5a0e3ad6af
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>
377 lines
11 KiB
C
377 lines
11 KiB
C
/*
|
|
* fs/cifs/xattr.c
|
|
*
|
|
* Copyright (c) International Business Machines Corp., 2003, 2007
|
|
* 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 <linux/slab.h>
|
|
#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"
|
|
#define CIFS_XATTR_USER_PREFIX "user."
|
|
#define CIFS_XATTR_SYSTEM_PREFIX "system."
|
|
#define CIFS_XATTR_OS2_PREFIX "os2."
|
|
#define CIFS_XATTR_SECURITY_PREFIX ".security"
|
|
#define CIFS_XATTR_TRUSTED_PREFIX "trusted."
|
|
#define XATTR_TRUSTED_PREFIX_LEN 8
|
|
#define XATTR_SECURITY_PREFIX_LEN 9
|
|
/* BB need to add server (Samba e.g) support for security and trusted prefix */
|
|
|
|
|
|
|
|
int cifs_removexattr(struct dentry *direntry, const char *ea_name)
|
|
{
|
|
int rc = -EOPNOTSUPP;
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
int xid;
|
|
struct cifs_sb_info *cifs_sb;
|
|
struct cifsTconInfo *pTcon;
|
|
struct super_block *sb;
|
|
char *full_path;
|
|
|
|
if (direntry == NULL)
|
|
return -EIO;
|
|
if (direntry->d_inode == NULL)
|
|
return -EIO;
|
|
sb = direntry->d_inode->i_sb;
|
|
if (sb == NULL)
|
|
return -EIO;
|
|
xid = GetXid();
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
|
pTcon = cifs_sb->tcon;
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
FreeXid(xid);
|
|
return rc;
|
|
}
|
|
if (ea_name == NULL) {
|
|
cFYI(1, ("Null xattr names not supported"));
|
|
} else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5)
|
|
&& (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4))) {
|
|
cFYI(1,
|
|
("illegal xattr request %s (only user namespace supported)",
|
|
ea_name));
|
|
/* BB what if no namespace prefix? */
|
|
/* Should we just pass them to server, except for
|
|
system and perhaps security prefixes? */
|
|
} else {
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto remove_ea_exit;
|
|
|
|
ea_name += 5; /* skip past user. prefix */
|
|
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL,
|
|
(__u16)0, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
}
|
|
remove_ea_exit:
|
|
kfree(full_path);
|
|
FreeXid(xid);
|
|
#endif
|
|
return rc;
|
|
}
|
|
|
|
int cifs_setxattr(struct dentry *direntry, const char *ea_name,
|
|
const void *ea_value, size_t value_size, int flags)
|
|
{
|
|
int rc = -EOPNOTSUPP;
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
int xid;
|
|
struct cifs_sb_info *cifs_sb;
|
|
struct cifsTconInfo *pTcon;
|
|
struct super_block *sb;
|
|
char *full_path;
|
|
|
|
if (direntry == NULL)
|
|
return -EIO;
|
|
if (direntry->d_inode == NULL)
|
|
return -EIO;
|
|
sb = direntry->d_inode->i_sb;
|
|
if (sb == NULL)
|
|
return -EIO;
|
|
xid = GetXid();
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
|
pTcon = cifs_sb->tcon;
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
FreeXid(xid);
|
|
return rc;
|
|
}
|
|
/* return dos attributes as pseudo xattr */
|
|
/* return alt name if available as pseudo attr */
|
|
|
|
/* if proc/fs/cifs/streamstoxattr is set then
|
|
search server for EAs or streams to
|
|
returns as xattrs */
|
|
if (value_size > MAX_EA_VALUE_SIZE) {
|
|
cFYI(1, ("size of EA value too large"));
|
|
kfree(full_path);
|
|
FreeXid(xid);
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
if (ea_name == NULL) {
|
|
cFYI(1, ("Null xattr names not supported"));
|
|
} else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto set_ea_exit;
|
|
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0)
|
|
cFYI(1, ("attempt to set cifs inode metadata"));
|
|
|
|
ea_name += 5; /* skip past user. prefix */
|
|
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
|
|
(__u16)value_size, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
} else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto set_ea_exit;
|
|
|
|
ea_name += 4; /* skip past os2. prefix */
|
|
rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
|
|
(__u16)value_size, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
} else {
|
|
int temp;
|
|
temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
|
|
strlen(POSIX_ACL_XATTR_ACCESS));
|
|
if (temp == 0) {
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
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 &
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
cFYI(1, ("set POSIX ACL rc %d", rc));
|
|
#else
|
|
cFYI(1, ("set POSIX ACL not supported"));
|
|
#endif
|
|
} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
|
|
strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (sb->s_flags & MS_POSIXACL)
|
|
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
|
|
ea_value, (const int)value_size,
|
|
ACL_TYPE_DEFAULT, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags &
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
cFYI(1, ("set POSIX default ACL rc %d", rc));
|
|
#else
|
|
cFYI(1, ("set default POSIX ACL not supported"));
|
|
#endif
|
|
} else {
|
|
cFYI(1, ("illegal xattr request %s (only user namespace"
|
|
" supported)", ea_name));
|
|
/* BB what if no namespace prefix? */
|
|
/* Should we just pass them to server, except for
|
|
system and perhaps security prefixes? */
|
|
}
|
|
}
|
|
|
|
set_ea_exit:
|
|
kfree(full_path);
|
|
FreeXid(xid);
|
|
#endif
|
|
return rc;
|
|
}
|
|
|
|
ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
|
|
void *ea_value, size_t buf_size)
|
|
{
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
int xid;
|
|
struct cifs_sb_info *cifs_sb;
|
|
struct cifsTconInfo *pTcon;
|
|
struct super_block *sb;
|
|
char *full_path;
|
|
|
|
if (direntry == NULL)
|
|
return -EIO;
|
|
if (direntry->d_inode == NULL)
|
|
return -EIO;
|
|
sb = direntry->d_inode->i_sb;
|
|
if (sb == NULL)
|
|
return -EIO;
|
|
|
|
xid = GetXid();
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
|
pTcon = cifs_sb->tcon;
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
FreeXid(xid);
|
|
return rc;
|
|
}
|
|
/* return dos attributes as pseudo xattr */
|
|
/* return alt name if available as pseudo attr */
|
|
if (ea_name == NULL) {
|
|
cFYI(1, ("Null xattr names not supported"));
|
|
} else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto get_ea_exit;
|
|
|
|
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
|
|
cFYI(1, ("attempt to query cifs inode metadata"));
|
|
/* revalidate/getattr then populate from inode */
|
|
} /* BB add else when above is implemented */
|
|
ea_name += 5; /* skip past user. prefix */
|
|
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
|
|
buf_size, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
} else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
goto get_ea_exit;
|
|
|
|
ea_name += 4; /* skip past os2. prefix */
|
|
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
|
|
buf_size, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
} else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
|
|
strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (sb->s_flags & MS_POSIXACL)
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
|
ea_value, buf_size, ACL_TYPE_ACCESS,
|
|
cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags &
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
#ifdef CONFIG_CIFS_EXPERIMENTAL
|
|
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
|
|
__u16 fid;
|
|
int oplock = 0;
|
|
struct cifs_ntsd *pacl = NULL;
|
|
__u32 buflen = 0;
|
|
if (experimEnabled)
|
|
rc = CIFSSMBOpen(xid, pTcon, full_path,
|
|
FILE_OPEN, GENERIC_READ, 0, &fid,
|
|
&oplock, NULL, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags &
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
/* else rc is EOPNOTSUPP from above */
|
|
|
|
if (rc == 0) {
|
|
rc = CIFSSMBGetCIFSACL(xid, pTcon, fid, &pacl,
|
|
&buflen);
|
|
CIFSSMBClose(xid, pTcon, fid);
|
|
}
|
|
}
|
|
#endif /* EXPERIMENTAL */
|
|
#else
|
|
cFYI(1, ("query POSIX ACL not supported yet"));
|
|
#endif /* CONFIG_CIFS_POSIX */
|
|
} else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
|
|
strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
|
|
#ifdef CONFIG_CIFS_POSIX
|
|
if (sb->s_flags & MS_POSIXACL)
|
|
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
|
|
ea_value, buf_size, ACL_TYPE_DEFAULT,
|
|
cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags &
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
#else
|
|
cFYI(1, ("query POSIX default ACL not supported yet"));
|
|
#endif
|
|
} else if (strncmp(ea_name,
|
|
CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
|
|
cFYI(1, ("Trusted xattr namespace not supported yet"));
|
|
} else if (strncmp(ea_name,
|
|
CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
|
|
cFYI(1, ("Security xattr namespace not supported yet"));
|
|
} else
|
|
cFYI(1,
|
|
("illegal xattr request %s (only user namespace supported)",
|
|
ea_name));
|
|
|
|
/* We could add an additional check for streams ie
|
|
if proc/fs/cifs/streamstoxattr is set then
|
|
search server for EAs or streams to
|
|
returns as xattrs */
|
|
|
|
if (rc == -EINVAL)
|
|
rc = -EOPNOTSUPP;
|
|
|
|
get_ea_exit:
|
|
kfree(full_path);
|
|
FreeXid(xid);
|
|
#endif
|
|
return rc;
|
|
}
|
|
|
|
ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
|
|
{
|
|
ssize_t rc = -EOPNOTSUPP;
|
|
#ifdef CONFIG_CIFS_XATTR
|
|
int xid;
|
|
struct cifs_sb_info *cifs_sb;
|
|
struct cifsTconInfo *pTcon;
|
|
struct super_block *sb;
|
|
char *full_path;
|
|
|
|
if (direntry == NULL)
|
|
return -EIO;
|
|
if (direntry->d_inode == NULL)
|
|
return -EIO;
|
|
sb = direntry->d_inode->i_sb;
|
|
if (sb == NULL)
|
|
return -EIO;
|
|
|
|
cifs_sb = CIFS_SB(sb);
|
|
pTcon = cifs_sb->tcon;
|
|
|
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
|
|
return -EOPNOTSUPP;
|
|
|
|
xid = GetXid();
|
|
|
|
full_path = build_path_from_dentry(direntry);
|
|
if (full_path == NULL) {
|
|
rc = -ENOMEM;
|
|
FreeXid(xid);
|
|
return rc;
|
|
}
|
|
/* return dos attributes as pseudo xattr */
|
|
/* return alt name if available as pseudo attr */
|
|
|
|
/* if proc/fs/cifs/streamstoxattr is set then
|
|
search server for EAs or streams to
|
|
returns as xattrs */
|
|
rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
|
|
buf_size, cifs_sb->local_nls,
|
|
cifs_sb->mnt_cifs_flags &
|
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
|
|
kfree(full_path);
|
|
FreeXid(xid);
|
|
#endif
|
|
return rc;
|
|
}
|