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