lobase

Linux port of OpenBSDs userland.
Log | Files | Refs | README

commit a5b82394b1c2eaae5aff6854e356e8e453518c8d
parent 3d2480158bfbc26d3ac21728fc8d715209023f87
Author: Duncaen <mail@duncano.de>
Date:   Tue,  7 Mar 2017 22:57:09 +0100

lib/libopenbsd: use stat(2)s st_dev as identifier for getstatfs(3) shim

Diffstat:
include/sys/mount.h | 1+
lib/libopenbsd/sys/getfsstat.c | 11++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/sys/mount.h b/include/sys/mount.h @@ -18,6 +18,7 @@ union mount_info { struct openbsd_statfs { struct statfs buf; + dev_t st_dev; char f_fstypename[MFSNAMELEN]; /* fs type name */ char f_mntonname[MNAMELEN]; /* directory on which mounted */ char f_mntfromname[MNAMELEN]; /* mounted file system */ diff --git a/lib/libopenbsd/sys/getfsstat.c b/lib/libopenbsd/sys/getfsstat.c @@ -1,4 +1,5 @@ #include <sys/mount.h> +#include <sys/stat.h> #include <stdio.h> #include <paths.h> @@ -13,6 +14,7 @@ int getfsstat(struct openbsd_statfs *buf, size_t bufsize, int flags) { struct openbsd_statfs *cur; + struct stat sb; struct mntent *m; FILE *fp; int n, max; @@ -20,16 +22,23 @@ getfsstat(struct openbsd_statfs *buf, size_t bufsize, int flags) if (!(fp = setmntent(_PATH_MOUNTED, "r"))) return -1; + if (flags == 0) + flags = MNT_WAIT; + n = 0; max = (bufsize / sizeof (struct openbsd_statfs)); while ((m = getmntent(fp))) { - if (!buf) { + if (!buf || (flags & MNT_NOWAIT)) { n++; continue; } if (n+1 >= max) break; cur = &buf[n++]; + + if (!cur->st_dev && stat(m->mnt_dir, &sb) == 0) + cur->st_dev = sb.st_dev; + statfs(m->mnt_dir, &cur->buf); strlcpy(cur->f_fstypename, m->mnt_type, sizeof (cur->f_fstypename)); strlcpy(cur->f_mntfromname, m->mnt_fsname, sizeof (cur->f_mntfromname));