diff options
-rw-r--r-- | libbb/find_mount_point.c | 2 | ||||
-rw-r--r-- | win32/statfs.c | 24 | ||||
-rw-r--r-- | win32/sys/statfs.h | 1 |
3 files changed, 13 insertions, 14 deletions
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c index b9bc1dd76..de314a3c7 100644 --- a/libbb/find_mount_point.c +++ b/libbb/find_mount_point.c | |||
@@ -27,7 +27,7 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) | |||
27 | #if ENABLE_PLATFORM_MINGW32 | 27 | #if ENABLE_PLATFORM_MINGW32 |
28 | static char mnt_fsname[4]; | 28 | static char mnt_fsname[4]; |
29 | static char mnt_dir[4]; | 29 | static char mnt_dir[4]; |
30 | struct mntent my_mount_entry = { mnt_fsname, mnt_dir, "", "", 0, 0 }; | 30 | static struct mntent my_mount_entry = { mnt_fsname, mnt_dir, "", "", 0, 0 }; |
31 | char *current, *path; | 31 | char *current, *path; |
32 | DWORD len; | 32 | DWORD len; |
33 | #endif | 33 | #endif |
diff --git a/win32/statfs.c b/win32/statfs.c index 9e6703849..a35c9adea 100644 --- a/win32/statfs.c +++ b/win32/statfs.c | |||
@@ -10,22 +10,24 @@ int statfs(const char *file, struct statfs *buf) | |||
10 | ULONGLONG total_number_of_bytes; | 10 | ULONGLONG total_number_of_bytes; |
11 | ULONGLONG total_number_of_free_bytes; /* for everyone - bfree */ | 11 | ULONGLONG total_number_of_free_bytes; /* for everyone - bfree */ |
12 | DWORD serial, namelen, flags; | 12 | DWORD serial, namelen, flags; |
13 | char drive[4], fsname[100]; | 13 | char fsname[100]; |
14 | struct mntent *mnt; | ||
14 | 15 | ||
16 | if ( (mnt=find_mount_point(file, 0)) == NULL ) { | ||
17 | return -1; | ||
18 | } | ||
19 | |||
20 | file = mnt->mnt_dir; | ||
15 | if ( !GetDiskFreeSpaceEx(file, (PULARGE_INTEGER) &free_bytes_available, | 21 | if ( !GetDiskFreeSpaceEx(file, (PULARGE_INTEGER) &free_bytes_available, |
16 | (PULARGE_INTEGER) &total_number_of_bytes, | 22 | (PULARGE_INTEGER) &total_number_of_bytes, |
17 | (PULARGE_INTEGER) &total_number_of_free_bytes) ) { | 23 | (PULARGE_INTEGER) &total_number_of_free_bytes) ) { |
24 | errno = err_win_to_posix(GetLastError()); | ||
18 | return -1; | 25 | return -1; |
19 | } | 26 | } |
20 | 27 | ||
21 | if ( strlen(file) == 2 && file[1] == ':' ) { | ||
22 | /* GetVolumeInformation wants a backslash */ | ||
23 | strcat(strcpy(drive, file), "\\"); | ||
24 | file = drive; | ||
25 | } | ||
26 | |||
27 | if ( !GetVolumeInformation(file, NULL, 0, &serial, &namelen, &flags, | 28 | if ( !GetVolumeInformation(file, NULL, 0, &serial, &namelen, &flags, |
28 | fsname, 100) ) { | 29 | fsname, 100) ) { |
30 | errno = err_win_to_posix(GetLastError()); | ||
29 | return -1; | 31 | return -1; |
30 | } | 32 | } |
31 | 33 | ||
@@ -64,16 +66,14 @@ int statfs(const char *file, struct statfs *buf) | |||
64 | buf->f_type = 0; | 66 | buf->f_type = 0; |
65 | } | 67 | } |
66 | 68 | ||
67 | /* As with stat, -1 indicates a field is not known. */ | ||
68 | buf->f_frsize = buf->f_bsize; | 69 | buf->f_frsize = buf->f_bsize; |
69 | buf->f_blocks = total_number_of_bytes / buf->f_bsize; | 70 | buf->f_blocks = total_number_of_bytes / buf->f_bsize; |
70 | buf->f_bfree = total_number_of_free_bytes / buf->f_bsize; | 71 | buf->f_bfree = total_number_of_free_bytes / buf->f_bsize; |
71 | buf->f_bavail = free_bytes_available / buf->f_bsize; | 72 | buf->f_bavail = free_bytes_available / buf->f_bsize; |
72 | buf->f_files = -1; | 73 | buf->f_files = UINT32_MAX; |
73 | buf->f_ffree = -1; | 74 | buf->f_ffree = UINT32_MAX; |
74 | buf->f_favail = -1; | ||
75 | buf->f_fsid = serial; | 75 | buf->f_fsid = serial; |
76 | buf->f_flag = -1; | 76 | buf->f_flag = UINT64_MAX; |
77 | buf->f_namelen = namelen; | 77 | buf->f_namelen = namelen; |
78 | 78 | ||
79 | return 0; | 79 | return 0; |
diff --git a/win32/sys/statfs.h b/win32/sys/statfs.h index 7cef6df73..498f41e50 100644 --- a/win32/sys/statfs.h +++ b/win32/sys/statfs.h | |||
@@ -12,7 +12,6 @@ struct statfs { | |||
12 | uint64_t f_bavail; | 12 | uint64_t f_bavail; |
13 | uint64_t f_files; | 13 | uint64_t f_files; |
14 | uint64_t f_ffree; | 14 | uint64_t f_ffree; |
15 | uint64_t f_favail; | ||
16 | uint64_t f_fsid; | 15 | uint64_t f_fsid; |
17 | uint64_t f_flag; | 16 | uint64_t f_flag; |
18 | uint64_t f_namelen; | 17 | uint64_t f_namelen; |