blob: 3e2ef0de120968e8e8012486f188e2b537590950 [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) {
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +053067 rc = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 FreeXid(xid);
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +053069 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 }
Steve French79a58d12007-07-06 22:44:50 +000071 if (ea_name == NULL) {
72 cFYI(1, ("Null xattr names not supported"));
73 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5)
74 && (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4))) {
75 cFYI(1,
76 ("illegal xattr request %s (only user namespace supported)",
77 ea_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 /* BB what if no namespace prefix? */
79 /* Should we just pass them to server, except for
80 system and perhaps security prefixes? */
81 } else {
Steve French79a58d12007-07-06 22:44:50 +000082 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 goto remove_ea_exit;
84
Steve French79a58d12007-07-06 22:44:50 +000085 ea_name += 5; /* skip past user. prefix */
86 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL,
Steve French737b7582005-04-28 22:41:06 -070087 (__u16)0, cifs_sb->local_nls,
88 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90remove_ea_exit:
Jesper Juhlf99d49a2005-11-07 01:01:34 -080091 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 FreeXid(xid);
93#endif
94 return rc;
95}
96
Steve French79a58d12007-07-06 22:44:50 +000097int cifs_setxattr(struct dentry *direntry, const char *ea_name,
98 const void *ea_value, size_t value_size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099{
100 int rc = -EOPNOTSUPP;
101#ifdef CONFIG_CIFS_XATTR
102 int xid;
103 struct cifs_sb_info *cifs_sb;
104 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +0000105 struct super_block *sb;
106 char *full_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Steve French79a58d12007-07-06 22:44:50 +0000108 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +0000110 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 return -EIO;
112 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +0000113 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 return -EIO;
115 xid = GetXid();
116
117 cifs_sb = CIFS_SB(sb);
118 pTcon = cifs_sb->tcon;
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +0000121 if (full_path == NULL) {
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +0530122 rc = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 FreeXid(xid);
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +0530124 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 }
126 /* return dos attributes as pseudo xattr */
127 /* return alt name if available as pseudo attr */
128
129 /* if proc/fs/cifs/streamstoxattr is set then
Steve French79a58d12007-07-06 22:44:50 +0000130 search server for EAs or streams to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 returns as xattrs */
Steve French79a58d12007-07-06 22:44:50 +0000132 if (value_size > MAX_EA_VALUE_SIZE) {
133 cFYI(1, ("size of EA value too large"));
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800134 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 FreeXid(xid);
136 return -EOPNOTSUPP;
137 }
138
Steve French79a58d12007-07-06 22:44:50 +0000139 if (ea_name == NULL) {
140 cFYI(1, ("Null xattr names not supported"));
141 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
142 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 goto set_ea_exit;
Steve Frenchad7a2922008-02-07 23:25:02 +0000144 if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0)
Steve French79a58d12007-07-06 22:44:50 +0000145 cFYI(1, ("attempt to set cifs inode metadata"));
Steve Frenchad7a2922008-02-07 23:25:02 +0000146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 ea_name += 5; /* skip past user. prefix */
Steve French79a58d12007-07-06 22:44:50 +0000148 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700149 (__u16)value_size, cifs_sb->local_nls,
150 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000151 } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
152 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 goto set_ea_exit;
154
155 ea_name += 4; /* skip past os2. prefix */
Steve French79a58d12007-07-06 22:44:50 +0000156 rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700157 (__u16)value_size, cifs_sb->local_nls,
158 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 } else {
Steve French79a58d12007-07-06 22:44:50 +0000160 int temp;
161 temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 strlen(POSIX_ACL_XATTR_ACCESS));
163 if (temp == 0) {
164#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000165 if (sb->s_flags & MS_POSIXACL)
166 rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
167 ea_value, (const int)value_size,
168 ACL_TYPE_ACCESS, cifs_sb->local_nls,
169 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700170 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000171 cFYI(1, ("set POSIX ACL rc %d", rc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172#else
Steve French79a58d12007-07-06 22:44:50 +0000173 cFYI(1, ("set POSIX ACL not supported"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174#endif
Steve French79a58d12007-07-06 22:44:50 +0000175 } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
176 strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000178 if (sb->s_flags & MS_POSIXACL)
179 rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
180 ea_value, (const int)value_size,
Steve French737b7582005-04-28 22:41:06 -0700181 ACL_TYPE_DEFAULT, cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000182 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700183 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000184 cFYI(1, ("set POSIX default ACL rc %d", rc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185#else
Steve French79a58d12007-07-06 22:44:50 +0000186 cFYI(1, ("set default POSIX ACL not supported"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187#endif
188 } else {
Steve French63135e02007-07-17 17:34:02 +0000189 cFYI(1, ("illegal xattr request %s (only user namespace"
190 " supported)", ea_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 /* BB what if no namespace prefix? */
Steve French79a58d12007-07-06 22:44:50 +0000192 /* Should we just pass them to server, except for
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 system and perhaps security prefixes? */
194 }
195 }
196
197set_ea_exit:
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800198 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 FreeXid(xid);
200#endif
201 return rc;
202}
203
Steve French79a58d12007-07-06 22:44:50 +0000204ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
205 void *ea_value, size_t buf_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206{
207 ssize_t rc = -EOPNOTSUPP;
208#ifdef CONFIG_CIFS_XATTR
209 int xid;
210 struct cifs_sb_info *cifs_sb;
211 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +0000212 struct super_block *sb;
213 char *full_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Steve French79a58d12007-07-06 22:44:50 +0000215 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +0000217 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 return -EIO;
219 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +0000220 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 return -EIO;
222
223 xid = GetXid();
224
225 cifs_sb = CIFS_SB(sb);
226 pTcon = cifs_sb->tcon;
227
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +0000229 if (full_path == NULL) {
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +0530230 rc = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 FreeXid(xid);
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +0530232 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 }
234 /* return dos attributes as pseudo xattr */
235 /* return alt name if available as pseudo attr */
Steve French79a58d12007-07-06 22:44:50 +0000236 if (ea_name == NULL) {
237 cFYI(1, ("Null xattr names not supported"));
238 } else if (strncmp(ea_name, CIFS_XATTR_USER_PREFIX, 5) == 0) {
239 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 goto get_ea_exit;
241
Steve French79a58d12007-07-06 22:44:50 +0000242 if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
243 cFYI(1, ("attempt to query cifs inode metadata"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 /* revalidate/getattr then populate from inode */
245 } /* BB add else when above is implemented */
246 ea_name += 5; /* skip past user. prefix */
Jeff Layton31c05192010-02-10 16:18:26 -0500247 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700248 buf_size, cifs_sb->local_nls,
249 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000250 } else if (strncmp(ea_name, CIFS_XATTR_OS2_PREFIX, 4) == 0) {
251 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 goto get_ea_exit;
253
254 ea_name += 4; /* skip past os2. prefix */
Jeff Layton31c05192010-02-10 16:18:26 -0500255 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
Steve French737b7582005-04-28 22:41:06 -0700256 buf_size, cifs_sb->local_nls,
257 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000258 } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
Steve French0a4b92c2006-01-12 15:44:21 -0800259 strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000261 if (sb->s_flags & MS_POSIXACL)
Steve French1da0c782005-04-28 22:41:04 -0700262 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
Steve French79a58d12007-07-06 22:44:50 +0000263 ea_value, buf_size, ACL_TYPE_ACCESS,
Steve French737b7582005-04-28 22:41:06 -0700264 cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000265 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700266 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve Frenchd12fd122007-10-03 19:43:19 +0000267#ifdef CONFIG_CIFS_EXPERIMENTAL
Steve Frenchad7a2922008-02-07 23:25:02 +0000268 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
Steve French0a4b92c2006-01-12 15:44:21 -0800269 __u16 fid;
Steve French4b18f2a2008-04-29 00:06:05 +0000270 int oplock = 0;
Steve French630f3f0c2007-10-25 21:17:17 +0000271 struct cifs_ntsd *pacl = NULL;
272 __u32 buflen = 0;
Steve French63d25832007-11-05 21:46:10 +0000273 if (experimEnabled)
Steve Frenchd12fd122007-10-03 19:43:19 +0000274 rc = CIFSSMBOpen(xid, pTcon, full_path,
275 FILE_OPEN, GENERIC_READ, 0, &fid,
276 &oplock, NULL, cifs_sb->local_nls,
277 cifs_sb->mnt_cifs_flags &
278 CIFS_MOUNT_MAP_SPECIAL_CHR);
279 /* else rc is EOPNOTSUPP from above */
280
Steve French63d25832007-11-05 21:46:10 +0000281 if (rc == 0) {
Steve French630f3f0c2007-10-25 21:17:17 +0000282 rc = CIFSSMBGetCIFSACL(xid, pTcon, fid, &pacl,
283 &buflen);
Steve French2fe87f02006-09-21 07:02:52 +0000284 CIFSSMBClose(xid, pTcon, fid);
Steve French0a4b92c2006-01-12 15:44:21 -0800285 }
Steve Frenchd12fd122007-10-03 19:43:19 +0000286 }
287#endif /* EXPERIMENTAL */
Steve French79a58d12007-07-06 22:44:50 +0000288#else
289 cFYI(1, ("query POSIX ACL not supported yet"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290#endif /* CONFIG_CIFS_POSIX */
Steve French79a58d12007-07-06 22:44:50 +0000291 } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
Steve French0a4b92c2006-01-12 15:44:21 -0800292 strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293#ifdef CONFIG_CIFS_POSIX
Steve French79a58d12007-07-06 22:44:50 +0000294 if (sb->s_flags & MS_POSIXACL)
Steve French1da0c782005-04-28 22:41:04 -0700295 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
Steve French79a58d12007-07-06 22:44:50 +0000296 ea_value, buf_size, ACL_TYPE_DEFAULT,
Steve French737b7582005-04-28 22:41:06 -0700297 cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000298 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700299 CIFS_MOUNT_MAP_SPECIAL_CHR);
Steve French79a58d12007-07-06 22:44:50 +0000300#else
301 cFYI(1, ("query POSIX default ACL not supported yet"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302#endif
Steve French79a58d12007-07-06 22:44:50 +0000303 } else if (strncmp(ea_name,
304 CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
305 cFYI(1, ("Trusted xattr namespace not supported yet"));
306 } else if (strncmp(ea_name,
307 CIFS_XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
308 cFYI(1, ("Security xattr namespace not supported yet"));
Steve Frenchad7a2922008-02-07 23:25:02 +0000309 } else
Steve French79a58d12007-07-06 22:44:50 +0000310 cFYI(1,
311 ("illegal xattr request %s (only user namespace supported)",
312 ea_name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Steve French79a58d12007-07-06 22:44:50 +0000314 /* We could add an additional check for streams ie
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 if proc/fs/cifs/streamstoxattr is set then
Steve French79a58d12007-07-06 22:44:50 +0000316 search server for EAs or streams to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 returns as xattrs */
318
Steve French79a58d12007-07-06 22:44:50 +0000319 if (rc == -EINVAL)
320 rc = -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322get_ea_exit:
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800323 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 FreeXid(xid);
325#endif
326 return rc;
327}
328
Steve French79a58d12007-07-06 22:44:50 +0000329ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330{
331 ssize_t rc = -EOPNOTSUPP;
332#ifdef CONFIG_CIFS_XATTR
333 int xid;
334 struct cifs_sb_info *cifs_sb;
335 struct cifsTconInfo *pTcon;
Steve French79a58d12007-07-06 22:44:50 +0000336 struct super_block *sb;
337 char *full_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
Steve French79a58d12007-07-06 22:44:50 +0000339 if (direntry == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 return -EIO;
Steve French79a58d12007-07-06 22:44:50 +0000341 if (direntry->d_inode == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 return -EIO;
343 sb = direntry->d_inode->i_sb;
Steve French79a58d12007-07-06 22:44:50 +0000344 if (sb == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347 cifs_sb = CIFS_SB(sb);
348 pTcon = cifs_sb->tcon;
349
Steve French79a58d12007-07-06 22:44:50 +0000350 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
Steve Frenchea4c07d2006-08-16 19:44:25 +0000351 return -EOPNOTSUPP;
352
353 xid = GetXid();
354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 full_path = build_path_from_dentry(direntry);
Steve French79a58d12007-07-06 22:44:50 +0000356 if (full_path == NULL) {
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +0530357 rc = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 FreeXid(xid);
Suresh Jayaraman0f3bc092009-06-25 18:12:34 +0530359 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 }
361 /* return dos attributes as pseudo xattr */
362 /* return alt name if available as pseudo attr */
363
364 /* if proc/fs/cifs/streamstoxattr is set then
Steve French79a58d12007-07-06 22:44:50 +0000365 search server for EAs or streams to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 returns as xattrs */
Jeff Layton31c05192010-02-10 16:18:26 -0500367 rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
368 buf_size, cifs_sb->local_nls,
Steve French79a58d12007-07-06 22:44:50 +0000369 cifs_sb->mnt_cifs_flags &
Steve French737b7582005-04-28 22:41:06 -0700370 CIFS_MOUNT_MAP_SPECIAL_CHR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
Jesper Juhlf99d49a2005-11-07 01:01:34 -0800372 kfree(full_path);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 FreeXid(xid);
374#endif
375 return rc;
376}