VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100  1) // SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  2) /*
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  3)  * Pioctl operations for Coda.
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200  4)  * Original version: (C) 1996 Peter Braam
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  5)  * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  6)  *
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  7)  * Carnegie Mellon encourages users of this code to contribute improvements
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  8)  * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700  9)  */
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 10) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 11) #include <linux/types.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 12) #include <linux/kernel.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 13) #include <linux/time.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 14) #include <linux/fs.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 15) #include <linux/stat.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 16) #include <linux/errno.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 17) #include <linux/string.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 18) #include <linux/namei.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 19) #include <linux/module.h>
834b46c37a290 (Fabian Frederick   2014-08-08 14:20:33 -0700 20) #include <linux/uaccess.h>
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 21) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 22) #include <linux/coda.h>
8fc8b9df83138 (David Howells      2019-07-16 16:28:47 -0700 23) #include "coda_psdev.h"
31a203df9c109 (Al Viro            2011-01-12 16:36:09 -0500 24) #include "coda_linux.h"
31a203df9c109 (Al Viro            2011-01-12 16:36:09 -0500 25) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 26) /* pioctl ops */
549c7297717c3 (Christian Brauner  2021-01-21 14:19:43 +0100 27) static int coda_ioctl_permission(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner  2021-01-21 14:19:43 +0100 28) 				 struct inode *inode, int mask);
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 29) static long coda_pioctl(struct file *filp, unsigned int cmd,
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 30) 			unsigned long user_data);
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 31) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 32) /* exported from this file */
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 33) const struct inode_operations coda_ioctl_inode_operations = {
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 34) 	.permission	= coda_ioctl_permission,
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 35) 	.setattr	= coda_setattr,
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 36) };
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 37) 
4b6f5d20b04dc (Arjan van de Ven   2006-03-28 01:56:42 -0800 38) const struct file_operations coda_ioctl_operations = {
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 39) 	.unlocked_ioctl	= coda_pioctl,
6038f373a3dc1 (Arnd Bergmann      2010-08-15 18:52:59 +0200 40) 	.llseek		= noop_llseek,
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 41) };
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 42) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 43) /* the coda pioctl inode ops */
549c7297717c3 (Christian Brauner  2021-01-21 14:19:43 +0100 44) static int coda_ioctl_permission(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner  2021-01-21 14:19:43 +0100 45) 				 struct inode *inode, int mask)
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 46) {
f696a3659fc4b (Miklos Szeredi     2008-07-31 13:41:58 +0200 47) 	return (mask & MAY_EXEC) ? -EACCES : 0;
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 48) }
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 49) 
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 50) static long coda_pioctl(struct file *filp, unsigned int cmd,
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 51) 			unsigned long user_data)
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 52) {
2d8f30380ab8c (Al Viro            2008-07-22 09:59:21 -0400 53) 	struct path path;
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 54) 	int error;
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 55) 	struct PioctlData data;
496ad9aa8ef44 (Al Viro            2013-01-23 17:07:38 -0500 56) 	struct inode *inode = file_inode(filp);
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 57) 	struct inode *target_inode = NULL;
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 58) 	struct coda_inode_info *cnp;
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 59) 
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 60) 	/* get the Pioctl data arguments from user space */
f7cc02b871561 (Yoshihisa Abe      2010-10-25 02:03:45 -0400 61) 	if (copy_from_user(&data, (void __user *)user_data, sizeof(data)))
f7cc02b871561 (Yoshihisa Abe      2010-10-25 02:03:45 -0400 62) 		return -EINVAL;
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 63) 
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 64) 	/*
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 65) 	 * Look up the pathname. Note that the pathname is in
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 66) 	 * user memory, and namei takes care of this
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 67) 	 */
ce6595a28a15c (Al Viro            2019-07-14 16:42:44 -0400 68) 	error = user_path_at(AT_FDCWD, data.path,
ce6595a28a15c (Al Viro            2019-07-14 16:42:44 -0400 69) 			     data.follow ? LOOKUP_FOLLOW : 0, &path);
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 70) 	if (error)
f7cc02b871561 (Yoshihisa Abe      2010-10-25 02:03:45 -0400 71) 		return error;
f7cc02b871561 (Yoshihisa Abe      2010-10-25 02:03:45 -0400 72) 
2b0143b5c986b (David Howells      2015-03-17 22:25:59 +0000 73) 	target_inode = d_inode(path.dentry);
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 74) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 75) 	/* return if it is not a Coda inode */
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 76) 	if (target_inode->i_sb != inode->i_sb) {
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 77) 		error = -EINVAL;
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 78) 		goto out;
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 79) 	}
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 80) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 81) 	/* now proceed to make the upcall */
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 82) 	cnp = ITOC(target_inode);
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 83) 
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 84) 	error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
2ff82f8521892 (John Kacur         2010-05-05 15:15:34 +0200 85) out:
f7cc02b871561 (Yoshihisa Abe      2010-10-25 02:03:45 -0400 86) 	path_put(&path);
1977bb2ed8ffd (John Kacur         2010-05-05 15:15:35 +0200 87) 	return error;
^1da177e4c3f4 (Linus Torvalds     2005-04-16 15:20:36 -0700 88) }