Ok, this has become a bit more urgent: Building on F24 on arm64, I noticed this: ../libxfs/.libs/libxfs.a(linux.o): In function `platform_check_ismounted': /root/sandeen/xfsprogs-dev/libxfs/linux.c:66: warning: ustat is not implemented and will always fail And lo: # xfs_metadump -o /dev/sda3 dump # mount /dev/sda3 /mnt/scratch # xfs_mdrestore dump /dev/sda3 # echo $? 0 # Are we scared yet? (I independently rewrote Felix's patch after seeing the above, then searched and found this old thread) We need to fix this, now. Performance issues or not I'd advocate for taking this patch, unless hch made any progress on the O_EXCL approach. hch said: > That being said I think ustat fits pretty well for this use case, > so getting rid of it might need a little more justification. but it looks like that ship has sailed. So for this patch I'll add: Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx> -Eric On 1/12/16 1:59 PM, Felix Janda wrote: > ustat has been used to check whether a device file is mounted. > The function is deprecated and not supported by uclibc and musl. > Now do the check using the *mntent functions. > > Based on patch by Natanael Copa <ncopa@xxxxxxxxxxxxxxx>. > > Signed-off-by: Felix Janda <felix.janda@xxxxxxxxx> > --- > libxfs/linux.c | 29 ++++++++++++++++++++--------- > 1 file changed, 20 insertions(+), 9 deletions(-) > > diff --git a/libxfs/linux.c b/libxfs/linux.c > index c532d65..e7adcf2 100644 > --- a/libxfs/linux.c > +++ b/libxfs/linux.c > @@ -16,11 +16,8 @@ > * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA > */ > > -#define ustat __kernel_ustat > #include <mntent.h> > #include <sys/stat.h> > -#undef ustat > -#include <sys/ustat.h> > #include <sys/mount.h> > #include <sys/ioctl.h> > #include <sys/sysinfo.h> > @@ -51,9 +48,10 @@ 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 stat64 st; > + FILE *f; > + struct stat64 st, mst; > + struct mntent *mnt; > + char mounts[MAXPATHLEN]; > > if (!s) { > if (stat64(block, &st) < 0) > @@ -63,14 +61,27 @@ platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) > s = &st; > } > > - if (ustat(s->st_rdev, ust) >= 0) { > + strcpy(mounts, (!access(PROC_MOUNTED, R_OK)) ? PROC_MOUNTED : MOUNTED); > + if ((f = setmntent(mounts, "r")) == NULL) { > + fprintf(stderr, > + _("%s: %s possibly contains a mounted filesystem\n"), > + progname, name); > + return 1; > + } > + while ((mnt = getmntent(f)) != NULL) { > + if (stat64(mnt->mnt_dir, &mst) < 0) > + continue; > + if (mst.st_dev != s->st_rdev) > + continue; > + > if (verbose) > fprintf(stderr, > _("%s: %s contains a mounted filesystem\n"), > progname, name); > - return 1; > + break; > } > - return 0; > + endmntent(f); > + return mnt == NULL; > } > > int > _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs