vfs_inode.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  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 as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to:
  21. * Free Software Foundation
  22. * 51 Franklin Street, Fifth Floor
  23. * Boston, MA 02111-1301 USA
  24. *
  25. */
  26. #include <linux/module.h>
  27. #include <linux/errno.h>
  28. #include <linux/fs.h>
  29. #include <linux/file.h>
  30. #include <linux/pagemap.h>
  31. #include <linux/stat.h>
  32. #include <linux/string.h>
  33. #include <linux/smp_lock.h>
  34. #include <linux/inet.h>
  35. #include <linux/namei.h>
  36. #include <linux/idr.h>
  37. #include "debug.h"
  38. #include "v9fs.h"
  39. #include "9p.h"
  40. #include "v9fs_vfs.h"
  41. #include "conv.h"
  42. #include "fid.h"
  43. static struct inode_operations v9fs_dir_inode_operations;
  44. static struct inode_operations v9fs_dir_inode_operations_ext;
  45. static struct inode_operations v9fs_file_inode_operations;
  46. static struct inode_operations v9fs_symlink_inode_operations;
  47. /**
  48. * unixmode2p9mode - convert unix mode bits to plan 9
  49. * @v9ses: v9fs session information
  50. * @mode: mode to convert
  51. *
  52. */
  53. static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
  54. {
  55. int res;
  56. res = mode & 0777;
  57. if (S_ISDIR(mode))
  58. res |= V9FS_DMDIR;
  59. if (v9ses->extended) {
  60. if (S_ISLNK(mode))
  61. res |= V9FS_DMSYMLINK;
  62. if (v9ses->nodev == 0) {
  63. if (S_ISSOCK(mode))
  64. res |= V9FS_DMSOCKET;
  65. if (S_ISFIFO(mode))
  66. res |= V9FS_DMNAMEDPIPE;
  67. if (S_ISBLK(mode))
  68. res |= V9FS_DMDEVICE;
  69. if (S_ISCHR(mode))
  70. res |= V9FS_DMDEVICE;
  71. }
  72. if ((mode & S_ISUID) == S_ISUID)
  73. res |= V9FS_DMSETUID;
  74. if ((mode & S_ISGID) == S_ISGID)
  75. res |= V9FS_DMSETGID;
  76. if ((mode & V9FS_DMLINK))
  77. res |= V9FS_DMLINK;
  78. }
  79. return res;
  80. }
  81. /**
  82. * p9mode2unixmode- convert plan9 mode bits to unix mode bits
  83. * @v9ses: v9fs session information
  84. * @mode: mode to convert
  85. *
  86. */
  87. static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
  88. {
  89. int res;
  90. res = mode & 0777;
  91. if ((mode & V9FS_DMDIR) == V9FS_DMDIR)
  92. res |= S_IFDIR;
  93. else if ((mode & V9FS_DMSYMLINK) && (v9ses->extended))
  94. res |= S_IFLNK;
  95. else if ((mode & V9FS_DMSOCKET) && (v9ses->extended)
  96. && (v9ses->nodev == 0))
  97. res |= S_IFSOCK;
  98. else if ((mode & V9FS_DMNAMEDPIPE) && (v9ses->extended)
  99. && (v9ses->nodev == 0))
  100. res |= S_IFIFO;
  101. else if ((mode & V9FS_DMDEVICE) && (v9ses->extended)
  102. && (v9ses->nodev == 0))
  103. res |= S_IFBLK;
  104. else
  105. res |= S_IFREG;
  106. if (v9ses->extended) {
  107. if ((mode & V9FS_DMSETUID) == V9FS_DMSETUID)
  108. res |= S_ISUID;
  109. if ((mode & V9FS_DMSETGID) == V9FS_DMSETGID)
  110. res |= S_ISGID;
  111. }
  112. return res;
  113. }
  114. /**
  115. * v9fs_blank_mistat - helper function to setup a 9P stat structure
  116. * @v9ses: 9P session info (for determining extended mode)
  117. * @mistat: structure to initialize
  118. *
  119. */
  120. static void
  121. v9fs_blank_mistat(struct v9fs_session_info *v9ses, struct v9fs_stat *mistat)
  122. {
  123. mistat->type = ~0;
  124. mistat->dev = ~0;
  125. mistat->qid.type = ~0;
  126. mistat->qid.version = ~0;
  127. *((long long *)&mistat->qid.path) = ~0;
  128. mistat->mode = ~0;
  129. mistat->atime = ~0;
  130. mistat->mtime = ~0;
  131. mistat->length = ~0;
  132. mistat->name = mistat->data;
  133. mistat->uid = mistat->data;
  134. mistat->gid = mistat->data;
  135. mistat->muid = mistat->data;
  136. if (v9ses->extended) {
  137. mistat->n_uid = ~0;
  138. mistat->n_gid = ~0;
  139. mistat->n_muid = ~0;
  140. mistat->extension = mistat->data;
  141. }
  142. *mistat->data = 0;
  143. }
  144. /**
  145. * v9fs_mistat2unix - convert mistat to unix stat
  146. * @mistat: Plan 9 metadata (mistat) structure
  147. * @buf: unix metadata (stat) structure to populate
  148. * @sb: superblock
  149. *
  150. */
  151. static void
  152. v9fs_mistat2unix(struct v9fs_stat *mistat, struct stat *buf,
  153. struct super_block *sb)
  154. {
  155. struct v9fs_session_info *v9ses = sb ? sb->s_fs_info : NULL;
  156. buf->st_nlink = 1;
  157. buf->st_atime = mistat->atime;
  158. buf->st_mtime = mistat->mtime;
  159. buf->st_ctime = mistat->mtime;
  160. buf->st_uid = (unsigned short)-1;
  161. buf->st_gid = (unsigned short)-1;
  162. if (v9ses && v9ses->extended) {
  163. /* TODO: string to uid mapping via user-space daemon */
  164. if (mistat->n_uid != -1)
  165. sscanf(mistat->uid, "%x", (unsigned int *)&buf->st_uid);
  166. if (mistat->n_gid != -1)
  167. sscanf(mistat->gid, "%x", (unsigned int *)&buf->st_gid);
  168. }
  169. if (buf->st_uid == (unsigned short)-1)
  170. buf->st_uid = v9ses->uid;
  171. if (buf->st_gid == (unsigned short)-1)
  172. buf->st_gid = v9ses->gid;
  173. buf->st_mode = p9mode2unixmode(v9ses, mistat->mode);
  174. if ((S_ISBLK(buf->st_mode)) || (S_ISCHR(buf->st_mode))) {
  175. char type = 0;
  176. int major = -1;
  177. int minor = -1;
  178. sscanf(mistat->extension, "%c %u %u", &type, &major, &minor);
  179. switch (type) {
  180. case 'c':
  181. buf->st_mode &= ~S_IFBLK;
  182. buf->st_mode |= S_IFCHR;
  183. break;
  184. case 'b':
  185. break;
  186. default:
  187. dprintk(DEBUG_ERROR, "Unknown special type %c (%s)\n",
  188. type, mistat->extension);
  189. };
  190. buf->st_rdev = MKDEV(major, minor);
  191. } else
  192. buf->st_rdev = 0;
  193. buf->st_size = mistat->length;
  194. buf->st_blksize = sb->s_blocksize;
  195. buf->st_blocks =
  196. (buf->st_size + buf->st_blksize - 1) >> sb->s_blocksize_bits;
  197. }
  198. /**
  199. * v9fs_get_inode - helper function to setup an inode
  200. * @sb: superblock
  201. * @mode: mode to setup inode with
  202. *
  203. */
  204. struct inode *v9fs_get_inode(struct super_block *sb, int mode)
  205. {
  206. struct inode *inode = NULL;
  207. struct v9fs_session_info *v9ses = sb->s_fs_info;
  208. dprintk(DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
  209. inode = new_inode(sb);
  210. if (inode) {
  211. inode->i_mode = mode;
  212. inode->i_uid = current->fsuid;
  213. inode->i_gid = current->fsgid;
  214. inode->i_blksize = sb->s_blocksize;
  215. inode->i_blocks = 0;
  216. inode->i_rdev = 0;
  217. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  218. switch (mode & S_IFMT) {
  219. case S_IFIFO:
  220. case S_IFBLK:
  221. case S_IFCHR:
  222. case S_IFSOCK:
  223. if(!v9ses->extended) {
  224. dprintk(DEBUG_ERROR, "special files without extended mode\n");
  225. return ERR_PTR(-EINVAL);
  226. }
  227. init_special_inode(inode, inode->i_mode,
  228. inode->i_rdev);
  229. break;
  230. case S_IFREG:
  231. inode->i_op = &v9fs_file_inode_operations;
  232. inode->i_fop = &v9fs_file_operations;
  233. break;
  234. case S_IFLNK:
  235. if(!v9ses->extended) {
  236. dprintk(DEBUG_ERROR, "extended modes used w/o 9P2000.u\n");
  237. return ERR_PTR(-EINVAL);
  238. }
  239. inode->i_op = &v9fs_symlink_inode_operations;
  240. break;
  241. case S_IFDIR:
  242. inode->i_nlink++;
  243. if(v9ses->extended)
  244. inode->i_op = &v9fs_dir_inode_operations_ext;
  245. else
  246. inode->i_op = &v9fs_dir_inode_operations;
  247. inode->i_fop = &v9fs_dir_operations;
  248. break;
  249. default:
  250. dprintk(DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
  251. mode, mode & S_IFMT);
  252. return ERR_PTR(-EINVAL);
  253. }
  254. } else {
  255. eprintk(KERN_WARNING, "Problem allocating inode\n");
  256. return ERR_PTR(-ENOMEM);
  257. }
  258. return inode;
  259. }
  260. /**
  261. * v9fs_create - helper function to create files and directories
  262. * @dir: directory inode file is being created in
  263. * @file_dentry: dentry file is being created in
  264. * @perm: permissions file is being created with
  265. * @open_mode: resulting open mode for file
  266. *
  267. */
  268. static int
  269. v9fs_create(struct inode *dir,
  270. struct dentry *file_dentry,
  271. unsigned int perm, unsigned int open_mode)
  272. {
  273. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
  274. struct super_block *sb = dir->i_sb;
  275. struct v9fs_fid *dirfid =
  276. v9fs_fid_lookup(file_dentry->d_parent, FID_WALK);
  277. struct v9fs_fid *fid = NULL;
  278. struct inode *file_inode = NULL;
  279. struct v9fs_fcall *fcall = NULL;
  280. struct v9fs_qid qid;
  281. struct stat newstat;
  282. int dirfidnum = -1;
  283. long newfid = -1;
  284. int result = 0;
  285. unsigned int iounit = 0;
  286. perm = unixmode2p9mode(v9ses, perm);
  287. dprintk(DEBUG_VFS, "dir: %p dentry: %p perm: %o mode: %o\n", dir,
  288. file_dentry, perm, open_mode);
  289. if (!dirfid)
  290. return -EBADF;
  291. dirfidnum = dirfid->fid;
  292. if (dirfidnum < 0) {
  293. dprintk(DEBUG_ERROR, "No fid for the directory #%lu\n",
  294. dir->i_ino);
  295. return -EBADF;
  296. }
  297. if (file_dentry->d_inode) {
  298. dprintk(DEBUG_ERROR,
  299. "Odd. There is an inode for dir %lu, name :%s:\n",
  300. dir->i_ino, file_dentry->d_name.name);
  301. return -EEXIST;
  302. }
  303. newfid = v9fs_get_idpool(&v9ses->fidpool);
  304. if (newfid < 0) {
  305. eprintk(KERN_WARNING, "no free fids available\n");
  306. return -ENOSPC;
  307. }
  308. result = v9fs_t_walk(v9ses, dirfidnum, newfid, NULL, &fcall);
  309. if (result < 0) {
  310. dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall));
  311. v9fs_put_idpool(newfid, &v9ses->fidpool);
  312. newfid = 0;
  313. goto CleanUpFid;
  314. }
  315. kfree(fcall);
  316. result = v9fs_t_create(v9ses, newfid, (char *)file_dentry->d_name.name,
  317. perm, open_mode, &fcall);
  318. if (result < 0) {
  319. dprintk(DEBUG_ERROR, "create fails: %s(%d)\n",
  320. FCALL_ERROR(fcall), result);
  321. goto CleanUpFid;
  322. }
  323. iounit = fcall->params.rcreate.iounit;
  324. qid = fcall->params.rcreate.qid;
  325. kfree(fcall);
  326. fid = v9fs_fid_create(file_dentry);
  327. if (!fid) {
  328. result = -ENOMEM;
  329. goto CleanUpFid;
  330. }
  331. fid->fid = newfid;
  332. fid->fidopen = 0;
  333. fid->fidcreate = 1;
  334. fid->qid = qid;
  335. fid->iounit = iounit;
  336. fid->rdir_pos = 0;
  337. fid->rdir_fcall = NULL;
  338. fid->v9ses = v9ses;
  339. if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) ||
  340. (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) ||
  341. (perm & V9FS_DMDEVICE))
  342. return 0;
  343. result = v9fs_t_stat(v9ses, newfid, &fcall);
  344. if (result < 0) {
  345. dprintk(DEBUG_ERROR, "stat error: %s(%d)\n", FCALL_ERROR(fcall),
  346. result);
  347. goto CleanUpFid;
  348. }
  349. v9fs_mistat2unix(fcall->params.rstat.stat, &newstat, sb);
  350. file_inode = v9fs_get_inode(sb, newstat.st_mode);
  351. if ((!file_inode) || IS_ERR(file_inode)) {
  352. dprintk(DEBUG_ERROR, "create inode failed\n");
  353. result = -EBADF;
  354. goto CleanUpFid;
  355. }
  356. v9fs_mistat2inode(fcall->params.rstat.stat, file_inode, sb);
  357. kfree(fcall);
  358. d_instantiate(file_dentry, file_inode);
  359. if (perm & V9FS_DMDIR) {
  360. if (v9fs_t_clunk(v9ses, newfid, &fcall))
  361. dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n",
  362. FCALL_ERROR(fcall));
  363. v9fs_put_idpool(newfid, &v9ses->fidpool);
  364. kfree(fcall);
  365. fid->fidopen = 0;
  366. fid->fidcreate = 0;
  367. d_drop(file_dentry);
  368. }
  369. return 0;
  370. CleanUpFid:
  371. kfree(fcall);
  372. if (newfid) {
  373. if (v9fs_t_clunk(v9ses, newfid, &fcall))
  374. dprintk(DEBUG_ERROR, "clunk failed: %s\n",
  375. FCALL_ERROR(fcall));
  376. v9fs_put_idpool(newfid, &v9ses->fidpool);
  377. kfree(fcall);
  378. }
  379. return result;
  380. }
  381. /**
  382. * v9fs_remove - helper function to remove files and directories
  383. * @dir: directory inode that is being deleted
  384. * @file: dentry that is being deleted
  385. * @rmdir: removing a directory
  386. *
  387. */
  388. static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
  389. {
  390. struct v9fs_fcall *fcall = NULL;
  391. struct super_block *sb = NULL;
  392. struct v9fs_session_info *v9ses = NULL;
  393. struct v9fs_fid *v9fid = NULL;
  394. struct inode *file_inode = NULL;
  395. int fid = -1;
  396. int result = 0;
  397. dprintk(DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file,
  398. rmdir);
  399. file_inode = file->d_inode;
  400. sb = file_inode->i_sb;
  401. v9ses = v9fs_inode2v9ses(file_inode);
  402. v9fid = v9fs_fid_lookup(file, FID_OP);
  403. if (!v9fid) {
  404. dprintk(DEBUG_ERROR,
  405. "no v9fs_fid\n");
  406. return -EBADF;
  407. }
  408. fid = v9fid->fid;
  409. if (fid < 0) {
  410. dprintk(DEBUG_ERROR, "inode #%lu, no fid!\n",
  411. file_inode->i_ino);
  412. return -EBADF;
  413. }
  414. result = v9fs_t_remove(v9ses, fid, &fcall);
  415. if (result < 0)
  416. dprintk(DEBUG_ERROR, "remove of file fails: %s(%d)\n",
  417. FCALL_ERROR(fcall), result);
  418. else {
  419. v9fs_put_idpool(fid, &v9ses->fidpool);
  420. v9fs_fid_destroy(v9fid);
  421. }
  422. kfree(fcall);
  423. return result;
  424. }
  425. /**
  426. * v9fs_vfs_create - VFS hook to create files
  427. * @inode: directory inode that is being deleted
  428. * @dentry: dentry that is being deleted
  429. * @perm: create permissions
  430. * @nd: path information
  431. *
  432. */
  433. static int
  434. v9fs_vfs_create(struct inode *inode, struct dentry *dentry, int perm,
  435. struct nameidata *nd)
  436. {
  437. return v9fs_create(inode, dentry, perm, O_RDWR);
  438. }
  439. /**
  440. * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
  441. * @inode: inode that is being unlinked
  442. * @dentry: dentry that is being unlinked
  443. * @mode: mode for new directory
  444. *
  445. */
  446. static int v9fs_vfs_mkdir(struct inode *inode, struct dentry *dentry, int mode)
  447. {
  448. return v9fs_create(inode, dentry, mode | S_IFDIR, O_RDONLY);
  449. }
  450. /**
  451. * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
  452. * @dir: inode that is being walked from
  453. * @dentry: dentry that is being walked to?
  454. * @nameidata: path data
  455. *
  456. */
  457. static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
  458. struct nameidata *nameidata)
  459. {
  460. struct super_block *sb;
  461. struct v9fs_session_info *v9ses;
  462. struct v9fs_fid *dirfid;
  463. struct v9fs_fid *fid;
  464. struct inode *inode;
  465. struct v9fs_fcall *fcall = NULL;
  466. struct stat newstat;
  467. int dirfidnum = -1;
  468. int newfid = -1;
  469. int result = 0;
  470. dprintk(DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n",
  471. dir, dentry->d_iname, dentry, nameidata);
  472. sb = dir->i_sb;
  473. v9ses = v9fs_inode2v9ses(dir);
  474. dirfid = v9fs_fid_lookup(dentry->d_parent, FID_WALK);
  475. if (!dirfid) {
  476. dprintk(DEBUG_ERROR, "no dirfid\n");
  477. return ERR_PTR(-EINVAL);
  478. }
  479. dirfidnum = dirfid->fid;
  480. if (dirfidnum < 0) {
  481. dprintk(DEBUG_ERROR, "no dirfid for inode %p, #%lu\n",
  482. dir, dir->i_ino);
  483. return ERR_PTR(-EBADF);
  484. }
  485. newfid = v9fs_get_idpool(&v9ses->fidpool);
  486. if (newfid < 0) {
  487. eprintk(KERN_WARNING, "newfid fails!\n");
  488. return ERR_PTR(-ENOSPC);
  489. }
  490. result =
  491. v9fs_t_walk(v9ses, dirfidnum, newfid, (char *)dentry->d_name.name,
  492. NULL);
  493. if (result < 0) {
  494. v9fs_put_idpool(newfid, &v9ses->fidpool);
  495. if (result == -ENOENT) {
  496. d_add(dentry, NULL);
  497. dprintk(DEBUG_ERROR,
  498. "Return negative dentry %p count %d\n",
  499. dentry, atomic_read(&dentry->d_count));
  500. return NULL;
  501. }
  502. dprintk(DEBUG_ERROR, "walk error:%d\n", result);
  503. goto FreeFcall;
  504. }
  505. result = v9fs_t_stat(v9ses, newfid, &fcall);
  506. if (result < 0) {
  507. dprintk(DEBUG_ERROR, "stat error\n");
  508. goto FreeFcall;
  509. }
  510. v9fs_mistat2unix(fcall->params.rstat.stat, &newstat, sb);
  511. inode = v9fs_get_inode(sb, newstat.st_mode);
  512. if (IS_ERR(inode) && (PTR_ERR(inode) == -ENOSPC)) {
  513. eprintk(KERN_WARNING, "inode alloc failes, returns %ld\n",
  514. PTR_ERR(inode));
  515. result = -ENOSPC;
  516. goto FreeFcall;
  517. }
  518. inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid);
  519. fid = v9fs_fid_create(dentry);
  520. if (fid == NULL) {
  521. dprintk(DEBUG_ERROR, "couldn't insert\n");
  522. result = -ENOMEM;
  523. goto FreeFcall;
  524. }
  525. fid->fid = newfid;
  526. fid->fidopen = 0;
  527. fid->v9ses = v9ses;
  528. fid->qid = fcall->params.rstat.stat->qid;
  529. dentry->d_op = &v9fs_dentry_operations;
  530. v9fs_mistat2inode(fcall->params.rstat.stat, inode, inode->i_sb);
  531. d_add(dentry, inode);
  532. kfree(fcall);
  533. return NULL;
  534. FreeFcall:
  535. kfree(fcall);
  536. return ERR_PTR(result);
  537. }
  538. /**
  539. * v9fs_vfs_unlink - VFS unlink hook to delete an inode
  540. * @i: inode that is being unlinked
  541. * @d: dentry that is being unlinked
  542. *
  543. */
  544. static int v9fs_vfs_unlink(struct inode *i, struct dentry *d)
  545. {
  546. return v9fs_remove(i, d, 0);
  547. }
  548. /**
  549. * v9fs_vfs_rmdir - VFS unlink hook to delete a directory
  550. * @i: inode that is being unlinked
  551. * @d: dentry that is being unlinked
  552. *
  553. */
  554. static int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
  555. {
  556. return v9fs_remove(i, d, 1);
  557. }
  558. /**
  559. * v9fs_vfs_rename - VFS hook to rename an inode
  560. * @old_dir: old dir inode
  561. * @old_dentry: old dentry
  562. * @new_dir: new dir inode
  563. * @new_dentry: new dentry
  564. *
  565. */
  566. static int
  567. v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  568. struct inode *new_dir, struct dentry *new_dentry)
  569. {
  570. struct inode *old_inode = old_dentry->d_inode;
  571. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode);
  572. struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_WALK);
  573. struct v9fs_fid *olddirfid =
  574. v9fs_fid_lookup(old_dentry->d_parent, FID_WALK);
  575. struct v9fs_fid *newdirfid =
  576. v9fs_fid_lookup(new_dentry->d_parent, FID_WALK);
  577. struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
  578. struct v9fs_fcall *fcall = NULL;
  579. int fid = -1;
  580. int olddirfidnum = -1;
  581. int newdirfidnum = -1;
  582. int retval = 0;
  583. dprintk(DEBUG_VFS, "\n");
  584. if (!mistat)
  585. return -ENOMEM;
  586. if ((!oldfid) || (!olddirfid) || (!newdirfid)) {
  587. dprintk(DEBUG_ERROR, "problem with arguments\n");
  588. return -EBADF;
  589. }
  590. /* 9P can only handle file rename in the same directory */
  591. if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) {
  592. dprintk(DEBUG_ERROR, "old dir and new dir are different\n");
  593. retval = -EPERM;
  594. goto FreeFcallnBail;
  595. }
  596. fid = oldfid->fid;
  597. olddirfidnum = olddirfid->fid;
  598. newdirfidnum = newdirfid->fid;
  599. if (fid < 0) {
  600. dprintk(DEBUG_ERROR, "no fid for old file #%lu\n",
  601. old_inode->i_ino);
  602. retval = -EBADF;
  603. goto FreeFcallnBail;
  604. }
  605. v9fs_blank_mistat(v9ses, mistat);
  606. strcpy(mistat->data + 1, v9ses->name);
  607. mistat->name = mistat->data + 1 + strlen(v9ses->name);
  608. if (new_dentry->d_name.len >
  609. (v9ses->maxdata - strlen(v9ses->name) - sizeof(struct v9fs_stat))) {
  610. dprintk(DEBUG_ERROR, "new name too long\n");
  611. goto FreeFcallnBail;
  612. }
  613. strcpy(mistat->name, new_dentry->d_name.name);
  614. retval = v9fs_t_wstat(v9ses, fid, mistat, &fcall);
  615. FreeFcallnBail:
  616. kfree(mistat);
  617. if (retval < 0)
  618. dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n",
  619. FCALL_ERROR(fcall));
  620. kfree(fcall);
  621. return retval;
  622. }
  623. /**
  624. * v9fs_vfs_getattr - retreive file metadata
  625. * @mnt - mount information
  626. * @dentry - file to get attributes on
  627. * @stat - metadata structure to populate
  628. *
  629. */
  630. static int
  631. v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
  632. struct kstat *stat)
  633. {
  634. struct v9fs_fcall *fcall = NULL;
  635. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode);
  636. struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP);
  637. int err = -EPERM;
  638. dprintk(DEBUG_VFS, "dentry: %p\n", dentry);
  639. if (!fid) {
  640. dprintk(DEBUG_ERROR,
  641. "couldn't find fid associated with dentry\n");
  642. return -EBADF;
  643. }
  644. err = v9fs_t_stat(v9ses, fid->fid, &fcall);
  645. if (err < 0)
  646. dprintk(DEBUG_ERROR, "stat error\n");
  647. else {
  648. v9fs_mistat2inode(fcall->params.rstat.stat, dentry->d_inode,
  649. dentry->d_inode->i_sb);
  650. generic_fillattr(dentry->d_inode, stat);
  651. }
  652. kfree(fcall);
  653. return err;
  654. }
  655. /**
  656. * v9fs_vfs_setattr - set file metadata
  657. * @dentry: file whose metadata to set
  658. * @iattr: metadata assignment structure
  659. *
  660. */
  661. static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
  662. {
  663. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode);
  664. struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP);
  665. struct v9fs_fcall *fcall = NULL;
  666. struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
  667. int res = -EPERM;
  668. dprintk(DEBUG_VFS, "\n");
  669. if (!mistat)
  670. return -ENOMEM;
  671. if (!fid) {
  672. dprintk(DEBUG_ERROR,
  673. "Couldn't find fid associated with dentry\n");
  674. return -EBADF;
  675. }
  676. v9fs_blank_mistat(v9ses, mistat);
  677. if (iattr->ia_valid & ATTR_MODE)
  678. mistat->mode = unixmode2p9mode(v9ses, iattr->ia_mode);
  679. if (iattr->ia_valid & ATTR_MTIME)
  680. mistat->mtime = iattr->ia_mtime.tv_sec;
  681. if (iattr->ia_valid & ATTR_ATIME)
  682. mistat->atime = iattr->ia_atime.tv_sec;
  683. if (iattr->ia_valid & ATTR_SIZE)
  684. mistat->length = iattr->ia_size;
  685. if (v9ses->extended) {
  686. char *ptr = mistat->data+1;
  687. if (iattr->ia_valid & ATTR_UID) {
  688. mistat->uid = ptr;
  689. ptr += 1+sprintf(ptr, "%08x", iattr->ia_uid);
  690. mistat->n_uid = iattr->ia_uid;
  691. }
  692. if (iattr->ia_valid & ATTR_GID) {
  693. mistat->gid = ptr;
  694. ptr += 1+sprintf(ptr, "%08x", iattr->ia_gid);
  695. mistat->n_gid = iattr->ia_gid;
  696. }
  697. }
  698. res = v9fs_t_wstat(v9ses, fid->fid, mistat, &fcall);
  699. if (res < 0)
  700. dprintk(DEBUG_ERROR, "wstat error: %s\n", FCALL_ERROR(fcall));
  701. kfree(mistat);
  702. kfree(fcall);
  703. if (res >= 0)
  704. res = inode_setattr(dentry->d_inode, iattr);
  705. return res;
  706. }
  707. /**
  708. * v9fs_mistat2inode - populate an inode structure with mistat info
  709. * @mistat: Plan 9 metadata (mistat) structure
  710. * @inode: inode to populate
  711. * @sb: superblock of filesystem
  712. *
  713. */
  714. void
  715. v9fs_mistat2inode(struct v9fs_stat *mistat, struct inode *inode,
  716. struct super_block *sb)
  717. {
  718. struct v9fs_session_info *v9ses = sb->s_fs_info;
  719. inode->i_nlink = 1;
  720. inode->i_atime.tv_sec = mistat->atime;
  721. inode->i_mtime.tv_sec = mistat->mtime;
  722. inode->i_ctime.tv_sec = mistat->mtime;
  723. inode->i_uid = -1;
  724. inode->i_gid = -1;
  725. if (v9ses->extended) {
  726. /* TODO: string to uid mapping via user-space daemon */
  727. inode->i_uid = mistat->n_uid;
  728. inode->i_gid = mistat->n_gid;
  729. if (mistat->n_uid == -1)
  730. sscanf(mistat->uid, "%x", &inode->i_uid);
  731. if (mistat->n_gid == -1)
  732. sscanf(mistat->gid, "%x", &inode->i_gid);
  733. }
  734. if (inode->i_uid == -1)
  735. inode->i_uid = v9ses->uid;
  736. if (inode->i_gid == -1)
  737. inode->i_gid = v9ses->gid;
  738. inode->i_mode = p9mode2unixmode(v9ses, mistat->mode);
  739. if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
  740. char type = 0;
  741. int major = -1;
  742. int minor = -1;
  743. sscanf(mistat->extension, "%c %u %u", &type, &major, &minor);
  744. switch (type) {
  745. case 'c':
  746. inode->i_mode &= ~S_IFBLK;
  747. inode->i_mode |= S_IFCHR;
  748. break;
  749. case 'b':
  750. break;
  751. default:
  752. dprintk(DEBUG_ERROR, "Unknown special type %c (%s)\n",
  753. type, mistat->extension);
  754. };
  755. inode->i_rdev = MKDEV(major, minor);
  756. } else
  757. inode->i_rdev = 0;
  758. inode->i_size = mistat->length;
  759. inode->i_blksize = sb->s_blocksize;
  760. inode->i_blocks =
  761. (inode->i_size + inode->i_blksize - 1) >> sb->s_blocksize_bits;
  762. }
  763. /**
  764. * v9fs_qid2ino - convert qid into inode number
  765. * @qid: qid to hash
  766. *
  767. * BUG: potential for inode number collisions?
  768. */
  769. ino_t v9fs_qid2ino(struct v9fs_qid *qid)
  770. {
  771. u64 path = qid->path + 2;
  772. ino_t i = 0;
  773. if (sizeof(ino_t) == sizeof(path))
  774. memcpy(&i, &path, sizeof(ino_t));
  775. else
  776. i = (ino_t) (path ^ (path >> 32));
  777. return i;
  778. }
  779. /**
  780. * v9fs_vfs_symlink - helper function to create symlinks
  781. * @dir: directory inode containing symlink
  782. * @dentry: dentry for symlink
  783. * @symname: symlink data
  784. *
  785. * See 9P2000.u RFC for more information
  786. *
  787. */
  788. static int
  789. v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
  790. {
  791. int retval = -EPERM;
  792. struct v9fs_fid *newfid;
  793. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
  794. struct v9fs_fcall *fcall = NULL;
  795. struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
  796. dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name,
  797. symname);
  798. if (!mistat)
  799. return -ENOMEM;
  800. if (!v9ses->extended) {
  801. dprintk(DEBUG_ERROR, "not extended\n");
  802. goto FreeFcall;
  803. }
  804. /* issue a create */
  805. retval = v9fs_create(dir, dentry, S_IFLNK, 0);
  806. if (retval != 0)
  807. goto FreeFcall;
  808. newfid = v9fs_fid_lookup(dentry, FID_OP);
  809. /* issue a twstat */
  810. v9fs_blank_mistat(v9ses, mistat);
  811. strcpy(mistat->data + 1, symname);
  812. mistat->extension = mistat->data + 1;
  813. retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall);
  814. if (retval < 0) {
  815. dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n",
  816. FCALL_ERROR(fcall));
  817. goto FreeFcall;
  818. }
  819. kfree(fcall);
  820. if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) {
  821. dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n",
  822. FCALL_ERROR(fcall));
  823. goto FreeFcall;
  824. }
  825. d_drop(dentry); /* FID - will this also clunk? */
  826. FreeFcall:
  827. kfree(mistat);
  828. kfree(fcall);
  829. return retval;
  830. }
  831. /**
  832. * v9fs_readlink - read a symlink's location (internal version)
  833. * @dentry: dentry for symlink
  834. * @buffer: buffer to load symlink location into
  835. * @buflen: length of buffer
  836. *
  837. */
  838. static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
  839. {
  840. int retval = -EPERM;
  841. struct v9fs_fcall *fcall = NULL;
  842. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode);
  843. struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP);
  844. if (!fid) {
  845. dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n");
  846. retval = -EBADF;
  847. goto FreeFcall;
  848. }
  849. if (!v9ses->extended) {
  850. retval = -EBADF;
  851. dprintk(DEBUG_ERROR, "not extended\n");
  852. goto FreeFcall;
  853. }
  854. dprintk(DEBUG_VFS, " %s\n", dentry->d_name.name);
  855. retval = v9fs_t_stat(v9ses, fid->fid, &fcall);
  856. if (retval < 0) {
  857. dprintk(DEBUG_ERROR, "stat error\n");
  858. goto FreeFcall;
  859. }
  860. if (!fcall)
  861. return -EIO;
  862. if (!(fcall->params.rstat.stat->mode & V9FS_DMSYMLINK)) {
  863. retval = -EINVAL;
  864. goto FreeFcall;
  865. }
  866. /* copy extension buffer into buffer */
  867. if (strlen(fcall->params.rstat.stat->extension) < buflen)
  868. buflen = strlen(fcall->params.rstat.stat->extension);
  869. memcpy(buffer, fcall->params.rstat.stat->extension, buflen + 1);
  870. retval = buflen;
  871. FreeFcall:
  872. kfree(fcall);
  873. return retval;
  874. }
  875. /**
  876. * v9fs_vfs_readlink - read a symlink's location
  877. * @dentry: dentry for symlink
  878. * @buf: buffer to load symlink location into
  879. * @buflen: length of buffer
  880. *
  881. */
  882. static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer,
  883. int buflen)
  884. {
  885. int retval;
  886. int ret;
  887. char *link = __getname();
  888. if (strlen(link) < buflen)
  889. buflen = strlen(link);
  890. dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry);
  891. retval = v9fs_readlink(dentry, link, buflen);
  892. if (retval > 0) {
  893. if ((ret = copy_to_user(buffer, link, retval)) != 0) {
  894. dprintk(DEBUG_ERROR, "problem copying to user: %d\n",
  895. ret);
  896. retval = ret;
  897. }
  898. }
  899. putname(link);
  900. return retval;
  901. }
  902. /**
  903. * v9fs_vfs_follow_link - follow a symlink path
  904. * @dentry: dentry for symlink
  905. * @nd: nameidata
  906. *
  907. */
  908. static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
  909. {
  910. int len = 0;
  911. char *link = __getname();
  912. dprintk(DEBUG_VFS, "%s n", dentry->d_name.name);
  913. if (!link)
  914. link = ERR_PTR(-ENOMEM);
  915. else {
  916. len = v9fs_readlink(dentry, link, strlen(link));
  917. if (len < 0) {
  918. putname(link);
  919. link = ERR_PTR(len);
  920. } else
  921. link[len] = 0;
  922. }
  923. nd_set_link(nd, link);
  924. return NULL;
  925. }
  926. /**
  927. * v9fs_vfs_put_link - release a symlink path
  928. * @dentry: dentry for symlink
  929. * @nd: nameidata
  930. *
  931. */
  932. static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
  933. {
  934. char *s = nd_get_link(nd);
  935. dprintk(DEBUG_VFS, " %s %s\n", dentry->d_name.name, s);
  936. if (!IS_ERR(s))
  937. putname(s);
  938. }
  939. /**
  940. * v9fs_vfs_link - create a hardlink
  941. * @old_dentry: dentry for file to link to
  942. * @dir: inode destination for new link
  943. * @dentry: dentry for link
  944. *
  945. */
  946. /* XXX - lots of code dup'd from symlink and creates,
  947. * figure out a better reuse strategy
  948. */
  949. static int
  950. v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
  951. struct dentry *dentry)
  952. {
  953. int retval = -EPERM;
  954. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
  955. struct v9fs_fcall *fcall = NULL;
  956. struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
  957. struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_OP);
  958. struct v9fs_fid *newfid = NULL;
  959. char *symname = __getname();
  960. dprintk(DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name,
  961. old_dentry->d_name.name);
  962. if (!v9ses->extended) {
  963. dprintk(DEBUG_ERROR, "not extended\n");
  964. goto FreeMem;
  965. }
  966. /* get fid of old_dentry */
  967. sprintf(symname, "hardlink(%d)\n", oldfid->fid);
  968. /* issue a create */
  969. retval = v9fs_create(dir, dentry, V9FS_DMLINK, 0);
  970. if (retval != 0)
  971. goto FreeMem;
  972. newfid = v9fs_fid_lookup(dentry, FID_OP);
  973. if (!newfid) {
  974. dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n");
  975. goto FreeMem;
  976. }
  977. /* issue a twstat */
  978. v9fs_blank_mistat(v9ses, mistat);
  979. strcpy(mistat->data + 1, symname);
  980. mistat->extension = mistat->data + 1;
  981. retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall);
  982. if (retval < 0) {
  983. dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n",
  984. FCALL_ERROR(fcall));
  985. goto FreeMem;
  986. }
  987. kfree(fcall);
  988. if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) {
  989. dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n",
  990. FCALL_ERROR(fcall));
  991. goto FreeMem;
  992. }
  993. d_drop(dentry); /* FID - will this also clunk? */
  994. kfree(fcall);
  995. fcall = NULL;
  996. FreeMem:
  997. kfree(mistat);
  998. kfree(fcall);
  999. putname(symname);
  1000. return retval;
  1001. }
  1002. /**
  1003. * v9fs_vfs_mknod - create a special file
  1004. * @dir: inode destination for new link
  1005. * @dentry: dentry for file
  1006. * @mode: mode for creation
  1007. * @dev_t: device associated with special file
  1008. *
  1009. */
  1010. static int
  1011. v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
  1012. {
  1013. int retval = -EPERM;
  1014. struct v9fs_fid *newfid;
  1015. struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
  1016. struct v9fs_fcall *fcall = NULL;
  1017. struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
  1018. char *symname = __getname();
  1019. dprintk(DEBUG_VFS, " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
  1020. dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
  1021. if (!mistat)
  1022. return -ENOMEM;
  1023. if (!new_valid_dev(rdev)) {
  1024. retval = -EINVAL;
  1025. goto FreeMem;
  1026. }
  1027. if (!v9ses->extended) {
  1028. dprintk(DEBUG_ERROR, "not extended\n");
  1029. goto FreeMem;
  1030. }
  1031. /* issue a create */
  1032. retval = v9fs_create(dir, dentry, mode, 0);
  1033. if (retval != 0)
  1034. goto FreeMem;
  1035. newfid = v9fs_fid_lookup(dentry, FID_OP);
  1036. if (!newfid) {
  1037. dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n");
  1038. retval = -EINVAL;
  1039. goto FreeMem;
  1040. }
  1041. /* build extension */
  1042. if (S_ISBLK(mode))
  1043. sprintf(symname, "b %u %u", MAJOR(rdev), MINOR(rdev));
  1044. else if (S_ISCHR(mode))
  1045. sprintf(symname, "c %u %u", MAJOR(rdev), MINOR(rdev));
  1046. else if (S_ISFIFO(mode))
  1047. ; /* DO NOTHING */
  1048. else {
  1049. retval = -EINVAL;
  1050. goto FreeMem;
  1051. }
  1052. if (!S_ISFIFO(mode)) {
  1053. /* issue a twstat */
  1054. v9fs_blank_mistat(v9ses, mistat);
  1055. strcpy(mistat->data + 1, symname);
  1056. mistat->extension = mistat->data + 1;
  1057. retval = v9fs_t_wstat(v9ses, newfid->fid, mistat, &fcall);
  1058. if (retval < 0) {
  1059. dprintk(DEBUG_ERROR, "v9fs_t_wstat error: %s\n",
  1060. FCALL_ERROR(fcall));
  1061. goto FreeMem;
  1062. }
  1063. }
  1064. /* need to update dcache so we show up */
  1065. kfree(fcall);
  1066. if (v9fs_t_clunk(v9ses, newfid->fid, &fcall)) {
  1067. dprintk(DEBUG_ERROR, "clunk for symlink failed: %s\n",
  1068. FCALL_ERROR(fcall));
  1069. goto FreeMem;
  1070. }
  1071. d_drop(dentry); /* FID - will this also clunk? */
  1072. FreeMem:
  1073. kfree(mistat);
  1074. kfree(fcall);
  1075. putname(symname);
  1076. return retval;
  1077. }
  1078. static struct inode_operations v9fs_dir_inode_operations_ext = {
  1079. .create = v9fs_vfs_create,
  1080. .lookup = v9fs_vfs_lookup,
  1081. .symlink = v9fs_vfs_symlink,
  1082. .link = v9fs_vfs_link,
  1083. .unlink = v9fs_vfs_unlink,
  1084. .mkdir = v9fs_vfs_mkdir,
  1085. .rmdir = v9fs_vfs_rmdir,
  1086. .mknod = v9fs_vfs_mknod,
  1087. .rename = v9fs_vfs_rename,
  1088. .readlink = v9fs_vfs_readlink,
  1089. .getattr = v9fs_vfs_getattr,
  1090. .setattr = v9fs_vfs_setattr,
  1091. };
  1092. static struct inode_operations v9fs_dir_inode_operations = {
  1093. .create = v9fs_vfs_create,
  1094. .lookup = v9fs_vfs_lookup,
  1095. .unlink = v9fs_vfs_unlink,
  1096. .mkdir = v9fs_vfs_mkdir,
  1097. .rmdir = v9fs_vfs_rmdir,
  1098. .mknod = v9fs_vfs_mknod,
  1099. .rename = v9fs_vfs_rename,
  1100. .getattr = v9fs_vfs_getattr,
  1101. .setattr = v9fs_vfs_setattr,
  1102. };
  1103. static struct inode_operations v9fs_file_inode_operations = {
  1104. .getattr = v9fs_vfs_getattr,
  1105. .setattr = v9fs_vfs_setattr,
  1106. };
  1107. static struct inode_operations v9fs_symlink_inode_operations = {
  1108. .readlink = v9fs_vfs_readlink,
  1109. .follow_link = v9fs_vfs_follow_link,
  1110. .put_link = v9fs_vfs_put_link,
  1111. .getattr = v9fs_vfs_getattr,
  1112. .setattr = v9fs_vfs_setattr,
  1113. };