30
31
#define MAX_EA_VALUE_SIZE 65535
31
32
#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
33
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
32
34
#define CIFS_XATTR_USER_PREFIX "user."
33
35
#define CIFS_XATTR_SYSTEM_PREFIX "system."
34
36
#define CIFS_XATTR_OS2_PREFIX "os2."
35
#define CIFS_XATTR_SECURITY_PREFIX ".security"
37
#define CIFS_XATTR_SECURITY_PREFIX "security."
36
38
#define CIFS_XATTR_TRUSTED_PREFIX "trusted."
37
39
#define XATTR_TRUSTED_PREFIX_LEN 8
38
40
#define XATTR_SECURITY_PREFIX_LEN 9
57
60
sb = direntry->d_inode->i_sb;
64
cifs_sb = CIFS_SB(sb);
65
tlink = cifs_sb_tlink(cifs_sb);
67
return PTR_ERR(tlink);
68
pTcon = tlink_tcon(tlink);
62
cifs_sb = CIFS_SB(sb);
63
pTcon = cifs_sb->tcon;
65
72
full_path = build_path_from_dentry(direntry);
66
73
if (full_path == NULL) {
71
77
if (ea_name == NULL) {
72
cFYI(1, ("Null xattr names not supported"));
78
cFYI(1, "Null xattr names not supported");
73
79
} else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5)
74
80
&& (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4))) {
76
("illegal xattr request %s (only user namespace supported)",
82
"illegal xattr request %s (only user namespace supported)",
78
84
/* BB what if no namespace prefix? */
79
85
/* Should we just pass them to server, except for
80
86
system and perhaps security prefixes? */
112
120
sb = direntry->d_inode->i_sb;
124
cifs_sb = CIFS_SB(sb);
125
tlink = cifs_sb_tlink(cifs_sb);
127
return PTR_ERR(tlink);
128
pTcon = tlink_tcon(tlink);
117
cifs_sb = CIFS_SB(sb);
118
pTcon = cifs_sb->tcon;
120
132
full_path = build_path_from_dentry(direntry);
121
133
if (full_path == NULL) {
126
137
/* return dos attributes as pseudo xattr */
127
138
/* return alt name if available as pseudo attr */
130
141
search server for EAs or streams to
131
142
returns as xattrs */
132
143
if (value_size > MAX_EA_VALUE_SIZE) {
133
cFYI(1, ("size of EA value too large"));
144
cFYI(1, "size of EA value too large");
139
149
if (ea_name == NULL) {
140
cFYI(1, ("Null xattr names not supported"));
150
cFYI(1, "Null xattr names not supported");
141
151
} else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
142
152
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
143
153
goto set_ea_exit;
144
154
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0)
145
cFYI(1, ("attempt to set cifs inode metadata"));
155
cFYI(1, "attempt to set cifs inode metadata");
147
157
ea_name += 5; /* skip past user. prefix */
148
158
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
168
178
ACL_TYPE_ACCESS, cifs_sb->local_nls,
169
179
cifs_sb->mnt_cifs_flags &
170
180
CIFS_MOUNT_MAP_SPECIAL_CHR);
171
cFYI(1, ("set POSIX ACL rc %d", rc));
181
cFYI(1, "set POSIX ACL rc %d", rc);
173
cFYI(1, ("set POSIX ACL not supported"));
183
cFYI(1, "set POSIX ACL not supported");
175
185
} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
176
186
strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
181
191
ACL_TYPE_DEFAULT, cifs_sb->local_nls,
182
192
cifs_sb->mnt_cifs_flags &
183
193
CIFS_MOUNT_MAP_SPECIAL_CHR);
184
cFYI(1, ("set POSIX default ACL rc %d", rc));
194
cFYI(1, "set POSIX default ACL rc %d", rc);
186
cFYI(1, ("set default POSIX ACL not supported"));
196
cFYI(1, "set default POSIX ACL not supported");
189
cFYI(1, ("illegal xattr request %s (only user namespace"
190
" supported)", ea_name));
199
cFYI(1, "illegal xattr request %s (only user namespace"
200
" supported)", ea_name);
191
201
/* BB what if no namespace prefix? */
192
202
/* Should we just pass them to server, except for
193
203
system and perhaps security prefixes? */
235
cifs_sb = CIFS_SB(sb);
236
tlink = cifs_sb_tlink(cifs_sb);
238
return PTR_ERR(tlink);
239
pTcon = tlink_tcon(tlink);
225
cifs_sb = CIFS_SB(sb);
226
pTcon = cifs_sb->tcon;
228
243
full_path = build_path_from_dentry(direntry);
229
244
if (full_path == NULL) {
234
248
/* return dos attributes as pseudo xattr */
235
249
/* return alt name if available as pseudo attr */
236
250
if (ea_name == NULL) {
237
cFYI(1, ("Null xattr names not supported"));
251
cFYI(1, "Null xattr names not supported");
238
252
} else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
239
253
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
240
254
goto get_ea_exit;
242
256
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
243
cFYI(1, ("attempt to query cifs inode metadata"));
257
cFYI(1, "attempt to query cifs inode metadata");
244
258
/* revalidate/getattr then populate from inode */
245
259
} /* BB add else when above is implemented */
246
260
ea_name += 5; /* skip past user. prefix */
247
rc = CIFSSMBQueryEA(xid, pTcon, full_path, ea_name, ea_value,
261
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
248
262
buf_size, cifs_sb->local_nls,
249
263
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
250
264
} else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
252
266
goto get_ea_exit;
254
268
ea_name += 4; /* skip past os2. prefix */
255
rc = CIFSSMBQueryEA(xid, pTcon, full_path, ea_name, ea_value,
269
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
256
270
buf_size, cifs_sb->local_nls,
257
271
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
258
272
} else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
264
278
cifs_sb->local_nls,
265
279
cifs_sb->mnt_cifs_flags &
266
280
CIFS_MOUNT_MAP_SPECIAL_CHR);
267
#ifdef CONFIG_CIFS_EXPERIMENTAL
268
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
271
struct cifs_ntsd *pacl = NULL;
274
rc = CIFSSMBOpen(xid, pTcon, full_path,
275
FILE_OPEN, GENERIC_READ, 0, &fid,
276
&oplock, NULL, cifs_sb->local_nls,
277
cifs_sb->mnt_cifs_flags &
278
CIFS_MOUNT_MAP_SPECIAL_CHR);
279
/* else rc is EOPNOTSUPP from above */
282
rc = CIFSSMBGetCIFSACL(xid, pTcon, fid, &pacl,
284
CIFSSMBClose(xid, pTcon, fid);
287
#endif /* EXPERIMENTAL */
289
cFYI(1, ("query POSIX ACL not supported yet"));
282
cFYI(1, "Query POSIX ACL not supported yet");
290
283
#endif /* CONFIG_CIFS_POSIX */
291
284
} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
292
285
strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
298
291
cifs_sb->mnt_cifs_flags &
299
292
CIFS_MOUNT_MAP_SPECIAL_CHR);
301
cFYI(1, ("query POSIX default ACL not supported yet"));
294
cFYI(1, "Query POSIX default ACL not supported yet");
295
#endif /* CONFIG_CIFS_POSIX */
296
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
297
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
298
#ifdef CONFIG_CIFS_ACL
300
struct cifs_ntsd *pacl;
302
pacl = get_cifs_acl(cifs_sb, direntry->d_inode,
306
cERROR(1, "%s: error %zd getting sec desc",
310
if (acllen > buf_size)
313
memcpy(ea_value, pacl, acllen);
319
cFYI(1, "Query CIFS ACL not supported yet");
320
#endif /* CONFIG_CIFS_ACL */
303
321
} else if (strncmp(ea_name,
304
322
CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
305
cFYI(1, ("Trusted xattr namespace not supported yet"));
323
cFYI(1, "Trusted xattr namespace not supported yet");
306
324
} else if (strncmp(ea_name,
307
325
CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
308
cFYI(1, ("Security xattr namespace not supported yet"));
326
cFYI(1, "Security xattr namespace not supported yet");
311
("illegal xattr request %s (only user namespace supported)",
329
"illegal xattr request %s (only user namespace supported)",
314
332
/* We could add an additional check for streams ie
315
333
if proc/fs/cifs/streamstoxattr is set then
347
367
cifs_sb = CIFS_SB(sb);
348
pTcon = cifs_sb->tcon;
350
368
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
351
369
return -EOPNOTSUPP;
371
tlink = cifs_sb_tlink(cifs_sb);
373
return PTR_ERR(tlink);
374
pTcon = tlink_tcon(tlink);
355
378
full_path = build_path_from_dentry(direntry);
356
379
if (full_path == NULL) {
361
383
/* return dos attributes as pseudo xattr */
362
384
/* return alt name if available as pseudo attr */
364
386
/* if proc/fs/cifs/streamstoxattr is set then
365
387
search server for EAs or streams to
366
388
returns as xattrs */
367
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, data, buf_size,
389
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
390
buf_size, cifs_sb->local_nls,
369
391
cifs_sb->mnt_cifs_flags &
370
392
CIFS_MOUNT_MAP_SPECIAL_CHR);
372
395
kfree(full_path);
397
cifs_put_tlink(tlink);