Skip to contentSkip to conversation

deprecated ustat() vs. statfs()

Buildroot Nigel Kukard 2 participants 2 messages Dec 31, 2008

lore
Share & tools
lore
#0 lore raw

I dont suppose this is the correct way to switch to statfs()?

--- xfsprogs-2.10.2_vanilla/libxfs/linux.c 2008-12-09
23:33:26.000000000 +0000
+++ xfsprogs-2.10.2_remove-deprecated/libxfs/linux.c 2008-12-31
14:30:45.000000000 +0000
@@ -21,7 +21,7 @@
#include <mntent.h>
#include <sys/stat.h>
#undef ustat
-#include <sys/ustat.h>
+#include <sys/statfs.h>
#include <sys/mount.h>
#include <sys/ioctl.h>
#include <sys/sysinfo.h>
@@ -49,7 +49,7 @@
int
platform_check_ismounted(char *name, char *block, struct stat64 *s, int
verbose)
{
- struct ustat ust;

+    struct statfs    ust;
     struct stat64    st;
 
     if (!s) {
@@ -60,7 +60,7 @@
         s = &st;
     }

- if (ustat(s->st_rdev, &ust) >= 0) {
+ if (statfs(s->st_rdev, &ust) >= 0) {
if (verbose)
fprintf(stderr,
_("%s: %s contains a mounted filesystem\n"),

#1 lore raw
Quoted 1 line · Nigel Kukard

I dont suppose this is the correct way to switch to statfs()?

Switching to {f,}statfs is per se not really desirable.

quote from the manpage:
LSB has deprecated the library calls statfs() and fstatfs() and tells us to use statvfs(2) and fstatvfs(2) instead.

statvfs is at least POSIX.

A simpler thing (i didn't look at the exact meaning of that function) may be to just stat the path like e.g. the mountpoint applet ?) does.

HTH,
?) http://sources.busybox.net/index.py/trunk/busybox/miscutils/mountpoint.c?view=markup

Quoted 35 lines

--- xfsprogs-2.10.2_vanilla/libxfs/linux.c 2008-12-09
23:33:26.000000000 +0000
+++ xfsprogs-2.10.2_remove-deprecated/libxfs/linux.c 2008-12-31
14:30:45.000000000 +0000

(quoted diff) +1 -1
@@ -21,7 +21,7 @@
 #include <mntent.h>
 #include <sys/stat.h>
 #undef ustat
-#include <sys/ustat.h>
+#include <sys/statfs.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/sysinfo.h>
@@ -49,7 +49,7 @@

int
platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
{

(quoted diff) +2 -2
-    struct ustat    ust;
+    struct statfs    ust;
    struct stat64    st;
 
    if (!s) {
@@ -60,7 +60,7 @@
        s = &st;
    }
 
-    if (ustat(s->st_rdev, &ust) >= 0) {
+    if (statfs(s->st_rdev, &ust) >= 0) {
        if (verbose)
            fprintf(stderr,
                _("%s: %s contains a mounted filesystem\n"),