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
|
|
|
|
#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
|
2010-11-27 20:37:54 +03:00
|
|
|
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
|
2005-04-17 02:20:36 +04:00
|
|
|
|
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
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
int cifs_removexattr(struct dentry *direntry, const char *ea_name)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
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;
|
2010-09-30 03:51:11 +04:00
|
|
|
char *full_path = NULL;
|
2007-07-07 02:44:50 +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();
|
2007-07-07 02:44:50 +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 remove_ea_exit;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2007-07-07 02:44:50 +04:00
|
|
|
if (ea_name == NULL) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Null xattr names not supported\n");
|
2016-04-14 01:30:15 +03:00
|
|
|
} else if (!strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 02:20:36 +04:00
|
|
|
goto remove_ea_exit;
|
|
|
|
|
2011-08-12 00:00:47 +04:00
|
|
|
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
|
2014-01-27 09:53:43 +04:00
|
|
|
if (pTcon->ses->server->ops->set_EA)
|
|
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
|
|
|
full_path, ea_name, NULL, (__u16)0,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2016-04-14 01:30:15 +03:00
|
|
|
} else if (!strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)) {
|
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
|
|
goto remove_ea_exit;
|
|
|
|
|
|
|
|
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
|
|
|
|
if (pTcon->ses->server->ops->set_EA)
|
|
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
|
|
|
full_path, ea_name, NULL, (__u16)0,
|
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
|
|
|
} else {
|
|
|
|
cifs_dbg(FYI,
|
|
|
|
"illegal xattr request %s (only user namespace supported)\n",
|
|
|
|
ea_name);
|
|
|
|
/* BB what if no namespace prefix? */
|
|
|
|
/* Should we just pass them to server, except for
|
|
|
|
system and perhaps security prefixes? */
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
remove_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
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
int cifs_setxattr(struct dentry *direntry, const char *ea_name,
|
|
|
|
const void *ea_value, size_t value_size, int flags)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
2012-06-20 11:21:16 +04:00
|
|
|
unsigned int xid;
|
2016-04-11 00:07:33 +03:00
|
|
|
struct super_block *sb = direntry->d_sb;
|
|
|
|
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
|
|
|
|
|
|
|
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 set_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 */
|
2007-07-07 02:44:50 +04:00
|
|
|
if (value_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;
|
|
|
|
goto set_ea_exit;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2007-07-07 02:44:50 +04:00
|
|
|
if (ea_name == NULL) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Null xattr names not supported\n");
|
2011-08-12 00:00:47 +04:00
|
|
|
} else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
|
|
|
|
== 0) {
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 02:20:36 +04:00
|
|
|
goto set_ea_exit;
|
2016-04-14 01:30:13 +03:00
|
|
|
if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0)
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "attempt to set cifs inode metadata\n");
|
2008-02-08 02:25:02 +03:00
|
|
|
|
2011-08-12 00:00:47 +04:00
|
|
|
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
|
2014-01-27 09:53:43 +04:00
|
|
|
if (pTcon->ses->server->ops->set_EA)
|
|
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
|
|
|
full_path, ea_name, ea_value, (__u16)value_size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2011-08-12 00:00:47 +04:00
|
|
|
} else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)
|
|
|
|
== 0) {
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 02:20:36 +04:00
|
|
|
goto set_ea_exit;
|
|
|
|
|
2011-08-12 00:00:47 +04:00
|
|
|
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
|
2014-01-27 09:53:43 +04:00
|
|
|
if (pTcon->ses->server->ops->set_EA)
|
|
|
|
rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
|
|
|
|
full_path, ea_name, ea_value, (__u16)value_size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2016-04-14 01:30:13 +03:00
|
|
|
} else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) {
|
2012-03-02 10:17:26 +04:00
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
struct cifs_ntsd *pacl;
|
2011-04-19 22:27:10 +04:00
|
|
|
pacl = kmalloc(value_size, GFP_KERNEL);
|
|
|
|
if (!pacl) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
} else {
|
|
|
|
memcpy(pacl, ea_value, value_size);
|
2014-02-03 09:31:47 +04:00
|
|
|
if (pTcon->ses->server->ops->set_acl)
|
|
|
|
rc = pTcon->ses->server->ops->set_acl(pacl,
|
2015-03-18 01:25:59 +03:00
|
|
|
value_size, d_inode(direntry),
|
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 */
|
2015-03-18 01:25:59 +03:00
|
|
|
CIFS_I(d_inode(direntry))->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
|
|
|
#else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Set CIFS ACL not supported yet\n");
|
2011-04-19 22:27:10 +04:00
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
2016-04-14 01:30:13 +03:00
|
|
|
if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) {
|
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)
|
|
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
|
|
ea_value, (const int)value_size,
|
|
|
|
ACL_TYPE_ACCESS, cifs_sb->local_nls,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_remap(cifs_sb));
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "set POSIX ACL rc %d\n", rc);
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "set POSIX ACL not supported\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
2016-04-14 01:30:13 +03:00
|
|
|
} else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) {
|
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)
|
|
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
|
|
ea_value, (const int)value_size,
|
2005-04-29 09:41:06 +04:00
|
|
|
ACL_TYPE_DEFAULT, cifs_sb->local_nls,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_remap(cifs_sb));
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "set POSIX default ACL rc %d\n", rc);
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "set default POSIX ACL not supported\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
} else {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "illegal xattr request %s (only user namespace supported)\n",
|
|
|
|
ea_name);
|
2005-04-17 02:20:36 +04:00
|
|
|
/* BB what if no namespace prefix? */
|
2007-07-07 02:44:50 +04:00
|
|
|
/* Should we just pass them to server, except for
|
2005-04-17 02:20:36 +04:00
|
|
|
system and perhaps security prefixes? */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_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
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-04-11 07:48:00 +03:00
|
|
|
ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode,
|
|
|
|
const char *ea_name, void *ea_value, size_t buf_size)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
2012-06-20 11:21:16 +04:00
|
|
|
unsigned int xid;
|
2016-04-11 00:07:33 +03:00
|
|
|
struct super_block *sb = direntry->d_sb;
|
|
|
|
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
|
|
|
|
|
|
|
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 get_ea_exit;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
|
|
/* return alt name if available as pseudo attr */
|
2007-07-07 02:44:50 +04:00
|
|
|
if (ea_name == NULL) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Null xattr names not supported\n");
|
2011-08-12 00:00:47 +04:00
|
|
|
} else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
|
|
|
|
== 0) {
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 02:20:36 +04:00
|
|
|
goto get_ea_exit;
|
|
|
|
|
2016-04-14 01:30:13 +03:00
|
|
|
if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "attempt to query cifs inode metadata\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
/* revalidate/getattr then populate from inode */
|
|
|
|
} /* BB add else when above is implemented */
|
2011-08-12 00:00:47 +04:00
|
|
|
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
|
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, ea_name, ea_value, buf_size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2011-08-12 00:00:47 +04:00
|
|
|
} else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
|
2007-07-07 02:44:50 +04:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 02:20:36 +04:00
|
|
|
goto get_ea_exit;
|
|
|
|
|
2011-08-12 00:00:47 +04:00
|
|
|
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
|
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, ea_name, ea_value, buf_size,
|
2014-09-27 11:19:01 +04:00
|
|
|
cifs_sb->local_nls, cifs_remap(cifs_sb));
|
2016-04-14 01:30:13 +03:00
|
|
|
} else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) {
|
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,
|
2007-07-07 02:44:50 +04:00
|
|
|
ea_value, buf_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));
|
2007-07-07 02:44:50 +04:00
|
|
|
#else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Query POSIX ACL not supported yet\n");
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
2016-04-14 01:30:13 +03:00
|
|
|
} else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) {
|
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,
|
2007-07-07 02:44:50 +04:00
|
|
|
ea_value, buf_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));
|
2007-07-07 02:44:50 +04:00
|
|
|
#else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Query POSIX default ACL not supported yet\n");
|
2010-11-27 20:37:54 +03:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
2016-04-14 01:30:13 +03:00
|
|
|
} else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) {
|
2010-11-27 20:37:54 +03:00
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
u32 acllen;
|
|
|
|
struct cifs_ntsd *pacl;
|
|
|
|
|
2014-02-03 09:31:47 +04:00
|
|
|
if (pTcon->ses->server->ops->get_acl == NULL)
|
|
|
|
goto get_ea_exit; /* rc already EOPNOTSUPP */
|
|
|
|
|
|
|
|
pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
|
2016-04-11 07:48:00 +03:00
|
|
|
inode, full_path, &acllen);
|
2010-11-27 20:37:54 +03:00
|
|
|
if (IS_ERR(pacl)) {
|
|
|
|
rc = PTR_ERR(pacl);
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
|
|
|
|
__func__, rc);
|
2010-11-27 20:37:54 +03:00
|
|
|
} else {
|
|
|
|
if (ea_value) {
|
|
|
|
if (acllen > buf_size)
|
|
|
|
acllen = -ERANGE;
|
|
|
|
else
|
|
|
|
memcpy(ea_value, pacl, acllen);
|
|
|
|
}
|
|
|
|
rc = acllen;
|
|
|
|
kfree(pacl);
|
|
|
|
}
|
|
|
|
#else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Query CIFS ACL not supported yet\n");
|
2010-11-27 20:37:54 +03:00
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
2007-07-07 02:44:50 +04:00
|
|
|
} else if (strncmp(ea_name,
|
2011-08-12 00:00:47 +04:00
|
|
|
XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Trusted xattr namespace not supported yet\n");
|
2007-07-07 02:44:50 +04:00
|
|
|
} else if (strncmp(ea_name,
|
2011-08-12 00:00:47 +04:00
|
|
|
XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI, "Security xattr namespace not supported yet\n");
|
2008-02-08 02:25:02 +03:00
|
|
|
} else
|
2013-05-05 07:12:25 +04:00
|
|
|
cifs_dbg(FYI,
|
|
|
|
"illegal xattr request %s (only user namespace supported)\n",
|
|
|
|
ea_name);
|
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
|
|
|
|
|
|
|
get_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
|
|
|
#endif
|
|
|
|
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;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
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
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|