nfsproc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * nfsproc2.c Process version 2 NFS requests.
  3. * linux/fs/nfsd/nfs2proc.c
  4. *
  5. * Process version 2 NFS requests.
  6. *
  7. * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
  8. */
  9. #include <linux/linkage.h>
  10. #include <linux/time.h>
  11. #include <linux/errno.h>
  12. #include <linux/fs.h>
  13. #include <linux/stat.h>
  14. #include <linux/fcntl.h>
  15. #include <linux/net.h>
  16. #include <linux/in.h>
  17. #include <linux/namei.h>
  18. #include <linux/unistd.h>
  19. #include <linux/slab.h>
  20. #include <linux/sunrpc/clnt.h>
  21. #include <linux/sunrpc/svc.h>
  22. #include <linux/nfsd/nfsd.h>
  23. #include <linux/nfsd/cache.h>
  24. #include <linux/nfsd/xdr.h>
  25. typedef struct svc_rqst svc_rqst;
  26. typedef struct svc_buf svc_buf;
  27. #define NFSDDBG_FACILITY NFSDDBG_PROC
  28. static __be32
  29. nfsd_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
  30. {
  31. return nfs_ok;
  32. }
  33. static __be32
  34. nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp)
  35. {
  36. if (err) return err;
  37. return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
  38. resp->fh.fh_dentry,
  39. &resp->stat));
  40. }
  41. static __be32
  42. nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp)
  43. {
  44. if (err) return err;
  45. return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
  46. resp->fh.fh_dentry,
  47. &resp->stat));
  48. }
  49. /*
  50. * Get a file's attributes
  51. * N.B. After this call resp->fh needs an fh_put
  52. */
  53. static __be32
  54. nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
  55. struct nfsd_attrstat *resp)
  56. {
  57. __be32 nfserr;
  58. dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh));
  59. fh_copy(&resp->fh, &argp->fh);
  60. nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP);
  61. return nfsd_return_attrs(nfserr, resp);
  62. }
  63. /*
  64. * Set a file's attributes
  65. * N.B. After this call resp->fh needs an fh_put
  66. */
  67. static __be32
  68. nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
  69. struct nfsd_attrstat *resp)
  70. {
  71. __be32 nfserr;
  72. dprintk("nfsd: SETATTR %s, valid=%x, size=%ld\n",
  73. SVCFH_fmt(&argp->fh),
  74. argp->attrs.ia_valid, (long) argp->attrs.ia_size);
  75. fh_copy(&resp->fh, &argp->fh);
  76. nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,0, (time_t)0);
  77. return nfsd_return_attrs(nfserr, resp);
  78. }
  79. /*
  80. * Look up a path name component
  81. * Note: the dentry in the resp->fh may be negative if the file
  82. * doesn't exist yet.
  83. * N.B. After this call resp->fh needs an fh_put
  84. */
  85. static __be32
  86. nfsd_proc_lookup(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
  87. struct nfsd_diropres *resp)
  88. {
  89. __be32 nfserr;
  90. dprintk("nfsd: LOOKUP %s %.*s\n",
  91. SVCFH_fmt(&argp->fh), argp->len, argp->name);
  92. fh_init(&resp->fh, NFS_FHSIZE);
  93. nfserr = nfsd_lookup(rqstp, &argp->fh, argp->name, argp->len,
  94. &resp->fh);
  95. fh_put(&argp->fh);
  96. return nfsd_return_dirop(nfserr, resp);
  97. }
  98. /*
  99. * Read a symlink.
  100. */
  101. static __be32
  102. nfsd_proc_readlink(struct svc_rqst *rqstp, struct nfsd_readlinkargs *argp,
  103. struct nfsd_readlinkres *resp)
  104. {
  105. __be32 nfserr;
  106. dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh));
  107. /* Read the symlink. */
  108. resp->len = NFS_MAXPATHLEN;
  109. nfserr = nfsd_readlink(rqstp, &argp->fh, argp->buffer, &resp->len);
  110. fh_put(&argp->fh);
  111. return nfserr;
  112. }
  113. /*
  114. * Read a portion of a file.
  115. * N.B. After this call resp->fh needs an fh_put
  116. */
  117. static __be32
  118. nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
  119. struct nfsd_readres *resp)
  120. {
  121. __be32 nfserr;
  122. dprintk("nfsd: READ %s %d bytes at %d\n",
  123. SVCFH_fmt(&argp->fh),
  124. argp->count, argp->offset);
  125. /* Obtain buffer pointer for payload. 19 is 1 word for
  126. * status, 17 words for fattr, and 1 word for the byte count.
  127. */
  128. if (NFSSVC_MAXBLKSIZE_V2 < argp->count) {
  129. char buf[RPC_MAX_ADDRBUFLEN];
  130. printk(KERN_NOTICE
  131. "oversized read request from %s (%d bytes)\n",
  132. svc_print_addr(rqstp, buf, sizeof(buf)),
  133. argp->count);
  134. argp->count = NFSSVC_MAXBLKSIZE_V2;
  135. }
  136. svc_reserve(rqstp, (19<<2) + argp->count + 4);
  137. resp->count = argp->count;
  138. nfserr = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), NULL,
  139. argp->offset,
  140. rqstp->rq_vec, argp->vlen,
  141. &resp->count);
  142. if (nfserr) return nfserr;
  143. return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
  144. resp->fh.fh_dentry,
  145. &resp->stat));
  146. }
  147. /*
  148. * Write data to a file
  149. * N.B. After this call resp->fh needs an fh_put
  150. */
  151. static __be32
  152. nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
  153. struct nfsd_attrstat *resp)
  154. {
  155. __be32 nfserr;
  156. int stable = 1;
  157. dprintk("nfsd: WRITE %s %d bytes at %d\n",
  158. SVCFH_fmt(&argp->fh),
  159. argp->len, argp->offset);
  160. nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL,
  161. argp->offset,
  162. rqstp->rq_vec, argp->vlen,
  163. argp->len,
  164. &stable);
  165. return nfsd_return_attrs(nfserr, resp);
  166. }
  167. /*
  168. * CREATE processing is complicated. The keyword here is `overloaded.'
  169. * The parent directory is kept locked between the check for existence
  170. * and the actual create() call in compliance with VFS protocols.
  171. * N.B. After this call _both_ argp->fh and resp->fh need an fh_put
  172. */
  173. static __be32
  174. nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
  175. struct nfsd_diropres *resp)
  176. {
  177. svc_fh *dirfhp = &argp->fh;
  178. svc_fh *newfhp = &resp->fh;
  179. struct iattr *attr = &argp->attrs;
  180. struct inode *inode;
  181. struct dentry *dchild;
  182. int type, mode;
  183. __be32 nfserr;
  184. dev_t rdev = 0, wanted = new_decode_dev(attr->ia_size);
  185. dprintk("nfsd: CREATE %s %.*s\n",
  186. SVCFH_fmt(dirfhp), argp->len, argp->name);
  187. /* First verify the parent file handle */
  188. nfserr = fh_verify(rqstp, dirfhp, S_IFDIR, MAY_EXEC);
  189. if (nfserr)
  190. goto done; /* must fh_put dirfhp even on error */
  191. /* Check for MAY_WRITE in nfsd_create if necessary */
  192. nfserr = nfserr_acces;
  193. if (!argp->len)
  194. goto done;
  195. nfserr = nfserr_exist;
  196. if (isdotent(argp->name, argp->len))
  197. goto done;
  198. fh_lock_nested(dirfhp, I_MUTEX_PARENT);
  199. dchild = lookup_one_len(argp->name, dirfhp->fh_dentry, argp->len);
  200. if (IS_ERR(dchild)) {
  201. nfserr = nfserrno(PTR_ERR(dchild));
  202. goto out_unlock;
  203. }
  204. fh_init(newfhp, NFS_FHSIZE);
  205. nfserr = fh_compose(newfhp, dirfhp->fh_export, dchild, dirfhp);
  206. if (!nfserr && !dchild->d_inode)
  207. nfserr = nfserr_noent;
  208. dput(dchild);
  209. if (nfserr) {
  210. if (nfserr != nfserr_noent)
  211. goto out_unlock;
  212. /*
  213. * If the new file handle wasn't verified, we can't tell
  214. * whether the file exists or not. Time to bail ...
  215. */
  216. nfserr = nfserr_acces;
  217. if (!newfhp->fh_dentry) {
  218. printk(KERN_WARNING
  219. "nfsd_proc_create: file handle not verified\n");
  220. goto out_unlock;
  221. }
  222. }
  223. inode = newfhp->fh_dentry->d_inode;
  224. /* Unfudge the mode bits */
  225. if (attr->ia_valid & ATTR_MODE) {
  226. type = attr->ia_mode & S_IFMT;
  227. mode = attr->ia_mode & ~S_IFMT;
  228. if (!type) {
  229. /* no type, so if target exists, assume same as that,
  230. * else assume a file */
  231. if (inode) {
  232. type = inode->i_mode & S_IFMT;
  233. switch(type) {
  234. case S_IFCHR:
  235. case S_IFBLK:
  236. /* reserve rdev for later checking */
  237. rdev = inode->i_rdev;
  238. attr->ia_valid |= ATTR_SIZE;
  239. /* FALLTHROUGH */
  240. case S_IFIFO:
  241. /* this is probably a permission check..
  242. * at least IRIX implements perm checking on
  243. * echo thing > device-special-file-or-pipe
  244. * by doing a CREATE with type==0
  245. */
  246. nfserr = nfsd_permission(newfhp->fh_export,
  247. newfhp->fh_dentry,
  248. MAY_WRITE|MAY_LOCAL_ACCESS);
  249. if (nfserr && nfserr != nfserr_rofs)
  250. goto out_unlock;
  251. }
  252. } else
  253. type = S_IFREG;
  254. }
  255. } else if (inode) {
  256. type = inode->i_mode & S_IFMT;
  257. mode = inode->i_mode & ~S_IFMT;
  258. } else {
  259. type = S_IFREG;
  260. mode = 0; /* ??? */
  261. }
  262. attr->ia_valid |= ATTR_MODE;
  263. attr->ia_mode = mode;
  264. /* Special treatment for non-regular files according to the
  265. * gospel of sun micro
  266. */
  267. if (type != S_IFREG) {
  268. int is_borc = 0;
  269. if (type != S_IFBLK && type != S_IFCHR) {
  270. rdev = 0;
  271. } else if (type == S_IFCHR && !(attr->ia_valid & ATTR_SIZE)) {
  272. /* If you think you've seen the worst, grok this. */
  273. type = S_IFIFO;
  274. } else {
  275. /* Okay, char or block special */
  276. is_borc = 1;
  277. if (!rdev)
  278. rdev = wanted;
  279. }
  280. /* we've used the SIZE information, so discard it */
  281. attr->ia_valid &= ~ATTR_SIZE;
  282. /* Make sure the type and device matches */
  283. nfserr = nfserr_exist;
  284. if (inode && type != (inode->i_mode & S_IFMT))
  285. goto out_unlock;
  286. }
  287. nfserr = 0;
  288. if (!inode) {
  289. /* File doesn't exist. Create it and set attrs */
  290. nfserr = nfsd_create(rqstp, dirfhp, argp->name, argp->len,
  291. attr, type, rdev, newfhp);
  292. } else if (type == S_IFREG) {
  293. dprintk("nfsd: existing %s, valid=%x, size=%ld\n",
  294. argp->name, attr->ia_valid, (long) attr->ia_size);
  295. /* File already exists. We ignore all attributes except
  296. * size, so that creat() behaves exactly like
  297. * open(..., O_CREAT|O_TRUNC|O_WRONLY).
  298. */
  299. attr->ia_valid &= ATTR_SIZE;
  300. if (attr->ia_valid)
  301. nfserr = nfsd_setattr(rqstp, newfhp, attr, 0, (time_t)0);
  302. }
  303. out_unlock:
  304. /* We don't really need to unlock, as fh_put does it. */
  305. fh_unlock(dirfhp);
  306. done:
  307. fh_put(dirfhp);
  308. return nfsd_return_dirop(nfserr, resp);
  309. }
  310. static __be32
  311. nfsd_proc_remove(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
  312. void *resp)
  313. {
  314. __be32 nfserr;
  315. dprintk("nfsd: REMOVE %s %.*s\n", SVCFH_fmt(&argp->fh),
  316. argp->len, argp->name);
  317. /* Unlink. -SIFDIR means file must not be a directory */
  318. nfserr = nfsd_unlink(rqstp, &argp->fh, -S_IFDIR, argp->name, argp->len);
  319. fh_put(&argp->fh);
  320. return nfserr;
  321. }
  322. static __be32
  323. nfsd_proc_rename(struct svc_rqst *rqstp, struct nfsd_renameargs *argp,
  324. void *resp)
  325. {
  326. __be32 nfserr;
  327. dprintk("nfsd: RENAME %s %.*s -> \n",
  328. SVCFH_fmt(&argp->ffh), argp->flen, argp->fname);
  329. dprintk("nfsd: -> %s %.*s\n",
  330. SVCFH_fmt(&argp->tfh), argp->tlen, argp->tname);
  331. nfserr = nfsd_rename(rqstp, &argp->ffh, argp->fname, argp->flen,
  332. &argp->tfh, argp->tname, argp->tlen);
  333. fh_put(&argp->ffh);
  334. fh_put(&argp->tfh);
  335. return nfserr;
  336. }
  337. static __be32
  338. nfsd_proc_link(struct svc_rqst *rqstp, struct nfsd_linkargs *argp,
  339. void *resp)
  340. {
  341. __be32 nfserr;
  342. dprintk("nfsd: LINK %s ->\n",
  343. SVCFH_fmt(&argp->ffh));
  344. dprintk("nfsd: %s %.*s\n",
  345. SVCFH_fmt(&argp->tfh),
  346. argp->tlen,
  347. argp->tname);
  348. nfserr = nfsd_link(rqstp, &argp->tfh, argp->tname, argp->tlen,
  349. &argp->ffh);
  350. fh_put(&argp->ffh);
  351. fh_put(&argp->tfh);
  352. return nfserr;
  353. }
  354. static __be32
  355. nfsd_proc_symlink(struct svc_rqst *rqstp, struct nfsd_symlinkargs *argp,
  356. void *resp)
  357. {
  358. struct svc_fh newfh;
  359. __be32 nfserr;
  360. dprintk("nfsd: SYMLINK %s %.*s -> %.*s\n",
  361. SVCFH_fmt(&argp->ffh), argp->flen, argp->fname,
  362. argp->tlen, argp->tname);
  363. fh_init(&newfh, NFS_FHSIZE);
  364. /*
  365. * Create the link, look up new file and set attrs.
  366. */
  367. nfserr = nfsd_symlink(rqstp, &argp->ffh, argp->fname, argp->flen,
  368. argp->tname, argp->tlen,
  369. &newfh, &argp->attrs);
  370. fh_put(&argp->ffh);
  371. fh_put(&newfh);
  372. return nfserr;
  373. }
  374. /*
  375. * Make directory. This operation is not idempotent.
  376. * N.B. After this call resp->fh needs an fh_put
  377. */
  378. static __be32
  379. nfsd_proc_mkdir(struct svc_rqst *rqstp, struct nfsd_createargs *argp,
  380. struct nfsd_diropres *resp)
  381. {
  382. __be32 nfserr;
  383. dprintk("nfsd: MKDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
  384. if (resp->fh.fh_dentry) {
  385. printk(KERN_WARNING
  386. "nfsd_proc_mkdir: response already verified??\n");
  387. }
  388. argp->attrs.ia_valid &= ~ATTR_SIZE;
  389. fh_init(&resp->fh, NFS_FHSIZE);
  390. nfserr = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
  391. &argp->attrs, S_IFDIR, 0, &resp->fh);
  392. fh_put(&argp->fh);
  393. return nfsd_return_dirop(nfserr, resp);
  394. }
  395. /*
  396. * Remove a directory
  397. */
  398. static __be32
  399. nfsd_proc_rmdir(struct svc_rqst *rqstp, struct nfsd_diropargs *argp,
  400. void *resp)
  401. {
  402. __be32 nfserr;
  403. dprintk("nfsd: RMDIR %s %.*s\n", SVCFH_fmt(&argp->fh), argp->len, argp->name);
  404. nfserr = nfsd_unlink(rqstp, &argp->fh, S_IFDIR, argp->name, argp->len);
  405. fh_put(&argp->fh);
  406. return nfserr;
  407. }
  408. /*
  409. * Read a portion of a directory.
  410. */
  411. static __be32
  412. nfsd_proc_readdir(struct svc_rqst *rqstp, struct nfsd_readdirargs *argp,
  413. struct nfsd_readdirres *resp)
  414. {
  415. int count;
  416. __be32 nfserr;
  417. loff_t offset;
  418. dprintk("nfsd: READDIR %s %d bytes at %d\n",
  419. SVCFH_fmt(&argp->fh),
  420. argp->count, argp->cookie);
  421. /* Shrink to the client read size */
  422. count = (argp->count >> 2) - 2;
  423. /* Make sure we've room for the NULL ptr & eof flag */
  424. count -= 2;
  425. if (count < 0)
  426. count = 0;
  427. resp->buffer = argp->buffer;
  428. resp->offset = NULL;
  429. resp->buflen = count;
  430. resp->common.err = nfs_ok;
  431. /* Read directory and encode entries on the fly */
  432. offset = argp->cookie;
  433. nfserr = nfsd_readdir(rqstp, &argp->fh, &offset,
  434. &resp->common, nfssvc_encode_entry);
  435. resp->count = resp->buffer - argp->buffer;
  436. if (resp->offset)
  437. *resp->offset = htonl(offset);
  438. fh_put(&argp->fh);
  439. return nfserr;
  440. }
  441. /*
  442. * Get file system info
  443. */
  444. static __be32
  445. nfsd_proc_statfs(struct svc_rqst * rqstp, struct nfsd_fhandle *argp,
  446. struct nfsd_statfsres *resp)
  447. {
  448. __be32 nfserr;
  449. dprintk("nfsd: STATFS %s\n", SVCFH_fmt(&argp->fh));
  450. nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats);
  451. fh_put(&argp->fh);
  452. return nfserr;
  453. }
  454. /*
  455. * NFSv2 Server procedures.
  456. * Only the results of non-idempotent operations are cached.
  457. */
  458. #define nfsd_proc_none NULL
  459. #define nfssvc_release_none NULL
  460. struct nfsd_void { int dummy; };
  461. #define PROC(name, argt, rest, relt, cache, respsize) \
  462. { (svc_procfunc) nfsd_proc_##name, \
  463. (kxdrproc_t) nfssvc_decode_##argt, \
  464. (kxdrproc_t) nfssvc_encode_##rest, \
  465. (kxdrproc_t) nfssvc_release_##relt, \
  466. sizeof(struct nfsd_##argt), \
  467. sizeof(struct nfsd_##rest), \
  468. 0, \
  469. cache, \
  470. respsize, \
  471. }
  472. #define ST 1 /* status */
  473. #define FH 8 /* filehandle */
  474. #define AT 18 /* attributes */
  475. static struct svc_procedure nfsd_procedures2[18] = {
  476. PROC(null, void, void, none, RC_NOCACHE, ST),
  477. PROC(getattr, fhandle, attrstat, fhandle, RC_NOCACHE, ST+AT),
  478. PROC(setattr, sattrargs, attrstat, fhandle, RC_REPLBUFF, ST+AT),
  479. PROC(none, void, void, none, RC_NOCACHE, ST),
  480. PROC(lookup, diropargs, diropres, fhandle, RC_NOCACHE, ST+FH+AT),
  481. PROC(readlink, readlinkargs, readlinkres, none, RC_NOCACHE, ST+1+NFS_MAXPATHLEN/4),
  482. PROC(read, readargs, readres, fhandle, RC_NOCACHE, ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4),
  483. PROC(none, void, void, none, RC_NOCACHE, ST),
  484. PROC(write, writeargs, attrstat, fhandle, RC_REPLBUFF, ST+AT),
  485. PROC(create, createargs, diropres, fhandle, RC_REPLBUFF, ST+FH+AT),
  486. PROC(remove, diropargs, void, none, RC_REPLSTAT, ST),
  487. PROC(rename, renameargs, void, none, RC_REPLSTAT, ST),
  488. PROC(link, linkargs, void, none, RC_REPLSTAT, ST),
  489. PROC(symlink, symlinkargs, void, none, RC_REPLSTAT, ST),
  490. PROC(mkdir, createargs, diropres, fhandle, RC_REPLBUFF, ST+FH+AT),
  491. PROC(rmdir, diropargs, void, none, RC_REPLSTAT, ST),
  492. PROC(readdir, readdirargs, readdirres, none, RC_NOCACHE, 0),
  493. PROC(statfs, fhandle, statfsres, none, RC_NOCACHE, ST+5),
  494. };
  495. struct svc_version nfsd_version2 = {
  496. .vs_vers = 2,
  497. .vs_nproc = 18,
  498. .vs_proc = nfsd_procedures2,
  499. .vs_dispatch = nfsd_dispatch,
  500. .vs_xdrsize = NFS2_SVC_XDRSIZE,
  501. };
  502. /*
  503. * Map errnos to NFS errnos.
  504. */
  505. __be32
  506. nfserrno (int errno)
  507. {
  508. static struct {
  509. __be32 nfserr;
  510. int syserr;
  511. } nfs_errtbl[] = {
  512. { nfs_ok, 0 },
  513. { nfserr_perm, -EPERM },
  514. { nfserr_noent, -ENOENT },
  515. { nfserr_io, -EIO },
  516. { nfserr_nxio, -ENXIO },
  517. { nfserr_acces, -EACCES },
  518. { nfserr_exist, -EEXIST },
  519. { nfserr_xdev, -EXDEV },
  520. { nfserr_mlink, -EMLINK },
  521. { nfserr_nodev, -ENODEV },
  522. { nfserr_notdir, -ENOTDIR },
  523. { nfserr_isdir, -EISDIR },
  524. { nfserr_inval, -EINVAL },
  525. { nfserr_fbig, -EFBIG },
  526. { nfserr_nospc, -ENOSPC },
  527. { nfserr_rofs, -EROFS },
  528. { nfserr_mlink, -EMLINK },
  529. { nfserr_nametoolong, -ENAMETOOLONG },
  530. { nfserr_notempty, -ENOTEMPTY },
  531. #ifdef EDQUOT
  532. { nfserr_dquot, -EDQUOT },
  533. #endif
  534. { nfserr_stale, -ESTALE },
  535. { nfserr_jukebox, -ETIMEDOUT },
  536. { nfserr_dropit, -EAGAIN },
  537. { nfserr_dropit, -ENOMEM },
  538. { nfserr_badname, -ESRCH },
  539. { nfserr_io, -ETXTBSY },
  540. { nfserr_notsupp, -EOPNOTSUPP },
  541. };
  542. int i;
  543. for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
  544. if (nfs_errtbl[i].syserr == errno)
  545. return nfs_errtbl[i].nfserr;
  546. }
  547. printk (KERN_INFO "nfsd: non-standard errno: %d\n", errno);
  548. return nfserr_io;
  549. }