blob: 369e838bebd3142554b72d58e7333547079b3e41 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/cifs/xattr.c
3 *
Steve French79a58d12007-07-06 22:44:50 +00004 * Copyright (c) International Business Machines Corp., 2003, 2007
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/fs.h>
23#include <linux/posix_acl_xattr.h>
24#include "cifsfs.h"
25#include "cifspdu.h"
26#include "cifsglob.h"
27#include "cifsproto.h"
28#include "cifs_debug.h"
29
30#define MAX_EA_VALUE_SIZE 65535
31#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
32#define CIFS_XATTR_USER_PREFIX "user."
33#define CIFS_XATTR_SYSTEM_PREFIX "system."
34#define CIFS_XATTR_OS2_PREFIX "os2."
35#define CIFS_XATTR_SECURITY_PREFIX ".security"
36#define CIFS_XATTR_TRUSTED_PREFIX "trusted."
37#define XATTR_TRUSTED_PREFIX_LEN 8
38#define XATTR_SECURITY_PREFIX_LEN 9
39/* BB need to add server (Samba e.g) support for security and trusted prefix */
Steve French50c2f752007-07-13 00:33:32 +000040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
42
Steve French79a58d12007-07-06 22:44:50 +000043int cifs_removexattr(struct dentry *direntry, const char *ea_name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
45 int rc = -EOPNOTSUPP;
46#ifdef CONFIG_CIFS_XATTR
47 int xid;
48 struct cifs_sb_info *cifs_sb;
49 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +000050 struct super_block *sb;
51 char *full_path;
52
53 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +000055 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 return -EIO;
57 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +000058 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 return -EIO;
60 xid = GetXid();
Steve French79a58d12007-07-06 22:44:50 +000061
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 cifs_sb = CIFS_SB(sb);
63 pTcon = cifs_sb->tcon;
Steve French79a58d12007-07-06 22:44:50 +000064
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +000066 if (full_path == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 FreeXid(xid);
68 return -ENOMEM;
69 }
Steve French79a58d12007-07-06 22:44:50 +000070 if (ea_name == NULL) {
71 cFYI(1, ("Null xattr names not supported"));
72 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5)
73 && (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4))) {
74 cFYI(1,
75 ("illegal xattr request %s (only user namespace supported)",
76 ea_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 /* BB what if no namespace prefix? */
78 /* Should we just pass them to server, except for
79 system and perhaps security prefixes? */
80 } else {
Steve French79a58d12007-07-06 22:44:50 +000081 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 goto remove_ea_exit;
83
Steve French79a58d12007-07-06 22:44:50 +000084 ea_name += 5; /* skip past user. prefix */
85 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL,
Steve French737b7582005-04-28 22:41:06 -070086 (__u16)0, cifs_sb->local_nls,
87 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 }
89remove_ea_exit:
Jesper Juhlf99d49a2005-11-07 01:01:34 -080090 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 FreeXid(xid);
92#endif
93 return rc;
94}
95
Steve French79a58d12007-07-06 22:44:50 +000096int cifs_setxattr(struct dentry *direntry, const char *ea_name,
97 const void *ea_value, size_t value_size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
99 int rc = -EOPNOTSUPP;
100#ifdef CONFIG_CIFS_XATTR
101 int xid;
102 struct cifs_sb_info *cifs_sb;
103 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +0000104 struct super_block *sb;
105 char *full_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Steve French79a58d12007-07-06 22:44:50 +0000107 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +0000109 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 return -EIO;
111 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +0000112 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 return -EIO;
114 xid = GetXid();
115
116 cifs_sb = CIFS_SB(sb);
117 pTcon = cifs_sb->tcon;
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +0000120 if (full_path == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 FreeXid(xid);
122 return -ENOMEM;
123 }
124 /* return dos attributes as pseudo xattr */
125 /* return alt name if available as pseudo attr */
126
127 /* if proc/fs/cifs/streamstoxattr is set then
Steve French79a58d12007-07-06 22:44:50 +0000128 search server for EAs or streams to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 returns as xattrs */
Steve French79a58d12007-07-06 22:44:50 +0000130 if (value_size > MAX_EA_VALUE_SIZE) {
131 cFYI(1, ("size of EA value too large"));
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800132 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 FreeXid(xid);
134 return -EOPNOTSUPP;
135 }
136
Steve French79a58d12007-07-06 22:44:50 +0000137 if (ea_name == NULL) {
138 cFYI(1, ("Null xattr names not supported"));
139 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
140 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 goto set_ea_exit;
Steve French79a58d12007-07-06 22:44:50 +0000142 if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
143 cFYI(1, ("attempt to set cifs inode metadata"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 }
145 ea_name += 5; /* skip past user. prefix */
Steve French79a58d12007-07-06 22:44:50 +0000146 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700147 (__u16)value_size, cifs_sb->local_nls,
148 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000149 } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
150 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 goto set_ea_exit;
152
153 ea_name += 4; /* skip past os2. prefix */
Steve French79a58d12007-07-06 22:44:50 +0000154 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700155 (__u16)value_size, cifs_sb->local_nls,
156 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 } else {
Steve French79a58d12007-07-06 22:44:50 +0000158 int temp;
159 temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 strlen(POSIX_ACL_XATTR_ACCESS));
161 if (temp == 0) {
162#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000163 if (sb->s_flags & MS_POSIXACL)
164 rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
165 ea_value, (const int)value_size,
166 ACL_TYPE_ACCESS, cifs_sb->local_nls,
167 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700168 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000169 cFYI(1, ("set POSIX ACL rc %d", rc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170#else
Steve French79a58d12007-07-06 22:44:50 +0000171 cFYI(1, ("set POSIX ACL not supported"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172#endif
Steve French79a58d12007-07-06 22:44:50 +0000173 } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
174 strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000176 if (sb->s_flags & MS_POSIXACL)
177 rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
178 ea_value, (const int)value_size,
Steve French737b7582005-04-28 22:41:06 -0700179 ACL_TYPE_DEFAULT, cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000180 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700181 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000182 cFYI(1, ("set POSIX default ACL rc %d", rc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183#else
Steve French79a58d12007-07-06 22:44:50 +0000184 cFYI(1, ("set default POSIX ACL not supported"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185#endif
186 } else {
Steve French63135e02007-07-17 17:34:02 +0000187 cFYI(1, ("illegal xattr request %s (only user namespace"
188 " supported)", ea_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 /* BB what if no namespace prefix? */
Steve French79a58d12007-07-06 22:44:50 +0000190 /* Should we just pass them to server, except for
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 system and perhaps security prefixes? */
192 }
193 }
194
195set_ea_exit:
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800196 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 FreeXid(xid);
198#endif
199 return rc;
200}
201
Steve French79a58d12007-07-06 22:44:50 +0000202ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
203 void *ea_value, size_t buf_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204{
205 ssize_t rc = -EOPNOTSUPP;
206#ifdef CONFIG_CIFS_XATTR
207 int xid;
208 struct cifs_sb_info *cifs_sb;
209 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +0000210 struct super_block *sb;
211 char *full_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Steve French79a58d12007-07-06 22:44:50 +0000213 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +0000215 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 return -EIO;
217 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +0000218 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 return -EIO;
220
221 xid = GetXid();
222
223 cifs_sb = CIFS_SB(sb);
224 pTcon = cifs_sb->tcon;
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +0000227 if (full_path == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 FreeXid(xid);
229 return -ENOMEM;
230 }
231 /* return dos attributes as pseudo xattr */
232 /* return alt name if available as pseudo attr */
Steve French79a58d12007-07-06 22:44:50 +0000233 if (ea_name == NULL) {
234 cFYI(1, ("Null xattr names not supported"));
235 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
236 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 goto get_ea_exit;
238
Steve French79a58d12007-07-06 22:44:50 +0000239 if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
240 cFYI(1, ("attempt to query cifs inode metadata"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 /* revalidate/getattr then populate from inode */
242 } /* BB add else when above is implemented */
243 ea_name += 5; /* skip past user. prefix */
Steve French79a58d12007-07-06 22:44:50 +0000244 rc = CIFSSMBQueryEA(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700245 buf_size, cifs_sb->local_nls,
246 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000247 } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
248 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 goto get_ea_exit;
250
251 ea_name += 4; /* skip past os2. prefix */
Steve French79a58d12007-07-06 22:44:50 +0000252 rc = CIFSSMBQueryEA(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700253 buf_size, cifs_sb->local_nls,
254 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000255 } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
Steve French0a4b92c2006-01-12 15:44:21 -0800256 strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000258 if (sb->s_flags & MS_POSIXACL)
Steve French1da0c782005-04-28 22:41:04 -0700259 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
Steve French79a58d12007-07-06 22:44:50 +0000260 ea_value, buf_size, ACL_TYPE_ACCESS,
Steve French737b7582005-04-28 22:41:06 -0700261 cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000262 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700263 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve Frenchd12fd122007-10-03 19:43:19 +0000264#ifdef CONFIG_CIFS_EXPERIMENTAL
265 else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
Steve French0a4b92c2006-01-12 15:44:21 -0800266 __u16 fid;
267 int oplock = FALSE;
Steve Frenchd12fd122007-10-03 19:43:19 +0000268 if (experimEnabled)
269 rc = CIFSSMBOpen(xid, pTcon, full_path,
270 FILE_OPEN, GENERIC_READ, 0, &fid,
271 &oplock, NULL, cifs_sb->local_nls,
272 cifs_sb->mnt_cifs_flags &
273 CIFS_MOUNT_MAP_SPECIAL_CHR);
274 /* else rc is EOPNOTSUPP from above */
275
Steve French0a4b92c2006-01-12 15:44:21 -0800276 if(rc == 0) {
277 rc = CIFSSMBGetCIFSACL(xid, pTcon, fid,
278 ea_value, buf_size,
279 ACL_TYPE_ACCESS);
Steve French2fe87f02006-09-21 07:02:52 +0000280 CIFSSMBClose(xid, pTcon, fid);
Steve French0a4b92c2006-01-12 15:44:21 -0800281 }
Steve Frenchd12fd122007-10-03 19:43:19 +0000282 }
283#endif /* EXPERIMENTAL */
Steve French79a58d12007-07-06 22:44:50 +0000284#else
285 cFYI(1, ("query POSIX ACL not supported yet"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286#endif /* CONFIG_CIFS_POSIX */
Steve French79a58d12007-07-06 22:44:50 +0000287 } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
Steve French0a4b92c2006-01-12 15:44:21 -0800288 strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000290 if (sb->s_flags & MS_POSIXACL)
Steve French1da0c782005-04-28 22:41:04 -0700291 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
Steve French79a58d12007-07-06 22:44:50 +0000292 ea_value, buf_size, ACL_TYPE_DEFAULT,
Steve French737b7582005-04-28 22:41:06 -0700293 cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000294 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700295 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000296#else
297 cFYI(1, ("query POSIX default ACL not supported yet"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298#endif
Steve French79a58d12007-07-06 22:44:50 +0000299 } else if (strncmp(ea_name,
300 CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
301 cFYI(1, ("Trusted xattr namespace not supported yet"));
302 } else if (strncmp(ea_name,
303 CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
304 cFYI(1, ("Security xattr namespace not supported yet"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 } else {
Steve French79a58d12007-07-06 22:44:50 +0000306 cFYI(1,
307 ("illegal xattr request %s (only user namespace supported)",
308 ea_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 }
310
Steve French79a58d12007-07-06 22:44:50 +0000311 /* We could add an additional check for streams ie
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 if proc/fs/cifs/streamstoxattr is set then
Steve French79a58d12007-07-06 22:44:50 +0000313 search server for EAs or streams to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 returns as xattrs */
315
Steve French79a58d12007-07-06 22:44:50 +0000316 if (rc == -EINVAL)
317 rc = -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319get_ea_exit:
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800320 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 FreeXid(xid);
322#endif
323 return rc;
324}
325
Steve French79a58d12007-07-06 22:44:50 +0000326ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 ssize_t rc = -EOPNOTSUPP;
329#ifdef CONFIG_CIFS_XATTR
330 int xid;
331 struct cifs_sb_info *cifs_sb;
332 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +0000333 struct super_block *sb;
334 char *full_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Steve French79a58d12007-07-06 22:44:50 +0000336 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +0000338 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 return -EIO;
340 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +0000341 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344 cifs_sb = CIFS_SB(sb);
345 pTcon = cifs_sb->tcon;
346
Steve French79a58d12007-07-06 22:44:50 +0000347 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Steve Frenchea4c07d2006-08-16 19:44:25 +0000348 return -EOPNOTSUPP;
349
350 xid = GetXid();
351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +0000353 if (full_path == NULL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 FreeXid(xid);
355 return -ENOMEM;
356 }
357 /* return dos attributes as pseudo xattr */
358 /* return alt name if available as pseudo attr */
359
360 /* if proc/fs/cifs/streamstoxattr is set then
Steve French79a58d12007-07-06 22:44:50 +0000361 search server for EAs or streams to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 returns as xattrs */
Steve French79a58d12007-07-06 22:44:50 +0000363 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, data, buf_size,
Steve French737b7582005-04-28 22:41:06 -0700364 cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000365 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700366 CIFS_MOUNT_MAP_SPECIAL_CHR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800368 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 FreeXid(xid);
370#endif
371 return rc;
372}