proc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. /*
  2. * linux/fs/nfs/proc.c
  3. *
  4. * Copyright (C) 1992, 1993, 1994 Rick Sladkey
  5. *
  6. * OS-independent nfs remote procedure call functions
  7. *
  8. * Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers
  9. * so at last we can have decent(ish) throughput off a
  10. * Sun server.
  11. *
  12. * Coding optimized and cleaned up by Florian La Roche.
  13. * Note: Error returns are optimized for NFS_OK, which isn't translated via
  14. * nfs_stat_to_errno(), but happens to be already the right return code.
  15. *
  16. * Also, the code currently doesn't check the size of the packet, when
  17. * it decodes the packet.
  18. *
  19. * Feel free to fix it and mail me the diffs if it worries you.
  20. *
  21. * Completely rewritten to support the new RPC call interface;
  22. * rewrote and moved the entire XDR stuff to xdr.c
  23. * --Olaf Kirch June 1996
  24. *
  25. * The code below initializes all auto variables explicitly, otherwise
  26. * it will fail to work as a module (gcc generates a memset call for an
  27. * incomplete struct).
  28. */
  29. #include <linux/types.h>
  30. #include <linux/param.h>
  31. #include <linux/slab.h>
  32. #include <linux/time.h>
  33. #include <linux/mm.h>
  34. #include <linux/utsname.h>
  35. #include <linux/errno.h>
  36. #include <linux/string.h>
  37. #include <linux/in.h>
  38. #include <linux/pagemap.h>
  39. #include <linux/sunrpc/clnt.h>
  40. #include <linux/nfs.h>
  41. #include <linux/nfs2.h>
  42. #include <linux/nfs_fs.h>
  43. #include <linux/nfs_page.h>
  44. #include <linux/lockd/bind.h>
  45. #include "internal.h"
  46. #define NFSDBG_FACILITY NFSDBG_PROC
  47. /*
  48. * Bare-bones access to getattr: this is for nfs_read_super.
  49. */
  50. static int
  51. nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
  52. struct nfs_fsinfo *info)
  53. {
  54. struct nfs_fattr *fattr = info->fattr;
  55. struct nfs2_fsstat fsinfo;
  56. struct rpc_message msg = {
  57. .rpc_proc = &nfs_procedures[NFSPROC_GETATTR],
  58. .rpc_argp = fhandle,
  59. .rpc_resp = fattr,
  60. };
  61. int status;
  62. dprintk("%s: call getattr\n", __func__);
  63. nfs_fattr_init(fattr);
  64. status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
  65. dprintk("%s: reply getattr: %d\n", __func__, status);
  66. if (status)
  67. return status;
  68. dprintk("%s: call statfs\n", __func__);
  69. msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
  70. msg.rpc_resp = &fsinfo;
  71. status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
  72. dprintk("%s: reply statfs: %d\n", __func__, status);
  73. if (status)
  74. return status;
  75. info->rtmax = NFS_MAXDATA;
  76. info->rtpref = fsinfo.tsize;
  77. info->rtmult = fsinfo.bsize;
  78. info->wtmax = NFS_MAXDATA;
  79. info->wtpref = fsinfo.tsize;
  80. info->wtmult = fsinfo.bsize;
  81. info->dtpref = fsinfo.tsize;
  82. info->maxfilesize = 0x7FFFFFFF;
  83. info->lease_time = 0;
  84. return 0;
  85. }
  86. /*
  87. * One function for each procedure in the NFS protocol.
  88. */
  89. static int
  90. nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
  91. struct nfs_fattr *fattr)
  92. {
  93. struct rpc_message msg = {
  94. .rpc_proc = &nfs_procedures[NFSPROC_GETATTR],
  95. .rpc_argp = fhandle,
  96. .rpc_resp = fattr,
  97. };
  98. int status;
  99. dprintk("NFS call getattr\n");
  100. nfs_fattr_init(fattr);
  101. status = rpc_call_sync(server->client, &msg, 0);
  102. dprintk("NFS reply getattr: %d\n", status);
  103. return status;
  104. }
  105. static int
  106. nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
  107. struct iattr *sattr)
  108. {
  109. struct inode *inode = dentry->d_inode;
  110. struct nfs_sattrargs arg = {
  111. .fh = NFS_FH(inode),
  112. .sattr = sattr
  113. };
  114. struct rpc_message msg = {
  115. .rpc_proc = &nfs_procedures[NFSPROC_SETATTR],
  116. .rpc_argp = &arg,
  117. .rpc_resp = fattr,
  118. };
  119. int status;
  120. /* Mask out the non-modebit related stuff from attr->ia_mode */
  121. sattr->ia_mode &= S_IALLUGO;
  122. dprintk("NFS call setattr\n");
  123. if (sattr->ia_valid & ATTR_FILE)
  124. msg.rpc_cred = nfs_file_cred(sattr->ia_file);
  125. nfs_fattr_init(fattr);
  126. status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
  127. if (status == 0)
  128. nfs_setattr_update_inode(inode, sattr);
  129. dprintk("NFS reply setattr: %d\n", status);
  130. return status;
  131. }
  132. static int
  133. nfs_proc_lookup(struct inode *dir, struct qstr *name,
  134. struct nfs_fh *fhandle, struct nfs_fattr *fattr)
  135. {
  136. struct nfs_diropargs arg = {
  137. .fh = NFS_FH(dir),
  138. .name = name->name,
  139. .len = name->len
  140. };
  141. struct nfs_diropok res = {
  142. .fh = fhandle,
  143. .fattr = fattr
  144. };
  145. struct rpc_message msg = {
  146. .rpc_proc = &nfs_procedures[NFSPROC_LOOKUP],
  147. .rpc_argp = &arg,
  148. .rpc_resp = &res,
  149. };
  150. int status;
  151. dprintk("NFS call lookup %s\n", name->name);
  152. nfs_fattr_init(fattr);
  153. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  154. dprintk("NFS reply lookup: %d\n", status);
  155. return status;
  156. }
  157. static int nfs_proc_readlink(struct inode *inode, struct page *page,
  158. unsigned int pgbase, unsigned int pglen)
  159. {
  160. struct nfs_readlinkargs args = {
  161. .fh = NFS_FH(inode),
  162. .pgbase = pgbase,
  163. .pglen = pglen,
  164. .pages = &page
  165. };
  166. struct rpc_message msg = {
  167. .rpc_proc = &nfs_procedures[NFSPROC_READLINK],
  168. .rpc_argp = &args,
  169. };
  170. int status;
  171. dprintk("NFS call readlink\n");
  172. status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
  173. dprintk("NFS reply readlink: %d\n", status);
  174. return status;
  175. }
  176. static int
  177. nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
  178. int flags, struct nameidata *nd)
  179. {
  180. struct nfs_fh fhandle;
  181. struct nfs_fattr fattr;
  182. struct nfs_createargs arg = {
  183. .fh = NFS_FH(dir),
  184. .name = dentry->d_name.name,
  185. .len = dentry->d_name.len,
  186. .sattr = sattr
  187. };
  188. struct nfs_diropok res = {
  189. .fh = &fhandle,
  190. .fattr = &fattr
  191. };
  192. struct rpc_message msg = {
  193. .rpc_proc = &nfs_procedures[NFSPROC_CREATE],
  194. .rpc_argp = &arg,
  195. .rpc_resp = &res,
  196. };
  197. int status;
  198. nfs_fattr_init(&fattr);
  199. dprintk("NFS call create %s\n", dentry->d_name.name);
  200. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  201. nfs_mark_for_revalidate(dir);
  202. if (status == 0)
  203. status = nfs_instantiate(dentry, &fhandle, &fattr);
  204. dprintk("NFS reply create: %d\n", status);
  205. return status;
  206. }
  207. /*
  208. * In NFSv2, mknod is grafted onto the create call.
  209. */
  210. static int
  211. nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
  212. dev_t rdev)
  213. {
  214. struct nfs_fh fhandle;
  215. struct nfs_fattr fattr;
  216. struct nfs_createargs arg = {
  217. .fh = NFS_FH(dir),
  218. .name = dentry->d_name.name,
  219. .len = dentry->d_name.len,
  220. .sattr = sattr
  221. };
  222. struct nfs_diropok res = {
  223. .fh = &fhandle,
  224. .fattr = &fattr
  225. };
  226. struct rpc_message msg = {
  227. .rpc_proc = &nfs_procedures[NFSPROC_CREATE],
  228. .rpc_argp = &arg,
  229. .rpc_resp = &res,
  230. };
  231. int status, mode;
  232. dprintk("NFS call mknod %s\n", dentry->d_name.name);
  233. mode = sattr->ia_mode;
  234. if (S_ISFIFO(mode)) {
  235. sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;
  236. sattr->ia_valid &= ~ATTR_SIZE;
  237. } else if (S_ISCHR(mode) || S_ISBLK(mode)) {
  238. sattr->ia_valid |= ATTR_SIZE;
  239. sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
  240. }
  241. nfs_fattr_init(&fattr);
  242. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  243. nfs_mark_for_revalidate(dir);
  244. if (status == -EINVAL && S_ISFIFO(mode)) {
  245. sattr->ia_mode = mode;
  246. nfs_fattr_init(&fattr);
  247. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  248. }
  249. if (status == 0)
  250. status = nfs_instantiate(dentry, &fhandle, &fattr);
  251. dprintk("NFS reply mknod: %d\n", status);
  252. return status;
  253. }
  254. static int
  255. nfs_proc_remove(struct inode *dir, struct qstr *name)
  256. {
  257. struct nfs_removeargs arg = {
  258. .fh = NFS_FH(dir),
  259. .name.len = name->len,
  260. .name.name = name->name,
  261. };
  262. struct rpc_message msg = {
  263. .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
  264. .rpc_argp = &arg,
  265. };
  266. int status;
  267. dprintk("NFS call remove %s\n", name->name);
  268. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  269. nfs_mark_for_revalidate(dir);
  270. dprintk("NFS reply remove: %d\n", status);
  271. return status;
  272. }
  273. static void
  274. nfs_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
  275. {
  276. msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
  277. }
  278. static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)
  279. {
  280. nfs_mark_for_revalidate(dir);
  281. return 1;
  282. }
  283. static int
  284. nfs_proc_rename(struct inode *old_dir, struct qstr *old_name,
  285. struct inode *new_dir, struct qstr *new_name)
  286. {
  287. struct nfs_renameargs arg = {
  288. .fromfh = NFS_FH(old_dir),
  289. .fromname = old_name->name,
  290. .fromlen = old_name->len,
  291. .tofh = NFS_FH(new_dir),
  292. .toname = new_name->name,
  293. .tolen = new_name->len
  294. };
  295. struct rpc_message msg = {
  296. .rpc_proc = &nfs_procedures[NFSPROC_RENAME],
  297. .rpc_argp = &arg,
  298. };
  299. int status;
  300. dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
  301. status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0);
  302. nfs_mark_for_revalidate(old_dir);
  303. nfs_mark_for_revalidate(new_dir);
  304. dprintk("NFS reply rename: %d\n", status);
  305. return status;
  306. }
  307. static int
  308. nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
  309. {
  310. struct nfs_linkargs arg = {
  311. .fromfh = NFS_FH(inode),
  312. .tofh = NFS_FH(dir),
  313. .toname = name->name,
  314. .tolen = name->len
  315. };
  316. struct rpc_message msg = {
  317. .rpc_proc = &nfs_procedures[NFSPROC_LINK],
  318. .rpc_argp = &arg,
  319. };
  320. int status;
  321. dprintk("NFS call link %s\n", name->name);
  322. status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
  323. nfs_mark_for_revalidate(inode);
  324. nfs_mark_for_revalidate(dir);
  325. dprintk("NFS reply link: %d\n", status);
  326. return status;
  327. }
  328. static int
  329. nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
  330. unsigned int len, struct iattr *sattr)
  331. {
  332. struct nfs_fh fhandle;
  333. struct nfs_fattr fattr;
  334. struct nfs_symlinkargs arg = {
  335. .fromfh = NFS_FH(dir),
  336. .fromname = dentry->d_name.name,
  337. .fromlen = dentry->d_name.len,
  338. .pages = &page,
  339. .pathlen = len,
  340. .sattr = sattr
  341. };
  342. struct rpc_message msg = {
  343. .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK],
  344. .rpc_argp = &arg,
  345. };
  346. int status;
  347. if (len > NFS2_MAXPATHLEN)
  348. return -ENAMETOOLONG;
  349. dprintk("NFS call symlink %s\n", dentry->d_name.name);
  350. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  351. nfs_mark_for_revalidate(dir);
  352. /*
  353. * V2 SYMLINK requests don't return any attributes. Setting the
  354. * filehandle size to zero indicates to nfs_instantiate that it
  355. * should fill in the data with a LOOKUP call on the wire.
  356. */
  357. if (status == 0) {
  358. nfs_fattr_init(&fattr);
  359. fhandle.size = 0;
  360. status = nfs_instantiate(dentry, &fhandle, &fattr);
  361. }
  362. dprintk("NFS reply symlink: %d\n", status);
  363. return status;
  364. }
  365. static int
  366. nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
  367. {
  368. struct nfs_fh fhandle;
  369. struct nfs_fattr fattr;
  370. struct nfs_createargs arg = {
  371. .fh = NFS_FH(dir),
  372. .name = dentry->d_name.name,
  373. .len = dentry->d_name.len,
  374. .sattr = sattr
  375. };
  376. struct nfs_diropok res = {
  377. .fh = &fhandle,
  378. .fattr = &fattr
  379. };
  380. struct rpc_message msg = {
  381. .rpc_proc = &nfs_procedures[NFSPROC_MKDIR],
  382. .rpc_argp = &arg,
  383. .rpc_resp = &res,
  384. };
  385. int status;
  386. dprintk("NFS call mkdir %s\n", dentry->d_name.name);
  387. nfs_fattr_init(&fattr);
  388. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  389. nfs_mark_for_revalidate(dir);
  390. if (status == 0)
  391. status = nfs_instantiate(dentry, &fhandle, &fattr);
  392. dprintk("NFS reply mkdir: %d\n", status);
  393. return status;
  394. }
  395. static int
  396. nfs_proc_rmdir(struct inode *dir, struct qstr *name)
  397. {
  398. struct nfs_diropargs arg = {
  399. .fh = NFS_FH(dir),
  400. .name = name->name,
  401. .len = name->len
  402. };
  403. struct rpc_message msg = {
  404. .rpc_proc = &nfs_procedures[NFSPROC_RMDIR],
  405. .rpc_argp = &arg,
  406. };
  407. int status;
  408. dprintk("NFS call rmdir %s\n", name->name);
  409. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  410. nfs_mark_for_revalidate(dir);
  411. dprintk("NFS reply rmdir: %d\n", status);
  412. return status;
  413. }
  414. /*
  415. * The READDIR implementation is somewhat hackish - we pass a temporary
  416. * buffer to the encode function, which installs it in the receive
  417. * the receive iovec. The decode function just parses the reply to make
  418. * sure it is syntactically correct; the entries itself are decoded
  419. * from nfs_readdir by calling the decode_entry function directly.
  420. */
  421. static int
  422. nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
  423. u64 cookie, struct page *page, unsigned int count, int plus)
  424. {
  425. struct inode *dir = dentry->d_inode;
  426. struct nfs_readdirargs arg = {
  427. .fh = NFS_FH(dir),
  428. .cookie = cookie,
  429. .count = count,
  430. .pages = &page,
  431. };
  432. struct rpc_message msg = {
  433. .rpc_proc = &nfs_procedures[NFSPROC_READDIR],
  434. .rpc_argp = &arg,
  435. .rpc_cred = cred,
  436. };
  437. int status;
  438. dprintk("NFS call readdir %d\n", (unsigned int)cookie);
  439. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  440. nfs_invalidate_atime(dir);
  441. dprintk("NFS reply readdir: %d\n", status);
  442. return status;
  443. }
  444. static int
  445. nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
  446. struct nfs_fsstat *stat)
  447. {
  448. struct nfs2_fsstat fsinfo;
  449. struct rpc_message msg = {
  450. .rpc_proc = &nfs_procedures[NFSPROC_STATFS],
  451. .rpc_argp = fhandle,
  452. .rpc_resp = &fsinfo,
  453. };
  454. int status;
  455. dprintk("NFS call statfs\n");
  456. nfs_fattr_init(stat->fattr);
  457. status = rpc_call_sync(server->client, &msg, 0);
  458. dprintk("NFS reply statfs: %d\n", status);
  459. if (status)
  460. goto out;
  461. stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize;
  462. stat->fbytes = (u64)fsinfo.bfree * fsinfo.bsize;
  463. stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize;
  464. stat->tfiles = 0;
  465. stat->ffiles = 0;
  466. stat->afiles = 0;
  467. out:
  468. return status;
  469. }
  470. static int
  471. nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
  472. struct nfs_fsinfo *info)
  473. {
  474. struct nfs2_fsstat fsinfo;
  475. struct rpc_message msg = {
  476. .rpc_proc = &nfs_procedures[NFSPROC_STATFS],
  477. .rpc_argp = fhandle,
  478. .rpc_resp = &fsinfo,
  479. };
  480. int status;
  481. dprintk("NFS call fsinfo\n");
  482. nfs_fattr_init(info->fattr);
  483. status = rpc_call_sync(server->client, &msg, 0);
  484. dprintk("NFS reply fsinfo: %d\n", status);
  485. if (status)
  486. goto out;
  487. info->rtmax = NFS_MAXDATA;
  488. info->rtpref = fsinfo.tsize;
  489. info->rtmult = fsinfo.bsize;
  490. info->wtmax = NFS_MAXDATA;
  491. info->wtpref = fsinfo.tsize;
  492. info->wtmult = fsinfo.bsize;
  493. info->dtpref = fsinfo.tsize;
  494. info->maxfilesize = 0x7FFFFFFF;
  495. info->lease_time = 0;
  496. out:
  497. return status;
  498. }
  499. static int
  500. nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
  501. struct nfs_pathconf *info)
  502. {
  503. info->max_link = 0;
  504. info->max_namelen = NFS2_MAXNAMLEN;
  505. return 0;
  506. }
  507. static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data)
  508. {
  509. nfs_invalidate_atime(data->inode);
  510. if (task->tk_status >= 0) {
  511. nfs_refresh_inode(data->inode, data->res.fattr);
  512. /* Emulate the eof flag, which isn't normally needed in NFSv2
  513. * as it is guaranteed to always return the file attributes
  514. */
  515. if (data->args.offset + data->args.count >= data->res.fattr->size)
  516. data->res.eof = 1;
  517. }
  518. return 0;
  519. }
  520. static void nfs_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg)
  521. {
  522. msg->rpc_proc = &nfs_procedures[NFSPROC_READ];
  523. }
  524. static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data)
  525. {
  526. if (task->tk_status >= 0)
  527. nfs_post_op_update_inode_force_wcc(data->inode, data->res.fattr);
  528. return 0;
  529. }
  530. static void nfs_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg)
  531. {
  532. /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
  533. data->args.stable = NFS_FILE_SYNC;
  534. msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE];
  535. }
  536. static void
  537. nfs_proc_commit_setup(struct nfs_write_data *data, struct rpc_message *msg)
  538. {
  539. BUG();
  540. }
  541. static int
  542. nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
  543. {
  544. struct inode *inode = filp->f_path.dentry->d_inode;
  545. return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl);
  546. }
  547. /* Helper functions for NFS lock bounds checking */
  548. #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL)
  549. static int nfs_lock_check_bounds(const struct file_lock *fl)
  550. {
  551. __s32 start, end;
  552. start = (__s32)fl->fl_start;
  553. if ((loff_t)start != fl->fl_start)
  554. goto out_einval;
  555. if (fl->fl_end != OFFSET_MAX) {
  556. end = (__s32)fl->fl_end;
  557. if ((loff_t)end != fl->fl_end)
  558. goto out_einval;
  559. } else
  560. end = NFS_LOCK32_OFFSET_MAX;
  561. if (start < 0 || start > end)
  562. goto out_einval;
  563. return 0;
  564. out_einval:
  565. return -EINVAL;
  566. }
  567. const struct nfs_rpc_ops nfs_v2_clientops = {
  568. .version = 2, /* protocol version */
  569. .dentry_ops = &nfs_dentry_operations,
  570. .dir_inode_ops = &nfs_dir_inode_operations,
  571. .file_inode_ops = &nfs_file_inode_operations,
  572. .getroot = nfs_proc_get_root,
  573. .getattr = nfs_proc_getattr,
  574. .setattr = nfs_proc_setattr,
  575. .lookup = nfs_proc_lookup,
  576. .access = NULL, /* access */
  577. .readlink = nfs_proc_readlink,
  578. .create = nfs_proc_create,
  579. .remove = nfs_proc_remove,
  580. .unlink_setup = nfs_proc_unlink_setup,
  581. .unlink_done = nfs_proc_unlink_done,
  582. .rename = nfs_proc_rename,
  583. .link = nfs_proc_link,
  584. .symlink = nfs_proc_symlink,
  585. .mkdir = nfs_proc_mkdir,
  586. .rmdir = nfs_proc_rmdir,
  587. .readdir = nfs_proc_readdir,
  588. .mknod = nfs_proc_mknod,
  589. .statfs = nfs_proc_statfs,
  590. .fsinfo = nfs_proc_fsinfo,
  591. .pathconf = nfs_proc_pathconf,
  592. .decode_dirent = nfs_decode_dirent,
  593. .read_setup = nfs_proc_read_setup,
  594. .read_done = nfs_read_done,
  595. .write_setup = nfs_proc_write_setup,
  596. .write_done = nfs_write_done,
  597. .commit_setup = nfs_proc_commit_setup,
  598. .lock = nfs_proc_lock,
  599. .lock_check_bounds = nfs_lock_check_bounds,
  600. };