2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* fs/cifs/xattr.c
|
|
|
|
*
|
2007-07-07 05:44:50 +07:00
|
|
|
* Copyright (c) International Business Machines Corp., 2003, 2007
|
2005-04-17 05:20:36 +07:00
|
|
|
* Author(s): Steve French (sfrench@us.ibm.com)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
|
|
* by the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
|
|
* the GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/posix_acl_xattr.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2011-08-12 03:00:47 +07:00
|
|
|
#include <linux/xattr.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "cifsfs.h"
|
|
|
|
#include "cifspdu.h"
|
|
|
|
#include "cifsglob.h"
|
|
|
|
#include "cifsproto.h"
|
|
|
|
#include "cifs_debug.h"
|
2014-09-27 14:19:01 +07:00
|
|
|
#include "cifs_fs_sb.h"
|
|
|
|
#include "cifs_unicode.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#define MAX_EA_VALUE_SIZE 65535
|
2010-11-28 00:37:54 +07:00
|
|
|
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
|
2016-09-19 23:14:06 +07:00
|
|
|
#define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */
|
2016-09-20 15:05:57 +07:00
|
|
|
#define CIFS_XATTR_CREATETIME "cifs.creationtime" /* user.cifs.creationtime */
|
2018-08-11 06:46:58 +07:00
|
|
|
/*
|
|
|
|
* Although these three are just aliases for the above, need to move away from
|
|
|
|
* confusing users and using the 20+ year old term 'cifs' when it is no longer
|
|
|
|
* secure, replaced by SMB2 (then even more highly secure SMB3) many years ago
|
|
|
|
*/
|
|
|
|
#define SMB3_XATTR_CIFS_ACL "system.smb3_acl"
|
|
|
|
#define SMB3_XATTR_ATTRIB "smb3.dosattrib" /* full name: user.smb3.dosattrib */
|
|
|
|
#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
|
2011-08-12 03:00:47 +07:00
|
|
|
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT };
|
2010-09-30 06:51:11 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
static int cifs_xattr_set(const struct xattr_handler *handler,
|
2016-05-27 21:19:30 +07:00
|
|
|
struct dentry *dentry, struct inode *inode,
|
|
|
|
const char *name, const void *value,
|
|
|
|
size_t size, int flags)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int rc = -EOPNOTSUPP;
|
2012-06-20 14:21:16 +07:00
|
|
|
unsigned int xid;
|
2016-04-22 17:11:38 +07:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2016-04-11 04:07:33 +07:00
|
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
2010-09-30 06:51:11 +07:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 11:34:02 +07:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 05:44:50 +07:00
|
|
|
char *full_path;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-30 06:51:11 +07:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2012-06-20 14:21:16 +07:00
|
|
|
xid = get_xid();
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
full_path = build_path_from_dentry(dentry);
|
2007-07-07 05:44:50 +07:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 19:42:34 +07:00
|
|
|
rc = -ENOMEM;
|
2016-04-22 17:11:38 +07:00
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
|
|
/* return alt name if available as pseudo attr */
|
|
|
|
|
|
|
|
/* if proc/fs/cifs/streamstoxattr is set then
|
2007-07-07 05:44:50 +07:00
|
|
|
search server for EAs or streams to
|
2005-04-17 05:20:36 +07:00
|
|
|
returns as xattrs */
|
2016-04-22 17:11:38 +07:00
|
|
|
if (size > MAX_EA_VALUE_SIZE) {
|
2013-05-05 10:12:25 +07:00
|
|
|
cifs_dbg(FYI, "size of EA value too large\n");
|
2010-09-30 06:51:11 +07:00
|
|
|
rc = -EOPNOTSUPP;
|
2016-04-22 17:11:38 +07:00
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
switch (handler->flags) {
|
|
|
|
case XATTR_USER:
|
2007-07-07 05:44:50 +07:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2016-04-22 17:11:38 +07:00
|
|
|
goto out;
|
2008-02-08 06:25:02 +07:00
|
|
|
|
2014-01-27 12:53:43 +07:00
|
|
|
if (pTcon->ses->server->ops->set_EA)
|
|
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
2016-04-22 17:11:38 +07:00
|
|
|
full_path, name, value, (__u16)size,
|
2017-08-24 08:24:56 +07:00
|
|
|
cifs_sb->local_nls, cifs_sb);
|
2016-04-22 17:11:38 +07:00
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
case XATTR_CIFS_ACL: {
|
2012-03-02 13:17:26 +07:00
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
struct cifs_ntsd *pacl;
|
2016-04-22 17:11:38 +07:00
|
|
|
|
|
|
|
if (!value)
|
|
|
|
goto out;
|
|
|
|
pacl = kmalloc(size, GFP_KERNEL);
|
2011-04-20 01:27:10 +07:00
|
|
|
if (!pacl) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
} else {
|
2016-04-22 17:11:38 +07:00
|
|
|
memcpy(pacl, value, size);
|
|
|
|
if (value &&
|
|
|
|
pTcon->ses->server->ops->set_acl)
|
2014-02-03 12:31:47 +07:00
|
|
|
rc = pTcon->ses->server->ops->set_acl(pacl,
|
2016-05-27 21:19:30 +07:00
|
|
|
size, inode,
|
2014-02-03 12:31:47 +07:00
|
|
|
full_path, CIFS_ACL_DACL);
|
|
|
|
else
|
|
|
|
rc = -EOPNOTSUPP;
|
2011-04-20 01:27:10 +07:00
|
|
|
if (rc == 0) /* force revalidate of the inode */
|
2016-05-27 21:19:30 +07:00
|
|
|
CIFS_I(inode)->time = 0;
|
2011-04-20 01:27:10 +07:00
|
|
|
kfree(pacl);
|
2012-03-02 13:17:26 +07:00
|
|
|
}
|
2011-04-20 01:27:10 +07:00
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
2016-04-22 17:11:38 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XATTR_ACL_ACCESS:
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2016-04-22 17:11:38 +07:00
|
|
|
if (!value)
|
|
|
|
goto out;
|
2017-11-28 04:05:09 +07:00
|
|
|
if (sb->s_flags & SB_POSIXACL)
|
2016-04-22 17:11:38 +07:00
|
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
|
|
value, (const int)size,
|
|
|
|
ACL_TYPE_ACCESS, cifs_sb->local_nls,
|
|
|
|
cifs_remap(cifs_sb));
|
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XATTR_ACL_DEFAULT:
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2016-04-22 17:11:38 +07:00
|
|
|
if (!value)
|
|
|
|
goto out;
|
2017-11-28 04:05:09 +07:00
|
|
|
if (sb->s_flags & SB_POSIXACL)
|
2016-04-22 17:11:38 +07:00
|
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
|
|
value, (const int)size,
|
|
|
|
ACL_TYPE_DEFAULT, cifs_sb->local_nls,
|
|
|
|
cifs_remap(cifs_sb));
|
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
out:
|
2005-11-07 16:01:34 +07:00
|
|
|
kfree(full_path);
|
2012-06-20 14:21:16 +07:00
|
|
|
free_xid(xid);
|
2010-09-30 06:51:11 +07:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-09-19 23:14:06 +07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-09-20 15:05:57 +07:00
|
|
|
static int cifs_creation_time_get(struct dentry *dentry, struct inode *inode,
|
|
|
|
void *value, size_t size)
|
|
|
|
{
|
|
|
|
ssize_t rc;
|
|
|
|
__u64 * pcreatetime;
|
|
|
|
|
|
|
|
rc = cifs_revalidate_dentry_attr(dentry);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
if ((value == NULL) || (size == 0))
|
|
|
|
return sizeof(__u64);
|
|
|
|
else if (size < sizeof(__u64))
|
|
|
|
return -ERANGE;
|
|
|
|
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
|
|
pcreatetime = (__u64 *)value;
|
|
|
|
*pcreatetime = CIFS_I(inode)->createtime;
|
|
|
|
return sizeof(__u64);
|
|
|
|
}
|
|
|
|
|
2016-09-19 23:14:06 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
static int cifs_xattr_get(const struct xattr_handler *handler,
|
|
|
|
struct dentry *dentry, struct inode *inode,
|
|
|
|
const char *name, void *value, size_t size)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
2012-06-20 14:21:16 +07:00
|
|
|
unsigned int xid;
|
2016-04-22 17:11:38 +07:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2016-04-11 04:07:33 +07:00
|
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
2010-09-30 06:51:11 +07:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 11:34:02 +07:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 05:44:50 +07:00
|
|
|
char *full_path;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-30 06:51:11 +07:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2012-06-20 14:21:16 +07:00
|
|
|
xid = get_xid();
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
full_path = build_path_from_dentry(dentry);
|
2007-07-07 05:44:50 +07:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 19:42:34 +07:00
|
|
|
rc = -ENOMEM;
|
2016-04-22 17:11:38 +07:00
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2016-09-19 23:14:06 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* return alt name if available as pseudo attr */
|
2016-04-22 17:11:38 +07:00
|
|
|
switch (handler->flags) {
|
|
|
|
case XATTR_USER:
|
2016-09-19 23:14:06 +07:00
|
|
|
cifs_dbg(FYI, "%s:querying user xattr %s\n", __func__, name);
|
2018-08-11 06:46:58 +07:00
|
|
|
if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
|
|
|
|
(strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
|
2016-09-19 23:14:06 +07:00
|
|
|
rc = cifs_attrib_get(dentry, inode, value, size);
|
|
|
|
break;
|
2018-08-11 06:46:58 +07:00
|
|
|
} else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
|
|
|
|
(strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
|
2016-09-20 15:05:57 +07:00
|
|
|
rc = cifs_creation_time_get(dentry, inode, value, size);
|
|
|
|
break;
|
2016-09-19 23:14:06 +07:00
|
|
|
}
|
|
|
|
|
2007-07-07 05:44:50 +07:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2016-04-22 17:11:38 +07:00
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-01-27 12:53:43 +07:00
|
|
|
if (pTcon->ses->server->ops->query_all_EAs)
|
|
|
|
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
|
2017-05-13 08:59:10 +07:00
|
|
|
full_path, name, value, size, cifs_sb);
|
2016-04-22 17:11:38 +07:00
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
case XATTR_CIFS_ACL: {
|
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
u32 acllen;
|
|
|
|
struct cifs_ntsd *pacl;
|
|
|
|
|
|
|
|
if (pTcon->ses->server->ops->get_acl == NULL)
|
|
|
|
goto out; /* rc already EOPNOTSUPP */
|
|
|
|
|
|
|
|
pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
|
|
|
|
inode, full_path, &acllen);
|
|
|
|
if (IS_ERR(pacl)) {
|
|
|
|
rc = PTR_ERR(pacl);
|
|
|
|
cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
|
|
|
|
__func__, rc);
|
|
|
|
} else {
|
|
|
|
if (value) {
|
|
|
|
if (acllen > size)
|
|
|
|
acllen = -ERANGE;
|
|
|
|
else
|
|
|
|
memcpy(value, pacl, acllen);
|
|
|
|
}
|
|
|
|
rc = acllen;
|
|
|
|
kfree(pacl);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XATTR_ACL_ACCESS:
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2017-11-28 04:05:09 +07:00
|
|
|
if (sb->s_flags & SB_POSIXACL)
|
2005-04-29 12:41:04 +07:00
|
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
2016-04-22 17:11:38 +07:00
|
|
|
value, size, ACL_TYPE_ACCESS,
|
2005-04-29 12:41:06 +07:00
|
|
|
cifs_sb->local_nls,
|
2014-09-27 14:19:01 +07:00
|
|
|
cifs_remap(cifs_sb));
|
2016-04-22 17:11:38 +07:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XATTR_ACL_DEFAULT:
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2017-11-28 04:05:09 +07:00
|
|
|
if (sb->s_flags & SB_POSIXACL)
|
2005-04-29 12:41:04 +07:00
|
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
2016-04-22 17:11:38 +07:00
|
|
|
value, size, ACL_TYPE_DEFAULT,
|
2005-04-29 12:41:06 +07:00
|
|
|
cifs_sb->local_nls,
|
2014-09-27 14:19:01 +07:00
|
|
|
cifs_remap(cifs_sb));
|
2016-04-22 17:11:38 +07:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-07-07 05:44:50 +07:00
|
|
|
/* We could add an additional check for streams ie
|
2005-04-17 05:20:36 +07:00
|
|
|
if proc/fs/cifs/streamstoxattr is set then
|
2007-07-07 05:44:50 +07:00
|
|
|
search server for EAs or streams to
|
2005-04-17 05:20:36 +07:00
|
|
|
returns as xattrs */
|
|
|
|
|
2007-07-07 05:44:50 +07:00
|
|
|
if (rc == -EINVAL)
|
|
|
|
rc = -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
out:
|
2005-11-07 16:01:34 +07:00
|
|
|
kfree(full_path);
|
2012-06-20 14:21:16 +07:00
|
|
|
free_xid(xid);
|
2010-09-30 06:51:11 +07:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-07-07 05:44:50 +07:00
|
|
|
ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
2012-06-20 14:21:16 +07:00
|
|
|
unsigned int xid;
|
2016-04-11 04:07:33 +07:00
|
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
|
2010-09-30 06:51:11 +07:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 11:34:02 +07:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 05:44:50 +07:00
|
|
|
char *full_path;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-07-07 05:44:50 +07:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2006-08-17 02:44:25 +07:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-09-30 06:51:11 +07:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2012-06-20 14:21:16 +07:00
|
|
|
xid = get_xid();
|
2006-08-17 02:44:25 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
full_path = build_path_from_dentry(direntry);
|
2007-07-07 05:44:50 +07:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 19:42:34 +07:00
|
|
|
rc = -ENOMEM;
|
2010-09-30 06:51:11 +07:00
|
|
|
goto list_ea_exit;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
|
|
/* return alt name if available as pseudo attr */
|
|
|
|
|
|
|
|
/* if proc/fs/cifs/streamstoxattr is set then
|
2007-07-07 05:44:50 +07:00
|
|
|
search server for EAs or streams to
|
2005-04-17 05:20:36 +07:00
|
|
|
returns as xattrs */
|
|
|
|
|
2014-01-27 12:53:43 +07:00
|
|
|
if (pTcon->ses->server->ops->query_all_EAs)
|
|
|
|
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
|
2017-05-13 08:59:10 +07:00
|
|
|
full_path, NULL, data, buf_size, cifs_sb);
|
2010-09-30 06:51:11 +07:00
|
|
|
list_ea_exit:
|
2005-11-07 16:01:34 +07:00
|
|
|
kfree(full_path);
|
2012-06-20 14:21:16 +07:00
|
|
|
free_xid(xid);
|
2010-09-30 06:51:11 +07:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 05:20:36 +07:00
|
|
|
return rc;
|
|
|
|
}
|
2016-04-22 17:11:38 +07:00
|
|
|
|
|
|
|
static const struct xattr_handler cifs_user_xattr_handler = {
|
|
|
|
.prefix = XATTR_USER_PREFIX,
|
|
|
|
.flags = XATTR_USER,
|
|
|
|
.get = cifs_xattr_get,
|
|
|
|
.set = cifs_xattr_set,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* os2.* attributes are treated like user.* attributes */
|
|
|
|
static const struct xattr_handler cifs_os2_xattr_handler = {
|
|
|
|
.prefix = XATTR_OS2_PREFIX,
|
|
|
|
.flags = XATTR_USER,
|
|
|
|
.get = cifs_xattr_get,
|
|
|
|
.set = cifs_xattr_set,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct xattr_handler cifs_cifs_acl_xattr_handler = {
|
|
|
|
.name = CIFS_XATTR_CIFS_ACL,
|
|
|
|
.flags = XATTR_CIFS_ACL,
|
|
|
|
.get = cifs_xattr_get,
|
|
|
|
.set = cifs_xattr_set,
|
|
|
|
};
|
|
|
|
|
2018-08-11 06:46:58 +07:00
|
|
|
/*
|
|
|
|
* Although this is just an alias for the above, need to move away from
|
|
|
|
* confusing users and using the 20 year old term 'cifs' when it is no
|
|
|
|
* longer secure and was replaced by SMB2/SMB3 a long time ago, and
|
|
|
|
* SMB3 and later are highly secure.
|
|
|
|
*/
|
|
|
|
static const struct xattr_handler smb3_acl_xattr_handler = {
|
|
|
|
.name = SMB3_XATTR_CIFS_ACL,
|
|
|
|
.flags = XATTR_CIFS_ACL,
|
|
|
|
.get = cifs_xattr_get,
|
|
|
|
.set = cifs_xattr_set,
|
|
|
|
};
|
|
|
|
|
2016-04-22 17:11:38 +07:00
|
|
|
static const struct xattr_handler cifs_posix_acl_access_xattr_handler = {
|
|
|
|
.name = XATTR_NAME_POSIX_ACL_ACCESS,
|
|
|
|
.flags = XATTR_ACL_ACCESS,
|
|
|
|
.get = cifs_xattr_get,
|
|
|
|
.set = cifs_xattr_set,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct xattr_handler cifs_posix_acl_default_xattr_handler = {
|
|
|
|
.name = XATTR_NAME_POSIX_ACL_DEFAULT,
|
|
|
|
.flags = XATTR_ACL_DEFAULT,
|
|
|
|
.get = cifs_xattr_get,
|
|
|
|
.set = cifs_xattr_set,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct xattr_handler *cifs_xattr_handlers[] = {
|
|
|
|
&cifs_user_xattr_handler,
|
|
|
|
&cifs_os2_xattr_handler,
|
|
|
|
&cifs_cifs_acl_xattr_handler,
|
2018-08-11 06:46:58 +07:00
|
|
|
&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
|
2016-04-22 17:11:38 +07:00
|
|
|
&cifs_posix_acl_access_xattr_handler,
|
|
|
|
&cifs_posix_acl_default_xattr_handler,
|
|
|
|
NULL
|
|
|
|
};
|