Add way to query file attributes via cifs xattr
Add parsing for new pseudo-xattr user.cifs.dosattrib file attribute so tools can recognize what kind of file it is, and verify if common SMB3 attributes (system, hidden, archive, sparse, indexed etc.) are set. Signed-off-by: Steve French <steve.french@primarydata.com> Reviewed-by: Pavel Shilovsky <pshilovsky@samba.org>
This commit is contained in:
parent
1573d2caf7
commit
a958fff242
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#define MAX_EA_VALUE_SIZE 65535
|
#define MAX_EA_VALUE_SIZE 65535
|
||||||
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
|
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
|
||||||
|
#define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */
|
||||||
|
|
||||||
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
||||||
|
|
||||||
|
@ -144,6 +145,31 @@ out:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cifs_attrib_get(struct dentry *dentry,
|
||||||
|
struct inode *inode, void *value,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
ssize_t rc;
|
||||||
|
__u32 *pattribute;
|
||||||
|
|
||||||
|
rc = cifs_revalidate_dentry_attr(dentry);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if ((value == NULL) || (size == 0))
|
||||||
|
return sizeof(__u32);
|
||||||
|
else if (size < sizeof(__u32))
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
/* return dos attributes as pseudo xattr */
|
||||||
|
pattribute = (__u32 *)value;
|
||||||
|
*pattribute = CIFS_I(inode)->cifsAttrs;
|
||||||
|
|
||||||
|
return sizeof(__u32);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int cifs_xattr_get(const struct xattr_handler *handler,
|
static int cifs_xattr_get(const struct xattr_handler *handler,
|
||||||
struct dentry *dentry, struct inode *inode,
|
struct dentry *dentry, struct inode *inode,
|
||||||
const char *name, void *value, size_t size)
|
const char *name, void *value, size_t size)
|
||||||
|
@ -168,10 +194,16 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* return dos attributes as pseudo xattr */
|
|
||||||
/* return alt name if available as pseudo attr */
|
/* return alt name if available as pseudo attr */
|
||||||
switch (handler->flags) {
|
switch (handler->flags) {
|
||||||
case XATTR_USER:
|
case XATTR_USER:
|
||||||
|
cifs_dbg(FYI, "%s:querying user xattr %s\n", __func__, name);
|
||||||
|
if (strcmp(name, CIFS_XATTR_ATTRIB) == 0) {
|
||||||
|
rc = cifs_attrib_get(dentry, inode, value, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue