Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smb: do some cleanups

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>

authored by

ChenXiaoSong and committed by
Steve French
95e8c1bf 464b9139

+45 -47
+28 -23
fs/smb/client/cifspdu.h
··· 19 19 #define BAD_PROT 0xFFFF 20 20 21 21 /* SMB command codes: 22 + * See MS-CIFS 2.2.2.1 22 23 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses 23 24 * (ie which include no useful data other than the SMB error code itself). 24 25 * This can allow us to avoid response buffer allocations and copy in some cases ··· 153 152 154 153 /* 155 154 * SMB flag definitions 155 + * See MS-CIFS 2.2.3.1 156 156 */ 157 157 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */ 158 158 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */ ··· 167 165 168 166 /* 169 167 * SMB flag2 definitions 168 + * See MS-CIFS 2.2.3.1 169 + * MS-SMB 2.2.3.1 170 170 */ 171 171 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3) 172 172 path names in response */ ··· 229 225 /* 230 226 * File Attribute flags 231 227 */ 232 - #define ATTR_READONLY 0x0001 233 - #define ATTR_HIDDEN 0x0002 234 - #define ATTR_SYSTEM 0x0004 235 - #define ATTR_VOLUME 0x0008 236 - #define ATTR_DIRECTORY 0x0010 237 - #define ATTR_ARCHIVE 0x0020 238 - #define ATTR_DEVICE 0x0040 239 - #define ATTR_NORMAL 0x0080 240 - #define ATTR_TEMPORARY 0x0100 241 - #define ATTR_SPARSE 0x0200 242 - #define ATTR_REPARSE 0x0400 243 - #define ATTR_COMPRESSED 0x0800 244 - #define ATTR_OFFLINE 0x1000 /* ie file not immediately available - 245 - on offline storage */ 246 - #define ATTR_NOT_CONTENT_INDEXED 0x2000 247 - #define ATTR_ENCRYPTED 0x4000 248 - #define ATTR_POSIX_SEMANTICS 0x01000000 249 - #define ATTR_BACKUP_SEMANTICS 0x02000000 250 - #define ATTR_DELETE_ON_CLOSE 0x04000000 251 - #define ATTR_SEQUENTIAL_SCAN 0x08000000 252 - #define ATTR_RANDOM_ACCESS 0x10000000 253 - #define ATTR_NO_BUFFERING 0x20000000 254 - #define ATTR_WRITE_THROUGH 0x80000000 228 + #define ATTR_READONLY 0x0001 /* See MS-CIFS 2.2.1.2.3 */ 229 + #define ATTR_HIDDEN 0x0002 /* See MS-CIFS 2.2.1.2.3 */ 230 + #define ATTR_SYSTEM 0x0004 /* See MS-CIFS 2.2.1.2.3 */ 231 + #define ATTR_VOLUME 0x0008 232 + #define ATTR_DIRECTORY 0x0010 /* See MS-CIFS 2.2.1.2.3 */ 233 + #define ATTR_ARCHIVE 0x0020 /* See MS-CIFS 2.2.1.2.3 */ 234 + #define ATTR_DEVICE 0x0040 235 + #define ATTR_NORMAL 0x0080 /* See MS-CIFS 2.2.1.2.3 */ 236 + #define ATTR_TEMPORARY 0x0100 /* See MS-CIFS 2.2.1.2.3 */ 237 + #define ATTR_SPARSE 0x0200 /* See MS-SMB 2.2.1.2.1 */ 238 + #define ATTR_REPARSE_POINT 0x0400 /* See MS-SMB 2.2.1.2.1 */ 239 + #define ATTR_COMPRESSED 0x0800 /* See MS-CIFS 2.2.1.2.3 */ 240 + #define ATTR_OFFLINE 0x1000 /* See MS-SMB 2.2.1.2.1 241 + ie file not immediately available - 242 + on offline storage */ 243 + #define ATTR_NOT_CONTENT_INDEXED 0x2000 /* See MS-SMB 2.2.1.2.1 */ 244 + #define ATTR_ENCRYPTED 0x4000 /* See MS-SMB 2.2.1.2.1 */ 245 + #define ATTR_POSIX_SEMANTICS 0x0100000 /* See MS-CIFS 2.2.1.2.3 */ 246 + #define ATTR_BACKUP_SEMANTICS 0x0200000 /* See MS-CIFS 2.2.1.2.3 */ 247 + #define ATTR_DELETE_ON_CLOSE 0x0400000 /* See MS-CIFS 2.2.1.2.3 */ 248 + #define ATTR_SEQUENTIAL_SCAN 0x0800000 /* See MS-CIFS 2.2.1.2.3 */ 249 + #define ATTR_RANDOM_ACCESS 0x1000000 /* See MS-CIFS 2.2.1.2.3 */ 250 + #define ATTR_NO_BUFFERING 0x2000000 /* See MS-CIFS 2.2.1.2.3 */ 251 + #define ATTR_WRITE_THROUGH 0x8000000 /* See MS-CIFS 2.2.1.2.3 */ 255 252 256 253 /* ShareAccess flags */ 257 254 #define FILE_NO_SHARE 0x00000000
+5 -5
fs/smb/client/readdir.c
··· 98 98 default: 99 99 break; 100 100 } 101 - } else if (fattr->cf_cifsattrs & ATTR_REPARSE) { 101 + } else if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) { 102 102 reparse_need_reval = true; 103 103 } 104 104 ··· 138 138 * reparse tag and ctime haven't changed. 139 139 */ 140 140 rc = 0; 141 - if (fattr->cf_cifsattrs & ATTR_REPARSE) { 141 + if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) { 142 142 if (likely(reparse_inode_match(inode, fattr))) { 143 143 fattr->cf_mode = inode->i_mode; 144 144 fattr->cf_rdev = inode->i_rdev; ··· 190 190 * TODO: go through all documented reparse tags to see if we can 191 191 * reasonably map some of them to directories vs. files vs. symlinks 192 192 */ 193 - if ((fattr->cf_cifsattrs & ATTR_REPARSE) && 193 + if ((fattr->cf_cifsattrs & ATTR_REPARSE_POINT) && 194 194 cifs_reparse_point_to_fattr(cifs_sb, fattr, &data)) 195 195 goto out_reparse; 196 196 ··· 258 258 fattr->cf_nlink = le32_to_cpu(info->HardLinks); 259 259 fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes); 260 260 261 - if (fattr->cf_cifsattrs & ATTR_REPARSE) 261 + if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) 262 262 fattr->cf_cifstag = le32_to_cpu(info->ReparseTag); 263 263 264 264 /* The Mode field in the response can now include the file type as well */ ··· 316 316 __dir_info_to_fattr(fattr, info); 317 317 318 318 /* See MS-FSCC 2.4.14, 2.4.19 */ 319 - if (fattr->cf_cifsattrs & ATTR_REPARSE) 319 + if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) 320 320 fattr->cf_cifstag = le32_to_cpu(di->EaSize); 321 321 cifs_fill_common_info(fattr, cifs_sb); 322 322 }
+4 -4
fs/smb/client/reparse.h
··· 93 93 if (cinode->reparse_tag != IO_REPARSE_TAG_INTERNAL && 94 94 cinode->reparse_tag != fattr->cf_cifstag) 95 95 return false; 96 - return (cinode->cifsAttrs & ATTR_REPARSE) && 96 + return (cinode->cifsAttrs & ATTR_REPARSE_POINT) && 97 97 timespec64_equal(&ctime, &fattr->cf_ctime); 98 98 } 99 99 ··· 107 107 108 108 attrs = le32_to_cpu(fi->DosAttributes); 109 109 if (data->reparse_point) { 110 - attrs |= ATTR_REPARSE; 110 + attrs |= ATTR_REPARSE_POINT; 111 111 fi->DosAttributes = cpu_to_le32(attrs); 112 112 } 113 113 ··· 116 116 117 117 attrs = le32_to_cpu(fi->Attributes); 118 118 if (data->reparse_point) { 119 - attrs |= ATTR_REPARSE; 119 + attrs |= ATTR_REPARSE_POINT; 120 120 fi->Attributes = cpu_to_le32(attrs); 121 121 } 122 122 } 123 123 124 - ret = attrs & ATTR_REPARSE; 124 + ret = attrs & ATTR_REPARSE_POINT; 125 125 126 126 return ret; 127 127 }
+1 -1
fs/smb/client/smb1ops.c
··· 647 647 648 648 if (!rc) { 649 649 move_cifs_info_to_smb2(&data->fi, &fi); 650 - data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE; 650 + data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE_POINT; 651 651 } 652 652 653 653 #ifdef CONFIG_CIFS_XATTR
+1 -1
fs/smb/client/smb2inode.c
··· 50 50 51 51 if (dentry) { 52 52 ci = CIFS_I(d_inode(dentry)); 53 - if (ci->cifsAttrs & ATTR_REPARSE) 53 + if (ci->cifsAttrs & ATTR_REPARSE_POINT) 54 54 return OPEN_REPARSE_POINT; 55 55 } 56 56 return 0;
+6 -13
fs/smb/server/smb_common.h
··· 38 38 #define F_CREATED 2 39 39 #define F_OVERWRITTEN 3 40 40 41 - /* 42 - * File Attribute flags 43 - */ 44 - #define ATTR_POSIX_SEMANTICS 0x01000000 45 - #define ATTR_BACKUP_SEMANTICS 0x02000000 46 - #define ATTR_DELETE_ON_CLOSE 0x04000000 47 - #define ATTR_SEQUENTIAL_SCAN 0x08000000 48 - #define ATTR_RANDOM_ACCESS 0x10000000 49 - #define ATTR_NO_BUFFERING 0x20000000 50 - #define ATTR_WRITE_THROUGH 0x80000000 51 - 52 41 /* Combinations of file access permission bits */ 53 42 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \ 54 43 | FILE_READ_ATTRIBUTES \ ··· 69 80 FILE_EXECUTE | FILE_DELETE_CHILD | \ 70 81 FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES) 71 82 72 - #define SMB_COM_NEGOTIATE 0x72 73 - #define SMB1_CLIENT_GUID_SIZE (16) 83 + #define SMB_COM_NEGOTIATE 0x72 /* See MS-CIFS 2.2.2.1 */ 74 84 85 + /* See MS-CIFS 2.2.3.1 */ 75 86 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */ 76 87 88 + /* 89 + * See MS-CIFS 2.2.3.1 90 + * MS-SMB 2.2.3.1 91 + */ 77 92 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) 78 93 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800) 79 94 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)