aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-02-06 03:57:56 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-13 10:28:49 -0500
commit49418b2c28c901294f8b36ff14c766c9458c3623 (patch)
tree134dabb2d9f0b0662d64feebc0fd667e63a3762f
parentdbfb98af18194cff87d4c1dea8d43faf14eae2e7 (diff)
cifs: Modify struct cifs_unix_set_info_args to hold a kuid_t and a kgid_t
Use INVALID_UID and INVALID_GID instead of NO_CHANGE_64 to indicate the value should not be changed. In cifs_fill_unix_set_info convert from kuids and kgids into uids and gids that will fit in FILE_UNIX_BASIC_INFO. Cc: Steve French <smfrench@gmail.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r--fs/cifs/cifsproto.h4
-rw-r--r--fs/cifs/cifssmb.c10
-rw-r--r--fs/cifs/dir.c18
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/cifs/inode.c14
5 files changed, 28 insertions, 22 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index feb9b6e2ab5a..f450f0683ddd 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -305,8 +305,8 @@ struct cifs_unix_set_info_args {
305 __u64 atime; 305 __u64 atime;
306 __u64 mtime; 306 __u64 mtime;
307 __u64 mode; 307 __u64 mode;
308 __u64 uid; 308 kuid_t uid;
309 __u64 gid; 309 kgid_t gid;
310 dev_t device; 310 dev_t device;
311}; 311};
312 312
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 76d0d2998850..00e12f2d626b 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -5819,8 +5819,14 @@ static void
5819cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset, 5819cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
5820 const struct cifs_unix_set_info_args *args) 5820 const struct cifs_unix_set_info_args *args)
5821{ 5821{
5822 u64 uid = NO_CHANGE_64, gid = NO_CHANGE_64;
5822 u64 mode = args->mode; 5823 u64 mode = args->mode;
5823 5824
5825 if (uid_valid(args->uid))
5826 uid = from_kuid(&init_user_ns, args->uid);
5827 if (gid_valid(args->gid))
5828 gid = from_kgid(&init_user_ns, args->gid);
5829
5824 /* 5830 /*
5825 * Samba server ignores set of file size to zero due to bugs in some 5831 * Samba server ignores set of file size to zero due to bugs in some
5826 * older clients, but we should be precise - we use SetFileSize to 5832 * older clients, but we should be precise - we use SetFileSize to
@@ -5833,8 +5839,8 @@ cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
5833 data_offset->LastStatusChange = cpu_to_le64(args->ctime); 5839 data_offset->LastStatusChange = cpu_to_le64(args->ctime);
5834 data_offset->LastAccessTime = cpu_to_le64(args->atime); 5840 data_offset->LastAccessTime = cpu_to_le64(args->atime);
5835 data_offset->LastModificationTime = cpu_to_le64(args->mtime); 5841 data_offset->LastModificationTime = cpu_to_le64(args->mtime);
5836 data_offset->Uid = cpu_to_le64(args->uid); 5842 data_offset->Uid = cpu_to_le64(uid);
5837 data_offset->Gid = cpu_to_le64(args->gid); 5843 data_offset->Gid = cpu_to_le64(gid);
5838 /* better to leave device as zero when it is */ 5844 /* better to leave device as zero when it is */
5839 data_offset->DevMajor = cpu_to_le64(MAJOR(args->device)); 5845 data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
5840 data_offset->DevMinor = cpu_to_le64(MINOR(args->device)); 5846 data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 8719bbe0dcc3..1cd016217448 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -342,14 +342,14 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
342 342
343 *created |= FILE_CREATED; 343 *created |= FILE_CREATED;
344 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 344 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
345 args.uid = (__u64) current_fsuid(); 345 args.uid = current_fsuid();
346 if (inode->i_mode & S_ISGID) 346 if (inode->i_mode & S_ISGID)
347 args.gid = (__u64) inode->i_gid; 347 args.gid = inode->i_gid;
348 else 348 else
349 args.gid = (__u64) current_fsgid(); 349 args.gid = current_fsgid();
350 } else { 350 } else {
351 args.uid = NO_CHANGE_64; 351 args.uid = INVALID_UID; /* no change */
352 args.gid = NO_CHANGE_64; 352 args.gid = INVALID_GID; /* no change */
353 } 353 }
354 CIFSSMBUnixSetFileInfo(xid, tcon, &args, fid->netfid, 354 CIFSSMBUnixSetFileInfo(xid, tcon, &args, fid->netfid,
355 current->tgid); 355 current->tgid);
@@ -588,11 +588,11 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
588 .device = device_number, 588 .device = device_number,
589 }; 589 };
590 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 590 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
591 args.uid = (__u64) current_fsuid(); 591 args.uid = current_fsuid();
592 args.gid = (__u64) current_fsgid(); 592 args.gid = current_fsgid();
593 } else { 593 } else {
594 args.uid = NO_CHANGE_64; 594 args.uid = INVALID_UID; /* no change */
595 args.gid = NO_CHANGE_64; 595 args.gid = INVALID_GID; /* no change */
596 } 596 }
597 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args, 597 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
598 cifs_sb->local_nls, 598 cifs_sb->local_nls,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 0a6677ba212b..b9baf5f66349 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -487,8 +487,8 @@ int cifs_open(struct inode *inode, struct file *file)
487 */ 487 */
488 struct cifs_unix_set_info_args args = { 488 struct cifs_unix_set_info_args args = {
489 .mode = inode->i_mode, 489 .mode = inode->i_mode,
490 .uid = NO_CHANGE_64, 490 .uid = INVALID_UID, /* no change */
491 .gid = NO_CHANGE_64, 491 .gid = INVALID_GID, /* no change */
492 .ctime = NO_CHANGE_64, 492 .ctime = NO_CHANGE_64,
493 .atime = NO_CHANGE_64, 493 .atime = NO_CHANGE_64,
494 .mtime = NO_CHANGE_64, 494 .mtime = NO_CHANGE_64,
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index d4cf7509c106..737643940540 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1249,14 +1249,14 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
1249 .device = 0, 1249 .device = 0,
1250 }; 1250 };
1251 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 1251 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
1252 args.uid = (__u64)current_fsuid(); 1252 args.uid = current_fsuid();
1253 if (parent->i_mode & S_ISGID) 1253 if (parent->i_mode & S_ISGID)
1254 args.gid = (__u64)parent->i_gid; 1254 args.gid = parent->i_gid;
1255 else 1255 else
1256 args.gid = (__u64)current_fsgid(); 1256 args.gid = current_fsgid();
1257 } else { 1257 } else {
1258 args.uid = NO_CHANGE_64; 1258 args.uid = INVALID_UID; /* no change */
1259 args.gid = NO_CHANGE_64; 1259 args.gid = INVALID_GID; /* no change */
1260 } 1260 }
1261 CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args, 1261 CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
1262 cifs_sb->local_nls, 1262 cifs_sb->local_nls,
@@ -2017,12 +2017,12 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
2017 if (attrs->ia_valid & ATTR_UID) 2017 if (attrs->ia_valid & ATTR_UID)
2018 args->uid = attrs->ia_uid; 2018 args->uid = attrs->ia_uid;
2019 else 2019 else
2020 args->uid = NO_CHANGE_64; 2020 args->uid = INVALID_UID; /* no change */
2021 2021
2022 if (attrs->ia_valid & ATTR_GID) 2022 if (attrs->ia_valid & ATTR_GID)
2023 args->gid = attrs->ia_gid; 2023 args->gid = attrs->ia_gid;
2024 else 2024 else
2025 args->gid = NO_CHANGE_64; 2025 args->gid = INVALID_GID; /* no change */
2026 2026
2027 if (attrs->ia_valid & ATTR_ATIME) 2027 if (attrs->ia_valid & ATTR_ATIME)
2028 args->atime = cifs_UnixTimeToNT(attrs->ia_atime); 2028 args->atime = cifs_UnixTimeToNT(attrs->ia_atime);