bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fts.m4: correct the test for statfs.f_type


From: Jim Meyering
Subject: Re: [PATCH] fts.m4: correct the test for statfs.f_type
Date: Thu, 02 Oct 2008 12:58:48 +0200

Bruno Haible <address@hidden> wrote:
>> If someone is interested enough to time things on HP-UX
>> and finds that there's a file system type (probably memory backed)
>> that it'd be good to exempt, then it might be worthwhile to
>> pursue this.
>
> I didn't mean to discuss for which filesystems on HP-UX which optimization
> may be worthwhile. (Probably it's reasonable to treat NFS on HP-UX like
> NFS on other platforms.)
>
> Rather I meant to say that in order to get 'struct statfs' defined, a
> simple "#include <sys/statfs.h>" is not enough, and this would be better:
>
> --- m4/fts.m4.orig    2008-10-02 02:50:50.000000000 +0200
> +++ m4/fts.m4 2008-10-02 02:44:07.000000000 +0200
> @@ -24,8 +24,16 @@
>    gl_FUNC_OPENAT
>
>    AC_CHECK_FUNCS_ONCE([fstatfs])
> -  AC_CHECK_HEADERS_ONCE([sys/param.h sys/vfs])dnl
> +  AC_CHECK_HEADERS_ONCE([sys/param.h sys/statfs.h sys/mount.h sys/vfs.h])dnl
>    AC_CHECK_MEMBERS([struct statfs.f_type],,,
>      [$ac_includes_default
> -     #include <sys/statfs.h>])
> +     #if HAVE_SYS_STATFS_H
> +     # include <sys/statfs.h>
> +     #endif
> +     #if HAVE_SYS_MOUNT_H
> +     # include <sys/mount.h>
> +     #endif
> +     #if HAVE_SYS_VFS_H
> +     # include <sys/vfs.h>
> +     #endif])
>  ])

Thanks.
However, I'm trying to avoid complexity unless it's actually needed.
See coreutils' src/stat.c for some of the messiness that is required
if you really want cross-platform file system types:

    /* Return the type of the specified file system.
       Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris).
       Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).
       Others have statfs.f_fstypename[MFSNAMELEN] (NetBSD 1.5.2).
       Still others have neither and have to get by with f_type (Linux).
       But f_type may only exist in statfs (Cygwin).  */
    static char const *
    human_fstype (STRUCT_STATVFS const *statfsbuf)

That is the part that would best be encapsulated in a module,
but for now, the little exclusion in remove.c and fts.c doesn't
need to work anywhere except on Linux.

Also, I chose to limit chances of failure by operating on a file
descriptor (hence used fstatfs, not statfs) rather than on a name.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]