2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* fs/cifs/xattr.c
|
|
|
|
*
|
2007-07-07 00:44:50 +02:00
|
|
|
* Copyright (c) International Business Machines Corp., 2003, 2007
|
2005-04-17 00:20:36 +02: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 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2011-08-11 22:00:47 +02:00
|
|
|
#include <linux/xattr.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include "cifsfs.h"
|
|
|
|
#include "cifspdu.h"
|
|
|
|
#include "cifsglob.h"
|
|
|
|
#include "cifsproto.h"
|
|
|
|
#include "cifs_debug.h"
|
|
|
|
|
|
|
|
#define MAX_EA_VALUE_SIZE 65535
|
|
|
|
#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
|
2010-11-27 18:37:54 +01:00
|
|
|
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2011-08-11 22:00:47 +02:00
|
|
|
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
int cifs_removexattr(struct dentry *direntry, const char *ea_name)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
|
|
int xid;
|
|
|
|
struct cifs_sb_info *cifs_sb;
|
2010-09-30 01:51:11 +02:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 06:34:02 +02:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 00:44:50 +02:00
|
|
|
struct super_block *sb;
|
2010-09-30 01:51:11 +02:00
|
|
|
char *full_path = NULL;
|
2007-07-07 00:44:50 +02:00
|
|
|
|
|
|
|
if (direntry == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry->d_inode == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
sb = direntry->d_inode->i_sb;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
2007-07-07 00:44:50 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
cifs_sb = CIFS_SB(sb);
|
2010-09-30 01:51:11 +02:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
|
|
|
xid = GetXid();
|
2007-07-07 00:44:50 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
full_path = build_path_from_dentry(direntry);
|
2007-07-07 00:44:50 +02:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 14:42:34 +02:00
|
|
|
rc = -ENOMEM;
|
2010-09-30 01:51:11 +02:00
|
|
|
goto remove_ea_exit;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2007-07-07 00:44:50 +02:00
|
|
|
if (ea_name == NULL) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "Null xattr names not supported");
|
2011-08-11 22:00:47 +02:00
|
|
|
} else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
|
|
|
|
&& (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN))) {
|
2007-07-07 00:44:50 +02:00
|
|
|
cFYI(1,
|
2010-04-21 05:50:45 +02:00
|
|
|
"illegal xattr request %s (only user namespace supported)",
|
|
|
|
ea_name);
|
2005-04-17 00:20:36 +02:00
|
|
|
/* BB what if no namespace prefix? */
|
|
|
|
/* Should we just pass them to server, except for
|
|
|
|
system and perhaps security prefixes? */
|
|
|
|
} else {
|
2007-07-07 00:44:50 +02:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto remove_ea_exit;
|
|
|
|
|
2011-08-11 22:00:47 +02:00
|
|
|
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
|
2007-07-07 00:44:50 +02:00
|
|
|
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL,
|
2005-04-29 07:41:06 +02:00
|
|
|
(__u16)0, cifs_sb->local_nls,
|
|
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
remove_ea_exit:
|
2005-11-07 10:01:34 +01:00
|
|
|
kfree(full_path);
|
2005-04-17 00:20:36 +02:00
|
|
|
FreeXid(xid);
|
2010-09-30 01:51:11 +02:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
int cifs_setxattr(struct dentry *direntry, const char *ea_name,
|
|
|
|
const void *ea_value, size_t value_size, int flags)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
|
|
int xid;
|
|
|
|
struct cifs_sb_info *cifs_sb;
|
2010-09-30 01:51:11 +02:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 06:34:02 +02:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 00:44:50 +02:00
|
|
|
struct super_block *sb;
|
|
|
|
char *full_path;
|
2011-04-19 20:27:10 +02:00
|
|
|
struct cifs_ntsd *pacl;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry->d_inode == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
sb = direntry->d_inode->i_sb;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
2010-09-30 01:51:11 +02:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
|
|
|
xid = GetXid();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
2007-07-07 00:44:50 +02:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 14:42:34 +02:00
|
|
|
rc = -ENOMEM;
|
2010-09-30 01:51:11 +02:00
|
|
|
goto set_ea_exit;
|
2005-04-17 00:20:36 +02: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 00:44:50 +02:00
|
|
|
search server for EAs or streams to
|
2005-04-17 00:20:36 +02:00
|
|
|
returns as xattrs */
|
2007-07-07 00:44:50 +02:00
|
|
|
if (value_size > MAX_EA_VALUE_SIZE) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "size of EA value too large");
|
2010-09-30 01:51:11 +02:00
|
|
|
rc = -EOPNOTSUPP;
|
|
|
|
goto set_ea_exit;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
if (ea_name == NULL) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "Null xattr names not supported");
|
2011-08-11 22:00:47 +02:00
|
|
|
} else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
|
|
|
|
== 0) {
|
2007-07-07 00:44:50 +02:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto set_ea_exit;
|
2008-02-08 00:25:02 +01:00
|
|
|
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0)
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "attempt to set cifs inode metadata");
|
2008-02-08 00:25:02 +01:00
|
|
|
|
2011-08-11 22:00:47 +02:00
|
|
|
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
|
2007-07-07 00:44:50 +02:00
|
|
|
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
|
2005-04-29 07:41:06 +02:00
|
|
|
(__u16)value_size, cifs_sb->local_nls,
|
|
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2011-08-11 22:00:47 +02:00
|
|
|
} else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)
|
|
|
|
== 0) {
|
2007-07-07 00:44:50 +02:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto set_ea_exit;
|
|
|
|
|
2011-08-11 22:00:47 +02:00
|
|
|
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
|
2007-07-07 00:44:50 +02:00
|
|
|
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
|
2005-04-29 07:41:06 +02:00
|
|
|
(__u16)value_size, cifs_sb->local_nls,
|
|
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2011-04-19 20:27:10 +02:00
|
|
|
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
|
|
|
|
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
|
|
|
|
pacl = kmalloc(value_size, GFP_KERNEL);
|
|
|
|
if (!pacl) {
|
|
|
|
cFYI(1, "%s: Can't allocate memory for ACL",
|
|
|
|
__func__);
|
|
|
|
rc = -ENOMEM;
|
|
|
|
} else {
|
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
memcpy(pacl, ea_value, value_size);
|
|
|
|
rc = set_cifs_acl(pacl, value_size,
|
2011-10-13 17:26:03 +02:00
|
|
|
direntry->d_inode, full_path, CIFS_ACL_DACL);
|
2011-04-19 20:27:10 +02:00
|
|
|
if (rc == 0) /* force revalidate of the inode */
|
|
|
|
CIFS_I(direntry->d_inode)->time = 0;
|
|
|
|
kfree(pacl);
|
|
|
|
#else
|
|
|
|
cFYI(1, "Set CIFS ACL not supported yet");
|
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
2007-07-07 00:44:50 +02:00
|
|
|
int temp;
|
|
|
|
temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
|
2005-04-17 00:20:36 +02:00
|
|
|
strlen(POSIX_ACL_XATTR_ACCESS));
|
|
|
|
if (temp == 0) {
|
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2007-07-07 00:44:50 +02: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,
|
|
|
|
cifs_sb->mnt_cifs_flags &
|
2005-04-29 07:41:06 +02:00
|
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "set POSIX ACL rc %d", rc);
|
2005-04-17 00:20:36 +02:00
|
|
|
#else
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "set POSIX ACL not supported");
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
2007-07-07 00:44:50 +02:00
|
|
|
} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
|
|
|
|
strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
|
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
|
|
ea_value, (const int)value_size,
|
2005-04-29 07:41:06 +02:00
|
|
|
ACL_TYPE_DEFAULT, cifs_sb->local_nls,
|
2007-07-07 00:44:50 +02:00
|
|
|
cifs_sb->mnt_cifs_flags &
|
2005-04-29 07:41:06 +02:00
|
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "set POSIX default ACL rc %d", rc);
|
2005-04-17 00:20:36 +02:00
|
|
|
#else
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "set default POSIX ACL not supported");
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
} else {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "illegal xattr request %s (only user namespace"
|
|
|
|
" supported)", ea_name);
|
2005-04-17 00:20:36 +02:00
|
|
|
/* BB what if no namespace prefix? */
|
2007-07-07 00:44:50 +02:00
|
|
|
/* Should we just pass them to server, except for
|
2005-04-17 00:20:36 +02:00
|
|
|
system and perhaps security prefixes? */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_ea_exit:
|
2005-11-07 10:01:34 +01:00
|
|
|
kfree(full_path);
|
2005-04-17 00:20:36 +02:00
|
|
|
FreeXid(xid);
|
2010-09-30 01:51:11 +02:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
|
|
|
|
void *ea_value, size_t buf_size)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
|
|
int xid;
|
|
|
|
struct cifs_sb_info *cifs_sb;
|
2010-09-30 01:51:11 +02:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 06:34:02 +02:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 00:44:50 +02:00
|
|
|
struct super_block *sb;
|
|
|
|
char *full_path;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry->d_inode == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
sb = direntry->d_inode->i_sb;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
2010-09-30 01:51:11 +02:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
|
|
|
xid = GetXid();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
2007-07-07 00:44:50 +02:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 14:42:34 +02:00
|
|
|
rc = -ENOMEM;
|
2010-09-30 01:51:11 +02:00
|
|
|
goto get_ea_exit;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
/* return dos attributes as pseudo xattr */
|
|
|
|
/* return alt name if available as pseudo attr */
|
2007-07-07 00:44:50 +02:00
|
|
|
if (ea_name == NULL) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "Null xattr names not supported");
|
2011-08-11 22:00:47 +02:00
|
|
|
} else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
|
|
|
|
== 0) {
|
2007-07-07 00:44:50 +02:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto get_ea_exit;
|
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "attempt to query cifs inode metadata");
|
2005-04-17 00:20:36 +02:00
|
|
|
/* revalidate/getattr then populate from inode */
|
|
|
|
} /* BB add else when above is implemented */
|
2011-08-11 22:00:47 +02:00
|
|
|
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
|
2010-02-10 22:18:26 +01:00
|
|
|
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
|
2005-04-29 07:41:06 +02:00
|
|
|
buf_size, cifs_sb->local_nls,
|
|
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2011-08-11 22:00:47 +02:00
|
|
|
} else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
|
2007-07-07 00:44:50 +02:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto get_ea_exit;
|
|
|
|
|
2011-08-11 22:00:47 +02:00
|
|
|
ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
|
2010-02-10 22:18:26 +01:00
|
|
|
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
|
2005-04-29 07:41:06 +02:00
|
|
|
buf_size, cifs_sb->local_nls,
|
|
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2007-07-07 00:44:50 +02:00
|
|
|
} else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
|
2006-01-13 00:44:21 +01:00
|
|
|
strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
2005-04-29 07:41:04 +02:00
|
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
2007-07-07 00:44:50 +02:00
|
|
|
ea_value, buf_size, ACL_TYPE_ACCESS,
|
2005-04-29 07:41:06 +02:00
|
|
|
cifs_sb->local_nls,
|
2007-07-07 00:44:50 +02:00
|
|
|
cifs_sb->mnt_cifs_flags &
|
2005-04-29 07:41:06 +02:00
|
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2007-07-07 00:44:50 +02:00
|
|
|
#else
|
2010-11-27 18:37:54 +01:00
|
|
|
cFYI(1, "Query POSIX ACL not supported yet");
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
2007-07-07 00:44:50 +02:00
|
|
|
} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
|
2006-01-13 00:44:21 +01:00
|
|
|
strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef CONFIG_CIFS_POSIX
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb->s_flags & MS_POSIXACL)
|
2005-04-29 07:41:04 +02:00
|
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
2007-07-07 00:44:50 +02:00
|
|
|
ea_value, buf_size, ACL_TYPE_DEFAULT,
|
2005-04-29 07:41:06 +02:00
|
|
|
cifs_sb->local_nls,
|
2007-07-07 00:44:50 +02:00
|
|
|
cifs_sb->mnt_cifs_flags &
|
2005-04-29 07:41:06 +02:00
|
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2007-07-07 00:44:50 +02:00
|
|
|
#else
|
2010-11-27 18:37:54 +01:00
|
|
|
cFYI(1, "Query POSIX default ACL not supported yet");
|
|
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
|
|
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
|
|
|
|
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
|
|
|
|
#ifdef CONFIG_CIFS_ACL
|
|
|
|
u32 acllen;
|
|
|
|
struct cifs_ntsd *pacl;
|
|
|
|
|
|
|
|
pacl = get_cifs_acl(cifs_sb, direntry->d_inode,
|
|
|
|
full_path, &acllen);
|
|
|
|
if (IS_ERR(pacl)) {
|
|
|
|
rc = PTR_ERR(pacl);
|
|
|
|
cERROR(1, "%s: error %zd getting sec desc",
|
|
|
|
__func__, rc);
|
|
|
|
} else {
|
|
|
|
if (ea_value) {
|
|
|
|
if (acllen > buf_size)
|
|
|
|
acllen = -ERANGE;
|
|
|
|
else
|
|
|
|
memcpy(ea_value, pacl, acllen);
|
|
|
|
}
|
|
|
|
rc = acllen;
|
|
|
|
kfree(pacl);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
cFYI(1, "Query CIFS ACL not supported yet");
|
|
|
|
#endif /* CONFIG_CIFS_ACL */
|
2007-07-07 00:44:50 +02:00
|
|
|
} else if (strncmp(ea_name,
|
2011-08-11 22:00:47 +02:00
|
|
|
XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "Trusted xattr namespace not supported yet");
|
2007-07-07 00:44:50 +02:00
|
|
|
} else if (strncmp(ea_name,
|
2011-08-11 22:00:47 +02:00
|
|
|
XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
|
2010-04-21 05:50:45 +02:00
|
|
|
cFYI(1, "Security xattr namespace not supported yet");
|
2008-02-08 00:25:02 +01:00
|
|
|
} else
|
2007-07-07 00:44:50 +02:00
|
|
|
cFYI(1,
|
2010-04-21 05:50:45 +02:00
|
|
|
"illegal xattr request %s (only user namespace supported)",
|
|
|
|
ea_name);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
/* We could add an additional check for streams ie
|
2005-04-17 00:20:36 +02:00
|
|
|
if proc/fs/cifs/streamstoxattr is set then
|
2007-07-07 00:44:50 +02:00
|
|
|
search server for EAs or streams to
|
2005-04-17 00:20:36 +02:00
|
|
|
returns as xattrs */
|
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
if (rc == -EINVAL)
|
|
|
|
rc = -EOPNOTSUPP;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
get_ea_exit:
|
2005-11-07 10:01:34 +01:00
|
|
|
kfree(full_path);
|
2005-04-17 00:20:36 +02:00
|
|
|
FreeXid(xid);
|
2010-09-30 01:51:11 +02:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
|
|
int xid;
|
|
|
|
struct cifs_sb_info *cifs_sb;
|
2010-09-30 01:51:11 +02:00
|
|
|
struct tcon_link *tlink;
|
2011-05-27 06:34:02 +02:00
|
|
|
struct cifs_tcon *pTcon;
|
2007-07-07 00:44:50 +02:00
|
|
|
struct super_block *sb;
|
|
|
|
char *full_path;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (direntry->d_inode == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
sb = direntry->d_inode->i_sb;
|
2007-07-07 00:44:50 +02:00
|
|
|
if (sb == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
2007-07-07 00:44:50 +02:00
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
2006-08-16 21:44:25 +02:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-09-30 01:51:11 +02:00
|
|
|
tlink = cifs_sb_tlink(cifs_sb);
|
|
|
|
if (IS_ERR(tlink))
|
|
|
|
return PTR_ERR(tlink);
|
|
|
|
pTcon = tlink_tcon(tlink);
|
|
|
|
|
2006-08-16 21:44:25 +02:00
|
|
|
xid = GetXid();
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
full_path = build_path_from_dentry(direntry);
|
2007-07-07 00:44:50 +02:00
|
|
|
if (full_path == NULL) {
|
2009-06-25 14:42:34 +02:00
|
|
|
rc = -ENOMEM;
|
2010-09-30 01:51:11 +02:00
|
|
|
goto list_ea_exit;
|
2005-04-17 00:20:36 +02: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 00:44:50 +02:00
|
|
|
search server for EAs or streams to
|
2005-04-17 00:20:36 +02:00
|
|
|
returns as xattrs */
|
2010-02-10 22:18:26 +01:00
|
|
|
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
|
|
|
|
buf_size, cifs_sb->local_nls,
|
2007-07-07 00:44:50 +02:00
|
|
|
cifs_sb->mnt_cifs_flags &
|
2005-04-29 07:41:06 +02:00
|
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2010-09-30 01:51:11 +02:00
|
|
|
list_ea_exit:
|
2005-11-07 10:01:34 +01:00
|
|
|
kfree(full_path);
|
2005-04-17 00:20:36 +02:00
|
|
|
FreeXid(xid);
|
2010-09-30 01:51:11 +02:00
|
|
|
cifs_put_tlink(tlink);
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
return rc;
|
|
|
|
}
|