Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124912
b: refs/heads/master
c: e94fc4a
h: refs/heads/master
v: v3
  • Loading branch information
sandeen@sandeen.net authored and Lachlan McIlroy committed Dec 2, 2008
1 parent 36c2bb9 commit 8c3360b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d5547f9feea459dfc9e7313bd1d561394e2c129f
refs/heads/master: e94fc4a43e5c39f689e83caf6d2f0939081f5e6b
61 changes: 56 additions & 5 deletions trunk/fs/xfs/linux-2.6/xfs_ioctl32.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,50 @@ xfs_inumbers_fmt_compat(
#define xfs_inumbers_fmt_compat xfs_inumbers_fmt
#endif

STATIC int
xfs_ioctl32_bstime_copyin(
xfs_bstime_t *bstime,
compat_xfs_bstime_t __user *bstime32)
{
compat_time_t sec32; /* tv_sec differs on 64 vs. 32 */

if (get_user(sec32, &bstime32->tv_sec) ||
get_user(bstime->tv_nsec, &bstime32->tv_nsec))
return -XFS_ERROR(EFAULT);
bstime->tv_sec = sec32;
return 0;
}

/* xfs_bstat_t has differing alignment on intel, & bstime_t sizes everywhere */
STATIC int
xfs_ioctl32_bstat_copyin(
xfs_bstat_t *bstat,
compat_xfs_bstat_t __user *bstat32)
{
if (get_user(bstat->bs_ino, &bstat32->bs_ino) ||
get_user(bstat->bs_mode, &bstat32->bs_mode) ||
get_user(bstat->bs_nlink, &bstat32->bs_nlink) ||
get_user(bstat->bs_uid, &bstat32->bs_uid) ||
get_user(bstat->bs_gid, &bstat32->bs_gid) ||
get_user(bstat->bs_rdev, &bstat32->bs_rdev) ||
get_user(bstat->bs_blksize, &bstat32->bs_blksize) ||
get_user(bstat->bs_size, &bstat32->bs_size) ||
xfs_ioctl32_bstime_copyin(&bstat->bs_atime, &bstat32->bs_atime) ||
xfs_ioctl32_bstime_copyin(&bstat->bs_mtime, &bstat32->bs_mtime) ||
xfs_ioctl32_bstime_copyin(&bstat->bs_ctime, &bstat32->bs_ctime) ||
get_user(bstat->bs_blocks, &bstat32->bs_size) ||
get_user(bstat->bs_xflags, &bstat32->bs_size) ||
get_user(bstat->bs_extsize, &bstat32->bs_extsize) ||
get_user(bstat->bs_extents, &bstat32->bs_extents) ||
get_user(bstat->bs_gen, &bstat32->bs_gen) ||
get_user(bstat->bs_projid, &bstat32->bs_projid) ||
get_user(bstat->bs_dmevmask, &bstat32->bs_dmevmask) ||
get_user(bstat->bs_dmstate, &bstat32->bs_dmstate) ||
get_user(bstat->bs_aextents, &bstat32->bs_aextents))
return -XFS_ERROR(EFAULT);
return 0;
}

/* XFS_IOC_FSBULKSTAT and friends */

STATIC int
Expand Down Expand Up @@ -292,6 +336,18 @@ xfs_compat_ioctl(
case XFS_IOC_GETVERSION_32:
cmd = _NATIVE_IOC(cmd, long);
break;
case XFS_IOC_SWAPEXT: {
struct xfs_swapext sxp;
struct compat_xfs_swapext __user *sxu = arg;

/* Bulk copy in up to the sx_stat field, then grab bstat */
if (copy_from_user(&sxp, sxu,
offsetof(xfs_swapext_t, sx_stat)) ||
xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat))
return -XFS_ERROR(EFAULT);
error = xfs_swapext(&sxp);
return -error;
}
#ifdef BROKEN_X86_ALIGNMENT
/* xfs_flock_t has wrong u32 vs u64 alignment */
case XFS_IOC_ALLOCSP_32:
Expand Down Expand Up @@ -322,11 +378,6 @@ xfs_compat_ioctl(
case XFS_IOC_UNRESVSP64:
case XFS_IOC_FSGEOMETRY_V1:
break;

/* xfs_bstat_t still has wrong u32 vs u64 alignment */
case XFS_IOC_SWAPEXT:
break;

#endif
case XFS_IOC_FSBULKSTAT_32:
case XFS_IOC_FSBULKSTAT_SINGLE_32:
Expand Down
13 changes: 13 additions & 0 deletions trunk/fs/xfs/linux-2.6/xfs_ioctl32.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ typedef struct compat_xfs_fsop_handlereq {
#define XFS_IOC_READLINK_BY_HANDLE_32 \
_IOWR('X', 108, struct compat_xfs_fsop_handlereq)

/* The bstat field in the swapext struct needs translation */
typedef struct compat_xfs_swapext {
__int64_t sx_version; /* version */
__int64_t sx_fdtarget; /* fd of target file */
__int64_t sx_fdtmp; /* fd of tmp file */
xfs_off_t sx_offset; /* offset into file */
xfs_off_t sx_length; /* leng from offset */
char sx_pad[16]; /* pad space, unused */
compat_xfs_bstat_t sx_stat; /* stat of target b4 copy */
} __compat_packed compat_xfs_swapext_t;

#define XFS_IOC_SWAPEXT_32 _IOWR('X', 109, struct compat_xfs_swapext)

#ifdef BROKEN_X86_ALIGNMENT
/* on ia32 l_start is on a 32-bit boundary */
typedef struct compat_xfs_flock64 {
Expand Down

0 comments on commit 8c3360b

Please sign in to comment.