diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2020-05-08 09:47:18 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2020-05-08 10:07:19 -0400 |
commit | 1b50e24c9db3c718395b03b8d069814c5d5ecbe9 (patch) | |
tree | b0c99722a315bfb994cd27c93d595a0c13f92b0b /support/misc | |
parent | 0b235facc0355c138e68edcb4131d69d741cf7be (diff) | |
download | nfs-utils-1b50e24c9db3c718395b03b8d069814c5d5ecbe9.tar.gz |
mountd: Add a helper nfsd_path_statfs64() for uuid_by_path()
Ensure uuid_by_path() works correctly when 'rootdir'
is set in the [exports] section of nfs.conf.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support/misc')
-rw-r--r-- | support/misc/nfsd_path.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c index f078a66..ab6c98d 100644 --- a/support/misc/nfsd_path.c +++ b/support/misc/nfsd_path.c @@ -5,6 +5,7 @@ #include <errno.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/vfs.h> #include <limits.h> #include <stdlib.h> #include <unistd.h> @@ -180,6 +181,48 @@ nfsd_path_lstat(const char *pathname, struct stat *statbuf) return nfsd_run_stat(nfsd_wq, nfsd_lstatfunc, pathname, statbuf); } +struct nfsd_statfs64_data { + const char *pathname; + struct statfs64 *statbuf; + int ret; + int err; +}; + +static void +nfsd_statfs64func(void *data) +{ + struct nfsd_statfs64_data *d = data; + + d->ret = statfs64(d->pathname, d->statbuf); + if (d->ret < 0) + d->err = errno; +} + +static int +nfsd_run_statfs64(struct xthread_workqueue *wq, + const char *pathname, + struct statfs64 *statbuf) +{ + struct nfsd_statfs64_data data = { + pathname, + statbuf, + 0, + 0 + }; + xthread_work_run_sync(wq, nfsd_statfs64func, &data); + if (data.ret < 0) + errno = data.err; + return data.ret; +} + +int +nfsd_path_statfs64(const char *pathname, struct statfs64 *statbuf) +{ + if (!nfsd_wq) + return statfs64(pathname, statbuf); + return nfsd_run_statfs64(nfsd_wq, pathname, statbuf); +} + struct nfsd_realpath_data { const char *pathname; char *resolved; |