pioctl.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/time.h>
  12. #include <linux/fs.h>
  13. #include <linux/stat.h>
  14. #include <linux/errno.h>
  15. #include <linux/string.h>
  16. #include <linux/namei.h>
  17. #include <linux/module.h>
  18. #include <asm/uaccess.h>
  19. #include <linux/coda.h>
  20. #include <linux/coda_linux.h>
  21. #include <linux/coda_fs_i.h>
  22. #include <linux/coda_psdev.h>
  23. /* pioctl ops */
  24. static int coda_ioctl_permission(struct inode *inode, int mask,
  25. struct nameidata *nd);
  26. static int coda_pioctl(struct inode * inode, struct file * filp,
  27. unsigned int cmd, unsigned long user_data);
  28. /* exported from this file */
  29. const struct inode_operations coda_ioctl_inode_operations =
  30. {
  31. .permission = coda_ioctl_permission,
  32. .setattr = coda_setattr,
  33. };
  34. const struct file_operations coda_ioctl_operations = {
  35. .owner = THIS_MODULE,
  36. .ioctl = coda_pioctl,
  37. };
  38. /* the coda pioctl inode ops */
  39. static int coda_ioctl_permission(struct inode *inode, int mask,
  40. struct nameidata *nd)
  41. {
  42. return 0;
  43. }
  44. static int coda_pioctl(struct inode * inode, struct file * filp,
  45. unsigned int cmd, unsigned long user_data)
  46. {
  47. struct nameidata nd;
  48. int error;
  49. struct PioctlData data;
  50. struct inode *target_inode = NULL;
  51. struct coda_inode_info *cnp;
  52. /* get the Pioctl data arguments from user space */
  53. if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) {
  54. return -EINVAL;
  55. }
  56. /*
  57. * Look up the pathname. Note that the pathname is in
  58. * user memory, and namei takes care of this
  59. */
  60. if ( data.follow ) {
  61. error = user_path_walk(data.path, &nd);
  62. } else {
  63. error = user_path_walk_link(data.path, &nd);
  64. }
  65. if ( error ) {
  66. return error;
  67. } else {
  68. target_inode = nd.dentry->d_inode;
  69. }
  70. /* return if it is not a Coda inode */
  71. if ( target_inode->i_sb != inode->i_sb ) {
  72. path_release(&nd);
  73. return -EINVAL;
  74. }
  75. /* now proceed to make the upcall */
  76. cnp = ITOC(target_inode);
  77. error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
  78. path_release(&nd);
  79. return error;
  80. }