libext2fs: fix 32-bit Windows build
PATCH 1/1 libext2fs: fix 32-bit Windows build
From: Eric Biggers <[email protected]>
_WIN32 is the standard macro to detect Windows, regardless of 32-bit or 64-bit. _WIN64 is for 64-bit Windows only. Use _WIN32 where _WIN64 was incorrectly being used.
This fixes several 32-bit Windows build errors, for example this one:
plausible.c: In function ‘print_ext2_info’:
plausible.c:109:31: error: ‘unix_io_manager’ undeclared (first use in this function); did you mean ‘undo_io_manager’?
109 | unix_io_manager,
| ^~~~~~~~~~~~~~~
| undo_io_manager--- lib/ext2fs/getsectsize.c | 12 ++++++------ lib/support/plausible.c | 2 +- util/subst.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
lib/ext2fs/getsectsize.c +6 -6
@@ -51,10 +51,10 @@*/ errcode_t ext2fs_get_device_sectsize (const char *file,int *sectsize) { -#ifdef _WIN64 +#ifdef _WIN32 *sectsize =512 ;// just guessing return 0 ; -#else // not _WIN64 +#else // not _WIN32 int fd;
@@ -78,7 +78,7 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)close (fd);return 0 ; -#endif // ifdef _WIN64 +#endif // ifdef _WIN32 }/*
@@ -117,11 +117,11 @@ int ext2fs_get_dio_alignment(int fd)*/ errcode_t ext2fs_get_device_phys_sectsize (const char *file,int *sectsize) { -#ifdef _WIN64 +#ifdef _WIN32return ext2fs_get_device_sectsize (file, sectsize); -#else // not _WIN64 +#else // not _WIN32 int fd;
@@ -147,5 +147,5 @@ errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)close (fd);return 0 ; -#endif // ifdef _WIN64 +#endif // ifdef _WIN32 }
lib/support/plausible.c +1 -1
@@ -103,7 +103,7 @@ static void print_ext2_info(const char *device)time_t tm; retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0, -#ifdef _WIN64 +#ifdef _WIN32 windows_io_manager, #else unix_io_manager,
util/subst.c +2 -2
@@ -434,7 +434,7 @@ int main(int argc, char **argv)printf ("Using original atime\n" );set_utimes (outfn,fileno (old), tv); } -#ifndef _WIN64 +#ifndef _WIN32if (ofd >=0 ) (void )fchmod (ofd,0444 );#endif
@@ -444,7 +444,7 @@ int main(int argc, char **argv) }else {if (verbose)printf ("Creating or replacing %s.\n" , outfn); -#ifndef _WIN64 +#ifndef _WIN32if (ofd >=0 ) (void )fchmod (ofd,0444 );#endif
Signature · 1 line
2.39.0
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
_WIN32is the standard macro to detect Windows, regardless of 32-bit or 64-bit._WIN64is for 64-bit Windows only. Use_WIN32where_WIN64was incorrectly being used.This fixes several 32-bit Windows build errors, for example this one:
Color me impressed, I would have applied to deprecate Windows support entirely, particularly given the existence of WSL.
That said ... back in the day, IIRC it was _WINDOWS that one was supposed to check for a Windows build, and the _WIN{16,32,64} variants existed to detect specific variants of it. But, that was 25 years ago; for all I know that's passé and _WIN32 is fine.
--D
Quoted 100 lines
plausible.c: In function ‘print_ext2_info’:
plausible.c:109:31: error: ‘unix_io_manager’ undeclared (first use in this function); did you mean ‘undo_io_manager’?109 | unix_io_manager, | ^~~~~~~~~~~~~~~ | undo_io_managerFixes 86b6db9f5a43 ("libext2fs: code adaptation to use the Windows IO manager")Cc Paulo Antonio Alvarez <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- lib/ext2fs/getsectsize.c | 12 ++++++------ lib/support/plausible.c | 2 +- util/subst.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)lib/ext2fs/getsectsize.c +6
-6@@ -51,10 +51,10 @@*/ errcode_t ext2fs_get_device_sectsize (const char *file,int *sectsize) { -#ifdef _WIN64 +#ifdef _WIN32 *sectsize =512 ;// just guessing return 0 ; -#else // not _WIN64 +#else // not _WIN32 int fd;@@ -78,7 +78,7 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)close (fd);return 0 ; -#endif // ifdef _WIN64 +#endif // ifdef _WIN32 }/* @@ -117,11 +117,11 @@ int ext2fs_get_dio_alignment(int fd)*/ errcode_t ext2fs_get_device_phys_sectsize (const char *file,int *sectsize) { -#ifdef _WIN64 +#ifdef _WIN32return ext2fs_get_device_sectsize (file, sectsize); -#else // not _WIN64 +#else // not _WIN32 int fd;@@ -147,5 +147,5 @@ errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)close (fd);return 0 ; -#endif // ifdef _WIN64 +#endif // ifdef _WIN32 }lib/support/plausible.c +1
-1@@ -103,7 +103,7 @@ static void print_ext2_info(const char *device)time_t tm; retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0, -#ifdef _WIN64 +#ifdef _WIN32 windows_io_manager, #else unix_io_manager,util/subst.c +2
-2@@ -434,7 +434,7 @@ int main(int argc, char **argv)printf ("Using original atime\n" );set_utimes (outfn,fileno (old), tv); } -#ifndef _WIN64 +#ifndef _WIN32if (ofd >=0 ) (void )fchmod (ofd,0444 );#endif @@ -444,7 +444,7 @@ int main(int argc, char **argv) }else {if (verbose)printf ("Creating or replacing %s.\n" , outfn); -#ifndef _WIN64 +#ifndef _WIN32if (ofd >=0 ) (void )fchmod (ofd,0444 );#endif Signature · 1 line
2.39.0
Quoted 11 lines · Darrick J. Wong
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
_WIN32is the standard macro to detect Windows, regardless of 32-bit or 64-bit._WIN64is for 64-bit Windows only. Use_WIN32where_WIN64was incorrectly being used.This fixes several 32-bit Windows build errors, for example this one:
Color me impressed, I would have applied to deprecate Windows support entirely, particularly given the existence of WSL.
Yes, now that everyone has migrated to GNU Hurd, which is fully supported by e2fsprogs, there's no need for Windows which no one uses anymore :-)
The reason I have to care about e2fsprogs support for Windows is because the Windows build of the Android SDK Platform tools includes a Windows binary of mke2fs, so that it can be used by 'fastboot format'.
I am sure that Ted would be very unhappy if Android had to bring back 'make_ext4fs' due to e2fsprogs removing Windows support...
(One way out of this for Android would be to remove fastboot's support for formatting filesystems, and just have it support wiping them. The actual formatting would then always happen on the Android device itself, using the Linux build of e2fsprogs. I'm not sure why that can't be done; however, I do know that it's been brought up many times before and still hasn't happened...)
Of course, a second problem that I ran into after I sent this patch without properly testing it, is that misc/mke2fs.c is hard-coding unix_io_manager. So an additional fix would be needed to make it use windows_io_manager on Windows, now that Windows has its own windows_io_manager instead of unix_io_manager.
Paulo, just to double check: was your intent when adding the windows_io_manager that it *always* replace unix_io_manager on Windows?
- Eric
Quoted 4 lines · Eric Biggers
Quoted 3 lines · Darrick J. Wong
Quoted 2 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
_WIN32is the standard macro to detect Windows, regardless of 32-bit or 64-bit._WIN64is for 64-bit Windows only. Use_WIN32where_WIN64was incorrectly being used.This fixes several 32-bit Windows build errors, for example this one:
Color me impressed, I would have applied to deprecate Windows support entirely, particularly given the existence of WSL.
Note that WSL doesn't really eliminate the need for native Windows binaries, since WSL is something that has to be explicitly enabled and configured; see
https://learn.microsoft.com/en-us/windows/wsl/install. It's not like running a 32-bit binary on a 64-bit system which is something that just works. You can't just take a Linux binary and run it on Windows.
- Eric