aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-03-07 22:57:09 +0100
committerDuncaen <mail@duncano.de>2017-03-07 22:57:45 +0100
commita5b82394b1c2eaae5aff6854e356e8e453518c8d (patch)
tree09c753a774247a26161aa5f8582a8ecf1c1df253
parent3d2480158bfbc26d3ac21728fc8d715209023f87 (diff)
downloadlobase-a5b82394b1c2eaae5aff6854e356e8e453518c8d.tar.gz
lib/libopenbsd: use stat(2)s st_dev as identifier for getstatfs(3) shim
-rw-r--r--include/sys/mount.h1
-rw-r--r--lib/libopenbsd/sys/getfsstat.c11
2 files changed, 11 insertions, 1 deletions
diff --git a/include/sys/mount.h b/include/sys/mount.h
index 52570b4..647cc5d 100644
--- 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
index 2013139..d1e5312 100644
--- 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));