proc.c 17 KB

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