Mercurial > gnulib
annotate lib/mountlist.c @ 18255:93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Originally reported at: https://bugzilla.redhat.com/1309247
* lib/mountlist.c (ME_REMOTE): Return true if a file system is named
"-hosts" because it is used by autofs to mount remote file systems.
author | Kamil Dudka <kdudka@redhat.com> |
---|---|
date | Fri, 19 Feb 2016 10:41:49 +0100 |
parents | 976d848c1f8d |
children | d81946484cce |
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 ':' |
18255
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
220 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//') |
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
221 or Fs_name is equal to "-hosts" (used by autofs to mount remote fs). */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
222 # define ME_REMOTE(Fs_name, Fs_type) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
223 (strchr (Fs_name, ':') != NULL \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
224 || ((Fs_name)[0] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
225 && (Fs_name)[1] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
226 && (strcmp (Fs_type, "smbfs") == 0 \ |
18255
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
227 || strcmp (Fs_type, "cifs") == 0)) \ |
93e9ece52a3c
mountlist: recognize autofs-mounted remote file systems, too
Kamil Dudka <kdudka@redhat.com>
parents:
18244
diff
changeset
|
228 || (strcmp("-hosts", Fs_name) == 0)) |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
229 #endif |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
230 |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
231 #if MOUNTED_GETMNTINFO |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
232 |
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
|
233 # if ! HAVE_STRUCT_STATFS_F_FSTYPENAME |
5 | 234 static char * |
5159 | 235 fstype_to_string (short int t) |
5 | 236 { |
237 switch (t) | |
238 { | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
239 # ifdef MOUNT_PC |
5 | 240 case MOUNT_PC: |
241 return "pc"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
242 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
243 # ifdef MOUNT_MFS |
5 | 244 case MOUNT_MFS: |
245 return "mfs"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
246 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
247 # ifdef MOUNT_LO |
5 | 248 case MOUNT_LO: |
249 return "lo"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
250 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
251 # ifdef MOUNT_TFS |
5 | 252 case MOUNT_TFS: |
253 return "tfs"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
254 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
255 # ifdef MOUNT_TMP |
5 | 256 case MOUNT_TMP: |
257 return "tmp"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
258 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
259 # ifdef MOUNT_UFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
260 case MOUNT_UFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
261 return "ufs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
262 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
263 # ifdef MOUNT_NFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
264 case MOUNT_NFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
265 return "nfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
266 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
267 # ifdef MOUNT_MSDOS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
268 case MOUNT_MSDOS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
269 return "msdos" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
270 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
271 # ifdef MOUNT_LFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
272 case MOUNT_LFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
273 return "lfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
274 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
275 # ifdef MOUNT_LOFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
276 case MOUNT_LOFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
277 return "lofs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
278 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
279 # ifdef MOUNT_FDESC |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
280 case MOUNT_FDESC: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
281 return "fdesc" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
282 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
283 # ifdef MOUNT_PORTAL |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
284 case MOUNT_PORTAL: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
285 return "portal" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
286 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
287 # ifdef MOUNT_NULL |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
288 case MOUNT_NULL: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
289 return "null" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
290 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
291 # ifdef MOUNT_UMAP |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
292 case MOUNT_UMAP: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
293 return "umap" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
294 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
295 # ifdef MOUNT_KERNFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
296 case MOUNT_KERNFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
297 return "kernfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
298 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
299 # ifdef MOUNT_PROCFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
300 case MOUNT_PROCFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
301 return "procfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
302 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
303 # ifdef MOUNT_AFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
304 case MOUNT_AFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
305 return "afs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
306 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
307 # ifdef MOUNT_CD9660 |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
308 case MOUNT_CD9660: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
309 return "cd9660" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
310 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
311 # ifdef MOUNT_UNION |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
312 case MOUNT_UNION: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
313 return "union" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
314 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
315 # ifdef MOUNT_DEVFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
316 case MOUNT_DEVFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
317 return "devfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
318 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
319 # ifdef MOUNT_EXT2FS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
320 case MOUNT_EXT2FS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
321 return "ext2fs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
322 # endif |
5 | 323 default: |
324 return "?"; | |
325 } | |
326 } | |
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
|
327 # endif |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
328 |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
329 static char * |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
330 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
|
331 { |
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
|
332 # 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
|
333 return (char *) (fsp->f_fstypename); |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
334 # else |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
335 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
|
336 # endif |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
337 } |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
338 |
5 | 339 #endif /* MOUNTED_GETMNTINFO */ |
340 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
341 #ifdef MOUNTED_VMOUNT /* AIX. */ |
5 | 342 static char * |
1446 | 343 fstype_to_string (int t) |
5 | 344 { |
345 struct vfs_ent *e; | |
346 | |
347 e = getvfsbytype (t); | |
348 if (!e || !e->vfsent_name) | |
349 return "none"; | |
350 else | |
351 return e->vfsent_name; | |
352 } | |
353 #endif /* MOUNTED_VMOUNT */ | |
354 | |
6527 | 355 |
356 #if defined MOUNTED_GETMNTENT1 || defined MOUNTED_GETMNTENT2 | |
357 | |
358 /* Return the device number from MOUNT_OPTIONS, if possible. | |
359 Otherwise return (dev_t) -1. */ | |
360 static dev_t | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
361 dev_from_mount_options (char const *mount_options) |
6527 | 362 { |
363 /* GNU/Linux allows file system implementations to define their own | |
364 meaning for "dev=" mount options, so don't trust the meaning | |
365 here. */ | |
366 # ifndef __linux__ | |
367 | |
368 static char const dev_pattern[] = ",dev="; | |
369 char const *devopt = strstr (mount_options, dev_pattern); | |
370 | |
371 if (devopt) | |
372 { | |
373 char const *optval = devopt + sizeof dev_pattern - 1; | |
374 char *optvalend; | |
375 unsigned long int dev; | |
376 errno = 0; | |
377 dev = strtoul (optval, &optvalend, 16); | |
378 if (optval != optvalend | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
379 && (*optvalend == '\0' || *optvalend == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
380 && ! (dev == ULONG_MAX && errno == ERANGE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
381 && dev == (dev_t) dev) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
382 return dev; |
6527 | 383 } |
384 | |
385 # endif | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
386 (void) mount_options; |
6527 | 387 return -1; |
388 } | |
389 | |
390 #endif | |
391 | |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
392 #if defined MOUNTED_GETMNTENT1 && defined __linux__ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
393 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
394 /* Unescape the paths in mount tables. |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
395 STR is updated in place. */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
396 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
397 static void |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
398 unescape_tab (char *str) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
399 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
400 size_t i, j = 0; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
401 size_t len = strlen (str) + 1; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
402 for (i = 0; i < len; i++) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
403 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
404 if (str[i] == '\\' && (i + 4 < len) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
405 && str[i + 1] >= '0' && str[i + 1] <= '3' |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
406 && str[i + 2] >= '0' && str[i + 2] <= '7' |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
407 && str[i + 3] >= '0' && str[i + 3] <= '7') |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
408 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
409 str[j++] = (str[i + 1] - '0') * 64 + |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
410 (str[i + 2] - '0') * 8 + |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
411 (str[i + 3] - '0'); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
412 i += 3; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
413 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
414 else |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
415 str[j++] = str[i]; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
416 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
417 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
418 #endif |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
419 |
5159 | 420 /* Return a list of the currently mounted file systems, or NULL on error. |
5 | 421 Add each entry to the tail of the list so that they stay in order. |
5159 | 422 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
|
423 the returned list are valid. Otherwise, they might not be. */ |
5 | 424 |
425 struct mount_entry * | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
426 read_file_system_list (bool need_fs_type) |
5 | 427 { |
428 struct mount_entry *mount_list; | |
429 struct mount_entry *me; | |
1413 | 430 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
|
431 (void) need_fs_type; |
5 | 432 |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
433 #ifdef MOUNTED_LISTMNTENT |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
434 { |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
435 struct tabmntent *mntlist, *p; |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
436 struct mntent *mnt; |
876 | 437 |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
438 /* 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
|
439 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
|
440 remove. Specifically, automount create normal NFS mounts. |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
441 */ |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
442 |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
443 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
|
444 return NULL; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
445 for (p = mntlist; p; p = p->next) |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
446 { |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
447 mnt = p->ment; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
448 me = xmalloc (sizeof *me); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
449 me->me_devname = xstrdup (mnt->mnt_fsname); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
450 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
|
451 me->me_mntroot = NULL; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
452 me->me_type = xstrdup (mnt->mnt_type); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
453 me->me_type_malloced = 1; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
454 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
|
455 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
|
456 me->me_dev = -1; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
457 *mtail = me; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
458 mtail = &me->me_next; |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
459 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
460 freemntlist (mntlist); |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
461 } |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
462 #endif |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
463 |
6527 | 464 #ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ |
5 | 465 { |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
466 FILE *fp; |
5 | 467 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
468 #ifdef __linux__ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
469 /* 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
|
470 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
|
471 (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
|
472 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
|
473 char const *mountinfo = "/proc/self/mountinfo"; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
474 fp = fopen (mountinfo, "r"); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
475 if (fp != NULL) |
5 | 476 { |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
477 char *line = NULL; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
478 size_t buf_size = 0; |
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 while (getline (&line, &buf_size, fp) != -1) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
481 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
482 unsigned int devmaj, devmin; |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
483 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
|
484 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
|
485 char test; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
486 char *dash; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
487 int rc; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
488 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
489 rc = sscanf(line, "%*u " /* id - discarded */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
490 "%*u " /* parent - discarded */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
491 "%u:%u " /* dev major:minor */ |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
492 "%n%*s%n " /* mountroot */ |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
493 "%n%*s%n" /* target, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
494 "%c", /* more data... */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
495 &devmaj, &devmin, |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
496 &mntroot_s, &mntroot_e, |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
497 &target_s, &target_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
498 &test); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
499 |
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
500 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
|
501 continue; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
502 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
503 /* skip optional fields, terminated by " - " */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
504 dash = strstr (line + target_e, " - "); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
505 if (! dash) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
506 continue; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
507 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
508 rc = sscanf(dash, " - " |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
509 "%n%*s%n " /* FS type, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
510 "%n%*s%n " /* source, start and end */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
511 "%c", /* more data... */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
512 &type_s, &type_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
513 &source_s, &source_e, |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
514 &test); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
515 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
|
516 continue; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
517 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
518 /* 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
|
519 line[mntroot_e] = '\0'; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
520 line[target_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
521 dash[type_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
522 dash[source_e] = '\0'; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
523 unescape_tab (dash + source_s); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
524 unescape_tab (line + target_s); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
525 unescape_tab (line + mntroot_s); |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
526 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
527 me = xmalloc (sizeof *me); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
528 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
529 me->me_devname = xstrdup (dash + source_s); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
530 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
|
531 me->me_mntroot = xstrdup (line + mntroot_s); |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
532 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
|
533 me->me_type_malloced = 1; |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
534 me->me_dev = makedev (devmaj, devmin); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
535 /* 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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
542 /* Add to the linked list. */ |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
543 *mtail = me; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
544 mtail = &me->me_next; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
545 } |
5 | 546 |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
547 free (line); |
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 if (ferror (fp)) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
550 { |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
551 int saved_errno = errno; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
552 fclose (fp); |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
553 errno = saved_errno; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
554 goto free_then_fail; |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
555 } |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
556 |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
557 if (fclose (fp) == EOF) |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
558 goto free_then_fail; |
5 | 559 } |
17951
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
560 else /* fallback to /proc/self/mounts (/etc/mtab). */ |
2ae3c246cda5
mountlist: remove dependency on libmount
Pádraig Brady <P@draigBrady.com>
parents:
17937
diff
changeset
|
561 #endif /* __linux __ */ |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
562 { |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
563 struct mntent *mnt; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
564 char const *table = MOUNTED; |
5 | 565 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
566 fp = setmntent (table, "r"); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
567 if (fp == NULL) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
568 return NULL; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
569 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
570 while ((mnt = getmntent (fp))) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
571 { |
17784
f8a2b0c3de24
mountlist: don't use libmount to decide on dummy/remote
Pádraig Brady <P@draigBrady.com>
parents:
17756
diff
changeset
|
572 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
|
573 |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
574 me = xmalloc (sizeof *me); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
575 me->me_devname = xstrdup (mnt->mnt_fsname); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
576 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
|
577 me->me_mntroot = NULL; |
17756
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
578 me->me_type = xstrdup (mnt->mnt_type); |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
579 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
|
580 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
|
581 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
|
582 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
|
583 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
584 /* Add to the linked list. */ |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
585 *mtail = me; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
586 mtail = &me->me_next; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
587 } |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
588 |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
589 if (endmntent (fp) == 0) |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
590 goto free_then_fail; |
326ae329c003
mountlist: use /proc/self/mountinfo when available
Fridolin Pokorny <fpokorny@redhat.com>
parents:
17697
diff
changeset
|
591 } |
5 | 592 } |
593 #endif /* MOUNTED_GETMNTENT1. */ | |
594 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
595 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ |
5 | 596 { |
597 struct statfs *fsp; | |
598 int entries; | |
599 | |
600 entries = getmntinfo (&fsp, MNT_NOWAIT); | |
601 if (entries < 0) | |
602 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
|
603 for (; entries-- > 0; fsp++) |
5 | 604 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
605 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
|
606 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
607 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
608 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
609 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
|
610 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
611 me->me_type = fs_type; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
612 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
613 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
|
614 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
|
615 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
5 | 616 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
617 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
618 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
619 mtail = &me->me_next; |
5 | 620 } |
621 } | |
622 #endif /* MOUNTED_GETMNTINFO */ | |
623 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
624 #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
|
625 { |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
626 struct statvfs *fsp; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
627 int entries; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
628 |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
629 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
|
630 if (entries < 0) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
631 return NULL; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
632 for (; entries-- > 0; fsp++) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
633 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
634 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
635 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
636 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
|
637 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
638 me->me_type = xstrdup (fsp->f_fstypename); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
639 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
644 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
645 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
646 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
|
647 } |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
648 } |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
649 #endif /* MOUNTED_GETMNTINFO2 */ |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
650 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
651 #ifdef MOUNTED_GETMNT /* Ultrix. */ |
5 | 652 { |
653 int offset = 0; | |
654 int val; | |
655 struct fs_data fsd; | |
656 | |
1413 | 657 while (errno = 0, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
658 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
|
659 (char *) 0))) |
5 | 660 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
661 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
662 me->me_devname = xstrdup (fsd.fd_req.devname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
663 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
|
664 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
665 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
|
666 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
667 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
|
668 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
|
669 me->me_dev = fsd.fd_req.dev; |
5 | 670 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
671 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
672 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
673 mtail = &me->me_next; |
5 | 674 } |
675 if (val < 0) | |
1413 | 676 goto free_then_fail; |
5 | 677 } |
678 #endif /* MOUNTED_GETMNT. */ | |
679 | |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
680 #if defined MOUNTED_FS_STAT_DEV /* BeOS */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
681 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
682 /* The next_dev() and fs_stat_dev() system calls give the list of |
5159 | 683 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
|
684 (fs type, total blocks, free blocks etc.), but without the mount |
5159 | 685 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
|
686 rootfs, directly under /. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
687 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
|
688 identical to the volume name of the device. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
689 We therefore get the list of subdirectories of /, and the list |
5159 | 690 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
|
691 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
692 DIR *dirp; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
693 struct rootdir_entry |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
694 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
695 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
696 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
697 ino_t ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
698 struct rootdir_entry *next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
699 }; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
700 struct rootdir_entry *rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
701 struct rootdir_entry **rootdir_tail; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
702 int32 pos; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
703 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
704 fs_info fi; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
705 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
706 /* 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
|
707 rootdir_list = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
708 rootdir_tail = &rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
709 dirp = opendir ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
710 if (dirp) |
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 struct dirent *d; |
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 while ((d = readdir (dirp)) != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
715 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
716 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
717 struct stat statbuf; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
718 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
719 if (strcmp (d->d_name, "..") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
720 continue; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
721 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
722 if (strcmp (d->d_name, ".") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
723 name = xstrdup ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
724 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
725 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
726 name = xmalloc (1 + strlen (d->d_name) + 1); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
727 name[0] = '/'; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
728 strcpy (name + 1, d->d_name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
729 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
730 |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
731 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
|
732 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
733 struct rootdir_entry *re = xmalloc (sizeof *re); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
734 re->name = name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
735 re->dev = statbuf.st_dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
736 re->ino = statbuf.st_ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
737 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
738 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
739 *rootdir_tail = re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
740 rootdir_tail = &re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
741 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
742 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
743 free (name); |
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 closedir (dirp); |
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 *rootdir_tail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
748 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
749 for (pos = 0; (dev = next_dev (&pos)) >= 0; ) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
750 if (fs_stat_dev (dev, &fi) >= 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
751 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
752 /* Note: fi.dev == dev. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
753 struct rootdir_entry *re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
754 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
755 for (re = rootdir_list; re; re = re->next) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
756 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
|
757 break; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
758 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
759 me = xmalloc (sizeof *me); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
760 me->me_devname = xstrdup (fi.device_name[0] != '\0' |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
761 ? fi.device_name : fi.fsh_name); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
762 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
|
763 me->me_mntroot = NULL; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
764 me->me_type = xstrdup (fi.fsh_name); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
765 me->me_type_malloced = 1; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
766 me->me_dev = fi.dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
767 me->me_dummy = 0; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
768 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
|
769 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
770 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
771 *mtail = me; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
772 mtail = &me->me_next; |
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 *mtail = 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 while (rootdir_list != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
777 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
778 struct rootdir_entry *re = rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
779 rootdir_list = re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
780 free (re->name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
781 free (re); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
782 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
783 } |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
784 #endif /* MOUNTED_FS_STAT_DEV */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
785 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
786 #if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ |
326 | 787 { |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
788 int numsys, counter; |
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
789 size_t bufsize; |
326 | 790 struct statfs *stats; |
791 | |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
792 numsys = getfsstat (NULL, 0L, MNT_NOWAIT); |
326 | 793 if (numsys < 0) |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
794 return NULL; |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
795 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
|
796 xalloc_die (); |
326 | 797 |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
798 bufsize = (1 + numsys) * sizeof *stats; |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
799 stats = xmalloc (bufsize); |
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
800 numsys = getfsstat (stats, bufsize, MNT_NOWAIT); |
326 | 801 |
802 if (numsys < 0) | |
803 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
804 free (stats); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
805 return NULL; |
326 | 806 } |
807 | |
808 for (counter = 0; counter < numsys; counter++) | |
809 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
810 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
811 me->me_devname = xstrdup (stats[counter].f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
812 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
|
813 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
814 me->me_type = xstrdup (FS_TYPE (stats[counter])); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
815 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
816 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
|
817 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
|
818 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 819 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
820 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
821 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
822 mtail = &me->me_next; |
326 | 823 } |
824 | |
825 free (stats); | |
826 } | |
827 #endif /* MOUNTED_GETFSSTAT */ | |
828 | |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
829 #if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23]. */ |
5 | 830 { |
831 struct mnttab mnt; | |
832 char *table = "/etc/mnttab"; | |
833 FILE *fp; | |
834 | |
835 fp = fopen (table, "r"); | |
836 if (fp == NULL) | |
837 return NULL; | |
838 | |
839 while (fread (&mnt, sizeof mnt, 1, fp) > 0) | |
840 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
841 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
842 # ifdef GETFSTYP /* SVR3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
843 me->me_devname = xstrdup (mnt.mt_dev); |
917 | 844 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
845 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
|
846 strcpy (me->me_devname, "/dev/"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
847 strcpy (me->me_devname + 5, mnt.mt_dev); |
917 | 848 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
849 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
|
850 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
851 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
|
852 me->me_type = ""; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
853 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
854 # ifdef GETFSTYP /* SVR3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
855 if (need_fs_type) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
856 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
857 struct statfs fsd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
858 char typebuf[FSTYPSZ]; |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
859 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
860 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
|
861 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
862 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
863 me->me_type = xstrdup (typebuf); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
864 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
865 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
866 } |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
867 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
868 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
869 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
5 | 870 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
871 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
872 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
873 mtail = &me->me_next; |
1413 | 874 } |
875 | |
876 if (ferror (fp)) | |
877 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
878 /* The last fread() call must have failed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
879 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
880 fclose (fp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
881 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
882 goto free_then_fail; |
5 | 883 } |
884 | |
885 if (fclose (fp) == EOF) | |
1413 | 886 goto free_then_fail; |
5 | 887 } |
888 #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ | |
889 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
890 #ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ |
326 | 891 { |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
892 struct mntent **mnttbl = getmnttbl (), **ent; |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
893 for (ent = mnttbl; *ent; ent++) |
326 | 894 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
895 me = xmalloc (sizeof *me); |
14192
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
896 me->me_devname = xstrdup ((*ent)->mt_resource); |
68883c50dbf9
mountlist: clean up code formatting
Jim Meyering <meyering@redhat.com>
parents:
14191
diff
changeset
|
897 me->me_mountdir = xstrdup ((*ent)->mt_directory); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
898 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
899 me->me_type = xstrdup ((*ent)->mt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
900 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
901 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
902 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
903 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 904 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
905 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
906 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
907 mtail = &me->me_next; |
326 | 908 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
909 endmnttbl (); |
326 | 910 } |
911 #endif | |
912 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
913 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */ |
5 | 914 { |
915 struct mnttab mnt; | |
916 char *table = MNTTAB; | |
917 FILE *fp; | |
918 int ret; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
919 int lockfd = -1; |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
920 |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
921 # 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
|
922 /* 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
|
923 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
|
924 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
|
925 (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
|
926 # ifndef MNTTAB_LOCK |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
927 # 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
|
928 # endif |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
929 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
|
930 if (0 <= lockfd) |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
931 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
932 struct flock flock; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
933 flock.l_type = F_RDLCK; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
934 flock.l_whence = SEEK_SET; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
935 flock.l_start = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
936 flock.l_len = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
937 while (fcntl (lockfd, F_SETLKW, &flock) == -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
938 if (errno != EINTR) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
939 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
940 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
941 close (lockfd); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
942 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
943 return NULL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
944 } |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
945 } |
1413 | 946 else if (errno != ENOENT) |
947 return NULL; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
948 # endif |
5 | 949 |
1413 | 950 errno = 0; |
5 | 951 fp = fopen (table, "r"); |
952 if (fp == NULL) | |
1413 | 953 ret = errno; |
1401 | 954 else |
1400
8e5de8bcae9f
(read_filesystem_list) [MOUNTED_GETMNTENT2]:
Jim Meyering <jim@meyering.net>
parents:
1399
diff
changeset
|
955 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
956 while ((ret = getmntent (fp, &mnt)) == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
957 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
958 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
959 me->me_devname = xstrdup (mnt.mnt_special); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
960 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
|
961 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
962 me->me_type = xstrdup (mnt.mnt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
963 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
964 me->me_dummy = MNT_IGNORE (&mnt) != 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
965 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
|
966 me->me_dev = dev_from_mount_options (mnt.mnt_mntopts); |
1401 | 967 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
968 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
969 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
970 mtail = &me->me_next; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
971 } |
1401 | 972 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
973 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
|
974 } |
5 | 975 |
1401 | 976 if (0 <= lockfd && close (lockfd) != 0) |
1413 | 977 ret = errno; |
5 | 978 |
1413 | 979 if (0 <= ret) |
980 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
981 errno = ret; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
982 goto free_then_fail; |
1413 | 983 } |
5 | 984 } |
985 #endif /* MOUNTED_GETMNTENT2. */ | |
986 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
987 #ifdef MOUNTED_VMOUNT /* AIX. */ |
5 | 988 { |
989 int bufsize; | |
18009
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
990 void *entries; |
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
991 char *thisent; |
2570
70878b295de9
move vmp decl back out to the scope where it belongs
Jim Meyering <jim@meyering.net>
parents:
2553
diff
changeset
|
992 struct vmount *vmp; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
993 int n_entries; |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
994 int i; |
5 | 995 |
5159 | 996 /* 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
|
997 entries = &bufsize; |
9d5c839f66b6
acl-permissions: more porting to AIX
Paul Eggert <eggert@cs.ucla.edu>
parents:
17951
diff
changeset
|
998 if (mntctl (MCTL_QUERY, sizeof bufsize, entries) != 0) |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
999 return NULL; |
5 | 1000 entries = xmalloc (bufsize); |
1001 | |
5159 | 1002 /* 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
|
1003 n_entries = mntctl (MCTL_QUERY, bufsize, entries); |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1004 if (n_entries < 0) |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1005 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1006 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1007 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1008 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1009 return NULL; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1010 } |
5 | 1011 |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
1012 for (i = 0, thisent = entries; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1013 i < n_entries; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1014 i++, thisent += vmp->vmt_length) |
5 | 1015 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1016 char *options, *ignore; |
2550
3ce1a171e216
(read_filesystem_list) [MOUNTED_VMOUNT]: Ignore mounts
Jim Meyering <jim@meyering.net>
parents:
2453
diff
changeset
|
1017 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1018 vmp = (struct vmount *) thisent; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1019 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1020 if (vmp->vmt_flags & MNT_REMOTE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1021 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1022 char *host, *dir; |
5 | 1023 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1024 me->me_remote = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1025 /* Prepend the remote dirname. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1026 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
|
1027 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
|
1028 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
|
1029 strcpy (me->me_devname, host); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1030 strcat (me->me_devname, ":"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1031 strcat (me->me_devname, dir); |
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 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1034 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1035 me->me_remote = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1036 me->me_devname = xstrdup (thisent + |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1037 vmp->vmt_data[VMT_OBJECT].vmt_off); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1038 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1039 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
|
1040 me->me_mntroot = NULL; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1041 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
|
1042 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1043 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
|
1044 ignore = strstr (options, "ignore"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1045 me->me_dummy = (ignore |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1046 && (ignore == options || ignore[-1] == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1047 && (ignore[sizeof "ignore" - 1] == ',' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1048 || ignore[sizeof "ignore" - 1] == '\0')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1049 me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ |
5 | 1050 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1051 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1052 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1053 mtail = &me->me_next; |
5 | 1054 } |
1055 free (entries); | |
1056 } | |
1057 #endif /* MOUNTED_VMOUNT. */ | |
1058 | |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1059 #ifdef MOUNTED_INTERIX_STATVFS |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1060 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1061 DIR *dirp = opendir ("/dev/fs"); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1062 char node[9 + NAME_MAX]; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1063 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1064 if (!dirp) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1065 goto free_then_fail; |
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 while (1) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1068 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1069 struct statvfs dev; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1070 struct dirent entry; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1071 struct dirent *result; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1072 |
18244
976d848c1f8d
readdir_r: now obsolescent
Paul Eggert <eggert@cs.ucla.edu>
parents:
18189
diff
changeset
|
1073 /* FIXME: readdir_r is planned to be withdrawn from POSIX and |
976d848c1f8d
readdir_r: now obsolescent
Paul Eggert <eggert@cs.ucla.edu>
parents:
18189
diff
changeset
|
1074 marked obsolescent in glibc. Use readdir instead. */ |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1075 if (readdir_r (dirp, &entry, &result) || result == NULL) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1076 break; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1077 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1078 strcpy (node, "/dev/fs/"); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1079 strcat (node, entry.d_name); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1080 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1081 if (statvfs (node, &dev) == 0) |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1082 { |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1083 me = xmalloc (sizeof *me); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1084 me->me_devname = xstrdup (dev.f_mntfromname); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1085 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
|
1086 me->me_mntroot = NULL; |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1087 me->me_type = xstrdup (dev.f_fstypename); |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1088 me->me_type_malloced = 1; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1089 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
|
1090 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
|
1091 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
|
1092 |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1093 /* Add to the linked list. */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1094 *mtail = me; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1095 mtail = &me->me_next; |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1096 } |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1097 } |
17502
94372321dd20
mountlist: fix resource leak with MOUNTED_INTERIX_STATVFS
Andrew Borodin <aborodin@vmail.ru>
parents:
17435
diff
changeset
|
1098 closedir (dirp); |
14191
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1099 } |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1100 #endif /* MOUNTED_INTERIX_STATVFS */ |
00edc8eebaa5
mountlist: add support for Interix
Markus Duft <mduft@gentoo.org>
parents:
14079
diff
changeset
|
1101 |
1413 | 1102 *mtail = NULL; |
5 | 1103 return mount_list; |
1413 | 1104 |
1105 | |
18028
4b0e76619c7f
mountlist: avoid an unused-label warning on OS X
Jim Meyering <meyering@fb.com>
parents:
18009
diff
changeset
|
1106 free_then_fail: _GL_UNUSED_LABEL |
1413 | 1107 { |
1108 int saved_errno = errno; | |
1109 *mtail = NULL; | |
1436
5919c19d9a1a
(read_filesystem_list): Fix more memory leaks on failure.
Jim Meyering <jim@meyering.net>
parents:
1413
diff
changeset
|
1110 |
1413 | 1111 while (mount_list) |
1112 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1113 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
|
1114 free_mount_entry (mount_list); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
1115 mount_list = me; |
1413 | 1116 } |
1117 | |
1118 errno = saved_errno; | |
1119 return NULL; | |
1120 } | |
5 | 1121 } |
17435
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 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
|
1124 |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1125 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
|
1126 { |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1127 free (me->me_devname); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1128 free (me->me_mountdir); |
18087
b20684a49361
mountlist: add me_mntroot field on Linux machines
Dave Chiluk <chiluk@canonical.com>
parents:
18028
diff
changeset
|
1129 free (me->me_mntroot); |
17435
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1130 if (me->me_type_malloced) |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1131 free (me->me_type); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1132 free (me); |
62bc285cb037
mountlist: add support for deallocating returned list entries
Pádraig Brady <P@draigBrady.com>
parents:
17332
diff
changeset
|
1133 } |