2 * Virtio 9p backend for Maru
3 * Based on hw/9pfs/virtio-9p-local.c:
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
8 * Sooyoung Ha <yoosah.ha@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include "hw/virtio/virtio.h"
31 #include "virtio-9p.h"
33 #include "virtio-9p-xattr.h"
34 #include <arpa/inet.h>
37 #include <sys/socket.h>
39 #include "qemu/xattr.h"
45 #ifdef CONFIG_LINUX_MAGIC_H
46 #include <linux/magic.h>
49 #include <sys/ioctl.h>
52 #include "../../tizen/src/debug_ch.h"
53 MULTI_DEBUG_CHANNEL(tizen, qemu_9p_local);
55 #ifndef XFS_SUPER_MAGIC
56 #define XFS_SUPER_MAGIC 0x58465342
58 #ifndef EXT2_SUPER_MAGIC
59 #define EXT2_SUPER_MAGIC 0xEF53
61 #ifndef REISERFS_SUPER_MAGIC
62 #define REISERFS_SUPER_MAGIC 0x52654973
64 #ifndef BTRFS_SUPER_MAGIC
65 #define BTRFS_SUPER_MAGIC 0x9123683E
69 #ifndef MSDOS_SUPER_MAGIC
70 #define MSDOS_SUPER_MAGIC 0x4d44
72 #ifndef NTFS_SUPER_MAGIC
73 #define NTFS_SUPER_MAGIC 0x5346544e
76 uint64_t hostBytesPerSector = -1;
79 #define VIRTFS_META_DIR ".virtfs_metadata"
82 #define AT_REMOVEDIR 0x200
85 static const char *local_mapped_attr_path(FsContext *ctx,
86 const char *path, char *buffer)
89 char *tmp_path = g_strdup(path);
90 char *base_name = basename(tmp_path);
92 /* NULL terminate the directory */
94 *(base_name - 1) = '\0';
96 snprintf(buffer, PATH_MAX, "%s/%s/%s/%s",
97 ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
99 snprintf(buffer, PATH_MAX, "%s\\%s\\%s\\%s",
100 ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
101 while(buffer[strlen(buffer)-1] == '\\'){
102 buffer[strlen(buffer)-1] = '\0';
109 static FILE *local_fopen(const char *path, const char *mode)
111 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
117 int flags = O_NOFOLLOW;
119 * only supports two modes
121 if (mode[0] == 'r') {
123 } else if (mode[0] == 'w') {
124 flags |= O_WRONLY | O_TRUNC | O_CREAT;
126 o_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
132 fd = open(path, flags, o_mode);
134 fd = open(path, flags | O_BINARY);
139 fp = fdopen(fd, mode);
148 static void local_mapped_file_attr(FsContext *ctx, const char *path,
151 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
154 char attr_path[PATH_MAX];
156 local_mapped_attr_path(ctx, path, attr_path);
157 fp = local_fopen(attr_path, "r");
161 memset(buf, 0, ATTR_MAX);
162 while (fgets(buf, ATTR_MAX, fp)) {
163 if (!strncmp(buf, "virtfs.uid", 10)) {
164 stbuf->st_uid = atoi(buf+11);
165 } else if (!strncmp(buf, "virtfs.gid", 10)) {
166 stbuf->st_gid = atoi(buf+11);
167 } else if (!strncmp(buf, "virtfs.mode", 11)) {
168 stbuf->st_mode = atoi(buf+12);
169 } else if (!strncmp(buf, "virtfs.rdev", 11)) {
170 stbuf->st_rdev = atoi(buf+12);
172 memset(buf, 0, ATTR_MAX);
178 static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
180 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
182 char buffer[PATH_MAX];
183 char *path = fs_path->data;
186 err = lstat(rpath(fs_ctx, path, buffer), stbuf);
190 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
191 /* Actual credentials are part of extended attrs */
197 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.uid", &tmp_uid,
198 sizeof(uid_t)) > 0) {
199 stbuf->st_uid = tmp_uid;
201 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.gid", &tmp_gid,
202 sizeof(gid_t)) > 0) {
203 stbuf->st_gid = tmp_gid;
205 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.mode",
206 &tmp_mode, sizeof(mode_t)) > 0) {
207 stbuf->st_mode = tmp_mode;
209 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.rdev", &tmp_dev,
210 sizeof(dev_t)) > 0) {
211 stbuf->st_rdev = tmp_dev;
215 * extra two parameters on Mac OS X.
216 * first one is position which specifies an offset within the extended attribute.
217 * i.e. extended attribute means "user.virtfs.uid". Currently, it is only used with
218 * resource fork attribute and all other extended attributes, it is reserved and should be zero.
219 * second one is options which specify option for retrieving extended attributes:
220 * (XATTR_NOFOLLOW, XATTR_SHOWCOMPRESSION)
222 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.uid", &tmp_uid,
223 sizeof(uid_t), 0, 0) > 0) {
224 stbuf->st_uid = tmp_uid;
226 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.gid", &tmp_gid,
227 sizeof(gid_t), 0, 0) > 0) {
228 stbuf->st_gid = tmp_gid;
230 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.mode",
231 &tmp_mode, sizeof(mode_t), 0, 0) > 0) {
232 stbuf->st_mode = tmp_mode;
234 if (getxattr(rpath(fs_ctx, path, buffer), "user.virtfs.rdev", &tmp_dev,
235 sizeof(dev_t), 0, 0) > 0) {
236 stbuf->st_rdev = tmp_dev;
239 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
240 local_mapped_file_attr(fs_ctx, path, stbuf);
243 const char * pathname = rpath(fs_ctx, path, buffer);
244 if (hostBytesPerSector == -1) {
245 DWORD BytesPerSector;
246 TCHAR tmpName[PATH_MAX] = {0};
248 strncpy(tmpName, pathname, 3 > PATH_MAX ? PATH_MAX : 3);
249 tmpName[4 > PATH_MAX ? PATH_MAX : 4] = '\0';
250 LPCTSTR RootPathName = (LPCTSTR)tmpName;
252 GetDiskFreeSpace(RootPathName, NULL, &BytesPerSector, NULL, NULL);
253 hostBytesPerSector = BytesPerSector;
255 err = _stat(pathname, stbuf);
257 /* Modify the permission to 777 except the directories. */
258 stbuf->st_mode = stbuf->st_mode | 0777;
263 static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
265 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
267 char attr_dir[PATH_MAX];
268 char *tmp_path = g_strdup(path);
270 snprintf(attr_dir, PATH_MAX, "%s/%s/%s",
271 ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
272 err = mkdir(attr_dir, 0700);
274 snprintf(attr_dir, PATH_MAX, "%s\\%s\\%s",
275 ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
276 err = mkdir(attr_dir);
279 if (err < 0 && errno == EEXIST) {
286 static int local_set_mapped_file_attr(FsContext *ctx,
287 const char *path, FsCred *credp)
289 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
293 char attr_path[PATH_MAX];
294 int uid = -1, gid = -1, mode = -1, rdev = -1;
296 fp = local_fopen(local_mapped_attr_path(ctx, path, attr_path), "r");
298 goto create_map_file;
300 memset(buf, 0, ATTR_MAX);
301 while (fgets(buf, ATTR_MAX, fp)) {
302 if (!strncmp(buf, "virtfs.uid", 10)) {
304 } else if (!strncmp(buf, "virtfs.gid", 10)) {
306 } else if (!strncmp(buf, "virtfs.mode", 11)) {
308 } else if (!strncmp(buf, "virtfs.rdev", 11)) {
311 memset(buf, 0, ATTR_MAX);
314 goto update_map_file;
317 ret = local_create_mapped_attr_dir(ctx, path);
323 fp = local_fopen(attr_path, "w");
329 if (credp->fc_uid != -1) {
332 if (credp->fc_gid != -1) {
335 if (credp->fc_mode != -1) {
336 mode = credp->fc_mode;
338 if (credp->fc_rdev != -1) {
339 rdev = credp->fc_rdev;
343 fprintf(fp, "virtfs.uid=%d\n", uid);
346 fprintf(fp, "virtfs.gid=%d\n", gid);
349 fprintf(fp, "virtfs.mode=%d\n", mode);
352 fprintf(fp, "virtfs.rdev=%d\n", rdev);
361 static int local_set_xattr(const char *path, FsCred *credp)
366 if (credp->fc_uid != -1) {
367 err = setxattr(path, "user.virtfs.uid", &credp->fc_uid, sizeof(uid_t),
373 if (credp->fc_gid != -1) {
374 err = setxattr(path, "user.virtfs.gid", &credp->fc_gid, sizeof(gid_t),
380 if (credp->fc_mode != -1) {
381 err = setxattr(path, "user.virtfs.mode", &credp->fc_mode,
387 if (credp->fc_rdev != -1) {
388 err = setxattr(path, "user.virtfs.rdev", &credp->fc_rdev,
396 * In case of setxattr on OS X, position parameter has been added.
397 * Its purpose is the same as getxattr. Last parameter options is the same as flags on Linux.
398 * XATTR_NOFOLLOW / XATTR_CREATE / XATTR_REPLACE
400 if (credp->fc_uid != -1) {
401 err = setxattr(path, "user.virtfs.uid", &credp->fc_uid, sizeof(uid_t),
407 if (credp->fc_gid != -1) {
408 err = setxattr(path, "user.virtfs.gid", &credp->fc_gid, sizeof(gid_t),
414 if (credp->fc_mode != -1) {
415 err = setxattr(path, "user.virtfs.mode", &credp->fc_mode,
416 sizeof(mode_t), 0, 0);
421 if (credp->fc_rdev != -1) {
422 err = setxattr(path, "user.virtfs.rdev", &credp->fc_rdev,
423 sizeof(dev_t), 0, 0);
434 static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,
438 char buffer[PATH_MAX];
440 if (lchown(rpath(fs_ctx, path, buffer), credp->fc_uid,
441 credp->fc_gid) < 0) {
443 * If we fail to change ownership and if we are
444 * using security model none. Ignore the error
446 if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {
451 if (chmod(rpath(fs_ctx, path, buffer), credp->fc_mode & 07777) < 0) {
458 static ssize_t local_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
459 char *buf, size_t bufsz)
461 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
464 char buffer[PATH_MAX];
465 char *path = fs_path->data;
467 if ((fs_ctx->export_flags & V9FS_SM_MAPPED) ||
468 (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE)) {
470 fd = open(rpath(fs_ctx, path, buffer), O_RDONLY | O_NOFOLLOW);
475 tsize = read(fd, (void *)buf, bufsz);
476 } while (tsize == -1 && errno == EINTR);
479 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
480 (fs_ctx->export_flags & V9FS_SM_NONE)) {
481 tsize = readlink(rpath(fs_ctx, path, buffer), buf, bufsz);
487 static int local_close(FsContext *ctx, V9fsFidOpenState *fs)
489 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
490 return close(fs->fd);
493 static int local_closedir(FsContext *ctx, V9fsFidOpenState *fs)
495 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
496 return closedir(fs->dir);
499 static int local_open(FsContext *ctx, V9fsPath *fs_path,
500 int flags, V9fsFidOpenState *fs)
502 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
503 char buffer[PATH_MAX];
504 char *path = fs_path->data;
509 fs->fd = open(rpath(ctx, path, buffer), flags | O_NOFOLLOW);
514 static int local_opendir(FsContext *ctx,
515 V9fsPath *fs_path, V9fsFidOpenState *fs)
517 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
518 char buffer[PATH_MAX];
519 char *path = fs_path->data;
521 fs->dir = opendir(rpath(ctx, path, buffer));
528 static void local_rewinddir(FsContext *ctx, V9fsFidOpenState *fs)
530 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
531 return rewinddir(fs->dir);
534 static off_t local_telldir(FsContext *ctx, V9fsFidOpenState *fs)
536 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
537 return telldir(fs->dir);
540 static int local_readdir_r(FsContext *ctx, V9fsFidOpenState *fs,
541 struct dirent *entry,
542 struct dirent **result)
544 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
549 ret = readdir_r(fs->dir, entry, result);
550 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
551 if (!ret && *result != NULL &&
552 !strcmp(entry->d_name, VIRTFS_META_DIR)) {
553 /* skp the meta data directory */
559 *result = readdir(fs->dir);
560 ret = (ret == errno ? 0 : errno);
562 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
563 if (!ret && *result != NULL &&
564 !strcmp(entry->d_name, VIRTFS_META_DIR)) {
565 /* skp the meta data directory */
573 static void local_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)
575 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
576 return seekdir(fs->dir, off);
579 static ssize_t local_preadv(FsContext *ctx, V9fsFidOpenState *fs,
580 const struct iovec *iov,
581 int iovcnt, off_t offset)
584 return preadv(fs->fd, iov, iovcnt, offset);
586 int err = lseek(fs->fd, offset, SEEK_SET);
590 return readv(fs->fd, iov, iovcnt);
595 static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
596 const struct iovec *iov,
597 int iovcnt, off_t offset)
602 ret = pwritev(fs->fd, iov, iovcnt, offset);
604 int err = lseek(fs->fd, offset, SEEK_SET);
608 ret = writev(fs->fd, iov, iovcnt);
611 #ifdef CONFIG_SYNC_FILE_RANGE
612 if (ret > 0 && ctx->export_flags & V9FS_IMMEDIATE_WRITEOUT) {
614 * Initiate a writeback. This is not a data integrity sync.
615 * We want to ensure that we don't leave dirty pages in the cache
616 * after write when writeout=immediate is sepcified.
618 sync_file_range(fs->fd, offset, ret,
619 SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE);
625 static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
627 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
629 char buffer[PATH_MAX];
630 char *path = fs_path->data;
632 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
633 return local_set_xattr(rpath(fs_ctx, path, buffer), credp);
634 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
635 return local_set_mapped_file_attr(fs_ctx, path, credp);
636 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
637 (fs_ctx->export_flags & V9FS_SM_NONE)) {
638 return chmod(rpath(fs_ctx, path, buffer), credp->fc_mode);
644 static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path,
645 const char *name, FsCred *credp)
647 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
653 char buffer[PATH_MAX];
655 v9fs_string_init(&fullname);
656 v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
657 path = fullname.data;
659 /* Determine the security model */
660 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
661 err = mknod(rpath(fs_ctx, path, buffer),
662 SM_LOCAL_MODE_BITS|S_IFREG, 0);
666 err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
671 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
673 err = mknod(rpath(fs_ctx, path, buffer),
674 SM_LOCAL_MODE_BITS|S_IFREG, 0);
678 err = local_set_mapped_file_attr(fs_ctx, path, credp);
683 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
684 (fs_ctx->export_flags & V9FS_SM_NONE)) {
685 err = mknod(rpath(fs_ctx, path, buffer), credp->fc_mode,
690 err = local_post_create_passthrough(fs_ctx, path, credp);
699 remove(rpath(fs_ctx, path, buffer));
702 v9fs_string_free(&fullname);
707 static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
708 const char *name, FsCred *credp)
710 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
715 char buffer[PATH_MAX];
717 v9fs_string_init(&fullname);
719 v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
721 v9fs_string_sprintf(&fullname, "%s\\%s", dir_path->data, name);
722 while((fullname.data)[strlen(fullname.data)-1] == '\\'){
723 (fullname.data)[strlen(fullname.data)-1] = '\0';
726 path = fullname.data;
729 /* Determine the security model */
730 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
731 err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
735 credp->fc_mode = credp->fc_mode|S_IFDIR;
736 err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
741 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
742 err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);
746 credp->fc_mode = credp->fc_mode|S_IFDIR;
747 err = local_set_mapped_file_attr(fs_ctx, path, credp);
752 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
753 (fs_ctx->export_flags & V9FS_SM_NONE)) {
754 err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode);
758 err = local_post_create_passthrough(fs_ctx, path, credp);
765 err = mkdir(rpath(fs_ctx, path, buffer));
770 remove(rpath(fs_ctx, path, buffer));
773 v9fs_string_free(&fullname);
777 static int local_fstat(FsContext *fs_ctx, int fid_type,
778 V9fsFidOpenState *fs, struct stat *stbuf)
780 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
783 if (fid_type == P9_FID_DIR) {
793 err = fstat(fd, stbuf);
797 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
799 /* Actual credentials are part of extended attrs */
806 if (fgetxattr(fd, "user.virtfs.uid",
807 &tmp_uid, sizeof(uid_t)) > 0) {
808 stbuf->st_uid = tmp_uid;
810 if (fgetxattr(fd, "user.virtfs.gid",
811 &tmp_gid, sizeof(gid_t)) > 0) {
812 stbuf->st_gid = tmp_gid;
814 if (fgetxattr(fd, "user.virtfs.mode",
815 &tmp_mode, sizeof(mode_t)) > 0) {
816 stbuf->st_mode = tmp_mode;
818 if (fgetxattr(fd, "user.virtfs.rdev",
819 &tmp_dev, sizeof(dev_t)) > 0) {
820 stbuf->st_rdev = tmp_dev;
823 if (fgetxattr(fd, "user.virtfs.uid",
824 &tmp_uid, sizeof(uid_t), 0, 0) > 0) {
825 stbuf->st_uid = tmp_uid;
827 if (fgetxattr(fd, "user.virtfs.gid",
828 &tmp_gid, sizeof(gid_t), 0, 0) > 0) {
829 stbuf->st_gid = tmp_gid;
831 if (fgetxattr(fd, "user.virtfs.mode",
832 &tmp_mode, sizeof(mode_t), 0, 0) > 0) {
833 stbuf->st_mode = tmp_mode;
835 if (fgetxattr(fd, "user.virtfs.rdev",
836 &tmp_dev, sizeof(dev_t), 0, 0) > 0) {
837 stbuf->st_rdev = tmp_dev;
841 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
848 static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name,
849 int flags, FsCred *credp, V9fsFidOpenState *fs)
851 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
857 char buffer[PATH_MAX];
860 * Mark all the open to not follow symlinks
864 v9fs_string_init(&fullname);
866 v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
868 v9fs_string_sprintf(&fullname, "%s\\%s", dir_path->data, name);
871 path = fullname.data;
873 /* Determine the security model */
874 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
875 fd = open(rpath(fs_ctx, path, buffer), flags, SM_LOCAL_MODE_BITS);
881 credp->fc_mode = credp->fc_mode|S_IFREG;
882 /* Set cleint credentials in xattr */
883 err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);
889 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
890 fd = open(rpath(fs_ctx, path, buffer), flags, SM_LOCAL_MODE_BITS);
895 credp->fc_mode = credp->fc_mode|S_IFREG;
896 /* Set client credentials in .virtfs_metadata directory files */
897 err = local_set_mapped_file_attr(fs_ctx, path, credp);
902 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
903 (fs_ctx->export_flags & V9FS_SM_NONE)) {
904 fd = open(rpath(fs_ctx, path, buffer), flags, credp->fc_mode);
909 err = local_post_create_passthrough(fs_ctx, path, credp);
921 remove(rpath(fs_ctx, path, buffer));
924 v9fs_string_free(&fullname);
928 static int local_symlink(FsContext *fs_ctx, const char *oldpath,
929 V9fsPath *dir_path, const char *name, FsCred *credp)
931 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
937 char buffer[PATH_MAX];
939 int flags = O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW;
941 v9fs_string_init(&fullname);
942 v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
943 newpath = fullname.data;
945 /* Determine the security model */
946 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
948 ssize_t oldpath_size, write_size;
949 fd = open(rpath(fs_ctx, newpath, buffer), flags, SM_LOCAL_MODE_BITS);
954 /* Write the oldpath (target) to the file. */
955 oldpath_size = strlen(oldpath);
957 write_size = write(fd, (void *)oldpath, oldpath_size);
958 } while (write_size == -1 && errno == EINTR);
960 if (write_size != oldpath_size) {
967 /* Set cleint credentials in symlink's xattr */
968 credp->fc_mode = credp->fc_mode|S_IFLNK;
969 err = local_set_xattr(rpath(fs_ctx, newpath, buffer), credp);
974 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
976 ssize_t oldpath_size, write_size;
977 fd = open(rpath(fs_ctx, newpath, buffer), flags, SM_LOCAL_MODE_BITS);
982 /* Write the oldpath (target) to the file. */
983 oldpath_size = strlen(oldpath);
985 write_size = write(fd, (void *)oldpath, oldpath_size);
986 } while (write_size == -1 && errno == EINTR);
988 if (write_size != oldpath_size) {
995 /* Set cleint credentials in symlink's xattr */
996 credp->fc_mode = credp->fc_mode|S_IFLNK;
997 err = local_set_mapped_file_attr(fs_ctx, newpath, credp);
1002 } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
1003 (fs_ctx->export_flags & V9FS_SM_NONE)) {
1004 err = symlink(oldpath, rpath(fs_ctx, newpath, buffer));
1008 err = lchown(rpath(fs_ctx, newpath, buffer), credp->fc_uid,
1012 * If we fail to change ownership and if we are
1013 * using security model none. Ignore the error
1015 if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {
1025 remove(rpath(fs_ctx, newpath, buffer));
1028 v9fs_string_free(&fullname);
1033 static int local_link(FsContext *ctx, V9fsPath *oldpath,
1034 V9fsPath *dirpath, const char *name)
1036 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1038 #ifndef CONFIG_WIN32
1040 char buffer[PATH_MAX], buffer1[PATH_MAX];
1042 v9fs_string_init(&newpath);
1043 v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name);
1045 ret = link(rpath(ctx, oldpath->data, buffer),
1046 rpath(ctx, newpath.data, buffer1));
1048 /* now link the virtfs_metadata files */
1049 if (!ret && (ctx->export_flags & V9FS_SM_MAPPED_FILE)) {
1050 /* Link the .virtfs_metadata files. Create the metada directory */
1051 ret = local_create_mapped_attr_dir(ctx, newpath.data);
1055 ret = link(local_mapped_attr_path(ctx, oldpath->data, buffer),
1056 local_mapped_attr_path(ctx, newpath.data, buffer1));
1057 if (ret < 0 && errno != ENOENT) {
1062 v9fs_string_free(&newpath);
1067 static int local_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size)
1069 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1070 char buffer[PATH_MAX];
1071 char *path = fs_path->data;
1072 #ifndef CONFIG_WIN32
1073 return truncate(rpath(ctx, path, buffer), size);
1076 int fd = open(rpath(ctx, path, buffer), O_RDWR | O_BINARY | O_NOFOLLOW);
1080 ret = ftruncate(fd, size);
1087 static int local_rename(FsContext *ctx, const char *oldpath,
1088 const char *newpath)
1090 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1092 char buffer[PATH_MAX], buffer1[PATH_MAX];
1094 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
1095 err = local_create_mapped_attr_dir(ctx, newpath);
1099 /* rename the .virtfs_metadata files */
1100 err = rename(local_mapped_attr_path(ctx, oldpath, buffer),
1101 local_mapped_attr_path(ctx, newpath, buffer1));
1102 if (err < 0 && errno != ENOENT) {
1106 #ifndef CONFIG_WIN32
1107 return rename(rpath(ctx, oldpath, buffer), rpath(ctx, newpath, buffer1));
1109 if (!MoveFileEx((LPCTSTR)rpath(ctx, oldpath, buffer),
1110 (LPCTSTR)rpath(ctx, newpath, buffer1), MOVEFILE_REPLACE_EXISTING)){
1111 err = -(GetLastError());
1112 ERR("[%d][ >> %s] err: %d\n", __LINE__, __func__, err);
1120 static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
1122 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1123 #ifndef CONFIG_WIN32
1124 char buffer[PATH_MAX];
1125 char *path = fs_path->data;
1127 if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
1128 (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
1129 (fs_ctx->export_flags & V9FS_SM_NONE)) {
1130 return lchown(rpath(fs_ctx, path, buffer),
1131 credp->fc_uid, credp->fc_gid);
1132 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
1133 return local_set_xattr(rpath(fs_ctx, path, buffer), credp);
1134 } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
1135 return local_set_mapped_file_attr(fs_ctx, path, credp);
1142 /* The function that change file last access and modification times for WIN32 */
1143 static int win_utimes (const char *filename, const struct timeval tv[2])
1145 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1147 FILETIME LastAccessTime, LastWriteTime;
1149 ULARGE_INTEGER tmpTime;
1151 ULONGLONG WindowsUnixTimeGap = 11644473600; // between 1601.01.01 and 1970.01.01
1152 ULONGLONG WindowsSecond = 10000000; // 1sec / 100nanosec
1156 HANDLE hFile = CreateFile(filename, FILE_WRITE_ATTRIBUTES,
1157 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
1158 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
1159 if (hFile == INVALID_HANDLE_VALUE) {
1160 if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) {
1167 if (!tv) { // case of NULL
1168 GetSystemTimeAsFileTime(&LastAccessTime);
1169 LastWriteTime = LastAccessTime;
1171 tmpTime.QuadPart = UInt32x32To64(WindowsUnixTimeGap + tv[0].tv_sec, WindowsSecond)
1172 + tv[0].tv_usec * 10;
1173 LastAccessTime.dwHighDateTime = tmpTime.HighPart;
1174 LastAccessTime.dwLowDateTime = tmpTime.LowPart;
1176 tmpTime.QuadPart = UInt32x32To64(WindowsUnixTimeGap + tv[1].tv_sec, WindowsSecond)
1177 + tv[1].tv_usec * 10;
1178 LastWriteTime.dwHighDateTime = tmpTime.HighPart;
1179 LastWriteTime.dwLowDateTime = tmpTime.LowPart;
1181 if (!SetFileTime(hFile, NULL, &LastAccessTime, &LastWriteTime)) {
1195 static int local_utimensat(FsContext *s, V9fsPath *fs_path,
1196 const struct timespec *buf)
1198 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1199 char buffer[PATH_MAX];
1200 char *path = fs_path->data;
1201 #ifndef CONFIG_WIN32
1202 return qemu_utimens(rpath(s, path, buffer), buf);
1204 const char * r_path = rpath(s, path, buffer);
1205 struct timeval tv[2], tv_now;
1209 /* happy if special cases */
1210 if (buf[0].tv_nsec == UTIME_OMIT && buf[1].tv_nsec == UTIME_OMIT) {
1213 if (buf[0].tv_nsec == UTIME_NOW && buf[1].tv_nsec == UTIME_NOW) {
1214 return win_utimes(r_path, NULL);
1217 /* prepare for hard cases */
1218 if (buf[0].tv_nsec == UTIME_NOW || buf[1].tv_nsec == UTIME_NOW) {
1219 gettimeofday(&tv_now, NULL);
1221 if (buf[0].tv_nsec == UTIME_OMIT || buf[1].tv_nsec == UTIME_OMIT) {
1225 for (i = 0; i < 2; i++) {
1226 if (buf[i].tv_nsec == UTIME_NOW) {
1227 tv[i].tv_sec = tv_now.tv_sec;
1228 tv[i].tv_usec = tv_now.tv_usec;
1229 } else if (buf[i].tv_nsec == UTIME_OMIT) {
1230 tv[i].tv_sec = (i == 0) ? st.st_atime : st.st_mtime;
1233 tv[i].tv_sec = buf[i].tv_sec;
1234 tv[i].tv_usec = buf[i].tv_nsec / 1000;
1238 return win_utimes(r_path, &tv[0]);
1242 static int local_remove(FsContext *ctx, const char *path)
1244 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1247 char buffer[PATH_MAX];
1249 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
1250 #ifndef CONFIG_WIN32
1251 err = lstat(rpath(ctx, path, buffer), &stbuf);
1253 err = _stat(rpath(ctx, path, buffer), &stbuf);
1259 * If directory remove .virtfs_metadata contained in the
1262 if (S_ISDIR(stbuf.st_mode)) {
1263 #ifndef CONFIG_WIN32
1264 sprintf(buffer, "%s/%s/%s", ctx->fs_root, path, VIRTFS_META_DIR);
1266 sprintf(buffer, "%s\\%s\\%s", ctx->fs_root, path, VIRTFS_META_DIR);
1268 err = remove(buffer);
1269 if (err < 0 && errno != ENOENT) {
1271 * We didn't had the .virtfs_metadata file. May be file created
1272 * in non-mapped mode ?. Ignore ENOENT.
1278 * Now remove the name from parent directory
1279 * .virtfs_metadata directory
1281 err = remove(local_mapped_attr_path(ctx, path, buffer));
1282 if (err < 0 && errno != ENOENT) {
1284 * We didn't had the .virtfs_metadata file. May be file created
1285 * in non-mapped mode ?. Ignore ENOENT.
1290 return remove(rpath(ctx, path, buffer));
1295 static int local_fsync(FsContext *ctx, int fid_type,
1296 V9fsFidOpenState *fs, int datasync)
1298 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1301 if (fid_type == P9_FID_DIR) {
1302 #ifndef CONFIG_WIN32
1303 fd = dirfd(fs->dir);
1310 #ifndef CONFIG_WIN32
1312 return qemu_fdatasync(fd);
1321 static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)
1323 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1324 char buffer[PATH_MAX];
1325 char *path = fs_path->data;
1327 #ifndef CONFIG_WIN32
1328 return statfs(rpath(s, path, buffer), stbuf);
1330 DWORD VolumeSerialNumber,
1331 MaximumComponentLength,
1334 DWORD SectorsPerCluster,
1336 NumberOfFreeClusters,
1337 TotalNumberOfClusters,
1340 ULARGE_INTEGER TotalNumberOfBytes,
1341 TotalNumberOfFreeBytes,
1342 FreeBytesAvailableToCaller;
1344 TCHAR tmpName[PATH_MAX] = {0};
1345 TCHAR VolumeNameBuffer[PATH_MAX] = {0};
1346 TCHAR FileSystemNameBuffer[PATH_MAX] = {0};
1348 strncpy(tmpName, rpath(s, path, buffer), 3 > PATH_MAX ? PATH_MAX : 3);
1349 tmpName[4 > PATH_MAX ? PATH_MAX : 4] = '\0';
1350 LPCTSTR RootPathName = (LPCTSTR)tmpName;
1352 if (RootPathName == NULL) {
1353 ERR("[%d][%s] >> err = %d\n", __LINE__, __func__, GetLastError());
1358 if (!GetVolumeInformation(RootPathName, (LPTSTR)&VolumeNameBuffer, PATH_MAX,
1359 &VolumeSerialNumber, &MaximumComponentLength, &FileSystemFlags,
1360 (LPTSTR)&FileSystemNameBuffer, PATH_MAX)) {
1361 ERR("[%d][%s] >> err = %d\n", __LINE__, __func__, GetLastError());
1365 if (!GetDiskFreeSpace(RootPathName, &SectorsPerCluster, &BytesPerSector,
1366 &NumberOfFreeClusters, &TotalNumberOfClusters)) {
1367 SectorsPerCluster = 1;
1369 NumberOfFreeClusters = 0;
1370 TotalNumberOfClusters = 0;
1373 BytesPerCluster = SectorsPerCluster * BytesPerSector;
1374 TotalNumberOfBytes.QuadPart = Int32x32To64(TotalNumberOfClusters, BytesPerCluster);
1375 TotalNumberOfFreeBytes.QuadPart = Int32x32To64(NumberOfFreeClusters, BytesPerCluster);
1376 FreeBytesAvailableToCaller=TotalNumberOfFreeBytes;
1378 if (!strcmp(FileSystemNameBuffer, "NTFS")) {
1379 stbuf->f_type = NTFS_SUPER_MAGIC;
1381 /* need to check more about other filesystems (ex CD) */
1383 stbuf->f_type = MSDOS_SUPER_MAGIC;
1385 stbuf->f_bsize = BytesPerSector;
1386 stbuf->f_blocks = TotalNumberOfBytes.QuadPart / BytesPerSector;
1387 stbuf->f_bfree = TotalNumberOfFreeBytes.QuadPart / BytesPerSector;
1388 stbuf->f_bavail = FreeBytesAvailableToCaller.QuadPart / BytesPerSector;
1389 stbuf->f_files = stbuf->f_blocks / SectorsPerCluster;
1390 stbuf->f_ffree = stbuf->f_bfree / SectorsPerCluster;
1391 stbuf->f_fsid.val[0] = HIWORD(VolumeSerialNumber);
1392 stbuf->f_fsid.val[1] = LOWORD(VolumeSerialNumber);
1393 stbuf->f_namelen = MaximumComponentLength;
1394 stbuf->f_spare[0] = 0;
1395 stbuf->f_spare[1] = 0;
1396 stbuf->f_spare[2] = 0;
1397 stbuf->f_spare[3] = 0;
1398 stbuf->f_spare[4] = 0;
1399 stbuf->f_spare[5] = 0;
1405 static ssize_t local_lgetxattr(FsContext *ctx, V9fsPath *fs_path,
1406 const char *name, void *value, size_t size)
1408 #ifndef CONFIG_WIN32
1409 char *path = fs_path->data;
1411 return v9fs_get_xattr(ctx, path, name, value, size);
1413 /* xattr doesn't support on Windows */
1418 static ssize_t local_llistxattr(FsContext *ctx, V9fsPath *fs_path,
1419 void *value, size_t size)
1421 #ifndef CONFIG_WIN32
1422 char *path = fs_path->data;
1424 return v9fs_list_xattr(ctx, path, value, size);
1426 /* xattr doesn't support on Windows */
1431 static int local_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name,
1432 void *value, size_t size, int flags)
1434 #ifndef CONFIG_WIN32
1435 char *path = fs_path->data;
1437 return v9fs_set_xattr(ctx, path, name, value, size, flags);
1439 /* xattr doesn't support on Windows */
1444 static int local_lremovexattr(FsContext *ctx, V9fsPath *fs_path,
1447 #ifndef CONFIG_WIN32
1448 char *path = fs_path->data;
1450 return v9fs_remove_xattr(ctx, path, name);
1452 /* xattr doesn't support on Windows */
1457 static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,
1458 const char *name, V9fsPath *target)
1460 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1462 #ifndef CONFIG_WIN32
1463 v9fs_string_sprintf((V9fsString *)target, "%s/%s",
1464 dir_path->data, name);
1466 v9fs_string_sprintf((V9fsString *)target, "%s\\%s",
1467 dir_path->data, name);
1468 while((target->data)[strlen(target->data)-1] == '\\'){
1469 (target->data)[strlen(target->data)-1] = '\0';
1473 v9fs_string_sprintf((V9fsString *)target, "%s", name);
1475 /* Bump the size for including terminating NULL */
1480 static int local_renameat(FsContext *ctx, V9fsPath *olddir,
1481 const char *old_name, V9fsPath *newdir,
1482 const char *new_name)
1484 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1486 V9fsString old_full_name, new_full_name;
1488 v9fs_string_init(&old_full_name);
1489 v9fs_string_init(&new_full_name);
1491 #ifndef CONFIG_WIN32
1492 v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name);
1493 v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name);
1495 v9fs_string_sprintf(&old_full_name, "%s\\%s", olddir->data, old_name);
1496 v9fs_string_sprintf(&new_full_name, "%s\\%s", newdir->data, new_name);
1499 ret = local_rename(ctx, old_full_name.data, new_full_name.data);
1500 v9fs_string_free(&old_full_name);
1501 v9fs_string_free(&new_full_name);
1505 static int local_unlinkat(FsContext *ctx, V9fsPath *dir,
1506 const char *name, int flags)
1508 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1510 V9fsString fullname;
1511 char buffer[PATH_MAX];
1513 v9fs_string_init(&fullname);
1515 #ifndef CONFIG_WIN32
1516 v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name);
1518 v9fs_string_sprintf(&fullname, "%s\\%s", dir->data, name);
1519 while(fullname.data[strlen(fullname.data)-1] == '\\'){
1520 fullname.data[strlen(fullname.data)-1] = '\0';
1523 if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
1524 #ifdef CONFIG_VIRTFS_DARWIN
1525 // TODO: find something to replace AT_REMOVEDIR feature.
1526 if (flags == AT_REMOVEDIR) {
1528 * If directory remove .virtfs_metadata contained in the
1531 #ifndef CONFIG_WIN32
1532 sprintf(buffer, "%s/%s/%s", ctx->fs_root,
1533 fullname.data, VIRTFS_META_DIR);
1535 sprintf(buffer, "%s\\%s\\%s", ctx->fs_root,
1536 fullname.data, VIRTFS_META_DIR);
1538 ret = remove(buffer);
1539 if (ret < 0 && errno != ENOENT) {
1541 * We didn't had the .virtfs_metadata file. May be file created
1542 * in non-mapped mode ?. Ignore ENOENT.
1549 * Now remove the name from parent directory
1550 * .virtfs_metadata directory.
1552 ret = remove(local_mapped_attr_path(ctx, fullname.data, buffer));
1553 if (ret < 0 && errno != ENOENT) {
1555 * We didn't had the .virtfs_metadata file. May be file created
1556 * in non-mapped mode ?. Ignore ENOENT.
1561 /* Remove the name finally */
1562 #ifndef CONFIG_WIN32
1563 ret = remove(rpath(ctx, fullname.data, buffer));
1565 if (flags == AT_REMOVEDIR) { // is dir
1566 ret = rmdir(rpath(ctx, fullname.data, buffer));
1568 ret = remove(rpath(ctx, fullname.data, buffer));
1571 v9fs_string_free(&fullname);
1577 #ifndef CONFIG_WIN32
1578 static int local_ioc_getversion(FsContext *ctx, V9fsPath *path,
1579 mode_t st_mode, uint64_t *st_gen)
1581 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1584 #ifdef FS_IOC_GETVERSION
1585 V9fsFidOpenState fid_open;
1588 * Do not try to open special files like device nodes, fifos etc
1589 * We can get fd for regular files and directories only
1591 if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) {
1594 err = local_open(ctx, path, O_RDONLY, &fid_open);
1598 err = ioctl(fid_open.fd, FS_IOC_GETVERSION, st_gen);
1599 local_close(ctx, &fid_open);
1607 static int local_init(FsContext *ctx)
1609 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1611 #ifdef FS_IOC_GETVERSION
1612 struct statfs stbuf;
1615 #ifndef CONFIG_WIN32
1616 if (ctx->export_flags & V9FS_SM_PASSTHROUGH) {
1617 ctx->xops = passthrough_xattr_ops;
1618 } else if (ctx->export_flags & V9FS_SM_MAPPED) {
1619 ctx->xops = mapped_xattr_ops;
1620 } else if (ctx->export_flags & V9FS_SM_NONE) {
1621 ctx->xops = none_xattr_ops;
1622 } else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
1624 * xattr operation for mapped-file and passthrough
1627 ctx->xops = passthrough_xattr_ops;
1632 ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT;
1633 #ifdef FS_IOC_GETVERSION
1635 * use ioc_getversion only if the iocl is definied
1637 err = statfs(ctx->fs_root, &stbuf);
1639 switch (stbuf.f_type) {
1640 case EXT2_SUPER_MAGIC:
1641 case BTRFS_SUPER_MAGIC:
1642 case REISERFS_SUPER_MAGIC:
1643 case XFS_SUPER_MAGIC:
1644 ctx->exops.get_st_gen = local_ioc_getversion;
1652 static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
1654 TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
1655 const char *sec_model = qemu_opt_get(opts, "security_model");
1656 const char *path = qemu_opt_get(opts, "path");
1659 fprintf(stderr, "security model not specified, "
1660 "local fs needs security model\nvalid options are:"
1661 "\tsecurity_model=[passthrough|mapped|none]\n");
1665 if (!strcmp(sec_model, "passthrough")) {
1666 fse->export_flags |= V9FS_SM_PASSTHROUGH;
1667 } else if (!strcmp(sec_model, "mapped") ||
1668 !strcmp(sec_model, "mapped-xattr")) {
1669 fse->export_flags |= V9FS_SM_MAPPED;
1670 } else if (!strcmp(sec_model, "none")) {
1671 fse->export_flags |= V9FS_SM_NONE;
1672 } else if (!strcmp(sec_model, "mapped-file")) {
1673 fse->export_flags |= V9FS_SM_MAPPED_FILE;
1675 fprintf(stderr, "Invalid security model %s specified, valid options are"
1676 "\n\t [passthrough|mapped-xattr|mapped-file|none]\n",
1682 fprintf(stderr, "fsdev: No path specified.\n");
1685 fse->path = g_strdup(path);
1690 FileOperations local_ops = {
1691 .parse_opts = local_parse_opts,
1693 .lstat = local_lstat,
1694 .readlink = local_readlink,
1695 .close = local_close,
1696 .closedir = local_closedir,
1698 .opendir = local_opendir,
1699 .rewinddir = local_rewinddir,
1700 .telldir = local_telldir,
1701 .readdir_r = local_readdir_r,
1702 .seekdir = local_seekdir,
1703 .statfs = local_statfs,
1704 .preadv = local_preadv,
1705 .pwritev = local_pwritev,
1706 .truncate = local_truncate,
1707 .utimensat = local_utimensat,
1708 .open2 = local_open2,
1709 .lgetxattr = local_lgetxattr,
1710 .llistxattr = local_llistxattr,
1711 .lsetxattr = local_lsetxattr,
1712 .lremovexattr = local_lremovexattr,
1713 .mkdir = local_mkdir,
1714 .symlink = local_symlink,
1715 .remove = local_remove,
1716 .fstat = local_fstat,
1717 .chmod = local_chmod,
1718 .mknod = local_mknod,
1720 .rename = local_rename,
1721 .chown = local_chown,
1722 .fsync = local_fsync,
1723 .name_to_path = local_name_to_path,
1724 .unlinkat = local_unlinkat,
1725 .renameat = local_renameat,