xattr.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /*
  2. * linux/fs/reiserfs/xattr.c
  3. *
  4. * Copyright (c) 2002 by Jeff Mahoney, <jeffm@suse.com>
  5. *
  6. */
  7. /*
  8. * In order to implement EA/ACLs in a clean, backwards compatible manner,
  9. * they are implemented as files in a "private" directory.
  10. * Each EA is in it's own file, with the directory layout like so (/ is assumed
  11. * to be relative to fs root). Inside the /.reiserfs_priv/xattrs directory,
  12. * directories named using the capital-hex form of the objectid and
  13. * generation number are used. Inside each directory are individual files
  14. * named with the name of the extended attribute.
  15. *
  16. * So, for objectid 12648430, we could have:
  17. * /.reiserfs_priv/xattrs/C0FFEE.0/system.posix_acl_access
  18. * /.reiserfs_priv/xattrs/C0FFEE.0/system.posix_acl_default
  19. * /.reiserfs_priv/xattrs/C0FFEE.0/user.Content-Type
  20. * .. or similar.
  21. *
  22. * The file contents are the text of the EA. The size is known based on the
  23. * stat data describing the file.
  24. *
  25. * In the case of system.posix_acl_access and system.posix_acl_default, since
  26. * these are special cases for filesystem ACLs, they are interpreted by the
  27. * kernel, in addition, they are negatively and positively cached and attached
  28. * to the inode so that unnecessary lookups are avoided.
  29. *
  30. * Locking works like so:
  31. * Directory components (xattr root, xattr dir) are protectd by their i_mutex.
  32. * The xattrs themselves are protected by the xattr_sem.
  33. */
  34. #include <linux/reiserfs_fs.h>
  35. #include <linux/capability.h>
  36. #include <linux/dcache.h>
  37. #include <linux/namei.h>
  38. #include <linux/errno.h>
  39. #include <linux/fs.h>
  40. #include <linux/file.h>
  41. #include <linux/pagemap.h>
  42. #include <linux/xattr.h>
  43. #include <linux/reiserfs_xattr.h>
  44. #include <linux/reiserfs_acl.h>
  45. #include <asm/uaccess.h>
  46. #include <net/checksum.h>
  47. #include <linux/smp_lock.h>
  48. #include <linux/stat.h>
  49. #include <linux/quotaops.h>
  50. #define PRIVROOT_NAME ".reiserfs_priv"
  51. #define XAROOT_NAME "xattrs"
  52. static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char *);
  53. /* Helpers for inode ops. We do this so that we don't have all the VFS
  54. * overhead and also for proper i_mutex annotation.
  55. * dir->i_mutex must be held for all of them. */
  56. static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
  57. {
  58. BUG_ON(!mutex_is_locked(&dir->i_mutex));
  59. DQUOT_INIT(dir);
  60. return dir->i_op->create(dir, dentry, mode, NULL);
  61. }
  62. static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode)
  63. {
  64. BUG_ON(!mutex_is_locked(&dir->i_mutex));
  65. DQUOT_INIT(dir);
  66. return dir->i_op->mkdir(dir, dentry, mode);
  67. }
  68. /* We use I_MUTEX_CHILD here to silence lockdep. It's safe because xattr
  69. * mutation ops aren't called during rename or splace, which are the
  70. * only other users of I_MUTEX_CHILD. It violates the ordering, but that's
  71. * better than allocating another subclass just for this code. */
  72. static int xattr_unlink(struct inode *dir, struct dentry *dentry)
  73. {
  74. int error;
  75. BUG_ON(!mutex_is_locked(&dir->i_mutex));
  76. DQUOT_INIT(dir);
  77. mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD);
  78. error = dir->i_op->unlink(dir, dentry);
  79. mutex_unlock(&dentry->d_inode->i_mutex);
  80. if (!error)
  81. d_delete(dentry);
  82. return error;
  83. }
  84. static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
  85. {
  86. int error;
  87. BUG_ON(!mutex_is_locked(&dir->i_mutex));
  88. DQUOT_INIT(dir);
  89. mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD);
  90. dentry_unhash(dentry);
  91. error = dir->i_op->rmdir(dir, dentry);
  92. if (!error)
  93. dentry->d_inode->i_flags |= S_DEAD;
  94. mutex_unlock(&dentry->d_inode->i_mutex);
  95. if (!error)
  96. d_delete(dentry);
  97. dput(dentry);
  98. return error;
  99. }
  100. #define xattr_may_create(flags) (!flags || flags & XATTR_CREATE)
  101. /* Returns and possibly creates the xattr dir. */
  102. static struct dentry *lookup_or_create_dir(struct dentry *parent,
  103. const char *name, int flags)
  104. {
  105. struct dentry *dentry;
  106. BUG_ON(!parent);
  107. dentry = lookup_one_len(name, parent, strlen(name));
  108. if (IS_ERR(dentry))
  109. return dentry;
  110. else if (!dentry->d_inode) {
  111. int err = -ENODATA;
  112. if (xattr_may_create(flags)) {
  113. mutex_lock_nested(&parent->d_inode->i_mutex,
  114. I_MUTEX_XATTR);
  115. err = xattr_mkdir(parent->d_inode, dentry, 0700);
  116. mutex_unlock(&parent->d_inode->i_mutex);
  117. }
  118. if (err) {
  119. dput(dentry);
  120. dentry = ERR_PTR(err);
  121. }
  122. }
  123. return dentry;
  124. }
  125. static struct dentry *open_xa_root(struct super_block *sb, int flags)
  126. {
  127. struct dentry *privroot = REISERFS_SB(sb)->priv_root;
  128. if (!privroot)
  129. return ERR_PTR(-ENODATA);
  130. return lookup_or_create_dir(privroot, XAROOT_NAME, flags);
  131. }
  132. static struct dentry *open_xa_dir(const struct inode *inode, int flags)
  133. {
  134. struct dentry *xaroot, *xadir;
  135. char namebuf[17];
  136. xaroot = open_xa_root(inode->i_sb, flags);
  137. if (IS_ERR(xaroot))
  138. return xaroot;
  139. snprintf(namebuf, sizeof(namebuf), "%X.%X",
  140. le32_to_cpu(INODE_PKEY(inode)->k_objectid),
  141. inode->i_generation);
  142. xadir = lookup_or_create_dir(xaroot, namebuf, flags);
  143. dput(xaroot);
  144. return xadir;
  145. }
  146. /*
  147. * this is very similar to fs/reiserfs/dir.c:reiserfs_readdir, but
  148. * we need to drop the path before calling the filldir struct. That
  149. * would be a big performance hit to the non-xattr case, so I've copied
  150. * the whole thing for now. --clm
  151. *
  152. * the big difference is that I go backwards through the directory,
  153. * and don't mess with f->f_pos, but the idea is the same. Do some
  154. * action on each and every entry in the directory.
  155. *
  156. * we're called with i_mutex held, so there are no worries about the directory
  157. * changing underneath us.
  158. */
  159. static int __xattr_readdir(struct inode *inode, void *dirent, filldir_t filldir)
  160. {
  161. struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
  162. INITIALIZE_PATH(path_to_entry);
  163. struct buffer_head *bh;
  164. int entry_num;
  165. struct item_head *ih, tmp_ih;
  166. int search_res;
  167. char *local_buf;
  168. loff_t next_pos;
  169. char small_buf[32]; /* avoid kmalloc if we can */
  170. struct reiserfs_de_head *deh;
  171. int d_reclen;
  172. char *d_name;
  173. off_t d_off;
  174. ino_t d_ino;
  175. struct reiserfs_dir_entry de;
  176. /* form key for search the next directory entry using f_pos field of
  177. file structure */
  178. next_pos = max_reiserfs_offset(inode);
  179. while (1) {
  180. research:
  181. if (next_pos <= DOT_DOT_OFFSET)
  182. break;
  183. make_cpu_key(&pos_key, inode, next_pos, TYPE_DIRENTRY, 3);
  184. search_res =
  185. search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
  186. &de);
  187. if (search_res == IO_ERROR) {
  188. // FIXME: we could just skip part of directory which could
  189. // not be read
  190. pathrelse(&path_to_entry);
  191. return -EIO;
  192. }
  193. if (search_res == NAME_NOT_FOUND)
  194. de.de_entry_num--;
  195. set_de_name_and_namelen(&de);
  196. entry_num = de.de_entry_num;
  197. deh = &(de.de_deh[entry_num]);
  198. bh = de.de_bh;
  199. ih = de.de_ih;
  200. if (!is_direntry_le_ih(ih)) {
  201. reiserfs_error(inode->i_sb, "jdm-20000",
  202. "not direntry %h", ih);
  203. break;
  204. }
  205. copy_item_head(&tmp_ih, ih);
  206. /* we must have found item, that is item of this directory, */
  207. RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
  208. "vs-9000: found item %h does not match to dir we readdir %K",
  209. ih, &pos_key);
  210. if (deh_offset(deh) <= DOT_DOT_OFFSET) {
  211. break;
  212. }
  213. /* look for the previous entry in the directory */
  214. next_pos = deh_offset(deh) - 1;
  215. if (!de_visible(deh))
  216. /* it is hidden entry */
  217. continue;
  218. d_reclen = entry_length(bh, ih, entry_num);
  219. d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
  220. d_off = deh_offset(deh);
  221. d_ino = deh_objectid(deh);
  222. if (!d_name[d_reclen - 1])
  223. d_reclen = strlen(d_name);
  224. if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)) {
  225. /* too big to send back to VFS */
  226. continue;
  227. }
  228. /* Ignore the .reiserfs_priv entry */
  229. if (reiserfs_xattrs(inode->i_sb) &&
  230. !old_format_only(inode->i_sb) &&
  231. deh_objectid(deh) ==
  232. le32_to_cpu(INODE_PKEY
  233. (REISERFS_SB(inode->i_sb)->priv_root->d_inode)->
  234. k_objectid))
  235. continue;
  236. if (d_reclen <= 32) {
  237. local_buf = small_buf;
  238. } else {
  239. local_buf = kmalloc(d_reclen, GFP_NOFS);
  240. if (!local_buf) {
  241. pathrelse(&path_to_entry);
  242. return -ENOMEM;
  243. }
  244. if (item_moved(&tmp_ih, &path_to_entry)) {
  245. kfree(local_buf);
  246. /* sigh, must retry. Do this same offset again */
  247. next_pos = d_off;
  248. goto research;
  249. }
  250. }
  251. // Note, that we copy name to user space via temporary
  252. // buffer (local_buf) because filldir will block if
  253. // user space buffer is swapped out. At that time
  254. // entry can move to somewhere else
  255. memcpy(local_buf, d_name, d_reclen);
  256. /* the filldir function might need to start transactions,
  257. * or do who knows what. Release the path now that we've
  258. * copied all the important stuff out of the deh
  259. */
  260. pathrelse(&path_to_entry);
  261. if (filldir(dirent, local_buf, d_reclen, d_off, d_ino,
  262. DT_UNKNOWN) < 0) {
  263. if (local_buf != small_buf) {
  264. kfree(local_buf);
  265. }
  266. goto end;
  267. }
  268. if (local_buf != small_buf) {
  269. kfree(local_buf);
  270. }
  271. } /* while */
  272. end:
  273. pathrelse(&path_to_entry);
  274. return 0;
  275. }
  276. /*
  277. * this could be done with dedicated readdir ops for the xattr files,
  278. * but I want to get something working asap
  279. * this is stolen from vfs_readdir
  280. *
  281. */
  282. static
  283. int xattr_readdir(struct inode *inode, filldir_t filler, void *buf)
  284. {
  285. int res = -ENOENT;
  286. if (!IS_DEADDIR(inode)) {
  287. lock_kernel();
  288. res = __xattr_readdir(inode, buf, filler);
  289. unlock_kernel();
  290. }
  291. return res;
  292. }
  293. /* expects xadir->d_inode->i_mutex to be locked */
  294. static int
  295. __reiserfs_xattr_del(struct dentry *xadir, const char *name, int namelen)
  296. {
  297. struct dentry *dentry;
  298. struct inode *dir = xadir->d_inode;
  299. int err = 0;
  300. struct reiserfs_xattr_handler *xah;
  301. dentry = lookup_one_len(name, xadir, namelen);
  302. if (IS_ERR(dentry)) {
  303. err = PTR_ERR(dentry);
  304. goto out;
  305. } else if (!dentry->d_inode) {
  306. err = -ENODATA;
  307. goto out_file;
  308. }
  309. /* Skip directories.. */
  310. if (S_ISDIR(dentry->d_inode->i_mode))
  311. goto out_file;
  312. if (!IS_PRIVATE(dentry->d_inode)) {
  313. reiserfs_error(dir->i_sb, "jdm-20003",
  314. "OID %08x [%.*s/%.*s] doesn't have "
  315. "priv flag set [parent is %sset].",
  316. le32_to_cpu(INODE_PKEY(dentry->d_inode)->
  317. k_objectid), xadir->d_name.len,
  318. xadir->d_name.name, namelen, name,
  319. IS_PRIVATE(xadir->d_inode) ? "" :
  320. "not ");
  321. dput(dentry);
  322. return -EIO;
  323. }
  324. /* Deletion pre-operation */
  325. xah = find_xattr_handler_prefix(name);
  326. if (xah && xah->del) {
  327. err = xah->del(dentry->d_inode, name);
  328. if (err)
  329. goto out;
  330. }
  331. err = xattr_unlink(dir, dentry);
  332. out_file:
  333. dput(dentry);
  334. out:
  335. return err;
  336. }
  337. /* The following are side effects of other operations that aren't explicitly
  338. * modifying extended attributes. This includes operations such as permissions
  339. * or ownership changes, object deletions, etc. */
  340. static int
  341. reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
  342. loff_t offset, u64 ino, unsigned int d_type)
  343. {
  344. struct dentry *xadir = (struct dentry *)buf;
  345. return __reiserfs_xattr_del(xadir, name, namelen);
  346. }
  347. /* This is called w/ inode->i_mutex downed */
  348. int reiserfs_delete_xattrs(struct inode *inode)
  349. {
  350. int err = -ENODATA;
  351. struct dentry *dir, *root;
  352. struct reiserfs_transaction_handle th;
  353. int blocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 +
  354. 4 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
  355. /* Skip out, an xattr has no xattrs associated with it */
  356. if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1)
  357. return 0;
  358. dir = open_xa_dir(inode, XATTR_REPLACE);
  359. if (IS_ERR(dir)) {
  360. err = PTR_ERR(dir);
  361. goto out;
  362. } else if (!dir->d_inode) {
  363. dput(dir);
  364. goto out;
  365. }
  366. mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
  367. err = xattr_readdir(dir->d_inode, reiserfs_delete_xattrs_filler, dir);
  368. mutex_unlock(&dir->d_inode->i_mutex);
  369. if (err) {
  370. dput(dir);
  371. goto out;
  372. }
  373. root = dget(dir->d_parent);
  374. dput(dir);
  375. /* We start a transaction here to avoid a ABBA situation
  376. * between the xattr root's i_mutex and the journal lock.
  377. * Inode creation will inherit an ACL, which requires a
  378. * lookup. The lookup locks the xattr root i_mutex with a
  379. * transaction open. Inode deletion takes teh xattr root
  380. * i_mutex to delete the directory and then starts a
  381. * transaction inside it. Boom. This doesn't incur much
  382. * additional overhead since the reiserfs_rmdir transaction
  383. * will just nest inside the outer transaction. */
  384. err = journal_begin(&th, inode->i_sb, blocks);
  385. if (!err) {
  386. int jerror;
  387. mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_XATTR);
  388. err = xattr_rmdir(root->d_inode, dir);
  389. jerror = journal_end(&th, inode->i_sb, blocks);
  390. mutex_unlock(&root->d_inode->i_mutex);
  391. err = jerror ?: err;
  392. }
  393. dput(root);
  394. out:
  395. if (!err)
  396. REISERFS_I(inode)->i_flags =
  397. REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
  398. else
  399. reiserfs_warning(inode->i_sb, "jdm-20004",
  400. "Couldn't remove all xattrs (%d)\n", err);
  401. return err;
  402. }
  403. struct reiserfs_chown_buf {
  404. struct inode *inode;
  405. struct dentry *xadir;
  406. struct iattr *attrs;
  407. };
  408. /* XXX: If there is a better way to do this, I'd love to hear about it */
  409. static int
  410. reiserfs_chown_xattrs_filler(void *buf, const char *name, int namelen,
  411. loff_t offset, u64 ino, unsigned int d_type)
  412. {
  413. struct reiserfs_chown_buf *chown_buf = (struct reiserfs_chown_buf *)buf;
  414. struct dentry *xafile, *xadir = chown_buf->xadir;
  415. struct iattr *attrs = chown_buf->attrs;
  416. int err = 0;
  417. xafile = lookup_one_len(name, xadir, namelen);
  418. if (IS_ERR(xafile))
  419. return PTR_ERR(xafile);
  420. else if (!xafile->d_inode) {
  421. dput(xafile);
  422. return -ENODATA;
  423. }
  424. if (!S_ISDIR(xafile->d_inode->i_mode)) {
  425. mutex_lock_nested(&xafile->d_inode->i_mutex, I_MUTEX_CHILD);
  426. err = reiserfs_setattr(xafile, attrs);
  427. mutex_unlock(&xafile->d_inode->i_mutex);
  428. }
  429. dput(xafile);
  430. return err;
  431. }
  432. int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
  433. {
  434. struct dentry *dir;
  435. int err = 0;
  436. struct reiserfs_chown_buf buf;
  437. unsigned int ia_valid = attrs->ia_valid;
  438. /* Skip out, an xattr has no xattrs associated with it */
  439. if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1)
  440. return 0;
  441. dir = open_xa_dir(inode, XATTR_REPLACE);
  442. if (IS_ERR(dir)) {
  443. if (PTR_ERR(dir) != -ENODATA)
  444. err = PTR_ERR(dir);
  445. goto out;
  446. } else if (!dir->d_inode)
  447. goto out_dir;
  448. attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
  449. buf.xadir = dir;
  450. buf.attrs = attrs;
  451. buf.inode = inode;
  452. mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
  453. err = xattr_readdir(dir->d_inode, reiserfs_chown_xattrs_filler, &buf);
  454. if (!err)
  455. err = reiserfs_setattr(dir, attrs);
  456. mutex_unlock(&dir->d_inode->i_mutex);
  457. attrs->ia_valid = ia_valid;
  458. out_dir:
  459. dput(dir);
  460. out:
  461. if (err)
  462. reiserfs_warning(inode->i_sb, "jdm-20007",
  463. "Couldn't chown all xattrs (%d)\n", err);
  464. return err;
  465. }
  466. #ifdef CONFIG_REISERFS_FS_XATTR
  467. static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
  468. *prefix);
  469. /* Returns a dentry corresponding to a specific extended attribute file
  470. * for the inode. If flags allow, the file is created. Otherwise, a
  471. * valid or negative dentry, or an error is returned. */
  472. static struct dentry *get_xa_file_dentry(const struct inode *inode,
  473. const char *name, int flags)
  474. {
  475. struct dentry *xadir, *xafile;
  476. int err = 0;
  477. xadir = open_xa_dir(inode, flags);
  478. if (IS_ERR(xadir))
  479. return ERR_CAST(xadir);
  480. xafile = lookup_one_len(name, xadir, strlen(name));
  481. if (IS_ERR(xafile)) {
  482. err = PTR_ERR(xafile);
  483. goto out;
  484. }
  485. if (xafile->d_inode && (flags & XATTR_CREATE))
  486. err = -EEXIST;
  487. if (!xafile->d_inode) {
  488. err = -ENODATA;
  489. if (xattr_may_create(flags)) {
  490. mutex_lock_nested(&xadir->d_inode->i_mutex,
  491. I_MUTEX_XATTR);
  492. err = xattr_create(xadir->d_inode, xafile,
  493. 0700|S_IFREG);
  494. mutex_unlock(&xadir->d_inode->i_mutex);
  495. }
  496. }
  497. if (err)
  498. dput(xafile);
  499. out:
  500. dput(xadir);
  501. if (err)
  502. return ERR_PTR(err);
  503. return xafile;
  504. }
  505. /* Internal operations on file data */
  506. static inline void reiserfs_put_page(struct page *page)
  507. {
  508. kunmap(page);
  509. page_cache_release(page);
  510. }
  511. static struct page *reiserfs_get_page(struct inode *dir, size_t n)
  512. {
  513. struct address_space *mapping = dir->i_mapping;
  514. struct page *page;
  515. /* We can deadlock if we try to free dentries,
  516. and an unlink/rmdir has just occured - GFP_NOFS avoids this */
  517. mapping_set_gfp_mask(mapping, GFP_NOFS);
  518. page = read_mapping_page(mapping, n >> PAGE_CACHE_SHIFT, NULL);
  519. if (!IS_ERR(page)) {
  520. kmap(page);
  521. if (PageError(page))
  522. goto fail;
  523. }
  524. return page;
  525. fail:
  526. reiserfs_put_page(page);
  527. return ERR_PTR(-EIO);
  528. }
  529. static inline __u32 xattr_hash(const char *msg, int len)
  530. {
  531. return csum_partial(msg, len, 0);
  532. }
  533. int reiserfs_commit_write(struct file *f, struct page *page,
  534. unsigned from, unsigned to);
  535. int reiserfs_prepare_write(struct file *f, struct page *page,
  536. unsigned from, unsigned to);
  537. /* Generic extended attribute operations that can be used by xa plugins */
  538. /*
  539. * inode->i_mutex: down
  540. */
  541. int
  542. reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
  543. size_t buffer_size, int flags)
  544. {
  545. int err = 0;
  546. struct dentry *dentry;
  547. struct page *page;
  548. char *data;
  549. size_t file_pos = 0;
  550. size_t buffer_pos = 0;
  551. struct iattr newattrs;
  552. __u32 xahash = 0;
  553. if (get_inode_sd_version(inode) == STAT_DATA_V1)
  554. return -EOPNOTSUPP;
  555. if (!buffer)
  556. return reiserfs_xattr_del(inode, name);
  557. dentry = get_xa_file_dentry(inode, name, flags);
  558. if (IS_ERR(dentry)) {
  559. err = PTR_ERR(dentry);
  560. goto out;
  561. }
  562. down_write(&REISERFS_I(inode)->i_xattr_sem);
  563. xahash = xattr_hash(buffer, buffer_size);
  564. REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
  565. /* Resize it so we're ok to write there */
  566. newattrs.ia_size = buffer_size;
  567. newattrs.ia_ctime = current_fs_time(inode->i_sb);
  568. newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
  569. mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_XATTR);
  570. down_write(&dentry->d_inode->i_alloc_sem);
  571. err = reiserfs_setattr(dentry, &newattrs);
  572. up_write(&dentry->d_inode->i_alloc_sem);
  573. mutex_unlock(&dentry->d_inode->i_mutex);
  574. if (err)
  575. goto out_filp;
  576. while (buffer_pos < buffer_size || buffer_pos == 0) {
  577. size_t chunk;
  578. size_t skip = 0;
  579. size_t page_offset = (file_pos & (PAGE_CACHE_SIZE - 1));
  580. if (buffer_size - buffer_pos > PAGE_CACHE_SIZE)
  581. chunk = PAGE_CACHE_SIZE;
  582. else
  583. chunk = buffer_size - buffer_pos;
  584. page = reiserfs_get_page(dentry->d_inode, file_pos);
  585. if (IS_ERR(page)) {
  586. err = PTR_ERR(page);
  587. goto out_filp;
  588. }
  589. lock_page(page);
  590. data = page_address(page);
  591. if (file_pos == 0) {
  592. struct reiserfs_xattr_header *rxh;
  593. skip = file_pos = sizeof(struct reiserfs_xattr_header);
  594. if (chunk + skip > PAGE_CACHE_SIZE)
  595. chunk = PAGE_CACHE_SIZE - skip;
  596. rxh = (struct reiserfs_xattr_header *)data;
  597. rxh->h_magic = cpu_to_le32(REISERFS_XATTR_MAGIC);
  598. rxh->h_hash = cpu_to_le32(xahash);
  599. }
  600. err = reiserfs_prepare_write(NULL, page, page_offset,
  601. page_offset + chunk + skip);
  602. if (!err) {
  603. if (buffer)
  604. memcpy(data + skip, buffer + buffer_pos, chunk);
  605. err = reiserfs_commit_write(NULL, page, page_offset,
  606. page_offset + chunk +
  607. skip);
  608. }
  609. unlock_page(page);
  610. reiserfs_put_page(page);
  611. buffer_pos += chunk;
  612. file_pos += chunk;
  613. skip = 0;
  614. if (err || buffer_size == 0 || !buffer)
  615. break;
  616. }
  617. /* We can't mark the inode dirty if it's not hashed. This is the case
  618. * when we're inheriting the default ACL. If we dirty it, the inode
  619. * gets marked dirty, but won't (ever) make it onto the dirty list until
  620. * it's synced explicitly to clear I_DIRTY. This is bad. */
  621. if (!hlist_unhashed(&inode->i_hash)) {
  622. inode->i_ctime = CURRENT_TIME_SEC;
  623. mark_inode_dirty(inode);
  624. }
  625. out_filp:
  626. up_write(&REISERFS_I(inode)->i_xattr_sem);
  627. dput(dentry);
  628. out:
  629. return err;
  630. }
  631. /*
  632. * inode->i_mutex: down
  633. */
  634. int
  635. reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
  636. size_t buffer_size)
  637. {
  638. ssize_t err = 0;
  639. struct dentry *dentry;
  640. size_t isize;
  641. size_t file_pos = 0;
  642. size_t buffer_pos = 0;
  643. struct page *page;
  644. __u32 hash = 0;
  645. if (name == NULL)
  646. return -EINVAL;
  647. /* We can't have xattrs attached to v1 items since they don't have
  648. * generation numbers */
  649. if (get_inode_sd_version(inode) == STAT_DATA_V1)
  650. return -EOPNOTSUPP;
  651. dentry = get_xa_file_dentry(inode, name, XATTR_REPLACE);
  652. if (IS_ERR(dentry)) {
  653. err = PTR_ERR(dentry);
  654. goto out;
  655. }
  656. down_read(&REISERFS_I(inode)->i_xattr_sem);
  657. isize = i_size_read(dentry->d_inode);
  658. REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
  659. /* Just return the size needed */
  660. if (buffer == NULL) {
  661. err = isize - sizeof(struct reiserfs_xattr_header);
  662. goto out_unlock;
  663. }
  664. if (buffer_size < isize - sizeof(struct reiserfs_xattr_header)) {
  665. err = -ERANGE;
  666. goto out_unlock;
  667. }
  668. while (file_pos < isize) {
  669. size_t chunk;
  670. char *data;
  671. size_t skip = 0;
  672. if (isize - file_pos > PAGE_CACHE_SIZE)
  673. chunk = PAGE_CACHE_SIZE;
  674. else
  675. chunk = isize - file_pos;
  676. page = reiserfs_get_page(dentry->d_inode, file_pos);
  677. if (IS_ERR(page)) {
  678. err = PTR_ERR(page);
  679. goto out_unlock;
  680. }
  681. lock_page(page);
  682. data = page_address(page);
  683. if (file_pos == 0) {
  684. struct reiserfs_xattr_header *rxh =
  685. (struct reiserfs_xattr_header *)data;
  686. skip = file_pos = sizeof(struct reiserfs_xattr_header);
  687. chunk -= skip;
  688. /* Magic doesn't match up.. */
  689. if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
  690. unlock_page(page);
  691. reiserfs_put_page(page);
  692. reiserfs_warning(inode->i_sb, "jdm-20001",
  693. "Invalid magic for xattr (%s) "
  694. "associated with %k", name,
  695. INODE_PKEY(inode));
  696. err = -EIO;
  697. goto out_unlock;
  698. }
  699. hash = le32_to_cpu(rxh->h_hash);
  700. }
  701. memcpy(buffer + buffer_pos, data + skip, chunk);
  702. unlock_page(page);
  703. reiserfs_put_page(page);
  704. file_pos += chunk;
  705. buffer_pos += chunk;
  706. skip = 0;
  707. }
  708. err = isize - sizeof(struct reiserfs_xattr_header);
  709. if (xattr_hash(buffer, isize - sizeof(struct reiserfs_xattr_header)) !=
  710. hash) {
  711. reiserfs_warning(inode->i_sb, "jdm-20002",
  712. "Invalid hash for xattr (%s) associated "
  713. "with %k", name, INODE_PKEY(inode));
  714. err = -EIO;
  715. }
  716. out_unlock:
  717. up_read(&REISERFS_I(inode)->i_xattr_sem);
  718. dput(dentry);
  719. out:
  720. return err;
  721. }
  722. int reiserfs_xattr_del(struct inode *inode, const char *name)
  723. {
  724. struct dentry *dir;
  725. int err;
  726. dir = open_xa_dir(inode, XATTR_REPLACE);
  727. if (IS_ERR(dir)) {
  728. err = PTR_ERR(dir);
  729. goto out;
  730. }
  731. mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
  732. err = __reiserfs_xattr_del(dir, name, strlen(name));
  733. mutex_unlock(&dir->d_inode->i_mutex);
  734. dput(dir);
  735. if (!err) {
  736. inode->i_ctime = CURRENT_TIME_SEC;
  737. mark_inode_dirty(inode);
  738. }
  739. out:
  740. return err;
  741. }
  742. /* Actual operations that are exported to VFS-land */
  743. /*
  744. * Inode operation getxattr()
  745. */
  746. ssize_t
  747. reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
  748. size_t size)
  749. {
  750. struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
  751. int err;
  752. if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
  753. get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
  754. return -EOPNOTSUPP;
  755. err = xah->get(dentry->d_inode, name, buffer, size);
  756. return err;
  757. }
  758. /*
  759. * Inode operation setxattr()
  760. *
  761. * dentry->d_inode->i_mutex down
  762. */
  763. int
  764. reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
  765. size_t size, int flags)
  766. {
  767. struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
  768. int err;
  769. if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
  770. get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
  771. return -EOPNOTSUPP;
  772. err = xah->set(dentry->d_inode, name, value, size, flags);
  773. return err;
  774. }
  775. /*
  776. * Inode operation removexattr()
  777. *
  778. * dentry->d_inode->i_mutex down
  779. */
  780. int reiserfs_removexattr(struct dentry *dentry, const char *name)
  781. {
  782. int err;
  783. struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
  784. if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
  785. get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
  786. return -EOPNOTSUPP;
  787. err = reiserfs_xattr_del(dentry->d_inode, name);
  788. dentry->d_inode->i_ctime = CURRENT_TIME_SEC;
  789. mark_inode_dirty(dentry->d_inode);
  790. return err;
  791. }
  792. /* This is what filldir will use:
  793. * r_pos will always contain the amount of space required for the entire
  794. * list. If r_pos becomes larger than r_size, we need more space and we
  795. * return an error indicating this. If r_pos is less than r_size, then we've
  796. * filled the buffer successfully and we return success */
  797. struct reiserfs_listxattr_buf {
  798. int r_pos;
  799. int r_size;
  800. char *r_buf;
  801. struct inode *r_inode;
  802. };
  803. static int
  804. reiserfs_listxattr_filler(void *buf, const char *name, int namelen,
  805. loff_t offset, u64 ino, unsigned int d_type)
  806. {
  807. struct reiserfs_listxattr_buf *b = (struct reiserfs_listxattr_buf *)buf;
  808. int len = 0;
  809. if (name[0] != '.'
  810. || (namelen != 1 && (name[1] != '.' || namelen != 2))) {
  811. struct reiserfs_xattr_handler *xah =
  812. find_xattr_handler_prefix(name);
  813. if (!xah)
  814. return 0; /* Unsupported xattr name, skip it */
  815. /* We call ->list() twice because the operation isn't required to just
  816. * return the name back - we want to make sure we have enough space */
  817. len += xah->list(b->r_inode, name, namelen, NULL);
  818. if (len) {
  819. if (b->r_pos + len + 1 <= b->r_size) {
  820. char *p = b->r_buf + b->r_pos;
  821. p += xah->list(b->r_inode, name, namelen, p);
  822. *p++ = '\0';
  823. }
  824. b->r_pos += len + 1;
  825. }
  826. }
  827. return 0;
  828. }
  829. /*
  830. * Inode operation listxattr()
  831. */
  832. ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
  833. {
  834. struct dentry *dir;
  835. int err = 0;
  836. struct reiserfs_listxattr_buf buf;
  837. if (!dentry->d_inode)
  838. return -EINVAL;
  839. if (!reiserfs_xattrs(dentry->d_sb) ||
  840. get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
  841. return -EOPNOTSUPP;
  842. dir = open_xa_dir(dentry->d_inode, XATTR_REPLACE);
  843. if (IS_ERR(dir)) {
  844. err = PTR_ERR(dir);
  845. if (err == -ENODATA)
  846. err = 0; /* Not an error if there aren't any xattrs */
  847. goto out;
  848. }
  849. buf.r_buf = buffer;
  850. buf.r_size = buffer ? size : 0;
  851. buf.r_pos = 0;
  852. buf.r_inode = dentry->d_inode;
  853. REISERFS_I(dentry->d_inode)->i_flags |= i_has_xattr_dir;
  854. mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
  855. err = xattr_readdir(dir->d_inode, reiserfs_listxattr_filler, &buf);
  856. mutex_unlock(&dir->d_inode->i_mutex);
  857. if (!err) {
  858. if (buf.r_pos > buf.r_size && buffer != NULL)
  859. err = -ERANGE;
  860. else
  861. err = buf.r_pos;
  862. }
  863. dput(dir);
  864. out:
  865. return err;
  866. }
  867. /* This is the implementation for the xattr plugin infrastructure */
  868. static LIST_HEAD(xattr_handlers);
  869. static DEFINE_RWLOCK(handler_lock);
  870. static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
  871. *prefix)
  872. {
  873. struct reiserfs_xattr_handler *xah = NULL;
  874. struct list_head *p;
  875. read_lock(&handler_lock);
  876. list_for_each(p, &xattr_handlers) {
  877. xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
  878. if (strncmp(xah->prefix, prefix, strlen(xah->prefix)) == 0)
  879. break;
  880. xah = NULL;
  881. }
  882. read_unlock(&handler_lock);
  883. return xah;
  884. }
  885. static void __unregister_handlers(void)
  886. {
  887. struct reiserfs_xattr_handler *xah;
  888. struct list_head *p, *tmp;
  889. list_for_each_safe(p, tmp, &xattr_handlers) {
  890. xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
  891. if (xah->exit)
  892. xah->exit();
  893. list_del_init(p);
  894. }
  895. INIT_LIST_HEAD(&xattr_handlers);
  896. }
  897. int __init reiserfs_xattr_register_handlers(void)
  898. {
  899. int err = 0;
  900. struct reiserfs_xattr_handler *xah;
  901. struct list_head *p;
  902. write_lock(&handler_lock);
  903. /* If we're already initialized, nothing to do */
  904. if (!list_empty(&xattr_handlers)) {
  905. write_unlock(&handler_lock);
  906. return 0;
  907. }
  908. /* Add the handlers */
  909. list_add_tail(&user_handler.handlers, &xattr_handlers);
  910. list_add_tail(&trusted_handler.handlers, &xattr_handlers);
  911. #ifdef CONFIG_REISERFS_FS_SECURITY
  912. list_add_tail(&security_handler.handlers, &xattr_handlers);
  913. #endif
  914. #ifdef CONFIG_REISERFS_FS_POSIX_ACL
  915. list_add_tail(&posix_acl_access_handler.handlers, &xattr_handlers);
  916. list_add_tail(&posix_acl_default_handler.handlers, &xattr_handlers);
  917. #endif
  918. /* Run initializers, if available */
  919. list_for_each(p, &xattr_handlers) {
  920. xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
  921. if (xah->init) {
  922. err = xah->init();
  923. if (err) {
  924. list_del_init(p);
  925. break;
  926. }
  927. }
  928. }
  929. /* Clean up other handlers, if any failed */
  930. if (err)
  931. __unregister_handlers();
  932. write_unlock(&handler_lock);
  933. return err;
  934. }
  935. void reiserfs_xattr_unregister_handlers(void)
  936. {
  937. write_lock(&handler_lock);
  938. __unregister_handlers();
  939. write_unlock(&handler_lock);
  940. }
  941. static int reiserfs_check_acl(struct inode *inode, int mask)
  942. {
  943. struct posix_acl *acl;
  944. int error = -EAGAIN; /* do regular unix permission checks by default */
  945. acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
  946. if (acl) {
  947. if (!IS_ERR(acl)) {
  948. error = posix_acl_permission(inode, acl, mask);
  949. posix_acl_release(acl);
  950. } else if (PTR_ERR(acl) != -ENODATA)
  951. error = PTR_ERR(acl);
  952. }
  953. return error;
  954. }
  955. int reiserfs_permission(struct inode *inode, int mask)
  956. {
  957. /*
  958. * We don't do permission checks on the internal objects.
  959. * Permissions are determined by the "owning" object.
  960. */
  961. if (IS_PRIVATE(inode))
  962. return 0;
  963. /*
  964. * Stat data v1 doesn't support ACLs.
  965. */
  966. if (get_inode_sd_version(inode) == STAT_DATA_V1)
  967. return generic_permission(inode, mask, NULL);
  968. else
  969. return generic_permission(inode, mask, reiserfs_check_acl);
  970. }
  971. static int create_privroot(struct dentry *dentry)
  972. {
  973. int err;
  974. struct inode *inode = dentry->d_parent->d_inode;
  975. mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR);
  976. err = xattr_mkdir(inode, dentry, 0700);
  977. mutex_unlock(&inode->i_mutex);
  978. if (err) {
  979. dput(dentry);
  980. dentry = NULL;
  981. }
  982. if (dentry && dentry->d_inode)
  983. reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
  984. "storage.\n", PRIVROOT_NAME);
  985. return err;
  986. }
  987. static int xattr_mount_check(struct super_block *s)
  988. {
  989. /* We need generation numbers to ensure that the oid mapping is correct
  990. * v3.5 filesystems don't have them. */
  991. if (!old_format_only(s)) {
  992. set_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
  993. } else if (reiserfs_xattrs_optional(s)) {
  994. /* Old format filesystem, but optional xattrs have been enabled
  995. * at mount time. Error out. */
  996. reiserfs_warning(s, "jdm-20005",
  997. "xattrs/ACLs not supported on pre v3.6 "
  998. "format filesystem. Failing mount.");
  999. return -EOPNOTSUPP;
  1000. } else {
  1001. /* Old format filesystem, but no optional xattrs have
  1002. * been enabled. This means we silently disable xattrs
  1003. * on the filesystem. */
  1004. clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
  1005. }
  1006. return 0;
  1007. }
  1008. #else
  1009. int __init reiserfs_xattr_register_handlers(void) { return 0; }
  1010. void reiserfs_xattr_unregister_handlers(void) {}
  1011. #endif
  1012. /* This will catch lookups from the fs root to .reiserfs_priv */
  1013. static int
  1014. xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
  1015. {
  1016. struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root;
  1017. if (name->len == priv_root->d_name.len &&
  1018. name->hash == priv_root->d_name.hash &&
  1019. !memcmp(name->name, priv_root->d_name.name, name->len)) {
  1020. return -ENOENT;
  1021. } else if (q1->len == name->len &&
  1022. !memcmp(q1->name, name->name, name->len))
  1023. return 0;
  1024. return 1;
  1025. }
  1026. static struct dentry_operations xattr_lookup_poison_ops = {
  1027. .d_compare = xattr_lookup_poison,
  1028. };
  1029. /* We need to take a copy of the mount flags since things like
  1030. * MS_RDONLY don't get set until *after* we're called.
  1031. * mount_flags != mount_options */
  1032. int reiserfs_xattr_init(struct super_block *s, int mount_flags)
  1033. {
  1034. int err = 0;
  1035. #ifdef CONFIG_REISERFS_FS_XATTR
  1036. err = xattr_mount_check(s);
  1037. if (err)
  1038. goto error;
  1039. #endif
  1040. /* If we don't have the privroot located yet - go find it */
  1041. if (!REISERFS_SB(s)->priv_root) {
  1042. struct dentry *dentry;
  1043. dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
  1044. strlen(PRIVROOT_NAME));
  1045. if (!IS_ERR(dentry)) {
  1046. #ifdef CONFIG_REISERFS_FS_XATTR
  1047. if (!(mount_flags & MS_RDONLY) && !dentry->d_inode)
  1048. err = create_privroot(dentry);
  1049. #endif
  1050. if (!dentry->d_inode) {
  1051. dput(dentry);
  1052. dentry = NULL;
  1053. }
  1054. } else
  1055. err = PTR_ERR(dentry);
  1056. if (!err && dentry) {
  1057. s->s_root->d_op = &xattr_lookup_poison_ops;
  1058. dentry->d_inode->i_flags |= S_PRIVATE;
  1059. REISERFS_SB(s)->priv_root = dentry;
  1060. #ifdef CONFIG_REISERFS_FS_XATTR
  1061. /* xattrs are unavailable */
  1062. } else if (!(mount_flags & MS_RDONLY)) {
  1063. /* If we're read-only it just means that the dir
  1064. * hasn't been created. Not an error -- just no
  1065. * xattrs on the fs. We'll check again if we
  1066. * go read-write */
  1067. reiserfs_warning(s, "jdm-20006",
  1068. "xattrs/ACLs enabled and couldn't "
  1069. "find/create .reiserfs_priv. "
  1070. "Failing mount.");
  1071. err = -EOPNOTSUPP;
  1072. #endif
  1073. }
  1074. }
  1075. #ifdef CONFIG_REISERFS_FS_XATTR
  1076. error:
  1077. if (err) {
  1078. clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
  1079. clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt));
  1080. clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt));
  1081. }
  1082. #endif
  1083. /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */
  1084. s->s_flags = s->s_flags & ~MS_POSIXACL;
  1085. #ifdef CONFIG_REISERFS_FS_POSIX_ACL
  1086. if (reiserfs_posixacl(s))
  1087. s->s_flags |= MS_POSIXACL;
  1088. #endif
  1089. return err;
  1090. }