mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Avoid stat/fstat in statvfs/fstatvfs (BZ #15132)
Delay the use of stat/fstat until stat data is required. When the kernel returns ST_VALID, stat data is not used by __internal_statvfs.
This commit is contained in:
committed by
Siddhesh Poyarekar
parent
0d3b7a190c
commit
26b0d2e1a1
@ -22,22 +22,20 @@
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
extern void __internal_statvfs (const char *name, struct statvfs *buf,
|
||||
struct statfs *fsbuf, struct stat64 *st);
|
||||
struct statfs *fsbuf, int fd);
|
||||
|
||||
|
||||
int
|
||||
statvfs (const char *file, struct statvfs *buf)
|
||||
{
|
||||
struct statfs fsbuf;
|
||||
struct stat64 st;
|
||||
|
||||
/* Get as much information as possible from the system. */
|
||||
if (__statfs (file, &fsbuf) < 0)
|
||||
return -1;
|
||||
|
||||
/* Convert the result. */
|
||||
__internal_statvfs (file, buf, &fsbuf,
|
||||
stat64 (file, &st) == -1 ? NULL : &st);
|
||||
__internal_statvfs (file, buf, &fsbuf, -1);
|
||||
|
||||
/* We signal success if the statfs call succeeded. */
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user