From: Pádraig Brady Date: Mon, 23 Feb 2026 14:22:51 +0000 (+0000) Subject: mountlist: use file-remote module to determine remoteness X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a12ab6c8564f4a2980c5fc3b6ab7cd1a6ff262c;p=thirdparty%2Fgnulib.git mountlist: use file-remote module to determine remoteness * lib/file-remote.c (is_remote_fs_type_name): A new function that matches file system _names_ as being remote. The list is an amalgamation of those names already referenced in file-remote, names referenced in ME_REMOTE, and IDs referenced in file-remote. * lib/file-remote.h: Declare new function. * lib/mountlist.c (ME_REMOTE): Use is_remote_fs_type_name() to determine if the name is remote. * modules/mountlist: Depend on file-remote. --- diff --git a/ChangeLog b/ChangeLog index 5cf39e9f6b..0662166b8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2026-02-28 Pádraig Brady + + mountlist: use file-remote module to determine remoteness + * lib/file-remote.c (is_remote_fs_type_name): A new function + that matches file system _names_ as being remote. The list is + an amalgamation of those names already referenced in file-remote, + names referenced in ME_REMOTE, and IDs referenced in file-remote. + * lib/file-remote.h: Declare new function. + * lib/mountlist.c (ME_REMOTE): Use is_remote_fs_type_name() + to determine if the name is remote. + * modules/mountlist: Depend on file-remote. + 2026-02-28 Bruno Haible strnul: Fix link-time error. diff --git a/lib/file-remote.c b/lib/file-remote.c index 890d67b518..49c83190c1 100644 --- a/lib/file-remote.c +++ b/lib/file-remote.c @@ -56,6 +56,41 @@ # endif #endif +int _GL_ATTRIBUTE_CONST +is_remote_fs_type_name (const char *fs_type) +{ + return ( strcmp (fs_type, "acfs") == 0 + || strcmp (fs_type, "afs") == 0 + || strcmp (fs_type, "autofs") == 0 + || strcmp (fs_type, "auristorfs") == 0 + || strcmp (fs_type, "cachefs") == 0 + || strcmp (fs_type, "ceph") == 0 + || strcmp (fs_type, "cifs") == 0 + || strcmp (fs_type, "coda") == 0 + || strcmp (fs_type, "fhgfs") == 0 + || strcmp (fs_type, "gfs") == 0 + || strcmp (fs_type, "gfs2") == 0 + || strcmp (fs_type, "gpfs") == 0 + || strcmp (fs_type, "ibrix") == 0 + || strcmp (fs_type, "lustre") == 0 + || strcmp (fs_type, "ncpfs") == 0 + || strcmp (fs_type, "netfs") == 0 + || strcmp (fs_type, "nfs") == 0 + || strcmp (fs_type, "nfs3") == 0 + || strcmp (fs_type, "nfs4") == 0 + || strcmp (fs_type, "ocfs2") == 0 + || strcmp (fs_type, "panfs") == 0 + || strcmp (fs_type, "smb") == 0 + || strcmp (fs_type, "smb2") == 0 + || strcmp (fs_type, "smb3") == 0 + || strcmp (fs_type, "smbfs") == 0 + || strcmp (fs_type, "snfs") == 0 + || strcmp (fs_type, "stnfs") == 0 + || strcmp (fs_type, "userlandfs") == 0 + || strcmp (fs_type, "vxfs") == 0 + || strcmp (fs_type, "websearchfs") == 0); +} + #if defined _WIN32 || defined __CYGWIN__ /* Windows */ # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include diff --git a/lib/file-remote.h b/lib/file-remote.h index 05c0d930f2..de7f09ea4f 100644 --- a/lib/file-remote.h +++ b/lib/file-remote.h @@ -30,6 +30,10 @@ extern "C" { - -1 with errno set, upon error (e.g. if the file is not accessible). */ extern int file_is_remote (const char *file); +/* Returns 1 if the filesystem type name FS_TYPE is known to be a + remote filesystem type, 0 otherwise. */ +extern int is_remote_fs_type_name (const char *fs_type); + #ifdef __cplusplus } #endif diff --git a/lib/mountlist.c b/lib/mountlist.c index c19ce3fa99..21f6c05613 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -29,6 +29,7 @@ #include #include "c-ctype.h" +#include "file-remote.h" #include "xalloc.h" #if HAVE_SYS_PARAM_H @@ -230,27 +231,13 @@ me_remote (char const *fs_name, _GL_UNUSED char const *fs_type) #ifndef ME_REMOTE /* A file system is "remote" if its Fs_name contains a ':' - or if (it is of type (smbfs or cifs) and its Fs_name starts with '//') - or if it is of any other of the listed types - or Fs_name is equal to "-hosts" (used by autofs to mount remote fs). + or Fs_name is equal to "-hosts" (used by autofs to mount remote fs) + or if it is of any other of the listed types. "VM" file systems like prl_fs or vboxsf are not considered remote here. */ # define ME_REMOTE(Fs_name, Fs_type) \ (strchr (Fs_name, ':') != NULL \ - || ((Fs_name)[0] == '/' \ - && (Fs_name)[1] == '/' \ - && (streq (Fs_type, "smbfs") \ - || streq (Fs_type, "smb3") \ - || streq (Fs_type, "cifs"))) \ - || streq (Fs_type, "acfs") \ - || streq (Fs_type, "afs") \ - || streq (Fs_type, "coda") \ - || streq (Fs_type, "auristorfs") \ - || streq (Fs_type, "fhgfs") \ - || streq (Fs_type, "gpfs") \ - || streq (Fs_type, "ibrix") \ - || streq (Fs_type, "ocfs2") \ - || streq (Fs_type, "vxfs") \ - || streq ("-hosts", Fs_name)) + || streq ("-hosts", Fs_name)) \ + || is_remote_fs_type_name (Fs_type) #endif #if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ diff --git a/modules/mountlist b/modules/mountlist index 4cf5563608..e495c90baa 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -9,6 +9,7 @@ m4/mountlist.m4 Depends-on: c-ctype +file-remote fopen-gnu free-posix getline