aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2011-11-02 15:48:34 -0400
committerChris Mason <chris.mason@oracle.com>2011-11-06 03:08:49 -0500
commit740c3d226cbba6cd6a32adfb66809c94938f3e57 (patch)
tree375a5d2ee3bdc66f29e69e99c3691c3200407820 /fs
parent806468f8bf76a3cb2b626dd282946a6c9c0a50f0 (diff)
Btrfs: fix the new inspection ioctls for 32 bit compat
The new ioctls to follow backrefs are not clean for 32/64 bit compat. This reworks them for u64s everywhere. They are brand new, so there are no problems with changing the interface now. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/backref.c8
-rw-r--r--fs/btrfs/ioctl.c10
-rw-r--r--fs/btrfs/ioctl.h11
-rw-r--r--fs/btrfs/scrub.c2
4 files changed, 15 insertions, 16 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 2351df0de450..8855aad3929c 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -676,14 +676,14 @@ static int inode_to_path(u64 inum, struct btrfs_inode_ref *iref,
676 bytes_left = ipath->fspath->bytes_left > s_ptr ? 676 bytes_left = ipath->fspath->bytes_left > s_ptr ?
677 ipath->fspath->bytes_left - s_ptr : 0; 677 ipath->fspath->bytes_left - s_ptr : 0;
678 678
679 fspath_min = (char *)ipath->fspath->str + (i + 1) * s_ptr; 679 fspath_min = (char *)ipath->fspath->val + (i + 1) * s_ptr;
680 fspath = iref_to_path(ipath->fs_root, ipath->btrfs_path, iref, eb, 680 fspath = iref_to_path(ipath->fs_root, ipath->btrfs_path, iref, eb,
681 inum, fspath_min, bytes_left); 681 inum, fspath_min, bytes_left);
682 if (IS_ERR(fspath)) 682 if (IS_ERR(fspath))
683 return PTR_ERR(fspath); 683 return PTR_ERR(fspath);
684 684
685 if (fspath > fspath_min) { 685 if (fspath > fspath_min) {
686 ipath->fspath->str[i] = fspath; 686 ipath->fspath->val[i] = (u64)fspath;
687 ++ipath->fspath->elem_cnt; 687 ++ipath->fspath->elem_cnt;
688 ipath->fspath->bytes_left = fspath - fspath_min; 688 ipath->fspath->bytes_left = fspath - fspath_min;
689 } else { 689 } else {
@@ -698,9 +698,9 @@ static int inode_to_path(u64 inum, struct btrfs_inode_ref *iref,
698/* 698/*
699 * this dumps all file system paths to the inode into the ipath struct, provided 699 * this dumps all file system paths to the inode into the ipath struct, provided
700 * is has been created large enough. each path is zero-terminated and accessed 700 * is has been created large enough. each path is zero-terminated and accessed
701 * from ipath->fspath->str[i]. 701 * from ipath->fspath->val[i].
702 * when it returns, there are ipath->fspath->elem_cnt number of paths available 702 * when it returns, there are ipath->fspath->elem_cnt number of paths available
703 * in ipath->fspath->str[]. when the allocated space wasn't sufficient, the 703 * in ipath->fspath->val[]. when the allocated space wasn't sufficient, the
704 * number of missed paths in recored in ipath->fspath->elem_missed, otherwise, 704 * number of missed paths in recored in ipath->fspath->elem_missed, otherwise,
705 * it's zero. ipath->fspath->bytes_missing holds the number of bytes that would 705 * it's zero. ipath->fspath->bytes_missing holds the number of bytes that would
706 * have been needed to return all paths. 706 * have been needed to return all paths.
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index cc9893990341..4a34c472f126 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2895,7 +2895,7 @@ static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg)
2895{ 2895{
2896 int ret = 0; 2896 int ret = 0;
2897 int i; 2897 int i;
2898 unsigned long rel_ptr; 2898 u64 rel_ptr;
2899 int size; 2899 int size;
2900 struct btrfs_ioctl_ino_path_args *ipa = NULL; 2900 struct btrfs_ioctl_ino_path_args *ipa = NULL;
2901 struct inode_fs_paths *ipath = NULL; 2901 struct inode_fs_paths *ipath = NULL;
@@ -2930,11 +2930,11 @@ static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg)
2930 goto out; 2930 goto out;
2931 2931
2932 for (i = 0; i < ipath->fspath->elem_cnt; ++i) { 2932 for (i = 0; i < ipath->fspath->elem_cnt; ++i) {
2933 rel_ptr = ipath->fspath->str[i] - (char *)ipath->fspath->str; 2933 rel_ptr = ipath->fspath->val[i] - (u64)ipath->fspath->val;
2934 ipath->fspath->str[i] = (void *)rel_ptr; 2934 ipath->fspath->val[i] = rel_ptr;
2935 } 2935 }
2936 2936
2937 ret = copy_to_user(ipa->fspath, ipath->fspath, size); 2937 ret = copy_to_user((void *)ipa->fspath, (void *)ipath->fspath, size);
2938 if (ret) { 2938 if (ret) {
2939 ret = -EFAULT; 2939 ret = -EFAULT;
2940 goto out; 2940 goto out;
@@ -3017,7 +3017,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_root *root,
3017 if (ret < 0) 3017 if (ret < 0)
3018 goto out; 3018 goto out;
3019 3019
3020 ret = copy_to_user(loi->inodes, inodes, size); 3020 ret = copy_to_user((void *)loi->inodes, (void *)inodes, size);
3021 if (ret) 3021 if (ret)
3022 ret = -EFAULT; 3022 ret = -EFAULT;
3023 3023
diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index 2da30d4950e6..252ae9915de8 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
@@ -198,24 +198,23 @@ struct btrfs_data_container {
198 __u32 bytes_missing; /* out -- additional bytes needed for result */ 198 __u32 bytes_missing; /* out -- additional bytes needed for result */
199 __u32 elem_cnt; /* out */ 199 __u32 elem_cnt; /* out */
200 __u32 elem_missed; /* out */ 200 __u32 elem_missed; /* out */
201 union { 201 __u64 val[0]; /* out */
202 char *str[0]; /* out */
203 __u64 val[0]; /* out */
204 };
205}; 202};
206 203
207struct btrfs_ioctl_ino_path_args { 204struct btrfs_ioctl_ino_path_args {
208 __u64 inum; /* in */ 205 __u64 inum; /* in */
209 __u32 size; /* in */ 206 __u32 size; /* in */
210 __u64 reserved[4]; 207 __u64 reserved[4];
211 struct btrfs_data_container *fspath; /* out */ 208 /* struct btrfs_data_container *fspath; out */
209 __u64 fspath; /* out */
212}; 210};
213 211
214struct btrfs_ioctl_logical_ino_args { 212struct btrfs_ioctl_logical_ino_args {
215 __u64 logical; /* in */ 213 __u64 logical; /* in */
216 __u32 size; /* in */ 214 __u32 size; /* in */
217 __u64 reserved[4]; 215 __u64 reserved[4];
218 struct btrfs_data_container *inodes; /* out */ 216 /* struct btrfs_data_container *inodes; out */
217 __u64 inodes;
219}; 218};
220 219
221#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \ 220#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 94cd3a19e9c8..562dad10dee9 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -272,7 +272,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root, void *ctx)
272 swarn->logical, swarn->dev->name, 272 swarn->logical, swarn->dev->name,
273 (unsigned long long)swarn->sector, root, inum, offset, 273 (unsigned long long)swarn->sector, root, inum, offset,
274 min(isize - offset, (u64)PAGE_SIZE), nlink, 274 min(isize - offset, (u64)PAGE_SIZE), nlink,
275 ipath->fspath->str[i]); 275 (char *)ipath->fspath->val[i]);
276 276
277 free_ipath(ipath); 277 free_ipath(ipath);
278 return 0; 278 return 0;