]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
mountlist: use file-remote module to determine remoteness
authorPádraig Brady <P@draigBrady.com>
Mon, 23 Feb 2026 14:22:51 +0000 (14:22 +0000)
committerPádraig Brady <P@draigBrady.com>
Sat, 28 Feb 2026 11:00:20 +0000 (11:00 +0000)
* 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.

ChangeLog
lib/file-remote.c
lib/file-remote.h
lib/mountlist.c
modules/mountlist

index 5cf39e9f6b042aaa3e99f65372e063ae65d0ea3e..0662166b8d9edb020ac987fc5e73665094c3aba7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-02-28  Pádraig Brady  <P@draigBrady.com>
+
+       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  <bruno@clisp.org>
 
        strnul: Fix link-time error.
index 890d67b5188a24d617f64da7e0f6e66c8d27c05c..49c83190c1d44bd88d6efd432b82191fe560dcc8 100644 (file)
 # 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 <windows.h>
index 05c0d930f20fec3852e228c43017f9dea97f9dae..de7f09ea4f2634c21e57588543aedc817b268e19 100644 (file)
@@ -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
index c19ce3fa99c6475faf383ec64d9b158da3636da2..21f6c05613dfa654e11a855582737badc33b9aca 100644 (file)
@@ -29,6 +29,7 @@
 #include <unistd.h>
 
 #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 */
index 4cf5563608bd25695d3a2cd5ac7770d99180cc6b..e495c90baa56631e6ba53e3b378e378b0afcb908 100644 (file)
@@ -9,6 +9,7 @@ m4/mountlist.m4
 
 Depends-on:
 c-ctype
+file-remote
 fopen-gnu
 free-posix
 getline