Skip to content

Commit 95e8c1b

Browse files
ChenXiaoSongsmfrench
authored andcommitted
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>
1 parent 464b913 commit 95e8c1b

6 files changed

Lines changed: 45 additions & 47 deletions

File tree

fs/smb/client/cifspdu.h

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define BAD_PROT 0xFFFF
2020

2121
/* SMB command codes:
22+
* See MS-CIFS 2.2.2.1
2223
* Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
2324
* (ie which include no useful data other than the SMB error code itself).
2425
* This can allow us to avoid response buffer allocations and copy in some cases
@@ -152,6 +153,7 @@
152153

153154
/*
154155
* SMB flag definitions
156+
* See MS-CIFS 2.2.3.1
155157
*/
156158
#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
157159
#define SMBFLG_RCV_POSTED 0x02 /* obsolete */
@@ -165,6 +167,8 @@
165167

166168
/*
167169
* SMB flag2 definitions
170+
* See MS-CIFS 2.2.3.1
171+
* MS-SMB 2.2.3.1
168172
*/
169173
#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
170174
path names in response */
@@ -225,29 +229,30 @@
225229
/*
226230
* File Attribute flags
227231
*/
228-
#define ATTR_READONLY 0x0001
229-
#define ATTR_HIDDEN 0x0002
230-
#define ATTR_SYSTEM 0x0004
231-
#define ATTR_VOLUME 0x0008
232-
#define ATTR_DIRECTORY 0x0010
233-
#define ATTR_ARCHIVE 0x0020
234-
#define ATTR_DEVICE 0x0040
235-
#define ATTR_NORMAL 0x0080
236-
#define ATTR_TEMPORARY 0x0100
237-
#define ATTR_SPARSE 0x0200
238-
#define ATTR_REPARSE 0x0400
239-
#define ATTR_COMPRESSED 0x0800
240-
#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
241-
on offline storage */
242-
#define ATTR_NOT_CONTENT_INDEXED 0x2000
243-
#define ATTR_ENCRYPTED 0x4000
244-
#define ATTR_POSIX_SEMANTICS 0x01000000
245-
#define ATTR_BACKUP_SEMANTICS 0x02000000
246-
#define ATTR_DELETE_ON_CLOSE 0x04000000
247-
#define ATTR_SEQUENTIAL_SCAN 0x08000000
248-
#define ATTR_RANDOM_ACCESS 0x10000000
249-
#define ATTR_NO_BUFFERING 0x20000000
250-
#define ATTR_WRITE_THROUGH 0x80000000
232+
#define ATTR_READONLY 0x0001 /* See MS-CIFS 2.2.1.2.3 */
233+
#define ATTR_HIDDEN 0x0002 /* See MS-CIFS 2.2.1.2.3 */
234+
#define ATTR_SYSTEM 0x0004 /* See MS-CIFS 2.2.1.2.3 */
235+
#define ATTR_VOLUME 0x0008
236+
#define ATTR_DIRECTORY 0x0010 /* See MS-CIFS 2.2.1.2.3 */
237+
#define ATTR_ARCHIVE 0x0020 /* See MS-CIFS 2.2.1.2.3 */
238+
#define ATTR_DEVICE 0x0040
239+
#define ATTR_NORMAL 0x0080 /* See MS-CIFS 2.2.1.2.3 */
240+
#define ATTR_TEMPORARY 0x0100 /* See MS-CIFS 2.2.1.2.3 */
241+
#define ATTR_SPARSE 0x0200 /* See MS-SMB 2.2.1.2.1 */
242+
#define ATTR_REPARSE_POINT 0x0400 /* See MS-SMB 2.2.1.2.1 */
243+
#define ATTR_COMPRESSED 0x0800 /* See MS-CIFS 2.2.1.2.3 */
244+
#define ATTR_OFFLINE 0x1000 /* See MS-SMB 2.2.1.2.1
245+
ie file not immediately available -
246+
on offline storage */
247+
#define ATTR_NOT_CONTENT_INDEXED 0x2000 /* See MS-SMB 2.2.1.2.1 */
248+
#define ATTR_ENCRYPTED 0x4000 /* See MS-SMB 2.2.1.2.1 */
249+
#define ATTR_POSIX_SEMANTICS 0x0100000 /* See MS-CIFS 2.2.1.2.3 */
250+
#define ATTR_BACKUP_SEMANTICS 0x0200000 /* See MS-CIFS 2.2.1.2.3 */
251+
#define ATTR_DELETE_ON_CLOSE 0x0400000 /* See MS-CIFS 2.2.1.2.3 */
252+
#define ATTR_SEQUENTIAL_SCAN 0x0800000 /* See MS-CIFS 2.2.1.2.3 */
253+
#define ATTR_RANDOM_ACCESS 0x1000000 /* See MS-CIFS 2.2.1.2.3 */
254+
#define ATTR_NO_BUFFERING 0x2000000 /* See MS-CIFS 2.2.1.2.3 */
255+
#define ATTR_WRITE_THROUGH 0x8000000 /* See MS-CIFS 2.2.1.2.3 */
251256

252257
/* ShareAccess flags */
253258
#define FILE_NO_SHARE 0x00000000

fs/smb/client/readdir.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
9898
default:
9999
break;
100100
}
101-
} else if (fattr->cf_cifsattrs & ATTR_REPARSE) {
101+
} else if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) {
102102
reparse_need_reval = true;
103103
}
104104

@@ -138,7 +138,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
138138
* reparse tag and ctime haven't changed.
139139
*/
140140
rc = 0;
141-
if (fattr->cf_cifsattrs & ATTR_REPARSE) {
141+
if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) {
142142
if (likely(reparse_inode_match(inode, fattr))) {
143143
fattr->cf_mode = inode->i_mode;
144144
fattr->cf_rdev = inode->i_rdev;
@@ -190,7 +190,7 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
190190
* TODO: go through all documented reparse tags to see if we can
191191
* reasonably map some of them to directories vs. files vs. symlinks
192192
*/
193-
if ((fattr->cf_cifsattrs & ATTR_REPARSE) &&
193+
if ((fattr->cf_cifsattrs & ATTR_REPARSE_POINT) &&
194194
cifs_reparse_point_to_fattr(cifs_sb, fattr, &data))
195195
goto out_reparse;
196196

@@ -258,7 +258,7 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info,
258258
fattr->cf_nlink = le32_to_cpu(info->HardLinks);
259259
fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes);
260260

261-
if (fattr->cf_cifsattrs & ATTR_REPARSE)
261+
if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT)
262262
fattr->cf_cifstag = le32_to_cpu(info->ReparseTag);
263263

264264
/* 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,
316316
__dir_info_to_fattr(fattr, info);
317317

318318
/* See MS-FSCC 2.4.14, 2.4.19 */
319-
if (fattr->cf_cifsattrs & ATTR_REPARSE)
319+
if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT)
320320
fattr->cf_cifstag = le32_to_cpu(di->EaSize);
321321
cifs_fill_common_info(fattr, cifs_sb);
322322
}

fs/smb/client/reparse.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static inline bool reparse_inode_match(struct inode *inode,
9393
if (cinode->reparse_tag != IO_REPARSE_TAG_INTERNAL &&
9494
cinode->reparse_tag != fattr->cf_cifstag)
9595
return false;
96-
return (cinode->cifsAttrs & ATTR_REPARSE) &&
96+
return (cinode->cifsAttrs & ATTR_REPARSE_POINT) &&
9797
timespec64_equal(&ctime, &fattr->cf_ctime);
9898
}
9999

@@ -107,7 +107,7 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)
107107

108108
attrs = le32_to_cpu(fi->DosAttributes);
109109
if (data->reparse_point) {
110-
attrs |= ATTR_REPARSE;
110+
attrs |= ATTR_REPARSE_POINT;
111111
fi->DosAttributes = cpu_to_le32(attrs);
112112
}
113113

@@ -116,12 +116,12 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)
116116

117117
attrs = le32_to_cpu(fi->Attributes);
118118
if (data->reparse_point) {
119-
attrs |= ATTR_REPARSE;
119+
attrs |= ATTR_REPARSE_POINT;
120120
fi->Attributes = cpu_to_le32(attrs);
121121
}
122122
}
123123

124-
ret = attrs & ATTR_REPARSE;
124+
ret = attrs & ATTR_REPARSE_POINT;
125125

126126
return ret;
127127
}

fs/smb/client/smb1ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static int cifs_query_path_info(const unsigned int xid,
647647

648648
if (!rc) {
649649
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;
651651
}
652652

653653
#ifdef CONFIG_CIFS_XATTR

fs/smb/client/smb2inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static inline __u32 file_create_options(struct dentry *dentry)
5050

5151
if (dentry) {
5252
ci = CIFS_I(d_inode(dentry));
53-
if (ci->cifsAttrs & ATTR_REPARSE)
53+
if (ci->cifsAttrs & ATTR_REPARSE_POINT)
5454
return OPEN_REPARSE_POINT;
5555
}
5656
return 0;

fs/smb/server/smb_common.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@
3838
#define F_CREATED 2
3939
#define F_OVERWRITTEN 3
4040

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-
5241
/* Combinations of file access permission bits */
5342
#define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA \
5443
| FILE_READ_ATTRIBUTES \
@@ -80,11 +69,15 @@
8069
FILE_EXECUTE | FILE_DELETE_CHILD | \
8170
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
8271

83-
#define SMB_COM_NEGOTIATE 0x72
84-
#define SMB1_CLIENT_GUID_SIZE (16)
72+
#define SMB_COM_NEGOTIATE 0x72 /* See MS-CIFS 2.2.2.1 */
8573

74+
/* See MS-CIFS 2.2.3.1 */
8675
#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
8776

77+
/*
78+
* See MS-CIFS 2.2.3.1
79+
* MS-SMB 2.2.3.1
80+
*/
8881
#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
8982
#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
9083
#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)

0 commit comments

Comments
 (0)