Mercurial > gnulib
annotate lib/mountlist.c @ 18189:31b2239ca59c
version-etc: new year
* build-aux/gendocs.sh (version):
* doc/gendocs_template:
* doc/gendocs_template_min:
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR):
Update copyright dates by hand in templates and the like.
* all files: Run 'make update-copyright'.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 01 Jan 2016 00:56:19 -0800 |
parents | fcaa6f67345d |
children | 976d848c1f8d |
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 |
18189 | 3 Copyright (C) 1991-1992, 1997-2016 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 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7944
diff
changeset
|
16 along with this program. If not, see <http://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 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
40 #if defined MOUNTED_GETFSSTAT /* OSF_1 and Darwin1.3.x */ |
3537 | 41 # if HAVE_SYS_UCRED_H |
4986 | 42 # 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
|
43 NGROUPS is used as an array dimension in ucred.h */ |
3537 | 44 # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */ |
45 # endif | |
46 # if HAVE_SYS_MOUNT_H | |
47 # include <sys/mount.h> | |
48 # endif | |
49 # if HAVE_SYS_FS_TYPES_H | |
50 # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */ | |
51 # endif | |
52 # if HAVE_STRUCT_FSSTAT_F_FSTYPENAME | |
53 # define FS_TYPE(Ent) ((Ent).f_fstypename) | |
54 # else | |
55 # define FS_TYPE(Ent) mnt_names[(Ent).f_type] | |
56 # endif | |
326 | 57 #endif /* MOUNTED_GETFSSTAT */ |
58 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
59 #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ |
917 | 60 # include <mntent.h> |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
61 # include <sys/types.h> |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
62 # if !defined MOUNTED |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
63 # if defined _PATH_MOUNTED /* GNU libc */ |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
64 # define MOUNTED _PATH_MOUNTED |
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
65 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
66 # if defined MNT_MNTTAB /* HP-UX. */ |
917 | 67 # define MOUNTED MNT_MNTTAB |
5 | 68 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
69 # if defined MNTTABNAME /* Dynix. */ |
917 | 70 # define MOUNTED MNTTABNAME |
5 | 71 # endif |
917 | 72 # endif |
5 | 73 #endif |
74 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
75 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ |
917 | 76 # include <sys/mount.h> |
5 | 77 #endif |
78 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
79 #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ |
7154
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
80 # include <sys/statvfs.h> |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
81 #endif |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
82 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
83 #ifdef MOUNTED_GETMNT /* Ultrix. */ |
917 | 84 # include <sys/mount.h> |
85 # include <sys/fs_types.h> | |
5 | 86 #endif |
87 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
88 #ifdef MOUNTED_FS_STAT_DEV /* BeOS. */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
89 # include <fs_info.h> |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
90 # include <dirent.h> |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
91 #endif |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
92 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
93 #ifdef MOUNTED_FREAD /* SVR2. */ |
917 | 94 # include <mnttab.h> |
5 | 95 #endif |
96 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
97 #ifdef MOUNTED_FREAD_FSTYP /* SVR3. */ |
917 | 98 # include <mnttab.h> |
99 # include <sys/fstyp.h> | |
100 # include <sys/statfs.h> | |
5 | 101 #endif |
102 | |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
103 #ifdef MOUNTED_LISTMNTENT |
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 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
107 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */ |
917 | 108 # include <sys/mnttab.h> |
5 | 109 #endif |
110 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
111 #ifdef MOUNTED_VMOUNT /* AIX. */ |
917 | 112 # include <fshelp.h> |
113 # include <sys/vfs.h> | |
5 | 114 #endif |
115 | |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
116 #ifdef MOUNTED_INTERIX_STATVFS /* Interix. */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
117 # include <sys/statvfs.h> |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
118 # include <dirent.h> |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
119 #endif |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
120 |
326 | 121 #ifdef DOLPHIN |
122 /* So special that it's not worth putting this in autoconf. */ | |
917 | 123 # undef MOUNTED_FREAD_FSTYP |
124 # define MOUNTED_GETMNTTBL | |
326 | 125 #endif |
126 | |
1278
9ad625a30b7d
Use #if, not #ifdef with HAVE_ macros
Jim Meyering <jim@meyering.net>
parents:
1183
diff
changeset
|
127 #if HAVE_SYS_MNTENT_H |
918
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
128 /* 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
|
129 # include <sys/mntent.h> |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
130 #endif |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
131 |
17332
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
132 #ifndef HAVE_HASMNTOPT |
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
133 # define hasmntopt(mnt, opt) ((char *) 0) |
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
134 #endif |
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
135 |
3991
ab906cd2631e
2002-07-13 Bruno Haible <bruno@clisp.org>
Jim Meyering <jim@meyering.net>
parents:
3621
diff
changeset
|
136 #undef MNT_IGNORE |
17332
e6a6fd004283
mountlist: port to HP NonStop
Paul Eggert <eggert@cs.ucla.edu>
parents:
17300
diff
changeset
|
137 #ifdef MNTOPT_IGNORE |
17697
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
138 # if defined __sun && defined __SVR4 |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
139 /* Solaris defines hasmntopt(struct mnttab *, char *) |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
140 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
|
141 # 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
|
142 # else |
5a079c01ad79
mountlist: avoid hasmntopt const type warning on solaris
Ben Walton <bdwalton@gmail.com>
parents:
17666
diff
changeset
|
143 # 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
|
144 # endif |
918
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
145 #else |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
146 # define MNT_IGNORE(M) 0 |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
147 #endif |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
148 |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
149 #if USE_UNLOCKED_IO |
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
150 # include "unlocked-io.h" |
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
151 #endif |
3621
56f442359b0d
Include unlocked-io.h after all system headers.
Jim Meyering <jim@meyering.net>
parents:
3618
diff
changeset
|
152 |
7863 | 153 /* The results of opendir() in this file are not used with dirfd and fchdir, |
154 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
|
155 #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
|
156 # undef opendir |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
157 #endif |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
158 #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
|
159 # undef closedir |
34065aa26b62
glob, etc.: port to MSVC v18 on MS-Windows 8.1
Paul Eggert <eggert@cs.ucla.edu>
parents:
17848
diff
changeset
|
160 #endif |
7863 | 161 |
17147
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
162 #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
|
163 (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
|
164 || 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
|
165 || strcmp (Fs_type, "subfs") == 0 \ |
17206
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
166 /* for Linux 2.6/3.x */ \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
167 || strcmp (Fs_type, "debugfs") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
168 || strcmp (Fs_type, "devpts") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
169 || strcmp (Fs_type, "fusectl") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
170 || strcmp (Fs_type, "mqueue") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
171 || strcmp (Fs_type, "rpc_pipefs") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
172 || strcmp (Fs_type, "sysfs") == 0 \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
173 /* FreeBSD, Linux 2.4 */ \ |
6a46fcdee530
mountlist: recognize more "dummy" file systems
Eric Wong <normalperson@yhbt.net>
parents:
17150
diff
changeset
|
174 || 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
|
175 /* 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
|
176 || 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
|
177 /* 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
|
178 || 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
|
179 |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
180 /* 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
|
181 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
|
182 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
|
183 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
|
184 #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
|
185 # 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
|
186 (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
|
187 || (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
|
188 #else |
c4a6dcd5073a
mountlist: do not classify a bind-mounted dir entry as "dummy"
Andrew Warshall <warshall@99main.com>
parents:
16235
diff
changeset
|
189 # 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
|
190 (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
|
191 #endif |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
192 |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
193 #ifdef __CYGWIN__ |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
194 # include <windows.h> |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
195 # define ME_REMOTE me_remote |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
196 /* 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
|
197 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
|
198 static bool |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
199 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
|
200 { |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
201 if (fs_name[0] && fs_name[1] == ':') |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
202 { |
14056
602afdb74dc3
mountlist: tweak previous commit
Eric Blake <eblake@redhat.com>
parents:
14055
diff
changeset
|
203 char drive[4]; |
602afdb74dc3
mountlist: tweak previous commit
Eric Blake <eblake@redhat.com>
parents:
14055
diff
changeset
|
204 sprintf (drive, "%c:\\", fs_name[0]); |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
205 switch (GetDriveType (drive)) |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
206 { |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
207 case DRIVE_REMOVABLE: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
208 case DRIVE_FIXED: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
209 case DRIVE_CDROM: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
210 case DRIVE_RAMDISK: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
211 return false; |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
212 } |
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 return true; |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
215 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
216 #endif |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
217 |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
218 #ifndef ME_REMOTE |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
219 /* A file system is "remote" if its Fs_name contains a ':' |
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
220 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//'). */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
221 # define ME_REMOTE(Fs_name, Fs_type) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
222 (strchr (Fs_name, ':') != NULL \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
223 || ((Fs_name)[0] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
224 && (Fs_name)[1] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
225 && (strcmp (Fs_type, "smbfs") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
226 || strcmp (Fs_type, "cifs") == 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 |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
229 #if MOUNTED_GETMNTINFO |
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 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
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 | |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
390 #if defined MOUNTED_GETMNTENT1 && defined __linux__ |
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 |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
431 #ifdef MOUNTED_LISTMNTENT |
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 |
6527 | 462 #ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ |
5 | 463 { |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
464 FILE *fp; |
5 | 465 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
466 #ifdef __linux__ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
467 /* 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
|
468 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
|
469 (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
|
470 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
|
471 char const *mountinfo = "/proc/self/mountinfo"; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
472 fp = fopen (mountinfo, "r"); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
473 if (fp != NULL) |
5 | 474 { |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
475 char *line = NULL; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
476 size_t buf_size = 0; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
477 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
478 while (getline (&line, &buf_size, fp) != -1) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
479 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
480 unsigned int devmaj, devmin; |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
481 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
|
482 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
|
483 char test; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
484 char *dash; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
485 int rc; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
486 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
487 rc = sscanf(line, "%*u " /* id - discarded */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
488 "%*u " /* parent - discarded */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
489 "%u:%u " /* dev major:minor */ |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
490 "%n%*s%n " /* mountroot */ |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
491 "%n%*s%n" /* target, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
492 "%c", /* more data... */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
493 &devmaj, &devmin, |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
494 &mntroot_s, &mntroot_e, |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
495 &target_s, &target_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
496 &test); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
497 |
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
498 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
|
499 continue; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
500 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
501 /* skip optional fields, terminated by " - " */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
502 dash = strstr (line + target_e, " - "); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
503 if (! dash) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
504 continue; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
505 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
506 rc = sscanf(dash, " - " |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
507 "%n%*s%n " /* FS type, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
508 "%n%*s%n " /* source, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
509 "%c", /* more data... */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
510 &type_s, &type_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
511 &source_s, &source_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
512 &test); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
513 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
|
514 continue; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
515 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
516 /* 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
|
517 line[mntroot_e] = '\0'; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
518 line[target_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
519 dash[type_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
520 dash[source_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
521 unescape_tab (dash + source_s); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
522 unescape_tab (line + target_s); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
523 unescape_tab (line + mntroot_s); |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
524 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
525 me = xmalloc (sizeof *me); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
526 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
527 me->me_devname = xstrdup (dash + source_s); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
528 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
|
529 me->me_mntroot = xstrdup (line + mntroot_s); |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
530 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
|
531 me->me_type_malloced = 1; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
532 me->me_dev = makedev (devmaj, devmin); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
533 /* 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
|
534 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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
540 /* Add to the linked list. */ |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
541 *mtail = me; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
542 mtail = &me->me_next; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
543 } |
5 | 544 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
545 free (line); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
546 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
547 if (ferror (fp)) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
548 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
549 int saved_errno = errno; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
550 fclose (fp); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
551 errno = saved_errno; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
552 goto free_then_fail; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
553 } |
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 if (fclose (fp) == EOF) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
556 goto free_then_fail; |
5 | 557 } |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
558 else /* fallback to /proc/self/mounts (/etc/mtab). */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
559 #endif /* __linux __ */ |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
560 { |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
561 struct mntent *mnt; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
562 char const *table = MOUNTED; |
5 | 563 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
564 fp = setmntent (table, "r"); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
565 if (fp == NULL) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
566 return NULL; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
567 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
568 while ((mnt = getmntent (fp))) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
569 { |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
570 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
|
571 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
572 me = xmalloc (sizeof *me); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
573 me->me_devname = xstrdup (mnt->mnt_fsname); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
574 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
|
575 me->me_mntroot = NULL; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
576 me->me_type = xstrdup (mnt->mnt_type); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
577 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
|
578 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
|
579 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
|
580 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
|
581 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
582 /* Add to the linked list. */ |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
583 *mtail = me; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
584 mtail = &me->me_next; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
585 } |
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 if (endmntent (fp) == 0) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
588 goto free_then_fail; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
589 } |
5 | 590 } |
591 #endif /* MOUNTED_GETMNTENT1. */ | |
592 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
593 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ |
5 | 594 { |
595 struct statfs *fsp; | |
596 int entries; | |
597 | |
598 entries = getmntinfo (&fsp, MNT_NOWAIT); | |
599 if (entries < 0) | |
600 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
|
601 for (; entries-- > 0; fsp++) |
5 | 602 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
603 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
|
604 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
605 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
606 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
607 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
|
608 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
609 me->me_type = fs_type; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
610 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
611 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
|
612 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
|
613 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
5 | 614 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
615 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
616 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
617 mtail = &me->me_next; |
5 | 618 } |
619 } | |
620 #endif /* MOUNTED_GETMNTINFO */ | |
621 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
622 #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ |
7154
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
623 { |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
624 struct statvfs *fsp; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
625 int entries; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
626 |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
627 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
|
628 if (entries < 0) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
629 return NULL; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
630 for (; entries-- > 0; fsp++) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
631 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
632 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
633 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
634 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
|
635 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
636 me->me_type = xstrdup (fsp->f_fstypename); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
637 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
638 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
|
639 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
|
640 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
|
641 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
642 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
643 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
644 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
|
645 } |
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 #endif /* MOUNTED_GETMNTINFO2 */ |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
648 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
649 #ifdef MOUNTED_GETMNT /* Ultrix. */ |
5 | 650 { |
651 int offset = 0; | |
652 int val; | |
653 struct fs_data fsd; | |
654 | |
1413 | 655 while (errno = 0, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
656 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
|
657 (char *) 0))) |
5 | 658 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
659 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
660 me->me_devname = xstrdup (fsd.fd_req.devname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
661 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
|
662 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
663 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
|
664 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
665 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
|
666 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
|
667 me->me_dev = fsd.fd_req.dev; |
5 | 668 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
669 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
670 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
671 mtail = &me->me_next; |
5 | 672 } |
673 if (val < 0) | |
1413 | 674 goto free_then_fail; |
5 | 675 } |
676 #endif /* MOUNTED_GETMNT. */ | |
677 | |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
678 #if defined MOUNTED_FS_STAT_DEV /* BeOS */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
679 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
680 /* The next_dev() and fs_stat_dev() system calls give the list of |
5159 | 681 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
|
682 (fs type, total blocks, free blocks etc.), but without the mount |
5159 | 683 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
|
684 rootfs, directly under /. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
685 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
|
686 identical to the volume name of the device. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
687 We therefore get the list of subdirectories of /, and the list |
5159 | 688 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
|
689 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
690 DIR *dirp; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
691 struct rootdir_entry |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
692 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
693 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
694 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
695 ino_t ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
696 struct rootdir_entry *next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
697 }; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
698 struct rootdir_entry *rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
699 struct rootdir_entry **rootdir_tail; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
700 int32 pos; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
701 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
702 fs_info fi; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
703 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
704 /* 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
|
705 rootdir_list = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
706 rootdir_tail = &rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
707 dirp = opendir ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
708 if (dirp) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
709 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
710 struct dirent *d; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
711 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
712 while ((d = readdir (dirp)) != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
713 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
714 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
715 struct stat statbuf; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
716 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
717 if (strcmp (d->d_name, "..") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
718 continue; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
719 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
720 if (strcmp (d->d_name, ".") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
721 name = xstrdup ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
722 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
723 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
724 name = xmalloc (1 + strlen (d->d_name) + 1); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
725 name[0] = '/'; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
726 strcpy (name + 1, d->d_name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
727 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
728 |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
729 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
|
730 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
731 struct rootdir_entry *re = xmalloc (sizeof *re); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
732 re->name = name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
733 re->dev = statbuf.st_dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
734 re->ino = statbuf.st_ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
735 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
736 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
737 *rootdir_tail = re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
738 rootdir_tail = &re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
739 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
740 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
741 free (name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
742 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
743 closedir (dirp); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
744 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
745 *rootdir_tail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
746 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
747 for (pos = 0; (dev = next_dev (&pos)) >= 0; ) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
748 if (fs_stat_dev (dev, &fi) >= 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
749 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
750 /* Note: fi.dev == dev. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
751 struct rootdir_entry *re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
752 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
753 for (re = rootdir_list; re; re = re->next) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
754 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
|
755 break; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
756 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
757 me = xmalloc (sizeof *me); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
758 me->me_devname = xstrdup (fi.device_name[0] != '\0' |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
759 ? fi.device_name : fi.fsh_name); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
760 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
|
761 me->me_mntroot = NULL; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
762 me->me_type = xstrdup (fi.fsh_name); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
763 me->me_type_malloced = 1; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
764 me->me_dev = fi.dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
765 me->me_dummy = 0; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
766 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
|
767 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
768 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
769 *mtail = me; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
770 mtail = &me->me_next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
771 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
772 *mtail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
773 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
774 while (rootdir_list != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
775 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
776 struct rootdir_entry *re = rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
777 rootdir_list = re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
778 free (re->name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
779 free (re); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
780 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
781 } |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
782 #endif /* MOUNTED_FS_STAT_DEV */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
783 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
784 #if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ |
326 | 785 { |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
786 int numsys, counter; |
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
787 size_t bufsize; |
326 | 788 struct statfs *stats; |
789 | |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
790 numsys = getfsstat (NULL, 0L, MNT_NOWAIT); |
326 | 791 if (numsys < 0) |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
792 return NULL; |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
793 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
|
794 xalloc_die (); |
326 | 795 |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
796 bufsize = (1 + numsys) * sizeof *stats; |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
797 stats = xmalloc (bufsize); |
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
798 numsys = getfsstat (stats, bufsize, MNT_NOWAIT); |
326 | 799 |
800 if (numsys < 0) | |
801 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
802 free (stats); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
803 return NULL; |
326 | 804 } |
805 | |
806 for (counter = 0; counter < numsys; counter++) | |
807 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
808 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
809 me->me_devname = xstrdup (stats[counter].f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
810 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
|
811 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
812 me->me_type = xstrdup (FS_TYPE (stats[counter])); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
813 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
814 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
|
815 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
|
816 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 817 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
818 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
819 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
820 mtail = &me->me_next; |
326 | 821 } |
822 | |
823 free (stats); | |
824 } | |
825 #endif /* MOUNTED_GETFSSTAT */ | |
826 | |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
827 #if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23]. */ |
5 | 828 { |
829 struct mnttab mnt; | |
830 char *table = "/etc/mnttab"; | |
831 FILE *fp; | |
832 | |
833 fp = fopen (table, "r"); | |
834 if (fp == NULL) | |
835 return NULL; | |
836 | |
837 while (fread (&mnt, sizeof mnt, 1, fp) > 0) | |
838 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
839 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
840 # ifdef GETFSTYP /* SVR3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
841 me->me_devname = xstrdup (mnt.mt_dev); |
917 | 842 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
843 me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
844 strcpy (me->me_devname, "/dev/"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
845 strcpy (me->me_devname + 5, mnt.mt_dev); |
917 | 846 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
847 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
|
848 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
849 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
|
850 me->me_type = ""; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
851 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
852 # ifdef GETFSTYP /* SVR3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
853 if (need_fs_type) |
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 struct statfs fsd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
856 char typebuf[FSTYPSZ]; |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
857 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
858 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
|
859 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
860 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
861 me->me_type = xstrdup (typebuf); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
862 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
863 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
864 } |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
865 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
866 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
|
867 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
5 | 868 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
869 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
870 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
871 mtail = &me->me_next; |
1413 | 872 } |
873 | |
874 if (ferror (fp)) | |
875 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
876 /* The last fread() call must have failed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
877 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
878 fclose (fp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
879 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
880 goto free_then_fail; |
5 | 881 } |
882 | |
883 if (fclose (fp) == EOF) | |
1413 | 884 goto free_then_fail; |
5 | 885 } |
886 #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ | |
887 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
888 #ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ |
326 | 889 { |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
890 struct mntent **mnttbl = getmnttbl (), **ent; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
891 for (ent = mnttbl; *ent; ent++) |
326 | 892 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
893 me = xmalloc (sizeof *me); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
894 me->me_devname = xstrdup ((*ent)->mt_resource); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
895 me->me_mountdir = xstrdup ((*ent)->mt_directory); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
896 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
897 me->me_type = xstrdup ((*ent)->mt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
898 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
899 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
|
900 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
|
901 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 902 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
903 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
904 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
905 mtail = &me->me_next; |
326 | 906 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
907 endmnttbl (); |
326 | 908 } |
909 #endif | |
910 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
911 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */ |
5 | 912 { |
913 struct mnttab mnt; | |
914 char *table = MNTTAB; | |
915 FILE *fp; | |
916 int ret; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
917 int lockfd = -1; |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
918 |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
919 # 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
|
920 /* 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
|
921 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
|
922 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
|
923 (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
|
924 # ifndef MNTTAB_LOCK |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
925 # 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
|
926 # endif |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
927 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
|
928 if (0 <= lockfd) |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
929 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
930 struct flock flock; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
931 flock.l_type = F_RDLCK; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
932 flock.l_whence = SEEK_SET; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
933 flock.l_start = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
934 flock.l_len = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
935 while (fcntl (lockfd, F_SETLKW, &flock) == -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
936 if (errno != EINTR) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
937 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
938 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
939 close (lockfd); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
940 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
941 return NULL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
942 } |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
943 } |
1413 | 944 else if (errno != ENOENT) |
945 return NULL; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
946 # endif |
5 | 947 |
1413 | 948 errno = 0; |
5 | 949 fp = fopen (table, "r"); |
950 if (fp == NULL) | |
1413 | 951 ret = errno; |
1401 | 952 else |
1400
8e5de8bcae9f
(read_filesystem_list) [MOUNTED_GETMNTENT2]:
Jim Meyering <jim@meyering.net>
parents:
1399
diff
changeset
|
953 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
954 while ((ret = getmntent (fp, &mnt)) == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
955 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
956 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
957 me->me_devname = xstrdup (mnt.mnt_special); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
958 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
|
959 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
960 me->me_type = xstrdup (mnt.mnt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
961 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
962 me->me_dummy = MNT_IGNORE (&mnt) != 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
963 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
|
964 me->me_dev = dev_from_mount_options (mnt.mnt_mntopts); |
1401 | 965 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
966 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
967 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
968 mtail = &me->me_next; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
969 } |
1401 | 970 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
971 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; |
1400
8e5de8bcae9f
(read_filesystem_list) [MOUNTED_GETMNTENT2]:
Jim Meyering <jim@meyering.net>
parents:
1399
diff
changeset
|
972 } |
5 | 973 |
1401 | 974 if (0 <= lockfd && close (lockfd) != 0) |
1413 | 975 ret = errno; |
5 | 976 |
1413 | 977 if (0 <= ret) |
978 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
979 errno = ret; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
980 goto free_then_fail; |
1413 | 981 } |
5 | 982 } |
983 #endif /* MOUNTED_GETMNTENT2. */ | |
984 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
985 #ifdef MOUNTED_VMOUNT /* AIX. */ |
5 | 986 { |
987 int bufsize; | |
18009
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
988 void *entries; |
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
989 char *thisent; |
2570
70878b295de9
move vmp decl back out to the scope where it belongs
Jim Meyering <jim@meyering.net>
parents:
2553
diff
changeset
|
990 struct vmount *vmp; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
991 int n_entries; |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
992 int i; |
5 | 993 |
5159 | 994 /* 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
|
995 entries = &bufsize; |
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
996 if (mntctl (MCTL_QUERY, sizeof bufsize, entries) != 0) |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
997 return NULL; |
5 | 998 entries = xmalloc (bufsize); |
999 | |
5159 | 1000 /* 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
|
1001 n_entries = mntctl (MCTL_QUERY, bufsize, entries); |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1002 if (n_entries < 0) |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1003 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1004 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1005 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1006 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1007 return NULL; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1008 } |
5 | 1009 |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1010 for (i = 0, thisent = entries; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1011 i < n_entries; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1012 i++, thisent += vmp->vmt_length) |
5 | 1013 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1014 char *options, *ignore; |
2550
3ce1a171e216
(read_filesystem_list) [MOUNTED_VMOUNT]: Ignore mounts
Jim Meyering <jim@meyering.net>
parents:
2453
diff
changeset
|
1015 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1016 vmp = (struct vmount *) thisent; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1017 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1018 if (vmp->vmt_flags & MNT_REMOTE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1019 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1020 char *host, *dir; |
5 | 1021 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1022 me->me_remote = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1023 /* Prepend the remote dirname. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1024 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
|
1025 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
|
1026 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
|
1027 strcpy (me->me_devname, host); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1028 strcat (me->me_devname, ":"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1029 strcat (me->me_devname, dir); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1030 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1031 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1032 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1033 me->me_remote = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1034 me->me_devname = xstrdup (thisent + |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1035 vmp->vmt_data[VMT_OBJECT].vmt_off); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1036 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1037 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
|
1038 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1039 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
|
1040 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1041 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
|
1042 ignore = strstr (options, "ignore"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1043 me->me_dummy = (ignore |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1044 && (ignore == options || ignore[-1] == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1045 && (ignore[sizeof "ignore" - 1] == ',' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1046 || ignore[sizeof "ignore" - 1] == '\0')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1047 me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ |
5 | 1048 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1049 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1050 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1051 mtail = &me->me_next; |
5 | 1052 } |
1053 free (entries); | |
1054 } | |
1055 #endif /* MOUNTED_VMOUNT. */ | |
1056 | |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1057 #ifdef MOUNTED_INTERIX_STATVFS |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1058 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1059 DIR *dirp = opendir ("/dev/fs"); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1060 char node[9 + NAME_MAX]; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1061 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1062 if (!dirp) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1063 goto free_then_fail; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1064 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1065 while (1) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1066 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1067 struct statvfs dev; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1068 struct dirent entry; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1069 struct dirent *result; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1070 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1071 if (readdir_r (dirp, &entry, &result) || result == NULL) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1072 break; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1073 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1074 strcpy (node, "/dev/fs/"); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1075 strcat (node, entry.d_name); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1076 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1077 if (statvfs (node, &dev) == 0) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1078 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1079 me = xmalloc (sizeof *me); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1080 me->me_devname = xstrdup (dev.f_mntfromname); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1081 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
|
1082 me->me_mntroot = NULL; |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1083 me->me_type = xstrdup (dev.f_fstypename); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1084 me->me_type_malloced = 1; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1085 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
|
1086 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
|
1087 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
|
1088 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1089 /* Add to the linked list. */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1090 *mtail = me; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1091 mtail = &me->me_next; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1092 } |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1093 } |
17502
94372321dd20
mountlist: fix resource leak with MOUNTED_INTERIX_STATVFS
Andrew Borodin <aborodin@vmail.ru>
parents:
17435
diff
changeset
|
1094 closedir (dirp); |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1095 } |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1096 #endif /* MOUNTED_INTERIX_STATVFS */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1097 |
1413 | 1098 *mtail = NULL; |
5 | 1099 return mount_list; |
1413 | 1100 |
1101 | |
18028
4b0e76619c7f
mountlist: avoid an unused-label warning on OS X
Jim Meyering <meyering@fb.com>
parents:
18009
diff
changeset
|
1102 free_then_fail: _GL_UNUSED_LABEL |
1413 | 1103 { |
1104 int saved_errno = errno; | |
1105 *mtail = NULL; | |
1436
5919c19d9a1a
(read_filesystem_list): Fix more memory leaks on failure.
Jim Meyering <jim@meyering.net>
parents:
1413
diff
changeset
|
1106 |
1413 | 1107 while (mount_list) |
1108 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1109 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
|
1110 free_mount_entry (mount_list); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1111 mount_list = me; |
1413 | 1112 } |
1113 | |
1114 errno = saved_errno; | |
1115 return NULL; | |
1116 } | |
5 | 1117 } |
17435
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1118 |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1119 /* 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
|
1120 |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1121 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
|
1122 { |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1123 free (me->me_devname); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1124 free (me->me_mountdir); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
1125 free (me->me_mntroot); |
17435
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1126 if (me->me_type_malloced) |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1127 free (me->me_type); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1128 free (me); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1129 } |