1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * This file contains vfs inode ops for the 9P2000 protocol. 4 * 5 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 6 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 */ 8 9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10 11 #include <linux/module.h> 12 #include <linux/errno.h> 13 #include <linux/fs.h> 14 #include <linux/file.h> 15 #include <linux/pagemap.h> 16 #include <linux/stat.h> 17 #include <linux/string.h> 18 #include <linux/namei.h> 19 #include <linux/sched.h> 20 #include <linux/slab.h> 21 #include <linux/xattr.h> 22 #include <linux/posix_acl.h> 23 #include <net/9p/9p.h> 24 #include <net/9p/client.h> 25 26 #include "v9fs.h" 27 #include "v9fs_vfs.h" 28 #include "fid.h" 29 #include "cache.h" 30 #include "xattr.h" 31 #include "acl.h" 32 33 static const struct inode_operations v9fs_dir_inode_operations; 34 static const struct inode_operations v9fs_dir_inode_operations_dotu; 35 static const struct inode_operations v9fs_file_inode_operations; 36 static const struct inode_operations v9fs_symlink_inode_operations; 37 38 /** 39 * unixmode2p9mode - convert unix mode bits to plan 9 40 * @v9ses: v9fs session information 41 * @mode: mode to convert 42 * 43 */ 44 45 static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, umode_t mode) 46 { 47 int res; 48 49 res = mode & 0777; 50 if (S_ISDIR(mode)) 51 res |= P9_DMDIR; 52 if (v9fs_proto_dotu(v9ses)) { 53 if (v9ses->nodev == 0) { 54 if (S_ISSOCK(mode)) 55 res |= P9_DMSOCKET; 56 if (S_ISFIFO(mode)) 57 res |= P9_DMNAMEDPIPE; 58 if (S_ISBLK(mode)) 59 res |= P9_DMDEVICE; 60 if (S_ISCHR(mode)) 61 res |= P9_DMDEVICE; 62 } 63 64 if ((mode & S_ISUID) == S_ISUID) 65 res |= P9_DMSETUID; 66 if ((mode & S_ISGID) == S_ISGID) 67 res |= P9_DMSETGID; 68 if ((mode & S_ISVTX) == S_ISVTX) 69 res |= P9_DMSETVTX; 70 } 71 return res; 72 } 73 74 /** 75 * p9mode2perm- convert plan9 mode bits to unix permission bits 76 * @v9ses: v9fs session information 77 * @stat: p9_wstat from which mode need to be derived 78 * 79 */ 80 static int p9mode2perm(struct v9fs_session_info *v9ses, 81 struct p9_wstat *stat) 82 { 83 int res; 84 int mode = stat->mode; 85 86 res = mode & 0777; /* S_IRWXUGO */ 87 if (v9fs_proto_dotu(v9ses)) { 88 if ((mode & P9_DMSETUID) == P9_DMSETUID) 89 res |= S_ISUID; 90 91 if ((mode & P9_DMSETGID) == P9_DMSETGID) 92 res |= S_ISGID; 93 94 if ((mode & P9_DMSETVTX) == P9_DMSETVTX) 95 res |= S_ISVTX; 96 } 97 return res; 98 } 99 100 /** 101 * p9mode2unixmode- convert plan9 mode bits to unix mode bits 102 * @v9ses: v9fs session information 103 * @stat: p9_wstat from which mode need to be derived 104 * @rdev: major number, minor number in case of device files. 105 * 106 */ 107 static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses, 108 struct p9_wstat *stat, dev_t *rdev) 109 { 110 int res, r; 111 u32 mode = stat->mode; 112 113 *rdev = 0; 114 res = p9mode2perm(v9ses, stat); 115 116 if ((mode & P9_DMDIR) == P9_DMDIR) 117 res |= S_IFDIR; 118 else if ((mode & P9_DMSYMLINK) && (v9fs_proto_dotu(v9ses))) 119 res |= S_IFLNK; 120 else if ((mode & P9_DMSOCKET) && (v9fs_proto_dotu(v9ses)) 121 && (v9ses->nodev == 0)) 122 res |= S_IFSOCK; 123 else if ((mode & P9_DMNAMEDPIPE) && (v9fs_proto_dotu(v9ses)) 124 && (v9ses->nodev == 0)) 125 res |= S_IFIFO; 126 else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses)) 127 && (v9ses->nodev == 0)) { 128 char type = 0; 129 int major = -1, minor = -1; 130 131 r = sscanf(stat->extension, "%c %i %i", &type, &major, &minor); 132 if (r != 3) { 133 p9_debug(P9_DEBUG_ERROR, 134 "invalid device string, umode will be bogus: %s\n", 135 stat->extension); 136 return res; 137 } 138 switch (type) { 139 case 'c': 140 res |= S_IFCHR; 141 break; 142 case 'b': 143 res |= S_IFBLK; 144 break; 145 default: 146 p9_debug(P9_DEBUG_ERROR, "Unknown special type %c %s\n", 147 type, stat->extension); 148 } 149 *rdev = MKDEV(major, minor); 150 } else 151 res |= S_IFREG; 152 153 return res; 154 } 155 156 /** 157 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits 158 * @uflags: flags to convert 159 * @extended: if .u extensions are active 160 */ 161 162 int v9fs_uflags2omode(int uflags, int extended) 163 { 164 int ret; 165 166 switch (uflags&3) { 167 default: 168 case O_RDONLY: 169 ret = P9_OREAD; 170 break; 171 172 case O_WRONLY: 173 ret = P9_OWRITE; 174 break; 175 176 case O_RDWR: 177 ret = P9_ORDWR; 178 break; 179 } 180 181 if (uflags & O_TRUNC) 182 ret |= P9_OTRUNC; 183 184 if (extended) { 185 if (uflags & O_EXCL) 186 ret |= P9_OEXCL; 187 188 if (uflags & O_APPEND) 189 ret |= P9_OAPPEND; 190 } 191 192 return ret; 193 } 194 195 /** 196 * v9fs_blank_wstat - helper function to setup a 9P stat structure 197 * @wstat: structure to initialize 198 * 199 */ 200 201 void 202 v9fs_blank_wstat(struct p9_wstat *wstat) 203 { 204 wstat->type = ~0; 205 wstat->dev = ~0; 206 wstat->qid.type = ~0; 207 wstat->qid.version = ~0; 208 *((long long *)&wstat->qid.path) = ~0; 209 wstat->mode = ~0; 210 wstat->atime = ~0; 211 wstat->mtime = ~0; 212 wstat->length = ~0; 213 wstat->name = NULL; 214 wstat->uid = NULL; 215 wstat->gid = NULL; 216 wstat->muid = NULL; 217 wstat->n_uid = INVALID_UID; 218 wstat->n_gid = INVALID_GID; 219 wstat->n_muid = INVALID_UID; 220 wstat->extension = NULL; 221 } 222 223 /** 224 * v9fs_alloc_inode - helper function to allocate an inode 225 * @sb: The superblock to allocate the inode from 226 */ 227 struct inode *v9fs_alloc_inode(struct super_block *sb) 228 { 229 struct v9fs_inode *v9inode; 230 231 v9inode = alloc_inode_sb(sb, v9fs_inode_cache, GFP_KERNEL); 232 if (!v9inode) 233 return NULL; 234 v9inode->cache_validity = 0; 235 mutex_init(&v9inode->v_mutex); 236 return &v9inode->netfs.inode; 237 } 238 239 /** 240 * v9fs_free_inode - destroy an inode 241 * @inode: The inode to be freed 242 */ 243 244 void v9fs_free_inode(struct inode *inode) 245 { 246 kmem_cache_free(v9fs_inode_cache, V9FS_I(inode)); 247 } 248 249 /* 250 * Set parameters for the netfs library 251 */ 252 void v9fs_set_netfs_context(struct inode *inode) 253 { 254 struct v9fs_inode *v9inode = V9FS_I(inode); 255 netfs_inode_init(&v9inode->netfs, &v9fs_req_ops, true); 256 } 257 258 int v9fs_init_inode(struct v9fs_session_info *v9ses, 259 struct inode *inode, umode_t mode, dev_t rdev) 260 { 261 int err = 0; 262 263 inode_init_owner(&nop_mnt_idmap, inode, NULL, mode); 264 inode->i_blocks = 0; 265 inode->i_rdev = rdev; 266 simple_inode_init_ts(inode); 267 inode->i_mapping->a_ops = &v9fs_addr_operations; 268 inode->i_private = NULL; 269 270 switch (mode & S_IFMT) { 271 case S_IFIFO: 272 case S_IFBLK: 273 case S_IFCHR: 274 case S_IFSOCK: 275 if (v9fs_proto_dotl(v9ses)) { 276 inode->i_op = &v9fs_file_inode_operations_dotl; 277 } else if (v9fs_proto_dotu(v9ses)) { 278 inode->i_op = &v9fs_file_inode_operations; 279 } else { 280 p9_debug(P9_DEBUG_ERROR, 281 "special files without extended mode\n"); 282 err = -EINVAL; 283 goto error; 284 } 285 init_special_inode(inode, inode->i_mode, inode->i_rdev); 286 break; 287 case S_IFREG: 288 if (v9fs_proto_dotl(v9ses)) { 289 inode->i_op = &v9fs_file_inode_operations_dotl; 290 inode->i_fop = &v9fs_file_operations_dotl; 291 } else { 292 inode->i_op = &v9fs_file_inode_operations; 293 inode->i_fop = &v9fs_file_operations; 294 } 295 296 break; 297 case S_IFLNK: 298 if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) { 299 p9_debug(P9_DEBUG_ERROR, 300 "extended modes used with legacy protocol\n"); 301 err = -EINVAL; 302 goto error; 303 } 304 305 if (v9fs_proto_dotl(v9ses)) { 306 inode->i_op = &v9fs_symlink_inode_operations_dotl; 307 inode_nohighmem(inode); 308 } else { 309 inode->i_op = &v9fs_symlink_inode_operations; 310 } 311 312 break; 313 case S_IFDIR: 314 inc_nlink(inode); 315 if (v9fs_proto_dotl(v9ses)) 316 inode->i_op = &v9fs_dir_inode_operations_dotl; 317 else if (v9fs_proto_dotu(v9ses)) 318 inode->i_op = &v9fs_dir_inode_operations_dotu; 319 else 320 inode->i_op = &v9fs_dir_inode_operations; 321 322 if (v9fs_proto_dotl(v9ses)) 323 inode->i_fop = &v9fs_dir_operations_dotl; 324 else 325 inode->i_fop = &v9fs_dir_operations; 326 327 break; 328 default: 329 p9_debug(P9_DEBUG_ERROR, "BAD mode 0x%hx S_IFMT 0x%x\n", 330 mode, mode & S_IFMT); 331 err = -EINVAL; 332 goto error; 333 } 334 error: 335 return err; 336 337 } 338 339 /** 340 * v9fs_evict_inode - Remove an inode from the inode cache 341 * @inode: inode to release 342 * 343 */ 344 void v9fs_evict_inode(struct inode *inode) 345 { 346 struct v9fs_inode __maybe_unused *v9inode = V9FS_I(inode); 347 __le32 __maybe_unused version; 348 349 if (!is_bad_inode(inode)) { 350 netfs_wait_for_outstanding_io(inode); 351 truncate_inode_pages_final(&inode->i_data); 352 353 version = cpu_to_le32(v9inode->qid.version); 354 netfs_clear_inode_writeback(inode, &version); 355 356 clear_inode(inode); 357 filemap_fdatawrite(&inode->i_data); 358 359 #ifdef CONFIG_9P_FSCACHE 360 if (v9fs_inode_cookie(v9inode)) 361 fscache_relinquish_cookie(v9fs_inode_cookie(v9inode), false); 362 #endif 363 } else 364 clear_inode(inode); 365 } 366 367 static int v9fs_test_inode(struct inode *inode, void *data) 368 { 369 int umode; 370 dev_t rdev; 371 struct v9fs_inode *v9inode = V9FS_I(inode); 372 struct p9_wstat *st = (struct p9_wstat *)data; 373 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); 374 375 umode = p9mode2unixmode(v9ses, st, &rdev); 376 /* don't match inode of different type */ 377 if (inode_wrong_type(inode, umode)) 378 return 0; 379 380 /* compare qid details */ 381 if (memcmp(&v9inode->qid.version, 382 &st->qid.version, sizeof(v9inode->qid.version))) 383 return 0; 384 385 if (v9inode->qid.type != st->qid.type) 386 return 0; 387 388 if (v9inode->qid.path != st->qid.path) 389 return 0; 390 return 1; 391 } 392 393 static int v9fs_test_new_inode(struct inode *inode, void *data) 394 { 395 return 0; 396 } 397 398 static int v9fs_set_inode(struct inode *inode, void *data) 399 { 400 struct v9fs_inode *v9inode = V9FS_I(inode); 401 struct p9_wstat *st = (struct p9_wstat *)data; 402 403 memcpy(&v9inode->qid, &st->qid, sizeof(st->qid)); 404 return 0; 405 } 406 407 static struct inode *v9fs_qid_iget(struct super_block *sb, 408 struct p9_qid *qid, 409 struct p9_wstat *st, 410 int new) 411 { 412 dev_t rdev; 413 int retval; 414 umode_t umode; 415 struct inode *inode; 416 struct v9fs_session_info *v9ses = sb->s_fs_info; 417 int (*test)(struct inode *inode, void *data); 418 419 if (new) 420 test = v9fs_test_new_inode; 421 else 422 test = v9fs_test_inode; 423 424 inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st); 425 if (!inode) 426 return ERR_PTR(-ENOMEM); 427 if (!(inode_state_read_once(inode) & I_NEW)) 428 return inode; 429 /* 430 * initialize the inode with the stat info 431 * FIXME!! we may need support for stale inodes 432 * later. 433 */ 434 inode->i_ino = QID2INO(qid); 435 umode = p9mode2unixmode(v9ses, st, &rdev); 436 retval = v9fs_init_inode(v9ses, inode, umode, rdev); 437 if (retval) 438 goto error; 439 440 v9fs_stat2inode(st, inode, sb, 0); 441 v9fs_set_netfs_context(inode); 442 v9fs_cache_inode_get_cookie(inode); 443 unlock_new_inode(inode); 444 return inode; 445 error: 446 iget_failed(inode); 447 return ERR_PTR(retval); 448 449 } 450 451 struct inode * 452 v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, 453 struct super_block *sb, int new) 454 { 455 struct p9_wstat *st; 456 struct inode *inode = NULL; 457 458 st = p9_client_stat(fid); 459 if (IS_ERR(st)) 460 return ERR_CAST(st); 461 462 inode = v9fs_qid_iget(sb, &st->qid, st, new); 463 p9stat_free(st); 464 kfree(st); 465 return inode; 466 } 467 468 /** 469 * v9fs_at_to_dotl_flags- convert Linux specific AT flags to 470 * plan 9 AT flag. 471 * @flags: flags to convert 472 */ 473 static int v9fs_at_to_dotl_flags(int flags) 474 { 475 int rflags = 0; 476 477 if (flags & AT_REMOVEDIR) 478 rflags |= P9_DOTL_AT_REMOVEDIR; 479 480 return rflags; 481 } 482 483 /** 484 * v9fs_dec_count - helper functon to drop i_nlink. 485 * 486 * If a directory had nlink <= 2 (including . and ..), then we should not drop 487 * the link count, which indicates the underlying exported fs doesn't maintain 488 * nlink accurately. e.g. 489 * - overlayfs sets nlink to 1 for merged dir 490 * - ext4 (with dir_nlink feature enabled) sets nlink to 1 if a dir has more 491 * than EXT4_LINK_MAX (65000) links. 492 * 493 * In cacheless mode the server is the source of truth for nlink and the 494 * inode is going away immediately, so locally adjusting i_nlink buys 495 * nothing and races with concurrent metadata fetches that may already 496 * have observed the post-unlink value (nlink == 0). 497 * 498 * @inode: inode whose nlink is being dropped 499 */ 500 static void v9fs_dec_count(struct inode *inode) 501 { 502 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); 503 504 if (!(v9ses->cache & (CACHE_META | CACHE_LOOSE))) 505 return; 506 if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2) 507 drop_nlink(inode); 508 } 509 510 /** 511 * v9fs_remove - helper function to remove files and directories 512 * @dir: directory inode that is being deleted 513 * @dentry: dentry that is being deleted 514 * @flags: removing a directory 515 * 516 */ 517 518 static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags) 519 { 520 struct inode *inode; 521 int retval = -EOPNOTSUPP; 522 struct p9_fid *v9fid, *dfid; 523 struct v9fs_session_info *v9ses; 524 525 p9_debug(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %x\n", 526 dir, dentry, flags); 527 528 v9ses = v9fs_inode2v9ses(dir); 529 inode = d_inode(dentry); 530 dfid = v9fs_parent_fid(dentry); 531 if (IS_ERR(dfid)) { 532 retval = PTR_ERR(dfid); 533 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", retval); 534 return retval; 535 } 536 if (v9fs_proto_dotl(v9ses)) 537 retval = p9_client_unlinkat(dfid, dentry->d_name.name, 538 v9fs_at_to_dotl_flags(flags)); 539 p9_fid_put(dfid); 540 if (retval == -EOPNOTSUPP) { 541 /* Try the one based on path */ 542 v9fid = v9fs_fid_clone(dentry); 543 if (IS_ERR(v9fid)) 544 return PTR_ERR(v9fid); 545 retval = p9_client_remove(v9fid); 546 } 547 if (!retval) { 548 /* 549 * directories on unlink should have zero 550 * link count 551 */ 552 if (flags & AT_REMOVEDIR) { 553 clear_nlink(inode); 554 v9fs_dec_count(dir); 555 } else 556 v9fs_dec_count(inode); 557 558 v9fs_invalidate_inode_attr(inode); 559 v9fs_invalidate_inode_attr(dir); 560 561 /* invalidate all fids associated with dentry */ 562 /* NOTE: This will not include open fids */ 563 v9fs_dentry_fid_remove(dentry); 564 } 565 return retval; 566 } 567 568 /** 569 * v9fs_create - Create a file 570 * @v9ses: session information 571 * @dir: directory that dentry is being created in 572 * @dentry: dentry that is being created 573 * @extension: 9p2000.u extension string to support devices, etc. 574 * @perm: create permissions 575 * @mode: open mode 576 * 577 */ 578 static struct p9_fid * 579 v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, 580 struct dentry *dentry, char *extension, u32 perm, u8 mode) 581 { 582 int err; 583 const unsigned char *name; 584 struct p9_fid *dfid, *ofid = NULL, *fid = NULL; 585 struct inode *inode; 586 587 p9_debug(P9_DEBUG_VFS, "name %pd\n", dentry); 588 589 name = dentry->d_name.name; 590 dfid = v9fs_parent_fid(dentry); 591 if (IS_ERR(dfid)) { 592 err = PTR_ERR(dfid); 593 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err); 594 return ERR_PTR(err); 595 } 596 597 /* clone a fid to use for creation */ 598 ofid = clone_fid(dfid); 599 if (IS_ERR(ofid)) { 600 err = PTR_ERR(ofid); 601 p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 602 goto error; 603 } 604 605 err = p9_client_fcreate(ofid, name, perm, mode, extension); 606 if (err < 0) { 607 p9_debug(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err); 608 goto error; 609 } 610 611 if (!(perm & P9_DMLINK)) { 612 /* now walk from the parent so we can get unopened fid */ 613 fid = p9_client_walk(dfid, 1, &name, 1); 614 if (IS_ERR(fid)) { 615 err = PTR_ERR(fid); 616 p9_debug(P9_DEBUG_VFS, 617 "p9_client_walk failed %d\n", err); 618 goto error; 619 } 620 /* 621 * instantiate inode and assign the unopened fid to the dentry 622 */ 623 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 624 if (IS_ERR(inode)) { 625 err = PTR_ERR(inode); 626 p9_debug(P9_DEBUG_VFS, 627 "inode creation failed %d\n", err); 628 goto error; 629 } 630 v9fs_fid_add(dentry, &fid); 631 d_instantiate(dentry, inode); 632 } 633 p9_fid_put(dfid); 634 return ofid; 635 error: 636 p9_fid_put(dfid); 637 p9_fid_put(ofid); 638 p9_fid_put(fid); 639 return ERR_PTR(err); 640 } 641 642 /** 643 * v9fs_vfs_create - VFS hook to create a regular file 644 * @idmap: idmap of the mount 645 * @dir: The parent directory 646 * @dentry: The name of file to be created 647 * @mode: The UNIX file mode to set 648 * @excl: True if the file must not yet exist 649 * 650 * open(.., O_CREAT) is handled in v9fs_vfs_atomic_open(). This is only called 651 * for mknod(2). 652 * 653 */ 654 655 static int 656 v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir, 657 struct dentry *dentry, umode_t mode, bool excl) 658 { 659 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); 660 u32 perm = unixmode2p9mode(v9ses, mode); 661 struct p9_fid *fid; 662 663 /* P9_OEXCL? */ 664 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, P9_ORDWR); 665 if (IS_ERR(fid)) 666 return PTR_ERR(fid); 667 668 v9fs_invalidate_inode_attr(dir); 669 p9_fid_put(fid); 670 671 return 0; 672 } 673 674 /** 675 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory 676 * @idmap: idmap of the mount 677 * @dir: inode that is being unlinked 678 * @dentry: dentry that is being unlinked 679 * @mode: mode for new directory 680 * 681 */ 682 683 static struct dentry *v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 684 struct dentry *dentry, umode_t mode) 685 { 686 u32 perm; 687 struct p9_fid *fid; 688 struct v9fs_session_info *v9ses; 689 690 p9_debug(P9_DEBUG_VFS, "name %pd\n", dentry); 691 v9ses = v9fs_inode2v9ses(dir); 692 perm = unixmode2p9mode(v9ses, mode | S_IFDIR); 693 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, P9_OREAD); 694 if (IS_ERR(fid)) 695 return ERR_CAST(fid); 696 inc_nlink(dir); 697 v9fs_invalidate_inode_attr(dir); 698 p9_fid_put(fid); 699 return NULL; 700 } 701 702 /** 703 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode 704 * @dir: inode that is being walked from 705 * @dentry: dentry that is being walked to? 706 * @flags: lookup flags (unused) 707 * 708 */ 709 710 struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, 711 unsigned int flags) 712 { 713 struct dentry *res; 714 struct v9fs_session_info *v9ses; 715 struct p9_fid *dfid, *fid; 716 struct inode *inode; 717 const unsigned char *name; 718 719 p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%pd) %p flags: %x\n", 720 dir, dentry, dentry, flags); 721 722 if (dentry->d_name.len > NAME_MAX) 723 return ERR_PTR(-ENAMETOOLONG); 724 725 v9ses = v9fs_inode2v9ses(dir); 726 /* We can walk d_parent because we hold the dir->i_mutex */ 727 dfid = v9fs_parent_fid(dentry); 728 if (IS_ERR(dfid)) 729 return ERR_CAST(dfid); 730 731 /* 732 * Make sure we don't use a wrong inode due to parallel 733 * unlink. For cached mode create calls request for new 734 * inode. But with cache disabled, lookup should do this. 735 */ 736 name = dentry->d_name.name; 737 fid = p9_client_walk(dfid, 1, &name, 1); 738 p9_fid_put(dfid); 739 if (fid == ERR_PTR(-ENOENT)) { 740 inode = NULL; 741 v9fs_ndentry_refresh_timeout(dentry); 742 } else if (IS_ERR(fid)) { 743 inode = ERR_CAST(fid); 744 } else if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) { 745 inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); 746 } else { 747 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 748 } 749 /* 750 * If we had a rename on the server and a parallel lookup 751 * for the new name, then make sure we instantiate with 752 * the new name. ie look up for a/b, while on server somebody 753 * moved b under k and client parallely did a lookup for 754 * k/b. 755 */ 756 res = d_splice_alias(inode, dentry); 757 if (!IS_ERR(fid)) { 758 if (!res) 759 v9fs_fid_add(dentry, &fid); 760 else if (!IS_ERR(res)) 761 v9fs_fid_add(res, &fid); 762 else 763 p9_fid_put(fid); 764 } 765 return res; 766 } 767 768 static int 769 v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, 770 struct file *file, unsigned int flags, umode_t mode) 771 { 772 int err; 773 u32 perm; 774 struct v9fs_inode __maybe_unused *v9inode; 775 struct v9fs_session_info *v9ses; 776 struct p9_fid *fid; 777 struct inode *inode; 778 int p9_omode; 779 780 if (d_in_lookup(dentry)) { 781 struct dentry *res = v9fs_vfs_lookup(dir, dentry, 0); 782 if (res || d_really_is_positive(dentry)) 783 return finish_no_open(file, res); 784 } 785 786 /* Only creates */ 787 if (!(flags & O_CREAT)) 788 return finish_no_open(file, NULL); 789 790 v9ses = v9fs_inode2v9ses(dir); 791 perm = unixmode2p9mode(v9ses, mode); 792 p9_omode = v9fs_uflags2omode(flags, v9fs_proto_dotu(v9ses)); 793 794 if ((v9ses->cache & CACHE_WRITEBACK) && (p9_omode & P9_OWRITE)) { 795 p9_omode = (p9_omode & ~(P9_OWRITE | P9_OAPPEND)) | P9_ORDWR; 796 p9_debug(P9_DEBUG_CACHE, 797 "write-only file with writeback enabled, creating w/ O_RDWR\n"); 798 } 799 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, p9_omode); 800 if (IS_ERR(fid)) 801 return PTR_ERR(fid); 802 803 v9fs_invalidate_inode_attr(dir); 804 inode = d_inode(dentry); 805 v9inode = V9FS_I(inode); 806 err = finish_open(file, dentry, generic_file_open); 807 if (unlikely(err)) { 808 p9_fid_put(fid); 809 return err; 810 } 811 812 file->private_data = fid; 813 #ifdef CONFIG_9P_FSCACHE 814 if (v9ses->cache & CACHE_FSCACHE) 815 fscache_use_cookie(v9fs_inode_cookie(v9inode), 816 file->f_mode & FMODE_WRITE); 817 #endif 818 819 v9fs_fid_add_modes(fid, v9ses->flags, v9ses->cache, file->f_flags); 820 v9fs_open_fid_add(inode, &fid); 821 822 file->f_mode |= FMODE_CREATED; 823 return 0; 824 } 825 826 /** 827 * v9fs_vfs_unlink - VFS unlink hook to delete an inode 828 * @i: inode that is being unlinked 829 * @d: dentry that is being unlinked 830 * 831 */ 832 833 int v9fs_vfs_unlink(struct inode *i, struct dentry *d) 834 { 835 return v9fs_remove(i, d, 0); 836 } 837 838 /** 839 * v9fs_vfs_rmdir - VFS unlink hook to delete a directory 840 * @i: inode that is being unlinked 841 * @d: dentry that is being unlinked 842 * 843 */ 844 845 int v9fs_vfs_rmdir(struct inode *i, struct dentry *d) 846 { 847 return v9fs_remove(i, d, AT_REMOVEDIR); 848 } 849 850 /** 851 * v9fs_vfs_rename - VFS hook to rename an inode 852 * @idmap: The idmap of the mount 853 * @old_dir: old dir inode 854 * @old_dentry: old dentry 855 * @new_dir: new dir inode 856 * @new_dentry: new dentry 857 * @flags: RENAME_* flags 858 * 859 */ 860 861 int 862 v9fs_vfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, 863 struct dentry *old_dentry, struct inode *new_dir, 864 struct dentry *new_dentry, unsigned int flags) 865 { 866 int retval; 867 struct inode *old_inode; 868 struct inode *new_inode; 869 struct v9fs_session_info *v9ses; 870 struct p9_fid *oldfid = NULL, *dfid = NULL; 871 struct p9_fid *olddirfid = NULL; 872 struct p9_fid *newdirfid = NULL; 873 struct p9_wstat wstat; 874 875 if (flags) 876 return -EINVAL; 877 878 p9_debug(P9_DEBUG_VFS, "\n"); 879 old_inode = d_inode(old_dentry); 880 new_inode = d_inode(new_dentry); 881 v9ses = v9fs_inode2v9ses(old_inode); 882 oldfid = v9fs_fid_lookup(old_dentry); 883 if (IS_ERR(oldfid)) 884 return PTR_ERR(oldfid); 885 886 dfid = v9fs_parent_fid(old_dentry); 887 olddirfid = clone_fid(dfid); 888 p9_fid_put(dfid); 889 dfid = NULL; 890 891 if (IS_ERR(olddirfid)) { 892 retval = PTR_ERR(olddirfid); 893 goto error; 894 } 895 896 dfid = v9fs_parent_fid(new_dentry); 897 newdirfid = clone_fid(dfid); 898 p9_fid_put(dfid); 899 dfid = NULL; 900 901 if (IS_ERR(newdirfid)) { 902 retval = PTR_ERR(newdirfid); 903 goto error; 904 } 905 906 down_write(&v9ses->rename_sem); 907 if (v9fs_proto_dotl(v9ses)) { 908 retval = p9_client_renameat(olddirfid, old_dentry->d_name.name, 909 newdirfid, new_dentry->d_name.name); 910 if (retval == -EOPNOTSUPP) 911 retval = p9_client_rename(oldfid, newdirfid, 912 new_dentry->d_name.name); 913 if (retval != -EOPNOTSUPP) 914 goto error_locked; 915 } 916 if (old_dentry->d_parent != new_dentry->d_parent) { 917 /* 918 * 9P .u can only handle file rename in the same directory 919 */ 920 921 p9_debug(P9_DEBUG_ERROR, "old dir and new dir are different\n"); 922 retval = -EXDEV; 923 goto error_locked; 924 } 925 v9fs_blank_wstat(&wstat); 926 wstat.muid = v9ses->uname; 927 wstat.name = new_dentry->d_name.name; 928 retval = p9_client_wstat(oldfid, &wstat); 929 930 error_locked: 931 if (!retval) { 932 if (new_inode) { 933 if (S_ISDIR(new_inode->i_mode)) 934 clear_nlink(new_inode); 935 else 936 v9fs_dec_count(new_inode); 937 } 938 if (S_ISDIR(old_inode->i_mode)) { 939 if (!new_inode) 940 inc_nlink(new_dir); 941 v9fs_dec_count(old_dir); 942 } 943 v9fs_invalidate_inode_attr(old_inode); 944 v9fs_invalidate_inode_attr(old_dir); 945 v9fs_invalidate_inode_attr(new_dir); 946 947 /* successful rename */ 948 d_move(old_dentry, new_dentry); 949 } 950 up_write(&v9ses->rename_sem); 951 952 error: 953 p9_fid_put(newdirfid); 954 p9_fid_put(olddirfid); 955 p9_fid_put(oldfid); 956 return retval; 957 } 958 959 /** 960 * v9fs_vfs_getattr - retrieve file metadata 961 * @idmap: idmap of the mount 962 * @path: Object to query 963 * @stat: metadata structure to populate 964 * @request_mask: Mask of STATX_xxx flags indicating the caller's interests 965 * @flags: AT_STATX_xxx setting 966 * 967 */ 968 969 static int 970 v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path, 971 struct kstat *stat, u32 request_mask, unsigned int flags) 972 { 973 struct dentry *dentry = path->dentry; 974 struct inode *inode = d_inode(dentry); 975 struct v9fs_session_info *v9ses; 976 struct p9_fid *fid; 977 struct p9_wstat *st; 978 979 p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); 980 v9ses = v9fs_dentry2v9ses(dentry); 981 if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) { 982 generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat); 983 return 0; 984 } else if (v9ses->cache & CACHE_WRITEBACK) { 985 if (S_ISREG(inode->i_mode)) { 986 int retval = filemap_fdatawrite(inode->i_mapping); 987 988 if (retval) 989 p9_debug(P9_DEBUG_ERROR, 990 "flushing writeback during getattr returned %d\n", retval); 991 } 992 } 993 fid = v9fs_fid_lookup(dentry); 994 if (IS_ERR(fid)) 995 return PTR_ERR(fid); 996 997 st = p9_client_stat(fid); 998 p9_fid_put(fid); 999 if (IS_ERR(st)) 1000 return PTR_ERR(st); 1001 1002 v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb, 0); 1003 generic_fillattr(&nop_mnt_idmap, request_mask, d_inode(dentry), stat); 1004 1005 p9stat_free(st); 1006 kfree(st); 1007 return 0; 1008 } 1009 1010 /** 1011 * v9fs_vfs_setattr - set file metadata 1012 * @idmap: idmap of the mount 1013 * @dentry: file whose metadata to set 1014 * @iattr: metadata assignment structure 1015 * 1016 */ 1017 1018 static int v9fs_vfs_setattr(struct mnt_idmap *idmap, 1019 struct dentry *dentry, struct iattr *iattr) 1020 { 1021 int retval, use_dentry = 0; 1022 struct inode *inode = d_inode(dentry); 1023 struct v9fs_session_info *v9ses; 1024 struct p9_fid *fid = NULL; 1025 struct p9_wstat wstat; 1026 1027 p9_debug(P9_DEBUG_VFS, "\n"); 1028 retval = setattr_prepare(&nop_mnt_idmap, dentry, iattr); 1029 if (retval) 1030 return retval; 1031 1032 v9ses = v9fs_dentry2v9ses(dentry); 1033 if (iattr->ia_valid & ATTR_FILE) { 1034 fid = iattr->ia_file->private_data; 1035 WARN_ON(!fid); 1036 } 1037 if (!fid) { 1038 fid = v9fs_fid_lookup(dentry); 1039 use_dentry = 1; 1040 } 1041 if (IS_ERR(fid)) 1042 return PTR_ERR(fid); 1043 1044 v9fs_blank_wstat(&wstat); 1045 if (iattr->ia_valid & ATTR_MODE) 1046 wstat.mode = unixmode2p9mode(v9ses, iattr->ia_mode); 1047 1048 if (iattr->ia_valid & ATTR_MTIME) 1049 wstat.mtime = iattr->ia_mtime.tv_sec; 1050 1051 if (iattr->ia_valid & ATTR_ATIME) 1052 wstat.atime = iattr->ia_atime.tv_sec; 1053 1054 if (iattr->ia_valid & ATTR_SIZE) 1055 wstat.length = iattr->ia_size; 1056 1057 if (v9fs_proto_dotu(v9ses)) { 1058 if (iattr->ia_valid & ATTR_UID) 1059 wstat.n_uid = iattr->ia_uid; 1060 1061 if (iattr->ia_valid & ATTR_GID) 1062 wstat.n_gid = iattr->ia_gid; 1063 } 1064 1065 /* Write all dirty data */ 1066 if (d_is_reg(dentry)) { 1067 retval = filemap_fdatawrite(inode->i_mapping); 1068 if (retval) 1069 p9_debug(P9_DEBUG_ERROR, 1070 "flushing writeback during setattr returned %d\n", retval); 1071 } 1072 1073 retval = p9_client_wstat(fid, &wstat); 1074 1075 if (use_dentry) 1076 p9_fid_put(fid); 1077 1078 if (retval < 0) 1079 return retval; 1080 1081 if ((iattr->ia_valid & ATTR_SIZE) && 1082 iattr->ia_size != i_size_read(inode)) { 1083 truncate_setsize(inode, iattr->ia_size); 1084 netfs_resize_file(netfs_inode(inode), iattr->ia_size, true); 1085 1086 #ifdef CONFIG_9P_FSCACHE 1087 if (v9ses->cache & CACHE_FSCACHE) { 1088 struct v9fs_inode *v9inode = V9FS_I(inode); 1089 1090 fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); 1091 } 1092 #endif 1093 } 1094 1095 v9fs_invalidate_inode_attr(inode); 1096 1097 setattr_copy(&nop_mnt_idmap, inode, iattr); 1098 mark_inode_dirty(inode); 1099 return 0; 1100 } 1101 1102 /** 1103 * v9fs_stat2inode - populate an inode structure with mistat info 1104 * @stat: Plan 9 metadata (mistat) structure 1105 * @inode: inode to populate 1106 * @sb: superblock of filesystem 1107 * @flags: control flags (e.g. V9FS_STAT2INODE_KEEP_ISIZE) 1108 * 1109 */ 1110 1111 void 1112 v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, 1113 struct super_block *sb, unsigned int flags) 1114 { 1115 umode_t mode; 1116 struct v9fs_session_info *v9ses = sb->s_fs_info; 1117 struct v9fs_inode *v9inode = V9FS_I(inode); 1118 1119 inode_set_atime(inode, stat->atime, 0); 1120 inode_set_mtime(inode, stat->mtime, 0); 1121 inode_set_ctime(inode, stat->mtime, 0); 1122 1123 inode->i_uid = v9ses->dfltuid; 1124 inode->i_gid = v9ses->dfltgid; 1125 1126 if (v9fs_proto_dotu(v9ses)) { 1127 inode->i_uid = stat->n_uid; 1128 inode->i_gid = stat->n_gid; 1129 } 1130 if ((S_ISREG(inode->i_mode)) || (S_ISDIR(inode->i_mode))) { 1131 if (v9fs_proto_dotu(v9ses)) { 1132 unsigned int i_nlink; 1133 /* 1134 * Hadlink support got added later to the .u extension. 1135 * So there can be a server out there that doesn't 1136 * support this even with .u extension. That would 1137 * just leave us with stat->extension being an empty 1138 * string, though. 1139 */ 1140 /* HARDLINKCOUNT %u */ 1141 if (sscanf(stat->extension, 1142 " HARDLINKCOUNT %u", &i_nlink) == 1) 1143 set_nlink(inode, i_nlink); 1144 } 1145 } 1146 mode = p9mode2perm(v9ses, stat); 1147 mode |= inode->i_mode & ~S_IALLUGO; 1148 inode->i_mode = mode; 1149 1150 spin_lock(&inode->i_lock); 1151 netfs_write_remote_i_size(inode, stat->length); 1152 if (!(flags & V9FS_STAT2INODE_KEEP_ISIZE)) 1153 i_size_write(inode, stat->length); 1154 /* not real number of blocks, but 512 byte ones ... */ 1155 inode->i_blocks = (stat->length + 512 - 1) >> 9; 1156 spin_unlock(&inode->i_lock); 1157 v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR; 1158 } 1159 1160 /** 1161 * v9fs_vfs_get_link - follow a symlink path 1162 * @dentry: dentry for symlink 1163 * @inode: inode for symlink 1164 * @done: delayed call for when we are done with the return value 1165 */ 1166 1167 static const char *v9fs_vfs_get_link(struct dentry *dentry, 1168 struct inode *inode, 1169 struct delayed_call *done) 1170 { 1171 struct v9fs_session_info *v9ses; 1172 struct p9_fid *fid; 1173 struct p9_wstat *st; 1174 char *res; 1175 1176 if (!dentry) 1177 return ERR_PTR(-ECHILD); 1178 1179 v9ses = v9fs_dentry2v9ses(dentry); 1180 if (!v9fs_proto_dotu(v9ses)) 1181 return ERR_PTR(-EBADF); 1182 1183 p9_debug(P9_DEBUG_VFS, "%pd\n", dentry); 1184 fid = v9fs_fid_lookup(dentry); 1185 1186 if (IS_ERR(fid)) 1187 return ERR_CAST(fid); 1188 1189 st = p9_client_stat(fid); 1190 p9_fid_put(fid); 1191 if (IS_ERR(st)) 1192 return ERR_CAST(st); 1193 1194 if (!(st->mode & P9_DMSYMLINK)) { 1195 p9stat_free(st); 1196 kfree(st); 1197 return ERR_PTR(-EINVAL); 1198 } 1199 res = st->extension; 1200 st->extension = NULL; 1201 if (strlen(res) >= PATH_MAX) 1202 res[PATH_MAX - 1] = '\0'; 1203 1204 p9stat_free(st); 1205 kfree(st); 1206 set_delayed_call(done, kfree_link, res); 1207 return res; 1208 } 1209 1210 /** 1211 * v9fs_vfs_mkspecial - create a special file 1212 * @dir: inode to create special file in 1213 * @dentry: dentry to create 1214 * @perm: mode to create special file 1215 * @extension: 9p2000.u format extension string representing special file 1216 * 1217 */ 1218 1219 static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, 1220 u32 perm, const char *extension) 1221 { 1222 struct p9_fid *fid; 1223 struct v9fs_session_info *v9ses; 1224 1225 v9ses = v9fs_inode2v9ses(dir); 1226 if (!v9fs_proto_dotu(v9ses)) { 1227 p9_debug(P9_DEBUG_ERROR, "not extended\n"); 1228 return -EPERM; 1229 } 1230 1231 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm, 1232 P9_OREAD); 1233 if (IS_ERR(fid)) 1234 return PTR_ERR(fid); 1235 1236 v9fs_invalidate_inode_attr(dir); 1237 p9_fid_put(fid); 1238 return 0; 1239 } 1240 1241 /** 1242 * v9fs_vfs_symlink - helper function to create symlinks 1243 * @idmap: idmap of the mount 1244 * @dir: directory inode containing symlink 1245 * @dentry: dentry for symlink 1246 * @symname: symlink data 1247 * 1248 * See Also: 9P2000.u RFC for more information 1249 * 1250 */ 1251 1252 static int 1253 v9fs_vfs_symlink(struct mnt_idmap *idmap, struct inode *dir, 1254 struct dentry *dentry, const char *symname) 1255 { 1256 p9_debug(P9_DEBUG_VFS, " %llu,%pd,%s\n", 1257 dir->i_ino, dentry, symname); 1258 1259 return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname); 1260 } 1261 1262 #define U32_MAX_DIGITS 10 1263 1264 /** 1265 * v9fs_vfs_link - create a hardlink 1266 * @old_dentry: dentry for file to link to 1267 * @dir: inode destination for new link 1268 * @dentry: dentry for link 1269 * 1270 */ 1271 1272 static int 1273 v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, 1274 struct dentry *dentry) 1275 { 1276 int retval; 1277 char name[1 + U32_MAX_DIGITS + 2]; /* sign + number + \n + \0 */ 1278 struct p9_fid *oldfid; 1279 1280 p9_debug(P9_DEBUG_VFS, " %llu,%pd,%pd\n", 1281 dir->i_ino, dentry, old_dentry); 1282 1283 oldfid = v9fs_fid_clone(old_dentry); 1284 if (IS_ERR(oldfid)) 1285 return PTR_ERR(oldfid); 1286 1287 sprintf(name, "%d\n", oldfid->fid); 1288 retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name); 1289 if (!retval) { 1290 v9fs_refresh_inode(oldfid, d_inode(old_dentry)); 1291 v9fs_invalidate_inode_attr(dir); 1292 } 1293 p9_fid_put(oldfid); 1294 return retval; 1295 } 1296 1297 /** 1298 * v9fs_vfs_mknod - create a special file 1299 * @idmap: idmap of the mount 1300 * @dir: inode destination for new link 1301 * @dentry: dentry for file 1302 * @mode: mode for creation 1303 * @rdev: device associated with special file 1304 * 1305 */ 1306 1307 static int 1308 v9fs_vfs_mknod(struct mnt_idmap *idmap, struct inode *dir, 1309 struct dentry *dentry, umode_t mode, dev_t rdev) 1310 { 1311 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); 1312 int retval; 1313 char name[2 + U32_MAX_DIGITS + 1 + U32_MAX_DIGITS + 1]; 1314 u32 perm; 1315 1316 p9_debug(P9_DEBUG_VFS, " %llu,%pd mode: %x MAJOR: %u MINOR: %u\n", 1317 dir->i_ino, dentry, mode, 1318 MAJOR(rdev), MINOR(rdev)); 1319 1320 /* build extension */ 1321 if (S_ISBLK(mode)) 1322 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev)); 1323 else if (S_ISCHR(mode)) 1324 sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev)); 1325 else 1326 *name = 0; 1327 1328 perm = unixmode2p9mode(v9ses, mode); 1329 retval = v9fs_vfs_mkspecial(dir, dentry, perm, name); 1330 1331 return retval; 1332 } 1333 1334 int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode) 1335 { 1336 int umode; 1337 dev_t rdev; 1338 struct p9_wstat *st; 1339 struct v9fs_session_info *v9ses; 1340 unsigned int flags; 1341 1342 v9ses = v9fs_inode2v9ses(inode); 1343 st = p9_client_stat(fid); 1344 if (IS_ERR(st)) 1345 return PTR_ERR(st); 1346 /* 1347 * Don't update inode if the file type is different 1348 */ 1349 umode = p9mode2unixmode(v9ses, st, &rdev); 1350 if (inode_wrong_type(inode, umode)) 1351 goto out; 1352 1353 /* 1354 * We don't want to refresh inode->i_size, 1355 * because we may have cached data 1356 */ 1357 flags = (v9ses->cache & CACHE_LOOSE) ? 1358 V9FS_STAT2INODE_KEEP_ISIZE : 0; 1359 v9fs_stat2inode(st, inode, inode->i_sb, flags); 1360 out: 1361 p9stat_free(st); 1362 kfree(st); 1363 return 0; 1364 } 1365 1366 static const struct inode_operations v9fs_dir_inode_operations_dotu = { 1367 .create = v9fs_vfs_create, 1368 .lookup = v9fs_vfs_lookup, 1369 .atomic_open = v9fs_vfs_atomic_open, 1370 .symlink = v9fs_vfs_symlink, 1371 .link = v9fs_vfs_link, 1372 .unlink = v9fs_vfs_unlink, 1373 .mkdir = v9fs_vfs_mkdir, 1374 .rmdir = v9fs_vfs_rmdir, 1375 .mknod = v9fs_vfs_mknod, 1376 .rename = v9fs_vfs_rename, 1377 .getattr = v9fs_vfs_getattr, 1378 .setattr = v9fs_vfs_setattr, 1379 }; 1380 1381 static const struct inode_operations v9fs_dir_inode_operations = { 1382 .create = v9fs_vfs_create, 1383 .lookup = v9fs_vfs_lookup, 1384 .atomic_open = v9fs_vfs_atomic_open, 1385 .unlink = v9fs_vfs_unlink, 1386 .mkdir = v9fs_vfs_mkdir, 1387 .rmdir = v9fs_vfs_rmdir, 1388 .mknod = v9fs_vfs_mknod, 1389 .rename = v9fs_vfs_rename, 1390 .getattr = v9fs_vfs_getattr, 1391 .setattr = v9fs_vfs_setattr, 1392 }; 1393 1394 static const struct inode_operations v9fs_file_inode_operations = { 1395 .getattr = v9fs_vfs_getattr, 1396 .setattr = v9fs_vfs_setattr, 1397 }; 1398 1399 static const struct inode_operations v9fs_symlink_inode_operations = { 1400 .get_link = v9fs_vfs_get_link, 1401 .getattr = v9fs_vfs_getattr, 1402 .setattr = v9fs_vfs_setattr, 1403 }; 1404