xfs_ioctl32.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (c) 2004-2005 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(
  58. unsigned long arg)
  59. {
  60. xfs_fsop_bulkreq32_t __user *p32 = (void __user *)arg;
  61. xfs_fsop_bulkreq_t __user *p = compat_alloc_user_space(sizeof(*p));
  62. u32 addr;
  63. if (get_user(addr, &p32->lastip) ||
  64. put_user(compat_ptr(addr), &p->lastip) ||
  65. copy_in_user(&p->icount, &p32->icount, sizeof(s32)) ||
  66. get_user(addr, &p32->ubuffer) ||
  67. put_user(compat_ptr(addr), &p->ubuffer) ||
  68. get_user(addr, &p32->ocount) ||
  69. put_user(compat_ptr(addr), &p->ocount))
  70. return -EFAULT;
  71. return (unsigned long)p;
  72. }
  73. #endif
  74. STATIC long
  75. __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
  76. {
  77. int error;
  78. struct inode *inode = f->f_dentry->d_inode;
  79. vnode_t *vp = LINVFS_GET_VP(inode);
  80. switch (cmd) {
  81. case XFS_IOC_DIOINFO:
  82. case XFS_IOC_FSGEOMETRY_V1:
  83. case XFS_IOC_FSGEOMETRY:
  84. case XFS_IOC_GETVERSION:
  85. case XFS_IOC_GETXFLAGS:
  86. case XFS_IOC_SETXFLAGS:
  87. case XFS_IOC_FSGETXATTR:
  88. case XFS_IOC_FSSETXATTR:
  89. case XFS_IOC_FSGETXATTRA:
  90. case XFS_IOC_FSSETDM:
  91. case XFS_IOC_GETBMAP:
  92. case XFS_IOC_GETBMAPA:
  93. case XFS_IOC_GETBMAPX:
  94. /* not handled
  95. case XFS_IOC_FD_TO_HANDLE:
  96. case XFS_IOC_PATH_TO_HANDLE:
  97. case XFS_IOC_PATH_TO_HANDLE:
  98. case XFS_IOC_PATH_TO_FSHANDLE:
  99. case XFS_IOC_OPEN_BY_HANDLE:
  100. case XFS_IOC_FSSETDM_BY_HANDLE:
  101. case XFS_IOC_READLINK_BY_HANDLE:
  102. case XFS_IOC_ATTRLIST_BY_HANDLE:
  103. case XFS_IOC_ATTRMULTI_BY_HANDLE:
  104. */
  105. case XFS_IOC_FSCOUNTS:
  106. case XFS_IOC_SET_RESBLKS:
  107. case XFS_IOC_GET_RESBLKS:
  108. case XFS_IOC_FSGROWFSDATA:
  109. case XFS_IOC_FSGROWFSLOG:
  110. case XFS_IOC_FSGROWFSRT:
  111. case XFS_IOC_FREEZE:
  112. case XFS_IOC_THAW:
  113. case XFS_IOC_GOINGDOWN:
  114. case XFS_IOC_ERROR_INJECTION:
  115. case XFS_IOC_ERROR_CLEARALL:
  116. break;
  117. #ifndef BROKEN_X86_ALIGNMENT
  118. /* xfs_flock_t and xfs_bstat_t have wrong u32 vs u64 alignment */
  119. case XFS_IOC_ALLOCSP:
  120. case XFS_IOC_FREESP:
  121. case XFS_IOC_RESVSP:
  122. case XFS_IOC_UNRESVSP:
  123. case XFS_IOC_ALLOCSP64:
  124. case XFS_IOC_FREESP64:
  125. case XFS_IOC_RESVSP64:
  126. case XFS_IOC_UNRESVSP64:
  127. case XFS_IOC_SWAPEXT:
  128. break;
  129. case XFS_IOC_FSBULKSTAT_SINGLE:
  130. case XFS_IOC_FSBULKSTAT:
  131. case XFS_IOC_FSINUMBERS:
  132. arg = xfs_ioctl32_bulkstat(arg);
  133. break;
  134. #endif
  135. default:
  136. return -ENOIOCTLCMD;
  137. }
  138. VOP_IOCTL(vp, inode, f, mode, cmd, (void __user *)arg, error);
  139. VMODIFY(vp);
  140. return error;
  141. }
  142. long
  143. linvfs_compat_ioctl(
  144. struct file *f,
  145. unsigned cmd,
  146. unsigned long arg)
  147. {
  148. return __linvfs_compat_ioctl(0, f, cmd, arg);
  149. }
  150. long
  151. linvfs_compat_invis_ioctl(
  152. struct file *f,
  153. unsigned cmd,
  154. unsigned long arg)
  155. {
  156. return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg);
  157. }