[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 071/104] virtiofsd: extract root inode init into setup_root()
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 071/104] virtiofsd: extract root inode init into setup_root() |
Date: |
Thu, 12 Dec 2019 16:38:31 +0000 |
From: Miklos Szeredi <address@hidden>
Inititialize the root inode in a single place.
Signed-off-by: Miklos Szeredi <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
tools/virtiofsd/passthrough_ll.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index ef8b88e3d1..0f33c3c5e9 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -2336,6 +2336,29 @@ static void log_func(enum fuse_log_level level, const
char *_fmt, va_list ap)
}
}
+static void setup_root(struct lo_data *lo, struct lo_inode *root)
+{
+ int fd, res;
+ struct stat stat;
+
+ fd = open("/", O_PATH);
+ if (fd == -1) {
+ fuse_log(FUSE_LOG_ERR, "open(%s, O_PATH): %m\n", lo->source);
+ exit(1);
+ }
+
+ res = fstatat(fd, "", &stat, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
+ if (res == -1) {
+ fuse_log(FUSE_LOG_ERR, "fstatat(%s): %m\n", lo->source);
+ exit(1);
+ }
+
+ root->fd = fd;
+ root->ino = stat.st_ino;
+ root->dev = stat.st_dev;
+ root->refcount = 2;
+}
+
int main(int argc, char *argv[])
{
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
@@ -2411,8 +2434,6 @@ int main(int argc, char *argv[])
if (lo.debug) {
current_log_level = FUSE_LOG_DEBUG;
}
- lo.root.refcount = 2;
-
if (lo.source) {
struct stat stat;
int res;
@@ -2480,6 +2501,7 @@ int main(int argc, char *argv[])
setup_sandbox(&lo, se, opts.syslog);
+ setup_root(&lo, &lo.root);
/* Block until ctrl+c or fusermount -u */
ret = virtio_loop(se);
--
2.23.0
- [PATCH 062/104] virtiofsd: Handle hard reboot, (continued)
- [PATCH 062/104] virtiofsd: Handle hard reboot, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 063/104] virtiofsd: Kill threads when queues are stopped, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 064/104] vhost-user: Print unexpected slave message types, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 065/104] contrib/libvhost-user: Protect slave fd with mutex, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 066/104] virtiofsd: passthrough_ll: add renameat2 support, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 067/104] virtiofsd: passthrough_ll: disable readdirplus on cache=never, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 068/104] virtiofsd: passthrough_ll: control readdirplus, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 069/104] virtiofsd: rename unref_inode() to unref_inode_lolocked(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 070/104] virtiofsd: fail when parent inode isn't known in lo_do_lookup(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 072/104] virtiofsd: passthrough_ll: fix refcounting on remove/rename, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 071/104] virtiofsd: extract root inode init into setup_root(),
Dr. David Alan Gilbert (git) <=
- [PATCH 073/104] virtiofsd: passthrough_ll: clean up cache related options, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 074/104] virtiofsd: passthrough_ll: use hashtable, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 075/104] virtiofsd: Clean up inodes on destroy, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 076/104] virtiofsd: support nanosecond resolution for file timestamp, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 077/104] virtiofsd: fix error handling in main(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 078/104] virtiofsd: cleanup allocated resource in se, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 079/104] virtiofsd: fix memory leak on lo.source, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 080/104] virtiofsd: add helper for lo_data cleanup, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 081/104] virtiofsd: Prevent multiply running with same vhost_user_socket, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 082/104] virtiofsd: enable PARALLEL_DIROPS during INIT, Dr. David Alan Gilbert (git), 2019/12/12