Skip to contentSkip to conversation

Shared flags: use in cifs client

PATCH Pavel Shilovsky 1 participant 1 message Nov 11, 2008 VFS

lore
Share & tools
lore
#0 lore raw
Quoted 264 lines · Benny Halevy
Quoted 107 lines · Pavel Shilovsky
fs/cifs/cifsacl.c +1 -1
index 57ecdc8..1d08705 100644
@@ -591,7 +591,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 
 *pacllen, struct inode *inode,
         int oplock = 0;
         /* open file */
         rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
-                READ_CONTROL, 0, &fid, &oplock, NULL,
+                READ_CONTROL, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
                 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                     CIFS_MOUNT_MAP_SPECIAL_CHR);
         if (rc != 0) {
fs/cifs/cifsacl.c +1 -1
@@ -645,7 +645,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, 
 __u32 acllen,
         int oplock = 0;
         /* open file */
         rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
-                WRITE_DAC, 0, &fid, &oplock, NULL,
+                WRITE_DAC, FILE_SHARE_ALL, 0, &fid, &oplock, NULL,
                 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                     CIFS_MOUNT_MAP_SPECIAL_CHR);
         if (rc != 0) {
fs/cifs/cifsproto.h +1 -1
index 0cff7fe..88732bc 100644
@@ -261,7 +261,7 @@ extern int CIFSSMBQueryReparseLinkInfo(const int 
 xid,
 
 extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
             const char *fileName, const int disposition,
-            const int access_flags, const int omode,
+            const int access_flags, const int share_flags, const int 
 omode,
             __u16 *netfid, int *pOplock, FILE_ALL_INFO *,
             const struct nls_table *nls_codepage, int remap);

extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,

fs/cifs/cifssmb.c +1 -1
index 843a85f..39c30c9 100644
@@ -1322,7 +1322,7 @@ OldOpenRetry:
 int
 CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
         const char *fileName, const int openDisposition,
-        const int access_flags, const int create_options, __u16 
 *netfid,
+        const int access_flags, const int share_flags, const int 
 create_options, __u16 *netfid,
         int *pOplock, FILE_ALL_INFO *pfile_info,

const struct nls_table *nls_codepage, int remap)
{

fs/cifs/cifssmb.c +1 -1
@@ -1379,7 +1379,7 @@ openRetry:
     if (create_options & CREATE_OPTION_READONLY)
         pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
 
-    pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
+    pSMB->ShareAccess = cpu_to_le32(share_flags);
     pSMB->CreateDisposition = cpu_to_le32(openDisposition);
     pSMB->CreateOptions = cpu_to_le32(create_options & 
 CREATE_OPTIONS_MASK);
     /* BB Expirement with various impersonation levels and verify */
fs/cifs/dir.c +1 -1
index e962e75..f440996 100644
@@ -207,7 +207,7 @@ cifs_create(struct inode *inode, struct dentry 
 *direntry, int mode,
 
     if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
         rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
-             desiredAccess, create_options,
+             desiredAccess, FILE_SHARE_ALL, create_options,
              &fileHandle, &oplock, buf, cifs_sb->local_nls,
              cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);

else

fs/cifs/dir.c +1 -0
@@ -417,6 +417,7 @@ int cifs_mknod(struct inode *inode, struct dentry 
 *direntry, int mode,
                       WRITE_OWNER | WRITE_DAC be better? */,
                      /* Create a file and set the
                         file attribute to SYSTEM */
+                     FILE_SHARE_ALL,
                      CREATE_NOT_DIR | CREATE_OPTION_SPECIAL,
                      &fileHandle, &oplock, buf,
                      cifs_sb->local_nls,
fs/cifs/fcntl.c +1 -1
index 5a57581..9dc88ca 100644
@@ -89,7 +89,7 @@ int cifs_dir_notify(struct file *file, unsigned 
 long arg)
     } else {
         cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg));
         rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
-            GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
+            GENERIC_READ | SYNCHRONIZE, FILE_SHARE_ALL, 0 /* create 
 options */,
             &netfid, &oplock, NULL, cifs_sb->local_nls,
             cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
         /* BB fixme - add this handle to a notify handle list */
fs/cifs/file.c +0 -0
index 62d8bd8..4981d75 100644

fs/cifs/file.c static inline int cifs_get_disposition(unsigned · line 102

Quoted 7 lines
fs/cifs/file.c +3 -0
@@ -96,6 +96,11 @@ static inline int cifs_get_disposition(unsigned 
 int flags)
         return FILE_OPEN;
 }
 
+static inline int cifs_get_share_flags(unsigned int flags)
+{
+    return ((~(flags>>21))&7);

Hmm, 004000000 == (1 << 20)
Aren't you losing one bit?

Benny

Quoted 142 lines
fs/cifs/file.c +2 -0
+}
+
 /* all arguments to this function must be checked for validity in 

caller */
static inline int cifs_open_inode_helper(struct inode *inode, struct
file *file,
struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile,

fs/cifs/file.c +1 -0
@@ -173,6 +178,7 @@ int cifs_open(struct inode *inode, struct file 
 *file)
     struct list_head *tmp;
     char *full_path = NULL;
     int desiredAccess;
+    int desiredShare;
     int disposition;
     __u16 netfid;
     FILE_ALL_INFO *buf = NULL;
fs/cifs/file.c +1 -0
@@ -221,6 +227,7 @@ int cifs_open(struct inode *inode, struct file 
 *file)
     cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
          inode, file->f_flags, full_path));
     desiredAccess = cifs_convert_flags(file->f_flags);
+    desiredShare = cifs_get_share_flags(file->f_flags);
 
 /*********************************************************************

* open flag mapping table:

fs/cifs/file.c +1 -1
@@ -270,7 +277,7 @@ int cifs_open(struct inode *inode, struct file 
 *file)
 
     if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
         rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
-             desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
+             desiredAccess, desiredShare, CREATE_NOT_DIR, &netfid, 
 &oplock, buf,
              cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
                  & CIFS_MOUNT_MAP_SPECIAL_CHR);
     else
fs/cifs/file.c +2 -0
@@ -355,6 +362,7 @@ static int cifs_reopen_file(struct file *file, 
 bool can_flush)
     struct inode *inode;
     char *full_path = NULL;
     int desiredAccess;
+    int desiredShare;
     int disposition = FILE_OPEN;
     __u16 netfid;
@@ -405,6 +413,7 @@ reopen_error_exit:
     cFYI(1, ("inode = 0x%p file flags 0x%x for %s",
          inode, file->f_flags, full_path));
     desiredAccess = cifs_convert_flags(file->f_flags);
+    desiredShare = cifs_get_share_flags(file->f_flags);
 
     if (oplockEnabled)
         oplock = REQ_OPLOCK;
@@ -417,7 +426,7 @@ reopen_error_exit:
        and server version of file size can be stale. If we knew for 

sure
that inode was not dirty locally we could do this */

fs/cifs/file.c +1 -1
-    rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
+    rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 

desiredAccess, desiredShare,

              CREATE_NOT_DIR, &netfid, &oplock, NULL,
              cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                 CIFS_MOUNT_MAP_SPECIAL_CHR);
fs/cifs/inode.c +1 -1
index d54fa8a..66d8785 100644
@@ -294,7 +294,7 @@ static int decode_sfu_inode(struct inode *inode, 
 __u64 size,
         return -EINVAL;     /* EOPNOTSUPP? */
     }
 
-    rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
+    rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ, 
 FILE_SHARE_ALL,
              CREATE_NOT_DIR, &netfid, &oplock, NULL,
              cifs_sb->local_nls,
              cifs_sb->mnt_cifs_flags &
fs/cifs/inode.c +1 -1
@@ -740,7 +740,7 @@ cifs_set_file_info(struct inode *inode, struct 
 iattr *attrs, int xid,
     cFYI(1, ("calling SetFileInfo since SetPathInfo for "
          "times not supported by this server"));
     rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
-             SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
+             SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL,
              CREATE_NOT_DIR, &netfid, &oplock,
              NULL, cifs_sb->local_nls,
              cifs_sb->mnt_cifs_flags &
fs/cifs/inode.c +1 -1
@@ -786,7 +786,7 @@ cifs_rename_pending_delete(char *full_path, 
 struct dentry *dentry, int xid)
     FILE_BASIC_INFO *info_buf = NULL;
 
     rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
-             DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
+             DELETE|FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL, 
 CREATE_NOT_DIR,
              &netfid, &oplock, NULL, cifs_sb->local_nls,
              cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
     if (rc != 0)
fs/cifs/inode.c +1 -1
@@ -1268,7 +1268,7 @@ cifs_do_rename(int xid, struct dentry 
 *from_dentry, const char *fromPath,
         return rc;
 
     /* open the file to be renamed -- we need DELETE perms */
-    rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE,
+    rc = CIFSSMBOpen(xid, pTcon, fromPath, FILE_OPEN, DELETE, 
 FILE_SHARE_ALL,
              CREATE_NOT_DIR, &srcfid, &oplock, NULL,
              cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                 CIFS_MOUNT_MAP_SPECIAL_CHR);
fs/cifs/link.c +1 -1
index 63f6440..7c9f495 100644
@@ -279,7 +279,7 @@ cifs_readlink(struct dentry *direntry, char 
 __user *pBuffer, int buflen)
         cERROR(1, ("SFU style symlinks not implemented yet"));
         /* add open and read as in fs/cifs/inode.c */
     } else {
-        rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 
 GENERIC_READ,
+        rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 
 GENERIC_READ, FILE_SHARE_ALL,
                 OPEN_REPARSE_POINT, &fid, &oplock, NULL,
                 cifs_sb->local_nls,
                 cifs_sb->mnt_cifs_flags &
fs/cifs/xattr.c +1 -1
index e9527ee..059211c 100644
@@ -269,7 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, 
 const char *ea_name,
             __u32 buflen = 0;
             if (experimEnabled)
                 rc = CIFSSMBOpen(xid, pTcon, full_path,
-                    FILE_OPEN, GENERIC_READ, 0, &fid,
+                    FILE_OPEN, GENERIC_READ, FILE_SHARE_ALL, 0, &fid,
                     &oplock, NULL, cifs_sb->local_nls,
                     cifs_sb->mnt_cifs_flags &
                     CIFS_MOUNT_MAP_SPECIAL_CHR);
Quoted 11 lines
Quoted 5 lines
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Yes, thanks, you are right - it's our bug...

+static inline int cifs_get_share_flags(unsigned int flags) +{
+ return ((~(flags>>20))&7);
+}

Pavel Shilovsky