_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'
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;
| ^~~~~~~~
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,
| ^~~~~~~~~~~~~~~~~~~~~
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 <anonymous>'
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
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 <anonymous>'
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;
| ^~~~
On linux the request argument of ioctl() is defined as an unsigned long,
but the fuse protocol squashes it into a signed int. As a consequence
the value received by ntfs-3g may appear as negative and different from
the value defined by the corresponding macro.
So define the request argument as unsigned long in ntfs-3g. It has
however to be fed as unsigned from fuse until the fuse protocol is
updated.
Upgrade the Win32 interface (win32_io.c) which was designed for Cygwin
so that it can be used for using the ntfsprogs utilities on native Windows.
Two new entries are added for truncating a file and creating a sparse
file, both of which not being supported through msvcrt.dll.