1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * linux/fs/nfs/proc.c 4 * 5 * Copyright (C) 1992, 1993, 1994 Rick Sladkey 6 * 7 * OS-independent nfs remote procedure call functions 8 * 9 * Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers 10 * so at last we can have decent(ish) throughput off a 11 * Sun server. 12 * 13 * Coding optimized and cleaned up by Florian La Roche. 14 * Note: Error returns are optimized for NFS_OK, which isn't translated via 15 * nfs_stat_to_errno(), but happens to be already the right return code. 16 * 17 * Also, the code currently doesn't check the size of the packet, when 18 * it decodes the packet. 19 * 20 * Feel free to fix it and mail me the diffs if it worries you. 21 * 22 * Completely rewritten to support the new RPC call interface; 23 * rewrote and moved the entire XDR stuff to xdr.c 24 * --Olaf Kirch June 1996 25 * 26 * The code below initializes all auto variables explicitly, otherwise 27 * it will fail to work as a module (gcc generates a memset call for an 28 * incomplete struct). 29 */ 30 31 #include <linux/types.h> 32 #include <linux/param.h> 33 #include <linux/time.h> 34 #include <linux/mm.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 <linux/freezer.h> 46 #include "internal.h" 47 48 #define NFSDBG_FACILITY NFSDBG_PROC 49 50 /* 51 * Bare-bones access to getattr: this is for nfs_read_super. 52 */ 53 static int 54 nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, 55 struct nfs_fsinfo *info) 56 { 57 struct nfs_fattr *fattr = info->fattr; 58 struct nfs2_fsstat fsinfo; 59 struct rpc_message msg = { 60 .rpc_proc = &nfs_procedures[NFSPROC_GETATTR], 61 .rpc_argp = fhandle, 62 .rpc_resp = fattr, 63 }; 64 int status; 65 66 dprintk("%s: call getattr\n", __func__); 67 nfs_fattr_init(fattr); 68 status = rpc_call_sync(server->client, &msg, 0); 69 /* Retry with default authentication if different */ 70 if (status && server->nfs_client->cl_rpcclient != server->client) 71 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 72 dprintk("%s: reply getattr: %d\n", __func__, status); 73 if (status) 74 return status; 75 dprintk("%s: call statfs\n", __func__); 76 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS]; 77 msg.rpc_resp = &fsinfo; 78 status = rpc_call_sync(server->client, &msg, 0); 79 /* Retry with default authentication if different */ 80 if (status && server->nfs_client->cl_rpcclient != server->client) 81 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 82 dprintk("%s: reply statfs: %d\n", __func__, status); 83 if (status) 84 return status; 85 info->rtmax = NFS_MAXDATA; 86 info->rtpref = fsinfo.tsize; 87 info->rtmult = fsinfo.bsize; 88 info->wtmax = NFS_MAXDATA; 89 info->wtpref = fsinfo.tsize; 90 info->wtmult = fsinfo.bsize; 91 info->dtpref = fsinfo.tsize; 92 info->maxfilesize = 0x7FFFFFFF; 93 info->lease_time = 0; 94 info->change_attr_type = NFS4_CHANGE_TYPE_IS_UNDEFINED; 95 info->xattr_support = 0; 96 return 0; 97 } 98 99 /* 100 * One function for each procedure in the NFS protocol. 101 */ 102 static int 103 nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, 104 struct nfs_fattr *fattr, struct nfs4_label *label, 105 struct inode *inode) 106 { 107 struct rpc_message msg = { 108 .rpc_proc = &nfs_procedures[NFSPROC_GETATTR], 109 .rpc_argp = fhandle, 110 .rpc_resp = fattr, 111 }; 112 int status; 113 unsigned short task_flags = 0; 114 115 /* Is this is an attribute revalidation, subject to softreval? */ 116 if (inode && (server->flags & NFS_MOUNT_SOFTREVAL)) 117 task_flags |= RPC_TASK_TIMEOUT; 118 119 dprintk("NFS call getattr\n"); 120 nfs_fattr_init(fattr); 121 status = rpc_call_sync(server->client, &msg, task_flags); 122 dprintk("NFS reply getattr: %d\n", status); 123 return status; 124 } 125 126 static int 127 nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, 128 struct iattr *sattr) 129 { 130 struct inode *inode = d_inode(dentry); 131 struct nfs_sattrargs arg = { 132 .fh = NFS_FH(inode), 133 .sattr = sattr 134 }; 135 struct rpc_message msg = { 136 .rpc_proc = &nfs_procedures[NFSPROC_SETATTR], 137 .rpc_argp = &arg, 138 .rpc_resp = fattr, 139 }; 140 int status; 141 142 /* Mask out the non-modebit related stuff from attr->ia_mode */ 143 sattr->ia_mode &= S_IALLUGO; 144 145 dprintk("NFS call setattr\n"); 146 if (sattr->ia_valid & ATTR_FILE) 147 msg.rpc_cred = nfs_file_cred(sattr->ia_file); 148 nfs_fattr_init(fattr); 149 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 150 if (status == 0) 151 nfs_setattr_update_inode(inode, sattr, fattr); 152 dprintk("NFS reply setattr: %d\n", status); 153 return status; 154 } 155 156 static int 157 nfs_proc_lookup(struct inode *dir, struct dentry *dentry, 158 struct nfs_fh *fhandle, struct nfs_fattr *fattr, 159 struct nfs4_label *label) 160 { 161 struct nfs_diropargs arg = { 162 .fh = NFS_FH(dir), 163 .name = dentry->d_name.name, 164 .len = dentry->d_name.len 165 }; 166 struct nfs_diropok res = { 167 .fh = fhandle, 168 .fattr = fattr 169 }; 170 struct rpc_message msg = { 171 .rpc_proc = &nfs_procedures[NFSPROC_LOOKUP], 172 .rpc_argp = &arg, 173 .rpc_resp = &res, 174 }; 175 int status; 176 unsigned short task_flags = 0; 177 178 /* Is this is an attribute revalidation, subject to softreval? */ 179 if (nfs_lookup_is_soft_revalidate(dentry)) 180 task_flags |= RPC_TASK_TIMEOUT; 181 182 dprintk("NFS call lookup %pd2\n", dentry); 183 nfs_fattr_init(fattr); 184 status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags); 185 dprintk("NFS reply lookup: %d\n", status); 186 return status; 187 } 188 189 static int nfs_proc_readlink(struct inode *inode, struct page *page, 190 unsigned int pgbase, unsigned int pglen) 191 { 192 struct nfs_readlinkargs args = { 193 .fh = NFS_FH(inode), 194 .pgbase = pgbase, 195 .pglen = pglen, 196 .pages = &page 197 }; 198 struct rpc_message msg = { 199 .rpc_proc = &nfs_procedures[NFSPROC_READLINK], 200 .rpc_argp = &args, 201 }; 202 int status; 203 204 dprintk("NFS call readlink\n"); 205 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 206 dprintk("NFS reply readlink: %d\n", status); 207 return status; 208 } 209 210 struct nfs_createdata { 211 struct nfs_createargs arg; 212 struct nfs_diropok res; 213 struct nfs_fh fhandle; 214 struct nfs_fattr fattr; 215 }; 216 217 static struct nfs_createdata *nfs_alloc_createdata(struct inode *dir, 218 struct dentry *dentry, struct iattr *sattr) 219 { 220 struct nfs_createdata *data; 221 222 data = kmalloc(sizeof(*data), GFP_KERNEL); 223 224 if (data != NULL) { 225 data->arg.fh = NFS_FH(dir); 226 data->arg.name = dentry->d_name.name; 227 data->arg.len = dentry->d_name.len; 228 data->arg.sattr = sattr; 229 nfs_fattr_init(&data->fattr); 230 data->fhandle.size = 0; 231 data->res.fh = &data->fhandle; 232 data->res.fattr = &data->fattr; 233 } 234 return data; 235 }; 236 237 static void nfs_free_createdata(const struct nfs_createdata *data) 238 { 239 kfree(data); 240 } 241 242 static int 243 nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 244 int flags) 245 { 246 struct nfs_createdata *data; 247 struct rpc_message msg = { 248 .rpc_proc = &nfs_procedures[NFSPROC_CREATE], 249 }; 250 int status = -ENOMEM; 251 252 dprintk("NFS call create %pd\n", dentry); 253 data = nfs_alloc_createdata(dir, dentry, sattr); 254 if (data == NULL) 255 goto out; 256 msg.rpc_argp = &data->arg; 257 msg.rpc_resp = &data->res; 258 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 259 nfs_mark_for_revalidate(dir); 260 if (status == 0) 261 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL); 262 nfs_free_createdata(data); 263 out: 264 dprintk("NFS reply create: %d\n", status); 265 return status; 266 } 267 268 /* 269 * In NFSv2, mknod is grafted onto the create call. 270 */ 271 static int 272 nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 273 dev_t rdev) 274 { 275 struct nfs_createdata *data; 276 struct rpc_message msg = { 277 .rpc_proc = &nfs_procedures[NFSPROC_CREATE], 278 }; 279 umode_t mode; 280 int status = -ENOMEM; 281 282 dprintk("NFS call mknod %pd\n", dentry); 283 284 mode = sattr->ia_mode; 285 if (S_ISFIFO(mode)) { 286 sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR; 287 sattr->ia_valid &= ~ATTR_SIZE; 288 } else if (S_ISCHR(mode) || S_ISBLK(mode)) { 289 sattr->ia_valid |= ATTR_SIZE; 290 sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */ 291 } 292 293 data = nfs_alloc_createdata(dir, dentry, sattr); 294 if (data == NULL) 295 goto out; 296 msg.rpc_argp = &data->arg; 297 msg.rpc_resp = &data->res; 298 299 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 300 nfs_mark_for_revalidate(dir); 301 302 if (status == -EINVAL && S_ISFIFO(mode)) { 303 sattr->ia_mode = mode; 304 nfs_fattr_init(data->res.fattr); 305 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 306 } 307 if (status == 0) 308 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL); 309 nfs_free_createdata(data); 310 out: 311 dprintk("NFS reply mknod: %d\n", status); 312 return status; 313 } 314 315 static int 316 nfs_proc_remove(struct inode *dir, struct dentry *dentry) 317 { 318 struct nfs_removeargs arg = { 319 .fh = NFS_FH(dir), 320 .name = dentry->d_name, 321 }; 322 struct rpc_message msg = { 323 .rpc_proc = &nfs_procedures[NFSPROC_REMOVE], 324 .rpc_argp = &arg, 325 }; 326 int status; 327 328 dprintk("NFS call remove %pd2\n",dentry); 329 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 330 nfs_mark_for_revalidate(dir); 331 332 dprintk("NFS reply remove: %d\n", status); 333 return status; 334 } 335 336 static void 337 nfs_proc_unlink_setup(struct rpc_message *msg, 338 struct dentry *dentry, 339 struct inode *inode) 340 { 341 msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE]; 342 } 343 344 static void nfs_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data) 345 { 346 rpc_call_start(task); 347 } 348 349 static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir) 350 { 351 nfs_mark_for_revalidate(dir); 352 return 1; 353 } 354 355 static void 356 nfs_proc_rename_setup(struct rpc_message *msg, 357 struct dentry *old_dentry, 358 struct dentry *new_dentry) 359 { 360 msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME]; 361 } 362 363 static void nfs_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data) 364 { 365 rpc_call_start(task); 366 } 367 368 static int 369 nfs_proc_rename_done(struct rpc_task *task, struct inode *old_dir, 370 struct inode *new_dir) 371 { 372 nfs_mark_for_revalidate(old_dir); 373 nfs_mark_for_revalidate(new_dir); 374 return 1; 375 } 376 377 static int 378 nfs_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name) 379 { 380 struct nfs_linkargs arg = { 381 .fromfh = NFS_FH(inode), 382 .tofh = NFS_FH(dir), 383 .toname = name->name, 384 .tolen = name->len 385 }; 386 struct rpc_message msg = { 387 .rpc_proc = &nfs_procedures[NFSPROC_LINK], 388 .rpc_argp = &arg, 389 }; 390 int status; 391 392 dprintk("NFS call link %s\n", name->name); 393 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 394 nfs_mark_for_revalidate(inode); 395 nfs_mark_for_revalidate(dir); 396 dprintk("NFS reply link: %d\n", status); 397 return status; 398 } 399 400 static int 401 nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, 402 unsigned int len, struct iattr *sattr) 403 { 404 struct nfs_fh *fh; 405 struct nfs_fattr *fattr; 406 struct nfs_symlinkargs arg = { 407 .fromfh = NFS_FH(dir), 408 .fromname = dentry->d_name.name, 409 .fromlen = dentry->d_name.len, 410 .pages = &page, 411 .pathlen = len, 412 .sattr = sattr 413 }; 414 struct rpc_message msg = { 415 .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK], 416 .rpc_argp = &arg, 417 }; 418 int status = -ENAMETOOLONG; 419 420 dprintk("NFS call symlink %pd\n", dentry); 421 422 if (len > NFS2_MAXPATHLEN) 423 goto out; 424 425 fh = nfs_alloc_fhandle(); 426 fattr = nfs_alloc_fattr(); 427 status = -ENOMEM; 428 if (fh == NULL || fattr == NULL) 429 goto out_free; 430 431 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 432 nfs_mark_for_revalidate(dir); 433 434 /* 435 * V2 SYMLINK requests don't return any attributes. Setting the 436 * filehandle size to zero indicates to nfs_instantiate that it 437 * should fill in the data with a LOOKUP call on the wire. 438 */ 439 if (status == 0) 440 status = nfs_instantiate(dentry, fh, fattr, NULL); 441 442 out_free: 443 nfs_free_fattr(fattr); 444 nfs_free_fhandle(fh); 445 out: 446 dprintk("NFS reply symlink: %d\n", status); 447 return status; 448 } 449 450 static int 451 nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) 452 { 453 struct nfs_createdata *data; 454 struct rpc_message msg = { 455 .rpc_proc = &nfs_procedures[NFSPROC_MKDIR], 456 }; 457 int status = -ENOMEM; 458 459 dprintk("NFS call mkdir %pd\n", dentry); 460 data = nfs_alloc_createdata(dir, dentry, sattr); 461 if (data == NULL) 462 goto out; 463 msg.rpc_argp = &data->arg; 464 msg.rpc_resp = &data->res; 465 466 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 467 nfs_mark_for_revalidate(dir); 468 if (status == 0) 469 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr, NULL); 470 nfs_free_createdata(data); 471 out: 472 dprintk("NFS reply mkdir: %d\n", status); 473 return status; 474 } 475 476 static int 477 nfs_proc_rmdir(struct inode *dir, const struct qstr *name) 478 { 479 struct nfs_diropargs arg = { 480 .fh = NFS_FH(dir), 481 .name = name->name, 482 .len = name->len 483 }; 484 struct rpc_message msg = { 485 .rpc_proc = &nfs_procedures[NFSPROC_RMDIR], 486 .rpc_argp = &arg, 487 }; 488 int status; 489 490 dprintk("NFS call rmdir %s\n", name->name); 491 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 492 nfs_mark_for_revalidate(dir); 493 dprintk("NFS reply rmdir: %d\n", status); 494 return status; 495 } 496 497 /* 498 * The READDIR implementation is somewhat hackish - we pass a temporary 499 * buffer to the encode function, which installs it in the receive 500 * the receive iovec. The decode function just parses the reply to make 501 * sure it is syntactically correct; the entries itself are decoded 502 * from nfs_readdir by calling the decode_entry function directly. 503 */ 504 static int nfs_proc_readdir(struct nfs_readdir_arg *nr_arg, 505 struct nfs_readdir_res *nr_res) 506 { 507 struct inode *dir = d_inode(nr_arg->dentry); 508 struct nfs_readdirargs arg = { 509 .fh = NFS_FH(dir), 510 .cookie = nr_arg->cookie, 511 .count = nr_arg->page_len, 512 .pages = nr_arg->pages, 513 }; 514 struct rpc_message msg = { 515 .rpc_proc = &nfs_procedures[NFSPROC_READDIR], 516 .rpc_argp = &arg, 517 .rpc_cred = nr_arg->cred, 518 }; 519 int status; 520 521 dprintk("NFS call readdir %llu\n", (unsigned long long)nr_arg->cookie); 522 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 523 nr_res->verf[0] = nr_res->verf[1] = 0; 524 525 nfs_invalidate_atime(dir); 526 527 dprintk("NFS reply readdir: %d\n", status); 528 return status; 529 } 530 531 static int 532 nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, 533 struct nfs_fsstat *stat) 534 { 535 struct nfs2_fsstat fsinfo; 536 struct rpc_message msg = { 537 .rpc_proc = &nfs_procedures[NFSPROC_STATFS], 538 .rpc_argp = fhandle, 539 .rpc_resp = &fsinfo, 540 }; 541 int status; 542 543 dprintk("NFS call statfs\n"); 544 nfs_fattr_init(stat->fattr); 545 status = rpc_call_sync(server->client, &msg, 0); 546 dprintk("NFS reply statfs: %d\n", status); 547 if (status) 548 goto out; 549 stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize; 550 stat->fbytes = (u64)fsinfo.bfree * fsinfo.bsize; 551 stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize; 552 stat->tfiles = 0; 553 stat->ffiles = 0; 554 stat->afiles = 0; 555 out: 556 return status; 557 } 558 559 static int 560 nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, 561 struct nfs_fsinfo *info) 562 { 563 struct nfs2_fsstat fsinfo; 564 struct rpc_message msg = { 565 .rpc_proc = &nfs_procedures[NFSPROC_STATFS], 566 .rpc_argp = fhandle, 567 .rpc_resp = &fsinfo, 568 }; 569 int status; 570 571 dprintk("NFS call fsinfo\n"); 572 nfs_fattr_init(info->fattr); 573 status = rpc_call_sync(server->client, &msg, 0); 574 dprintk("NFS reply fsinfo: %d\n", status); 575 if (status) 576 goto out; 577 info->rtmax = NFS_MAXDATA; 578 info->rtpref = fsinfo.tsize; 579 info->rtmult = fsinfo.bsize; 580 info->wtmax = NFS_MAXDATA; 581 info->wtpref = fsinfo.tsize; 582 info->wtmult = fsinfo.bsize; 583 info->dtpref = fsinfo.tsize; 584 info->maxfilesize = 0x7FFFFFFF; 585 info->lease_time = 0; 586 out: 587 return status; 588 } 589 590 static int 591 nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, 592 struct nfs_pathconf *info) 593 { 594 info->max_link = 0; 595 info->max_namelen = NFS2_MAXNAMLEN; 596 return 0; 597 } 598 599 static int nfs_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) 600 { 601 struct inode *inode = hdr->inode; 602 603 nfs_invalidate_atime(inode); 604 if (task->tk_status >= 0) { 605 nfs_refresh_inode(inode, hdr->res.fattr); 606 /* Emulate the eof flag, which isn't normally needed in NFSv2 607 * as it is guaranteed to always return the file attributes 608 */ 609 if ((hdr->res.count == 0 && hdr->args.count > 0) || 610 hdr->args.offset + hdr->res.count >= hdr->res.fattr->size) 611 hdr->res.eof = 1; 612 } 613 return 0; 614 } 615 616 static void nfs_proc_read_setup(struct nfs_pgio_header *hdr, 617 struct rpc_message *msg) 618 { 619 msg->rpc_proc = &nfs_procedures[NFSPROC_READ]; 620 } 621 622 static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task, 623 struct nfs_pgio_header *hdr) 624 { 625 rpc_call_start(task); 626 return 0; 627 } 628 629 static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr) 630 { 631 if (task->tk_status >= 0) { 632 hdr->res.count = hdr->args.count; 633 nfs_writeback_update_inode(hdr); 634 } 635 return 0; 636 } 637 638 static void nfs_proc_write_setup(struct nfs_pgio_header *hdr, 639 struct rpc_message *msg, 640 struct rpc_clnt **clnt) 641 { 642 /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */ 643 hdr->args.stable = NFS_FILE_SYNC; 644 msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE]; 645 } 646 647 static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) 648 { 649 BUG(); 650 } 651 652 static void 653 nfs_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg, 654 struct rpc_clnt **clnt) 655 { 656 BUG(); 657 } 658 659 static int 660 nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl) 661 { 662 struct inode *inode = file_inode(filp); 663 664 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl, NULL); 665 } 666 667 /* Helper functions for NFS lock bounds checking */ 668 #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL) 669 static int nfs_lock_check_bounds(const struct file_lock *fl) 670 { 671 __s32 start, end; 672 673 start = (__s32)fl->fl_start; 674 if ((loff_t)start != fl->fl_start) 675 goto out_einval; 676 677 if (fl->fl_end != OFFSET_MAX) { 678 end = (__s32)fl->fl_end; 679 if ((loff_t)end != fl->fl_end) 680 goto out_einval; 681 } else 682 end = NFS_LOCK32_OFFSET_MAX; 683 684 if (start < 0 || start > end) 685 goto out_einval; 686 return 0; 687 out_einval: 688 return -EINVAL; 689 } 690 691 static int nfs_have_delegation(struct inode *inode, fmode_t flags) 692 { 693 return 0; 694 } 695 696 static const struct inode_operations nfs_dir_inode_operations = { 697 .create = nfs_create, 698 .lookup = nfs_lookup, 699 .link = nfs_link, 700 .unlink = nfs_unlink, 701 .symlink = nfs_symlink, 702 .mkdir = nfs_mkdir, 703 .rmdir = nfs_rmdir, 704 .mknod = nfs_mknod, 705 .rename = nfs_rename, 706 .permission = nfs_permission, 707 .getattr = nfs_getattr, 708 .setattr = nfs_setattr, 709 }; 710 711 static const struct inode_operations nfs_file_inode_operations = { 712 .permission = nfs_permission, 713 .getattr = nfs_getattr, 714 .setattr = nfs_setattr, 715 }; 716 717 const struct nfs_rpc_ops nfs_v2_clientops = { 718 .version = 2, /* protocol version */ 719 .dentry_ops = &nfs_dentry_operations, 720 .dir_inode_ops = &nfs_dir_inode_operations, 721 .file_inode_ops = &nfs_file_inode_operations, 722 .file_ops = &nfs_file_operations, 723 .getroot = nfs_proc_get_root, 724 .submount = nfs_submount, 725 .try_get_tree = nfs_try_get_tree, 726 .getattr = nfs_proc_getattr, 727 .setattr = nfs_proc_setattr, 728 .lookup = nfs_proc_lookup, 729 .access = NULL, /* access */ 730 .readlink = nfs_proc_readlink, 731 .create = nfs_proc_create, 732 .remove = nfs_proc_remove, 733 .unlink_setup = nfs_proc_unlink_setup, 734 .unlink_rpc_prepare = nfs_proc_unlink_rpc_prepare, 735 .unlink_done = nfs_proc_unlink_done, 736 .rename_setup = nfs_proc_rename_setup, 737 .rename_rpc_prepare = nfs_proc_rename_rpc_prepare, 738 .rename_done = nfs_proc_rename_done, 739 .link = nfs_proc_link, 740 .symlink = nfs_proc_symlink, 741 .mkdir = nfs_proc_mkdir, 742 .rmdir = nfs_proc_rmdir, 743 .readdir = nfs_proc_readdir, 744 .mknod = nfs_proc_mknod, 745 .statfs = nfs_proc_statfs, 746 .fsinfo = nfs_proc_fsinfo, 747 .pathconf = nfs_proc_pathconf, 748 .decode_dirent = nfs2_decode_dirent, 749 .pgio_rpc_prepare = nfs_proc_pgio_rpc_prepare, 750 .read_setup = nfs_proc_read_setup, 751 .read_done = nfs_read_done, 752 .write_setup = nfs_proc_write_setup, 753 .write_done = nfs_write_done, 754 .commit_setup = nfs_proc_commit_setup, 755 .commit_rpc_prepare = nfs_proc_commit_rpc_prepare, 756 .lock = nfs_proc_lock, 757 .lock_check_bounds = nfs_lock_check_bounds, 758 .close_context = nfs_close_context, 759 .have_delegation = nfs_have_delegation, 760 .alloc_client = nfs_alloc_client, 761 .init_client = nfs_init_client, 762 .free_client = nfs_free_client, 763 .create_server = nfs_create_server, 764 .clone_server = nfs_clone_server, 765 }; 766