1 /* 2 * 9p Posix callback 3 * 4 * Copyright IBM, Corp. 2010 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2. See 10 * the COPYING file in the top-level directory. 11 * 12 */ 13 14 #include "qemu/osdep.h" 15 #include "9p.h" 16 #include "9p-local.h" 17 #include "9p-xattr.h" 18 #include "9p-util.h" 19 #include "fsdev/qemu-fsdev.h" /* local_ops */ 20 #include <arpa/inet.h> 21 #include <pwd.h> 22 #include <grp.h> 23 #include <sys/socket.h> 24 #include <sys/un.h> 25 #include "qemu/xattr.h" 26 #include "qemu/cutils.h" 27 #include "qemu/error-report.h" 28 #include <libgen.h> 29 #include <linux/fs.h> 30 #ifdef CONFIG_LINUX_MAGIC_H 31 #include <linux/magic.h> 32 #endif 33 #include <sys/ioctl.h> 34 35 #ifndef XFS_SUPER_MAGIC 36 #define XFS_SUPER_MAGIC 0x58465342 37 #endif 38 #ifndef EXT2_SUPER_MAGIC 39 #define EXT2_SUPER_MAGIC 0xEF53 40 #endif 41 #ifndef REISERFS_SUPER_MAGIC 42 #define REISERFS_SUPER_MAGIC 0x52654973 43 #endif 44 #ifndef BTRFS_SUPER_MAGIC 45 #define BTRFS_SUPER_MAGIC 0x9123683E 46 #endif 47 48 typedef struct { 49 int mountfd; 50 } LocalData; 51 52 int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags, 53 mode_t mode) 54 { 55 LocalData *data = fs_ctx->private; 56 57 /* All paths are relative to the path data->mountfd points to */ 58 while (*path == '/') { 59 path++; 60 } 61 62 return relative_openat_nofollow(data->mountfd, path, flags, mode); 63 } 64 65 int local_opendir_nofollow(FsContext *fs_ctx, const char *path) 66 { 67 return local_open_nofollow(fs_ctx, path, O_DIRECTORY | O_RDONLY, 0); 68 } 69 70 static void renameat_preserve_errno(int odirfd, const char *opath, int ndirfd, 71 const char *npath) 72 { 73 int serrno = errno; 74 renameat(odirfd, opath, ndirfd, npath); 75 errno = serrno; 76 } 77 78 static void unlinkat_preserve_errno(int dirfd, const char *path, int flags) 79 { 80 int serrno = errno; 81 unlinkat(dirfd, path, flags); 82 errno = serrno; 83 } 84 85 #define VIRTFS_META_DIR ".virtfs_metadata" 86 87 static FILE *local_fopenat(int dirfd, const char *name, const char *mode) 88 { 89 int fd, o_mode = 0; 90 FILE *fp; 91 int flags; 92 /* 93 * only supports two modes 94 */ 95 if (mode[0] == 'r') { 96 flags = O_RDONLY; 97 } else if (mode[0] == 'w') { 98 flags = O_WRONLY | O_TRUNC | O_CREAT; 99 o_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 100 } else { 101 return NULL; 102 } 103 fd = openat_file(dirfd, name, flags, o_mode); 104 if (fd == -1) { 105 return NULL; 106 } 107 fp = fdopen(fd, mode); 108 if (!fp) { 109 close(fd); 110 } 111 return fp; 112 } 113 114 #define ATTR_MAX 100 115 static void local_mapped_file_attr(int dirfd, const char *name, 116 struct stat *stbuf) 117 { 118 FILE *fp; 119 char buf[ATTR_MAX]; 120 int map_dirfd; 121 122 map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); 123 if (map_dirfd == -1) { 124 return; 125 } 126 127 fp = local_fopenat(map_dirfd, name, "r"); 128 close_preserve_errno(map_dirfd); 129 if (!fp) { 130 return; 131 } 132 memset(buf, 0, ATTR_MAX); 133 while (fgets(buf, ATTR_MAX, fp)) { 134 if (!strncmp(buf, "virtfs.uid", 10)) { 135 stbuf->st_uid = atoi(buf+11); 136 } else if (!strncmp(buf, "virtfs.gid", 10)) { 137 stbuf->st_gid = atoi(buf+11); 138 } else if (!strncmp(buf, "virtfs.mode", 11)) { 139 stbuf->st_mode = atoi(buf+12); 140 } else if (!strncmp(buf, "virtfs.rdev", 11)) { 141 stbuf->st_rdev = atoi(buf+12); 142 } 143 memset(buf, 0, ATTR_MAX); 144 } 145 fclose(fp); 146 } 147 148 static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf) 149 { 150 int err = -1; 151 char *dirpath = g_path_get_dirname(fs_path->data); 152 char *name = g_path_get_basename(fs_path->data); 153 int dirfd; 154 155 dirfd = local_opendir_nofollow(fs_ctx, dirpath); 156 if (dirfd == -1) { 157 goto out; 158 } 159 160 err = fstatat(dirfd, name, stbuf, AT_SYMLINK_NOFOLLOW); 161 if (err) { 162 goto err_out; 163 } 164 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 165 /* Actual credentials are part of extended attrs */ 166 uid_t tmp_uid; 167 gid_t tmp_gid; 168 mode_t tmp_mode; 169 dev_t tmp_dev; 170 171 if (fgetxattrat_nofollow(dirfd, name, "user.virtfs.uid", &tmp_uid, 172 sizeof(uid_t)) > 0) { 173 stbuf->st_uid = le32_to_cpu(tmp_uid); 174 } 175 if (fgetxattrat_nofollow(dirfd, name, "user.virtfs.gid", &tmp_gid, 176 sizeof(gid_t)) > 0) { 177 stbuf->st_gid = le32_to_cpu(tmp_gid); 178 } 179 if (fgetxattrat_nofollow(dirfd, name, "user.virtfs.mode", &tmp_mode, 180 sizeof(mode_t)) > 0) { 181 stbuf->st_mode = le32_to_cpu(tmp_mode); 182 } 183 if (fgetxattrat_nofollow(dirfd, name, "user.virtfs.rdev", &tmp_dev, 184 sizeof(dev_t)) > 0) { 185 stbuf->st_rdev = le64_to_cpu(tmp_dev); 186 } 187 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 188 local_mapped_file_attr(dirfd, name, stbuf); 189 } 190 191 err_out: 192 close_preserve_errno(dirfd); 193 out: 194 g_free(name); 195 g_free(dirpath); 196 return err; 197 } 198 199 static int local_set_mapped_file_attrat(int dirfd, const char *name, 200 FsCred *credp) 201 { 202 FILE *fp; 203 int ret; 204 char buf[ATTR_MAX]; 205 int uid = -1, gid = -1, mode = -1, rdev = -1; 206 int map_dirfd; 207 208 ret = mkdirat(dirfd, VIRTFS_META_DIR, 0700); 209 if (ret < 0 && errno != EEXIST) { 210 return -1; 211 } 212 213 map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); 214 if (map_dirfd == -1) { 215 return -1; 216 } 217 218 fp = local_fopenat(map_dirfd, name, "r"); 219 if (!fp) { 220 if (errno == ENOENT) { 221 goto update_map_file; 222 } else { 223 close_preserve_errno(map_dirfd); 224 return -1; 225 } 226 } 227 memset(buf, 0, ATTR_MAX); 228 while (fgets(buf, ATTR_MAX, fp)) { 229 if (!strncmp(buf, "virtfs.uid", 10)) { 230 uid = atoi(buf + 11); 231 } else if (!strncmp(buf, "virtfs.gid", 10)) { 232 gid = atoi(buf + 11); 233 } else if (!strncmp(buf, "virtfs.mode", 11)) { 234 mode = atoi(buf + 12); 235 } else if (!strncmp(buf, "virtfs.rdev", 11)) { 236 rdev = atoi(buf + 12); 237 } 238 memset(buf, 0, ATTR_MAX); 239 } 240 fclose(fp); 241 242 update_map_file: 243 fp = local_fopenat(map_dirfd, name, "w"); 244 close_preserve_errno(map_dirfd); 245 if (!fp) { 246 return -1; 247 } 248 249 if (credp->fc_uid != -1) { 250 uid = credp->fc_uid; 251 } 252 if (credp->fc_gid != -1) { 253 gid = credp->fc_gid; 254 } 255 if (credp->fc_mode != -1) { 256 mode = credp->fc_mode; 257 } 258 if (credp->fc_rdev != -1) { 259 rdev = credp->fc_rdev; 260 } 261 262 if (uid != -1) { 263 fprintf(fp, "virtfs.uid=%d\n", uid); 264 } 265 if (gid != -1) { 266 fprintf(fp, "virtfs.gid=%d\n", gid); 267 } 268 if (mode != -1) { 269 fprintf(fp, "virtfs.mode=%d\n", mode); 270 } 271 if (rdev != -1) { 272 fprintf(fp, "virtfs.rdev=%d\n", rdev); 273 } 274 fclose(fp); 275 276 return 0; 277 } 278 279 static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) 280 { 281 int fd, ret; 282 283 /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW). 284 * Unfortunately, the linux kernel doesn't implement it yet. As an 285 * alternative, let's open the file and use fchmod() instead. This 286 * may fail depending on the permissions of the file, but it is the 287 * best we can do to avoid TOCTTOU. We first try to open read-only 288 * in case name points to a directory. If that fails, we try write-only 289 * in case name doesn't point to a directory. 290 */ 291 fd = openat_file(dirfd, name, O_RDONLY, 0); 292 if (fd == -1) { 293 /* In case the file is writable-only and isn't a directory. */ 294 if (errno == EACCES) { 295 fd = openat_file(dirfd, name, O_WRONLY, 0); 296 } 297 if (fd == -1 && errno == EISDIR) { 298 errno = EACCES; 299 } 300 } 301 if (fd == -1) { 302 return -1; 303 } 304 ret = fchmod(fd, mode); 305 close_preserve_errno(fd); 306 return ret; 307 } 308 309 static int local_set_xattrat(int dirfd, const char *path, FsCred *credp) 310 { 311 int err; 312 313 if (credp->fc_uid != -1) { 314 uint32_t tmp_uid = cpu_to_le32(credp->fc_uid); 315 err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.uid", &tmp_uid, 316 sizeof(uid_t), 0); 317 if (err) { 318 return err; 319 } 320 } 321 if (credp->fc_gid != -1) { 322 uint32_t tmp_gid = cpu_to_le32(credp->fc_gid); 323 err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.gid", &tmp_gid, 324 sizeof(gid_t), 0); 325 if (err) { 326 return err; 327 } 328 } 329 if (credp->fc_mode != -1) { 330 uint32_t tmp_mode = cpu_to_le32(credp->fc_mode); 331 err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.mode", &tmp_mode, 332 sizeof(mode_t), 0); 333 if (err) { 334 return err; 335 } 336 } 337 if (credp->fc_rdev != -1) { 338 uint64_t tmp_rdev = cpu_to_le64(credp->fc_rdev); 339 err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.rdev", &tmp_rdev, 340 sizeof(dev_t), 0); 341 if (err) { 342 return err; 343 } 344 } 345 return 0; 346 } 347 348 static int local_set_cred_passthrough(FsContext *fs_ctx, int dirfd, 349 const char *name, FsCred *credp) 350 { 351 if (fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, 352 AT_SYMLINK_NOFOLLOW) < 0) { 353 /* 354 * If we fail to change ownership and if we are 355 * using security model none. Ignore the error 356 */ 357 if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) { 358 return -1; 359 } 360 } 361 362 return fchmodat_nofollow(dirfd, name, credp->fc_mode & 07777); 363 } 364 365 static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path, 366 char *buf, size_t bufsz) 367 { 368 ssize_t tsize = -1; 369 370 if ((fs_ctx->export_flags & V9FS_SM_MAPPED) || 371 (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) { 372 int fd; 373 374 fd = local_open_nofollow(fs_ctx, fs_path->data, O_RDONLY, 0); 375 if (fd == -1) { 376 return -1; 377 } 378 do { 379 tsize = read(fd, (void *)buf, bufsz); 380 } while (tsize == -1 && errno == EINTR); 381 close_preserve_errno(fd); 382 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || 383 (fs_ctx->export_flags & V9FS_SM_NONE)) { 384 char *dirpath = g_path_get_dirname(fs_path->data); 385 char *name = g_path_get_basename(fs_path->data); 386 int dirfd; 387 388 dirfd = local_opendir_nofollow(fs_ctx, dirpath); 389 if (dirfd == -1) { 390 goto out; 391 } 392 393 tsize = readlinkat(dirfd, name, buf, bufsz); 394 close_preserve_errno(dirfd); 395 out: 396 g_free(name); 397 g_free(dirpath); 398 } 399 return tsize; 400 } 401 402 static int local_close(FsContext *ctx, V9fsFidOpenState *fs) 403 { 404 return close(fs->fd); 405 } 406 407 static int local_closedir(FsContext *ctx, V9fsFidOpenState *fs) 408 { 409 return closedir(fs->dir.stream); 410 } 411 412 static int local_open(FsContext *ctx, V9fsPath *fs_path, 413 int flags, V9fsFidOpenState *fs) 414 { 415 int fd; 416 417 fd = local_open_nofollow(ctx, fs_path->data, flags, 0); 418 if (fd == -1) { 419 return -1; 420 } 421 fs->fd = fd; 422 return fs->fd; 423 } 424 425 static int local_opendir(FsContext *ctx, 426 V9fsPath *fs_path, V9fsFidOpenState *fs) 427 { 428 int dirfd; 429 DIR *stream; 430 431 dirfd = local_opendir_nofollow(ctx, fs_path->data); 432 if (dirfd == -1) { 433 return -1; 434 } 435 436 stream = fdopendir(dirfd); 437 if (!stream) { 438 close(dirfd); 439 return -1; 440 } 441 fs->dir.stream = stream; 442 return 0; 443 } 444 445 static void local_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) 446 { 447 rewinddir(fs->dir.stream); 448 } 449 450 static off_t local_telldir(FsContext *ctx, V9fsFidOpenState *fs) 451 { 452 return telldir(fs->dir.stream); 453 } 454 455 static bool local_is_mapped_file_metadata(FsContext *fs_ctx, const char *name) 456 { 457 return !strcmp(name, VIRTFS_META_DIR); 458 } 459 460 static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs) 461 { 462 struct dirent *entry; 463 464 again: 465 entry = readdir(fs->dir.stream); 466 if (!entry) { 467 return NULL; 468 } 469 470 if (ctx->export_flags & V9FS_SM_MAPPED) { 471 entry->d_type = DT_UNKNOWN; 472 } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { 473 if (local_is_mapped_file_metadata(ctx, entry->d_name)) { 474 /* skip the meta data directory */ 475 goto again; 476 } 477 entry->d_type = DT_UNKNOWN; 478 } 479 480 return entry; 481 } 482 483 static void local_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) 484 { 485 seekdir(fs->dir.stream, off); 486 } 487 488 static ssize_t local_preadv(FsContext *ctx, V9fsFidOpenState *fs, 489 const struct iovec *iov, 490 int iovcnt, off_t offset) 491 { 492 #ifdef CONFIG_PREADV 493 return preadv(fs->fd, iov, iovcnt, offset); 494 #else 495 int err = lseek(fs->fd, offset, SEEK_SET); 496 if (err == -1) { 497 return err; 498 } else { 499 return readv(fs->fd, iov, iovcnt); 500 } 501 #endif 502 } 503 504 static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs, 505 const struct iovec *iov, 506 int iovcnt, off_t offset) 507 { 508 ssize_t ret; 509 #ifdef CONFIG_PREADV 510 ret = pwritev(fs->fd, iov, iovcnt, offset); 511 #else 512 int err = lseek(fs->fd, offset, SEEK_SET); 513 if (err == -1) { 514 return err; 515 } else { 516 ret = writev(fs->fd, iov, iovcnt); 517 } 518 #endif 519 #ifdef CONFIG_SYNC_FILE_RANGE 520 if (ret > 0 && ctx->export_flags & V9FS_IMMEDIATE_WRITEOUT) { 521 /* 522 * Initiate a writeback. This is not a data integrity sync. 523 * We want to ensure that we don't leave dirty pages in the cache 524 * after write when writeout=immediate is sepcified. 525 */ 526 sync_file_range(fs->fd, offset, ret, 527 SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE); 528 } 529 #endif 530 return ret; 531 } 532 533 static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) 534 { 535 char *dirpath = g_path_get_dirname(fs_path->data); 536 char *name = g_path_get_basename(fs_path->data); 537 int ret = -1; 538 int dirfd; 539 540 dirfd = local_opendir_nofollow(fs_ctx, dirpath); 541 if (dirfd == -1) { 542 goto out; 543 } 544 545 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 546 ret = local_set_xattrat(dirfd, name, credp); 547 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 548 ret = local_set_mapped_file_attrat(dirfd, name, credp); 549 } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || 550 fs_ctx->export_flags & V9FS_SM_NONE) { 551 ret = fchmodat_nofollow(dirfd, name, credp->fc_mode); 552 } 553 close_preserve_errno(dirfd); 554 555 out: 556 g_free(dirpath); 557 g_free(name); 558 return ret; 559 } 560 561 static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, 562 const char *name, FsCred *credp) 563 { 564 int err = -1; 565 int dirfd; 566 567 if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && 568 local_is_mapped_file_metadata(fs_ctx, name)) { 569 errno = EINVAL; 570 return -1; 571 } 572 573 dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); 574 if (dirfd == -1) { 575 return -1; 576 } 577 578 if (fs_ctx->export_flags & V9FS_SM_MAPPED || 579 fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 580 err = mknodat(dirfd, name, SM_LOCAL_MODE_BITS | S_IFREG, 0); 581 if (err == -1) { 582 goto out; 583 } 584 585 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 586 err = local_set_xattrat(dirfd, name, credp); 587 } else { 588 err = local_set_mapped_file_attrat(dirfd, name, credp); 589 } 590 if (err == -1) { 591 goto err_end; 592 } 593 } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || 594 fs_ctx->export_flags & V9FS_SM_NONE) { 595 err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); 596 if (err == -1) { 597 goto out; 598 } 599 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); 600 if (err == -1) { 601 goto err_end; 602 } 603 } 604 goto out; 605 606 err_end: 607 unlinkat_preserve_errno(dirfd, name, 0); 608 out: 609 close_preserve_errno(dirfd); 610 return err; 611 } 612 613 static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, 614 const char *name, FsCred *credp) 615 { 616 int err = -1; 617 int dirfd; 618 619 if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && 620 local_is_mapped_file_metadata(fs_ctx, name)) { 621 errno = EINVAL; 622 return -1; 623 } 624 625 dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); 626 if (dirfd == -1) { 627 return -1; 628 } 629 630 if (fs_ctx->export_flags & V9FS_SM_MAPPED || 631 fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 632 err = mkdirat(dirfd, name, SM_LOCAL_DIR_MODE_BITS); 633 if (err == -1) { 634 goto out; 635 } 636 credp->fc_mode = credp->fc_mode | S_IFDIR; 637 638 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 639 err = local_set_xattrat(dirfd, name, credp); 640 } else { 641 err = local_set_mapped_file_attrat(dirfd, name, credp); 642 } 643 if (err == -1) { 644 goto err_end; 645 } 646 } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || 647 fs_ctx->export_flags & V9FS_SM_NONE) { 648 err = mkdirat(dirfd, name, credp->fc_mode); 649 if (err == -1) { 650 goto out; 651 } 652 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); 653 if (err == -1) { 654 goto err_end; 655 } 656 } 657 goto out; 658 659 err_end: 660 unlinkat_preserve_errno(dirfd, name, AT_REMOVEDIR); 661 out: 662 close_preserve_errno(dirfd); 663 return err; 664 } 665 666 static int local_fstat(FsContext *fs_ctx, int fid_type, 667 V9fsFidOpenState *fs, struct stat *stbuf) 668 { 669 int err, fd; 670 671 if (fid_type == P9_FID_DIR) { 672 fd = dirfd(fs->dir.stream); 673 } else { 674 fd = fs->fd; 675 } 676 677 err = fstat(fd, stbuf); 678 if (err) { 679 return err; 680 } 681 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 682 /* Actual credentials are part of extended attrs */ 683 uid_t tmp_uid; 684 gid_t tmp_gid; 685 mode_t tmp_mode; 686 dev_t tmp_dev; 687 688 if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { 689 stbuf->st_uid = le32_to_cpu(tmp_uid); 690 } 691 if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { 692 stbuf->st_gid = le32_to_cpu(tmp_gid); 693 } 694 if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { 695 stbuf->st_mode = le32_to_cpu(tmp_mode); 696 } 697 if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { 698 stbuf->st_rdev = le64_to_cpu(tmp_dev); 699 } 700 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 701 errno = EOPNOTSUPP; 702 return -1; 703 } 704 return err; 705 } 706 707 static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, 708 int flags, FsCred *credp, V9fsFidOpenState *fs) 709 { 710 int fd = -1; 711 int err = -1; 712 int dirfd; 713 714 if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && 715 local_is_mapped_file_metadata(fs_ctx, name)) { 716 errno = EINVAL; 717 return -1; 718 } 719 720 /* 721 * Mark all the open to not follow symlinks 722 */ 723 flags |= O_NOFOLLOW; 724 725 dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); 726 if (dirfd == -1) { 727 return -1; 728 } 729 730 /* Determine the security model */ 731 if (fs_ctx->export_flags & V9FS_SM_MAPPED || 732 fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 733 fd = openat_file(dirfd, name, flags, SM_LOCAL_MODE_BITS); 734 if (fd == -1) { 735 goto out; 736 } 737 credp->fc_mode = credp->fc_mode|S_IFREG; 738 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 739 /* Set cleint credentials in xattr */ 740 err = local_set_xattrat(dirfd, name, credp); 741 } else { 742 err = local_set_mapped_file_attrat(dirfd, name, credp); 743 } 744 if (err == -1) { 745 goto err_end; 746 } 747 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || 748 (fs_ctx->export_flags & V9FS_SM_NONE)) { 749 fd = openat_file(dirfd, name, flags, credp->fc_mode); 750 if (fd == -1) { 751 goto out; 752 } 753 err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp); 754 if (err == -1) { 755 goto err_end; 756 } 757 } 758 err = fd; 759 fs->fd = fd; 760 goto out; 761 762 err_end: 763 unlinkat_preserve_errno(dirfd, name, 764 flags & O_DIRECTORY ? AT_REMOVEDIR : 0); 765 close_preserve_errno(fd); 766 out: 767 close_preserve_errno(dirfd); 768 return err; 769 } 770 771 772 static int local_symlink(FsContext *fs_ctx, const char *oldpath, 773 V9fsPath *dir_path, const char *name, FsCred *credp) 774 { 775 int err = -1; 776 int dirfd; 777 778 if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE && 779 local_is_mapped_file_metadata(fs_ctx, name)) { 780 errno = EINVAL; 781 return -1; 782 } 783 784 dirfd = local_opendir_nofollow(fs_ctx, dir_path->data); 785 if (dirfd == -1) { 786 return -1; 787 } 788 789 /* Determine the security model */ 790 if (fs_ctx->export_flags & V9FS_SM_MAPPED || 791 fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 792 int fd; 793 ssize_t oldpath_size, write_size; 794 795 fd = openat_file(dirfd, name, O_CREAT | O_EXCL | O_RDWR, 796 SM_LOCAL_MODE_BITS); 797 if (fd == -1) { 798 goto out; 799 } 800 /* Write the oldpath (target) to the file. */ 801 oldpath_size = strlen(oldpath); 802 do { 803 write_size = write(fd, (void *)oldpath, oldpath_size); 804 } while (write_size == -1 && errno == EINTR); 805 close_preserve_errno(fd); 806 807 if (write_size != oldpath_size) { 808 goto err_end; 809 } 810 /* Set cleint credentials in symlink's xattr */ 811 credp->fc_mode = credp->fc_mode | S_IFLNK; 812 813 if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 814 err = local_set_xattrat(dirfd, name, credp); 815 } else { 816 err = local_set_mapped_file_attrat(dirfd, name, credp); 817 } 818 if (err == -1) { 819 goto err_end; 820 } 821 } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || 822 fs_ctx->export_flags & V9FS_SM_NONE) { 823 err = symlinkat(oldpath, dirfd, name); 824 if (err) { 825 goto out; 826 } 827 err = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, 828 AT_SYMLINK_NOFOLLOW); 829 if (err == -1) { 830 /* 831 * If we fail to change ownership and if we are 832 * using security model none. Ignore the error 833 */ 834 if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) { 835 goto err_end; 836 } else { 837 err = 0; 838 } 839 } 840 } 841 goto out; 842 843 err_end: 844 unlinkat_preserve_errno(dirfd, name, 0); 845 out: 846 close_preserve_errno(dirfd); 847 return err; 848 } 849 850 static int local_link(FsContext *ctx, V9fsPath *oldpath, 851 V9fsPath *dirpath, const char *name) 852 { 853 char *odirpath = g_path_get_dirname(oldpath->data); 854 char *oname = g_path_get_basename(oldpath->data); 855 int ret = -1; 856 int odirfd, ndirfd; 857 858 if (ctx->export_flags & V9FS_SM_MAPPED_FILE && 859 local_is_mapped_file_metadata(ctx, name)) { 860 errno = EINVAL; 861 return -1; 862 } 863 864 odirfd = local_opendir_nofollow(ctx, odirpath); 865 if (odirfd == -1) { 866 goto out; 867 } 868 869 ndirfd = local_opendir_nofollow(ctx, dirpath->data); 870 if (ndirfd == -1) { 871 close_preserve_errno(odirfd); 872 goto out; 873 } 874 875 ret = linkat(odirfd, oname, ndirfd, name, 0); 876 if (ret < 0) { 877 goto out_close; 878 } 879 880 /* now link the virtfs_metadata files */ 881 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { 882 int omap_dirfd, nmap_dirfd; 883 884 ret = mkdirat(ndirfd, VIRTFS_META_DIR, 0700); 885 if (ret < 0 && errno != EEXIST) { 886 goto err_undo_link; 887 } 888 889 omap_dirfd = openat_dir(odirfd, VIRTFS_META_DIR); 890 if (omap_dirfd == -1) { 891 goto err; 892 } 893 894 nmap_dirfd = openat_dir(ndirfd, VIRTFS_META_DIR); 895 if (nmap_dirfd == -1) { 896 close_preserve_errno(omap_dirfd); 897 goto err; 898 } 899 900 ret = linkat(omap_dirfd, oname, nmap_dirfd, name, 0); 901 close_preserve_errno(nmap_dirfd); 902 close_preserve_errno(omap_dirfd); 903 if (ret < 0 && errno != ENOENT) { 904 goto err_undo_link; 905 } 906 907 ret = 0; 908 } 909 goto out_close; 910 911 err: 912 ret = -1; 913 err_undo_link: 914 unlinkat_preserve_errno(ndirfd, name, 0); 915 out_close: 916 close_preserve_errno(ndirfd); 917 close_preserve_errno(odirfd); 918 out: 919 g_free(oname); 920 g_free(odirpath); 921 return ret; 922 } 923 924 static int local_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) 925 { 926 int fd, ret; 927 928 fd = local_open_nofollow(ctx, fs_path->data, O_WRONLY, 0); 929 if (fd == -1) { 930 return -1; 931 } 932 ret = ftruncate(fd, size); 933 close_preserve_errno(fd); 934 return ret; 935 } 936 937 static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) 938 { 939 char *dirpath = g_path_get_dirname(fs_path->data); 940 char *name = g_path_get_basename(fs_path->data); 941 int ret = -1; 942 int dirfd; 943 944 dirfd = local_opendir_nofollow(fs_ctx, dirpath); 945 if (dirfd == -1) { 946 goto out; 947 } 948 949 if ((credp->fc_uid == -1 && credp->fc_gid == -1) || 950 (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || 951 (fs_ctx->export_flags & V9FS_SM_NONE)) { 952 ret = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid, 953 AT_SYMLINK_NOFOLLOW); 954 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) { 955 ret = local_set_xattrat(dirfd, name, credp); 956 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { 957 ret = local_set_mapped_file_attrat(dirfd, name, credp); 958 } 959 960 close_preserve_errno(dirfd); 961 out: 962 g_free(name); 963 g_free(dirpath); 964 return ret; 965 } 966 967 static int local_utimensat(FsContext *s, V9fsPath *fs_path, 968 const struct timespec *buf) 969 { 970 char *dirpath = g_path_get_dirname(fs_path->data); 971 char *name = g_path_get_basename(fs_path->data); 972 int dirfd, ret = -1; 973 974 dirfd = local_opendir_nofollow(s, dirpath); 975 if (dirfd == -1) { 976 goto out; 977 } 978 979 ret = utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); 980 close_preserve_errno(dirfd); 981 out: 982 g_free(dirpath); 983 g_free(name); 984 return ret; 985 } 986 987 static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, 988 int flags) 989 { 990 int ret = -1; 991 992 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { 993 int map_dirfd; 994 995 /* We need to remove the metadata as well: 996 * - the metadata directory if we're removing a directory 997 * - the metadata file in the parent's metadata directory 998 * 999 * If any of these are missing (ie, ENOENT) then we're probably 1000 * trying to remove something that wasn't created in mapped-file 1001 * mode. We just ignore the error. 1002 */ 1003 if (flags == AT_REMOVEDIR) { 1004 int fd; 1005 1006 fd = openat_dir(dirfd, name); 1007 if (fd == -1) { 1008 goto err_out; 1009 } 1010 ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR); 1011 close_preserve_errno(fd); 1012 if (ret < 0 && errno != ENOENT) { 1013 goto err_out; 1014 } 1015 } 1016 map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); 1017 if (map_dirfd != -1) { 1018 ret = unlinkat(map_dirfd, name, 0); 1019 close_preserve_errno(map_dirfd); 1020 if (ret < 0 && errno != ENOENT) { 1021 goto err_out; 1022 } 1023 } else if (errno != ENOENT) { 1024 goto err_out; 1025 } 1026 } 1027 1028 ret = unlinkat(dirfd, name, flags); 1029 err_out: 1030 return ret; 1031 } 1032 1033 static int local_remove(FsContext *ctx, const char *path) 1034 { 1035 struct stat stbuf; 1036 char *dirpath = g_path_get_dirname(path); 1037 char *name = g_path_get_basename(path); 1038 int flags = 0; 1039 int dirfd; 1040 int err = -1; 1041 1042 dirfd = local_opendir_nofollow(ctx, dirpath); 1043 if (dirfd == -1) { 1044 goto out; 1045 } 1046 1047 if (fstatat(dirfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) { 1048 goto err_out; 1049 } 1050 1051 if (S_ISDIR(stbuf.st_mode)) { 1052 flags |= AT_REMOVEDIR; 1053 } 1054 1055 err = local_unlinkat_common(ctx, dirfd, name, flags); 1056 err_out: 1057 close_preserve_errno(dirfd); 1058 out: 1059 g_free(name); 1060 g_free(dirpath); 1061 return err; 1062 } 1063 1064 static int local_fsync(FsContext *ctx, int fid_type, 1065 V9fsFidOpenState *fs, int datasync) 1066 { 1067 int fd; 1068 1069 if (fid_type == P9_FID_DIR) { 1070 fd = dirfd(fs->dir.stream); 1071 } else { 1072 fd = fs->fd; 1073 } 1074 1075 if (datasync) { 1076 return qemu_fdatasync(fd); 1077 } else { 1078 return fsync(fd); 1079 } 1080 } 1081 1082 static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) 1083 { 1084 int fd, ret; 1085 1086 fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0); 1087 if (fd == -1) { 1088 return -1; 1089 } 1090 ret = fstatfs(fd, stbuf); 1091 close_preserve_errno(fd); 1092 return ret; 1093 } 1094 1095 static ssize_t local_lgetxattr(FsContext *ctx, V9fsPath *fs_path, 1096 const char *name, void *value, size_t size) 1097 { 1098 char *path = fs_path->data; 1099 1100 return v9fs_get_xattr(ctx, path, name, value, size); 1101 } 1102 1103 static ssize_t local_llistxattr(FsContext *ctx, V9fsPath *fs_path, 1104 void *value, size_t size) 1105 { 1106 char *path = fs_path->data; 1107 1108 return v9fs_list_xattr(ctx, path, value, size); 1109 } 1110 1111 static int local_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name, 1112 void *value, size_t size, int flags) 1113 { 1114 char *path = fs_path->data; 1115 1116 return v9fs_set_xattr(ctx, path, name, value, size, flags); 1117 } 1118 1119 static int local_lremovexattr(FsContext *ctx, V9fsPath *fs_path, 1120 const char *name) 1121 { 1122 char *path = fs_path->data; 1123 1124 return v9fs_remove_xattr(ctx, path, name); 1125 } 1126 1127 static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path, 1128 const char *name, V9fsPath *target) 1129 { 1130 if (ctx->export_flags & V9FS_SM_MAPPED_FILE && 1131 local_is_mapped_file_metadata(ctx, name)) { 1132 errno = EINVAL; 1133 return -1; 1134 } 1135 1136 if (dir_path) { 1137 v9fs_path_sprintf(target, "%s/%s", dir_path->data, name); 1138 } else if (strcmp(name, "/")) { 1139 v9fs_path_sprintf(target, "%s", name); 1140 } else { 1141 /* We want the path of the export root to be relative, otherwise 1142 * "*at()" syscalls would treat it as "/" in the host. 1143 */ 1144 v9fs_path_sprintf(target, "%s", "."); 1145 } 1146 return 0; 1147 } 1148 1149 static int local_renameat(FsContext *ctx, V9fsPath *olddir, 1150 const char *old_name, V9fsPath *newdir, 1151 const char *new_name) 1152 { 1153 int ret; 1154 int odirfd, ndirfd; 1155 1156 if (ctx->export_flags & V9FS_SM_MAPPED_FILE && 1157 (local_is_mapped_file_metadata(ctx, old_name) || 1158 local_is_mapped_file_metadata(ctx, new_name))) { 1159 errno = EINVAL; 1160 return -1; 1161 } 1162 1163 odirfd = local_opendir_nofollow(ctx, olddir->data); 1164 if (odirfd == -1) { 1165 return -1; 1166 } 1167 1168 ndirfd = local_opendir_nofollow(ctx, newdir->data); 1169 if (ndirfd == -1) { 1170 close_preserve_errno(odirfd); 1171 return -1; 1172 } 1173 1174 ret = renameat(odirfd, old_name, ndirfd, new_name); 1175 if (ret < 0) { 1176 goto out; 1177 } 1178 1179 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { 1180 int omap_dirfd, nmap_dirfd; 1181 1182 ret = mkdirat(ndirfd, VIRTFS_META_DIR, 0700); 1183 if (ret < 0 && errno != EEXIST) { 1184 goto err_undo_rename; 1185 } 1186 1187 omap_dirfd = openat_dir(odirfd, VIRTFS_META_DIR); 1188 if (omap_dirfd == -1) { 1189 goto err; 1190 } 1191 1192 nmap_dirfd = openat_dir(ndirfd, VIRTFS_META_DIR); 1193 if (nmap_dirfd == -1) { 1194 close_preserve_errno(omap_dirfd); 1195 goto err; 1196 } 1197 1198 /* rename the .virtfs_metadata files */ 1199 ret = renameat(omap_dirfd, old_name, nmap_dirfd, new_name); 1200 close_preserve_errno(nmap_dirfd); 1201 close_preserve_errno(omap_dirfd); 1202 if (ret < 0 && errno != ENOENT) { 1203 goto err_undo_rename; 1204 } 1205 1206 ret = 0; 1207 } 1208 goto out; 1209 1210 err: 1211 ret = -1; 1212 err_undo_rename: 1213 renameat_preserve_errno(ndirfd, new_name, odirfd, old_name); 1214 out: 1215 close_preserve_errno(ndirfd); 1216 close_preserve_errno(odirfd); 1217 return ret; 1218 } 1219 1220 static void v9fs_path_init_dirname(V9fsPath *path, const char *str) 1221 { 1222 path->data = g_path_get_dirname(str); 1223 path->size = strlen(path->data) + 1; 1224 } 1225 1226 static int local_rename(FsContext *ctx, const char *oldpath, 1227 const char *newpath) 1228 { 1229 int err; 1230 char *oname = g_path_get_basename(oldpath); 1231 char *nname = g_path_get_basename(newpath); 1232 V9fsPath olddir, newdir; 1233 1234 v9fs_path_init_dirname(&olddir, oldpath); 1235 v9fs_path_init_dirname(&newdir, newpath); 1236 1237 err = local_renameat(ctx, &olddir, oname, &newdir, nname); 1238 1239 v9fs_path_free(&newdir); 1240 v9fs_path_free(&olddir); 1241 g_free(nname); 1242 g_free(oname); 1243 1244 return err; 1245 } 1246 1247 static int local_unlinkat(FsContext *ctx, V9fsPath *dir, 1248 const char *name, int flags) 1249 { 1250 int ret; 1251 int dirfd; 1252 1253 if (ctx->export_flags & V9FS_SM_MAPPED_FILE && 1254 local_is_mapped_file_metadata(ctx, name)) { 1255 errno = EINVAL; 1256 return -1; 1257 } 1258 1259 dirfd = local_opendir_nofollow(ctx, dir->data); 1260 if (dirfd == -1) { 1261 return -1; 1262 } 1263 1264 ret = local_unlinkat_common(ctx, dirfd, name, flags); 1265 close_preserve_errno(dirfd); 1266 return ret; 1267 } 1268 1269 static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, 1270 mode_t st_mode, uint64_t *st_gen) 1271 { 1272 #ifdef FS_IOC_GETVERSION 1273 int err; 1274 V9fsFidOpenState fid_open; 1275 1276 /* 1277 * Do not try to open special files like device nodes, fifos etc 1278 * We can get fd for regular files and directories only 1279 */ 1280 if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { 1281 errno = ENOTTY; 1282 return -1; 1283 } 1284 err = local_open(ctx, path, O_RDONLY, &fid_open); 1285 if (err < 0) { 1286 return err; 1287 } 1288 err = ioctl(fid_open.fd, FS_IOC_GETVERSION, st_gen); 1289 local_close(ctx, &fid_open); 1290 return err; 1291 #else 1292 errno = ENOTTY; 1293 return -1; 1294 #endif 1295 } 1296 1297 static int local_init(FsContext *ctx) 1298 { 1299 struct statfs stbuf; 1300 LocalData *data = g_malloc(sizeof(*data)); 1301 1302 data->mountfd = open(ctx->fs_root, O_DIRECTORY | O_RDONLY); 1303 if (data->mountfd == -1) { 1304 goto err; 1305 } 1306 1307 #ifdef FS_IOC_GETVERSION 1308 /* 1309 * use ioc_getversion only if the ioctl is definied 1310 */ 1311 if (fstatfs(data->mountfd, &stbuf) < 0) { 1312 close_preserve_errno(data->mountfd); 1313 goto err; 1314 } 1315 switch (stbuf.f_type) { 1316 case EXT2_SUPER_MAGIC: 1317 case BTRFS_SUPER_MAGIC: 1318 case REISERFS_SUPER_MAGIC: 1319 case XFS_SUPER_MAGIC: 1320 ctx->exops.get_st_gen = local_ioc_getversion; 1321 break; 1322 } 1323 #endif 1324 1325 if (ctx->export_flags & V9FS_SM_PASSTHROUGH) { 1326 ctx->xops = passthrough_xattr_ops; 1327 } else if (ctx->export_flags & V9FS_SM_MAPPED) { 1328 ctx->xops = mapped_xattr_ops; 1329 } else if (ctx->export_flags & V9FS_SM_NONE) { 1330 ctx->xops = none_xattr_ops; 1331 } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { 1332 /* 1333 * xattr operation for mapped-file and passthrough 1334 * remain same. 1335 */ 1336 ctx->xops = passthrough_xattr_ops; 1337 } 1338 ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT; 1339 1340 ctx->private = data; 1341 return 0; 1342 1343 err: 1344 g_free(data); 1345 return -1; 1346 } 1347 1348 static void local_cleanup(FsContext *ctx) 1349 { 1350 LocalData *data = ctx->private; 1351 1352 close(data->mountfd); 1353 g_free(data); 1354 } 1355 1356 static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse) 1357 { 1358 const char *sec_model = qemu_opt_get(opts, "security_model"); 1359 const char *path = qemu_opt_get(opts, "path"); 1360 Error *err = NULL; 1361 1362 if (!sec_model) { 1363 error_report("Security model not specified, local fs needs security model"); 1364 error_printf("valid options are:" 1365 "\tsecurity_model=[passthrough|mapped-xattr|mapped-file|none]\n"); 1366 return -1; 1367 } 1368 1369 if (!strcmp(sec_model, "passthrough")) { 1370 fse->export_flags |= V9FS_SM_PASSTHROUGH; 1371 } else if (!strcmp(sec_model, "mapped") || 1372 !strcmp(sec_model, "mapped-xattr")) { 1373 fse->export_flags |= V9FS_SM_MAPPED; 1374 } else if (!strcmp(sec_model, "none")) { 1375 fse->export_flags |= V9FS_SM_NONE; 1376 } else if (!strcmp(sec_model, "mapped-file")) { 1377 fse->export_flags |= V9FS_SM_MAPPED_FILE; 1378 } else { 1379 error_report("Invalid security model %s specified", sec_model); 1380 error_printf("valid options are:" 1381 "\t[passthrough|mapped-xattr|mapped-file|none]\n"); 1382 return -1; 1383 } 1384 1385 if (!path) { 1386 error_report("fsdev: No path specified"); 1387 return -1; 1388 } 1389 1390 fsdev_throttle_parse_opts(opts, &fse->fst, &err); 1391 if (err) { 1392 error_reportf_err(err, "Throttle configuration is not valid: "); 1393 return -1; 1394 } 1395 1396 fse->path = g_strdup(path); 1397 1398 return 0; 1399 } 1400 1401 FileOperations local_ops = { 1402 .parse_opts = local_parse_opts, 1403 .init = local_init, 1404 .cleanup = local_cleanup, 1405 .lstat = local_lstat, 1406 .readlink = local_readlink, 1407 .close = local_close, 1408 .closedir = local_closedir, 1409 .open = local_open, 1410 .opendir = local_opendir, 1411 .rewinddir = local_rewinddir, 1412 .telldir = local_telldir, 1413 .readdir = local_readdir, 1414 .seekdir = local_seekdir, 1415 .preadv = local_preadv, 1416 .pwritev = local_pwritev, 1417 .chmod = local_chmod, 1418 .mknod = local_mknod, 1419 .mkdir = local_mkdir, 1420 .fstat = local_fstat, 1421 .open2 = local_open2, 1422 .symlink = local_symlink, 1423 .link = local_link, 1424 .truncate = local_truncate, 1425 .rename = local_rename, 1426 .chown = local_chown, 1427 .utimensat = local_utimensat, 1428 .remove = local_remove, 1429 .fsync = local_fsync, 1430 .statfs = local_statfs, 1431 .lgetxattr = local_lgetxattr, 1432 .llistxattr = local_llistxattr, 1433 .lsetxattr = local_lsetxattr, 1434 .lremovexattr = local_lremovexattr, 1435 .name_to_path = local_name_to_path, 1436 .renameat = local_renameat, 1437 .unlinkat = local_unlinkat, 1438 }; 1439