From a8c63f25b3a8d4b8c9e12b8f6db65c61596da602 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 20 Mar 2019 11:31:07 +0000 Subject: win32: improve filesystem detection and display Miscellaneous improvements: - Enable '-a' option to display all filesystems in df(1). - Detect the UDF CDROM filesystem and display it in 'stat -f'. - Let getmntent(3) handle CDROM and floppy devices, ignoring those that have no media. - Set number of inodes and filesystem flags to 0 in statfs(2). --- configs/mingw32_defconfig | 4 ++-- configs/mingw64_defconfig | 4 ++-- coreutils/stat.c | 3 +++ libbb/appletlib.c | 3 +++ win32/mntent.c | 9 ++++++--- win32/statfs.c | 11 +++++++---- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index d7a32e53f..a51805b84 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.31.0.git -# Thu Mar 7 14:31:51 2019 +# Wed Mar 20 11:37:19 2019 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -234,7 +234,7 @@ CONFIG_DD=y CONFIG_FEATURE_DD_IBS_OBS=y CONFIG_FEATURE_DD_STATUS=y CONFIG_DF=y -# CONFIG_FEATURE_DF_FANCY is not set +CONFIG_FEATURE_DF_FANCY=y CONFIG_DIRNAME=y CONFIG_DOS2UNIX=y CONFIG_UNIX2DOS=y diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 98317c358..b773fb1b1 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.31.0.git -# Thu Mar 7 14:31:51 2019 +# Wed Mar 20 11:37:19 2019 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -234,7 +234,7 @@ CONFIG_DD=y CONFIG_FEATURE_DD_IBS_OBS=y CONFIG_FEATURE_DD_STATUS=y CONFIG_DF=y -# CONFIG_FEATURE_DF_FANCY is not set +CONFIG_FEATURE_DF_FANCY=y CONFIG_DIRNAME=y CONFIG_DOS2UNIX=y CONFIG_UNIX2DOS=y diff --git a/coreutils/stat.c b/coreutils/stat.c index cf13af0b6..78b60603d 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -204,6 +204,9 @@ static const char *human_fstype(uint32_t f_type) { 0x012FF7B5, "sysv4" }, { 0x012FF7B6, "sysv2" }, { 0x012FF7B7, "coh" }, +#if ENABLE_PLATFORM_MINGW32 + { 0x15013346, "udf" }, +#endif { 0x00011954, "ufs" }, { 0x012FD16D, "xia" }, { 0x5346544e, "ntfs" }, diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 35aabe758..58e391fd9 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -1233,6 +1233,9 @@ int main(int argc UNUSED_PARAM, char **argv) # if ENABLE_FEATURE_EURO init_codepage(); # endif + /* Ignore critical errors, such as calling GetVolumeInformation() on + * a floppy or CDROM drive with no media. */ + SetErrorMode(SEM_FAILCRITICALERRORS); #endif #if defined(__MINGW64_VERSION_MAJOR) diff --git a/win32/mntent.c b/win32/mntent.c index f9a2d26d4..2a07476e3 100644 --- a/win32/mntent.c +++ b/win32/mntent.c @@ -32,6 +32,7 @@ struct mntent *getmntent(FILE *stream) { struct mntdata *data = (struct mntdata *)stream; struct mntent *entry; + UINT drive_type; data->me.mnt_fsname = data->mnt_fsname; data->me.mnt_dir = data->mnt_dir; @@ -48,15 +49,17 @@ struct mntent *getmntent(FILE *stream) data->mnt_fsname[2] = '\0'; data->mnt_dir[0] = 'A' + data->index; data->mnt_dir[1] = ':'; - data->mnt_dir[2] = '\\'; + data->mnt_dir[2] = '/'; data->mnt_dir[3] = '\0'; data->mnt_type[0] = '\0'; data->mnt_opts[0] = '\0'; - if ( GetDriveType(data->mnt_dir) == DRIVE_FIXED ) { + drive_type = GetDriveType(data->mnt_dir); + if ( drive_type == DRIVE_FIXED || drive_type == DRIVE_CDROM || + drive_type == DRIVE_REMOVABLE) { if ( !GetVolumeInformation(data->mnt_dir, NULL, 0, NULL, NULL, NULL, data->mnt_type, 100) ) { - data->mnt_type[0] = '\0'; + continue; } entry = &data->me; diff --git a/win32/statfs.c b/win32/statfs.c index d81a69380..22fc591ec 100644 --- a/win32/statfs.c +++ b/win32/statfs.c @@ -51,7 +51,7 @@ int statfs(const char *file, struct statfs *buf) /* * Valid filesystem names don't seem to be documented. The following - * are present in Wine. + * are present in Wine (dlls/kernel32/volume.c). */ if ( strcmp(fsname, "NTFS") == 0 ) { buf->f_type = 0x5346544e; @@ -62,6 +62,9 @@ int statfs(const char *file, struct statfs *buf) else if ( strcmp(fsname, "CDFS") == 0 ) { buf->f_type = 0x9660; } + else if ( strcmp(fsname, "UDF") == 0 ) { + buf->f_type = 0x15013346; + } else { buf->f_type = 0; } @@ -70,10 +73,10 @@ int statfs(const char *file, struct statfs *buf) buf->f_blocks = total_number_of_bytes / buf->f_bsize; buf->f_bfree = total_number_of_free_bytes / buf->f_bsize; buf->f_bavail = free_bytes_available / buf->f_bsize; - buf->f_files = UINT32_MAX; - buf->f_ffree = UINT32_MAX; + buf->f_files = 0; + buf->f_ffree = 0; buf->f_fsid = serial; - buf->f_flag = UINT64_MAX; + buf->f_flag = 0; buf->f_namelen = namelen; return 0; -- cgit v1.2.3-55-g6feb