--- xfsprogs-3.1.10/libxfs/linux.c +++ xfsprogs-3.1.10-statfs/libxfs/linux.c @@ -21,7 +21,7 @@ #include #include #undef ustat -#include +#include #include #include #include @@ -49,9 +49,11 @@ static int max_block_alignment; int platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) { - /* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */ - struct ustat ust[2]; + struct statfs ust; struct stat64 st; + char mounts[MAXPATHLEN]; + FILE* mtab; + struct mntent* mnt; if (!s) { if (stat64(block, &st) < 0) @@ -61,7 +63,32 @@ platform_check_ismounted(char *name, cha s = &st; } - if (ustat(s->st_rdev, ust) >= 0) { + if (strcmp(name, block) == 0) { + /* Device node was passed as parameter. Find its mount point */ + strcpy(mounts, (!access(PROC_MOUNTED, R_OK)) ? PROC_MOUNTED : MOUNTED); + mtab = setmntent(mounts, "r"); + if (mtab == NULL) { + if (verbose) { + fprintf(stderr, _("%s: %s contains a possibly mounted filesystem\n"), progname, name); + } + return 1; + } + else { + mnt = getmntent(mtab); + while (mnt != NULL) { + if (strcmp(block, mnt->mnt_fsname) == 0) { + if (verbose) { + fprintf(stderr, _("%s: %s contains a mounted filesystem\n"), progname, name); + } + endmntent(mtab); + return 1; + } + mnt = getmntent(mtab); + } + endmntent(mtab); + } + } + else if (statfs(name, &ust) >= 0) { if (verbose) fprintf(stderr, _("%s: %s contains a mounted filesystem\n"),