xfs_ioctl32.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #include <linux/config.h>
  33. #include <linux/compat.h>
  34. #include <linux/init.h>
  35. #include <linux/ioctl.h>
  36. #include <linux/ioctl32.h>
  37. #include <linux/syscalls.h>
  38. #include <linux/types.h>
  39. #include <linux/fs.h>
  40. #include <asm/uaccess.h>
  41. #include "xfs.h"
  42. #include "xfs_types.h"
  43. #include "xfs_fs.h"
  44. #include "xfs_vfs.h"
  45. #include "xfs_vnode.h"
  46. #include "xfs_dfrag.h"
  47. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  48. #define BROKEN_X86_ALIGNMENT
  49. #else
  50. typedef struct xfs_fsop_bulkreq32 {
  51. compat_uptr_t lastip; /* last inode # pointer */
  52. __s32 icount; /* count of entries in buffer */
  53. compat_uptr_t ubuffer; /* user buffer for inode desc. */
  54. __s32 ocount; /* output count pointer */
  55. } xfs_fsop_bulkreq32_t;
  56. static unsigned long
  57. xfs_ioctl32_bulkstat(unsigned long arg)
  58. {
  59. xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg;
  60. xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p));
  61. u32 addr;
  62. if (get_user(addr, &p32->lastip) ||
  63. put_user(compat_ptr(addr), &p->lastip) ||
  64. copy_in_user(&p->icount, &p32->icount, sizeof(s32)) ||
  65. get_user(addr, &p32->ubuffer) ||
  66. put_user(compat_ptr(addr), &p->ubuffer) ||
  67. get_user(addr, &p32->ocount) ||
  68. put_user(compat_ptr(addr), &p->ocount))
  69. return -EFAULT;
  70. return (unsigned long)p;
  71. }
  72. #endif
  73. static long
  74. __xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
  75. {
  76. int error;
  77. struct inode *inode = f->f_dentry->d_inode;
  78. vnode_t *vp = LINVFS_GET_VP(inode);
  79. switch (cmd) {
  80. case XFS_IOC_DIOINFO:
  81. case XFS_IOC_FSGEOMETRY_V1:
  82. case XFS_IOC_FSGEOMETRY:
  83. case XFS_IOC_GETVERSION:
  84. case XFS_IOC_GETXFLAGS:
  85. case XFS_IOC_SETXFLAGS:
  86. case XFS_IOC_FSGETXATTR:
  87. case XFS_IOC_FSSETXATTR:
  88. case XFS_IOC_FSGETXATTRA:
  89. case XFS_IOC_FSSETDM:
  90. case XFS_IOC_GETBMAP:
  91. case XFS_IOC_GETBMAPA:
  92. case XFS_IOC_GETBMAPX:
  93. /* not handled
  94. case XFS_IOC_FD_TO_HANDLE:
  95. case XFS_IOC_PATH_TO_HANDLE:
  96. case XFS_IOC_PATH_TO_HANDLE:
  97. case XFS_IOC_PATH_TO_FSHANDLE:
  98. case XFS_IOC_OPEN_BY_HANDLE:
  99. case XFS_IOC_FSSETDM_BY_HANDLE:
  100. case XFS_IOC_READLINK_BY_HANDLE:
  101. case XFS_IOC_ATTRLIST_BY_HANDLE:
  102. case XFS_IOC_ATTRMULTI_BY_HANDLE:
  103. */
  104. case XFS_IOC_FSCOUNTS:
  105. case XFS_IOC_SET_RESBLKS:
  106. case XFS_IOC_GET_RESBLKS:
  107. case XFS_IOC_FSGROWFSDATA:
  108. case XFS_IOC_FSGROWFSLOG:
  109. case XFS_IOC_FSGROWFSRT:
  110. case XFS_IOC_FREEZE:
  111. case XFS_IOC_THAW:
  112. case XFS_IOC_GOINGDOWN:
  113. case XFS_IOC_ERROR_INJECTION:
  114. case XFS_IOC_ERROR_CLEARALL:
  115. break;
  116. #ifndef BROKEN_X86_ALIGNMENT
  117. /* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */
  118. case XFS_IOC_ALLOCSP:
  119. case XFS_IOC_FREESP:
  120. case XFS_IOC_RESVSP:
  121. case XFS_IOC_UNRESVSP:
  122. case XFS_IOC_ALLOCSP64:
  123. case XFS_IOC_FREESP64:
  124. case XFS_IOC_RESVSP64:
  125. case XFS_IOC_UNRESVSP64:
  126. case XFS_IOC_SWAPEXT:
  127. break;
  128. case XFS_IOC_FSBULKSTAT_SINGLE:
  129. case XFS_IOC_FSBULKSTAT:
  130. case XFS_IOC_FSINUMBERS:
  131. arg = xfs_ioctl32_bulkstat(arg);
  132. break;
  133. #endif
  134. default:
  135. return -ENOIOCTLCMD;
  136. }
  137. VOP_IOCTL(vp, inode, f, mode, cmd, (void __user *)arg, error);
  138. VMODIFY(vp);
  139. return error;
  140. }
  141. long xfs_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg)
  142. {
  143. return __xfs_compat_ioctl(0, f, cmd, arg);
  144. }
  145. long xfs_compat_invis_ioctl(struct file *f, unsigned cmd, unsigned long arg)
  146. {
  147. return __xfs_compat_ioctl(IO_INVIS, f, cmd, arg);
  148. }