aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_ioctl32.c
diff options
context:
space:
mode:
authorsandeen@sandeen.net <sandeen@sandeen.net>2008-11-25 22:20:09 -0500
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-12-02 01:10:04 -0500
commite94fc4a43e5c39f689e83caf6d2f0939081f5e6b (patch)
tree8c076b71376488d7829f6c992d5e5ee545be9e19 /fs/xfs/linux-2.6/xfs_ioctl32.c
parentd5547f9feea459dfc9e7313bd1d561394e2c129f (diff)
[XFS] Add compat handlers for swapext ioctl
The big hitter here was the bstat field, which contains different sized time_t on 32 vs. 64 bit. Add a copyin function to translate the 32-bit arg to 64-bit, and call the swapext ioctl helper. Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_ioctl32.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c61
1 files changed, 56 insertions, 5 deletions
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index 35edc054fb99..132f3dd2c7e8 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -108,6 +108,50 @@ xfs_inumbers_fmt_compat(
108#define xfs_inumbers_fmt_compat xfs_inumbers_fmt 108#define xfs_inumbers_fmt_compat xfs_inumbers_fmt
109#endif 109#endif
110 110
111STATIC int
112xfs_ioctl32_bstime_copyin(
113 xfs_bstime_t *bstime,
114 compat_xfs_bstime_t __user *bstime32)
115{
116 compat_time_t sec32; /* tv_sec differs on 64 vs. 32 */
117
118 if (get_user(sec32, &bstime32->tv_sec) ||
119 get_user(bstime->tv_nsec, &bstime32->tv_nsec))
120 return -XFS_ERROR(EFAULT);
121 bstime->tv_sec = sec32;
122 return 0;
123}
124
125/* xfs_bstat_t has differing alignment on intel, & bstime_t sizes everywhere */
126STATIC int
127xfs_ioctl32_bstat_copyin(
128 xfs_bstat_t *bstat,
129 compat_xfs_bstat_t __user *bstat32)
130{
131 if (get_user(bstat->bs_ino, &bstat32->bs_ino) ||
132 get_user(bstat->bs_mode, &bstat32->bs_mode) ||
133 get_user(bstat->bs_nlink, &bstat32->bs_nlink) ||
134 get_user(bstat->bs_uid, &bstat32->bs_uid) ||
135 get_user(bstat->bs_gid, &bstat32->bs_gid) ||
136 get_user(bstat->bs_rdev, &bstat32->bs_rdev) ||
137 get_user(bstat->bs_blksize, &bstat32->bs_blksize) ||
138 get_user(bstat->bs_size, &bstat32->bs_size) ||
139 xfs_ioctl32_bstime_copyin(&bstat->bs_atime, &bstat32->bs_atime) ||
140 xfs_ioctl32_bstime_copyin(&bstat->bs_mtime, &bstat32->bs_mtime) ||
141 xfs_ioctl32_bstime_copyin(&bstat->bs_ctime, &bstat32->bs_ctime) ||
142 get_user(bstat->bs_blocks, &bstat32->bs_size) ||
143 get_user(bstat->bs_xflags, &bstat32->bs_size) ||
144 get_user(bstat->bs_extsize, &bstat32->bs_extsize) ||
145 get_user(bstat->bs_extents, &bstat32->bs_extents) ||
146 get_user(bstat->bs_gen, &bstat32->bs_gen) ||
147 get_user(bstat->bs_projid, &bstat32->bs_projid) ||
148 get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) ||
149 get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) ||
150 get_user(bstat->bs_aextents, &bstat32->bs_aextents))
151 return -XFS_ERROR(EFAULT);
152 return 0;
153}
154
111/* XFS_IOC_FSBULKSTAT and friends */ 155/* XFS_IOC_FSBULKSTAT and friends */
112 156
113STATIC int 157STATIC int
@@ -292,6 +336,18 @@ xfs_compat_ioctl(
292 case XFS_IOC_GETVERSION_32: 336 case XFS_IOC_GETVERSION_32:
293 cmd = _NATIVE_IOC(cmd, long); 337 cmd = _NATIVE_IOC(cmd, long);
294 break; 338 break;
339 case XFS_IOC_SWAPEXT: {
340 struct xfs_swapext sxp;
341 struct compat_xfs_swapext __user *sxu = arg;
342
343 /* Bulk copy in up to the sx_stat field, then grab bstat */
344 if (copy_from_user(&sxp, sxu,
345 offsetof(xfs_swapext_t, sx_stat)) ||
346 xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat))
347 return -XFS_ERROR(EFAULT);
348 error = xfs_swapext(&sxp);
349 return -error;
350 }
295#ifdef BROKEN_X86_ALIGNMENT 351#ifdef BROKEN_X86_ALIGNMENT
296 /* xfs_flock_t has wrong u32 vs u64 alignment */ 352 /* xfs_flock_t has wrong u32 vs u64 alignment */
297 case XFS_IOC_ALLOCSP_32: 353 case XFS_IOC_ALLOCSP_32:
@@ -322,11 +378,6 @@ xfs_compat_ioctl(
322 case XFS_IOC_UNRESVSP64: 378 case XFS_IOC_UNRESVSP64:
323 case XFS_IOC_FSGEOMETRY_V1: 379 case XFS_IOC_FSGEOMETRY_V1:
324 break; 380 break;
325
326 /* xfs_bstat_t still has wrong u32 vs u64 alignment */
327 case XFS_IOC_SWAPEXT:
328 break;
329
330#endif 381#endif
331 case XFS_IOC_FSBULKSTAT_32: 382 case XFS_IOC_FSBULKSTAT_32:
332 case XFS_IOC_FSBULKSTAT_SINGLE_32: 383 case XFS_IOC_FSBULKSTAT_SINGLE_32: