2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* fs/cifs/xattr.c
|
|
|
|
*
|
2007-07-07 02:44:50 +04:00
|
|
|
* Copyright (c) International Business Machines Corp., 2003, 2007
|
2005-04-17 02:20:36 +04: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 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2011-08-12 00:00:47 +04:00
|
|
|
#include <linux/xattr.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include "cifsfs.h"
|
|
|
|
#include "cifspdu.h"
|
|
|
|
#include "cifsglob.h"
|
|
|
|
#include "cifsproto.h"
|
|
|
|
#include "cifs_debug.h"
|
2014-09-27 11:19:01 +04:00
|
|
|
#include "cifs_fs_sb.h"
|
|
|
|
#include "cifs_unicode.h"
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define MAX_EA_VALUE_SIZE 65535
|
2010-11-27 20:37:54 +03:00
|
|
|
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
|
2016-09-19 19:14:06 +03:00
|
|
|
#define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */
|
2016-09-20 11:05:57 +03:00
|
|
|
#define CIFS_XATTR_CREATETIME "cifs.creationtime" /* user.cifs.creationtime */
|
2011-08-12 00:00:47 +04:00
|
|
|
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT };
|
2010-09-30 03:51:11 +04:00
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
static int cifs_xattr_set(const struct xattr_handler *handler,
|
2016-05-27 17:19:30 +03:00
|
|
|
struct dentry *dentry, struct inode *inode,
|
|
|
|
const char *name, const void *value,
|
|
|
|
size_t size, int flags)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int rc = -EOPNOTSUPP;
|
2012-06-20 11:21:16 +04:00
|
|
|
unsigned int xid;
|
2016-04-22 13:11:38 +03:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2016-04-11 00:07:33 +03:00
|
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
2010-09-30 03:51:11 +04:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 08:34:02 +04:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 02:44:50 +04:00
|
|
|
char *full_path;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-09-30 03:51:11 +04:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2012-06-20 11:21:16 +04:00
|
|
|
xid = get_xid();
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
full_path = build_path_from_dentry(dentry);
|
2007-07-07 02:44:50 +04:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 16:42:34 +04:00
|
|
|
rc = -ENOMEM;
|
2016-04-22 13:11:38 +03:00
|
|
|
goto out;
|
2005-04-17 02:20:36 +04: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 02:44:50 +04:00
|
|
|
search server for EAs or streams to
|
2005-04-17 02:20:36 +04:00
|
|
|
returns as xattrs */
|
2016-04-22 13:11:38 +03:00
|
|
|
if (size > MAX_EA_VALUE_SIZE) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "size of EA value too large\n");
|
2010-09-30 03:51:11 +04:00
|
|
|
rc = -EOPNOTSUPP;
|
2016-04-22 13:11:38 +03:00
|
|
|
goto out;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
switch (handler->flags) {
|
|
|
|
case XATTR_USER:
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2016-04-22 13:11:38 +03:00
|
|
|
goto out;
|
2008-02-08 02:25:02 +03:00
|
|
|
|
2014-01-27 09:53:43 +04:00
|
|
|
if (pTcon->ses->server->ops->set_EA)
|
|
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
2016-04-22 13:11:38 +03:00
|
|
|
full_path, name, value, (__u16)size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2016-04-22 13:11:38 +03:00
|
|
|
break;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
case XATTR_CIFS_ACL: {
|
2012-03-02 10:17:26 +04:00
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
struct cifs_ntsd *pacl;
|
2016-04-22 13:11:38 +03:00
|
|
|
|
|
|
|
if (!value)
|
|
|
|
goto out;
|
|
|
|
pacl = kmalloc(size, GFP_KERNEL);
|
2011-04-19 22:27:10 +04:00
|
|
|
if (!pacl) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
} else {
|
2016-04-22 13:11:38 +03:00
|
|
|
memcpy(pacl, value, size);
|
|
|
|
if (value &&
|
|
|
|
pTcon->ses->server->ops->set_acl)
|
2014-02-03 09:31:47 +04:00
|
|
|
rc = pTcon->ses->server->ops->set_acl(pacl,
|
2016-05-27 17:19:30 +03:00
|
|
|
size, inode,
|
2014-02-03 09:31:47 +04:00
|
|
|
full_path, CIFS_ACL_DACL);
|
|
|
|
else
|
|
|
|
rc = -EOPNOTSUPP;
|
2011-04-19 22:27:10 +04:00
|
|
|
if (rc == 0) /* force revalidate of the inode */
|
2016-05-27 17:19:30 +03:00
|
|
|
CIFS_I(inode)->time = 0;
|
2011-04-19 22:27:10 +04:00
|
|
|
kfree(pacl);
|
2012-03-02 10:17:26 +04:00
|
|
|
}
|
2011-04-19 22:27:10 +04:00
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
2016-04-22 13:11:38 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XATTR_ACL_ACCESS:
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2016-04-22 13:11:38 +03:00
|
|
|
if (!value)
|
|
|
|
goto out;
|
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
|
|
|
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 02:20:36 +04:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2016-04-22 13:11:38 +03:00
|
|
|
if (!value)
|
|
|
|
goto out;
|
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
|
|
|
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 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
out:
|
2005-11-07 12:01:34 +03:00
|
|
|
kfree(full_path);
|
2012-06-20 11:21:16 +04:00
|
|
|
free_xid(xid);
|
2010-09-30 03:51:11 +04:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 02:20:36 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-09-19 19:14:06 +03: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 11:05:57 +03: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);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-09-19 19:14:06 +03:00
|
|
|
|
2016-04-22 13:11:38 +03: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 02:20:36 +04:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
2012-06-20 11:21:16 +04:00
|
|
|
unsigned int xid;
|
2016-04-22 13:11:38 +03:00
|
|
|
struct super_block *sb = dentry->d_sb;
|
2016-04-11 00:07:33 +03:00
|
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
2010-09-30 03:51:11 +04:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 08:34:02 +04:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 02:44:50 +04:00
|
|
|
char *full_path;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-09-30 03:51:11 +04:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2012-06-20 11:21:16 +04:00
|
|
|
xid = get_xid();
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
full_path = build_path_from_dentry(dentry);
|
2007-07-07 02:44:50 +04:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 16:42:34 +04:00
|
|
|
rc = -ENOMEM;
|
2016-04-22 13:11:38 +03:00
|
|
|
goto out;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2016-09-19 19:14:06 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* return alt name if available as pseudo attr */
|
2016-04-22 13:11:38 +03:00
|
|
|
switch (handler->flags) {
|
|
|
|
case XATTR_USER:
|
2016-09-19 19:14:06 +03:00
|
|
|
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;
|
2016-09-20 11:05:57 +03:00
|
|
|
} else if (strcmp(name, CIFS_XATTR_CREATETIME) == 0) {
|
|
|
|
rc = cifs_creation_time_get(dentry, inode, value, size);
|
|
|
|
break;
|
2016-09-19 19:14:06 +03:00
|
|
|
}
|
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2016-04-22 13:11:38 +03:00
|
|
|
goto out;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2014-01-27 09:53:43 +04:00
|
|
|
if (pTcon->ses->server->ops->query_all_EAs)
|
|
|
|
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
|
2016-04-22 13:11:38 +03:00
|
|
|
full_path, name, value, size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2016-04-22 13:11:38 +03:00
|
|
|
break;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-22 13:11:38 +03: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 02:20:36 +04:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2007-07-07 02:44:50 +04:00
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
2005-04-29 09:41:04 +04:00
|
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
2016-04-22 13:11:38 +03:00
|
|
|
value, size, ACL_TYPE_ACCESS,
|
2005-04-29 09:41:06 +04:00
|
|
|
cifs_sb->local_nls,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_remap(cifs_sb));
|
2016-04-22 13:11:38 +03:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XATTR_ACL_DEFAULT:
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2007-07-07 02:44:50 +04:00
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
2005-04-29 09:41:04 +04:00
|
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
2016-04-22 13:11:38 +03:00
|
|
|
value, size, ACL_TYPE_DEFAULT,
|
2005-04-29 09:41:06 +04:00
|
|
|
cifs_sb->local_nls,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_remap(cifs_sb));
|
2016-04-22 13:11:38 +03:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
/* We could add an additional check for streams ie
|
2005-04-17 02:20:36 +04:00
|
|
|
if proc/fs/cifs/streamstoxattr is set then
|
2007-07-07 02:44:50 +04:00
|
|
|
search server for EAs or streams to
|
2005-04-17 02:20:36 +04:00
|
|
|
returns as xattrs */
|
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
if (rc == -EINVAL)
|
|
|
|
rc = -EOPNOTSUPP;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2016-04-22 13:11:38 +03:00
|
|
|
out:
|
2005-11-07 12:01:34 +03:00
|
|
|
kfree(full_path);
|
2012-06-20 11:21:16 +04:00
|
|
|
free_xid(xid);
|
2010-09-30 03:51:11 +04:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 02:20:36 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
2012-06-20 11:21:16 +04:00
|
|
|
unsigned int xid;
|
2016-04-11 00:07:33 +03:00
|
|
|
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
|
2010-09-30 03:51:11 +04:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 08:34:02 +04:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 02:44:50 +04:00
|
|
|
char *full_path;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2006-08-16 23:44:25 +04:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-09-30 03:51:11 +04:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2012-06-20 11:21:16 +04:00
|
|
|
xid = get_xid();
|
2006-08-16 23:44:25 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
full_path = build_path_from_dentry(direntry);
|
2007-07-07 02:44:50 +04:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 16:42:34 +04:00
|
|
|
rc = -ENOMEM;
|
2010-09-30 03:51:11 +04:00
|
|
|
goto list_ea_exit;
|
2005-04-17 02:20:36 +04: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 02:44:50 +04:00
|
|
|
search server for EAs or streams to
|
2005-04-17 02:20:36 +04:00
|
|
|
returns as xattrs */
|
|
|
|
|
2014-01-27 09:53:43 +04:00
|
|
|
if (pTcon->ses->server->ops->query_all_EAs)
|
|
|
|
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
|
|
|
|
full_path, NULL, data, buf_size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2010-09-30 03:51:11 +04:00
|
|
|
list_ea_exit:
|
2005-11-07 12:01:34 +03:00
|
|
|
kfree(full_path);
|
2012-06-20 11:21:16 +04:00
|
|
|
free_xid(xid);
|
2010-09-30 03:51:11 +04:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 02:20:36 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2016-04-22 13:11:38 +03: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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
&cifs_posix_acl_access_xattr_handler,
|
|
|
|
&cifs_posix_acl_default_xattr_handler,
|
|
|
|
NULL
|
|
|
|
};
|