Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Pioctl operations for Coda.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Original version: (C) 1996 Peter Braam
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Carnegie Mellon encourages users of this code to contribute improvements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/coda.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "coda_psdev.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "coda_linux.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* pioctl ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static int coda_ioctl_permission(struct inode *inode, int mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static long coda_pioctl(struct file *filp, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 			unsigned long user_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* exported from this file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) const struct inode_operations coda_ioctl_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	.permission	= coda_ioctl_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	.setattr	= coda_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) const struct file_operations coda_ioctl_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	.unlocked_ioctl	= coda_pioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	.llseek		= noop_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* the coda pioctl inode ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static int coda_ioctl_permission(struct inode *inode, int mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	return (mask & MAY_EXEC) ? -EACCES : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static long coda_pioctl(struct file *filp, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 			unsigned long user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	struct path path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	struct PioctlData data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	struct inode *inode = file_inode(filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	struct inode *target_inode = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	struct coda_inode_info *cnp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	/* get the Pioctl data arguments from user space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	if (copy_from_user(&data, (void __user *)user_data, sizeof(data)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	 * Look up the pathname. Note that the pathname is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	 * user memory, and namei takes care of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	error = user_path_at(AT_FDCWD, data.path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 			     data.follow ? LOOKUP_FOLLOW : 0, &path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	target_inode = d_inode(path.dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	/* return if it is not a Coda inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	if (target_inode->i_sb != inode->i_sb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 		error = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	/* now proceed to make the upcall */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	cnp = ITOC(target_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	path_put(&path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }