]> err.no Git - linux-2.6/commitdiff
bundle up Unix SET_PATH_INFO args into a struct and change name
authorJeff Layton <jlayton@redhat.com>
Sat, 2 Aug 2008 11:26:12 +0000 (07:26 -0400)
committerSteve French <sfrench@us.ibm.com>
Wed, 6 Aug 2008 04:17:20 +0000 (04:17 +0000)
We'd like to be able to use the unix SET_PATH_INFO_BASIC args to set
file times as well, but that makes the argument list rather long. Bundle
up the args for unix SET_PATH_INFO call into a struct. For now, we don't
actually use the times fields anywhere. That will be done in a follow-on
patch.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifspdu.h
fs/cifs/cifsproto.h
fs/cifs/cifssmb.c
fs/cifs/dir.c
fs/cifs/file.c
fs/cifs/inode.c

index 409abce1273246374560f8753baf5638b0d75884..d2a073edd1b8877246b2c9149a0963139317b65a 100644 (file)
  */
 #define CIFS_NO_HANDLE        0xFFFF
 
-#define NO_CHANGE_64          cpu_to_le64(0xFFFFFFFFFFFFFFFFULL)
+#define NO_CHANGE_64          0xFFFFFFFFFFFFFFFFULL
 #define NO_CHANGE_32          0xFFFFFFFFUL
 
 /* IPC$ in ASCII */
index b9f5e935f821641f3e347f9026f35f527946bdfc..e65ff9849092fc082add7e6a2136fab97d8f51d8 100644 (file)
@@ -191,9 +191,20 @@ extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon,
 extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
                         __u64 size, __u16 fileHandle, __u32 opener_pid,
                        bool AllocSizeFlag);
-extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
-                       char *full_path, __u64 mode, __u64 uid,
-                       __u64 gid, dev_t dev,
+
+struct cifs_unix_set_info_args {
+       __u64   ctime;
+       __u64   atime;
+       __u64   mtime;
+       __u64   mode;
+       __u64   uid;
+       __u64   gid;
+       dev_t   device;
+};
+
+extern int CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *pTcon,
+                       char *fileName,
+                       const struct cifs_unix_set_info_args *args,
                        const struct nls_table *nls_codepage,
                        int remap_special_chars);
 
index c621ffa2ca90632173d83b59b4eb203dadbc496c..ced8eaa9d37da7cb12280113f13f23059982f3e9 100644 (file)
@@ -5013,10 +5013,9 @@ SetAttrLgcyRetry:
 #endif /* temporarily unneeded SetAttr legacy function */
 
 int
-CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
-                   char *fileName, __u64 mode, __u64 uid, __u64 gid,
-                   dev_t device, const struct nls_table *nls_codepage,
-                   int remap)
+CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *tcon, char *fileName,
+                  const struct cifs_unix_set_info_args *args, 
+                  const struct nls_table *nls_codepage, int remap)
 {
        TRANSACTION2_SPI_REQ *pSMB = NULL;
        TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -5025,6 +5024,7 @@ CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
        int bytes_returned = 0;
        FILE_UNIX_BASIC_INFO *data_offset;
        __u16 params, param_offset, offset, count, byte_count;
+       __u64 mode = args->mode;
 
        cFYI(1, ("In SetUID/GID/Mode"));
 setPermsRetry:
@@ -5080,16 +5080,16 @@ setPermsRetry:
        set file size and do not want to truncate file size to zero
        accidently as happened on one Samba server beta by putting
        zero instead of -1 here */
-       data_offset->EndOfFile = NO_CHANGE_64;
-       data_offset->NumOfBytes = NO_CHANGE_64;
-       data_offset->LastStatusChange = NO_CHANGE_64;
-       data_offset->LastAccessTime = NO_CHANGE_64;
-       data_offset->LastModificationTime = NO_CHANGE_64;
-       data_offset->Uid = cpu_to_le64(uid);
-       data_offset->Gid = cpu_to_le64(gid);
+       data_offset->EndOfFile = cpu_to_le64(NO_CHANGE_64);
+       data_offset->NumOfBytes = cpu_to_le64(NO_CHANGE_64);
+       data_offset->LastStatusChange = cpu_to_le64(args->ctime);
+       data_offset->LastAccessTime = cpu_to_le64(args->atime);
+       data_offset->LastModificationTime = cpu_to_le64(args->mtime);
+       data_offset->Uid = cpu_to_le64(args->uid);
+       data_offset->Gid = cpu_to_le64(args->gid);
        /* better to leave device as zero when it is  */
-       data_offset->DevMajor = cpu_to_le64(MAJOR(device));
-       data_offset->DevMinor = cpu_to_le64(MINOR(device));
+       data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
+       data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
        data_offset->Permissions = cpu_to_le64(mode);
 
        if (S_ISREG(mode))
index fb69c1fa85c975d17b16122fdfbf74a9e835e949..634cf330fe04a4c746c60b9b57c652a19f6ab905 100644 (file)
@@ -226,23 +226,26 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                /* If Open reported that we actually created a file
                then we now have to set the mode if possible */
                if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
+                       struct cifs_unix_set_info_args args = {
+                               .mode   = mode,
+                               .ctime  = NO_CHANGE_64,
+                               .atime  = NO_CHANGE_64,
+                               .mtime  = NO_CHANGE_64,
+                               .device = 0,
+                       };
+
                        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
-                               CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
-                                       (__u64)current->fsuid,
-                                       (__u64)current->fsgid,
-                                       0 /* dev */,
-                                       cifs_sb->local_nls,
-                                       cifs_sb->mnt_cifs_flags &
-                                               CIFS_MOUNT_MAP_SPECIAL_CHR);
+                               args.uid = (__u64) current->fsuid;
+                               args.gid = (__u64) current->fsgid;
                        } else {
-                               CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
-                                       (__u64)-1,
-                                       (__u64)-1,
-                                       0 /* dev */,
-                                       cifs_sb->local_nls,
-                                       cifs_sb->mnt_cifs_flags &
-                                               CIFS_MOUNT_MAP_SPECIAL_CHR);
+                               args.uid = NO_CHANGE_64;
+                               args.gid = NO_CHANGE_64;
                        }
+
+                       CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
+                               cifs_sb->local_nls,
+                               cifs_sb->mnt_cifs_flags &
+                                       CIFS_MOUNT_MAP_SPECIAL_CHR);
                } else {
                        /* BB implement mode setting via Windows security
                           descriptors e.g. */
@@ -357,21 +360,24 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
        if (full_path == NULL)
                rc = -ENOMEM;
        else if (pTcon->unix_ext) {
-               mode &= ~current->fs->umask;
+               struct cifs_unix_set_info_args args = {
+                       .mode   = mode & ~current->fs->umask,
+                       .ctime  = NO_CHANGE_64,
+                       .atime  = NO_CHANGE_64,
+                       .mtime  = NO_CHANGE_64,
+                       .device = device_number,
+               };
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
-                       rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
-                               mode, (__u64)current->fsuid,
-                               (__u64)current->fsgid,
-                               device_number, cifs_sb->local_nls,
-                               cifs_sb->mnt_cifs_flags &
-                                       CIFS_MOUNT_MAP_SPECIAL_CHR);
+                       args.uid = (__u64) current->fsuid;
+                       args.gid = (__u64) current->fsgid;
                } else {
-                       rc = CIFSSMBUnixSetPerms(xid, pTcon,
-                               full_path, mode, (__u64)-1, (__u64)-1,
-                               device_number, cifs_sb->local_nls,
-                               cifs_sb->mnt_cifs_flags &
-                                       CIFS_MOUNT_MAP_SPECIAL_CHR);
+                       args.uid = NO_CHANGE_64;
+                       args.gid = NO_CHANGE_64;
                }
+               rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path,
+                       &args, cifs_sb->local_nls,
+                       cifs_sb->mnt_cifs_flags &
+                               CIFS_MOUNT_MAP_SPECIAL_CHR);
 
                if (!rc) {
                        rc = cifs_get_inode_info_unix(&newinode, full_path,
index 0aac824371a579bd4f508f7360685b15c4ad74a4..d40738d2ab58c1183a7f940c7d5d086583d0a1e1 100644 (file)
@@ -310,18 +310,19 @@ int cifs_open(struct inode *inode, struct file *file)
                /* time to set mode which we can not set earlier due to
                   problems creating new read-only files */
                if (pTcon->unix_ext) {
-                       CIFSSMBUnixSetPerms(xid, pTcon, full_path,
-                                           inode->i_mode,
-                                           (__u64)-1, (__u64)-1, 0 /* dev */,
+                       struct cifs_unix_set_info_args args = {
+                               .mode   = inode->i_mode,
+                               .uid    = NO_CHANGE_64,
+                               .gid    = NO_CHANGE_64,
+                               .ctime  = NO_CHANGE_64,
+                               .atime  = NO_CHANGE_64,
+                               .mtime  = NO_CHANGE_64,
+                               .device = 0,
+                       };
+                       CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
                                            cifs_sb->local_nls,
                                            cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
-               } else {
-                       /* BB implement via Windows security descriptors eg
-                          CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
-                                             -1, -1, local_nls);
-                          in the meantime could set r/o dos attribute when
-                          perms are eg: mode & 0222 == 0 */
                }
        }
 
index 0e5dccc2f79a2f0e15a3bedef69342913a0ca2aa..024846719f1f3483d51cff4420261401b64b6aec 100644 (file)
@@ -986,23 +986,24 @@ mkdir_get_info:
                                direntry->d_inode->i_nlink = 2;
                mode &= ~current->fs->umask;
                if (pTcon->unix_ext) {
+                       struct cifs_unix_set_info_args args = {
+                               .mode   = mode,
+                               .ctime  = NO_CHANGE_64,
+                               .atime  = NO_CHANGE_64,
+                               .mtime  = NO_CHANGE_64,
+                               .device = 0,
+                       };
                        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
-                               CIFSSMBUnixSetPerms(xid, pTcon, full_path,
-                                                   mode,
-                                                   (__u64)current->fsuid,
-                                                   (__u64)current->fsgid,
-                                                   0 /* dev_t */,
-                                                   cifs_sb->local_nls,
-                                                   cifs_sb->mnt_cifs_flags &
-                                                   CIFS_MOUNT_MAP_SPECIAL_CHR);
+                               args.uid = (__u64)current->fsuid;
+                               args.gid = (__u64)current->fsgid;
                        } else {
-                               CIFSSMBUnixSetPerms(xid, pTcon, full_path,
-                                                   mode, (__u64)-1,
-                                                   (__u64)-1, 0 /* dev_t */,
-                                                   cifs_sb->local_nls,
-                                                   cifs_sb->mnt_cifs_flags &
-                                                   CIFS_MOUNT_MAP_SPECIAL_CHR);
+                               args.uid = NO_CHANGE_64;
+                               args.gid = NO_CHANGE_64;
                        }
+                       CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
+                                           cifs_sb->local_nls,
+                                           cifs_sb->mnt_cifs_flags &
+                                           CIFS_MOUNT_MAP_SPECIAL_CHR);
                } else {
                        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
                            (mode & S_IWUGO) == 0) {
@@ -1500,9 +1501,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
        FILE_BASIC_INFO time_buf;
        bool set_time = false;
        bool set_dosattr = false;
-       __u64 mode = 0xFFFFFFFFFFFFFFFFULL;
-       __u64 uid = 0xFFFFFFFFFFFFFFFFULL;
-       __u64 gid = 0xFFFFFFFFFFFFFFFFULL;
+       __u64 mode = NO_CHANGE_64;
+       __u64 uid = NO_CHANGE_64;
+       __u64 gid = NO_CHANGE_64;
        struct cifsInodeInfo *cifsInode;
        struct inode *inode = direntry->d_inode;
 
@@ -1586,12 +1587,21 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
        }
 
        if ((pTcon->unix_ext)
-           && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))
-               rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,
-                                        0 /* dev_t */, cifs_sb->local_nls,
-                                        cifs_sb->mnt_cifs_flags &
+           && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) {
+               struct cifs_unix_set_info_args args = {
+                       .mode   = mode,
+                       .uid    = uid,
+                       .gid    = gid,
+                       .ctime  = NO_CHANGE_64,
+                       .atime  = NO_CHANGE_64,
+                       .mtime  = NO_CHANGE_64,
+                       .device = 0,
+               };
+               rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
+                                       cifs_sb->local_nls,
+                                       cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
-       else if (attrs->ia_valid & ATTR_MODE) {
+       else if (attrs->ia_valid & ATTR_MODE) {
                rc = 0;
 #ifdef CONFIG_CIFS_EXPERIMENTAL
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)