[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 071/104] virtiofsd: extract root inode init into setup_root()
From: |
Misono Tomohiro |
Subject: |
Re: [PATCH 071/104] virtiofsd: extract root inode init into setup_root() |
Date: |
Thu, 16 Jan 2020 16:20:37 +0900 |
> 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);
Following block still remains in main():
2933 lo.root.is_symlink = false;
...
2952 lo.root.fd = open(lo.source, O_PATH);
2953
2954 if (lo.root.fd == -1) {
2955 fuse_log(FUSE_LOG_ERR, "open(\"%s\", O_PATH): %m\n", lo.source);
2956 exit(1);
2957 }
L.2933 should be included in lo_setup_root() and can we just remove L.2952-2957?
Thanks,
Misono
- Re: [PATCH 071/104] virtiofsd: extract root inode init into setup_root(),
Misono Tomohiro <=