]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: do some cleanups
authorChenXiaoSong <chenxiaosong@kylinos.cn>
Sun, 2 Nov 2025 07:30:58 +0000 (15:30 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 1 Dec 2025 03:11:45 +0000 (21:11 -0600)
Modify the following places:

  - Add documentation references
  - ATTR_REPARSE -> ATTR_REPARSE_POINT: consistent with MS-SMB 2.2.1.2.1
  - Remove unused File Attribute flags from server, if the server uses
    them in the future, we can move the client-side definitions to common
  - Remove unused SMB1_CLIENT_GUID_SIZE from server

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifspdu.h
fs/smb/client/readdir.c
fs/smb/client/reparse.h
fs/smb/client/smb1ops.c
fs/smb/client/smb2inode.c
fs/smb/server/smb_common.h

index a9a853b9011f63db6c176fa4112223689aae8226..df603bdbe6ba788127065233c1be41e34921b286 100644 (file)
@@ -19,6 +19,7 @@
 #define BAD_PROT 0xFFFF
 
 /* SMB command codes:
+ * See MS-CIFS 2.2.2.1
  * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
  * (ie which include no useful data other than the SMB error code itself).
  * This can allow us to avoid response buffer allocations and copy in some cases
 
 /*
  * SMB flag definitions
+ * See MS-CIFS 2.2.3.1
  */
 #define SMBFLG_EXTD_LOCK 0x01  /* server supports lock-read write-unlock smb */
 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
 
 /*
  * SMB flag2 definitions
+ * See MS-CIFS 2.2.3.1
+ *     MS-SMB 2.2.3.1
  */
 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)        /* can send long (non-8.3)
                                                   path names in response */
 /*
  * File Attribute flags
  */
-#define ATTR_READONLY  0x0001
-#define ATTR_HIDDEN    0x0002
-#define ATTR_SYSTEM    0x0004
-#define ATTR_VOLUME    0x0008
-#define ATTR_DIRECTORY 0x0010
-#define ATTR_ARCHIVE   0x0020
-#define ATTR_DEVICE    0x0040
-#define ATTR_NORMAL    0x0080
-#define ATTR_TEMPORARY 0x0100
-#define ATTR_SPARSE    0x0200
-#define ATTR_REPARSE   0x0400
-#define ATTR_COMPRESSED 0x0800
-#define ATTR_OFFLINE    0x1000 /* ie file not immediately available -
-                                       on offline storage */
-#define ATTR_NOT_CONTENT_INDEXED 0x2000
-#define ATTR_ENCRYPTED  0x4000
-#define ATTR_POSIX_SEMANTICS 0x01000000
-#define ATTR_BACKUP_SEMANTICS 0x02000000
-#define ATTR_DELETE_ON_CLOSE 0x04000000
-#define ATTR_SEQUENTIAL_SCAN 0x08000000
-#define ATTR_RANDOM_ACCESS   0x10000000
-#define ATTR_NO_BUFFERING    0x20000000
-#define ATTR_WRITE_THROUGH   0x80000000
+#define ATTR_READONLY          0x0001          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_HIDDEN            0x0002          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_SYSTEM            0x0004          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_VOLUME            0x0008
+#define ATTR_DIRECTORY         0x0010          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_ARCHIVE           0x0020          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_DEVICE            0x0040
+#define ATTR_NORMAL            0x0080          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_TEMPORARY         0x0100          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_SPARSE            0x0200          /* See MS-SMB 2.2.1.2.1 */
+#define ATTR_REPARSE_POINT     0x0400          /* See MS-SMB 2.2.1.2.1 */
+#define ATTR_COMPRESSED                0x0800          /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_OFFLINE           0x1000          /* See MS-SMB 2.2.1.2.1
+                                                  ie file not immediately available -
+                                                  on offline storage */
+#define ATTR_NOT_CONTENT_INDEXED 0x2000                /* See MS-SMB 2.2.1.2.1 */
+#define ATTR_ENCRYPTED         0x4000          /* See MS-SMB 2.2.1.2.1 */
+#define ATTR_POSIX_SEMANTICS   0x0100000       /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_BACKUP_SEMANTICS  0x0200000       /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_DELETE_ON_CLOSE   0x0400000       /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_SEQUENTIAL_SCAN   0x0800000       /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_RANDOM_ACCESS     0x1000000       /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_NO_BUFFERING      0x2000000       /* See MS-CIFS 2.2.1.2.3 */
+#define ATTR_WRITE_THROUGH     0x8000000       /* See MS-CIFS 2.2.1.2.3 */
 
 /* ShareAccess flags */
 #define FILE_NO_SHARE     0x00000000
index 2fd95c1e91ab6bb4afe4f266f5c22a20e85ca242..7ff728503ed1d93c629ea0ad2cfe3a16ef87ebc0 100644 (file)
@@ -98,7 +98,7 @@ retry:
                        default:
                                break;
                        }
-               } else if (fattr->cf_cifsattrs & ATTR_REPARSE) {
+               } else if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) {
                        reparse_need_reval = true;
                }
 
@@ -138,7 +138,7 @@ retry:
                                 * reparse tag and ctime haven't changed.
                                 */
                                rc = 0;
-                               if (fattr->cf_cifsattrs & ATTR_REPARSE) {
+                               if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) {
                                        if (likely(reparse_inode_match(inode, fattr))) {
                                                fattr->cf_mode = inode->i_mode;
                                                fattr->cf_rdev = inode->i_rdev;
@@ -190,7 +190,7 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
         * TODO: go through all documented  reparse tags to see if we can
         * reasonably map some of them to directories vs. files vs. symlinks
         */
-       if ((fattr->cf_cifsattrs & ATTR_REPARSE) &&
+       if ((fattr->cf_cifsattrs & ATTR_REPARSE_POINT) &&
            cifs_reparse_point_to_fattr(cifs_sb, fattr, &data))
                goto out_reparse;
 
@@ -258,7 +258,7 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info,
        fattr->cf_nlink = le32_to_cpu(info->HardLinks);
        fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes);
 
-       if (fattr->cf_cifsattrs & ATTR_REPARSE)
+       if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT)
                fattr->cf_cifstag = le32_to_cpu(info->ReparseTag);
 
        /* The Mode field in the response can now include the file type as well */
@@ -316,7 +316,7 @@ static void cifs_fulldir_info_to_fattr(struct cifs_fattr *fattr,
        __dir_info_to_fattr(fattr, info);
 
        /* See MS-FSCC 2.4.14, 2.4.19 */
-       if (fattr->cf_cifsattrs & ATTR_REPARSE)
+       if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT)
                fattr->cf_cifstag = le32_to_cpu(di->EaSize);
        cifs_fill_common_info(fattr, cifs_sb);
 }
index 66269c10beba9cbb9e70b54197dc0daecee0e455..19caab2fd11e6ae656c6ea0a16c9b7106b8bef27 100644 (file)
@@ -93,7 +93,7 @@ static inline bool reparse_inode_match(struct inode *inode,
        if (cinode->reparse_tag != IO_REPARSE_TAG_INTERNAL &&
            cinode->reparse_tag != fattr->cf_cifstag)
                return false;
-       return (cinode->cifsAttrs & ATTR_REPARSE) &&
+       return (cinode->cifsAttrs & ATTR_REPARSE_POINT) &&
                timespec64_equal(&ctime, &fattr->cf_ctime);
 }
 
@@ -107,7 +107,7 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)
 
                attrs = le32_to_cpu(fi->DosAttributes);
                if (data->reparse_point) {
-                       attrs |= ATTR_REPARSE;
+                       attrs |= ATTR_REPARSE_POINT;
                        fi->DosAttributes = cpu_to_le32(attrs);
                }
 
@@ -116,12 +116,12 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)
 
                attrs = le32_to_cpu(fi->Attributes);
                if (data->reparse_point) {
-                       attrs |= ATTR_REPARSE;
+                       attrs |= ATTR_REPARSE_POINT;
                        fi->Attributes = cpu_to_le32(attrs);
                }
        }
 
-       ret = attrs & ATTR_REPARSE;
+       ret = attrs & ATTR_REPARSE_POINT;
 
        return ret;
 }
index ca8f3dd7ff63b8555e36daa881e036615fc987bf..a15ebd3f0d50b87288f835c1f8c60ee69a618cd3 100644 (file)
@@ -647,7 +647,7 @@ static int cifs_query_path_info(const unsigned int xid,
 
        if (!rc) {
                move_cifs_info_to_smb2(&data->fi, &fi);
-               data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE;
+               data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE_POINT;
        }
 
 #ifdef CONFIG_CIFS_XATTR
index 69cb81fa0d3ab17a89835305d74180f57d4e38df..d0aad4821ed4d946ed6dfb107d0015c64c6fa732 100644 (file)
@@ -50,7 +50,7 @@ static inline __u32 file_create_options(struct dentry *dentry)
 
        if (dentry) {
                ci = CIFS_I(d_inode(dentry));
-               if (ci->cifsAttrs & ATTR_REPARSE)
+               if (ci->cifsAttrs & ATTR_REPARSE_POINT)
                        return OPEN_REPARSE_POINT;
        }
        return 0;
index 13751a4f0888fb4f4c4a8b14f571b1c2b35541cb..a91717da3895eb34a9d8e28de64baaca23b62c4e 100644 (file)
 #define F_CREATED      2
 #define F_OVERWRITTEN  3
 
-/*
- * File Attribute flags
- */
-#define ATTR_POSIX_SEMANTICS           0x01000000
-#define ATTR_BACKUP_SEMANTICS          0x02000000
-#define ATTR_DELETE_ON_CLOSE           0x04000000
-#define ATTR_SEQUENTIAL_SCAN           0x08000000
-#define ATTR_RANDOM_ACCESS             0x10000000
-#define ATTR_NO_BUFFERING              0x20000000
-#define ATTR_WRITE_THROUGH             0x80000000
-
 /* Combinations of file access permission bits */
 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
                | FILE_READ_ATTRIBUTES \
                FILE_EXECUTE | FILE_DELETE_CHILD | \
                FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
 
-#define SMB_COM_NEGOTIATE              0x72
-#define SMB1_CLIENT_GUID_SIZE          (16)
+#define SMB_COM_NEGOTIATE              0x72 /* See MS-CIFS 2.2.2.1 */
 
+/* See MS-CIFS 2.2.3.1 */
 #define SMBFLG_RESPONSE 0x80   /* this PDU is a response from server */
 
+/*
+ * See MS-CIFS 2.2.3.1
+ *     MS-SMB 2.2.3.1
+ */
 #define SMBFLG2_IS_LONG_NAME   cpu_to_le16(0x40)
 #define SMBFLG2_EXT_SEC                cpu_to_le16(0x800)
 #define SMBFLG2_ERR_STATUS     cpu_to_le16(0x4000)