nfsproc.c 16 KB

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