1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC. 23 * Copyright (c) 2015 by Chunwei Chen. All rights reserved. 24 */ 25 26 27 #include <sys/zfs_ctldir.h> 28 #include <sys/zfs_vfsops.h> 29 #include <sys/zfs_vnops.h> 30 #include <sys/zfs_znode.h> 31 #include <sys/dmu_objset.h> 32 #include <sys/vfs.h> 33 #include <sys/zpl.h> 34 #include <sys/file.h> 35 36 37 static struct dentry * 38 zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) 39 { 40 cred_t *cr = CRED(); 41 struct inode *ip; 42 znode_t *zp; 43 int error; 44 fstrans_cookie_t cookie; 45 pathname_t *ppn = NULL; 46 pathname_t pn; 47 int zfs_flags = 0; 48 zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info; 49 50 if (dlen(dentry) >= ZAP_MAXNAMELEN) 51 return (ERR_PTR(-ENAMETOOLONG)); 52 53 crhold(cr); 54 cookie = spl_fstrans_mark(); 55 56 /* If we are a case insensitive fs, we need the real name */ 57 if (zfsvfs->z_case == ZFS_CASE_INSENSITIVE) { 58 zfs_flags = FIGNORECASE; 59 pn_alloc(&pn); 60 ppn = &pn; 61 } 62 63 error = -zfs_lookup(ITOZ(dir), dname(dentry), &zp, 64 zfs_flags, cr, NULL, ppn); 65 spl_fstrans_unmark(cookie); 66 ASSERT3S(error, <=, 0); 67 crfree(cr); 68 69 spin_lock(&dentry->d_lock); 70 dentry->d_time = jiffies; 71 spin_unlock(&dentry->d_lock); 72 73 if (error) { 74 /* 75 * If we have a case sensitive fs, we do not want to 76 * insert negative entries, so return NULL for ENOENT. 77 * Fall through if the error is not ENOENT. Also free memory. 78 */ 79 if (ppn) { 80 pn_free(ppn); 81 if (error == -ENOENT) 82 return (NULL); 83 } 84 85 if (error == -ENOENT) 86 return (d_splice_alias(NULL, dentry)); 87 else 88 return (ERR_PTR(error)); 89 } 90 ip = ZTOI(zp); 91 92 /* 93 * If we are case insensitive, call the correct function 94 * to install the name. 95 */ 96 if (ppn) { 97 struct dentry *new_dentry; 98 struct qstr ci_name; 99 100 if (strcmp(dname(dentry), pn.pn_buf) == 0) { 101 new_dentry = d_splice_alias(ip, dentry); 102 } else { 103 ci_name.name = pn.pn_buf; 104 ci_name.len = strlen(pn.pn_buf); 105 new_dentry = d_add_ci(dentry, ip, &ci_name); 106 } 107 pn_free(ppn); 108 return (new_dentry); 109 } else { 110 return (d_splice_alias(ip, dentry)); 111 } 112 } 113 114 void 115 zpl_vap_init(vattr_t *vap, struct inode *dir, umode_t mode, cred_t *cr) 116 { 117 vap->va_mask = ATTR_MODE; 118 vap->va_mode = mode; 119 vap->va_uid = crgetfsuid(cr); 120 121 if (dir && dir->i_mode & S_ISGID) { 122 vap->va_gid = KGID_TO_SGID(dir->i_gid); 123 if (S_ISDIR(mode)) 124 vap->va_mode |= S_ISGID; 125 } else { 126 vap->va_gid = crgetfsgid(cr); 127 } 128 } 129 130 static int 131 #ifdef HAVE_IOPS_CREATE_USERNS 132 zpl_create(struct user_namespace *user_ns, struct inode *dir, 133 struct dentry *dentry, umode_t mode, bool flag) 134 #else 135 zpl_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool flag) 136 #endif 137 { 138 cred_t *cr = CRED(); 139 znode_t *zp; 140 vattr_t *vap; 141 int error; 142 fstrans_cookie_t cookie; 143 144 crhold(cr); 145 vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP); 146 zpl_vap_init(vap, dir, mode, cr); 147 148 cookie = spl_fstrans_mark(); 149 error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0, 150 mode, &zp, cr, 0, NULL); 151 if (error == 0) { 152 error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name); 153 if (error == 0) 154 error = zpl_init_acl(ZTOI(zp), dir); 155 156 if (error) { 157 (void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0); 158 remove_inode_hash(ZTOI(zp)); 159 iput(ZTOI(zp)); 160 } else { 161 d_instantiate(dentry, ZTOI(zp)); 162 } 163 } 164 165 spl_fstrans_unmark(cookie); 166 kmem_free(vap, sizeof (vattr_t)); 167 crfree(cr); 168 ASSERT3S(error, <=, 0); 169 170 return (error); 171 } 172 173 static int 174 #ifdef HAVE_IOPS_MKNOD_USERNS 175 zpl_mknod(struct user_namespace *user_ns, struct inode *dir, 176 struct dentry *dentry, umode_t mode, 177 #else 178 zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, 179 #endif 180 dev_t rdev) 181 { 182 cred_t *cr = CRED(); 183 znode_t *zp; 184 vattr_t *vap; 185 int error; 186 fstrans_cookie_t cookie; 187 188 /* 189 * We currently expect Linux to supply rdev=0 for all sockets 190 * and fifos, but we want to know if this behavior ever changes. 191 */ 192 if (S_ISSOCK(mode) || S_ISFIFO(mode)) 193 ASSERT(rdev == 0); 194 195 crhold(cr); 196 vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP); 197 zpl_vap_init(vap, dir, mode, cr); 198 vap->va_rdev = rdev; 199 200 cookie = spl_fstrans_mark(); 201 error = -zfs_create(ITOZ(dir), dname(dentry), vap, 0, 202 mode, &zp, cr, 0, NULL); 203 if (error == 0) { 204 error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name); 205 if (error == 0) 206 error = zpl_init_acl(ZTOI(zp), dir); 207 208 if (error) { 209 (void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0); 210 remove_inode_hash(ZTOI(zp)); 211 iput(ZTOI(zp)); 212 } else { 213 d_instantiate(dentry, ZTOI(zp)); 214 } 215 } 216 217 spl_fstrans_unmark(cookie); 218 kmem_free(vap, sizeof (vattr_t)); 219 crfree(cr); 220 ASSERT3S(error, <=, 0); 221 222 return (error); 223 } 224 225 #ifdef HAVE_TMPFILE 226 static int 227 #ifdef HAVE_TMPFILE_USERNS 228 zpl_tmpfile(struct user_namespace *userns, struct inode *dir, 229 struct dentry *dentry, umode_t mode) 230 #else 231 zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) 232 #endif 233 { 234 cred_t *cr = CRED(); 235 struct inode *ip; 236 vattr_t *vap; 237 int error; 238 fstrans_cookie_t cookie; 239 240 crhold(cr); 241 vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP); 242 /* 243 * The VFS does not apply the umask, therefore it is applied here 244 * when POSIX ACLs are not enabled. 245 */ 246 if (!IS_POSIXACL(dir)) 247 mode &= ~current_umask(); 248 zpl_vap_init(vap, dir, mode, cr); 249 250 cookie = spl_fstrans_mark(); 251 error = -zfs_tmpfile(dir, vap, 0, mode, &ip, cr, 0, NULL); 252 if (error == 0) { 253 /* d_tmpfile will do drop_nlink, so we should set it first */ 254 set_nlink(ip, 1); 255 d_tmpfile(dentry, ip); 256 257 error = zpl_xattr_security_init(ip, dir, &dentry->d_name); 258 if (error == 0) 259 error = zpl_init_acl(ip, dir); 260 /* 261 * don't need to handle error here, file is already in 262 * unlinked set. 263 */ 264 } 265 266 spl_fstrans_unmark(cookie); 267 kmem_free(vap, sizeof (vattr_t)); 268 crfree(cr); 269 ASSERT3S(error, <=, 0); 270 271 return (error); 272 } 273 #endif 274 275 static int 276 zpl_unlink(struct inode *dir, struct dentry *dentry) 277 { 278 cred_t *cr = CRED(); 279 int error; 280 fstrans_cookie_t cookie; 281 zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info; 282 283 crhold(cr); 284 cookie = spl_fstrans_mark(); 285 error = -zfs_remove(ITOZ(dir), dname(dentry), cr, 0); 286 287 /* 288 * For a CI FS we must invalidate the dentry to prevent the 289 * creation of negative entries. 290 */ 291 if (error == 0 && zfsvfs->z_case == ZFS_CASE_INSENSITIVE) 292 d_invalidate(dentry); 293 294 spl_fstrans_unmark(cookie); 295 crfree(cr); 296 ASSERT3S(error, <=, 0); 297 298 return (error); 299 } 300 301 static int 302 #ifdef HAVE_IOPS_MKDIR_USERNS 303 zpl_mkdir(struct user_namespace *user_ns, struct inode *dir, 304 struct dentry *dentry, umode_t mode) 305 #else 306 zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 307 #endif 308 { 309 cred_t *cr = CRED(); 310 vattr_t *vap; 311 znode_t *zp; 312 int error; 313 fstrans_cookie_t cookie; 314 315 crhold(cr); 316 vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP); 317 zpl_vap_init(vap, dir, mode | S_IFDIR, cr); 318 319 cookie = spl_fstrans_mark(); 320 error = -zfs_mkdir(ITOZ(dir), dname(dentry), vap, &zp, cr, 0, NULL); 321 if (error == 0) { 322 error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name); 323 if (error == 0) 324 error = zpl_init_acl(ZTOI(zp), dir); 325 326 if (error) { 327 (void) zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0); 328 remove_inode_hash(ZTOI(zp)); 329 iput(ZTOI(zp)); 330 } else { 331 d_instantiate(dentry, ZTOI(zp)); 332 } 333 } 334 335 spl_fstrans_unmark(cookie); 336 kmem_free(vap, sizeof (vattr_t)); 337 crfree(cr); 338 ASSERT3S(error, <=, 0); 339 340 return (error); 341 } 342 343 static int 344 zpl_rmdir(struct inode *dir, struct dentry *dentry) 345 { 346 cred_t *cr = CRED(); 347 int error; 348 fstrans_cookie_t cookie; 349 zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info; 350 351 crhold(cr); 352 cookie = spl_fstrans_mark(); 353 error = -zfs_rmdir(ITOZ(dir), dname(dentry), NULL, cr, 0); 354 355 /* 356 * For a CI FS we must invalidate the dentry to prevent the 357 * creation of negative entries. 358 */ 359 if (error == 0 && zfsvfs->z_case == ZFS_CASE_INSENSITIVE) 360 d_invalidate(dentry); 361 362 spl_fstrans_unmark(cookie); 363 crfree(cr); 364 ASSERT3S(error, <=, 0); 365 366 return (error); 367 } 368 369 static int 370 #ifdef HAVE_USERNS_IOPS_GETATTR 371 zpl_getattr_impl(struct user_namespace *user_ns, 372 const struct path *path, struct kstat *stat, u32 request_mask, 373 unsigned int query_flags) 374 #else 375 zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask, 376 unsigned int query_flags) 377 #endif 378 { 379 int error; 380 fstrans_cookie_t cookie; 381 382 cookie = spl_fstrans_mark(); 383 384 /* 385 * XXX request_mask and query_flags currently ignored. 386 */ 387 388 #ifdef HAVE_USERNS_IOPS_GETATTR 389 error = -zfs_getattr_fast(user_ns, path->dentry->d_inode, stat); 390 #else 391 error = -zfs_getattr_fast(kcred->user_ns, path->dentry->d_inode, stat); 392 #endif 393 spl_fstrans_unmark(cookie); 394 ASSERT3S(error, <=, 0); 395 396 return (error); 397 } 398 ZPL_GETATTR_WRAPPER(zpl_getattr); 399 400 static int 401 #ifdef HAVE_SETATTR_PREPARE_USERNS 402 zpl_setattr(struct user_namespace *user_ns, struct dentry *dentry, 403 struct iattr *ia) 404 #else 405 zpl_setattr(struct dentry *dentry, struct iattr *ia) 406 #endif 407 { 408 struct inode *ip = dentry->d_inode; 409 cred_t *cr = CRED(); 410 vattr_t *vap; 411 int error; 412 fstrans_cookie_t cookie; 413 414 error = zpl_setattr_prepare(kcred->user_ns, dentry, ia); 415 if (error) 416 return (error); 417 418 crhold(cr); 419 vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP); 420 vap->va_mask = ia->ia_valid & ATTR_IATTR_MASK; 421 vap->va_mode = ia->ia_mode; 422 vap->va_uid = KUID_TO_SUID(ia->ia_uid); 423 vap->va_gid = KGID_TO_SGID(ia->ia_gid); 424 vap->va_size = ia->ia_size; 425 vap->va_atime = ia->ia_atime; 426 vap->va_mtime = ia->ia_mtime; 427 vap->va_ctime = ia->ia_ctime; 428 429 if (vap->va_mask & ATTR_ATIME) 430 ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip); 431 432 cookie = spl_fstrans_mark(); 433 error = -zfs_setattr(ITOZ(ip), vap, 0, cr); 434 if (!error && (ia->ia_valid & ATTR_MODE)) 435 error = zpl_chmod_acl(ip); 436 437 spl_fstrans_unmark(cookie); 438 kmem_free(vap, sizeof (vattr_t)); 439 crfree(cr); 440 ASSERT3S(error, <=, 0); 441 442 return (error); 443 } 444 445 static int 446 #ifdef HAVE_IOPS_RENAME_USERNS 447 zpl_rename2(struct user_namespace *user_ns, struct inode *sdip, 448 struct dentry *sdentry, struct inode *tdip, struct dentry *tdentry, 449 unsigned int flags) 450 #else 451 zpl_rename2(struct inode *sdip, struct dentry *sdentry, 452 struct inode *tdip, struct dentry *tdentry, unsigned int flags) 453 #endif 454 { 455 cred_t *cr = CRED(); 456 int error; 457 fstrans_cookie_t cookie; 458 459 /* We don't have renameat2(2) support */ 460 if (flags) 461 return (-EINVAL); 462 463 crhold(cr); 464 cookie = spl_fstrans_mark(); 465 error = -zfs_rename(ITOZ(sdip), dname(sdentry), ITOZ(tdip), 466 dname(tdentry), cr, 0); 467 spl_fstrans_unmark(cookie); 468 crfree(cr); 469 ASSERT3S(error, <=, 0); 470 471 return (error); 472 } 473 474 #if !defined(HAVE_RENAME_WANTS_FLAGS) && !defined(HAVE_IOPS_RENAME_USERNS) 475 static int 476 zpl_rename(struct inode *sdip, struct dentry *sdentry, 477 struct inode *tdip, struct dentry *tdentry) 478 { 479 return (zpl_rename2(sdip, sdentry, tdip, tdentry, 0)); 480 } 481 #endif 482 483 static int 484 #ifdef HAVE_IOPS_SYMLINK_USERNS 485 zpl_symlink(struct user_namespace *user_ns, struct inode *dir, 486 struct dentry *dentry, const char *name) 487 #else 488 zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name) 489 #endif 490 { 491 cred_t *cr = CRED(); 492 vattr_t *vap; 493 znode_t *zp; 494 int error; 495 fstrans_cookie_t cookie; 496 497 crhold(cr); 498 vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP); 499 zpl_vap_init(vap, dir, S_IFLNK | S_IRWXUGO, cr); 500 501 cookie = spl_fstrans_mark(); 502 error = -zfs_symlink(ITOZ(dir), dname(dentry), vap, 503 (char *)name, &zp, cr, 0); 504 if (error == 0) { 505 error = zpl_xattr_security_init(ZTOI(zp), dir, &dentry->d_name); 506 if (error) { 507 (void) zfs_remove(ITOZ(dir), dname(dentry), cr, 0); 508 remove_inode_hash(ZTOI(zp)); 509 iput(ZTOI(zp)); 510 } else { 511 d_instantiate(dentry, ZTOI(zp)); 512 } 513 } 514 515 spl_fstrans_unmark(cookie); 516 kmem_free(vap, sizeof (vattr_t)); 517 crfree(cr); 518 ASSERT3S(error, <=, 0); 519 520 return (error); 521 } 522 523 #if defined(HAVE_PUT_LINK_COOKIE) 524 static void 525 zpl_put_link(struct inode *unused, void *cookie) 526 { 527 kmem_free(cookie, MAXPATHLEN); 528 } 529 #elif defined(HAVE_PUT_LINK_NAMEIDATA) 530 static void 531 zpl_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr) 532 { 533 const char *link = nd_get_link(nd); 534 535 if (!IS_ERR(link)) 536 kmem_free(link, MAXPATHLEN); 537 } 538 #elif defined(HAVE_PUT_LINK_DELAYED) 539 static void 540 zpl_put_link(void *ptr) 541 { 542 kmem_free(ptr, MAXPATHLEN); 543 } 544 #endif 545 546 static int 547 zpl_get_link_common(struct dentry *dentry, struct inode *ip, char **link) 548 { 549 fstrans_cookie_t cookie; 550 cred_t *cr = CRED(); 551 int error; 552 553 crhold(cr); 554 *link = NULL; 555 556 struct iovec iov; 557 iov.iov_len = MAXPATHLEN; 558 iov.iov_base = kmem_zalloc(MAXPATHLEN, KM_SLEEP); 559 560 zfs_uio_t uio; 561 zfs_uio_iovec_init(&uio, &iov, 1, 0, UIO_SYSSPACE, MAXPATHLEN - 1, 0); 562 563 cookie = spl_fstrans_mark(); 564 error = -zfs_readlink(ip, &uio, cr); 565 spl_fstrans_unmark(cookie); 566 crfree(cr); 567 568 if (error) 569 kmem_free(iov.iov_base, MAXPATHLEN); 570 else 571 *link = iov.iov_base; 572 573 return (error); 574 } 575 576 #if defined(HAVE_GET_LINK_DELAYED) 577 static const char * 578 zpl_get_link(struct dentry *dentry, struct inode *inode, 579 struct delayed_call *done) 580 { 581 char *link = NULL; 582 int error; 583 584 if (!dentry) 585 return (ERR_PTR(-ECHILD)); 586 587 error = zpl_get_link_common(dentry, inode, &link); 588 if (error) 589 return (ERR_PTR(error)); 590 591 set_delayed_call(done, zpl_put_link, link); 592 593 return (link); 594 } 595 #elif defined(HAVE_GET_LINK_COOKIE) 596 static const char * 597 zpl_get_link(struct dentry *dentry, struct inode *inode, void **cookie) 598 { 599 char *link = NULL; 600 int error; 601 602 if (!dentry) 603 return (ERR_PTR(-ECHILD)); 604 605 error = zpl_get_link_common(dentry, inode, &link); 606 if (error) 607 return (ERR_PTR(error)); 608 609 return (*cookie = link); 610 } 611 #elif defined(HAVE_FOLLOW_LINK_COOKIE) 612 static const char * 613 zpl_follow_link(struct dentry *dentry, void **cookie) 614 { 615 char *link = NULL; 616 int error; 617 618 error = zpl_get_link_common(dentry, dentry->d_inode, &link); 619 if (error) 620 return (ERR_PTR(error)); 621 622 return (*cookie = link); 623 } 624 #elif defined(HAVE_FOLLOW_LINK_NAMEIDATA) 625 static void * 626 zpl_follow_link(struct dentry *dentry, struct nameidata *nd) 627 { 628 char *link = NULL; 629 int error; 630 631 error = zpl_get_link_common(dentry, dentry->d_inode, &link); 632 if (error) 633 nd_set_link(nd, ERR_PTR(error)); 634 else 635 nd_set_link(nd, link); 636 637 return (NULL); 638 } 639 #endif 640 641 static int 642 zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) 643 { 644 cred_t *cr = CRED(); 645 struct inode *ip = old_dentry->d_inode; 646 int error; 647 fstrans_cookie_t cookie; 648 649 if (ip->i_nlink >= ZFS_LINK_MAX) 650 return (-EMLINK); 651 652 crhold(cr); 653 ip->i_ctime = current_time(ip); 654 /* Must have an existing ref, so igrab() cannot return NULL */ 655 VERIFY3P(igrab(ip), !=, NULL); 656 657 cookie = spl_fstrans_mark(); 658 error = -zfs_link(ITOZ(dir), ITOZ(ip), dname(dentry), cr, 0); 659 if (error) { 660 iput(ip); 661 goto out; 662 } 663 664 d_instantiate(dentry, ip); 665 out: 666 spl_fstrans_unmark(cookie); 667 crfree(cr); 668 ASSERT3S(error, <=, 0); 669 670 return (error); 671 } 672 673 static int 674 #ifdef HAVE_D_REVALIDATE_NAMEIDATA 675 zpl_revalidate(struct dentry *dentry, struct nameidata *nd) 676 { 677 unsigned int flags = (nd ? nd->flags : 0); 678 #else 679 zpl_revalidate(struct dentry *dentry, unsigned int flags) 680 { 681 #endif /* HAVE_D_REVALIDATE_NAMEIDATA */ 682 /* CSTYLED */ 683 zfsvfs_t *zfsvfs = dentry->d_sb->s_fs_info; 684 int error; 685 686 if (flags & LOOKUP_RCU) 687 return (-ECHILD); 688 689 /* 690 * After a rollback negative dentries created before the rollback 691 * time must be invalidated. Otherwise they can obscure files which 692 * are only present in the rolled back dataset. 693 */ 694 if (dentry->d_inode == NULL) { 695 spin_lock(&dentry->d_lock); 696 error = time_before(dentry->d_time, zfsvfs->z_rollback_time); 697 spin_unlock(&dentry->d_lock); 698 699 if (error) 700 return (0); 701 } 702 703 /* 704 * The dentry may reference a stale inode if a mounted file system 705 * was rolled back to a point in time where the object didn't exist. 706 */ 707 if (dentry->d_inode && ITOZ(dentry->d_inode)->z_is_stale) 708 return (0); 709 710 return (1); 711 } 712 713 const struct inode_operations zpl_inode_operations = { 714 .setattr = zpl_setattr, 715 .getattr = zpl_getattr, 716 #ifdef HAVE_GENERIC_SETXATTR 717 .setxattr = generic_setxattr, 718 .getxattr = generic_getxattr, 719 .removexattr = generic_removexattr, 720 #endif 721 .listxattr = zpl_xattr_list, 722 #if defined(CONFIG_FS_POSIX_ACL) 723 #if defined(HAVE_SET_ACL) 724 .set_acl = zpl_set_acl, 725 #endif /* HAVE_SET_ACL */ 726 .get_acl = zpl_get_acl, 727 #endif /* CONFIG_FS_POSIX_ACL */ 728 }; 729 730 const struct inode_operations zpl_dir_inode_operations = { 731 .create = zpl_create, 732 .lookup = zpl_lookup, 733 .link = zpl_link, 734 .unlink = zpl_unlink, 735 .symlink = zpl_symlink, 736 .mkdir = zpl_mkdir, 737 .rmdir = zpl_rmdir, 738 .mknod = zpl_mknod, 739 #if defined(HAVE_RENAME_WANTS_FLAGS) || defined(HAVE_IOPS_RENAME_USERNS) 740 .rename = zpl_rename2, 741 #else 742 .rename = zpl_rename, 743 #endif 744 #ifdef HAVE_TMPFILE 745 .tmpfile = zpl_tmpfile, 746 #endif 747 .setattr = zpl_setattr, 748 .getattr = zpl_getattr, 749 #ifdef HAVE_GENERIC_SETXATTR 750 .setxattr = generic_setxattr, 751 .getxattr = generic_getxattr, 752 .removexattr = generic_removexattr, 753 #endif 754 .listxattr = zpl_xattr_list, 755 #if defined(CONFIG_FS_POSIX_ACL) 756 #if defined(HAVE_SET_ACL) 757 .set_acl = zpl_set_acl, 758 #endif /* HAVE_SET_ACL */ 759 .get_acl = zpl_get_acl, 760 #endif /* CONFIG_FS_POSIX_ACL */ 761 }; 762 763 const struct inode_operations zpl_symlink_inode_operations = { 764 #ifdef HAVE_GENERIC_READLINK 765 .readlink = generic_readlink, 766 #endif 767 #if defined(HAVE_GET_LINK_DELAYED) || defined(HAVE_GET_LINK_COOKIE) 768 .get_link = zpl_get_link, 769 #elif defined(HAVE_FOLLOW_LINK_COOKIE) || defined(HAVE_FOLLOW_LINK_NAMEIDATA) 770 .follow_link = zpl_follow_link, 771 #endif 772 #if defined(HAVE_PUT_LINK_COOKIE) || defined(HAVE_PUT_LINK_NAMEIDATA) 773 .put_link = zpl_put_link, 774 #endif 775 .setattr = zpl_setattr, 776 .getattr = zpl_getattr, 777 #ifdef HAVE_GENERIC_SETXATTR 778 .setxattr = generic_setxattr, 779 .getxattr = generic_getxattr, 780 .removexattr = generic_removexattr, 781 #endif 782 .listxattr = zpl_xattr_list, 783 }; 784 785 const struct inode_operations zpl_special_inode_operations = { 786 .setattr = zpl_setattr, 787 .getattr = zpl_getattr, 788 #ifdef HAVE_GENERIC_SETXATTR 789 .setxattr = generic_setxattr, 790 .getxattr = generic_getxattr, 791 .removexattr = generic_removexattr, 792 #endif 793 .listxattr = zpl_xattr_list, 794 #if defined(CONFIG_FS_POSIX_ACL) 795 #if defined(HAVE_SET_ACL) 796 .set_acl = zpl_set_acl, 797 #endif /* HAVE_SET_ACL */ 798 .get_acl = zpl_get_acl, 799 #endif /* CONFIG_FS_POSIX_ACL */ 800 }; 801 802 dentry_operations_t zpl_dentry_operations = { 803 .d_revalidate = zpl_revalidate, 804 }; 805