vfs_inode.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. /*
  2. * linux/fs/9p/vfs_inode.c
  3. *
  4. * This file contains vfs inode ops for the 9P2000 protocol.
  5. *
  6. * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
  7. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to:
  20. * Free Software Foundation
  21. * 51 Franklin Street, Fifth Floor
  22. * Boston, MA 02111-1301 USA
  23. *
  24. */
  25. #include <linux/module.h>
  26. #include <linux/errno.h>
  27. #include <linux/fs.h>
  28. #include <linux/file.h>
  29. #include <linux/pagemap.h>
  30. #include <linux/stat.h>
  31. #include <linux/string.h>
  32. #include <linux/inet.h>
  33. #include <linux/namei.h>
  34. #include <linux/idr.h>
  35. #include <linux/sched.h>
  36. #include <linux/slab.h>
  37. #include <linux/xattr.h>
  38. #include <linux/posix_acl.h>
  39. #include <net/9p/9p.h>
  40. #include <net/9p/client.h>
  41. #include "v9fs.h"
  42. #include "v9fs_vfs.h"
  43. #include "fid.h"
  44. #include "cache.h"
  45. #include "xattr.h"
  46. #include "acl.h"
  47. static const struct inode_operations v9fs_dir_inode_operations;
  48. static const struct inode_operations v9fs_dir_inode_operations_dotu;
  49. static const struct inode_operations v9fs_file_inode_operations;
  50. static const struct inode_operations v9fs_symlink_inode_operations;
  51. /**
  52. * unixmode2p9mode - convert unix mode bits to plan 9
  53. * @v9ses: v9fs session information
  54. * @mode: mode to convert
  55. *
  56. */
  57. static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
  58. {
  59. int res;
  60. res = mode & 0777;
  61. if (S_ISDIR(mode))
  62. res |= P9_DMDIR;
  63. if (v9fs_proto_dotu(v9ses)) {
  64. if (S_ISLNK(mode))
  65. res |= P9_DMSYMLINK;
  66. if (v9ses->nodev == 0) {
  67. if (S_ISSOCK(mode))
  68. res |= P9_DMSOCKET;
  69. if (S_ISFIFO(mode))
  70. res |= P9_DMNAMEDPIPE;
  71. if (S_ISBLK(mode))
  72. res |= P9_DMDEVICE;
  73. if (S_ISCHR(mode))
  74. res |= P9_DMDEVICE;
  75. }
  76. if ((mode & S_ISUID) == S_ISUID)
  77. res |= P9_DMSETUID;
  78. if ((mode & S_ISGID) == S_ISGID)
  79. res |= P9_DMSETGID;
  80. if ((mode & S_ISVTX) == S_ISVTX)
  81. res |= P9_DMSETVTX;
  82. if ((mode & P9_DMLINK))
  83. res |= P9_DMLINK;
  84. }
  85. return res;
  86. }
  87. /**
  88. * p9mode2unixmode- convert plan9 mode bits to unix mode bits
  89. * @v9ses: v9fs session information
  90. * @mode: mode to convert
  91. *
  92. */
  93. static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
  94. {
  95. int res;
  96. res = mode & 0777;
  97. if ((mode & P9_DMDIR) == P9_DMDIR)
  98. res |= S_IFDIR;
  99. else if ((mode & P9_DMSYMLINK) && (v9fs_proto_dotu(v9ses)))
  100. res |= S_IFLNK;
  101. else if ((mode & P9_DMSOCKET) && (v9fs_proto_dotu(v9ses))
  102. && (v9ses->nodev == 0))
  103. res |= S_IFSOCK;
  104. else if ((mode & P9_DMNAMEDPIPE) && (v9fs_proto_dotu(v9ses))
  105. && (v9ses->nodev == 0))
  106. res |= S_IFIFO;
  107. else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses))
  108. && (v9ses->nodev == 0))
  109. res |= S_IFBLK;
  110. else
  111. res |= S_IFREG;
  112. if (v9fs_proto_dotu(v9ses)) {
  113. if ((mode & P9_DMSETUID) == P9_DMSETUID)
  114. res |= S_ISUID;
  115. if ((mode & P9_DMSETGID) == P9_DMSETGID)
  116. res |= S_ISGID;
  117. if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
  118. res |= S_ISVTX;
  119. }
  120. return res;
  121. }
  122. /**
  123. * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
  124. * @uflags: flags to convert
  125. * @extended: if .u extensions are active
  126. */
  127. int v9fs_uflags2omode(int uflags, int extended)
  128. {
  129. int ret;
  130. ret = 0;
  131. switch (uflags&3) {
  132. default:
  133. case O_RDONLY:
  134. ret = P9_OREAD;
  135. break;
  136. case O_WRONLY:
  137. ret = P9_OWRITE;
  138. break;
  139. case O_RDWR:
  140. ret = P9_ORDWR;
  141. break;
  142. }
  143. if (uflags & O_TRUNC)
  144. ret |= P9_OTRUNC;
  145. if (extended) {
  146. if (uflags & O_EXCL)
  147. ret |= P9_OEXCL;
  148. if (uflags & O_APPEND)
  149. ret |= P9_OAPPEND;
  150. }
  151. return ret;
  152. }
  153. /**
  154. * v9fs_blank_wstat - helper function to setup a 9P stat structure
  155. * @wstat: structure to initialize
  156. *
  157. */
  158. void
  159. v9fs_blank_wstat(struct p9_wstat *wstat)
  160. {
  161. wstat->type = ~0;
  162. wstat->dev = ~0;
  163. wstat->qid.type = ~0;
  164. wstat->qid.version = ~0;
  165. *((long long *)&wstat->qid.path) = ~0;
  166. wstat->mode = ~0;
  167. wstat->atime = ~0;
  168. wstat->mtime = ~0;
  169. wstat->length = ~0;
  170. wstat->name = NULL;
  171. wstat->uid = NULL;
  172. wstat->gid = NULL;
  173. wstat->muid = NULL;
  174. wstat->n_uid = ~0;
  175. wstat->n_gid = ~0;
  176. wstat->n_muid = ~0;
  177. wstat->extension = NULL;
  178. }
  179. #ifdef CONFIG_9P_FSCACHE
  180. /**
  181. * v9fs_alloc_inode - helper function to allocate an inode
  182. * This callback is executed before setting up the inode so that we
  183. * can associate a vcookie with each inode.
  184. *
  185. */
  186. struct inode *v9fs_alloc_inode(struct super_block *sb)
  187. {
  188. struct v9fs_cookie *vcookie;
  189. vcookie = (struct v9fs_cookie *)kmem_cache_alloc(vcookie_cache,
  190. GFP_KERNEL);
  191. if (!vcookie)
  192. return NULL;
  193. vcookie->fscache = NULL;
  194. vcookie->qid = NULL;
  195. spin_lock_init(&vcookie->lock);
  196. return &vcookie->inode;
  197. }
  198. /**
  199. * v9fs_destroy_inode - destroy an inode
  200. *
  201. */
  202. static void v9fs_i_callback(struct rcu_head *head)
  203. {
  204. struct inode *inode = container_of(head, struct inode, i_rcu);
  205. INIT_LIST_HEAD(&inode->i_dentry);
  206. kmem_cache_free(vcookie_cache, v9fs_inode2cookie(inode));
  207. }
  208. void v9fs_destroy_inode(struct inode *inode)
  209. {
  210. call_rcu(&inode->i_rcu, v9fs_i_callback);
  211. }
  212. #endif
  213. int v9fs_init_inode(struct v9fs_session_info *v9ses,
  214. struct inode *inode, int mode)
  215. {
  216. int err = 0;
  217. inode_init_owner(inode, NULL, mode);
  218. inode->i_blocks = 0;
  219. inode->i_rdev = 0;
  220. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  221. inode->i_mapping->a_ops = &v9fs_addr_operations;
  222. switch (mode & S_IFMT) {
  223. case S_IFIFO:
  224. case S_IFBLK:
  225. case S_IFCHR:
  226. case S_IFSOCK:
  227. if (v9fs_proto_dotl(v9ses)) {
  228. inode->i_op = &v9fs_file_inode_operations_dotl;
  229. inode->i_fop = &v9fs_file_operations_dotl;
  230. } else if (v9fs_proto_dotu(v9ses)) {
  231. inode->i_op = &v9fs_file_inode_operations;
  232. inode->i_fop = &v9fs_file_operations;
  233. } else {
  234. P9_DPRINTK(P9_DEBUG_ERROR,
  235. "special files without extended mode\n");
  236. err = -EINVAL;
  237. goto error;
  238. }
  239. init_special_inode(inode, inode->i_mode, inode->i_rdev);
  240. break;
  241. case S_IFREG:
  242. if (v9fs_proto_dotl(v9ses)) {
  243. inode->i_op = &v9fs_file_inode_operations_dotl;
  244. if (v9ses->cache)
  245. inode->i_fop =
  246. &v9fs_cached_file_operations_dotl;
  247. else
  248. inode->i_fop = &v9fs_file_operations_dotl;
  249. } else {
  250. inode->i_op = &v9fs_file_inode_operations;
  251. if (v9ses->cache)
  252. inode->i_fop = &v9fs_cached_file_operations;
  253. else
  254. inode->i_fop = &v9fs_file_operations;
  255. }
  256. break;
  257. case S_IFLNK:
  258. if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) {
  259. P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with "
  260. "legacy protocol.\n");
  261. err = -EINVAL;
  262. goto error;
  263. }
  264. if (v9fs_proto_dotl(v9ses))
  265. inode->i_op = &v9fs_symlink_inode_operations_dotl;
  266. else
  267. inode->i_op = &v9fs_symlink_inode_operations;
  268. break;
  269. case S_IFDIR:
  270. inc_nlink(inode);
  271. if (v9fs_proto_dotl(v9ses))
  272. inode->i_op = &v9fs_dir_inode_operations_dotl;
  273. else if (v9fs_proto_dotu(v9ses))
  274. inode->i_op = &v9fs_dir_inode_operations_dotu;
  275. else
  276. inode->i_op = &v9fs_dir_inode_operations;
  277. if (v9fs_proto_dotl(v9ses))
  278. inode->i_fop = &v9fs_dir_operations_dotl;
  279. else
  280. inode->i_fop = &v9fs_dir_operations;
  281. break;
  282. default:
  283. P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
  284. mode, mode & S_IFMT);
  285. err = -EINVAL;
  286. goto error;
  287. }
  288. error:
  289. return err;
  290. }
  291. /**
  292. * v9fs_get_inode - helper function to setup an inode
  293. * @sb: superblock
  294. * @mode: mode to setup inode with
  295. *
  296. */
  297. struct inode *v9fs_get_inode(struct super_block *sb, int mode)
  298. {
  299. int err;
  300. struct inode *inode;
  301. struct v9fs_session_info *v9ses = sb->s_fs_info;
  302. P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
  303. inode = new_inode(sb);
  304. if (!inode) {
  305. P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
  306. return ERR_PTR(-ENOMEM);
  307. }
  308. err = v9fs_init_inode(v9ses, inode, mode);
  309. if (err) {
  310. iput(inode);
  311. return ERR_PTR(err);
  312. }
  313. return inode;
  314. }
  315. /*
  316. static struct v9fs_fid*
  317. v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
  318. {
  319. int err;
  320. int nfid;
  321. struct v9fs_fid *ret;
  322. struct v9fs_fcall *fcall;
  323. nfid = v9fs_get_idpool(&v9ses->fidpool);
  324. if (nfid < 0) {
  325. eprintk(KERN_WARNING, "no free fids available\n");
  326. return ERR_PTR(-ENOSPC);
  327. }
  328. err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
  329. &fcall);
  330. if (err < 0) {
  331. if (fcall && fcall->id == RWALK)
  332. goto clunk_fid;
  333. PRINT_FCALL_ERROR("walk error", fcall);
  334. v9fs_put_idpool(nfid, &v9ses->fidpool);
  335. goto error;
  336. }
  337. kfree(fcall);
  338. fcall = NULL;
  339. ret = v9fs_fid_create(v9ses, nfid);
  340. if (!ret) {
  341. err = -ENOMEM;
  342. goto clunk_fid;
  343. }
  344. err = v9fs_fid_insert(ret, dentry);
  345. if (err < 0) {
  346. v9fs_fid_destroy(ret);
  347. goto clunk_fid;
  348. }
  349. return ret;
  350. clunk_fid:
  351. v9fs_t_clunk(v9ses, nfid);
  352. error:
  353. kfree(fcall);
  354. return ERR_PTR(err);
  355. }
  356. */
  357. /**
  358. * v9fs_clear_inode - release an inode
  359. * @inode: inode to release
  360. *
  361. */
  362. void v9fs_evict_inode(struct inode *inode)
  363. {
  364. truncate_inode_pages(inode->i_mapping, 0);
  365. end_writeback(inode);
  366. filemap_fdatawrite(inode->i_mapping);
  367. #ifdef CONFIG_9P_FSCACHE
  368. v9fs_cache_inode_put_cookie(inode);
  369. #endif
  370. /* clunk the fid stashed in inode->i_private */
  371. if (inode->i_private) {
  372. p9_client_clunk((struct p9_fid *)inode->i_private);
  373. inode->i_private = NULL;
  374. }
  375. }
  376. static struct inode *v9fs_qid_iget(struct super_block *sb,
  377. struct p9_qid *qid,
  378. struct p9_wstat *st)
  379. {
  380. int retval, umode;
  381. unsigned long i_ino;
  382. struct inode *inode;
  383. struct v9fs_session_info *v9ses = sb->s_fs_info;
  384. i_ino = v9fs_qid2ino(qid);
  385. inode = iget_locked(sb, i_ino);
  386. if (!inode)
  387. return ERR_PTR(-ENOMEM);
  388. if (!(inode->i_state & I_NEW))
  389. return inode;
  390. /*
  391. * initialize the inode with the stat info
  392. * FIXME!! we may need support for stale inodes
  393. * later.
  394. */
  395. umode = p9mode2unixmode(v9ses, st->mode);
  396. retval = v9fs_init_inode(v9ses, inode, umode);
  397. if (retval)
  398. goto error;
  399. v9fs_stat2inode(st, inode, sb);
  400. #ifdef CONFIG_9P_FSCACHE
  401. v9fs_vcookie_set_qid(ret, &st->qid);
  402. v9fs_cache_inode_get_cookie(inode);
  403. #endif
  404. unlock_new_inode(inode);
  405. return inode;
  406. error:
  407. unlock_new_inode(inode);
  408. iput(inode);
  409. return ERR_PTR(retval);
  410. }
  411. struct inode *
  412. v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid,
  413. struct super_block *sb)
  414. {
  415. struct p9_wstat *st;
  416. struct inode *inode = NULL;
  417. st = p9_client_stat(fid);
  418. if (IS_ERR(st))
  419. return ERR_CAST(st);
  420. inode = v9fs_qid_iget(sb, &st->qid, st);
  421. p9stat_free(st);
  422. kfree(st);
  423. return inode;
  424. }
  425. /**
  426. * v9fs_remove - helper function to remove files and directories
  427. * @dir: directory inode that is being deleted
  428. * @file: dentry that is being deleted
  429. * @rmdir: removing a directory
  430. *
  431. */
  432. static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
  433. {
  434. int retval;
  435. struct inode *file_inode;
  436. struct p9_fid *v9fid;
  437. P9_DPRINTK(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file,
  438. rmdir);
  439. file_inode = file->d_inode;
  440. v9fid = v9fs_fid_clone(file);
  441. if (IS_ERR(v9fid))
  442. return PTR_ERR(v9fid);
  443. retval = p9_client_remove(v9fid);
  444. if (!retval)
  445. drop_nlink(file_inode);
  446. return retval;
  447. }
  448. /**
  449. * v9fs_create - Create a file
  450. * @v9ses: session information
  451. * @dir: directory that dentry is being created in
  452. * @dentry: dentry that is being created
  453. * @extension: 9p2000.u extension string to support devices, etc.
  454. * @perm: create permissions
  455. * @mode: open mode
  456. *
  457. */
  458. static struct p9_fid *
  459. v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
  460. struct dentry *dentry, char *extension, u32 perm, u8 mode)
  461. {
  462. int err;
  463. char *name;
  464. struct p9_fid *dfid, *ofid, *fid;
  465. struct inode *inode;
  466. P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
  467. err = 0;
  468. ofid = NULL;
  469. fid = NULL;
  470. name = (char *) dentry->d_name.name;
  471. dfid = v9fs_fid_lookup(dentry->d_parent);
  472. if (IS_ERR(dfid)) {
  473. err = PTR_ERR(dfid);
  474. P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
  475. return ERR_PTR(err);
  476. }
  477. /* clone a fid to use for creation */
  478. ofid = p9_client_walk(dfid, 0, NULL, 1);
  479. if (IS_ERR(ofid)) {
  480. err = PTR_ERR(ofid);
  481. P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
  482. return ERR_PTR(err);
  483. }
  484. err = p9_client_fcreate(ofid, name, perm, mode, extension);
  485. if (err < 0) {
  486. P9_DPRINTK(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err);
  487. goto error;
  488. }
  489. /* now walk from the parent so we can get unopened fid */
  490. fid = p9_client_walk(dfid, 1, &name, 1);
  491. if (IS_ERR(fid)) {
  492. err = PTR_ERR(fid);
  493. P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
  494. fid = NULL;
  495. goto error;
  496. }
  497. /* instantiate inode and assign the unopened fid to the dentry */
  498. inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
  499. if (IS_ERR(inode)) {
  500. err = PTR_ERR(inode);
  501. P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
  502. goto error;
  503. }
  504. d_instantiate(dentry, inode);
  505. err = v9fs_fid_add(dentry, fid);
  506. if (err < 0)
  507. goto error;
  508. return ofid;
  509. error:
  510. if (ofid)
  511. p9_client_clunk(ofid);
  512. if (fid)
  513. p9_client_clunk(fid);
  514. return ERR_PTR(err);
  515. }
  516. /**
  517. * v9fs_vfs_create - VFS hook to create files
  518. * @dir: directory inode that is being created
  519. * @dentry: dentry that is being deleted
  520. * @mode: create permissions
  521. * @nd: path information
  522. *
  523. */
  524. static int
  525. v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
  526. struct nameidata *nd)
  527. {
  528. int err;
  529. u32 perm;
  530. int flags;
  531. struct v9fs_session_info *v9ses;
  532. struct p9_fid *fid, *inode_fid;
  533. struct file *filp;
  534. err = 0;
  535. fid = NULL;
  536. v9ses = v9fs_inode2v9ses(dir);
  537. perm = unixmode2p9mode(v9ses, mode);
  538. if (nd && nd->flags & LOOKUP_OPEN)
  539. flags = nd->intent.open.flags - 1;
  540. else
  541. flags = O_RDWR;
  542. fid = v9fs_create(v9ses, dir, dentry, NULL, perm,
  543. v9fs_uflags2omode(flags,
  544. v9fs_proto_dotu(v9ses)));
  545. if (IS_ERR(fid)) {
  546. err = PTR_ERR(fid);
  547. fid = NULL;
  548. goto error;
  549. }
  550. /* if we are opening a file, assign the open fid to the file */
  551. if (nd && nd->flags & LOOKUP_OPEN) {
  552. if (v9ses->cache && !dentry->d_inode->i_private) {
  553. /*
  554. * clone a fid and add it to inode->i_private
  555. * we do it during open time instead of
  556. * page dirty time via write_begin/page_mkwrite
  557. * because we want write after unlink usecase
  558. * to work.
  559. */
  560. inode_fid = v9fs_writeback_fid(dentry);
  561. if (IS_ERR(inode_fid)) {
  562. err = PTR_ERR(inode_fid);
  563. goto error;
  564. }
  565. dentry->d_inode->i_private = (void *) inode_fid;
  566. }
  567. filp = lookup_instantiate_filp(nd, dentry, generic_file_open);
  568. if (IS_ERR(filp)) {
  569. err = PTR_ERR(filp);
  570. goto error;
  571. }
  572. filp->private_data = fid;
  573. #ifdef CONFIG_9P_FSCACHE
  574. if (v9ses->cache)
  575. v9fs_cache_inode_set_cookie(dentry->d_inode, filp);
  576. #endif
  577. } else
  578. p9_client_clunk(fid);
  579. return 0;
  580. error:
  581. if (fid)
  582. p9_client_clunk(fid);
  583. return err;
  584. }
  585. /**
  586. * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
  587. * @dir: inode that is being unlinked
  588. * @dentry: dentry that is being unlinked
  589. * @mode: mode for new directory
  590. *
  591. */
  592. static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
  593. {
  594. int err;
  595. u32 perm;
  596. struct v9fs_session_info *v9ses;
  597. struct p9_fid *fid;
  598. P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
  599. err = 0;
  600. v9ses = v9fs_inode2v9ses(dir);
  601. perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
  602. fid = v9fs_create(v9ses, dir, dentry, NULL, perm, P9_OREAD);
  603. if (IS_ERR(fid)) {
  604. err = PTR_ERR(fid);
  605. fid = NULL;
  606. }
  607. if (fid)
  608. p9_client_clunk(fid);
  609. return err;
  610. }
  611. /**
  612. * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
  613. * @dir: inode that is being walked from
  614. * @dentry: dentry that is being walked to?
  615. * @nameidata: path data
  616. *
  617. */
  618. struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
  619. struct nameidata *nameidata)
  620. {
  621. struct super_block *sb;
  622. struct v9fs_session_info *v9ses;
  623. struct p9_fid *dfid, *fid;
  624. struct inode *inode;
  625. char *name;
  626. int result = 0;
  627. P9_DPRINTK(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n",
  628. dir, dentry->d_name.name, dentry, nameidata);
  629. if (dentry->d_name.len > NAME_MAX)
  630. return ERR_PTR(-ENAMETOOLONG);
  631. sb = dir->i_sb;
  632. v9ses = v9fs_inode2v9ses(dir);
  633. /* We can walk d_parent because we hold the dir->i_mutex */
  634. dfid = v9fs_fid_lookup(dentry->d_parent);
  635. if (IS_ERR(dfid))
  636. return ERR_CAST(dfid);
  637. name = (char *) dentry->d_name.name;
  638. fid = p9_client_walk(dfid, 1, &name, 1);
  639. if (IS_ERR(fid)) {
  640. result = PTR_ERR(fid);
  641. if (result == -ENOENT) {
  642. inode = NULL;
  643. goto inst_out;
  644. }
  645. return ERR_PTR(result);
  646. }
  647. inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
  648. if (IS_ERR(inode)) {
  649. result = PTR_ERR(inode);
  650. inode = NULL;
  651. goto error;
  652. }
  653. result = v9fs_fid_add(dentry, fid);
  654. if (result < 0)
  655. goto error_iput;
  656. inst_out:
  657. d_add(dentry, inode);
  658. return NULL;
  659. error_iput:
  660. iput(inode);
  661. error:
  662. p9_client_clunk(fid);
  663. return ERR_PTR(result);
  664. }
  665. /**
  666. * v9fs_vfs_unlink - VFS unlink hook to delete an inode
  667. * @i: inode that is being unlinked
  668. * @d: dentry that is being unlinked
  669. *
  670. */
  671. int v9fs_vfs_unlink(struct inode *i, struct dentry *d)
  672. {
  673. return v9fs_remove(i, d, 0);
  674. }
  675. /**
  676. * v9fs_vfs_rmdir - VFS unlink hook to delete a directory
  677. * @i: inode that is being unlinked
  678. * @d: dentry that is being unlinked
  679. *
  680. */
  681. int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
  682. {
  683. return v9fs_remove(i, d, 1);
  684. }
  685. /**
  686. * v9fs_vfs_rename - VFS hook to rename an inode
  687. * @old_dir: old dir inode
  688. * @old_dentry: old dentry
  689. * @new_dir: new dir inode
  690. * @new_dentry: new dentry
  691. *
  692. */
  693. int
  694. v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  695. struct inode *new_dir, struct dentry *new_dentry)
  696. {
  697. struct inode *old_inode;
  698. struct v9fs_session_info *v9ses;
  699. struct p9_fid *oldfid;
  700. struct p9_fid *olddirfid;
  701. struct p9_fid *newdirfid;
  702. struct p9_wstat wstat;
  703. int retval;
  704. P9_DPRINTK(P9_DEBUG_VFS, "\n");
  705. retval = 0;
  706. old_inode = old_dentry->d_inode;
  707. v9ses = v9fs_inode2v9ses(old_inode);
  708. oldfid = v9fs_fid_lookup(old_dentry);
  709. if (IS_ERR(oldfid))
  710. return PTR_ERR(oldfid);
  711. olddirfid = v9fs_fid_clone(old_dentry->d_parent);
  712. if (IS_ERR(olddirfid)) {
  713. retval = PTR_ERR(olddirfid);
  714. goto done;
  715. }
  716. newdirfid = v9fs_fid_clone(new_dentry->d_parent);
  717. if (IS_ERR(newdirfid)) {
  718. retval = PTR_ERR(newdirfid);
  719. goto clunk_olddir;
  720. }
  721. down_write(&v9ses->rename_sem);
  722. if (v9fs_proto_dotl(v9ses)) {
  723. retval = p9_client_rename(oldfid, newdirfid,
  724. (char *) new_dentry->d_name.name);
  725. if (retval != -ENOSYS)
  726. goto clunk_newdir;
  727. }
  728. if (old_dentry->d_parent != new_dentry->d_parent) {
  729. /*
  730. * 9P .u can only handle file rename in the same directory
  731. */
  732. P9_DPRINTK(P9_DEBUG_ERROR,
  733. "old dir and new dir are different\n");
  734. retval = -EXDEV;
  735. goto clunk_newdir;
  736. }
  737. v9fs_blank_wstat(&wstat);
  738. wstat.muid = v9ses->uname;
  739. wstat.name = (char *) new_dentry->d_name.name;
  740. retval = p9_client_wstat(oldfid, &wstat);
  741. clunk_newdir:
  742. if (!retval)
  743. /* successful rename */
  744. d_move(old_dentry, new_dentry);
  745. up_write(&v9ses->rename_sem);
  746. p9_client_clunk(newdirfid);
  747. clunk_olddir:
  748. p9_client_clunk(olddirfid);
  749. done:
  750. return retval;
  751. }
  752. /**
  753. * v9fs_vfs_getattr - retrieve file metadata
  754. * @mnt: mount information
  755. * @dentry: file to get attributes on
  756. * @stat: metadata structure to populate
  757. *
  758. */
  759. static int
  760. v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
  761. struct kstat *stat)
  762. {
  763. int err;
  764. struct v9fs_session_info *v9ses;
  765. struct p9_fid *fid;
  766. struct p9_wstat *st;
  767. P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
  768. err = -EPERM;
  769. v9ses = v9fs_inode2v9ses(dentry->d_inode);
  770. if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
  771. generic_fillattr(dentry->d_inode, stat);
  772. return 0;
  773. }
  774. fid = v9fs_fid_lookup(dentry);
  775. if (IS_ERR(fid))
  776. return PTR_ERR(fid);
  777. st = p9_client_stat(fid);
  778. if (IS_ERR(st))
  779. return PTR_ERR(st);
  780. v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb);
  781. generic_fillattr(dentry->d_inode, stat);
  782. p9stat_free(st);
  783. kfree(st);
  784. return 0;
  785. }
  786. /**
  787. * v9fs_vfs_setattr - set file metadata
  788. * @dentry: file whose metadata to set
  789. * @iattr: metadata assignment structure
  790. *
  791. */
  792. static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
  793. {
  794. int retval;
  795. struct v9fs_session_info *v9ses;
  796. struct p9_fid *fid;
  797. struct p9_wstat wstat;
  798. P9_DPRINTK(P9_DEBUG_VFS, "\n");
  799. retval = -EPERM;
  800. v9ses = v9fs_inode2v9ses(dentry->d_inode);
  801. fid = v9fs_fid_lookup(dentry);
  802. if(IS_ERR(fid))
  803. return PTR_ERR(fid);
  804. v9fs_blank_wstat(&wstat);
  805. if (iattr->ia_valid & ATTR_MODE)
  806. wstat.mode = unixmode2p9mode(v9ses, iattr->ia_mode);
  807. if (iattr->ia_valid & ATTR_MTIME)
  808. wstat.mtime = iattr->ia_mtime.tv_sec;
  809. if (iattr->ia_valid & ATTR_ATIME)
  810. wstat.atime = iattr->ia_atime.tv_sec;
  811. if (iattr->ia_valid & ATTR_SIZE)
  812. wstat.length = iattr->ia_size;
  813. if (v9fs_proto_dotu(v9ses)) {
  814. if (iattr->ia_valid & ATTR_UID)
  815. wstat.n_uid = iattr->ia_uid;
  816. if (iattr->ia_valid & ATTR_GID)
  817. wstat.n_gid = iattr->ia_gid;
  818. }
  819. retval = p9_client_wstat(fid, &wstat);
  820. if (retval < 0)
  821. return retval;
  822. if ((iattr->ia_valid & ATTR_SIZE) &&
  823. iattr->ia_size != i_size_read(dentry->d_inode)) {
  824. retval = vmtruncate(dentry->d_inode, iattr->ia_size);
  825. if (retval)
  826. return retval;
  827. }
  828. setattr_copy(dentry->d_inode, iattr);
  829. mark_inode_dirty(dentry->d_inode);
  830. return 0;
  831. }
  832. /**
  833. * v9fs_stat2inode - populate an inode structure with mistat info
  834. * @stat: Plan 9 metadata (mistat) structure
  835. * @inode: inode to populate
  836. * @sb: superblock of filesystem
  837. *
  838. */
  839. void
  840. v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
  841. struct super_block *sb)
  842. {
  843. char ext[32];
  844. char tag_name[14];
  845. unsigned int i_nlink;
  846. struct v9fs_session_info *v9ses = sb->s_fs_info;
  847. inode->i_nlink = 1;
  848. inode->i_atime.tv_sec = stat->atime;
  849. inode->i_mtime.tv_sec = stat->mtime;
  850. inode->i_ctime.tv_sec = stat->mtime;
  851. inode->i_uid = v9ses->dfltuid;
  852. inode->i_gid = v9ses->dfltgid;
  853. if (v9fs_proto_dotu(v9ses)) {
  854. inode->i_uid = stat->n_uid;
  855. inode->i_gid = stat->n_gid;
  856. }
  857. if ((S_ISREG(inode->i_mode)) || (S_ISDIR(inode->i_mode))) {
  858. if (v9fs_proto_dotu(v9ses) && (stat->extension[0] != '\0')) {
  859. /*
  860. * Hadlink support got added later to
  861. * to the .u extension. So there can be
  862. * server out there that doesn't support
  863. * this even with .u extension. So check
  864. * for non NULL stat->extension
  865. */
  866. strncpy(ext, stat->extension, sizeof(ext));
  867. /* HARDLINKCOUNT %u */
  868. sscanf(ext, "%13s %u", tag_name, &i_nlink);
  869. if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
  870. inode->i_nlink = i_nlink;
  871. }
  872. }
  873. inode->i_mode = p9mode2unixmode(v9ses, stat->mode);
  874. if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
  875. char type = 0;
  876. int major = -1;
  877. int minor = -1;
  878. strncpy(ext, stat->extension, sizeof(ext));
  879. sscanf(ext, "%c %u %u", &type, &major, &minor);
  880. switch (type) {
  881. case 'c':
  882. inode->i_mode &= ~S_IFBLK;
  883. inode->i_mode |= S_IFCHR;
  884. break;
  885. case 'b':
  886. break;
  887. default:
  888. P9_DPRINTK(P9_DEBUG_ERROR,
  889. "Unknown special type %c %s\n", type,
  890. stat->extension);
  891. };
  892. inode->i_rdev = MKDEV(major, minor);
  893. init_special_inode(inode, inode->i_mode, inode->i_rdev);
  894. } else
  895. inode->i_rdev = 0;
  896. i_size_write(inode, stat->length);
  897. /* not real number of blocks, but 512 byte ones ... */
  898. inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
  899. }
  900. /**
  901. * v9fs_qid2ino - convert qid into inode number
  902. * @qid: qid to hash
  903. *
  904. * BUG: potential for inode number collisions?
  905. */
  906. ino_t v9fs_qid2ino(struct p9_qid *qid)
  907. {
  908. u64 path = qid->path + 2;
  909. ino_t i = 0;
  910. if (sizeof(ino_t) == sizeof(path))
  911. memcpy(&i, &path, sizeof(ino_t));
  912. else
  913. i = (ino_t) (path ^ (path >> 32));
  914. return i;
  915. }
  916. /**
  917. * v9fs_readlink - read a symlink's location (internal version)
  918. * @dentry: dentry for symlink
  919. * @buffer: buffer to load symlink location into
  920. * @buflen: length of buffer
  921. *
  922. */
  923. static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
  924. {
  925. int retval;
  926. struct v9fs_session_info *v9ses;
  927. struct p9_fid *fid;
  928. struct p9_wstat *st;
  929. P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
  930. retval = -EPERM;
  931. v9ses = v9fs_inode2v9ses(dentry->d_inode);
  932. fid = v9fs_fid_lookup(dentry);
  933. if (IS_ERR(fid))
  934. return PTR_ERR(fid);
  935. if (!v9fs_proto_dotu(v9ses))
  936. return -EBADF;
  937. st = p9_client_stat(fid);
  938. if (IS_ERR(st))
  939. return PTR_ERR(st);
  940. if (!(st->mode & P9_DMSYMLINK)) {
  941. retval = -EINVAL;
  942. goto done;
  943. }
  944. /* copy extension buffer into buffer */
  945. strncpy(buffer, st->extension, buflen);
  946. P9_DPRINTK(P9_DEBUG_VFS,
  947. "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);
  948. retval = strnlen(buffer, buflen);
  949. done:
  950. p9stat_free(st);
  951. kfree(st);
  952. return retval;
  953. }
  954. /**
  955. * v9fs_vfs_follow_link - follow a symlink path
  956. * @dentry: dentry for symlink
  957. * @nd: nameidata
  958. *
  959. */
  960. static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
  961. {
  962. int len = 0;
  963. char *link = __getname();
  964. P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
  965. if (!link)
  966. link = ERR_PTR(-ENOMEM);
  967. else {
  968. len = v9fs_readlink(dentry, link, PATH_MAX);
  969. if (len < 0) {
  970. __putname(link);
  971. link = ERR_PTR(len);
  972. } else
  973. link[min(len, PATH_MAX-1)] = 0;
  974. }
  975. nd_set_link(nd, link);
  976. return NULL;
  977. }
  978. /**
  979. * v9fs_vfs_put_link - release a symlink path
  980. * @dentry: dentry for symlink
  981. * @nd: nameidata
  982. * @p: unused
  983. *
  984. */
  985. void
  986. v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
  987. {
  988. char *s = nd_get_link(nd);
  989. P9_DPRINTK(P9_DEBUG_VFS, " %s %s\n", dentry->d_name.name,
  990. IS_ERR(s) ? "<error>" : s);
  991. if (!IS_ERR(s))
  992. __putname(s);
  993. }
  994. /**
  995. * v9fs_vfs_mkspecial - create a special file
  996. * @dir: inode to create special file in
  997. * @dentry: dentry to create
  998. * @mode: mode to create special file
  999. * @extension: 9p2000.u format extension string representing special file
  1000. *
  1001. */
  1002. static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
  1003. int mode, const char *extension)
  1004. {
  1005. u32 perm;
  1006. struct v9fs_session_info *v9ses;
  1007. struct p9_fid *fid;
  1008. v9ses = v9fs_inode2v9ses(dir);
  1009. if (!v9fs_proto_dotu(v9ses)) {
  1010. P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n");
  1011. return -EPERM;
  1012. }
  1013. perm = unixmode2p9mode(v9ses, mode);
  1014. fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm,
  1015. P9_OREAD);
  1016. if (IS_ERR(fid))
  1017. return PTR_ERR(fid);
  1018. p9_client_clunk(fid);
  1019. return 0;
  1020. }
  1021. /**
  1022. * v9fs_vfs_symlink - helper function to create symlinks
  1023. * @dir: directory inode containing symlink
  1024. * @dentry: dentry for symlink
  1025. * @symname: symlink data
  1026. *
  1027. * See Also: 9P2000.u RFC for more information
  1028. *
  1029. */
  1030. static int
  1031. v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
  1032. {
  1033. P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino,
  1034. dentry->d_name.name, symname);
  1035. return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname);
  1036. }
  1037. /**
  1038. * v9fs_vfs_link - create a hardlink
  1039. * @old_dentry: dentry for file to link to
  1040. * @dir: inode destination for new link
  1041. * @dentry: dentry for link
  1042. *
  1043. */
  1044. static int
  1045. v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
  1046. struct dentry *dentry)
  1047. {
  1048. int retval;
  1049. struct p9_fid *oldfid;
  1050. char *name;
  1051. P9_DPRINTK(P9_DEBUG_VFS,
  1052. " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name,
  1053. old_dentry->d_name.name);
  1054. oldfid = v9fs_fid_clone(old_dentry);
  1055. if (IS_ERR(oldfid))
  1056. return PTR_ERR(oldfid);
  1057. name = __getname();
  1058. if (unlikely(!name)) {
  1059. retval = -ENOMEM;
  1060. goto clunk_fid;
  1061. }
  1062. sprintf(name, "%d\n", oldfid->fid);
  1063. retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name);
  1064. __putname(name);
  1065. clunk_fid:
  1066. p9_client_clunk(oldfid);
  1067. return retval;
  1068. }
  1069. /**
  1070. * v9fs_vfs_mknod - create a special file
  1071. * @dir: inode destination for new link
  1072. * @dentry: dentry for file
  1073. * @mode: mode for creation
  1074. * @rdev: device associated with special file
  1075. *
  1076. */
  1077. static int
  1078. v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
  1079. {
  1080. int retval;
  1081. char *name;
  1082. P9_DPRINTK(P9_DEBUG_VFS,
  1083. " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
  1084. dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
  1085. if (!new_valid_dev(rdev))
  1086. return -EINVAL;
  1087. name = __getname();
  1088. if (!name)
  1089. return -ENOMEM;
  1090. /* build extension */
  1091. if (S_ISBLK(mode))
  1092. sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
  1093. else if (S_ISCHR(mode))
  1094. sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev));
  1095. else if (S_ISFIFO(mode))
  1096. *name = 0;
  1097. else if (S_ISSOCK(mode))
  1098. *name = 0;
  1099. else {
  1100. __putname(name);
  1101. return -EINVAL;
  1102. }
  1103. retval = v9fs_vfs_mkspecial(dir, dentry, mode, name);
  1104. __putname(name);
  1105. return retval;
  1106. }
  1107. static const struct inode_operations v9fs_dir_inode_operations_dotu = {
  1108. .create = v9fs_vfs_create,
  1109. .lookup = v9fs_vfs_lookup,
  1110. .symlink = v9fs_vfs_symlink,
  1111. .link = v9fs_vfs_link,
  1112. .unlink = v9fs_vfs_unlink,
  1113. .mkdir = v9fs_vfs_mkdir,
  1114. .rmdir = v9fs_vfs_rmdir,
  1115. .mknod = v9fs_vfs_mknod,
  1116. .rename = v9fs_vfs_rename,
  1117. .getattr = v9fs_vfs_getattr,
  1118. .setattr = v9fs_vfs_setattr,
  1119. };
  1120. static const struct inode_operations v9fs_dir_inode_operations = {
  1121. .create = v9fs_vfs_create,
  1122. .lookup = v9fs_vfs_lookup,
  1123. .unlink = v9fs_vfs_unlink,
  1124. .mkdir = v9fs_vfs_mkdir,
  1125. .rmdir = v9fs_vfs_rmdir,
  1126. .mknod = v9fs_vfs_mknod,
  1127. .rename = v9fs_vfs_rename,
  1128. .getattr = v9fs_vfs_getattr,
  1129. .setattr = v9fs_vfs_setattr,
  1130. };
  1131. static const struct inode_operations v9fs_file_inode_operations = {
  1132. .getattr = v9fs_vfs_getattr,
  1133. .setattr = v9fs_vfs_setattr,
  1134. };
  1135. static const struct inode_operations v9fs_symlink_inode_operations = {
  1136. .readlink = generic_readlink,
  1137. .follow_link = v9fs_vfs_follow_link,
  1138. .put_link = v9fs_vfs_put_link,
  1139. .getattr = v9fs_vfs_getattr,
  1140. .setattr = v9fs_vfs_setattr,
  1141. };