original development tree for Linux kernel GTP module; now long in mainline.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

414 lines
12 KiB

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>
12 years ago
cifs: Fix incorrect return code being printed in cFYI messages FreeXid() along with freeing Xid does add a cifsFYI debug message that prints rc (return code) as well. In some code paths where we set/return error code after calling FreeXid(), incorrect error code is being printed when cifsFYI is enabled. This could be misleading in few cases. For eg. In cifs_open() if cifs_fill_filedata() returns a valid pointer to cifsFileInfo, FreeXid() prints rc=-13 whereas 0 is actually being returned. Fix this by setting rc before calling FreeXid(). Basically convert FreeXid(xid); rc = -ERR; return -ERR; => FreeXid(xid); return rc; [Note that Christoph would like to replace the GetXid/FreeXid calls, which are primarily used for debugging. This seems like a good longer term goal, but although there is an alternative tracing facility, there are no examples yet available that I know of that we can use (yet) to convert this cifs function entry/exit logging, and for creating an identifier that we can use to correlate all dmesg log entries for a particular vfs operation (ie identify all log entries for a particular vfs request to cifs: e.g. a particular close or read or write or byte range lock call ... and just using the thread id is harder). Eventually when a replacement for this is available (e.g. when NFS switches over and various samples to look at in other file systems) we can remove the GetXid/FreeXid macro but in the meantime multiple people use this run time configurable logging all the time for debugging, and Suresh's patch fixes a problem which made it harder to notice some low memory problems in the log so it is worthwhile to fix this problem until a better logging approach is able to be used] Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
12 years ago
cifs: Fix incorrect return code being printed in cFYI messages FreeXid() along with freeing Xid does add a cifsFYI debug message that prints rc (return code) as well. In some code paths where we set/return error code after calling FreeXid(), incorrect error code is being printed when cifsFYI is enabled. This could be misleading in few cases. For eg. In cifs_open() if cifs_fill_filedata() returns a valid pointer to cifsFileInfo, FreeXid() prints rc=-13 whereas 0 is actually being returned. Fix this by setting rc before calling FreeXid(). Basically convert FreeXid(xid); rc = -ERR; return -ERR; => FreeXid(xid); return rc; [Note that Christoph would like to replace the GetXid/FreeXid calls, which are primarily used for debugging. This seems like a good longer term goal, but although there is an alternative tracing facility, there are no examples yet available that I know of that we can use (yet) to convert this cifs function entry/exit logging, and for creating an identifier that we can use to correlate all dmesg log entries for a particular vfs operation (ie identify all log entries for a particular vfs request to cifs: e.g. a particular close or read or write or byte range lock call ... and just using the thread id is harder). Eventually when a replacement for this is available (e.g. when NFS switches over and various samples to look at in other file systems) we can remove the GetXid/FreeXid macro but in the meantime multiple people use this run time configurable logging all the time for debugging, and Suresh's patch fixes a problem which made it harder to notice some low memory problems in the log so it is worthwhile to fix this problem until a better logging approach is able to be used] Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
12 years ago
cifs: Fix incorrect return code being printed in cFYI messages FreeXid() along with freeing Xid does add a cifsFYI debug message that prints rc (return code) as well. In some code paths where we set/return error code after calling FreeXid(), incorrect error code is being printed when cifsFYI is enabled. This could be misleading in few cases. For eg. In cifs_open() if cifs_fill_filedata() returns a valid pointer to cifsFileInfo, FreeXid() prints rc=-13 whereas 0 is actually being returned. Fix this by setting rc before calling FreeXid(). Basically convert FreeXid(xid); rc = -ERR; return -ERR; => FreeXid(xid); return rc; [Note that Christoph would like to replace the GetXid/FreeXid calls, which are primarily used for debugging. This seems like a good longer term goal, but although there is an alternative tracing facility, there are no examples yet available that I know of that we can use (yet) to convert this cifs function entry/exit logging, and for creating an identifier that we can use to correlate all dmesg log entries for a particular vfs operation (ie identify all log entries for a particular vfs request to cifs: e.g. a particular close or read or write or byte range lock call ... and just using the thread id is harder). Eventually when a replacement for this is available (e.g. when NFS switches over and various samples to look at in other file systems) we can remove the GetXid/FreeXid macro but in the meantime multiple people use this run time configurable logging all the time for debugging, and Suresh's patch fixes a problem which made it harder to notice some low memory problems in the log so it is worthwhile to fix this problem until a better logging approach is able to be used] Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
12 years ago
cifs: Fix incorrect return code being printed in cFYI messages FreeXid() along with freeing Xid does add a cifsFYI debug message that prints rc (return code) as well. In some code paths where we set/return error code after calling FreeXid(), incorrect error code is being printed when cifsFYI is enabled. This could be misleading in few cases. For eg. In cifs_open() if cifs_fill_filedata() returns a valid pointer to cifsFileInfo, FreeXid() prints rc=-13 whereas 0 is actually being returned. Fix this by setting rc before calling FreeXid(). Basically convert FreeXid(xid); rc = -ERR; return -ERR; => FreeXid(xid); return rc; [Note that Christoph would like to replace the GetXid/FreeXid calls, which are primarily used for debugging. This seems like a good longer term goal, but although there is an alternative tracing facility, there are no examples yet available that I know of that we can use (yet) to convert this cifs function entry/exit logging, and for creating an identifier that we can use to correlate all dmesg log entries for a particular vfs operation (ie identify all log entries for a particular vfs request to cifs: e.g. a particular close or read or write or byte range lock call ... and just using the thread id is harder). Eventually when a replacement for this is available (e.g. when NFS switches over and various samples to look at in other file systems) we can remove the GetXid/FreeXid macro but in the meantime multiple people use this run time configurable logging all the time for debugging, and Suresh's patch fixes a problem which made it harder to notice some low memory problems in the log so it is worthwhile to fix this problem until a better logging approach is able to be used] Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
12 years ago
  1. /*
  2. * fs/cifs/xattr.c
  3. *
  4. * Copyright (c) International Business Machines Corp., 2003, 2007
  5. * 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. #include <linux/fs.h>
  22. #include <linux/posix_acl_xattr.h>
  23. #include <linux/slab.h>
  24. #include <linux/xattr.h>
  25. #include "cifsfs.h"
  26. #include "cifspdu.h"
  27. #include "cifsglob.h"
  28. #include "cifsproto.h"
  29. #include "cifs_debug.h"
  30. #define MAX_EA_VALUE_SIZE 65535
  31. #define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
  32. #define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
  33. /* BB need to add server (Samba e.g) support for security and trusted prefix */
  34. int cifs_removexattr(struct dentry *direntry, const char *ea_name)
  35. {
  36. int rc = -EOPNOTSUPP;
  37. #ifdef CONFIG_CIFS_XATTR
  38. unsigned int xid;
  39. struct cifs_sb_info *cifs_sb;
  40. struct tcon_link *tlink;
  41. struct cifs_tcon *pTcon;
  42. struct super_block *sb;
  43. char *full_path = NULL;
  44. if (direntry == NULL)
  45. return -EIO;
  46. if (direntry->d_inode == NULL)
  47. return -EIO;
  48. sb = direntry->d_inode->i_sb;
  49. if (sb == NULL)
  50. return -EIO;
  51. cifs_sb = CIFS_SB(sb);
  52. tlink = cifs_sb_tlink(cifs_sb);
  53. if (IS_ERR(tlink))
  54. return PTR_ERR(tlink);
  55. pTcon = tlink_tcon(tlink);
  56. xid = get_xid();
  57. full_path = build_path_from_dentry(direntry);
  58. if (full_path == NULL) {
  59. rc = -ENOMEM;
  60. goto remove_ea_exit;
  61. }
  62. if (ea_name == NULL) {
  63. cifs_dbg(FYI, "Null xattr names not supported\n");
  64. } else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
  65. && (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN))) {
  66. cifs_dbg(FYI,
  67. "illegal xattr request %s (only user namespace supported)\n",
  68. ea_name);
  69. /* BB what if no namespace prefix? */
  70. /* Should we just pass them to server, except for
  71. system and perhaps security prefixes? */
  72. } else {
  73. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  74. goto remove_ea_exit;
  75. ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
  76. rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, NULL,
  77. (__u16)0, cifs_sb->local_nls,
  78. cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  79. }
  80. remove_ea_exit:
  81. kfree(full_path);
  82. free_xid(xid);
  83. cifs_put_tlink(tlink);
  84. #endif
  85. return rc;
  86. }
  87. int cifs_setxattr(struct dentry *direntry, const char *ea_name,
  88. const void *ea_value, size_t value_size, int flags)
  89. {
  90. int rc = -EOPNOTSUPP;
  91. #ifdef CONFIG_CIFS_XATTR
  92. unsigned int xid;
  93. struct cifs_sb_info *cifs_sb;
  94. struct tcon_link *tlink;
  95. struct cifs_tcon *pTcon;
  96. struct super_block *sb;
  97. char *full_path;
  98. if (direntry == NULL)
  99. return -EIO;
  100. if (direntry->d_inode == NULL)
  101. return -EIO;
  102. sb = direntry->d_inode->i_sb;
  103. if (sb == NULL)
  104. return -EIO;
  105. cifs_sb = CIFS_SB(sb);
  106. tlink = cifs_sb_tlink(cifs_sb);
  107. if (IS_ERR(tlink))
  108. return PTR_ERR(tlink);
  109. pTcon = tlink_tcon(tlink);
  110. xid = get_xid();
  111. full_path = build_path_from_dentry(direntry);
  112. if (full_path == NULL) {
  113. rc = -ENOMEM;
  114. goto set_ea_exit;
  115. }
  116. /* return dos attributes as pseudo xattr */
  117. /* return alt name if available as pseudo attr */
  118. /* if proc/fs/cifs/streamstoxattr is set then
  119. search server for EAs or streams to
  120. returns as xattrs */
  121. if (value_size > MAX_EA_VALUE_SIZE) {
  122. cifs_dbg(FYI, "size of EA value too large\n");
  123. rc = -EOPNOTSUPP;
  124. goto set_ea_exit;
  125. }
  126. if (ea_name == NULL) {
  127. cifs_dbg(FYI, "Null xattr names not supported\n");
  128. } else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
  129. == 0) {
  130. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  131. goto set_ea_exit;
  132. if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0)
  133. cifs_dbg(FYI, "attempt to set cifs inode metadata\n");
  134. ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
  135. rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
  136. (__u16)value_size, cifs_sb->local_nls,
  137. cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  138. } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)
  139. == 0) {
  140. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  141. goto set_ea_exit;
  142. ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
  143. rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
  144. (__u16)value_size, cifs_sb->local_nls,
  145. cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  146. } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
  147. strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
  148. #ifdef CONFIG_CIFS_ACL
  149. struct cifs_ntsd *pacl;
  150. pacl = kmalloc(value_size, GFP_KERNEL);
  151. if (!pacl) {
  152. rc = -ENOMEM;
  153. } else {
  154. memcpy(pacl, ea_value, value_size);
  155. rc = set_cifs_acl(pacl, value_size,
  156. direntry->d_inode, full_path, CIFS_ACL_DACL);
  157. if (rc == 0) /* force revalidate of the inode */
  158. CIFS_I(direntry->d_inode)->time = 0;
  159. kfree(pacl);
  160. }
  161. #else
  162. cifs_dbg(FYI, "Set CIFS ACL not supported yet\n");
  163. #endif /* CONFIG_CIFS_ACL */
  164. } else {
  165. int temp;
  166. temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
  167. strlen(POSIX_ACL_XATTR_ACCESS));
  168. if (temp == 0) {
  169. #ifdef CONFIG_CIFS_POSIX
  170. if (sb->s_flags & MS_POSIXACL)
  171. rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
  172. ea_value, (const int)value_size,
  173. ACL_TYPE_ACCESS, cifs_sb->local_nls,
  174. cifs_sb->mnt_cifs_flags &
  175. CIFS_MOUNT_MAP_SPECIAL_CHR);
  176. cifs_dbg(FYI, "set POSIX ACL rc %d\n", rc);
  177. #else
  178. cifs_dbg(FYI, "set POSIX ACL not supported\n");
  179. #endif
  180. } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
  181. strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
  182. #ifdef CONFIG_CIFS_POSIX
  183. if (sb->s_flags & MS_POSIXACL)
  184. rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
  185. ea_value, (const int)value_size,
  186. ACL_TYPE_DEFAULT, cifs_sb->local_nls,
  187. cifs_sb->mnt_cifs_flags &
  188. CIFS_MOUNT_MAP_SPECIAL_CHR);
  189. cifs_dbg(FYI, "set POSIX default ACL rc %d\n", rc);
  190. #else
  191. cifs_dbg(FYI, "set default POSIX ACL not supported\n");
  192. #endif
  193. } else {
  194. cifs_dbg(FYI, "illegal xattr request %s (only user namespace supported)\n",
  195. ea_name);
  196. /* BB what if no namespace prefix? */
  197. /* Should we just pass them to server, except for
  198. system and perhaps security prefixes? */
  199. }
  200. }
  201. set_ea_exit:
  202. kfree(full_path);
  203. free_xid(xid);
  204. cifs_put_tlink(tlink);
  205. #endif
  206. return rc;
  207. }
  208. ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
  209. void *ea_value, size_t buf_size)
  210. {
  211. ssize_t rc = -EOPNOTSUPP;
  212. #ifdef CONFIG_CIFS_XATTR
  213. unsigned int xid;
  214. struct cifs_sb_info *cifs_sb;
  215. struct tcon_link *tlink;
  216. struct cifs_tcon *pTcon;
  217. struct super_block *sb;
  218. char *full_path;
  219. if (direntry == NULL)
  220. return -EIO;
  221. if (direntry->d_inode == NULL)
  222. return -EIO;
  223. sb = direntry->d_inode->i_sb;
  224. if (sb == NULL)
  225. return -EIO;
  226. cifs_sb = CIFS_SB(sb);
  227. tlink = cifs_sb_tlink(cifs_sb);
  228. if (IS_ERR(tlink))
  229. return PTR_ERR(tlink);
  230. pTcon = tlink_tcon(tlink);
  231. xid = get_xid();
  232. full_path = build_path_from_dentry(direntry);
  233. if (full_path == NULL) {
  234. rc = -ENOMEM;
  235. goto get_ea_exit;
  236. }
  237. /* return dos attributes as pseudo xattr */
  238. /* return alt name if available as pseudo attr */
  239. if (ea_name == NULL) {
  240. cifs_dbg(FYI, "Null xattr names not supported\n");
  241. } else if (strncmp(ea_name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)
  242. == 0) {
  243. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  244. goto get_ea_exit;
  245. if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) {
  246. cifs_dbg(FYI, "attempt to query cifs inode metadata\n");
  247. /* revalidate/getattr then populate from inode */
  248. } /* BB add else when above is implemented */
  249. ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
  250. rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
  251. buf_size, cifs_sb->local_nls,
  252. cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  253. } else if (strncmp(ea_name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
  254. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  255. goto get_ea_exit;
  256. ea_name += XATTR_OS2_PREFIX_LEN; /* skip past os2. prefix */
  257. rc = CIFSSMBQAllEAs(xid, pTcon, full_path, ea_name, ea_value,
  258. buf_size, cifs_sb->local_nls,
  259. cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
  260. } else if (strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
  261. strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
  262. #ifdef CONFIG_CIFS_POSIX
  263. if (sb->s_flags & MS_POSIXACL)
  264. rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
  265. ea_value, buf_size, ACL_TYPE_ACCESS,
  266. cifs_sb->local_nls,
  267. cifs_sb->mnt_cifs_flags &
  268. CIFS_MOUNT_MAP_SPECIAL_CHR);
  269. #else
  270. cifs_dbg(FYI, "Query POSIX ACL not supported yet\n");
  271. #endif /* CONFIG_CIFS_POSIX */
  272. } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
  273. strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
  274. #ifdef CONFIG_CIFS_POSIX
  275. if (sb->s_flags & MS_POSIXACL)
  276. rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
  277. ea_value, buf_size, ACL_TYPE_DEFAULT,
  278. cifs_sb->local_nls,
  279. cifs_sb->mnt_cifs_flags &
  280. CIFS_MOUNT_MAP_SPECIAL_CHR);
  281. #else
  282. cifs_dbg(FYI, "Query POSIX default ACL not supported yet\n");
  283. #endif /* CONFIG_CIFS_POSIX */
  284. } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
  285. strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
  286. #ifdef CONFIG_CIFS_ACL
  287. u32 acllen;
  288. struct cifs_ntsd *pacl;
  289. pacl = get_cifs_acl(cifs_sb, direntry->d_inode,
  290. full_path, &acllen);
  291. if (IS_ERR(pacl)) {
  292. rc = PTR_ERR(pacl);
  293. cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
  294. __func__, rc);
  295. } else {
  296. if (ea_value) {
  297. if (acllen > buf_size)
  298. acllen = -ERANGE;
  299. else
  300. memcpy(ea_value, pacl, acllen);
  301. }
  302. rc = acllen;
  303. kfree(pacl);
  304. }
  305. #else
  306. cifs_dbg(FYI, "Query CIFS ACL not supported yet\n");
  307. #endif /* CONFIG_CIFS_ACL */
  308. } else if (strncmp(ea_name,
  309. XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
  310. cifs_dbg(FYI, "Trusted xattr namespace not supported yet\n");
  311. } else if (strncmp(ea_name,
  312. XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) == 0) {
  313. cifs_dbg(FYI, "Security xattr namespace not supported yet\n");
  314. } else
  315. cifs_dbg(FYI,
  316. "illegal xattr request %s (only user namespace supported)\n",
  317. ea_name);
  318. /* We could add an additional check for streams ie
  319. if proc/fs/cifs/streamstoxattr is set then
  320. search server for EAs or streams to
  321. returns as xattrs */
  322. if (rc == -EINVAL)
  323. rc = -EOPNOTSUPP;
  324. get_ea_exit:
  325. kfree(full_path);
  326. free_xid(xid);
  327. cifs_put_tlink(tlink);
  328. #endif
  329. return rc;
  330. }
  331. ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
  332. {
  333. ssize_t rc = -EOPNOTSUPP;
  334. #ifdef CONFIG_CIFS_XATTR
  335. unsigned int xid;
  336. struct cifs_sb_info *cifs_sb;
  337. struct tcon_link *tlink;
  338. struct cifs_tcon *pTcon;
  339. struct super_block *sb;
  340. char *full_path;
  341. if (direntry == NULL)
  342. return -EIO;
  343. if (direntry->d_inode == NULL)
  344. return -EIO;
  345. sb = direntry->d_inode->i_sb;
  346. if (sb == NULL)
  347. return -EIO;
  348. cifs_sb = CIFS_SB(sb);
  349. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  350. return -EOPNOTSUPP;
  351. tlink = cifs_sb_tlink(cifs_sb);
  352. if (IS_ERR(tlink))
  353. return PTR_ERR(tlink);
  354. pTcon = tlink_tcon(tlink);
  355. xid = get_xid();
  356. full_path = build_path_from_dentry(direntry);
  357. if (full_path == NULL) {
  358. rc = -ENOMEM;
  359. goto list_ea_exit;
  360. }
  361. /* return dos attributes as pseudo xattr */
  362. /* return alt name if available as pseudo attr */
  363. /* if proc/fs/cifs/streamstoxattr is set then
  364. search server for EAs or streams to
  365. returns as xattrs */
  366. rc = CIFSSMBQAllEAs(xid, pTcon, full_path, NULL, data,
  367. buf_size, cifs_sb->local_nls,
  368. cifs_sb->mnt_cifs_flags &
  369. CIFS_MOUNT_MAP_SPECIAL_CHR);
  370. list_ea_exit:
  371. kfree(full_path);
  372. free_xid(xid);
  373. cifs_put_tlink(tlink);
  374. #endif
  375. return rc;
  376. }