Commit Graph

19 Commits (9e0b9ec23aad6352883e48dcee05978abf141dcc)

Author SHA1 Message Date
CodingKoopa 6261aa3c0c 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'
2024-03-08 06:18:29 +00:00
CodingKoopa ecfe5e1af3 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));
      |                               ^~~~~~
2024-03-08 06:09:12 +00:00
CodingKoopa 7d1c1ad3ca 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;
      |                ^~~~~~~~
2024-03-08 06:07:04 +00:00
CodingKoopa 22dac966ba 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,
      |    ^~~~~~~~~~~~~~~~~~~~~
2024-03-08 05:59:20 +00:00
CodingKoopa 9038bb8dca 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 <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
2024-03-08 05:52:33 +00:00
CodingKoopa 13d341356b 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 <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;
      |   ^~~~
2024-03-08 05:43:51 +00:00
Jean-Pierre André 32c27a8a4f Defined the request argument of ioctl() as unsigned long
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.
2020-03-07 10:31:12 +01:00
Jean-Pierre André 31430ae01a Returned an error code for an exclusive access violation on Windows
Translate to Windows error code STATUS_SHARING_VIOLATION to Unix error
code EBUSY.
2016-04-06 10:08:01 +02:00
Jean-Pierre André 3fb1deb13b Fixed getting sector size from a partition image (Windows variant)
On Windows, when processing a partition image, get the sector size
from the boot sector instead of the containing partition.
2015-04-17 09:21:58 +02:00
Jean-Pierre André 952917bccf Fixed const violation in win32_io.c (cosmetic)
Fixed the read-modify-write procedure to be compatible with the
write-only one to avoid violating the "const" attibute of the latter.
2014-06-23 10:46:31 +02:00
Jean-Pierre André b80d33785a Fixed marking device as closed (Windows variant)
When closing a device, the flag keeping track of open state was not reset,
and this prevented opening again (native Windows variant only).
2014-03-11 10:32:39 +01:00
Jean-Pierre André 33bbb9d009 Fixed creating a new image file on Windows
Creating a new image file (clone or metadata) by ntfsclone failed on
Windows, because the file was not opened with the needed flags.
2013-08-06 11:44:40 +02:00
Jean-Pierre André a28e2a8606 Fixed dealing with errors getting the file size from Windows
Using SetFilePointer() for compatibility with old Windows implies
a specific management of errors....
2013-08-06 11:39:13 +02:00
Jean-Pierre André ebf35000c9 Fixed computing a file size on Windows
The lower part should not have been sign-extended.
2013-07-30 11:42:59 +02:00
Jean-Pierre André 2c10bd6a98 Fixed struct formats for running on 64-bit Windows
Added a few paddings for field alignment in structs whose layout has to
match 64-bit Windows internals.
2013-07-30 11:31:56 +02:00
Jean-Pierre André e221ad783c Improved emulation of stat(2) on Windows
Made a distinction between a file and a partition when emulating stat(2)
on Windows (useful for ntfsclone).
2013-07-30 11:17:29 +02:00
Jean-Pierre André 44fbf02a97 Upgraded the Win32 interface for use with ntfsprogs
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.
2013-02-09 11:22:41 +01:00
jpandre 499e106341 Adapted to ntfs-3g.1.2812 2008-08-16 15:17:47 +00:00
szaka ba63b7daca initial CVS import 2006-10-30 22:32:48 +00:00