aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorsandeen@sandeen.net <sandeen@sandeen.net>2008-11-25 22:20:11 -0500
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-12-02 01:15:36 -0500
commit2ee4fa5cb716eba104a4ef8efe159e1007a2aef6 (patch)
tree943c9966c8daa913dff42216bcdc1cc4c1c835da /fs
parent471d59103167c84f17b9bcfee22ed10b44ff206e (diff)
[XFS] Make the bulkstat_one compat ioctl handling more sane
Currently the compat formatter was handled by passing in "private_data" for the xfs_bulkstat_one formatter, which was really just another formatter... IMHO this got confusing. Instead, just make a new xfs_bulkstat_one_compat formatter for xfs_bulkstat, and call it via a wrapper. Also, don't translate the ioctl nrs into their native counterparts, that just clouds the issue; we're in a compat handler anyway, just switch on the 32-bit cmds. 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')
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c36
-rw-r--r--fs/xfs/xfs_itable.c24
-rw-r--r--fs/xfs/xfs_itable.h12
3 files changed, 56 insertions, 16 deletions
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index d1ac5d5c009b..a97022f2d9b0 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -223,14 +223,30 @@ xfs_bulkstat_one_fmt_compat(
223 return sizeof(*p32); 223 return sizeof(*p32);
224} 224}
225 225
226STATIC int
227xfs_bulkstat_one_compat(
228 xfs_mount_t *mp, /* mount point for filesystem */
229 xfs_ino_t ino, /* inode number to get data for */
230 void __user *buffer, /* buffer to place output in */
231 int ubsize, /* size of buffer */
232 void *private_data, /* my private data */
233 xfs_daddr_t bno, /* starting bno of inode cluster */
234 int *ubused, /* bytes used by me */
235 void *dibuff, /* on-disk inode buffer */
236 int *stat) /* BULKSTAT_RV_... */
237{
238 return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
239 xfs_bulkstat_one_fmt_compat, bno,
240 ubused, dibuff, stat);
241}
242
226/* copied from xfs_ioctl.c */ 243/* copied from xfs_ioctl.c */
227STATIC int 244STATIC int
228xfs_ioc_bulkstat_compat( 245xfs_compat_ioc_bulkstat(
229 xfs_mount_t *mp, 246 xfs_mount_t *mp,
230 unsigned int cmd, 247 unsigned int cmd,
231 void __user *arg) 248 compat_xfs_fsop_bulkreq_t __user *p32)
232{ 249{
233 compat_xfs_fsop_bulkreq_t __user *p32 = (void __user *)arg;
234 u32 addr; 250 u32 addr;
235 xfs_fsop_bulkreq_t bulkreq; 251 xfs_fsop_bulkreq_t bulkreq;
236 int count; /* # of records returned */ 252 int count; /* # of records returned */
@@ -267,14 +283,12 @@ xfs_ioc_bulkstat_compat(
267 if (bulkreq.ubuffer == NULL) 283 if (bulkreq.ubuffer == NULL)
268 return -XFS_ERROR(EINVAL); 284 return -XFS_ERROR(EINVAL);
269 285
270 if (cmd == XFS_IOC_FSINUMBERS) 286 if (cmd == XFS_IOC_FSINUMBERS_32)
271 error = xfs_inumbers(mp, &inlast, &count, 287 error = xfs_inumbers(mp, &inlast, &count,
272 bulkreq.ubuffer, xfs_inumbers_fmt_compat); 288 bulkreq.ubuffer, xfs_inumbers_fmt_compat);
273 else { 289 else {
274 /* declare a var to get a warning in case the type changes */
275 bulkstat_one_fmt_pf formatter = xfs_bulkstat_one_fmt_compat;
276 error = xfs_bulkstat(mp, &inlast, &count, 290 error = xfs_bulkstat(mp, &inlast, &count,
277 xfs_bulkstat_one, formatter, 291 xfs_bulkstat_one_compat, NULL,
278 sizeof(compat_xfs_bstat_t), bulkreq.ubuffer, 292 sizeof(compat_xfs_bstat_t), bulkreq.ubuffer,
279 BULKSTAT_FG_QUICK, &done); 293 BULKSTAT_FG_QUICK, &done);
280 } 294 }
@@ -422,9 +436,7 @@ xfs_compat_ioctl(
422 case XFS_IOC_FSBULKSTAT_32: 436 case XFS_IOC_FSBULKSTAT_32:
423 case XFS_IOC_FSBULKSTAT_SINGLE_32: 437 case XFS_IOC_FSBULKSTAT_SINGLE_32:
424 case XFS_IOC_FSINUMBERS_32: 438 case XFS_IOC_FSINUMBERS_32:
425 cmd = _NATIVE_IOC(cmd, struct xfs_fsop_bulkreq); 439 return xfs_compat_ioc_bulkstat(mp, cmd, arg);
426 return xfs_ioc_bulkstat_compat(XFS_I(inode)->i_mount,
427 cmd, (void __user*)arg);
428 case XFS_IOC_FD_TO_HANDLE_32: 440 case XFS_IOC_FD_TO_HANDLE_32:
429 case XFS_IOC_PATH_TO_HANDLE_32: 441 case XFS_IOC_PATH_TO_HANDLE_32:
430 case XFS_IOC_PATH_TO_FSHANDLE_32: { 442 case XFS_IOC_PATH_TO_FSHANDLE_32: {
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index d4c0de860124..7bd49b87160c 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -202,13 +202,13 @@ xfs_bulkstat_one_fmt(
202 * Return stat information for one inode. 202 * Return stat information for one inode.
203 * Return 0 if ok, else errno. 203 * Return 0 if ok, else errno.
204 */ 204 */
205int /* error status */ 205int /* error status */
206xfs_bulkstat_one( 206xfs_bulkstat_one_int(
207 xfs_mount_t *mp, /* mount point for filesystem */ 207 xfs_mount_t *mp, /* mount point for filesystem */
208 xfs_ino_t ino, /* inode number to get data for */ 208 xfs_ino_t ino, /* inode number to get data for */
209 void __user *buffer, /* buffer to place output in */ 209 void __user *buffer, /* buffer to place output in */
210 int ubsize, /* size of buffer */ 210 int ubsize, /* size of buffer */
211 void *private_data, /* my private data */ 211 bulkstat_one_fmt_pf formatter, /* formatter, copy to user */
212 xfs_daddr_t bno, /* starting bno of inode cluster */ 212 xfs_daddr_t bno, /* starting bno of inode cluster */
213 int *ubused, /* bytes used by me */ 213 int *ubused, /* bytes used by me */
214 void *dibuff, /* on-disk inode buffer */ 214 void *dibuff, /* on-disk inode buffer */
@@ -217,7 +217,6 @@ xfs_bulkstat_one(
217 xfs_bstat_t *buf; /* return buffer */ 217 xfs_bstat_t *buf; /* return buffer */
218 int error = 0; /* error value */ 218 int error = 0; /* error value */
219 xfs_dinode_t *dip; /* dinode inode pointer */ 219 xfs_dinode_t *dip; /* dinode inode pointer */
220 bulkstat_one_fmt_pf formatter = private_data ? : xfs_bulkstat_one_fmt;
221 220
222 dip = (xfs_dinode_t *)dibuff; 221 dip = (xfs_dinode_t *)dibuff;
223 *stat = BULKSTAT_RV_NOTHING; 222 *stat = BULKSTAT_RV_NOTHING;
@@ -255,6 +254,23 @@ xfs_bulkstat_one(
255 return error; 254 return error;
256} 255}
257 256
257int
258xfs_bulkstat_one(
259 xfs_mount_t *mp, /* mount point for filesystem */
260 xfs_ino_t ino, /* inode number to get data for */
261 void __user *buffer, /* buffer to place output in */
262 int ubsize, /* size of buffer */
263 void *private_data, /* my private data */
264 xfs_daddr_t bno, /* starting bno of inode cluster */
265 int *ubused, /* bytes used by me */
266 void *dibuff, /* on-disk inode buffer */
267 int *stat) /* BULKSTAT_RV_... */
268{
269 return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
270 xfs_bulkstat_one_fmt, bno,
271 ubused, dibuff, stat);
272}
273
258/* 274/*
259 * Test to see whether we can use the ondisk inode directly, based 275 * Test to see whether we can use the ondisk inode directly, based
260 * on the given bulkstat flags, filling in dipp accordingly. 276 * on the given bulkstat flags, filling in dipp accordingly.
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
index a1f18fce9b70..e210a4c06569 100644
--- a/fs/xfs/xfs_itable.h
+++ b/fs/xfs/xfs_itable.h
@@ -74,6 +74,18 @@ typedef int (*bulkstat_one_fmt_pf)( /* used size in bytes or negative error */
74 const xfs_bstat_t *buffer); /* buffer to read from */ 74 const xfs_bstat_t *buffer); /* buffer to read from */
75 75
76int 76int
77xfs_bulkstat_one_int(
78 xfs_mount_t *mp,
79 xfs_ino_t ino,
80 void __user *buffer,
81 int ubsize,
82 bulkstat_one_fmt_pf formatter,
83 xfs_daddr_t bno,
84 int *ubused,
85 void *dibuff,
86 int *stat);
87
88int
77xfs_bulkstat_one( 89xfs_bulkstat_one(
78 xfs_mount_t *mp, 90 xfs_mount_t *mp,
79 xfs_ino_t ino, 91 xfs_ino_t ino,