Files
linux-apfs/fs/coda/pioctl.c
T

91 lines
2.1 KiB
C
Raw Normal View History

2005-04-16 15:20:36 -07:00
/*
* Pioctl operations for Coda.
* Original version: (C) 1996 Peter Braam
2005-04-16 15:20:36 -07:00
* Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
*
* Carnegie Mellon encourages users of this code to contribute improvements
* to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
*/
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/namei.h>
#include <linux/module.h>
2014-08-08 14:20:33 -07:00
#include <linux/uaccess.h>
2005-04-16 15:20:36 -07:00
#include <linux/coda.h>
#include <linux/coda_psdev.h>
#include "coda_linux.h"
2005-04-16 15:20:36 -07:00
/* pioctl ops */
static int coda_ioctl_permission(struct inode *inode, int mask);
2010-05-05 15:15:34 +02:00
static long coda_pioctl(struct file *filp, unsigned int cmd,
unsigned long user_data);
2005-04-16 15:20:36 -07:00
/* exported from this file */
const struct inode_operations coda_ioctl_inode_operations = {
2005-04-16 15:20:36 -07:00
.permission = coda_ioctl_permission,
.setattr = coda_setattr,
};
const struct file_operations coda_ioctl_operations = {
2005-04-16 15:20:36 -07:00
.owner = THIS_MODULE,
2010-05-05 15:15:34 +02:00
.unlocked_ioctl = coda_pioctl,
2010-08-15 18:52:59 +02:00
.llseek = noop_llseek,
2005-04-16 15:20:36 -07:00
};
/* the coda pioctl inode ops */
static int coda_ioctl_permission(struct inode *inode, int mask)
2005-04-16 15:20:36 -07:00
{
return (mask & MAY_EXEC) ? -EACCES : 0;
2005-04-16 15:20:36 -07:00
}
2010-05-05 15:15:34 +02:00
static long coda_pioctl(struct file *filp, unsigned int cmd,
unsigned long user_data)
2005-04-16 15:20:36 -07:00
{
2008-07-22 09:59:21 -04:00
struct path path;
int error;
2005-04-16 15:20:36 -07:00
struct PioctlData data;
2013-01-23 17:07:38 -05:00
struct inode *inode = file_inode(filp);
struct inode *target_inode = NULL;
struct coda_inode_info *cnp;
2005-04-16 15:20:36 -07:00
/* get the Pioctl data arguments from user space */
2010-10-25 02:03:45 -04:00
if (copy_from_user(&data, (void __user *)user_data, sizeof(data)))
return -EINVAL;
/*
* Look up the pathname. Note that the pathname is in
* user memory, and namei takes care of this
*/
2010-05-05 15:15:34 +02:00
if (data.follow)
error = user_path(data.path, &path);
2010-05-05 15:15:34 +02:00
else
error = user_lpath(data.path, &path);
2010-05-05 15:15:34 +02:00
if (error)
2010-10-25 02:03:45 -04:00
return error;
target_inode = d_inode(path.dentry);
2010-05-05 15:15:34 +02:00
2005-04-16 15:20:36 -07:00
/* return if it is not a Coda inode */
if (target_inode->i_sb != inode->i_sb) {
2010-05-05 15:15:34 +02:00
error = -EINVAL;
goto out;
2005-04-16 15:20:36 -07:00
}
/* now proceed to make the upcall */
cnp = ITOC(target_inode);
2005-04-16 15:20:36 -07:00
error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
2010-05-05 15:15:34 +02:00
out:
2010-10-25 02:03:45 -04:00
path_put(&path);
return error;
2005-04-16 15:20:36 -07:00
}