]> Savannah Git Hosting - gnulib.git/commitdiff
mountlist: Make more robust in multithreaded applications.
authorBruno Haible <bruno@clisp.org>
Tue, 26 May 2020 16:04:26 +0000 (18:04 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 27 May 2020 17:30:48 +0000 (19:30 +0200)
* lib/mountlist.c (setmntent, read_file_system_list): Pass an 'e' flag
to fopen.
* modules/mountlist (Depends-on): Add fopen-gnu.

ChangeLog
lib/mountlist.c
modules/mountlist

index 80bb80eaf2c235a69c12fc5c4b22c321d0677062..be5b2a19a0d5a1349316ec28b6954c5b4658de1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-05-27  Bruno Haible  <bruno@clisp.org>
+
+       mountlist: Make more robust in multithreaded applications.
+       * lib/mountlist.c (setmntent, read_file_system_list): Pass an 'e' flag
+       to fopen.
+       * modules/mountlist (Depends-on): Add fopen-gnu.
+
 2020-05-27  Bruno Haible  <bruno@clisp.org>
 
        sethostname: Make more robust in multithreaded applications.
index 7abe0248ec22dc96ba2f7ef4322d3556e841e915..4cb19c87f1291bdb9459ebbc9354a8f8aa42ce66 100644 (file)
 
 #ifdef MOUNTED_GETMNTENT1
 # if !HAVE_SETMNTENT            /* Android <= 4.4 */
-#  define setmntent(fp,mode) fopen (fp, mode)
+#  define setmntent(fp,mode) fopen (fp, mode "e")
 # endif
 # if !HAVE_ENDMNTENT            /* Android <= 4.4 */
 #  define endmntent(fp) fclose (fp)
@@ -460,7 +460,7 @@ read_file_system_list (bool need_fs_type)
        (and that code is in previous versions of this function), however
        libmount depends on libselinux which pulls in many dependencies.  */
     char const *mountinfo = "/proc/self/mountinfo";
-    fp = fopen (mountinfo, "r");
+    fp = fopen (mountinfo, "re");
     if (fp != NULL)
       {
         char *line = NULL;
@@ -794,7 +794,7 @@ read_file_system_list (bool need_fs_type)
     char *table = "/etc/mnttab";
     FILE *fp;
 
-    fp = fopen (table, "r");
+    fp = fopen (table, "re");
     if (fp == NULL)
       return NULL;
 
@@ -852,7 +852,7 @@ read_file_system_list (bool need_fs_type)
        by the kernel.  */
 
     errno = 0;
-    fp = fopen (table, "r");
+    fp = fopen (table, "re");
     if (fp == NULL)
       ret = errno;
     else
@@ -924,7 +924,7 @@ read_file_system_list (bool need_fs_type)
 # endif
 
     errno = 0;
-    fp = fopen (table, "r");
+    fp = fopen (table, "re");
     if (fp == NULL)
       ret = errno;
     else
index 11cf809ab26456dddeed93c6c73c68aaedf88d1d..5bb45edf6485d68a041166a718604c67107dc572 100644 (file)
@@ -8,6 +8,7 @@ m4/fstypename.m4
 m4/mountlist.m4
 
 Depends-on:
+fopen-gnu
 getline
 stdbool
 stdint