The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/coda/pioctl.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Pioctl operations for Coda.
    3  * Original version: (C) 1996 Peter Braam 
    4  * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University
    5  *
    6  * Carnegie Mellon encourages users of this code to contribute improvements
    7  * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>.
    8  */
    9 
   10 #include <linux/types.h>
   11 #include <linux/kernel.h>
   12 #include <linux/sched.h>
   13 #include <linux/fs.h>
   14 #include <linux/stat.h>
   15 #include <linux/errno.h>
   16 #include <linux/locks.h>
   17 #include <linux/string.h>
   18 #define __NO_VERSION__
   19 #include <linux/module.h>
   20 #include <asm/uaccess.h>
   21 
   22 #include <linux/coda.h>
   23 #include <linux/coda_linux.h>
   24 #include <linux/coda_fs_i.h>
   25 #include <linux/coda_psdev.h>
   26 
   27 /* pioctl ops */
   28 static int coda_ioctl_permission(struct inode *inode, int mask);
   29 static int coda_pioctl(struct inode * inode, struct file * filp, 
   30                        unsigned int cmd, unsigned long user_data);
   31 
   32 /* exported from this file */
   33 struct inode_operations coda_ioctl_inode_operations =
   34 {
   35         permission:     coda_ioctl_permission,
   36         setattr:        coda_notify_change,
   37 };
   38 
   39 struct file_operations coda_ioctl_operations = {
   40         owner:          THIS_MODULE,
   41         ioctl:          coda_pioctl,
   42 };
   43 
   44 /* the coda pioctl inode ops */
   45 static int coda_ioctl_permission(struct inode *inode, int mask)
   46 {
   47         return 0;
   48 }
   49 
   50 static int coda_pioctl(struct inode * inode, struct file * filp, 
   51                        unsigned int cmd, unsigned long user_data)
   52 {
   53         struct nameidata nd;
   54         int error;
   55         struct PioctlData data;
   56         struct inode *target_inode = NULL;
   57         struct coda_inode_info *cnp;
   58 
   59         /* get the Pioctl data arguments from user space */
   60         if (copy_from_user(&data, (int *)user_data, sizeof(data))) {
   61             return -EINVAL;
   62         }
   63        
   64         /* 
   65          * Look up the pathname. Note that the pathname is in 
   66          * user memory, and namei takes care of this
   67          */
   68         CDEBUG(D_PIOCTL, "namei, data.follow = %d\n", 
   69                data.follow);
   70         if ( data.follow ) {
   71                 error = user_path_walk(data.path, &nd);
   72         } else {
   73                 error = user_path_walk_link(data.path, &nd);
   74         }
   75                 
   76         if ( error ) {
   77                 CDEBUG(D_PIOCTL, "error: lookup fails.\n");
   78                 return error;
   79         } else {
   80                 target_inode = nd.dentry->d_inode;
   81         }
   82         
   83         CDEBUG(D_PIOCTL, "target ino: 0x%ld, dev: 0x%x\n",
   84                target_inode->i_ino, target_inode->i_dev);
   85 
   86         /* return if it is not a Coda inode */
   87         if ( target_inode->i_sb != inode->i_sb ) {
   88                 path_release(&nd);
   89                 return  -EINVAL;
   90         }
   91 
   92         /* now proceed to make the upcall */
   93         cnp = ITOC(target_inode);
   94 
   95         error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
   96 
   97         CDEBUG(D_PIOCTL, "ioctl on inode %ld\n", target_inode->i_ino);
   98         CDEBUG(D_DOWNCALL, "dput on ino: %ld, icount %d, dcount %d\n", target_inode->i_ino, 
   99                atomic_read(&target_inode->i_count), atomic_read(&nd.dentry->d_count));
  100         path_release(&nd);
  101         return error;
  102 }
  103 

Cache object: 86c50a9348d09695a486b50d7e92ff4a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.