Mercurial > gnulib
annotate lib/mountlist.c @ 39923:8e97d3ff3b45
mountlist: Remove support for SVR2.
Reported by Andrew Borodin <aborodin@vmail.ru> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-10/msg00101.html>.
* lib/mountlist.c: Remove MOUNTED_FREAD case.
* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Don't define
MOUNTED_FREAD.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 16 Oct 2018 18:44:33 +0200 |
parents | f2b5499e6ee2 |
children | 9e47123a5054 |
rev | line source |
---|---|
5159 | 1 /* mountlist.c -- return a list of mounted file systems |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
2 |
19484
10eb9086bea0
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19190
diff
changeset
|
3 Copyright (C) 1991-1992, 1997-2018 Free Software Foundation, Inc. |
5 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7944
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
5 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7944
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7944
diff
changeset
|
8 (at your option) any later version. |
5 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
19190 | 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
5 | 17 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
7247
diff
changeset
|
18 #include <config.h> |
326 | 19 |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
20 #include "mountlist.h" |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
21 |
6527 | 22 #include <limits.h> |
5 | 23 #include <stdio.h> |
4666 | 24 #include <stdlib.h> |
25 #include <string.h> | |
11395
5442b2430859
avoid gcc warnings about unused macro definitions
Jim Meyering <meyering@redhat.com>
parents:
11112
diff
changeset
|
26 #include <stdint.h> |
5 | 27 |
3621
56f442359b0d
Include unlocked-io.h after all system headers.
Jim Meyering <jim@meyering.net>
parents:
3618
diff
changeset
|
28 #include "xalloc.h" |
5 | 29 |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
30 #include <errno.h> |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
31 |
5955
ace6ea191424
Assume HAVE_FCNTL_H (i.e., include <fcntl.h> unconditionally,
Jim Meyering <jim@meyering.net>
parents:
5907
diff
changeset
|
32 #include <fcntl.h> |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
33 |
6275 | 34 #include <unistd.h> |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
35 |
1278
9ad625a30b7d
Use #if, not #ifdef with HAVE_ macros
Jim Meyering <jim@meyering.net>
parents:
1183
diff
changeset
|
36 #if HAVE_SYS_PARAM_H |
917 | 37 # include <sys/param.h> |
326 | 38 #endif |
39 | |
18419
d81946484cce
mountlist: include sysmacros.h for glibc
Eric Blake <eblake@redhat.com>
parents:
18255
diff
changeset
|
40 #if MAJOR_IN_MKDEV |
d81946484cce
mountlist: include sysmacros.h for glibc
Eric Blake <eblake@redhat.com>
parents:
18255
diff
changeset
|
41 # include <sys/mkdev.h> |
d81946484cce
mountlist: include sysmacros.h for glibc
Eric Blake <eblake@redhat.com>
parents:
18255
diff
changeset
|
42 #elif MAJOR_IN_SYSMACROS |
d81946484cce
mountlist: include sysmacros.h for glibc
Eric Blake <eblake@redhat.com>
parents:
18255
diff
changeset
|
43 # include <sys/sysmacros.h> |
d81946484cce
mountlist: include sysmacros.h for glibc
Eric Blake <eblake@redhat.com>
parents:
18255
diff
changeset
|
44 #endif |
d81946484cce
mountlist: include sysmacros.h for glibc
Eric Blake <eblake@redhat.com>
parents:
18255
diff
changeset
|
45 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
46 #if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */ |
3537 | 47 # if HAVE_SYS_UCRED_H |
4986 | 48 # include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
49 NGROUPS is used as an array dimension in ucred.h */ |
3537 | 50 # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */ |
51 # endif | |
52 # if HAVE_SYS_MOUNT_H | |
53 # include <sys/mount.h> | |
54 # endif | |
55 # if HAVE_SYS_FS_TYPES_H | |
56 # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */ | |
57 # endif | |
58 # if HAVE_STRUCT_FSSTAT_F_FSTYPENAME | |
59 # define FS_TYPE(Ent) ((Ent).f_fstypename) | |
60 # else | |
61 # define FS_TYPE(Ent) mnt_names[(Ent).f_type] | |
62 # endif | |
326 | 63 #endif /* MOUNTED_GETFSSTAT */ |
64 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
65 #ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android, |
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
66 also (obsolete) 4.3BSD, SunOS, Dynix */ |
917 | 67 # include <mntent.h> |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
68 # include <sys/types.h> |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
69 # if !defined MOUNTED |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
70 # if defined _PATH_MOUNTED /* GNU libc */ |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
71 # define MOUNTED _PATH_MOUNTED |
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
72 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
73 # if defined MNT_MNTTAB /* HP-UX. */ |
917 | 74 # define MOUNTED MNT_MNTTAB |
5 | 75 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
76 # if defined MNTTABNAME /* Dynix. */ |
917 | 77 # define MOUNTED MNTTABNAME |
5 | 78 # endif |
917 | 79 # endif |
5 | 80 #endif |
81 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
82 #ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ |
917 | 83 # include <sys/mount.h> |
5 | 84 #endif |
85 | |
39907
b14bcf3a1610
mountlist: Add support for Minix.
Bruno Haible <bruno@clisp.org>
parents:
39905
diff
changeset
|
86 #ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */ |
7154
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
87 # include <sys/statvfs.h> |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
88 #endif |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
89 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
90 #ifdef MOUNTED_GETMNT /* (obsolete) Ultrix */ |
917 | 91 # include <sys/mount.h> |
92 # include <sys/fs_types.h> | |
5 | 93 #endif |
94 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
95 #ifdef MOUNTED_FS_STAT_DEV /* Haiku, also (obsolete) BeOS */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
96 # include <fs_info.h> |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
97 # include <dirent.h> |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
98 #endif |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
99 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
100 #ifdef MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */ |
917 | 101 # include <mnttab.h> |
102 # include <sys/fstyp.h> | |
103 # include <sys/statfs.h> | |
5 | 104 #endif |
105 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
106 #ifdef MOUNTED_LISTMNTENT /* (obsolete) Cray UNICOS 9 */ |
917 | 107 # include <mntent.h> |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
108 #endif |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
109 |
39908
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
110 #ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */ |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
111 # include <sys/mnttab.h> |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
112 #endif |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
113 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
114 #ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */ |
917 | 115 # include <sys/mnttab.h> |
5 | 116 #endif |
117 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
118 #ifdef MOUNTED_VMOUNT /* AIX */ |
917 | 119 # include <fshelp.h> |
120 # include <sys/vfs.h> | |
5 | 121 #endif |
122 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
123 #ifdef MOUNTED_INTERIX_STATVFS /* Interix */ |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
124 # include <sys/statvfs.h> |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
125 # include <dirent.h> |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
126 #endif |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
127 |
326 | 128 #ifdef DOLPHIN |
129 /* So special that it's not worth putting this in autoconf. */ | |
917 | 130 # undef MOUNTED_FREAD_FSTYP |
131 # define MOUNTED_GETMNTTBL | |
326 | 132 #endif |
133 | |
1278
9ad625a30b7d
Use #if, not #ifdef with HAVE_ macros
Jim Meyering <jim@meyering.net>
parents:
1183
diff
changeset
|
134 #if HAVE_SYS_MNTENT_H |
918
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
135 /* This is to get MNTOPT_IGNORE on e.g. SVR4. */ |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
136 # include <sys/mntent.h> |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
137 #endif |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
138 |
17332
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
139 #ifndef HAVE_HASMNTOPT |
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
140 # define hasmntopt(mnt, opt) ((char *) 0) |
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
141 #endif |
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
142 |
3991
ab906cd2631e
2002-07-13 Bruno Haible <bruno@clisp.org>
Jim Meyering <jim@meyering.net>
parents:
3621
diff
changeset
|
143 #undef MNT_IGNORE |
17332
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
144 #ifdef MNTOPT_IGNORE |
17697
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
145 # if defined __sun && defined __SVR4 |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
146 /* Solaris defines hasmntopt(struct mnttab *, char *) |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
147 while it is otherwise hasmntopt(struct mnttab *, const char *). */ |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
148 # define MNT_IGNORE(M) hasmntopt (M, (char *) MNTOPT_IGNORE) |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
149 # else |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
150 # define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE) |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
151 # endif |
918
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
152 #else |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
153 # define MNT_IGNORE(M) 0 |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
154 #endif |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
155 |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
156 #if USE_UNLOCKED_IO |
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
157 # include "unlocked-io.h" |
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
158 #endif |
3621
56f442359b0d
Include unlocked-io.h after all system headers.
Jim Meyering <jim@meyering.net>
parents:
3618
diff
changeset
|
159 |
7863 | 160 /* The results of opendir() in this file are not used with dirfd and fchdir, |
161 therefore save some unnecessary work in fchdir.c. */ | |
17937
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
162 #ifdef GNULIB_defined_opendir |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
163 # undef opendir |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
164 #endif |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
165 #ifdef GNULIB_defined_closedir |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
166 # undef closedir |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
167 #endif |
7863 | 168 |
17147
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
169 #define ME_DUMMY_0(Fs_name, Fs_type) \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
170 (strcmp (Fs_type, "autofs") == 0 \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
171 || strcmp (Fs_type, "proc") == 0 \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
172 || strcmp (Fs_type, "subfs") == 0 \ |
17206
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
173 /* for Linux 2.6/3.x */ \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
174 || strcmp (Fs_type, "debugfs") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
175 || strcmp (Fs_type, "devpts") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
176 || strcmp (Fs_type, "fusectl") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
177 || strcmp (Fs_type, "mqueue") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
178 || strcmp (Fs_type, "rpc_pipefs") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
179 || strcmp (Fs_type, "sysfs") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
180 /* FreeBSD, Linux 2.4 */ \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
181 || strcmp (Fs_type, "devfs") == 0 \ |
17147
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
182 /* for NetBSD 3.0 */ \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
183 || strcmp (Fs_type, "kernfs") == 0 \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
184 /* for Irix 6.5 */ \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
185 || strcmp (Fs_type, "ignore") == 0) |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
186 |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
187 /* Historically, we have marked as "dummy" any file system of type "none", |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
188 but now that programs like du need to know about bind-mounted directories, |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
189 we grant an exception to any with "bind" in its list of mount options. |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
190 I.e., those are *not* dummy entries. */ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
191 #ifdef MOUNTED_GETMNTENT1 |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
192 # define ME_DUMMY(Fs_name, Fs_type, Bind) \ |
17147
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
193 (ME_DUMMY_0 (Fs_name, Fs_type) \ |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
194 || (strcmp (Fs_type, "none") == 0 && !Bind)) |
17147
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
195 #else |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
196 # define ME_DUMMY(Fs_name, Fs_type) \ |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
197 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0) |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
198 #endif |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
199 |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
200 #ifdef __CYGWIN__ |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
201 # include <windows.h> |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
202 # define ME_REMOTE me_remote |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
203 /* All cygwin mount points include ':' or start with '//'; so it |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
204 requires a native Windows call to determine remote disks. */ |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
205 static bool |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
206 me_remote (char const *fs_name, char const *fs_type _GL_UNUSED) |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
207 { |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
208 if (fs_name[0] && fs_name[1] == ':') |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
209 { |
14056
602afdb74dc3
mountlist: tweak previous commit
Eric Blake <eblake@redhat.com>
parents:
14055
diff
changeset
|
210 char drive[4]; |
602afdb74dc3
mountlist: tweak previous commit
Eric Blake <eblake@redhat.com>
parents:
14055
diff
changeset
|
211 sprintf (drive, "%c:\\", fs_name[0]); |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
212 switch (GetDriveType (drive)) |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
213 { |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
214 case DRIVE_REMOVABLE: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
215 case DRIVE_FIXED: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
216 case DRIVE_CDROM: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
217 case DRIVE_RAMDISK: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
218 return false; |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
219 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
220 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
221 return true; |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
222 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
223 #endif |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
224 |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
225 #ifndef ME_REMOTE |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
226 /* A file system is "remote" if its Fs_name contains a ':' |
18255
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
227 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//') |
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
228 or Fs_name is equal to "-hosts" (used by autofs to mount remote fs). */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
229 # define ME_REMOTE(Fs_name, Fs_type) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
230 (strchr (Fs_name, ':') != NULL \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
231 || ((Fs_name)[0] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
232 && (Fs_name)[1] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
233 && (strcmp (Fs_type, "smbfs") == 0 \ |
18255
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
234 || strcmp (Fs_type, "cifs") == 0)) \ |
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
235 || (strcmp("-hosts", Fs_name) == 0)) |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
236 #endif |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
237 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
238 #if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
239 |
7247
c77c9dc7d8c6
* lib/mountlist.c: All uses of HAVE_F_FSTYPENAME_IN_STATFS replaced by
Paul Eggert <eggert@cs.ucla.edu>
parents:
7154
diff
changeset
|
240 # if ! HAVE_STRUCT_STATFS_F_FSTYPENAME |
5 | 241 static char * |
5159 | 242 fstype_to_string (short int t) |
5 | 243 { |
244 switch (t) | |
245 { | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
246 # ifdef MOUNT_PC |
5 | 247 case MOUNT_PC: |
248 return "pc"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
249 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
250 # ifdef MOUNT_MFS |
5 | 251 case MOUNT_MFS: |
252 return "mfs"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
253 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
254 # ifdef MOUNT_LO |
5 | 255 case MOUNT_LO: |
256 return "lo"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
257 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
258 # ifdef MOUNT_TFS |
5 | 259 case MOUNT_TFS: |
260 return "tfs"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
261 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
262 # ifdef MOUNT_TMP |
5 | 263 case MOUNT_TMP: |
264 return "tmp"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
265 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
266 # ifdef MOUNT_UFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
267 case MOUNT_UFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
268 return "ufs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
269 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
270 # ifdef MOUNT_NFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
271 case MOUNT_NFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
272 return "nfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
273 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
274 # ifdef MOUNT_MSDOS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
275 case MOUNT_MSDOS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
276 return "msdos" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
277 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
278 # ifdef MOUNT_LFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
279 case MOUNT_LFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
280 return "lfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
281 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
282 # ifdef MOUNT_LOFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
283 case MOUNT_LOFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
284 return "lofs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
285 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
286 # ifdef MOUNT_FDESC |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
287 case MOUNT_FDESC: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
288 return "fdesc" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
289 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
290 # ifdef MOUNT_PORTAL |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
291 case MOUNT_PORTAL: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
292 return "portal" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
293 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
294 # ifdef MOUNT_NULL |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
295 case MOUNT_NULL: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
296 return "null" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
297 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
298 # ifdef MOUNT_UMAP |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
299 case MOUNT_UMAP: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
300 return "umap" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
301 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
302 # ifdef MOUNT_KERNFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
303 case MOUNT_KERNFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
304 return "kernfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
305 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
306 # ifdef MOUNT_PROCFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
307 case MOUNT_PROCFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
308 return "procfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
309 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
310 # ifdef MOUNT_AFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
311 case MOUNT_AFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
312 return "afs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
313 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
314 # ifdef MOUNT_CD9660 |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
315 case MOUNT_CD9660: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
316 return "cd9660" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
317 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
318 # ifdef MOUNT_UNION |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
319 case MOUNT_UNION: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
320 return "union" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
321 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
322 # ifdef MOUNT_DEVFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
323 case MOUNT_DEVFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
324 return "devfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
325 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
326 # ifdef MOUNT_EXT2FS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
327 case MOUNT_EXT2FS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
328 return "ext2fs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
329 # endif |
5 | 330 default: |
331 return "?"; | |
332 } | |
333 } | |
7247
c77c9dc7d8c6
* lib/mountlist.c: All uses of HAVE_F_FSTYPENAME_IN_STATFS replaced by
Paul Eggert <eggert@cs.ucla.edu>
parents:
7154
diff
changeset
|
334 # endif |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
335 |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
336 static char * |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
337 fsp_to_string (const struct statfs *fsp) |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
338 { |
7247
c77c9dc7d8c6
* lib/mountlist.c: All uses of HAVE_F_FSTYPENAME_IN_STATFS replaced by
Paul Eggert <eggert@cs.ucla.edu>
parents:
7154
diff
changeset
|
339 # if HAVE_STRUCT_STATFS_F_FSTYPENAME |
2667
a61942f1a535
(fsp_to_string) [HAVE_F_FSTYPENAME_IN_STATFS]:
Jim Meyering <jim@meyering.net>
parents:
2570
diff
changeset
|
340 return (char *) (fsp->f_fstypename); |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
341 # else |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
342 return fstype_to_string (fsp->f_type); |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
343 # endif |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
344 } |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
345 |
5 | 346 #endif /* MOUNTED_GETMNTINFO */ |
347 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
348 #ifdef MOUNTED_VMOUNT /* AIX */ |
5 | 349 static char * |
1446 | 350 fstype_to_string (int t) |
5 | 351 { |
352 struct vfs_ent *e; | |
353 | |
354 e = getvfsbytype (t); | |
355 if (!e || !e->vfsent_name) | |
356 return "none"; | |
357 else | |
358 return e->vfsent_name; | |
359 } | |
360 #endif /* MOUNTED_VMOUNT */ | |
361 | |
6527 | 362 |
363 #if defined MOUNTED_GETMNTENT1 || defined MOUNTED_GETMNTENT2 | |
364 | |
365 /* Return the device number from MOUNT_OPTIONS, if possible. | |
366 Otherwise return (dev_t) -1. */ | |
367 static dev_t | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
368 dev_from_mount_options (char const *mount_options) |
6527 | 369 { |
370 /* GNU/Linux allows file system implementations to define their own | |
371 meaning for "dev=" mount options, so don't trust the meaning | |
372 here. */ | |
373 # ifndef __linux__ | |
374 | |
375 static char const dev_pattern[] = ",dev="; | |
376 char const *devopt = strstr (mount_options, dev_pattern); | |
377 | |
378 if (devopt) | |
379 { | |
380 char const *optval = devopt + sizeof dev_pattern - 1; | |
381 char *optvalend; | |
382 unsigned long int dev; | |
383 errno = 0; | |
384 dev = strtoul (optval, &optvalend, 16); | |
385 if (optval != optvalend | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
386 && (*optvalend == '\0' || *optvalend == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
387 && ! (dev == ULONG_MAX && errno == ERANGE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
388 && dev == (dev_t) dev) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
389 return dev; |
6527 | 390 } |
391 | |
392 # endif | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
393 (void) mount_options; |
6527 | 394 return -1; |
395 } | |
396 | |
397 #endif | |
398 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
399 #if defined MOUNTED_GETMNTENT1 && defined __linux__ /* GNU/Linux, Android */ |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
400 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
401 /* Unescape the paths in mount tables. |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
402 STR is updated in place. */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
403 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
404 static void |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
405 unescape_tab (char *str) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
406 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
407 size_t i, j = 0; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
408 size_t len = strlen (str) + 1; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
409 for (i = 0; i < len; i++) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
410 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
411 if (str[i] == '\\' && (i + 4 < len) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
412 && str[i + 1] >= '0' && str[i + 1] <= '3' |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
413 && str[i + 2] >= '0' && str[i + 2] <= '7' |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
414 && str[i + 3] >= '0' && str[i + 3] <= '7') |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
415 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
416 str[j++] = (str[i + 1] - '0') * 64 + |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
417 (str[i + 2] - '0') * 8 + |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
418 (str[i + 3] - '0'); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
419 i += 3; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
420 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
421 else |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
422 str[j++] = str[i]; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
423 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
424 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
425 #endif |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
426 |
5159 | 427 /* Return a list of the currently mounted file systems, or NULL on error. |
5 | 428 Add each entry to the tail of the list so that they stay in order. |
5159 | 429 If NEED_FS_TYPE is true, ensure that the file system type fields in |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
430 the returned list are valid. Otherwise, they might not be. */ |
5 | 431 |
432 struct mount_entry * | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
433 read_file_system_list (bool need_fs_type) |
5 | 434 { |
435 struct mount_entry *mount_list; | |
436 struct mount_entry *me; | |
1413 | 437 struct mount_entry **mtail = &mount_list; |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
438 (void) need_fs_type; |
5 | 439 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
440 #ifdef MOUNTED_LISTMNTENT /* (obsolete) Cray UNICOS 9 */ |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
441 { |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
442 struct tabmntent *mntlist, *p; |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
443 struct mntent *mnt; |
876 | 444 |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
445 /* the third and fourth arguments could be used to filter mounts, |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
446 but Crays doesn't seem to have any mounts that we want to |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
447 remove. Specifically, automount create normal NFS mounts. |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
448 */ |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
449 |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
450 if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0) |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
451 return NULL; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
452 for (p = mntlist; p; p = p->next) |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
453 { |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
454 mnt = p->ment; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
455 me = xmalloc (sizeof *me); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
456 me->me_devname = xstrdup (mnt->mnt_fsname); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
457 me->me_mountdir = xstrdup (mnt->mnt_dir); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
458 me->me_mntroot = NULL; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
459 me->me_type = xstrdup (mnt->mnt_type); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
460 me->me_type_malloced = 1; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
461 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
462 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
463 me->me_dev = -1; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
464 *mtail = me; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
465 mtail = &me->me_next; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
466 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
467 freemntlist (mntlist); |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
468 } |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
469 #endif |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
470 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
471 #ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android, |
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
472 also (obsolete) 4.3BSD, SunOS, Dynix */ |
5 | 473 { |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
474 FILE *fp; |
5 | 475 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
476 # ifdef __linux__ |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
477 /* Try parsing mountinfo first, as that make device IDs available. |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
478 Note we could use libmount routines to simplify this parsing a little |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
479 (and that code is in previous versions of this function), however |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
480 libmount depends on libselinux which pulls in many dependencies. */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
481 char const *mountinfo = "/proc/self/mountinfo"; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
482 fp = fopen (mountinfo, "r"); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
483 if (fp != NULL) |
5 | 484 { |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
485 char *line = NULL; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
486 size_t buf_size = 0; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
487 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
488 while (getline (&line, &buf_size, fp) != -1) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
489 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
490 unsigned int devmaj, devmin; |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
491 int target_s, target_e, type_s, type_e; |
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
492 int source_s, source_e, mntroot_s, mntroot_e; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
493 char test; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
494 char *dash; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
495 int rc; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
496 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
497 rc = sscanf(line, "%*u " /* id - discarded */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
498 "%*u " /* parent - discarded */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
499 "%u:%u " /* dev major:minor */ |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
500 "%n%*s%n " /* mountroot */ |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
501 "%n%*s%n" /* target, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
502 "%c", /* more data... */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
503 &devmaj, &devmin, |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
504 &mntroot_s, &mntroot_e, |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
505 &target_s, &target_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
506 &test); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
507 |
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
508 if (rc != 3 && rc != 7) /* 7 if %n included in count. */ |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
509 continue; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
510 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
511 /* skip optional fields, terminated by " - " */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
512 dash = strstr (line + target_e, " - "); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
513 if (! dash) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
514 continue; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
515 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
516 rc = sscanf(dash, " - " |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
517 "%n%*s%n " /* FS type, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
518 "%n%*s%n " /* source, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
519 "%c", /* more data... */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
520 &type_s, &type_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
521 &source_s, &source_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
522 &test); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
523 if (rc != 1 && rc != 5) /* 5 if %n included in count. */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
524 continue; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
525 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
526 /* manipulate the sub-strings in place. */ |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
527 line[mntroot_e] = '\0'; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
528 line[target_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
529 dash[type_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
530 dash[source_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
531 unescape_tab (dash + source_s); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
532 unescape_tab (line + target_s); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
533 unescape_tab (line + mntroot_s); |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
534 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
535 me = xmalloc (sizeof *me); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
536 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
537 me->me_devname = xstrdup (dash + source_s); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
538 me->me_mountdir = xstrdup (line + target_s); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
539 me->me_mntroot = xstrdup (line + mntroot_s); |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
540 me->me_type = xstrdup (dash + type_s); |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
541 me->me_type_malloced = 1; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
542 me->me_dev = makedev (devmaj, devmin); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
543 /* we pass "false" for the "Bind" option as that's only |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
544 significant when the Fs_type is "none" which will not be |
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
545 the case when parsing "/proc/self/mountinfo", and only |
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
546 applies for static /etc/mtab files. */ |
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
547 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, false); |
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
548 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
549 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
550 /* Add to the linked list. */ |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
551 *mtail = me; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
552 mtail = &me->me_next; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
553 } |
5 | 554 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
555 free (line); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
556 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
557 if (ferror (fp)) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
558 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
559 int saved_errno = errno; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
560 fclose (fp); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
561 errno = saved_errno; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
562 goto free_then_fail; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
563 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
564 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
565 if (fclose (fp) == EOF) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
566 goto free_then_fail; |
5 | 567 } |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
568 else /* fallback to /proc/self/mounts (/etc/mtab). */ |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
569 # endif /* __linux __ */ |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
570 { |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
571 struct mntent *mnt; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
572 char const *table = MOUNTED; |
5 | 573 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
574 fp = setmntent (table, "r"); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
575 if (fp == NULL) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
576 return NULL; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
577 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
578 while ((mnt = getmntent (fp))) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
579 { |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
580 bool bind = hasmntopt (mnt, "bind"); |
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
581 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
582 me = xmalloc (sizeof *me); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
583 me->me_devname = xstrdup (mnt->mnt_fsname); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
584 me->me_mountdir = xstrdup (mnt->mnt_dir); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
585 me->me_mntroot = NULL; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
586 me->me_type = xstrdup (mnt->mnt_type); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
587 me->me_type_malloced = 1; |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
588 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, bind); |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
589 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
590 me->me_dev = dev_from_mount_options (mnt->mnt_opts); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
591 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
592 /* Add to the linked list. */ |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
593 *mtail = me; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
594 mtail = &me->me_next; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
595 } |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
596 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
597 if (endmntent (fp) == 0) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
598 goto free_then_fail; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
599 } |
5 | 600 } |
601 #endif /* MOUNTED_GETMNTENT1. */ | |
602 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
603 #ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ |
5 | 604 { |
605 struct statfs *fsp; | |
606 int entries; | |
607 | |
608 entries = getmntinfo (&fsp, MNT_NOWAIT); | |
609 if (entries < 0) | |
610 return NULL; | |
1443
13bcee72981f
(read_filesystem_list): If all_fs is negative, omit non-local filesytems.
Jim Meyering <jim@meyering.net>
parents:
1436
diff
changeset
|
611 for (; entries-- > 0; fsp++) |
5 | 612 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
613 char *fs_type = fsp_to_string (fsp); |
1443
13bcee72981f
(read_filesystem_list): If all_fs is negative, omit non-local filesytems.
Jim Meyering <jim@meyering.net>
parents:
1436
diff
changeset
|
614 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
615 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
616 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
617 me->me_mountdir = xstrdup (fsp->f_mntonname); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
618 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
619 me->me_type = fs_type; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
620 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
621 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
622 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
623 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
5 | 624 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
625 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
626 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
627 mtail = &me->me_next; |
5 | 628 } |
629 } | |
630 #endif /* MOUNTED_GETMNTINFO */ | |
631 | |
39907
b14bcf3a1610
mountlist: Add support for Minix.
Bruno Haible <bruno@clisp.org>
parents:
39905
diff
changeset
|
632 #ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */ |
7154
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
633 { |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
634 struct statvfs *fsp; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
635 int entries; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
636 |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
637 entries = getmntinfo (&fsp, MNT_NOWAIT); |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
638 if (entries < 0) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
639 return NULL; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
640 for (; entries-- > 0; fsp++) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
641 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
642 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
643 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
644 me->me_mountdir = xstrdup (fsp->f_mntonname); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
645 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
646 me->me_type = xstrdup (fsp->f_fstypename); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
647 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
648 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
649 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
650 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
7154
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
651 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
652 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
653 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
654 mtail = &me->me_next; |
7154
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
655 } |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
656 } |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
657 #endif /* MOUNTED_GETMNTINFO2 */ |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
658 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
659 #ifdef MOUNTED_GETMNT /* (obsolete) Ultrix */ |
5 | 660 { |
661 int offset = 0; | |
662 int val; | |
663 struct fs_data fsd; | |
664 | |
1413 | 665 while (errno = 0, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
666 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
667 (char *) 0))) |
5 | 668 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
669 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
670 me->me_devname = xstrdup (fsd.fd_req.devname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
671 me->me_mountdir = xstrdup (fsd.fd_req.path); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
672 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
673 me->me_type = gt_names[fsd.fd_req.fstype]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
674 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
675 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
676 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
677 me->me_dev = fsd.fd_req.dev; |
5 | 678 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
679 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
680 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
681 mtail = &me->me_next; |
5 | 682 } |
683 if (val < 0) | |
1413 | 684 goto free_then_fail; |
5 | 685 } |
686 #endif /* MOUNTED_GETMNT. */ | |
687 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
688 #if defined MOUNTED_FS_STAT_DEV /* Haiku, also (obsolete) BeOS */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
689 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
690 /* The next_dev() and fs_stat_dev() system calls give the list of |
5159 | 691 all file systems, including the information returned by statvfs() |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
692 (fs type, total blocks, free blocks etc.), but without the mount |
5159 | 693 point. But on BeOS all file systems except / are mounted in the |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
694 rootfs, directly under /. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
695 The directory name of the mount point is often, but not always, |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
696 identical to the volume name of the device. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
697 We therefore get the list of subdirectories of /, and the list |
5159 | 698 of all file systems, and match the two lists. */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
699 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
700 DIR *dirp; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
701 struct rootdir_entry |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
702 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
703 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
704 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
705 ino_t ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
706 struct rootdir_entry *next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
707 }; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
708 struct rootdir_entry *rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
709 struct rootdir_entry **rootdir_tail; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
710 int32 pos; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
711 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
712 fs_info fi; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
713 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
714 /* All volumes are mounted in the rootfs, directly under /. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
715 rootdir_list = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
716 rootdir_tail = &rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
717 dirp = opendir ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
718 if (dirp) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
719 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
720 struct dirent *d; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
721 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
722 while ((d = readdir (dirp)) != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
723 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
724 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
725 struct stat statbuf; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
726 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
727 if (strcmp (d->d_name, "..") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
728 continue; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
729 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
730 if (strcmp (d->d_name, ".") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
731 name = xstrdup ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
732 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
733 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
734 name = xmalloc (1 + strlen (d->d_name) + 1); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
735 name[0] = '/'; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
736 strcpy (name + 1, d->d_name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
737 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
738 |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
739 if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode)) |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
740 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
741 struct rootdir_entry *re = xmalloc (sizeof *re); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
742 re->name = name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
743 re->dev = statbuf.st_dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
744 re->ino = statbuf.st_ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
745 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
746 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
747 *rootdir_tail = re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
748 rootdir_tail = &re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
749 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
750 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
751 free (name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
752 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
753 closedir (dirp); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
754 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
755 *rootdir_tail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
756 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
757 for (pos = 0; (dev = next_dev (&pos)) >= 0; ) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
758 if (fs_stat_dev (dev, &fi) >= 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
759 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
760 /* Note: fi.dev == dev. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
761 struct rootdir_entry *re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
762 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
763 for (re = rootdir_list; re; re = re->next) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
764 if (re->dev == fi.dev && re->ino == fi.root) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
765 break; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
766 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
767 me = xmalloc (sizeof *me); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
768 me->me_devname = xstrdup (fi.device_name[0] != '\0' |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
769 ? fi.device_name : fi.fsh_name); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
770 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
771 me->me_mntroot = NULL; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
772 me->me_type = xstrdup (fi.fsh_name); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
773 me->me_type_malloced = 1; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
774 me->me_dev = fi.dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
775 me->me_dummy = 0; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
776 me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
777 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
778 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
779 *mtail = me; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
780 mtail = &me->me_next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
781 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
782 *mtail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
783 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
784 while (rootdir_list != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
785 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
786 struct rootdir_entry *re = rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
787 rootdir_list = re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
788 free (re->name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
789 free (re); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
790 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
791 } |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
792 #endif /* MOUNTED_FS_STAT_DEV */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
793 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
794 #if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */ |
326 | 795 { |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
796 int numsys, counter; |
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
797 size_t bufsize; |
326 | 798 struct statfs *stats; |
799 | |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
800 numsys = getfsstat (NULL, 0L, MNT_NOWAIT); |
326 | 801 if (numsys < 0) |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
802 return NULL; |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
803 if (SIZE_MAX / sizeof *stats <= numsys) |
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
804 xalloc_die (); |
326 | 805 |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
806 bufsize = (1 + numsys) * sizeof *stats; |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
807 stats = xmalloc (bufsize); |
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
808 numsys = getfsstat (stats, bufsize, MNT_NOWAIT); |
326 | 809 |
810 if (numsys < 0) | |
811 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
812 free (stats); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
813 return NULL; |
326 | 814 } |
815 | |
816 for (counter = 0; counter < numsys; counter++) | |
817 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
818 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
819 me->me_devname = xstrdup (stats[counter].f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
820 me->me_mountdir = xstrdup (stats[counter].f_mntonname); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
821 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
822 me->me_type = xstrdup (FS_TYPE (stats[counter])); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
823 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
824 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
825 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
826 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 827 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
828 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
829 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
830 mtail = &me->me_next; |
326 | 831 } |
832 | |
833 free (stats); | |
834 } | |
835 #endif /* MOUNTED_GETFSSTAT */ | |
836 | |
39923
8e97d3ff3b45
mountlist: Remove support for SVR2.
Bruno Haible <bruno@clisp.org>
parents:
39908
diff
changeset
|
837 #if defined MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */ |
5 | 838 { |
839 struct mnttab mnt; | |
840 char *table = "/etc/mnttab"; | |
841 FILE *fp; | |
842 | |
843 fp = fopen (table, "r"); | |
844 if (fp == NULL) | |
845 return NULL; | |
846 | |
847 while (fread (&mnt, sizeof mnt, 1, fp) > 0) | |
848 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
849 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
850 me->me_devname = xstrdup (mnt.mt_dev); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
851 me->me_mountdir = xstrdup (mnt.mt_filsys); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
852 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
853 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
854 me->me_type = ""; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
855 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
856 if (need_fs_type) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
857 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
858 struct statfs fsd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
859 char typebuf[FSTYPSZ]; |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
860 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
861 if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
862 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
863 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
864 me->me_type = xstrdup (typebuf); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
865 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
866 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
867 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
868 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
869 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
5 | 870 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
871 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
872 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
873 mtail = &me->me_next; |
1413 | 874 } |
875 | |
876 if (ferror (fp)) | |
877 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
878 /* The last fread() call must have failed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
879 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
880 fclose (fp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
881 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
882 goto free_then_fail; |
5 | 883 } |
884 | |
885 if (fclose (fp) == EOF) | |
1413 | 886 goto free_then_fail; |
5 | 887 } |
39923
8e97d3ff3b45
mountlist: Remove support for SVR2.
Bruno Haible <bruno@clisp.org>
parents:
39908
diff
changeset
|
888 #endif /* MOUNTED_FREAD_FSTYP. */ |
5 | 889 |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
890 #ifdef MOUNTED_GETMNTTBL /* (obsolete) DolphinOS */ |
326 | 891 { |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
892 struct mntent **mnttbl = getmnttbl (), **ent; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
893 for (ent = mnttbl; *ent; ent++) |
326 | 894 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
895 me = xmalloc (sizeof *me); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
896 me->me_devname = xstrdup ((*ent)->mt_resource); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
897 me->me_mountdir = xstrdup ((*ent)->mt_directory); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
898 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
899 me->me_type = xstrdup ((*ent)->mt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
900 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
901 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
902 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
903 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 904 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
905 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
906 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
907 mtail = &me->me_next; |
326 | 908 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
909 endmnttbl (); |
326 | 910 } |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
911 #endif /* MOUNTED_GETMNTTBL */ |
326 | 912 |
39908
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
913 #ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */ |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
914 { |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
915 struct extmnttab mnt; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
916 const char *table = MNTTAB; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
917 FILE *fp; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
918 int ret; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
919 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
920 /* No locking is needed, because the contents of /etc/mnttab is generated |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
921 by the kernel. */ |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
922 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
923 errno = 0; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
924 fp = fopen (table, "r"); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
925 if (fp == NULL) |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
926 ret = errno; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
927 else |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
928 { |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
929 while ((ret = getextmntent (fp, &mnt, 1)) == 0) |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
930 { |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
931 me = xmalloc (sizeof *me); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
932 me->me_devname = xstrdup (mnt.mnt_special); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
933 me->me_mountdir = xstrdup (mnt.mnt_mountp); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
934 me->me_mntroot = NULL; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
935 me->me_type = xstrdup (mnt.mnt_fstype); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
936 me->me_type_malloced = 1; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
937 me->me_dummy = MNT_IGNORE (&mnt) != 0; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
938 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
939 me->me_dev = makedev (mnt.mnt_major, mnt.mnt_minor); |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
940 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
941 /* Add to the linked list. */ |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
942 *mtail = me; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
943 mtail = &me->me_next; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
944 } |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
945 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
946 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
947 /* Here ret = -1 means success, ret >= 0 means failure. */ |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
948 } |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
949 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
950 if (0 <= ret) |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
951 { |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
952 errno = ret; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
953 goto free_then_fail; |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
954 } |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
955 } |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
956 #endif /* MOUNTED_GETMNTTBL */ |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
957 |
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
958 #ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */ |
5 | 959 { |
960 struct mnttab mnt; | |
39908
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
961 const char *table = MNTTAB; |
5 | 962 FILE *fp; |
963 int ret; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
964 int lockfd = -1; |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
965 |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
966 # if defined F_RDLCK && defined F_SETLKW |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
967 /* MNTTAB_LOCK is a macro name of our own invention; it's not present in |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
968 e.g. Solaris 2.6. If the SVR4 folks ever define a macro |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
969 for this file name, we should use their macro name instead. |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
970 (Why not just lock MNTTAB directly? We don't know.) */ |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
971 # ifndef MNTTAB_LOCK |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
972 # define MNTTAB_LOCK "/etc/.mnttab.lock" |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
973 # endif |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
974 lockfd = open (MNTTAB_LOCK, O_RDONLY); |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
975 if (0 <= lockfd) |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
976 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
977 struct flock flock; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
978 flock.l_type = F_RDLCK; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
979 flock.l_whence = SEEK_SET; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
980 flock.l_start = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
981 flock.l_len = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
982 while (fcntl (lockfd, F_SETLKW, &flock) == -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
983 if (errno != EINTR) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
984 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
985 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
986 close (lockfd); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
987 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
988 return NULL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
989 } |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
990 } |
1413 | 991 else if (errno != ENOENT) |
992 return NULL; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
993 # endif |
5 | 994 |
1413 | 995 errno = 0; |
5 | 996 fp = fopen (table, "r"); |
997 if (fp == NULL) | |
1413 | 998 ret = errno; |
1401 | 999 else |
1400
8e5de8bcae9f
(read_filesystem_list) [MOUNTED_GETMNTENT2]:
Jim Meyering <jim@meyering.net>
parents:
1399
diff
changeset
|
1000 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1001 while ((ret = getmntent (fp, &mnt)) == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1002 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1003 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1004 me->me_devname = xstrdup (mnt.mnt_special); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1005 me->me_mountdir = xstrdup (mnt.mnt_mountp); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
1006 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1007 me->me_type = xstrdup (mnt.mnt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1008 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1009 me->me_dummy = MNT_IGNORE (&mnt) != 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1010 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1011 me->me_dev = dev_from_mount_options (mnt.mnt_mntopts); |
1401 | 1012 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1013 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1014 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1015 mtail = &me->me_next; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1016 } |
1401 | 1017 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1018 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; |
39908
f2b5499e6ee2
mountlist: Improve support for Solaris in 64-bit mode.
Bruno Haible <bruno@clisp.org>
parents:
39907
diff
changeset
|
1019 /* Here ret = -1 means success, ret >= 0 means failure. */ |
1400
8e5de8bcae9f
(read_filesystem_list) [MOUNTED_GETMNTENT2]:
Jim Meyering <jim@meyering.net>
parents:
1399
diff
changeset
|
1020 } |
5 | 1021 |
1401 | 1022 if (0 <= lockfd && close (lockfd) != 0) |
1413 | 1023 ret = errno; |
5 | 1024 |
1413 | 1025 if (0 <= ret) |
1026 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1027 errno = ret; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1028 goto free_then_fail; |
1413 | 1029 } |
5 | 1030 } |
1031 #endif /* MOUNTED_GETMNTENT2. */ | |
1032 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
1033 #ifdef MOUNTED_VMOUNT /* AIX */ |
5 | 1034 { |
1035 int bufsize; | |
18009
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
1036 void *entries; |
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
1037 char *thisent; |
2570
70878b295de9
move vmp decl back out to the scope where it belongs
Jim Meyering <jim@meyering.net>
parents:
2553
diff
changeset
|
1038 struct vmount *vmp; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1039 int n_entries; |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1040 int i; |
5 | 1041 |
5159 | 1042 /* Ask how many bytes to allocate for the mounted file system info. */ |
18009
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
1043 entries = &bufsize; |
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
1044 if (mntctl (MCTL_QUERY, sizeof bufsize, entries) != 0) |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1045 return NULL; |
5 | 1046 entries = xmalloc (bufsize); |
1047 | |
5159 | 1048 /* Get the list of mounted file systems. */ |
18009
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
1049 n_entries = mntctl (MCTL_QUERY, bufsize, entries); |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1050 if (n_entries < 0) |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1051 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1052 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1053 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1054 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1055 return NULL; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1056 } |
5 | 1057 |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1058 for (i = 0, thisent = entries; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1059 i < n_entries; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1060 i++, thisent += vmp->vmt_length) |
5 | 1061 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1062 char *options, *ignore; |
2550
3ce1a171e216
(read_filesystem_list) [MOUNTED_VMOUNT]: Ignore mounts
Jim Meyering <jim@meyering.net>
parents:
2453
diff
changeset
|
1063 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1064 vmp = (struct vmount *) thisent; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1065 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1066 if (vmp->vmt_flags & MNT_REMOTE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1067 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1068 char *host, *dir; |
5 | 1069 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1070 me->me_remote = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1071 /* Prepend the remote dirname. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1072 host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1073 dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1074 me->me_devname = xmalloc (strlen (host) + strlen (dir) + 2); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1075 strcpy (me->me_devname, host); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1076 strcat (me->me_devname, ":"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1077 strcat (me->me_devname, dir); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1078 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1079 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1080 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1081 me->me_remote = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1082 me->me_devname = xstrdup (thisent + |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1083 vmp->vmt_data[VMT_OBJECT].vmt_off); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1084 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1085 me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
1086 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1087 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1088 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1089 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1090 ignore = strstr (options, "ignore"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1091 me->me_dummy = (ignore |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1092 && (ignore == options || ignore[-1] == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1093 && (ignore[sizeof "ignore" - 1] == ',' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1094 || ignore[sizeof "ignore" - 1] == '\0')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1095 me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ |
5 | 1096 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1097 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1098 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1099 mtail = &me->me_next; |
5 | 1100 } |
1101 free (entries); | |
1102 } | |
1103 #endif /* MOUNTED_VMOUNT. */ | |
1104 | |
39905
c3122bb580fe
mountlist: Modernize platform lists.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
1105 #ifdef MOUNTED_INTERIX_STATVFS /* Interix */ |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1106 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1107 DIR *dirp = opendir ("/dev/fs"); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1108 char node[9 + NAME_MAX]; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1109 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1110 if (!dirp) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1111 goto free_then_fail; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1112 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1113 while (1) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1114 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1115 struct statvfs dev; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1116 struct dirent entry; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1117 struct dirent *result; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1118 |
18244
976d848c1f8d
readdir_r: now obsolescent
Paul Eggert <eggert@cs.ucla.edu>
parents:
18189
diff
changeset
|
1119 /* FIXME: readdir_r is planned to be withdrawn from POSIX and |
976d848c1f8d
readdir_r: now obsolescent
Paul Eggert <eggert@cs.ucla.edu>
parents:
18189
diff
changeset
|
1120 marked obsolescent in glibc. Use readdir instead. */ |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1121 if (readdir_r (dirp, &entry, &result) || result == NULL) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1122 break; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1123 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1124 strcpy (node, "/dev/fs/"); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1125 strcat (node, entry.d_name); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1126 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1127 if (statvfs (node, &dev) == 0) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1128 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1129 me = xmalloc (sizeof *me); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1130 me->me_devname = xstrdup (dev.f_mntfromname); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1131 me->me_mountdir = xstrdup (dev.f_mntonname); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
1132 me->me_mntroot = NULL; |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1133 me->me_type = xstrdup (dev.f_fstypename); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1134 me->me_type_malloced = 1; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1135 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1136 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1137 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1138 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1139 /* Add to the linked list. */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1140 *mtail = me; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1141 mtail = &me->me_next; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1142 } |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1143 } |
17502
94372321dd20
mountlist: fix resource leak with MOUNTED_INTERIX_STATVFS
Andrew Borodin <aborodin@vmail.ru>
parents:
17435
diff
changeset
|
1144 closedir (dirp); |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1145 } |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1146 #endif /* MOUNTED_INTERIX_STATVFS */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1147 |
1413 | 1148 *mtail = NULL; |
5 | 1149 return mount_list; |
1413 | 1150 |
1151 | |
18028
4b0e76619c7f
mountlist: avoid an unused-label warning on OS X
Jim Meyering <meyering@fb.com>
parents:
18009
diff
changeset
|
1152 free_then_fail: _GL_UNUSED_LABEL |
1413 | 1153 { |
1154 int saved_errno = errno; | |
1155 *mtail = NULL; | |
1436
5919c19d9a1a
(read_filesystem_list): Fix more memory leaks on failure.
Jim Meyering <jim@meyering.net>
parents:
1413
diff
changeset
|
1156 |
1413 | 1157 while (mount_list) |
1158 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1159 me = mount_list->me_next; |
17435
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1160 free_mount_entry (mount_list); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1161 mount_list = me; |
1413 | 1162 } |
1163 | |
1164 errno = saved_errno; | |
1165 return NULL; | |
1166 } | |
5 | 1167 } |
17435
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1168 |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1169 /* Free a mount entry as returned from read_file_system_list (). */ |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1170 |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1171 void free_mount_entry (struct mount_entry *me) |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1172 { |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1173 free (me->me_devname); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1174 free (me->me_mountdir); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
1175 free (me->me_mntroot); |
17435
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1176 if (me->me_type_malloced) |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1177 free (me->me_type); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1178 free (me); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1179 } |