mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Doesn't use the physical address in Wine.
This commit is contained in:
parent
275ef2ed3c
commit
e8b2d359d6
2 changed files with 52 additions and 1 deletions
25
mingw.c
25
mingw.c
|
|
@ -48,6 +48,7 @@ typedef struct _FILE_ATTRIBUTE_TAG_INFO {
|
|||
#define WIN32_ES_AWAYMODE_REQUIRED 0x00000040L
|
||||
#define WIN32_ES_CONTINUOUS 0x80000000L
|
||||
|
||||
#ifndef FSCTL_GET_RETRIEVAL_POINTERS
|
||||
#define FSCTL_GET_RETRIEVAL_POINTERS 0x00090073
|
||||
|
||||
typedef struct RETRIEVAL_POINTERS_BUFFER {
|
||||
|
|
@ -62,6 +63,7 @@ typedef struct RETRIEVAL_POINTERS_BUFFER {
|
|||
typedef struct {
|
||||
LARGE_INTEGER StartingVcn;
|
||||
} STARTING_VCN_INPUT_BUFFER;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Portable implementation of GetFileInformationByHandleEx.
|
||||
|
|
@ -86,14 +88,27 @@ static BOOLEAN (WINAPI* ptr_CreateSymbolicLinkW)(LPWSTR, LPWSTR, DWORD);
|
|||
*/
|
||||
static char* last_error;
|
||||
|
||||
/**
|
||||
* If we are running in Wine.
|
||||
*/
|
||||
static int is_wine;
|
||||
|
||||
void os_init(void)
|
||||
{
|
||||
HMODULE kernel32 = GetModuleHandle("KERNEL32.DLL");
|
||||
HMODULE kernel32, ntdll;
|
||||
|
||||
kernel32 = GetModuleHandle("KERNEL32.DLL");
|
||||
if (!kernel32) {
|
||||
fprintf(stderr, "Error loading the KERNEL32 module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ntdll = GetModuleHandle("NTDLL.DLL");
|
||||
if (!ntdll) {
|
||||
fprintf(stderr, "Error loading the NTDLL module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* load functions not always available */
|
||||
ptr_SetThreadExecutionState = (void*)GetProcAddress(kernel32, "SetThreadExecutionState");
|
||||
ptr_GetFileInformationByHandleEx = (void*)GetProcAddress(kernel32, "GetFileInformationByHandleEx");
|
||||
|
|
@ -108,6 +123,8 @@ void os_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
is_wine = GetProcAddress(ntdll, "wine_get_version") != 0;
|
||||
|
||||
last_error = 0;
|
||||
}
|
||||
|
||||
|
|
@ -1086,6 +1103,12 @@ int filephy(const char* file, struct stat* st, uint64_t* physical)
|
|||
DWORD ret;
|
||||
DWORD n;
|
||||
|
||||
/* in Wine just uses the inode number as FSCTL_GET_RETRIVIAL_POINTERS is not supported */
|
||||
if (is_wine) {
|
||||
*physical = st->st_ino;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* open the handle of the file */
|
||||
h = CreateFileW(convert(file), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
|
|
|
|||
28
mingw.h
28
mingw.h
|
|
@ -29,33 +29,52 @@
|
|||
#define PATH_MAX 1024
|
||||
|
||||
/* Remap functions and types */
|
||||
#undef fopen
|
||||
#define fopen windows_fopen
|
||||
#undef open
|
||||
#define open windows_open
|
||||
#define open_noatime windows_open
|
||||
#undef stat
|
||||
#define stat windows_stat
|
||||
#undef lstat
|
||||
#define lstat windows_lstat
|
||||
#undef off_t
|
||||
#define off_t off64_t
|
||||
#undef fstat
|
||||
#define fstat windows_fstat
|
||||
#define HAVE_FTRUNCATE 1
|
||||
#undef ftruncate
|
||||
#define ftruncate windows_ftruncate
|
||||
#define HAVE_FSYNC 1
|
||||
#undef fsync
|
||||
#define fsync _commit
|
||||
#undef rename
|
||||
#define rename windows_rename
|
||||
#undef remove
|
||||
#define remove windows_remove
|
||||
#undef mkdir
|
||||
#define mkdir(a, b) windows_mkdir(a)
|
||||
#undef rmdir
|
||||
#define rmdir windows_rmdir
|
||||
#undef dirent
|
||||
#define dirent windows_dirent
|
||||
#undef DIR
|
||||
#define DIR windows_dir
|
||||
#undef opendir
|
||||
#define opendir windows_opendir
|
||||
#undef readdir
|
||||
#define readdir windows_readdir
|
||||
#undef closedir
|
||||
#define closedir windows_closedir
|
||||
#define HAVE_FUTIMENS 1
|
||||
#undef futimens
|
||||
#define futimens windows_futimens
|
||||
#define O_NOFOLLOW 0
|
||||
#define dirent_hidden windows_dirent_hidden
|
||||
#define HAVE_DIRENT_LSTAT 1
|
||||
#define dirent_lstat windows_dirent_lstat
|
||||
#define stat_desc windows_stat_desc
|
||||
#undef sleep
|
||||
#define sleep windows_sleep
|
||||
/* 4==DIR, 5,6,7=free, 8==REG */
|
||||
#define S_IFLNK 0x5000 /* Symbolic link to file */
|
||||
|
|
@ -64,16 +83,25 @@
|
|||
#define S_ISLNKDIR(m) (((m) & _S_IFMT) == S_IFLNKDIR)
|
||||
#define S_IFJUN 0x7000 /* Junction */
|
||||
#define S_ISJUN(m) (((m) & _S_IFMT) == S_IFJUN)
|
||||
#undef readlink
|
||||
#define readlink windows_readlink
|
||||
#undef symlink
|
||||
#define symlink windows_symlink
|
||||
#undef link
|
||||
#define link windows_link
|
||||
#undef strerror
|
||||
#define strerror windows_strerror
|
||||
#undef read
|
||||
#define read windows_read
|
||||
#undef write
|
||||
#define write windows_write
|
||||
#undef lseek
|
||||
#define lseek windows_lseek
|
||||
#define HAVE_PREAD 1
|
||||
#define HAVE_PWRITE 1
|
||||
#undef pread
|
||||
#define pread windows_pread
|
||||
#undef pwrite
|
||||
#define pwrite windows_pwrite
|
||||
|
||||
/* We have nano second support */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue