Mercurial > gnulib
annotate lib/mountlist.c @ 14056:602afdb74dc3
mountlist: tweak previous commit
* lib/mountlist.c (me_remote): Guarantee trailing backslash.
Reported by Paul Eggert.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Wed, 29 Dec 2010 15:53:15 -0700 |
parents | b968dd130aed |
children | 97fc9a21a8fb |
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 |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
3 Copyright (C) 1991-1992, 1997-2010 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> |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
61 # if !defined MOUNTED |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
62 # if defined _PATH_MOUNTED /* GNU libc */ |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
63 # define MOUNTED _PATH_MOUNTED |
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
64 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
65 # if defined MNT_MNTTAB /* HP-UX. */ |
917 | 66 # define MOUNTED MNT_MNTTAB |
5 | 67 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
68 # if defined MNTTABNAME /* Dynix. */ |
917 | 69 # define MOUNTED MNTTABNAME |
5 | 70 # endif |
917 | 71 # endif |
5 | 72 #endif |
73 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
74 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ |
917 | 75 # include <sys/mount.h> |
5 | 76 #endif |
77 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
78 #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
|
79 # include <sys/statvfs.h> |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
80 #endif |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
81 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
82 #ifdef MOUNTED_GETMNT /* Ultrix. */ |
917 | 83 # include <sys/mount.h> |
84 # include <sys/fs_types.h> | |
5 | 85 #endif |
86 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
87 #ifdef MOUNTED_FS_STAT_DEV /* BeOS. */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
88 # include <fs_info.h> |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
89 # include <dirent.h> |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
90 #endif |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
91 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
92 #ifdef MOUNTED_FREAD /* SVR2. */ |
917 | 93 # include <mnttab.h> |
5 | 94 #endif |
95 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
96 #ifdef MOUNTED_FREAD_FSTYP /* SVR3. */ |
917 | 97 # include <mnttab.h> |
98 # include <sys/fstyp.h> | |
99 # include <sys/statfs.h> | |
5 | 100 #endif |
101 | |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
102 #ifdef MOUNTED_LISTMNTENT |
917 | 103 # include <mntent.h> |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
104 #endif |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
105 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
106 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */ |
917 | 107 # include <sys/mnttab.h> |
5 | 108 #endif |
109 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
110 #ifdef MOUNTED_VMOUNT /* AIX. */ |
917 | 111 # include <fshelp.h> |
112 # include <sys/vfs.h> | |
5 | 113 #endif |
114 | |
326 | 115 #ifdef DOLPHIN |
116 /* So special that it's not worth putting this in autoconf. */ | |
917 | 117 # undef MOUNTED_FREAD_FSTYP |
118 # define MOUNTED_GETMNTTBL | |
326 | 119 #endif |
120 | |
1278
9ad625a30b7d
Use #if, not #ifdef with HAVE_ macros
Jim Meyering <jim@meyering.net>
parents:
1183
diff
changeset
|
121 #if HAVE_SYS_MNTENT_H |
918
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
122 /* 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
|
123 # include <sys/mntent.h> |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
124 #endif |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
125 |
3991
ab906cd2631e
2002-07-13 Bruno Haible <bruno@clisp.org>
Jim Meyering <jim@meyering.net>
parents:
3621
diff
changeset
|
126 #undef MNT_IGNORE |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
127 #if defined MNTOPT_IGNORE && defined HAVE_HASMNTOPT |
12845
ad16dedc2e1d
removing useless parentheses in cpp #define directives
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
128 # define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE) |
918
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
129 #else |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
130 # define MNT_IGNORE(M) 0 |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
131 #endif |
09fe18b51677
(read_filesystem_list): Show automount-related
Jim Meyering <jim@meyering.net>
parents:
917
diff
changeset
|
132 |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
133 #if USE_UNLOCKED_IO |
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
134 # include "unlocked-io.h" |
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
135 #endif |
3621
56f442359b0d
Include unlocked-io.h after all system headers.
Jim Meyering <jim@meyering.net>
parents:
3618
diff
changeset
|
136 |
7863 | 137 /* The results of open() in this file are not used with fchdir, |
138 therefore save some unnecessary work in fchdir.c. */ | |
139 #undef open | |
140 #undef close | |
141 | |
142 /* The results of opendir() in this file are not used with dirfd and fchdir, | |
143 therefore save some unnecessary work in fchdir.c. */ | |
144 #undef opendir | |
145 #undef closedir | |
146 | |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
147 #ifndef ME_DUMMY |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
148 # define ME_DUMMY(Fs_name, Fs_type) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
149 (strcmp (Fs_type, "autofs") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
150 || strcmp (Fs_type, "none") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
151 || strcmp (Fs_type, "proc") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
152 || strcmp (Fs_type, "subfs") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
153 /* for NetBSD 3.0 */ \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
154 || strcmp (Fs_type, "kernfs") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
155 /* for Irix 6.5 */ \ |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
156 || strcmp (Fs_type, "ignore") == 0) |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
157 #endif |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
158 |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
159 #ifdef __CYGWIN__ |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
160 # include <windows.h> |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
161 # define ME_REMOTE me_remote |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
162 /* All cygwin mount points include `:' or start with `//'; so it |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
163 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
|
164 static bool |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
165 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
|
166 { |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
167 if (fs_name[0] && fs_name[1] == ':') |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
168 { |
14056
602afdb74dc3
mountlist: tweak previous commit
Eric Blake <eblake@redhat.com>
parents:
14055
diff
changeset
|
169 char drive[4]; |
602afdb74dc3
mountlist: tweak previous commit
Eric Blake <eblake@redhat.com>
parents:
14055
diff
changeset
|
170 sprintf (drive, "%c:\\", fs_name[0]); |
14055
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
171 switch (GetDriveType (drive)) |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
172 { |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
173 case DRIVE_REMOVABLE: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
174 case DRIVE_FIXED: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
175 case DRIVE_CDROM: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
176 case DRIVE_RAMDISK: |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
177 return false; |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
178 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
179 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
180 return true; |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
181 } |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
182 #endif |
b968dd130aed
mountlist: fix local drive detection on cygwin
Eric Blake <eblake@redhat.com>
parents:
12845
diff
changeset
|
183 |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
184 #ifndef ME_REMOTE |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
185 /* A file system is `remote' if its Fs_name contains a `:' |
7099 | 186 or if (it is of type (smbfs or cifs) and its Fs_name starts with `//'). */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
187 # define ME_REMOTE(Fs_name, Fs_type) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
188 (strchr (Fs_name, ':') != NULL \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
189 || ((Fs_name)[0] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
190 && (Fs_name)[1] == '/' \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
191 && (strcmp (Fs_type, "smbfs") == 0 \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
192 || strcmp (Fs_type, "cifs") == 0))) |
5632
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
193 #endif |
f2a6ab91acad
* mountlist.h (MOUNTLIST_H_): New macro, to protect against double
Paul Eggert <eggert@cs.ucla.edu>
parents:
5318
diff
changeset
|
194 |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
195 #if MOUNTED_GETMNTINFO |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
196 |
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
|
197 # if ! HAVE_STRUCT_STATFS_F_FSTYPENAME |
5 | 198 static char * |
5159 | 199 fstype_to_string (short int t) |
5 | 200 { |
201 switch (t) | |
202 { | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
203 # ifdef MOUNT_PC |
5 | 204 case MOUNT_PC: |
205 return "pc"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
206 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
207 # ifdef MOUNT_MFS |
5 | 208 case MOUNT_MFS: |
209 return "mfs"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
210 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
211 # ifdef MOUNT_LO |
5 | 212 case MOUNT_LO: |
213 return "lo"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
214 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
215 # ifdef MOUNT_TFS |
5 | 216 case MOUNT_TFS: |
217 return "tfs"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
218 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
219 # ifdef MOUNT_TMP |
5 | 220 case MOUNT_TMP: |
221 return "tmp"; | |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
222 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
223 # ifdef MOUNT_UFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
224 case MOUNT_UFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
225 return "ufs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
226 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
227 # ifdef MOUNT_NFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
228 case MOUNT_NFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
229 return "nfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
230 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
231 # ifdef MOUNT_MSDOS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
232 case MOUNT_MSDOS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
233 return "msdos" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
234 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
235 # ifdef MOUNT_LFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
236 case MOUNT_LFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
237 return "lfs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
238 # endif |
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
239 # ifdef MOUNT_LOFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
240 case MOUNT_LOFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
241 return "lofs" ; |
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_FDESC |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
244 case MOUNT_FDESC: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
245 return "fdesc" ; |
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_PORTAL |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
248 case MOUNT_PORTAL: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
249 return "portal" ; |
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_NULL |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
252 case MOUNT_NULL: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
253 return "null" ; |
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_UMAP |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
256 case MOUNT_UMAP: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
257 return "umap" ; |
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_KERNFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
260 case MOUNT_KERNFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
261 return "kernfs" ; |
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_PROCFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
264 case MOUNT_PROCFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
265 return "procfs" ; |
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_AFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
268 case MOUNT_AFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
269 return "afs" ; |
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_CD9660 |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
272 case MOUNT_CD9660: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
273 return "cd9660" ; |
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_UNION |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
276 case MOUNT_UNION: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
277 return "union" ; |
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_DEVFS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
280 case MOUNT_DEVFS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
281 return "devfs" ; |
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_EXT2FS |
736
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
284 case MOUNT_EXT2FS: |
bf298c166b8d
(fstype_to_string): Handle fstypes of freebsd.
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
285 return "ext2fs" ; |
1396
f3912c1d7674
(fstype_to_string): Guard with #if ! HAVE_F_FSTYPENAME_IN_STATFS.
Jim Meyering <jim@meyering.net>
parents:
1389
diff
changeset
|
286 # endif |
5 | 287 default: |
288 return "?"; | |
289 } | |
290 } | |
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
|
291 # endif |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
292 |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
293 static char * |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
294 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
|
295 { |
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
|
296 # 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
|
297 return (char *) (fsp->f_fstypename); |
1389
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
298 # else |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
299 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
|
300 # endif |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
301 } |
e947a465b033
(fsp_to_string): Clean out some crufty #ifdefs
Jim Meyering <jim@meyering.net>
parents:
1278
diff
changeset
|
302 |
5 | 303 #endif /* MOUNTED_GETMNTINFO */ |
304 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
305 #ifdef MOUNTED_VMOUNT /* AIX. */ |
5 | 306 static char * |
1446 | 307 fstype_to_string (int t) |
5 | 308 { |
309 struct vfs_ent *e; | |
310 | |
311 e = getvfsbytype (t); | |
312 if (!e || !e->vfsent_name) | |
313 return "none"; | |
314 else | |
315 return e->vfsent_name; | |
316 } | |
317 #endif /* MOUNTED_VMOUNT */ | |
318 | |
6527 | 319 |
320 #if defined MOUNTED_GETMNTENT1 || defined MOUNTED_GETMNTENT2 | |
321 | |
322 /* Return the device number from MOUNT_OPTIONS, if possible. | |
323 Otherwise return (dev_t) -1. */ | |
324 static dev_t | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
325 dev_from_mount_options (char const *mount_options) |
6527 | 326 { |
327 /* GNU/Linux allows file system implementations to define their own | |
328 meaning for "dev=" mount options, so don't trust the meaning | |
329 here. */ | |
330 # ifndef __linux__ | |
331 | |
332 static char const dev_pattern[] = ",dev="; | |
333 char const *devopt = strstr (mount_options, dev_pattern); | |
334 | |
335 if (devopt) | |
336 { | |
337 char const *optval = devopt + sizeof dev_pattern - 1; | |
338 char *optvalend; | |
339 unsigned long int dev; | |
340 errno = 0; | |
341 dev = strtoul (optval, &optvalend, 16); | |
342 if (optval != optvalend | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
343 && (*optvalend == '\0' || *optvalend == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
344 && ! (dev == ULONG_MAX && errno == ERANGE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
345 && dev == (dev_t) dev) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
346 return dev; |
6527 | 347 } |
348 | |
349 # endif | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
350 (void) mount_options; |
6527 | 351 return -1; |
352 } | |
353 | |
354 #endif | |
355 | |
5159 | 356 /* Return a list of the currently mounted file systems, or NULL on error. |
5 | 357 Add each entry to the tail of the list so that they stay in order. |
5159 | 358 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
|
359 the returned list are valid. Otherwise, they might not be. */ |
5 | 360 |
361 struct mount_entry * | |
11112
e7df8edd0e88
still avoid unused-parameter warnings, but do it cleanly
Jim Meyering <meyering@redhat.com>
parents:
11110
diff
changeset
|
362 read_file_system_list (bool need_fs_type) |
5 | 363 { |
364 struct mount_entry *mount_list; | |
365 struct mount_entry *me; | |
1413 | 366 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
|
367 (void) need_fs_type; |
5 | 368 |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
369 #ifdef MOUNTED_LISTMNTENT |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
370 { |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
371 struct tabmntent *mntlist, *p; |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
372 struct mntent *mnt; |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
373 struct mount_entry *me; |
876 | 374 |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
375 /* 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
|
376 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
|
377 remove. Specifically, automount create normal NFS mounts. |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
378 */ |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
379 |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
380 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
|
381 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
|
382 for (p = mntlist; p; p = p->next) { |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
383 mnt = p->ment; |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
384 me = xmalloc (sizeof *me); |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
385 me->me_devname = xstrdup (mnt->mnt_fsname); |
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
386 me->me_mountdir = xstrdup (mnt->mnt_dir); |
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
387 me->me_type = xstrdup (mnt->mnt_type); |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
388 me->me_type_malloced = 1; |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
389 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); |
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
390 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
391 me->me_dev = -1; |
1413 | 392 *mtail = me; |
393 mtail = &me->me_next; | |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
394 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
395 freemntlist (mntlist); |
619
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
396 } |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
397 #endif |
dbaeca6a1983
(read_filesystem_list) [MOUNTED_LISTMNTENT]: New function.
Jim Meyering <jim@meyering.net>
parents:
492
diff
changeset
|
398 |
6527 | 399 #ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ |
5 | 400 { |
401 struct mntent *mnt; | |
11110 | 402 char const *table = MOUNTED; |
5 | 403 FILE *fp; |
404 | |
405 fp = setmntent (table, "r"); | |
406 if (fp == NULL) | |
407 return NULL; | |
408 | |
409 while ((mnt = getmntent (fp))) | |
410 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
411 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
412 me->me_devname = xstrdup (mnt->mnt_fsname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
413 me->me_mountdir = xstrdup (mnt->mnt_dir); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
414 me->me_type = xstrdup (mnt->mnt_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
415 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
416 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
|
417 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
|
418 me->me_dev = dev_from_mount_options (mnt->mnt_opts); |
5 | 419 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
420 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
421 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
422 mtail = &me->me_next; |
5 | 423 } |
424 | |
425 if (endmntent (fp) == 0) | |
1413 | 426 goto free_then_fail; |
5 | 427 } |
428 #endif /* MOUNTED_GETMNTENT1. */ | |
429 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
430 #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ |
5 | 431 { |
432 struct statfs *fsp; | |
433 int entries; | |
434 | |
435 entries = getmntinfo (&fsp, MNT_NOWAIT); | |
436 if (entries < 0) | |
437 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
|
438 for (; entries-- > 0; fsp++) |
5 | 439 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
440 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
|
441 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
442 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
443 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
444 me->me_mountdir = xstrdup (fsp->f_mntonname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
445 me->me_type = fs_type; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
446 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
447 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
|
448 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
|
449 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
5 | 450 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
451 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
452 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
453 mtail = &me->me_next; |
5 | 454 } |
455 } | |
456 #endif /* MOUNTED_GETMNTINFO */ | |
457 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
458 #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
|
459 { |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
460 struct statvfs *fsp; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
461 int entries; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
462 |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
463 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
|
464 if (entries < 0) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
465 return NULL; |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
466 for (; entries-- > 0; fsp++) |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
467 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
468 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
469 me->me_devname = xstrdup (fsp->f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
470 me->me_mountdir = xstrdup (fsp->f_mntonname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
471 me->me_type = xstrdup (fsp->f_fstypename); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
472 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
473 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
|
474 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
|
475 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
|
476 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
477 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
478 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
479 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
|
480 } |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
481 } |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
482 #endif /* MOUNTED_GETMNTINFO2 */ |
7a3549db58ef
* lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7099
diff
changeset
|
483 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
484 #ifdef MOUNTED_GETMNT /* Ultrix. */ |
5 | 485 { |
486 int offset = 0; | |
487 int val; | |
488 struct fs_data fsd; | |
489 | |
1413 | 490 while (errno = 0, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
491 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
|
492 (char *) 0))) |
5 | 493 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
494 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
495 me->me_devname = xstrdup (fsd.fd_req.devname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
496 me->me_mountdir = xstrdup (fsd.fd_req.path); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
497 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
|
498 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
499 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
|
500 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
|
501 me->me_dev = fsd.fd_req.dev; |
5 | 502 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
503 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
504 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
505 mtail = &me->me_next; |
5 | 506 } |
507 if (val < 0) | |
1413 | 508 goto free_then_fail; |
5 | 509 } |
510 #endif /* MOUNTED_GETMNT. */ | |
511 | |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
512 #if defined MOUNTED_FS_STAT_DEV /* BeOS */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
513 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
514 /* The next_dev() and fs_stat_dev() system calls give the list of |
5159 | 515 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
|
516 (fs type, total blocks, free blocks etc.), but without the mount |
5159 | 517 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
|
518 rootfs, directly under /. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
519 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
|
520 identical to the volume name of the device. |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
521 We therefore get the list of subdirectories of /, and the list |
5159 | 522 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
|
523 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
524 DIR *dirp; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
525 struct rootdir_entry |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
526 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
527 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
528 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
529 ino_t ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
530 struct rootdir_entry *next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
531 }; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
532 struct rootdir_entry *rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
533 struct rootdir_entry **rootdir_tail; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
534 int32 pos; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
535 dev_t dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
536 fs_info fi; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
537 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
538 /* 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
|
539 rootdir_list = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
540 rootdir_tail = &rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
541 dirp = opendir ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
542 if (dirp) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
543 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
544 struct dirent *d; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
545 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
546 while ((d = readdir (dirp)) != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
547 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
548 char *name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
549 struct stat statbuf; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
550 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
551 if (strcmp (d->d_name, "..") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
552 continue; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
553 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
554 if (strcmp (d->d_name, ".") == 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
555 name = xstrdup ("/"); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
556 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
557 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
558 name = xmalloc (1 + strlen (d->d_name) + 1); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
559 name[0] = '/'; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
560 strcpy (name + 1, d->d_name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
561 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
562 |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
563 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
|
564 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
565 struct rootdir_entry *re = xmalloc (sizeof *re); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
566 re->name = name; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
567 re->dev = statbuf.st_dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
568 re->ino = statbuf.st_ino; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
569 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
570 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
571 *rootdir_tail = re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
572 rootdir_tail = &re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
573 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
574 else |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
575 free (name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
576 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
577 closedir (dirp); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
578 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
579 *rootdir_tail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
580 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
581 for (pos = 0; (dev = next_dev (&pos)) >= 0; ) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
582 if (fs_stat_dev (dev, &fi) >= 0) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
583 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
584 /* Note: fi.dev == dev. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
585 struct rootdir_entry *re; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
586 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
587 for (re = rootdir_list; re; re = re->next) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
588 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
|
589 break; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
590 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
591 me = xmalloc (sizeof *me); |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
592 me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
593 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
594 me->me_type = xstrdup (fi.fsh_name); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
595 me->me_type_malloced = 1; |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
596 me->me_dev = fi.dev; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
597 me->me_dummy = 0; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
598 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
|
599 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
600 /* Add to the linked list. */ |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
601 *mtail = me; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
602 mtail = &me->me_next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
603 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
604 *mtail = NULL; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
605 |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
606 while (rootdir_list != NULL) |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
607 { |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
608 struct rootdir_entry *re = rootdir_list; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
609 rootdir_list = re->next; |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
610 free (re->name); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
611 free (re); |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
612 } |
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
613 } |
2677
a15fc2b3bc82
Use MOUNTED_FS_STAT_DEV instead of MOUNTED_NEXT_DEV,
Jim Meyering <jim@meyering.net>
parents:
2667
diff
changeset
|
614 #endif /* MOUNTED_FS_STAT_DEV */ |
2453
f3784b04894c
(read_filesystem_list): Add BeOS support.
Jim Meyering <jim@meyering.net>
parents:
1887
diff
changeset
|
615 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
616 #if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ |
326 | 617 { |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
618 int numsys, counter; |
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
619 size_t bufsize; |
326 | 620 struct statfs *stats; |
621 | |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
622 numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT); |
326 | 623 if (numsys < 0) |
624 return (NULL); | |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
625 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
|
626 xalloc_die (); |
326 | 627 |
4839
72b30d7ed3c6
Catch size calculation overflow problem on Alphas running OSF/1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4716
diff
changeset
|
628 bufsize = (1 + numsys) * sizeof *stats; |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
629 stats = xmalloc (bufsize); |
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
630 numsys = getfsstat (stats, bufsize, MNT_NOWAIT); |
326 | 631 |
632 if (numsys < 0) | |
633 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
634 free (stats); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
635 return (NULL); |
326 | 636 } |
637 | |
638 for (counter = 0; counter < numsys; counter++) | |
639 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
640 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
641 me->me_devname = xstrdup (stats[counter].f_mntfromname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
642 me->me_mountdir = xstrdup (stats[counter].f_mntonname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
643 me->me_type = xstrdup (FS_TYPE (stats[counter])); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
644 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
645 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
|
646 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
|
647 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 648 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
649 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
650 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
651 mtail = &me->me_next; |
326 | 652 } |
653 | |
654 free (stats); | |
655 } | |
656 #endif /* MOUNTED_GETFSSTAT */ | |
657 | |
3502
ebfd8c693504
Remove useless parentheses in #if directives.
Jim Meyering <jim@meyering.net>
parents:
2677
diff
changeset
|
658 #if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23]. */ |
5 | 659 { |
660 struct mnttab mnt; | |
661 char *table = "/etc/mnttab"; | |
662 FILE *fp; | |
663 | |
664 fp = fopen (table, "r"); | |
665 if (fp == NULL) | |
666 return NULL; | |
667 | |
668 while (fread (&mnt, sizeof mnt, 1, fp) > 0) | |
669 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
670 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
671 # ifdef GETFSTYP /* SVR3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
672 me->me_devname = xstrdup (mnt.mt_dev); |
917 | 673 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
674 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
|
675 strcpy (me->me_devname, "/dev/"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
676 strcpy (me->me_devname + 5, mnt.mt_dev); |
917 | 677 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
678 me->me_mountdir = xstrdup (mnt.mt_filsys); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
679 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
|
680 me->me_type = ""; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
681 me->me_type_malloced = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
682 # ifdef GETFSTYP /* SVR3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
683 if (need_fs_type) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
684 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
685 struct statfs fsd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
686 char typebuf[FSTYPSZ]; |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
687 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
688 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
|
689 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
690 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
691 me->me_type = xstrdup (typebuf); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
692 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
693 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
694 } |
1453
d5f389e692e8
(read_filesystem_list): Remove all_fs
Jim Meyering <jim@meyering.net>
parents:
1446
diff
changeset
|
695 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
696 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
|
697 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); |
5 | 698 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
699 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
700 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
701 mtail = &me->me_next; |
1413 | 702 } |
703 | |
704 if (ferror (fp)) | |
705 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
706 /* The last fread() call must have failed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
707 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
708 fclose (fp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
709 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
710 goto free_then_fail; |
5 | 711 } |
712 | |
713 if (fclose (fp) == EOF) | |
1413 | 714 goto free_then_fail; |
5 | 715 } |
716 #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ | |
717 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
718 #ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ |
326 | 719 { |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
720 struct mntent **mnttbl = getmnttbl (), **ent; |
326 | 721 for (ent=mnttbl;*ent;ent++) |
722 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
723 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
724 me->me_devname = xstrdup ( (*ent)->mt_resource); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
725 me->me_mountdir = xstrdup ( (*ent)->mt_directory); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
726 me->me_type = xstrdup ((*ent)->mt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
727 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
728 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
|
729 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
|
730 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
326 | 731 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
732 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
733 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
734 mtail = &me->me_next; |
326 | 735 } |
4548
a61e996662a3
Merge mountlist changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4287
diff
changeset
|
736 endmnttbl (); |
326 | 737 } |
738 #endif | |
739 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
740 #ifdef MOUNTED_GETMNTENT2 /* SVR4. */ |
5 | 741 { |
742 struct mnttab mnt; | |
743 char *table = MNTTAB; | |
744 FILE *fp; | |
745 int ret; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
746 int lockfd = -1; |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
747 |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
748 # 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
|
749 /* 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
|
750 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
|
751 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
|
752 (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
|
753 # ifndef MNTTAB_LOCK |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
754 # 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
|
755 # endif |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
756 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
|
757 if (0 <= lockfd) |
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
758 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
759 struct flock flock; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
760 flock.l_type = F_RDLCK; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
761 flock.l_whence = SEEK_SET; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
762 flock.l_start = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
763 flock.l_len = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
764 while (fcntl (lockfd, F_SETLKW, &flock) == -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
765 if (errno != EINTR) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
766 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
767 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
768 close (lockfd); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
769 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
770 return NULL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
771 } |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
772 } |
1413 | 773 else if (errno != ENOENT) |
774 return NULL; | |
1399
edb0581923b9
(read_filesystem_list): If SVR4, lock /etc/.mnttab.lock if available,
Jim Meyering <jim@meyering.net>
parents:
1396
diff
changeset
|
775 # endif |
5 | 776 |
1413 | 777 errno = 0; |
5 | 778 fp = fopen (table, "r"); |
779 if (fp == NULL) | |
1413 | 780 ret = errno; |
1401 | 781 else |
1400
8e5de8bcae9f
(read_filesystem_list) [MOUNTED_GETMNTENT2]:
Jim Meyering <jim@meyering.net>
parents:
1399
diff
changeset
|
782 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
783 while ((ret = getmntent (fp, &mnt)) == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
784 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
785 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
786 me->me_devname = xstrdup (mnt.mnt_special); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
787 me->me_mountdir = xstrdup (mnt.mnt_mountp); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
788 me->me_type = xstrdup (mnt.mnt_fstype); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
789 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
790 me->me_dummy = MNT_IGNORE (&mnt) != 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
791 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
|
792 me->me_dev = dev_from_mount_options (mnt.mnt_mntopts); |
1401 | 793 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
794 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
795 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
796 mtail = &me->me_next; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
797 } |
1401 | 798 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
799 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
|
800 } |
5 | 801 |
1401 | 802 if (0 <= lockfd && close (lockfd) != 0) |
1413 | 803 ret = errno; |
5 | 804 |
1413 | 805 if (0 <= ret) |
806 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
807 errno = ret; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
808 goto free_then_fail; |
1413 | 809 } |
5 | 810 } |
811 #endif /* MOUNTED_GETMNTENT2. */ | |
812 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
813 #ifdef MOUNTED_VMOUNT /* AIX. */ |
5 | 814 { |
815 int bufsize; | |
816 char *entries, *thisent; | |
2570
70878b295de9
move vmp decl back out to the scope where it belongs
Jim Meyering <jim@meyering.net>
parents:
2553
diff
changeset
|
817 struct vmount *vmp; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
818 int n_entries; |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
819 int i; |
5 | 820 |
5159 | 821 /* Ask how many bytes to allocate for the mounted file system info. */ |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
822 if (mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize) != 0) |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
823 return NULL; |
5 | 824 entries = xmalloc (bufsize); |
825 | |
5159 | 826 /* Get the list of mounted file systems. */ |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
827 n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries); |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
828 if (n_entries < 0) |
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
829 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
830 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
831 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
832 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
833 return NULL; |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
834 } |
5 | 835 |
4287
0c926607b93d
Merge change from Coreutils.
Jim Meyering <jim@meyering.net>
parents:
3993
diff
changeset
|
836 for (i = 0, thisent = entries; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
837 i < n_entries; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
838 i++, thisent += vmp->vmt_length) |
5 | 839 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
840 char *options, *ignore; |
2550
3ce1a171e216
(read_filesystem_list) [MOUNTED_VMOUNT]: Ignore mounts
Jim Meyering <jim@meyering.net>
parents:
2453
diff
changeset
|
841 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
842 vmp = (struct vmount *) thisent; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
843 me = xmalloc (sizeof *me); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
844 if (vmp->vmt_flags & MNT_REMOTE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
845 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
846 char *host, *dir; |
5 | 847 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
848 me->me_remote = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
849 /* Prepend the remote dirname. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
850 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
|
851 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
|
852 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
|
853 strcpy (me->me_devname, host); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
854 strcat (me->me_devname, ":"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
855 strcat (me->me_devname, dir); |
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 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
858 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
859 me->me_remote = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
860 me->me_devname = xstrdup (thisent + |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
861 vmp->vmt_data[VMT_OBJECT].vmt_off); |
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_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
864 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
|
865 me->me_type_malloced = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
866 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
|
867 ignore = strstr (options, "ignore"); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
868 me->me_dummy = (ignore |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
869 && (ignore == options || ignore[-1] == ',') |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
870 && (ignore[sizeof "ignore" - 1] == ',' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
871 || ignore[sizeof "ignore" - 1] == '\0')); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
872 me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ |
5 | 873 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
874 /* Add to the linked list. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
875 *mtail = me; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
876 mtail = &me->me_next; |
5 | 877 } |
878 free (entries); | |
879 } | |
880 #endif /* MOUNTED_VMOUNT. */ | |
881 | |
1413 | 882 *mtail = NULL; |
5 | 883 return mount_list; |
1413 | 884 |
885 | |
886 free_then_fail: | |
887 { | |
888 int saved_errno = errno; | |
889 *mtail = NULL; | |
1436
5919c19d9a1a
(read_filesystem_list): Fix more memory leaks on failure.
Jim Meyering <jim@meyering.net>
parents:
1413
diff
changeset
|
890 |
1413 | 891 while (mount_list) |
892 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
893 me = mount_list->me_next; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
894 free (mount_list->me_devname); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
895 free (mount_list->me_mountdir); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
896 if (mount_list->me_type_malloced) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
897 free (mount_list->me_type); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
898 free (mount_list); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11395
diff
changeset
|
899 mount_list = me; |
1413 | 900 } |
901 | |
902 errno = saved_errno; | |
903 return NULL; | |
904 } | |
5 | 905 } |