Skip to content

Commit e8f1225

Browse files
committed
Remove __ASSUME_STATFS_F_FLAGS.
Now that 3.2 is the minimum Linux kernel version for glibc, this patch removes __ASSUME_STATFS_F_FLAGS and associated conditional code. Tested for x86_64. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_STATFS_F_FLAGS): Remove macro. * sysdeps/unix/sysv/linux/internal_statvfs.c [!__ASSUME_STATFS_F_FLAGS]: Remove conditional code.
1 parent 7c3018f commit e8f1225

File tree

3 files changed

+8
-199
lines changed

3 files changed

+8
-199
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2017-05-12 Joseph Myers <[email protected]>
2+
3+
* sysdeps/unix/sysv/linux/kernel-features.h
4+
(__ASSUME_STATFS_F_FLAGS): Remove macro.
5+
* sysdeps/unix/sysv/linux/internal_statvfs.c
6+
[!__ASSUME_STATFS_F_FLAGS]: Remove conditional code.
7+
18
2017-05-11 Zack Weinberg <[email protected]>
29

310
* Makerules: New subdir configuration variables 'tests-internal'

sysdeps/unix/sysv/linux/internal_statvfs.c

Lines changed: 1 addition & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -39,190 +39,6 @@
3939
# define STATFS statfs
4040
# define STATVFS statvfs
4141
# define INTERNAL_STATVFS __internal_statvfs
42-
43-
44-
# ifndef __ASSUME_STATFS_F_FLAGS
45-
int
46-
__statvfs_getflags (const char *name, int fstype, int fd)
47-
{
48-
struct stat64 st;
49-
50-
if ((fd < 0 ? stat64 (name, &st) : fstat64 (fd, &st)) < 0)
51-
return 0;
52-
53-
const char *fsname = NULL;
54-
const char *fsname2 = NULL;
55-
const char *fsname3 = NULL;
56-
57-
/* Map the filesystem type we got from the statfs call to a string. */
58-
switch (fstype)
59-
{
60-
case EXT2_SUPER_MAGIC:
61-
fsname = "ext4";
62-
fsname2 = "ext3";
63-
fsname3 = "ext2";
64-
break;
65-
case DEVPTS_SUPER_MAGIC:
66-
fsname= "devpts";
67-
break;
68-
case SHMFS_SUPER_MAGIC:
69-
fsname = "tmpfs";
70-
break;
71-
case PROC_SUPER_MAGIC:
72-
fsname = "proc";
73-
break;
74-
case USBDEVFS_SUPER_MAGIC:
75-
fsname = "usbdevfs";
76-
break;
77-
case AUTOFS_SUPER_MAGIC:
78-
fsname = "autofs";
79-
break;
80-
case NFS_SUPER_MAGIC:
81-
fsname = "nfs";
82-
break;
83-
case SYSFS_MAGIC:
84-
fsname = "sysfs";
85-
break;
86-
case REISERFS_SUPER_MAGIC:
87-
fsname = "reiserfs";
88-
break;
89-
case XFS_SUPER_MAGIC:
90-
fsname = "xfs";
91-
break;
92-
case JFS_SUPER_MAGIC:
93-
fsname = "jfs";
94-
break;
95-
case HPFS_SUPER_MAGIC:
96-
fsname = "hpfs";
97-
break;
98-
case DEVFS_SUPER_MAGIC:
99-
fsname = "devfs";
100-
break;
101-
case ISOFS_SUPER_MAGIC:
102-
fsname = "iso9660";
103-
break;
104-
case MSDOS_SUPER_MAGIC:
105-
fsname = "msdos";
106-
break;
107-
case NTFS_SUPER_MAGIC:
108-
fsname = "ntfs";
109-
break;
110-
case LOGFS_MAGIC_U32:
111-
fsname = "logfs";
112-
break;
113-
case BTRFS_SUPER_MAGIC:
114-
fsname = "btrfs";
115-
break;
116-
case CGROUP_SUPER_MAGIC:
117-
fsname = "cgroup";
118-
break;
119-
case LUSTRE_SUPER_MAGIC:
120-
fsname = "lustre";
121-
break;
122-
case F2FS_SUPER_MAGIC:
123-
fsname = "f2fs";
124-
break;
125-
case EFIVARFS_MAGIC:
126-
fsname = "efivarfs";
127-
break;
128-
}
129-
130-
FILE *mtab = __setmntent ("/proc/mounts", "r");
131-
if (mtab == NULL)
132-
mtab = __setmntent (_PATH_MOUNTED, "r");
133-
134-
int result = 0;
135-
if (mtab != NULL)
136-
{
137-
bool success = false;
138-
struct mntent mntbuf;
139-
char tmpbuf[1024];
140-
141-
/* No locking needed. */
142-
(void) __fsetlocking (mtab, FSETLOCKING_BYCALLER);
143-
144-
again:
145-
while (__getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf)))
146-
{
147-
/* In a first round we look for a given mount point, if
148-
we have a name. */
149-
if (name != NULL && strcmp (name, mntbuf.mnt_dir) != 0)
150-
continue;
151-
/* We need to look at the entry only if the filesystem
152-
name matches. If we have a filesystem name. */
153-
else if (fsname != NULL
154-
&& strcmp (fsname, mntbuf.mnt_type) != 0
155-
&& (fsname2 == NULL
156-
|| strcmp (fsname2, mntbuf.mnt_type) != 0)
157-
&& (fsname3 == NULL
158-
|| strcmp (fsname3, mntbuf.mnt_type) != 0))
159-
continue;
160-
161-
/* Find out about the device the current entry is for. */
162-
struct stat64 fsst;
163-
if (stat64 (mntbuf.mnt_dir, &fsst) >= 0
164-
&& st.st_dev == fsst.st_dev)
165-
{
166-
/* Bingo, we found the entry for the device FD is on.
167-
Now interpret the option string. */
168-
char *cp = mntbuf.mnt_opts;
169-
char *opt;
170-
171-
while ((opt = __strsep (&cp, ",")) != NULL)
172-
if (strcmp (opt, "ro") == 0)
173-
result |= ST_RDONLY;
174-
else if (strcmp (opt, "nosuid") == 0)
175-
result |= ST_NOSUID;
176-
else if (strcmp (opt, "noexec") == 0)
177-
result |= ST_NOEXEC;
178-
else if (strcmp (opt, "nodev") == 0)
179-
result |= ST_NODEV;
180-
else if (strcmp (opt, "sync") == 0)
181-
result |= ST_SYNCHRONOUS;
182-
else if (strcmp (opt, "mand") == 0)
183-
result |= ST_MANDLOCK;
184-
else if (strcmp (opt, "noatime") == 0)
185-
result |= ST_NOATIME;
186-
else if (strcmp (opt, "nodiratime") == 0)
187-
result |= ST_NODIRATIME;
188-
else if (strcmp (opt, "relatime") == 0)
189-
result |= ST_RELATIME;
190-
191-
/* We can stop looking for more entries. */
192-
success = true;
193-
break;
194-
}
195-
}
196-
/* Maybe the kernel names for the filesystems changed or the
197-
statvfs call got a name which was not the mount point. Check
198-
again, this time without checking for name matches first. */
199-
if (! success && (name != NULL || fsname != NULL))
200-
{
201-
if (name != NULL)
202-
/* Try without a mount point name. */
203-
name = NULL;
204-
else
205-
{
206-
/* Try without a filesystem name. */
207-
assert (fsname != NULL);
208-
fsname = fsname2 = fsname3 = NULL;
209-
}
210-
211-
/* It is not strictly allowed to use rewind here. But
212-
this code is part of the implementation so it is
213-
acceptable. */
214-
rewind (mtab);
215-
216-
goto again;
217-
}
218-
219-
/* Close the file. */
220-
__endmntent (mtab);
221-
}
222-
223-
return result;
224-
}
225-
# endif
22642
#else
22743
extern int __statvfs_getflags (const char *name, int fstype, int fd);
22844
#endif
@@ -267,14 +83,5 @@ INTERNAL_STATVFS (const char *name, struct STATVFS *buf,
26783
/* XXX I have no idea how to compute f_favail. Any idea??? */
26884
buf->f_favail = buf->f_ffree;
26985

270-
#ifndef __ASSUME_STATFS_F_FLAGS
271-
if ((fsbuf->f_flags & ST_VALID) == 0)
272-
/* Determining the flags is tricky. We have to read /proc/mounts or
273-
the /etc/mtab file and search for the entry which matches the given
274-
file. The way we can test for matching filesystem is using the
275-
device number. */
276-
buf->f_flag = __statvfs_getflags (name, fsbuf->f_type, fd);
277-
else
278-
#endif
279-
buf->f_flag = fsbuf->f_flags ^ ST_VALID;
86+
buf->f_flag = fsbuf->f_flags ^ ST_VALID;
28087
}

sysdeps/unix/sysv/linux/kernel-features.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@
7878
#define __ASSUME_PREADV 1
7979
#define __ASSUME_PWRITEV 1
8080

81-
/* statfs fills in f_flags since 2.6.36. */
82-
#if __LINUX_KERNEL_VERSION >= 0x020624
83-
# define __ASSUME_STATFS_F_FLAGS 1
84-
#endif
85-
8681
/* Support for sendmmsg functionality was added in 3.0. */
8782
#define __ASSUME_SENDMMSG 1
8883

0 commit comments

Comments
 (0)