From ba086d6f1a4ab644fce26205d4c517d7634e9bec Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Sat, 24 Feb 2024 09:09:33 +0000 Subject: [PATCH 01/18] guard syslog.h --- libntfs-3g/ioctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libntfs-3g/ioctl.c b/libntfs-3g/ioctl.c index b059a53f..a3a56722 100644 --- a/libntfs-3g/ioctl.c +++ b/libntfs-3g/ioctl.c @@ -48,7 +48,9 @@ #ifdef HAVE_LIMITS_H #include #endif +#ifdef HAVE_SYSLOG_H #include +#endif #ifdef HAVE_SYS_TYPES_H #include #endif From fcd27ddb2d4c361362f6b96071e217f373227a2e Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Sat, 24 Feb 2024 09:18:35 +0000 Subject: [PATCH 02/18] remove bogus __timespec_defined --- include/ntfs-3g/ntfstime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ntfs-3g/ntfstime.h b/include/ntfs-3g/ntfstime.h index f3a89dd8..80e163f8 100644 --- a/include/ntfs-3g/ntfstime.h +++ b/include/ntfs-3g/ntfstime.h @@ -39,7 +39,7 @@ /* * assume "struct timespec" is not defined if st_mtime is not defined */ -#if !defined(st_mtime) & !defined(__timespec_defined) +#if !defined(st_mtime) struct timespec { time_t tv_sec; long tv_nsec; From 13d341356b65a2729ff359daf11d393ddcb0bed7 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 05:43:51 +0000 Subject: [PATCH 03/18] win32_io.c: rm GUID type definition This conflicts with the GUID defined in the Windows headers, and we don't seem to use this one. Fixes compiler error (could also be fixed by redefining Windows' GUID): win32_io.c:55:3: error: conflicting types for 'GUID'; have 'struct ' 55 | } GUID; | ^~~~ In file included from /usr/include/w32api/winnt.h:648, from /usr/include/w32api/minwindef.h:163, from /usr/include/w32api/windef.h:9, from /usr/include/w32api/windows.h:69, from win32_io.c:31: /usr/include/w32api/guiddef.h:24:3: note: previous declaration of 'GUID' with type 'GUID' 24 | } GUID; | ^~~~ --- libntfs-3g/win32_io.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index 9c72dee3..41c43c6b 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -45,15 +45,6 @@ typedef unsigned long long DWORD64; #endif -typedef struct { - DWORD data1; /* The first eight hexadecimal digits of the GUID. */ - WORD data2; /* The first group of four hexadecimal digits. */ - WORD data3; /* The second group of four hexadecimal digits. */ - char data4[8]; /* The first two bytes are the third group of four - hexadecimal digits. The remaining six bytes are the - final 12 hexadecimal digits. */ -} GUID; - #include #ifdef HAVE_STDIO_H From 9038bb8dca09c3842ad32f876f0509e366d86a8e Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 05:52:33 +0000 Subject: [PATCH 04/18] win32_io.c: use different BOOL workaround Fixes compiler error: In file included from ../include/ntfs-3g/logging.h:34, from ../include/ntfs-3g/debug.h:29, from win32_io.c:73: ../include/ntfs-3g/types.h:114:3: error: conflicting types for 'BOOL'; have 'enum ' 114 | } BOOL; | ^~~~ In file included from /usr/include/w32api/windef.h:9, from /usr/include/w32api/windows.h:69, from win32_io.c:31: /usr/include/w32api/minwindef.h:131:15: note: previous declaration of 'BOOL' with type 'BOOL' {aka 'int'} 131 | typedef int BOOL; | ^~~~ This leverages the fact that, in minwindef.h, the definition is guarded like so: #if !defined(__OBJC__) && !defined(__OBJC_BOOL) && !defined(__objc_INCLUDE_GNU) && !defined(_NO_BOOL_TYPEDEF) typedef int BOOL; #endif --- libntfs-3g/win32_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index 41c43c6b..7e76f638 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -27,9 +27,9 @@ #include "config.h" #ifdef HAVE_WINDOWS_H -#define BOOL WINBOOL /* avoid conflicting definitions of BOOL */ +#define _NO_BOOL_TYPEDEF /* supported by both Cygwin and MinGW-w64's w32api */ #include -#undef BOOL +#undef _NO_BOOL_TYPEDEF #endif #ifdef HAVE_STDLIB_H From 22dac966baee478fcaf0ef13833678dced1a4f55 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 05:59:20 +0000 Subject: [PATCH 05/18] win32_io.c: undefine all enum constants Some of the STATUS enum constants conflict with those from winnt.h. This change undefines all of them to be safe. Fixes compiler error: In file included from /usr/include/w32api/minwindef.h:163, from /usr/include/w32api/windef.h:9, from /usr/include/w32api/windows.h:69, from win32_io.c:31: win32_io.c:132:4: error: expected identifier before '(' token 132 | STATUS_INVALID_HANDLE = 0xC0000008, | ^~~~~~~~~~~~~~~~~~~~~ --- libntfs-3g/win32_io.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index 7e76f638..d6783ead 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -125,6 +125,30 @@ static LPFN_SETFILEPOINTEREX fnSetFilePointerEx = NULL; #define FNPOSTFIX "A" #endif +/* + * Since many of the ahead enum constants conflict with winnt.h defines, + * make sure that each enum constant is undefined. + */ + +#undef STATUS_UNKNOWN +#undef STATUS_SUCCESS +#undef STATUS_BUFFER_OVERFLOW +#undef STATUS_INVALID_HANDLE +#undef STATUS_INVALID_PARAMETER +#undef STATUS_INVALID_DEVICE_REQUEST +#undef STATUS_END_OF_FILE +#undef STATUS_CONFLICTING_ADDRESSES +#undef STATUS_NO_MATCH +#undef STATUS_ACCESS_DENIED +#undef STATUS_BUFFER_TOO_SMALL +#undef STATUS_OBJECT_TYPE_MISMATCH +#undef STATUS_FILE_NOT_FOUND +#undef STATUS_OBJECT_NAME_INVALID +#undef STATUS_OBJECT_NAME_NOT_FOUND +#undef STATUS_SHARING_VIOLATION +#undef STATUS_INVALID_PARAMETER_1 +#undef STATUS_IO_DEVICE_ERROR +#undef STATUS_GUARD_PAGE_VIOLATION enum { /* see http://msdn.microsoft.com/en-us/library/cc704588(v=prot.10).aspx */ STATUS_UNKNOWN = -1, STATUS_SUCCESS = 0x00000000, From 7d1c1ad3ca540589faa524fef1f7a39bd6160a53 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:07:04 +0000 Subject: [PATCH 06/18] win32_io.c: make NTSTATUS signed bcrypt.h defines this as a long, which causes a conflict. On LLP64, long and u32 are the same size, but have different signedness. Signed seems to be the prevailing view of the type. Fixes compiler error: win32_io.c:174:13: error: conflicting types for 'NTSTATUS'; have 'u32' {aka 'unsigned int'} 174 | typedef u32 NTSTATUS; /* do not let the compiler choose the size */ | ^~~~~~~~ In file included from /usr/include/w32api/wincrypt.h:846, from /usr/include/w32api/windows.h:95, from win32_io.c:31: /usr/include/w32api/bcrypt.h:27:16: note: previous declaration of 'NTSTATUS' with type 'NTSTATUS' {aka 'int'} 27 | typedef LONG NTSTATUS,*PNTSTATUS; | ^~~~~~~~ --- libntfs-3g/win32_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index d6783ead..20976686 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -171,7 +171,7 @@ enum { /* see http://msdn.microsoft.com/en-us/library/cc704588(v=prot.10).aspx * STATUS_GUARD_PAGE_VIOLATION = 0x80000001 } ; -typedef u32 NTSTATUS; /* do not let the compiler choose the size */ +typedef s32 NTSTATUS; /* do not let the compiler choose the size */ #ifdef __x86_64__ typedef unsigned long long ULONG_PTR; /* an integer the same size as a pointer */ #else From ecfe5e1af398ece2ec72c7c1abf33146d2a118ec Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:09:12 +0000 Subject: [PATCH 07/18] win32_io.c: use stat on Cygwin Fixes compiler error (among others): win32_io.c: In function 'ntfs_device_win32_stat': win32_io.c:1804:31: error: invalid application of 'sizeof' to incomplete type 'struct stat64' 1804 | memset(buf, 0, sizeof(struct stat)); | ^~~~~~ --- libntfs-3g/win32_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index 20976686..b1422603 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -61,7 +61,9 @@ typedef unsigned long long DWORD64; #endif #ifdef HAVE_SYS_STAT_H #include +#ifndef __CYGWIN__ /* See https://cygwin.com/faq.html#faq.programming.stat64 */ #define stat stat64 +#endif #define st_blocks st_rdev /* emulate st_blocks, missing in Windows */ #endif From 64f3464378b81cc266c5dcfa7ff3399527b85868 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:13:18 +0000 Subject: [PATCH 08/18] device_io.h: forward declare ntfs_device struct. Fixes compiler error: win32_io.c:2037:5: error: conflicting types for 'ntfs_device_win32_ftruncate'; have 'int(struct ntfs_device *, s64)' {aka 'int(struct ntfs_device *, long int)'} 2037 | int ntfs_device_win32_ftruncate(struct ntfs_device *dev, s64 size) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../include/ntfs-3g/device.h:30, from win32_io.c:77: ../include/ntfs-3g/device_io.h:75:5: note: previous declaration of 'ntfs_device_win32_ftruncate' with type 'int(struct ntfs_device *, s64)' {aka 'int(struct ntfs_device *, long int)'} 75 | int ntfs_device_win32_ftruncate(struct ntfs_device*, s64); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ --- include/ntfs-3g/device_io.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/ntfs-3g/device_io.h b/include/ntfs-3g/device_io.h index 66ad2439..12c1e370 100644 --- a/include/ntfs-3g/device_io.h +++ b/include/ntfs-3g/device_io.h @@ -69,6 +69,9 @@ struct hd_geometry { /* On Windows (and Cygwin) : use Win32 low level device operations. */ #define ntfs_device_default_io_ops ntfs_device_win32_io_ops +/* Forward declaration. */ +struct ntfs_device; + /* A few useful functions */ int ntfs_win32_set_sparse(int); int ntfs_win32_ftruncate(int fd, s64 size); From 6261aa3c0c6ab2956227ff8a0bca3ef51b9a1eac Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:18:29 +0000 Subject: [PATCH 09/18] win32_io.c: switch to _get_osfhandle from get_osfhandle _get_osfhandle is what is documented. The alternative might have been removed. Fixes linker error: /cygdrive/e/Documents/Programs/ntfs-3g/libntfs-3g/win32_io.c:1990:(.text+0x21a5): undefined reference to `get_osfhandle' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: .libs/libntfs_3g_la-win32_io.o: in function `ntfs_win32_ftruncate': /cygdrive/e/Documents/Programs/ntfs-3g/libntfs-3g/win32_io.c:2054:(.text+0x223a): undefined reference to `get_osfhandle' --- libntfs-3g/win32_io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index b1422603..75e7b3be 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -180,7 +180,7 @@ typedef unsigned long long ULONG_PTR; /* an integer the same size as a pointer * typedef unsigned long ULONG_PTR; /* an integer the same size as a pointer */ #endif -HANDLE get_osfhandle(int); /* from msvcrt.dll */ +HANDLE _get_osfhandle(int); /* from msvcrt.dll */ /* * A few needed definitions not included in @@ -1987,7 +1987,7 @@ int ntfs_win32_set_sparse(int fd) HANDLE handle; DWORD bytes; - handle = get_osfhandle(fd); + handle = _get_osfhandle(fd); if (handle == INVALID_HANDLE_VALUE) ok = FALSE; else @@ -2051,7 +2051,7 @@ int ntfs_win32_ftruncate(int fd, s64 size) int ret; HANDLE handle; - handle = get_osfhandle(fd); + handle = _get_osfhandle(fd); ret = win32_ftruncate(handle, size); return (ret); } From d43ede9b7d7c5441197e4479a3fd11888c32c3af Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:23:21 +0000 Subject: [PATCH 10/18] libntfs-3g: link to ntdll.dll on Windows win32_io.c uses some symbols from this DLL. Fixes linker error (among others): /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: .libs/libntfs_3g_la-win32_io.o: in function `ntfs_device_win32_pio': /cygdrive/e/Documents/Programs/ntfs-3g/libntfs-3g/win32_io.c:1386:(.text+0x274): undefined reference to `NtWriteFile' /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/e/Documents/Programs/ntfs-3g/libntfs-3g/win32_io.c:1391:(.text+0x348): undefined reference to `NtReadFile' --- libntfs-3g/Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libntfs-3g/Makefile.am b/libntfs-3g/Makefile.am index 6feba7d7..28d873f3 100644 --- a/libntfs-3g/Makefile.am +++ b/libntfs-3g/Makefile.am @@ -14,6 +14,10 @@ libntfs_3g_la_CPPFLAGS= $(AM_CPPFLAGS) $(LIBNTFS_CPPFLAGS) -I$(top_srcdir)/inclu libntfs_3g_la_LIBADD = $(LIBNTFS_LIBS) libntfs_3g_la_LDFLAGS = -version-info $(LIBNTFS_3G_VERSION) -no-undefined +if WINDOWS +libntfs_3g_la_LDFLAGS += -lntdll +endif + libntfs_3g_la_SOURCES = \ acls.c \ attrib.c \ From f1960238411d0a7286ed279749968398df83e10f Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:25:49 +0000 Subject: [PATCH 11/18] utils.h: remove compat macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It might be worth figuring out a more proper fix than this. Fixes compiler error: In file included from ntfswipe.c:63: ntfswipe.c: In function ‘version’: utils.h:113:58: error: expected expression before ‘)’ token 113 | ntfs_utils_reformat(_b,MAX_FMT,fmt), args); } while (0) | ^ ../include/ntfs-3g/logging.h:95:40: note: in expansion of macro ‘ntfs_log_redirect’ 95 | #define ntfs_log_info(FORMAT, ARGS...) ntfs_log_redirect(__FUNCTION__,__FILE__,__LINE__,NTFS_LOG_LEVEL_INFO,NULL,FORMAT,##ARGS) | ^~~~~~~~~~~~~~~~~ --- ntfsprogs/utils.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/ntfsprogs/utils.h b/ntfsprogs/utils.h index 6335924e..3974da00 100644 --- a/ntfsprogs/utils.h +++ b/ntfsprogs/utils.h @@ -101,27 +101,6 @@ int mft_next_record(struct mft_search_ctx *ctx); #define MAX_PATH 1024 #endif -#ifdef HAVE_WINDOWS_H -/* - * Macroes to hide the needs to translate formats on older Windows - */ -#define MAX_FMT 1536 -char *ntfs_utils_reformat(char *out, int sz, const char *fmt); -char *ntfs_utils_unix_path(const char *in); -#define ntfs_log_redirect(fn,fi,li,le,d,fmt, args...) \ - do { char _b[MAX_FMT]; ntfs_log_redirect(fn,fi,li,le,d, \ - ntfs_utils_reformat(_b,MAX_FMT,fmt), args); } while (0) -#define printf(fmt, args...) \ - do { char _b[MAX_FMT]; \ - printf(ntfs_utils_reformat(_b,MAX_FMT,fmt), args); } while (0) -#define fprintf(str, fmt, args...) \ - do { char _b[MAX_FMT]; \ - fprintf(str, ntfs_utils_reformat(_b,MAX_FMT,fmt), args); } while (0) -#define vfprintf(file, fmt, args) \ - do { char _b[MAX_FMT]; vfprintf(file, \ - ntfs_utils_reformat(_b,MAX_FMT,fmt), args); } while (0) -#endif - /** * linux-ntfs's ntfs_mbstoucs has different semantics, so we emulate it with * ntfs-3g's. From 9e0b9ec23aad6352883e48dcee05978abf141dcc Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:31:19 +0000 Subject: [PATCH 12/18] ntfsprogs: provide WINAPI definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copied from a header in the public domain. Fixes compiler error: ntfsusermap.c:149:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘LookupAccountNameA’ 149 | BOOL WINAPI LookupAccountNameA(const char*, const char*, void*, | ^~~~~~~~~~~~~~~~~~ ntfsusermap.c:151:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘GetUserNameA’ 151 | BOOL WINAPI GetUserNameA(char*, u32*); | ^~~~~~~~~~~~ --- ntfsprogs/ntfssecaudit.c | 10 ++++++++++ ntfsprogs/ntfsusermap.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/ntfsprogs/ntfssecaudit.c b/ntfsprogs/ntfssecaudit.c index 9484a605..25b136b8 100644 --- a/ntfsprogs/ntfssecaudit.c +++ b/ntfsprogs/ntfssecaudit.c @@ -434,6 +434,16 @@ struct SDH { /* this is an image of an $SDH index entry */ } ; #ifdef HAVE_WINDOWS_H + +// Copied from minwindef.h. +#ifndef WINAPI +#if defined(_ARM_) +#define WINAPI +#else +#define WINAPI __stdcall +#endif +#endif + /* * Including leads to numerous conflicts with layout.h * so define a few needed Windows calls unrelated to ntfs-3g diff --git a/ntfsprogs/ntfsusermap.c b/ntfsprogs/ntfsusermap.c index 6c1f61b8..b4c41070 100644 --- a/ntfsprogs/ntfsusermap.c +++ b/ntfsprogs/ntfsusermap.c @@ -142,6 +142,16 @@ #include "misc.h" #ifdef HAVE_WINDOWS_H + +// Copied from minwindef.h. +#ifndef WINAPI +#if defined(_ARM_) +#define WINAPI +#else +#define WINAPI __stdcall +#endif +#endif + /* * Including leads to numerous conflicts with layout.h * so define a few needed Windows calls unrelated to ntfs-3g From 69c2377280241973a395e3aedad78f4a2da33d5b Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 06:37:05 +0000 Subject: [PATCH 13/18] ntfsusermap.c: provide mode with mkdir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The desired mkdir does not seem to exist on Cygwin. Fixes compiler error: ntfsusermap.c: In function ‘outputmap’: ntfsusermap.c:817:25: error: too few arguments to function ‘mkdir’ 817 | mkdir(fullname); | ^~~~~ In file included from /usr/include/sys/_default_fcntl.h:212, from /usr/include/sys/fcntl.h:3, from /usr/include/fcntl.h:13, from ntfsusermap.c:113: /usr/include/sys/stat.h:140:9: note: declared here 140 | int mkdir (const char *_path, mode_t __mode ); | ^~~~~ --- ntfsprogs/ntfsusermap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ntfsprogs/ntfsusermap.c b/ntfsprogs/ntfsusermap.c index b4c41070..d8150fde 100644 --- a/ntfsprogs/ntfsusermap.c +++ b/ntfsprogs/ntfsusermap.c @@ -814,7 +814,12 @@ static boolean outputmap(const char *volume, const char *dir) /* build directory, if not present */ if (stat(fullname,&st) && (errno == ENOENT)) { printf("* Creating directory %s\n", fullname); + #ifdef __CYGWIN__ + // The one-argument mkdir is exclusive to msvcrt.dll. + mkdir(fullname, 777); + #else mkdir(fullname); + #endif } strcat(fullname, DIRSEP); From e2f2bfbe784bcc0d78ef7b675e50ab6fa361c910 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 04:20:02 -0500 Subject: [PATCH 14/18] ntfsclone.c: use setmode from header Fixes linker error: /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: ntfsclone.o: in function `open_image': /cygdrive/e/Documents/Programs/ntfs-3g/ntfsprogs/ntfsclone.c:2385:(.text.startup+0x34e): undefined reference to `setmode' --- ntfsprogs/ntfsclone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 00876313..2aab675d 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -110,10 +110,14 @@ #endif #ifdef HAVE_WINDOWS_H +#ifdef __CYGWIN__ +#include +#else /* * Replacements for functions which do not exist on Windows */ int setmode(int, int); /* from msvcrt.dll */ +#endif #define getpid() (0) #define srandom(seed) srand(seed) From 11543cd632eae9f1e3785a2fbd6de28d8aaaa412 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 18:53:56 -0500 Subject: [PATCH 15/18] readme: add windows instructions --- README | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README b/README index aaa63414..66c7bc0a 100644 --- a/README +++ b/README @@ -119,6 +119,30 @@ then, as root: And, to end the test, unmount the usual way: umount /dev/sda1 +BUILDING FOR WINDOWS +==================== + +A subset of the components found in this repository may be compiled and +executed on Windows. This includes the libntfs-3g library and the ntfsprogs +programs, but NOT the actual ntfs-3g driver. + +To target Cygwin, you must install the following packages +from the Cygwin installer: + + automake + libtool + make + gcc-core + libgcrypt-devel + +Then + + ./configure --disable-ntfs-3g --disable-plugins + make + +The full set of ntfsprogs, including ntfsusermap, can be built using: + + make extra NTFS UTILITIES ============== From 1a3def37c5727defacd4fa6de3bd83e51e375bd2 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 19:07:49 -0500 Subject: [PATCH 16/18] win32_io.c: fix variable name This fixes a compiler error only manifesting in debug mode. --- libntfs-3g/win32_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index 75e7b3be..a2e18088 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -360,7 +360,7 @@ static int ntfs_w32error_to_errno(unsigned int w32error) static int ntfs_ntstatus_to_errno(NTSTATUS status) { - ntfs_log_trace("Converting w32error 0x%x.\n",w32error); + ntfs_log_trace("Converting w32error 0x%x.\n",status); switch (status) { case STATUS_INVALID_HANDLE : case STATUS_INVALID_PARAMETER : From 0038d946bead4b9d3e7c2cb0d4e20bb44e06ee97 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Fri, 8 Mar 2024 19:08:39 -0500 Subject: [PATCH 17/18] win32_io.c: fix variable name + comment This fixes a compiler error only manifesting in debug mode. --- libntfs-3g/win32_io.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index a2e18088..8d0d718e 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -1340,7 +1340,8 @@ static s64 ntfs_device_win32_seek(struct ntfs_device *dev, s64 offset, * @fd: win32 device descriptor obtained via ->open * @pos: at which position to do i/o from/to * @count: how many bytes should be transfered - * @b: source/destination buffer + * @rbuf: source buffer (null if writing) + * @wbuf: destination buffer (null if reading) * @write: TRUE if write transfer and FALSE if read transfer * * On success returns the number of bytes transfered (can be < @count) and on @@ -1362,7 +1363,7 @@ static s64 ntfs_device_win32_pio(win32_fd *fd, const s64 pos, s64 bytes; ntfs_log_trace("pos = 0x%llx, count = 0x%llx, direction = %s.\n", - (long long)pos, (long long)count, write ? "write" : + (long long)pos, (long long)count, wbuf ? "write" : "read"); li.QuadPart = pos; if (fd->vol_handle != INVALID_HANDLE_VALUE && pos < fd->geo_size) { @@ -1412,7 +1413,7 @@ static s64 ntfs_device_win32_pio(win32_fd *fd, const s64 pos, bytes = bt; if (!res) { errno = ntfs_w32error_to_errno(GetLastError()); - ntfs_log_trace("%sFile() failed.\n", write ? + ntfs_log_trace("%sFile() failed.\n", wbuf ? "Write" : "Read"); return -1; } From 00e2074920b50b368d2d668a03806db6db269469 Mon Sep 17 00:00:00 2001 From: CodingKoopa Date: Sat, 9 Mar 2024 03:18:14 +0000 Subject: [PATCH 18/18] fixup! ntfsusermap.c: provide mode with mkdir --- ntfsprogs/ntfsusermap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntfsprogs/ntfsusermap.c b/ntfsprogs/ntfsusermap.c index d8150fde..8a25b278 100644 --- a/ntfsprogs/ntfsusermap.c +++ b/ntfsprogs/ntfsusermap.c @@ -816,7 +816,7 @@ static boolean outputmap(const char *volume, const char *dir) printf("* Creating directory %s\n", fullname); #ifdef __CYGWIN__ // The one-argument mkdir is exclusive to msvcrt.dll. - mkdir(fullname, 777); + mkdir(fullname, 0777); #else mkdir(fullname); #endif