mirror of
https://github.com/reactos/reactos.git
synced 2024-06-21 05:21:31 +00:00
[BTRFS][UBTRFS][SHELLBTRFS] Upgrade to 1.7.2
CORE-16679
This commit is contained in:
parent
c2d36912b9
commit
194ea909fd
|
@ -383,6 +383,8 @@ void BtrfsBalance::SaveBalanceOpts(HWND hwndDlg) {
|
|||
if (IsDlgButtonChecked(hwndDlg, IDC_PROFILES_RAID10) == BST_CHECKED) opts->profiles |= BLOCK_FLAG_RAID10;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_PROFILES_RAID5) == BST_CHECKED) opts->profiles |= BLOCK_FLAG_RAID5;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_PROFILES_RAID6) == BST_CHECKED) opts->profiles |= BLOCK_FLAG_RAID6;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_PROFILES_RAID1C3) == BST_CHECKED) opts->profiles |= BLOCK_FLAG_RAID1C3;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_PROFILES_RAID1C4) == BST_CHECKED) opts->profiles |= BLOCK_FLAG_RAID1C4;
|
||||
}
|
||||
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_DEVID) == BST_CHECKED) {
|
||||
|
@ -515,7 +517,7 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT uMsg, WPARA
|
|||
HWND devcb, convcb;
|
||||
btrfs_device* bd;
|
||||
btrfs_balance_opts* opts;
|
||||
static int convtypes[] = { IDS_SINGLE2, IDS_DUP, IDS_RAID0, IDS_RAID1, IDS_RAID5, IDS_RAID6, IDS_RAID10, 0 };
|
||||
static int convtypes[] = { IDS_SINGLE2, IDS_DUP, IDS_RAID0, IDS_RAID1, IDS_RAID5, IDS_RAID1C3, IDS_RAID6, IDS_RAID10, IDS_RAID1C4, 0 };
|
||||
int i, num_devices = 0, num_writeable_devices = 0;
|
||||
wstring s, u;
|
||||
bool balance_started = balance_status & (BTRFS_BALANCE_RUNNING | BTRFS_BALANCE_PAUSED);
|
||||
|
@ -601,7 +603,7 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT uMsg, WPARA
|
|||
break;
|
||||
else if (num_writeable_devices < 3 && i == 4)
|
||||
break;
|
||||
else if (num_writeable_devices < 4 && i == 5)
|
||||
else if (num_writeable_devices < 4 && i == 6)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -615,6 +617,8 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT uMsg, WPARA
|
|||
CheckDlgButton(hwndDlg, IDC_PROFILES_RAID10, opts->profiles & BLOCK_FLAG_RAID10 ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_PROFILES_RAID5, opts->profiles & BLOCK_FLAG_RAID5 ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_PROFILES_RAID6, opts->profiles & BLOCK_FLAG_RAID6 ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_PROFILES_RAID1C3, opts->profiles & BLOCK_FLAG_RAID1C3 ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_PROFILES_RAID1C4, opts->profiles & BLOCK_FLAG_RAID1C4 ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_SINGLE), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_DUP), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
|
@ -623,6 +627,8 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT uMsg, WPARA
|
|||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID10), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID5), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID6), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1C3), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1C4), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES), balance_started ? false : true);
|
||||
|
||||
// usage
|
||||
|
@ -752,6 +758,8 @@ INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc(HWND hwndDlg, UINT uMsg, WPARA
|
|||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID10), enabled);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID5), enabled);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID6), enabled);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1C3), enabled);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1C4), enabled);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ static void find_devices(HWND hwnd, const GUID* guid, const mountmgr& mm, vector
|
|||
if (ss > 0) {
|
||||
WCHAR* desc3 = (WCHAR*)malloc(ss * sizeof(WCHAR));
|
||||
|
||||
if (MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, desc2.c_str(), -1, desc3, (int)(ss * sizeof(WCHAR))))
|
||||
if (MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, desc2.c_str(), -1, desc3, ss))
|
||||
dev.friendly_name = desc3;
|
||||
|
||||
free(desc3);
|
||||
|
|
|
@ -327,7 +327,7 @@ static void register_clsid(const GUID clsid, const WCHAR* description) {
|
|||
|
||||
write_reg_key(HKEY_CLASSES_ROOT, clsidkeyname, nullptr, description);
|
||||
|
||||
GetModuleFileNameW(module, dllpath, sizeof(dllpath));
|
||||
GetModuleFileNameW(module, dllpath, sizeof(dllpath) / sizeof(WCHAR));
|
||||
|
||||
write_reg_key(HKEY_CLASSES_ROOT, inproc, nullptr, dllpath);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by shellbtrfs.rc
|
||||
//
|
||||
|
@ -134,6 +134,7 @@
|
|||
#define IDS_OUT_OF_MEMORY 215
|
||||
#define IDS_RECV_UNKNOWN_COMMAND 216
|
||||
#define IDS_RECV_CANT_OPEN_PATH 217
|
||||
#define IDS_RAID1C3 218
|
||||
#define IDS_RECV_CREATE_SUBVOL_FAILED 219
|
||||
#define IDS_RECV_MISSING_PARAM 220
|
||||
#define IDS_RECV_SHORT_PARAM 221
|
||||
|
@ -145,6 +146,7 @@
|
|||
#define IDS_RECV_CREATEHARDLINK_FAILED 227
|
||||
#define IDS_RECV_SETENDOFFILE_FAILED 228
|
||||
#define IDS_RECV_CANT_CREATE_FILE 229
|
||||
#define IDS_RAID1C4 230
|
||||
#define IDS_RECV_SETINODEINFO_FAILED 231
|
||||
#define IDS_RECV_SUCCESS 232
|
||||
#define IDS_RECV_BUTTON_OK 233
|
||||
|
@ -309,7 +311,9 @@
|
|||
#define IDC_SOFT 1057
|
||||
#define IDC_PAUSE_SCRUB 1057
|
||||
#define IDC_CANCEL_SCRUB 1058
|
||||
#define IDC_PROFILES_RAID1C3 1058
|
||||
#define IDC_SCRUB_PROGRESS 1059
|
||||
#define IDC_PROFILES_RAID1C4 1059
|
||||
#define IDC_SCRUB_STATUS 1060
|
||||
#define IDC_COMPRESS_TYPE 1061
|
||||
#define IDC_CHECK1 1062
|
||||
|
@ -334,10 +338,10 @@
|
|||
#define IDC_DRIVE_LETTER_COMBO 1074
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 178
|
||||
#define _APS_NEXT_RESOURCE_VALUE 179
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1075
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
|
|
|
@ -25,18 +25,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
|||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
|
@ -61,8 +61,8 @@ IDI_ICON1 ICON "subvol.ico"
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,5,0,0
|
||||
PRODUCTVERSION 1,5,0,0
|
||||
FILEVERSION 1,7,2,0
|
||||
PRODUCTVERSION 1,7,2,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -78,12 +78,12 @@ BEGIN
|
|||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "WinBtrfs shell extension"
|
||||
VALUE "FileVersion", "1.5"
|
||||
VALUE "FileVersion", "1.7.2"
|
||||
VALUE "InternalName", "btrfs"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-19"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-20"
|
||||
VALUE "OriginalFilename", "shellbtrfs.dll"
|
||||
VALUE "ProductName", "WinBtrfs"
|
||||
VALUE "ProductVersion", "1.5"
|
||||
VALUE "ProductVersion", "1.7.2"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -112,8 +112,8 @@ BEGIN
|
|||
LTEXT "Group:",IDC_STATIC,14,141,22,8
|
||||
EDITTEXT IDC_UID,94,123,40,14,ES_AUTOHSCROLL | ES_NUMBER
|
||||
EDITTEXT IDC_GID,94,139,40,14,ES_AUTOHSCROLL | ES_NUMBER
|
||||
LTEXT "User",IDC_STATIC,14,172,15,8
|
||||
LTEXT "Group",IDC_STATIC,14,182,20,8
|
||||
LTEXT "User",IDC_STATIC,14,175,15,8
|
||||
LTEXT "Group",IDC_STATIC,14,186,20,8
|
||||
LTEXT "Others",IDC_STATIC,14,196,22,8
|
||||
LTEXT "Read",IDC_STATIC,50,162,17,8
|
||||
LTEXT "Write",IDC_STATIC,89,162,18,8
|
||||
|
@ -209,9 +209,11 @@ BEGIN
|
|||
CONTROL "DUP",IDC_PROFILES_DUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,29,10
|
||||
CONTROL "RAID0",IDC_PROFILES_RAID0,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,36,10
|
||||
CONTROL "RAID1",IDC_PROFILES_RAID1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,36,10
|
||||
CONTROL "RAID10",IDC_PROFILES_RAID10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,19,39,10
|
||||
CONTROL "RAID5",IDC_PROFILES_RAID5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,30,36,10
|
||||
CONTROL "RAID6",IDC_PROFILES_RAID6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,41,36,10
|
||||
CONTROL "RAID10",IDC_PROFILES_RAID10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,63,39,10
|
||||
CONTROL "RAID5",IDC_PROFILES_RAID5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,19,36,10
|
||||
CONTROL "RAID6",IDC_PROFILES_RAID6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,30,36,10
|
||||
CONTROL "RAID1C3",IDC_PROFILES_RAID1C3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,41,44,10
|
||||
CONTROL "RAID1C4",IDC_PROFILES_RAID1C4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,52,44,10
|
||||
CONTROL "&Usage:",IDC_USAGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,80,37,10
|
||||
EDITTEXT IDC_USAGE_START,7,94,19,14,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_USAGE_START_SPINNER,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,25,94,11,14
|
||||
|
@ -535,6 +537,11 @@ BEGIN
|
|||
0
|
||||
END
|
||||
|
||||
IDD_BALANCE_OPTIONS AFX_DIALOG_LAYOUT
|
||||
BEGIN
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -627,9 +634,9 @@ BEGIN
|
|||
IDS_DEVLIST_READONLY_NO "No"
|
||||
IDS_DEVLIST_ALLOC "Allocated"
|
||||
IDS_DEVLIST_ALLOC_PC "%"
|
||||
IDS_BALANCE_RUNNING_REMOVAL
|
||||
IDS_BALANCE_RUNNING_REMOVAL
|
||||
"Currently removing device %llu (%llu out of %llu chunks processed, %1.1f%%)"
|
||||
IDS_BALANCE_PAUSED_REMOVAL
|
||||
IDS_BALANCE_PAUSED_REMOVAL
|
||||
"Removal of device %llu paused (%llu out of %llu chunks processed, %1.1f%%)"
|
||||
IDS_BALANCE_CANCELLED_REMOVAL "Device removal cancelled."
|
||||
IDS_BALANCE_COMPLETE_REMOVAL "Device removal completed successfully."
|
||||
|
@ -640,12 +647,12 @@ END
|
|||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_CANNOT_REMOVE_RAID "The current RAID levels do not allow this device to be removed. You must do a conversion balance before you will be able to proceed."
|
||||
IDS_REMOVE_DEVICE_CONFIRMATION
|
||||
IDS_REMOVE_DEVICE_CONFIRMATION
|
||||
"Are you sure that you want to remove device %s, %s?"
|
||||
IDS_CONFIRMATION_TITLE "Confirmation"
|
||||
IDS_ADD_DEVICE_CONFIRMATION
|
||||
IDS_ADD_DEVICE_CONFIRMATION
|
||||
"Are you sure that you want to add this device?"
|
||||
IDS_ADD_DEVICE_CONFIRMATION_FS
|
||||
IDS_ADD_DEVICE_CONFIRMATION_FS
|
||||
"Are you sure that you want to add this device? It already appears to contain a filesystem (%s)."
|
||||
IDS_BALANCE_FAILED "Balance failed (error %08x, %s)"
|
||||
IDS_BALANCE_FAILED_REMOVAL "Device removal failed (error %08x, %s)"
|
||||
|
@ -656,32 +663,32 @@ BEGIN
|
|||
IDS_SCRUB_FINISHED "Scrub finished."
|
||||
IDS_SCRUB_PAUSED "Scrub paused (%llu out of %llu chunks processed, %1.1f%%)"
|
||||
IDS_SCRUB_MSG_STARTED "Scrub started at %s %s."
|
||||
IDS_SCRUB_MSG_RECOVERABLE_DATA
|
||||
IDS_SCRUB_MSG_RECOVERABLE_DATA
|
||||
"Recovered from data checksum error at %llx on device %llx."
|
||||
IDS_SCRUB_MSG_RECOVERABLE_METADATA
|
||||
IDS_SCRUB_MSG_RECOVERABLE_METADATA
|
||||
"Recovered from metadata checksum error at %llx on device %llx."
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_DATA
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_DATA
|
||||
"Unrecoverable data checksum error at %llx on device %llx (%.*s, offset %llx)"
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_DATA_SUBVOL
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_DATA_SUBVOL
|
||||
"Unrecoverable data checksum error at %llx on device %llx (subvol %llx, %.*s, offset %llx)"
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_METADATA
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_METADATA
|
||||
"Unrecoverable metadata checksum error at %llx on device %llx (root %llx, level %x)"
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_METADATA_FIRSTITEM
|
||||
IDS_SCRUB_MSG_UNRECOVERABLE_METADATA_FIRSTITEM
|
||||
"Unrecoverable metadata checksum error at %llx on device %llx (root %llx, level %x, first item %llx,%x,%llx)"
|
||||
IDS_SCRUB_MSG_FINISHED "Scrub finished at %s %s."
|
||||
IDS_SCRUB_MSG_SUMMARY "Scrubbed %s in %llu seconds (%s/s)."
|
||||
IDS_BALANCE_SCRUB_RUNNING "Cannot start balance while scrub running."
|
||||
IDS_SCRUB_BALANCE_RUNNING "Cannot start scrub while balance running."
|
||||
IDS_SCRUB_MSG_SUMMARY_ERRORS_RECOVERABLE "Recovered from %llu error(s)."
|
||||
IDS_SCRUB_MSG_SUMMARY_ERRORS_UNRECOVERABLE
|
||||
IDS_SCRUB_MSG_SUMMARY_ERRORS_UNRECOVERABLE
|
||||
"%llu unrecoverable error(s) found."
|
||||
IDS_SCRUB_FAILED "Scrub failed with error %08x."
|
||||
IDS_LOCK_FAILED "Unable to lock volume: error %08x. Make sure that there are no files open, and that you have closed any Explorer windows."
|
||||
IDS_SCRUB_MSG_RECOVERABLE_PARITY
|
||||
IDS_SCRUB_MSG_RECOVERABLE_PARITY
|
||||
"Recovered from parity error at %llx on device %llx."
|
||||
IDS_COMPRESS_ANY "(any)"
|
||||
IDS_COMPRESS_ZLIB "Zlib"
|
||||
|
@ -700,12 +707,13 @@ BEGIN
|
|||
IDS_OUT_OF_MEMORY "Out of memory."
|
||||
IDS_RECV_UNKNOWN_COMMAND "Unrecognized command %u encountered."
|
||||
IDS_RECV_CANT_OPEN_PATH "Couldn't open path %s (error %u, %s)."
|
||||
IDS_RECV_CREATE_SUBVOL_FAILED
|
||||
IDS_RAID1C3 "RAID1C3"
|
||||
IDS_RECV_CREATE_SUBVOL_FAILED
|
||||
"FSCTL_BTRFS_CREATE_SUBVOL returned %08x (%s)."
|
||||
IDS_RECV_MISSING_PARAM "%S: could not find %s parameter."
|
||||
IDS_RECV_SHORT_PARAM "%S: length of parameter %s was %u, expected %u."
|
||||
IDS_RECV_MKNOD_FAILED "FSCTL_BTRFS_MKNOD returned %08x (%s)."
|
||||
IDS_RECV_SET_REPARSE_POINT_FAILED
|
||||
IDS_RECV_SET_REPARSE_POINT_FAILED
|
||||
"FSCTL_SET_REPARSE_POINT returned %08x (%s)."
|
||||
END
|
||||
|
||||
|
@ -714,17 +722,18 @@ BEGIN
|
|||
IDS_RECV_MOVEFILE_FAILED "MoveFile (%s -> %s) failed (error %u, %s)."
|
||||
IDS_RECV_SETFILEPOINTER_FAILED "SetFilePointer failed (error %u, %s)."
|
||||
IDS_RECV_WRITEFILE_FAILED "WriteFile failed (error %u, %s)."
|
||||
IDS_RECV_CREATEHARDLINK_FAILED
|
||||
IDS_RECV_CREATEHARDLINK_FAILED
|
||||
"CreateHardLink (%s -> %s) failed (error %u, %s)."
|
||||
IDS_RECV_SETENDOFFILE_FAILED "SetEndOfFile failed (error %u, %s)."
|
||||
IDS_RECV_CANT_CREATE_FILE "Couldn't create %s (error %u, %s)."
|
||||
IDS_RECV_SETINODEINFO_FAILED
|
||||
IDS_RAID1C4 "RAID1C4"
|
||||
IDS_RECV_SETINODEINFO_FAILED
|
||||
"FSCTL_BTRFS_SET_INODE_INFO returned %08x (%s)."
|
||||
IDS_RECV_SUCCESS "Received 1 subvolume successfully."
|
||||
IDS_RECV_BUTTON_OK "OK"
|
||||
IDS_RECV_SETFILEATTRIBUTES_FAILED
|
||||
IDS_RECV_SETFILEATTRIBUTES_FAILED
|
||||
"SetFileAttributes failed (error %u, %s)."
|
||||
IDS_RECV_GETFILEATTRIBUTES_FAILED
|
||||
IDS_RECV_GETFILEATTRIBUTES_FAILED
|
||||
"GetFileAttributes failed (error %u, %s)."
|
||||
IDS_RECV_CSUM_ERROR "Checksum error."
|
||||
IDS_RECV_NOT_A_SEND_STREAM "File was not a send stream."
|
||||
|
@ -734,28 +743,28 @@ END
|
|||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_RECV_RECEIVED_SUBVOL_FAILED
|
||||
IDS_RECV_RECEIVED_SUBVOL_FAILED
|
||||
"FSCTL_BTRFS_RECEIVED_SUBVOL returned %08x (%s)."
|
||||
IDS_RECV_SETSECURITYOBJECT_FAILED
|
||||
IDS_RECV_SETSECURITYOBJECT_FAILED
|
||||
"NtSetSecurityObject returned %08x (%s)."
|
||||
IDS_RECV_SETXATTR_FAILED "FSCTL_BTRFS_SET_XATTR returned %08x (%s)."
|
||||
IDS_RECV_CREATETHREAD_FAILED "CreateThread failed (error %u, %s)."
|
||||
IDS_RECV_FILE_TRUNCATED "File was truncated."
|
||||
IDS_RECV_RESERVE_SUBVOL_FAILED
|
||||
IDS_RECV_RESERVE_SUBVOL_FAILED
|
||||
"FSCTL_BTRFS_RESERVE_SUBVOL returned %08x (%s)."
|
||||
IDS_RECV_CANCELLED "Receiving cancelled."
|
||||
IDS_RECV_CANT_FIND_PARENT_SUBVOL "Could not find parent subvolume."
|
||||
IDS_RECV_FIND_SUBVOL_FAILED "FSCTL_BTRFS_FIND_SUBVOL returned %08x (%s)."
|
||||
IDS_RECV_CREATE_SNAPSHOT_FAILED
|
||||
IDS_RECV_CREATE_SNAPSHOT_FAILED
|
||||
"FSCTL_BTRFS_CREATE_SNAPSHOT returned %08x (%s)."
|
||||
IDS_RECV_GETVOLUMEPATHNAME_FAILED
|
||||
IDS_RECV_GETVOLUMEPATHNAME_FAILED
|
||||
"GetVolumePathName failed (error %u, %s)."
|
||||
IDS_RECV_DELETEFILE_FAILED "DeleteFile failed for %s (error %u, %s)."
|
||||
IDS_RECV_REMOVEDIRECTORY_FAILED
|
||||
IDS_RECV_REMOVEDIRECTORY_FAILED
|
||||
"RemoveDirectory failed for %s (error %u, %s)."
|
||||
IDS_RECV_CANT_FIND_CLONE_SUBVOL "Could not find clone subvolume."
|
||||
IDS_RECV_GETFILESIZEEX_FAILED "GetFileSizeEx failed (error %u, %s)."
|
||||
IDS_RECV_DUPLICATE_EXTENTS_FAILED
|
||||
IDS_RECV_DUPLICATE_EXTENTS_FAILED
|
||||
"FSCTL_DUPLICATE_EXTENTS_TO_FILE returned %08x (%s)."
|
||||
END
|
||||
|
||||
|
@ -766,13 +775,13 @@ BEGIN
|
|||
IDS_SEND_SUBVOL_HELP "Exports a subvolume so that it can be recreated on another volume."
|
||||
IDS_SEND_CANT_OPEN_FILE "Error opening file %s (error %u, %s)."
|
||||
IDS_SEND_CANT_OPEN_DIR "Error opening directory %s (error %u, %s)."
|
||||
IDS_SEND_FSCTL_BTRFS_SEND_SUBVOL_FAILED
|
||||
IDS_SEND_FSCTL_BTRFS_SEND_SUBVOL_FAILED
|
||||
"FSCTL_BTRFS_SEND_SUBVOL returned error %08x (%s)."
|
||||
IDS_SEND_FSCTL_BTRFS_READ_SEND_BUFFER_FAILED
|
||||
IDS_SEND_FSCTL_BTRFS_READ_SEND_BUFFER_FAILED
|
||||
"FSCTL_BTRFS_READ_SEND_BUFFER returned error %08x (%s)."
|
||||
IDS_SEND_SUCCESS "Stream written successfully."
|
||||
IDS_SEND_WRITEFILE_FAILED "Writing to file failed (error %u, %s)."
|
||||
IDS_SEND_GET_FILE_INFO_FAILED
|
||||
IDS_SEND_GET_FILE_INFO_FAILED
|
||||
"GetFileInformationByHandle failed (error %u, %s)."
|
||||
IDS_SEND_NOT_READONLY "Subvolume not readonly."
|
||||
IDS_NOT_SUBVOL "Directory was not a subvolume."
|
||||
|
@ -788,9 +797,9 @@ BEGIN
|
|||
IDS_SEND_WRITING "Writing..."
|
||||
IDS_MISSING "(missing)"
|
||||
IDS_RESIZE_SUCCESSFUL "Device %llx successfully resized to %s."
|
||||
IDS_BALANCE_RUNNING_SHRINK
|
||||
IDS_BALANCE_RUNNING_SHRINK
|
||||
"Currently shrinking device %llu (%llu out of %llu chunks processed, %1.1f%%)"
|
||||
IDS_BALANCE_PAUSED_SHRINK
|
||||
IDS_BALANCE_PAUSED_SHRINK
|
||||
"Shrinking of device %llu paused (%llu out of %llu chunks processed, %1.1f%%)"
|
||||
IDS_BALANCE_CANCELLED_SHRINK "Device shrinking cancelled."
|
||||
IDS_BALANCE_COMPLETE_SHRINK "Device successfully shrunk."
|
||||
|
@ -799,7 +808,7 @@ BEGIN
|
|||
IDS_REGCREATEKEY_FAILED "RegCreateKey returned %08x"
|
||||
IDS_REGSETVALUEEX_FAILED "RegSetValueEx returned %08x"
|
||||
IDS_REGCLOSEKEY_FAILED "RegCloseKey returned %08x"
|
||||
IDS_CANT_REFLINK_DIFFERENT_FS
|
||||
IDS_CANT_REFLINK_DIFFERENT_FS
|
||||
"Cannot create a reflink between two different filesystems."
|
||||
END
|
||||
|
||||
|
|
|
@ -172,8 +172,12 @@ void BtrfsVolPropSheet::FormatUsage(HWND hwndDlg, wstring& s, btrfs_usage* usage
|
|||
|
||||
static const uint64_t types[] = { BLOCK_FLAG_DATA, BLOCK_FLAG_DATA | BLOCK_FLAG_METADATA, BLOCK_FLAG_METADATA, BLOCK_FLAG_SYSTEM };
|
||||
static const ULONG typestrings[] = { IDS_USAGE_DATA, IDS_USAGE_MIXED, IDS_USAGE_METADATA, IDS_USAGE_SYSTEM };
|
||||
static const uint64_t duptypes[] = { 0, BLOCK_FLAG_DUPLICATE, BLOCK_FLAG_RAID0, BLOCK_FLAG_RAID1, BLOCK_FLAG_RAID10, BLOCK_FLAG_RAID5, BLOCK_FLAG_RAID6 };
|
||||
static const ULONG dupstrings[] = { IDS_SINGLE, IDS_DUP, IDS_RAID0, IDS_RAID1, IDS_RAID10, IDS_RAID5, IDS_RAID6 };
|
||||
static const uint64_t duptypes[] = { 0, BLOCK_FLAG_DUPLICATE, BLOCK_FLAG_RAID0, BLOCK_FLAG_RAID1, BLOCK_FLAG_RAID10, BLOCK_FLAG_RAID5,
|
||||
BLOCK_FLAG_RAID6, BLOCK_FLAG_RAID1C3, BLOCK_FLAG_RAID1C4 };
|
||||
static const ULONG dupstrings[] = { IDS_SINGLE, IDS_DUP, IDS_RAID0, IDS_RAID1, IDS_RAID10, IDS_RAID5, IDS_RAID6, IDS_RAID1C3, IDS_RAID1C4 };
|
||||
|
||||
static const uint64_t raid_types = BLOCK_FLAG_DUPLICATE | BLOCK_FLAG_RAID0 | BLOCK_FLAG_RAID1 | BLOCK_FLAG_RAID10 | BLOCK_FLAG_RAID5 |
|
||||
BLOCK_FLAG_RAID6 | BLOCK_FLAG_RAID1C3 | BLOCK_FLAG_RAID1C4;
|
||||
|
||||
s = L"";
|
||||
|
||||
|
@ -327,9 +331,7 @@ void BtrfsVolPropSheet::FormatUsage(HWND hwndDlg, wstring& s, btrfs_usage* usage
|
|||
bue = usage;
|
||||
|
||||
while (true) {
|
||||
if ((bue->type & types[i]) == types[i] &&
|
||||
((duptypes[j] == 0 && (bue->type & (BLOCK_FLAG_DUPLICATE | BLOCK_FLAG_RAID0 | BLOCK_FLAG_RAID1 | BLOCK_FLAG_RAID10 | BLOCK_FLAG_RAID5 | BLOCK_FLAG_RAID6)) == 0)
|
||||
|| bue->type & duptypes[j])) {
|
||||
if ((bue->type & types[i]) == types[i] && ((duptypes[j] == 0 && (bue->type & raid_types) == 0) || bue->type & duptypes[j])) {
|
||||
wstring sizestring, usedstring, typestring, dupstring;
|
||||
|
||||
if (bue->type & BLOCK_FLAG_DATA && bue->type & BLOCK_FLAG_METADATA && (types[i] == BLOCK_FLAG_DATA || types[i] == BLOCK_FLAG_METADATA))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by ubtrfs.rc
|
||||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
|
|
|
@ -51,8 +51,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,5,0,0
|
||||
PRODUCTVERSION 1,5,0,0
|
||||
FILEVERSION 1,7,2,0
|
||||
PRODUCTVERSION 1,7,2,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -68,12 +68,12 @@ BEGIN
|
|||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "Btrfs utility DLL"
|
||||
VALUE "FileVersion", "1.5"
|
||||
VALUE "FileVersion", "1.7.2"
|
||||
VALUE "InternalName", "ubtrfs"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-19"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-20"
|
||||
VALUE "OriginalFilename", "ubtrfs.dll"
|
||||
VALUE "ProductName", "WinBtrfs"
|
||||
VALUE "ProductVersion", "1.5"
|
||||
VALUE "ProductVersion", "1.7.2"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -5,6 +5,7 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers
|
|||
|
||||
list(APPEND SOURCE
|
||||
balance.c
|
||||
blake2b-ref.c
|
||||
boot.c
|
||||
btrfs.c
|
||||
cache.c
|
||||
|
@ -30,11 +31,13 @@ list(APPEND SOURCE
|
|||
scrub.c
|
||||
search.c
|
||||
security.c
|
||||
sha256.c
|
||||
send.c
|
||||
treefuncs.c
|
||||
volume.c
|
||||
worker-thread.c
|
||||
write.c
|
||||
xxhash.c
|
||||
zstd/entropy_common.c
|
||||
zstd/fse_compress.c
|
||||
zstd/hist.c
|
||||
|
@ -46,14 +49,21 @@ list(APPEND SOURCE
|
|||
zstd/error_private.c
|
||||
zstd/fse_decompress.c
|
||||
zstd/huf_compress.c
|
||||
zstd/xxhash.c
|
||||
zstd/zstd_compress.c
|
||||
zstd/zstd_double_fast.c
|
||||
zstd/zstd_lazy.c
|
||||
zstd/zstd_opt.c
|
||||
btrfs_drv.h)
|
||||
|
||||
add_library(btrfs MODULE ${SOURCE} btrfs.rc)
|
||||
if(ARCH STREQUAL "i386")
|
||||
list(APPEND ASM_SOURCE crc32c-x86.S)
|
||||
elseif(ARCH STREQUAL "amd64")
|
||||
list(APPEND ASM_SOURCE crc32c-amd64.S)
|
||||
endif()
|
||||
|
||||
add_asm_files(btrfs_asm ${ASM_SOURCE})
|
||||
|
||||
add_library(btrfs MODULE ${SOURCE} ${btrfs_asm} btrfs.rc)
|
||||
|
||||
add_definitions(-D__KERNEL__)
|
||||
set_module_type(btrfs kernelmodedriver)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "btrfs_drv.h"
|
||||
#include "btrfsioctl.h"
|
||||
#include "crc32c.h"
|
||||
#include <ntddstor.h>
|
||||
|
||||
typedef struct {
|
||||
|
@ -96,7 +97,7 @@ static NTSTATUS add_metadata_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_l
|
|||
|
||||
Status = delete_tree_item(Vcb, tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(mr);
|
||||
return Status;
|
||||
}
|
||||
|
@ -191,7 +192,7 @@ static NTSTATUS add_metadata_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_l
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (tp2.item->key.obj_type == TYPE_SHARED_BLOCK_REF) {
|
||||
|
@ -209,7 +210,7 @@ static NTSTATUS add_metadata_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_l
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +253,7 @@ static NTSTATUS add_metadata_reloc_parent(_Requires_exclusive_lock_held_(_Curr_-
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -273,7 +274,7 @@ static NTSTATUS add_metadata_reloc_parent(_Requires_exclusive_lock_held_(_Curr_-
|
|||
|
||||
Status = add_metadata_reloc(Vcb, items, &tp, skinny, mr2, NULL, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -414,7 +415,7 @@ static NTSTATUS add_metadata_reloc_extent_item(_Requires_exclusive_lock_held_(_C
|
|||
Status = insert_tree_item(Vcb, Vcb->extent_root, mr->new_address, TYPE_EXTENT_ITEM, Vcb->superblock.node_size, ei, inline_len, NULL, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(ei);
|
||||
return Status;
|
||||
}
|
||||
|
@ -428,13 +429,13 @@ static NTSTATUS add_metadata_reloc_extent_item(_Requires_exclusive_lock_held_(_C
|
|||
if (ref->type == TYPE_TREE_BLOCK_REF) {
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, mr->new_address, TYPE_TREE_BLOCK_REF, ref->tbr.offset, NULL, 0, NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (ref->type == TYPE_SHARED_BLOCK_REF) {
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, mr->new_address, TYPE_SHARED_BLOCK_REF, ref->parent->new_address, NULL, 0, NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -458,7 +459,7 @@ static NTSTATUS add_metadata_reloc_extent_item(_Requires_exclusive_lock_held_(_C
|
|||
|
||||
Status = increase_extent_refcount(Vcb, in[i].address, Vcb->superblock.node_size, TYPE_SHARED_BLOCK_REF, &sbr, NULL, 0, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("increase_extent_refcount returned %08x\n", Status);
|
||||
ERR("increase_extent_refcount returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -467,7 +468,7 @@ static NTSTATUS add_metadata_reloc_extent_item(_Requires_exclusive_lock_held_(_C
|
|||
Status = decrease_extent_refcount(Vcb, in[i].address, Vcb->superblock.node_size, TYPE_SHARED_BLOCK_REF, &sbr, NULL, 0,
|
||||
sbr.offset, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("decrease_extent_refcount returned %08x\n", Status);
|
||||
ERR("decrease_extent_refcount returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -495,7 +496,7 @@ static NTSTATUS add_metadata_reloc_extent_item(_Requires_exclusive_lock_held_(_C
|
|||
|
||||
Status = increase_extent_refcount(Vcb, ed2->address, ed2->size, TYPE_SHARED_DATA_REF, &sdr, NULL, 0, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("increase_extent_refcount returned %08x\n", Status);
|
||||
ERR("increase_extent_refcount returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -504,7 +505,7 @@ static NTSTATUS add_metadata_reloc_extent_item(_Requires_exclusive_lock_held_(_C
|
|||
Status = decrease_extent_refcount(Vcb, ed2->address, ed2->size, TYPE_SHARED_DATA_REF, &sdr, NULL, 0,
|
||||
sdr.offset, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("decrease_extent_refcount returned %08x\n", Status);
|
||||
ERR("decrease_extent_refcount returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -591,7 +592,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
Status = read_data(Vcb, mr->address, Vcb->superblock.node_size, NULL, true, (uint8_t*)mr->data,
|
||||
c && mr->address >= c->offset && mr->address < c->offset + c->chunk_item->size ? c : NULL, &pc, NULL, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -656,7 +657,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = find_item_to_level(Vcb, r, &tp, firstitem, false, mr->data->level + 1, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("find_item_to_level returned %08x\n", Status);
|
||||
ERR("find_item_to_level returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -672,7 +673,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = add_metadata_reloc_parent(Vcb, items, t->header.address, &mr2, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc_parent returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc_parent returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -683,7 +684,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = add_metadata_reloc_parent(Vcb, items, ref->sbr.offset, &mr2, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc_parent returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc_parent returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -788,7 +789,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
Status = alloc_chunk(Vcb, flags, &newchunk, false);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
goto end;
|
||||
}
|
||||
|
@ -880,7 +881,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -901,13 +902,13 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->root_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, ri, sizeof(ROOT_ITEM), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1026,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
t3 = t4;
|
||||
}
|
||||
|
||||
*((uint32_t*)mr->data) = ~calc_crc32c(0xffffffff, (uint8_t*)&mr->data->fs_uuid, Vcb->superblock.node_size - sizeof(mr->data->csum));
|
||||
calc_tree_checksum(Vcb, mr->data);
|
||||
|
||||
tw = ExAllocatePoolWithTag(PagedPool, sizeof(tree_write), ALLOC_TAG);
|
||||
if (!tw) {
|
||||
|
@ -1068,7 +1069,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = do_tree_writes(Vcb, &tree_writes, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_tree_writes returned %08x\n", Status);
|
||||
ERR("do_tree_writes returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1078,7 +1079,7 @@ static NTSTATUS write_metadata_items(_Requires_exclusive_lock_held_(_Curr_->tree
|
|||
|
||||
Status = add_metadata_reloc_extent_item(Vcb, mr);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc_extent_item returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc_extent_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1122,7 @@ static NTSTATUS balance_metadata_chunk(device_extension* Vcb, chunk* c, bool* ch
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1150,7 @@ static NTSTATUS balance_metadata_chunk(device_extension* Vcb, chunk* c, bool* ch
|
|||
Status = add_metadata_reloc(Vcb, &items, &tp, skinny, NULL, c, &rollback);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1175,7 +1176,7 @@ static NTSTATUS balance_metadata_chunk(device_extension* Vcb, chunk* c, bool* ch
|
|||
|
||||
Status = write_metadata_items(Vcb, &items, NULL, c, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_metadata_items returned %08x\n", Status);
|
||||
ERR("write_metadata_items returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1188,7 @@ end:
|
|||
if (NT_SUCCESS(Status)) {
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -1241,7 +1242,7 @@ static NTSTATUS data_reloc_add_tree_edr(_Requires_lock_held_(_Curr_->tree_lock)
|
|||
}
|
||||
|
||||
if (!r) {
|
||||
ERR("could not find subvol %I64x\n", edr->count);
|
||||
ERR("could not find subvol %I64x\n", edr->root);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1252,7 @@ static NTSTATUS data_reloc_add_tree_edr(_Requires_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = find_item(Vcb, r, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1293,7 +1294,7 @@ static NTSTATUS data_reloc_add_tree_edr(_Requires_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = add_metadata_reloc_parent(Vcb, metadata_items, tp.tree->header.address, &mr, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc_parent returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc_parent returned %08lx\n", Status);
|
||||
ExFreePool(ref);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1338,7 +1339,7 @@ static NTSTATUS add_data_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = delete_tree_item(Vcb, tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1384,7 +1385,7 @@ static NTSTATUS add_data_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = data_reloc_add_tree_edr(Vcb, metadata_items, dr, edr, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("data_reloc_add_tree_edr returned %08x\n", Status);
|
||||
ERR("data_reloc_add_tree_edr returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (secttype == TYPE_SHARED_DATA_REF) {
|
||||
|
@ -1403,7 +1404,7 @@ static NTSTATUS add_data_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = add_metadata_reloc_parent(Vcb, metadata_items, ref->sdr.offset, &mr, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc_parent returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc_parent returned %08lx\n", Status);
|
||||
ExFreePool(ref);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1431,13 +1432,13 @@ static NTSTATUS add_data_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
if (tp2.item->key.obj_type == TYPE_EXTENT_DATA_REF && tp2.item->size >= sizeof(EXTENT_DATA_REF)) {
|
||||
Status = data_reloc_add_tree_edr(Vcb, metadata_items, dr, (EXTENT_DATA_REF*)tp2.item->data, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("data_reloc_add_tree_edr returned %08x\n", Status);
|
||||
ERR("data_reloc_add_tree_edr returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (tp2.item->key.obj_type == TYPE_SHARED_DATA_REF && tp2.item->size >= sizeof(uint32_t)) {
|
||||
|
@ -1456,7 +1457,7 @@ static NTSTATUS add_data_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = add_metadata_reloc_parent(Vcb, metadata_items, ref->sdr.offset, &mr, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_metadata_reloc_parent returned %08x\n", Status);
|
||||
ERR("add_metadata_reloc_parent returned %08lx\n", Status);
|
||||
ExFreePool(ref);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1466,7 +1467,7 @@ static NTSTATUS add_data_reloc(_Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1620,7 +1621,7 @@ static NTSTATUS add_data_reloc_extent_item(_Requires_exclusive_lock_held_(_Curr_
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, dr->new_address, TYPE_EXTENT_ITEM, dr->size, ei, inline_len, NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1643,7 +1644,7 @@ static NTSTATUS add_data_reloc_extent_item(_Requires_exclusive_lock_held_(_Curr_
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, dr->new_address, TYPE_EXTENT_DATA_REF, ref->hash, edr, sizeof(EXTENT_DATA_REF), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (ref->type == TYPE_SHARED_DATA_REF) {
|
||||
|
@ -1659,7 +1660,7 @@ static NTSTATUS add_data_reloc_extent_item(_Requires_exclusive_lock_held_(_Curr_
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, dr->new_address, TYPE_SHARED_DATA_REF, ref->parent->new_address, sdr, sizeof(uint32_t), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1695,7 +1696,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1720,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
Status = add_data_reloc(Vcb, &items, &metadata_items, &tp, c, &rollback);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_data_reloc returned %08x\n", Status);
|
||||
ERR("add_data_reloc returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1756,7 +1757,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
data_reloc* dr = CONTAINING_RECORD(le, data_reloc, list_entry);
|
||||
bool done = false;
|
||||
LIST_ENTRY* le2;
|
||||
uint32_t* csum;
|
||||
void* csum;
|
||||
RTL_BITMAP bmp;
|
||||
ULONG* bmparr;
|
||||
ULONG bmplen, runlength, index, lastoff;
|
||||
|
@ -1805,7 +1806,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
Status = alloc_chunk(Vcb, Vcb->data_flags, &newchunk, false);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1842,7 +1843,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
goto end;
|
||||
}
|
||||
|
||||
csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(dr->size * sizeof(uint32_t) / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(dr->size * Vcb->csum_size / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
if (!csum) {
|
||||
ERR("out of memory\n");
|
||||
ExFreePool(bmparr);
|
||||
|
@ -1859,7 +1860,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
|
||||
Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -1872,13 +1873,13 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
if (tp.item->key.obj_type == TYPE_EXTENT_CSUM) {
|
||||
if (tp.item->key.offset >= dr->address + dr->size)
|
||||
break;
|
||||
else if (tp.item->size >= sizeof(uint32_t) && tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / sizeof(uint32_t)) >= dr->address) {
|
||||
else if (tp.item->size >= Vcb->csum_size && tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / Vcb->csum_size) >= dr->address) {
|
||||
uint64_t cs = max(dr->address, tp.item->key.offset);
|
||||
uint64_t ce = min(dr->address + dr->size, tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / sizeof(uint32_t)));
|
||||
uint64_t ce = min(dr->address + dr->size, tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / Vcb->csum_size));
|
||||
|
||||
RtlCopyMemory(csum + ((cs - dr->address) / Vcb->superblock.sector_size),
|
||||
tp.item->data + ((cs - tp.item->key.offset) * sizeof(uint32_t) / Vcb->superblock.sector_size),
|
||||
(ULONG)((ce - cs) * sizeof(uint32_t) / Vcb->superblock.sector_size));
|
||||
RtlCopyMemory((uint8_t*)csum + ((cs - dr->address) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
tp.item->data + ((cs - tp.item->key.offset) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
(ULONG)((ce - cs) * Vcb->csum_size / Vcb->superblock.sector_size));
|
||||
|
||||
RtlClearBits(&bmp, (ULONG)((cs - dr->address) / Vcb->superblock.sector_size), (ULONG)((ce - cs) / Vcb->superblock.sector_size));
|
||||
|
||||
|
@ -1924,7 +1925,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
Status = read_data(Vcb, dr->address + (off * Vcb->superblock.sector_size), rl * Vcb->superblock.sector_size, NULL, false, data,
|
||||
c, NULL, NULL, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -1933,7 +1934,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
Status = write_data_complete(Vcb, dr->new_address + (off * Vcb->superblock.sector_size), data, rl * Vcb->superblock.sector_size,
|
||||
NULL, newchunk, false, 0, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_complete returned %08x\n", Status);
|
||||
ERR("write_data_complete returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -1944,7 +1945,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
} while (size > 0);
|
||||
}
|
||||
|
||||
add_checksum_entry(Vcb, dr->new_address + (index * Vcb->superblock.sector_size), runlength, &csum[index], NULL);
|
||||
add_checksum_entry(Vcb, dr->new_address + (index * Vcb->superblock.sector_size), runlength, (uint8_t*)csum + (index * Vcb->csum_size), NULL);
|
||||
add_checksum_entry(Vcb, dr->address + (index * Vcb->superblock.sector_size), runlength, NULL, NULL);
|
||||
|
||||
// handle csum run
|
||||
|
@ -1956,10 +1957,10 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
else
|
||||
rl = runlength;
|
||||
|
||||
Status = read_data(Vcb, dr->address + (index * Vcb->superblock.sector_size), rl * Vcb->superblock.sector_size, &csum[index], false, data,
|
||||
c, NULL, NULL, 0, false, NormalPagePriority);
|
||||
Status = read_data(Vcb, dr->address + (index * Vcb->superblock.sector_size), rl * Vcb->superblock.sector_size,
|
||||
(uint8_t*)csum + (index * Vcb->csum_size), false, data, c, NULL, NULL, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -1968,7 +1969,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
Status = write_data_complete(Vcb, dr->new_address + (index * Vcb->superblock.sector_size), data, rl * Vcb->superblock.sector_size,
|
||||
NULL, newchunk, false, 0, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_complete returned %08x\n", Status);
|
||||
ERR("write_data_complete returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -2001,14 +2002,14 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
Status = read_data(Vcb, dr->address + (off * Vcb->superblock.sector_size), rl * Vcb->superblock.sector_size, NULL, false, data,
|
||||
c, NULL, NULL, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = write_data_complete(Vcb, dr->new_address + (off * Vcb->superblock.sector_size), data, rl * Vcb->superblock.sector_size,
|
||||
NULL, newchunk, false, 0, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_complete returned %08x\n", Status);
|
||||
ERR("write_data_complete returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2025,7 +2026,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
|
||||
Status = write_metadata_items(Vcb, &metadata_items, &items, NULL, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_metadata_items returned %08x\n", Status);
|
||||
ERR("write_metadata_items returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2035,7 +2036,7 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, bool* change
|
|||
|
||||
Status = add_data_reloc_extent_item(Vcb, dr);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_data_reloc_extent_item returned %08x\n", Status);
|
||||
ERR("add_data_reloc_extent_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2117,7 +2118,7 @@ end:
|
|||
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status)) {
|
||||
|
@ -2217,6 +2218,10 @@ static __inline uint64_t get_chunk_dup_type(chunk* c) {
|
|||
return BLOCK_FLAG_RAID5;
|
||||
else if (c->chunk_item->type & BLOCK_FLAG_RAID6)
|
||||
return BLOCK_FLAG_RAID6;
|
||||
else if (c->chunk_item->type & BLOCK_FLAG_RAID1C3)
|
||||
return BLOCK_FLAG_RAID1C3;
|
||||
else if (c->chunk_item->type & BLOCK_FLAG_RAID1C4)
|
||||
return BLOCK_FLAG_RAID1C4;
|
||||
else
|
||||
return BLOCK_FLAG_SINGLE;
|
||||
}
|
||||
|
@ -2266,7 +2271,7 @@ static bool should_balance_chunk(device_extension* Vcb, uint8_t sort, chunk* c)
|
|||
factor = c->chunk_item->num_stripes - 1;
|
||||
else if (c->chunk_item->type & BLOCK_FLAG_RAID6)
|
||||
factor = c->chunk_item->num_stripes - 2;
|
||||
else // SINGLE, DUPLICATE, RAID1
|
||||
else // SINGLE, DUPLICATE, RAID1, RAID1C3, RAID1C4
|
||||
factor = 1;
|
||||
|
||||
physsize = c->chunk_item->size / factor;
|
||||
|
@ -2388,14 +2393,14 @@ static NTSTATUS add_balance_item(device_extension* Vcb) {
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!keycmp(tp.item->key, searchkey)) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2426,7 +2431,7 @@ static NTSTATUS add_balance_item(device_extension* Vcb) {
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->root_root, BALANCE_ITEM_ID, TYPE_TEMP_ITEM, 0, bi, sizeof(BALANCE_ITEM), NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(bi);
|
||||
goto end;
|
||||
}
|
||||
|
@ -2437,7 +2442,7 @@ end:
|
|||
if (NT_SUCCESS(Status)) {
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
free_trees(Vcb);
|
||||
|
@ -2460,20 +2465,20 @@ static NTSTATUS remove_balance_item(device_extension* Vcb) {
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!keycmp(tp.item->key, searchkey)) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2593,7 +2598,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
Status = do_write(Vcb, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
} else
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
|
@ -2610,7 +2615,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
|
||||
Status = find_item(Vcb, Vcb->chunk_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2618,7 +2623,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
Status = delete_tree_item(Vcb, &tp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -2631,7 +2636,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
|
||||
Status = find_item(Vcb, Vcb->dev_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2639,7 +2644,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
Status = delete_tree_item(Vcb, &tp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -2656,7 +2661,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
|
||||
free_trees(Vcb);
|
||||
|
||||
|
@ -2666,7 +2671,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
if (!dev->readonly && dev->devobj) {
|
||||
Status = remove_superblocks(dev);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("remove_superblocks returned %08x\n", Status);
|
||||
WARN("remove_superblocks returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
// remove entry in volume list
|
||||
|
@ -2693,13 +2698,13 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
|
||||
Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &FileObject, &mountmgr);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
else {
|
||||
MOUNTDEV_NAME mdn;
|
||||
|
||||
Status = dev_ioctl(dev->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, &mdn, sizeof(MOUNTDEV_NAME), true, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
else {
|
||||
MOUNTDEV_NAME* mdn2;
|
||||
ULONG mdnsize = (ULONG)offsetof(MOUNTDEV_NAME, Name[0]) + mdn.NameLength;
|
||||
|
@ -2710,7 +2715,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
else {
|
||||
Status = dev_ioctl(dev->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, mdn2, mdnsize, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
else {
|
||||
UNICODE_STRING name;
|
||||
|
||||
|
@ -2719,7 +2724,7 @@ static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
|
||||
Status = mountmgr_add_drive_letter(mountmgr, &name);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("mountmgr_add_drive_letter returned %08x\n", Status);
|
||||
WARN("mountmgr_add_drive_letter returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
ExFreePool(mdn2);
|
||||
|
@ -2817,7 +2822,7 @@ static void trim_unalloc_space(_Requires_lock_held_(_Curr_->tree_lock) device_ex
|
|||
|
||||
Status = find_item(Vcb, Vcb->dev_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2833,7 +2838,7 @@ static void trim_unalloc_space(_Requires_lock_held_(_Curr_->tree_lock) device_ex
|
|||
|
||||
lastoff = tp.item->key.offset + de->length;
|
||||
} else {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(DEV_EXTENT));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(DEV_EXTENT));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2885,7 +2890,7 @@ static void trim_unalloc_space(_Requires_lock_held_(_Curr_->tree_lock) device_ex
|
|||
|
||||
Status = dev_ioctl(dev->devobj, IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES, dmdsa, datalen, NULL, 0, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES returned %08x\n", Status);
|
||||
WARN("IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES returned %08lx\n", Status);
|
||||
|
||||
ExFreePool(dmdsa);
|
||||
|
||||
|
@ -2947,7 +2952,7 @@ static NTSTATUS try_consolidation(device_extension* Vcb, uint64_t flags, chunk**
|
|||
|
||||
Status = balance_data_chunk(Vcb, rc, &changed);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("balance_data_chunk returned %08x\n", Status);
|
||||
ERR("balance_data_chunk returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
rc->list_entry_balance.Flink = NULL;
|
||||
rc->reloc = false;
|
||||
|
@ -2971,7 +2976,7 @@ static NTSTATUS try_consolidation(device_extension* Vcb, uint64_t flags, chunk**
|
|||
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2988,7 +2993,7 @@ static NTSTATUS try_consolidation(device_extension* Vcb, uint64_t flags, chunk**
|
|||
*newchunk = rc;
|
||||
return Status;
|
||||
} else {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -3027,7 +3032,7 @@ static NTSTATUS regenerate_space_list(device_extension* Vcb, device* dev) {
|
|||
factor = c->chunk_item->num_stripes - 1;
|
||||
else if (c->chunk_item->type & BLOCK_FLAG_RAID6)
|
||||
factor = c->chunk_item->num_stripes - 2;
|
||||
else // SINGLE, DUP, RAID1
|
||||
else // SINGLE, DUP, RAID1, RAID1C3, RAID1C4
|
||||
factor = 1;
|
||||
|
||||
stripe_size = c->chunk_item->size / factor;
|
||||
|
@ -3092,7 +3097,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (!Vcb->balance.removing && !Vcb->balance.shrinking) {
|
||||
Status = add_balance_item(Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_balance_item returned %08x\n", Status);
|
||||
ERR("add_balance_item returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3103,7 +3108,7 @@ void __stdcall balance_thread(void* context) {
|
|||
free_trees(Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3155,7 +3160,7 @@ void __stdcall balance_thread(void* context) {
|
|||
Status = load_cache_chunk(Vcb, c, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("load_cache_chunk returned %08x\n", Status);
|
||||
ERR("load_cache_chunk returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
release_chunk_lock(c, Vcb);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
|
@ -3182,7 +3187,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (NT_SUCCESS(Status))
|
||||
c->balance_num = Vcb->balance.balance_num;
|
||||
else if (Status != STATUS_DISK_FULL || consolidated) {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
|
@ -3193,7 +3198,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (Status == STATUS_DISK_FULL) {
|
||||
Status = try_consolidation(Vcb, Vcb->metadata_flags, &c);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("try_consolidation returned %08x\n", Status);
|
||||
ERR("try_consolidation returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
} else
|
||||
|
@ -3213,7 +3218,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (NT_SUCCESS(Status))
|
||||
c->balance_num = Vcb->balance.balance_num;
|
||||
else if (Status != STATUS_DISK_FULL || consolidated) {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
|
@ -3224,7 +3229,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (Status == STATUS_DISK_FULL) {
|
||||
Status = try_consolidation(Vcb, Vcb->data_flags, &c);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("try_consolidation returned %08x\n", Status);
|
||||
ERR("try_consolidation returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
} else
|
||||
|
@ -3244,7 +3249,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (NT_SUCCESS(Status))
|
||||
c->balance_num = Vcb->balance.balance_num;
|
||||
else if (Status != STATUS_DISK_FULL || consolidated) {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
|
@ -3255,7 +3260,7 @@ void __stdcall balance_thread(void* context) {
|
|||
if (Status == STATUS_DISK_FULL) {
|
||||
Status = try_consolidation(Vcb, Vcb->system_flags, &c);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("try_consolidation returned %08x\n", Status);
|
||||
ERR("try_consolidation returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
} else
|
||||
|
@ -3296,7 +3301,7 @@ void __stdcall balance_thread(void* context) {
|
|||
|
||||
Status = balance_data_chunk(Vcb, c, &changed);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("balance_data_chunk returned %08x\n", Status);
|
||||
ERR("balance_data_chunk returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3340,7 +3345,7 @@ void __stdcall balance_thread(void* context) {
|
|||
do {
|
||||
Status = balance_metadata_chunk(Vcb, c, &changed);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("balance_metadata_chunk returned %08x\n", Status);
|
||||
ERR("balance_metadata_chunk returned %08lx\n", Status);
|
||||
Vcb->balance.status = Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3410,7 +3415,7 @@ end:
|
|||
Status = finish_removing_device(Vcb, dev);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("finish_removing_device returned %08x\n", Status);
|
||||
ERR("finish_removing_device returned %08lx\n", Status);
|
||||
dev->reloc = false;
|
||||
}
|
||||
} else
|
||||
|
@ -3444,7 +3449,7 @@ end:
|
|||
if (dev) {
|
||||
Status = regenerate_space_list(Vcb, dev);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("regenerate_space_list returned %08x\n", Status);
|
||||
WARN("regenerate_space_list returned %08lx\n", Status);
|
||||
}
|
||||
} else {
|
||||
uint64_t old_size;
|
||||
|
@ -3454,19 +3459,19 @@ end:
|
|||
|
||||
Status = update_dev_item(Vcb, dev, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_dev_item returned %08x\n", Status);
|
||||
ERR("update_dev_item returned %08lx\n", Status);
|
||||
dev->devitem.num_bytes = old_size;
|
||||
Vcb->balance.status = Status;
|
||||
|
||||
Status = regenerate_space_list(Vcb, dev);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("regenerate_space_list returned %08x\n", Status);
|
||||
WARN("regenerate_space_list returned %08lx\n", Status);
|
||||
} else {
|
||||
Vcb->superblock.total_bytes -= old_size - dev->devitem.num_bytes;
|
||||
|
||||
Status = do_write(Vcb, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
|
||||
free_trees(Vcb);
|
||||
}
|
||||
|
@ -3479,7 +3484,7 @@ end:
|
|||
} else {
|
||||
Status = remove_balance_item(Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("remove_balance_item returned %08x\n", Status);
|
||||
ERR("remove_balance_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -3546,7 +3551,8 @@ NTSTATUS start_balance(device_extension* Vcb, void* data, ULONG length, KPROCESS
|
|||
if (bsb->opts[i].flags & BTRFS_BALANCE_OPTS_ENABLED) {
|
||||
if (bsb->opts[i].flags & BTRFS_BALANCE_OPTS_PROFILES) {
|
||||
bsb->opts[i].profiles &= BLOCK_FLAG_RAID0 | BLOCK_FLAG_RAID1 | BLOCK_FLAG_DUPLICATE | BLOCK_FLAG_RAID10 |
|
||||
BLOCK_FLAG_RAID5 | BLOCK_FLAG_RAID6 | BLOCK_FLAG_SINGLE;
|
||||
BLOCK_FLAG_RAID5 | BLOCK_FLAG_RAID6 | BLOCK_FLAG_SINGLE | BLOCK_FLAG_RAID1C3 |
|
||||
BLOCK_FLAG_RAID1C4;
|
||||
|
||||
if (bsb->opts[i].profiles == 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -3595,7 +3601,8 @@ NTSTATUS start_balance(device_extension* Vcb, void* data, ULONG length, KPROCESS
|
|||
if (bsb->opts[i].convert != BLOCK_FLAG_RAID0 && bsb->opts[i].convert != BLOCK_FLAG_RAID1 &&
|
||||
bsb->opts[i].convert != BLOCK_FLAG_DUPLICATE && bsb->opts[i].convert != BLOCK_FLAG_RAID10 &&
|
||||
bsb->opts[i].convert != BLOCK_FLAG_RAID5 && bsb->opts[i].convert != BLOCK_FLAG_RAID6 &&
|
||||
bsb->opts[i].convert != BLOCK_FLAG_SINGLE)
|
||||
bsb->opts[i].convert != BLOCK_FLAG_SINGLE && bsb->opts[i].convert != BLOCK_FLAG_RAID1C3 &&
|
||||
bsb->opts[i].convert != BLOCK_FLAG_RAID1C4)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
@ -3615,7 +3622,7 @@ NTSTATUS start_balance(device_extension* Vcb, void* data, ULONG length, KPROCESS
|
|||
|
||||
Status = PsCreateSystemThread(&Vcb->balance.thread, 0, &oa, NULL, NULL, balance_thread, Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("PsCreateSystemThread returned %08x\n", Status);
|
||||
ERR("PsCreateSystemThread returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -3636,7 +3643,7 @@ NTSTATUS look_for_balance_item(_Requires_lock_held_(_Curr_->tree_lock) device_ex
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -3646,7 +3653,7 @@ NTSTATUS look_for_balance_item(_Requires_lock_held_(_Curr_->tree_lock) device_ex
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(BALANCE_ITEM)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(BALANCE_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -3698,7 +3705,7 @@ NTSTATUS look_for_balance_item(_Requires_lock_held_(_Curr_->tree_lock) device_ex
|
|||
|
||||
Status = PsCreateSystemThread(&Vcb->balance.thread, 0, &oa, NULL, NULL, balance_thread, Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("PsCreateSystemThread returned %08x\n", Status);
|
||||
ERR("PsCreateSystemThread returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -3802,7 +3809,7 @@ NTSTATUS remove_device(device_extension* Vcb, void* data, ULONG length, KPROCESS
|
|||
uint64_t num_rw_devices;
|
||||
OBJECT_ATTRIBUTES oa;
|
||||
|
||||
TRACE("(%p, %p, %x)\n", Vcb, data, length);
|
||||
TRACE("(%p, %p, %lx)\n", Vcb, data, length);
|
||||
|
||||
if (!SeSinglePrivilegeCheck(RtlConvertLongToLuid(SE_MANAGE_VOLUME_PRIVILEGE), processor_mode))
|
||||
return STATUS_PRIVILEGE_NOT_HELD;
|
||||
|
@ -3849,16 +3856,21 @@ NTSTATUS remove_device(device_extension* Vcb, void* data, ULONG length, KPROCESS
|
|||
|
||||
if (num_rw_devices == 4 &&
|
||||
((Vcb->data_flags & BLOCK_FLAG_RAID10 || Vcb->metadata_flags & BLOCK_FLAG_RAID10 || Vcb->system_flags & BLOCK_FLAG_RAID10) ||
|
||||
(Vcb->data_flags & BLOCK_FLAG_RAID6 || Vcb->metadata_flags & BLOCK_FLAG_RAID6 || Vcb->system_flags & BLOCK_FLAG_RAID6))
|
||||
(Vcb->data_flags & BLOCK_FLAG_RAID6 || Vcb->metadata_flags & BLOCK_FLAG_RAID6 || Vcb->system_flags & BLOCK_FLAG_RAID6) ||
|
||||
(Vcb->data_flags & BLOCK_FLAG_RAID1C4 || Vcb->metadata_flags & BLOCK_FLAG_RAID1C4 || Vcb->system_flags & BLOCK_FLAG_RAID1C4)
|
||||
)
|
||||
) {
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
ERR("would not be enough devices to satisfy RAID requirement (RAID6/10)\n");
|
||||
ERR("would not be enough devices to satisfy RAID requirement (RAID6/10/1C4)\n");
|
||||
return STATUS_CANNOT_DELETE;
|
||||
}
|
||||
|
||||
if (num_rw_devices == 3 && (Vcb->data_flags & BLOCK_FLAG_RAID5 || Vcb->metadata_flags & BLOCK_FLAG_RAID5 || Vcb->system_flags & BLOCK_FLAG_RAID5)) {
|
||||
if (num_rw_devices == 3 &&
|
||||
((Vcb->data_flags & BLOCK_FLAG_RAID5 || Vcb->metadata_flags & BLOCK_FLAG_RAID5 || Vcb->system_flags & BLOCK_FLAG_RAID5) ||
|
||||
(Vcb->data_flags & BLOCK_FLAG_RAID1C3 || Vcb->metadata_flags & BLOCK_FLAG_RAID1C3 || Vcb->system_flags & BLOCK_FLAG_RAID1C3))
|
||||
) {
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
ERR("would not be enough devices to satisfy RAID requirement (RAID5)\n");
|
||||
ERR("would not be enough devices to satisfy RAID requirement (RAID5/1C3)\n");
|
||||
return STATUS_CANNOT_DELETE;
|
||||
}
|
||||
|
||||
|
@ -3898,7 +3910,7 @@ NTSTATUS remove_device(device_extension* Vcb, void* data, ULONG length, KPROCESS
|
|||
|
||||
Status = PsCreateSystemThread(&Vcb->balance.thread, 0, &oa, NULL, NULL, balance_thread, Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("PsCreateSystemThread returned %08x\n", Status);
|
||||
ERR("PsCreateSystemThread returned %08lx\n", Status);
|
||||
dev->reloc = false;
|
||||
return Status;
|
||||
}
|
||||
|
|
194
drivers/filesystems/btrfs/blake2-impl.h
Normal file
194
drivers/filesystems/btrfs/blake2-impl.h
Normal file
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
||||
#if defined(_MSC_VER)
|
||||
#define BLAKE2_INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
#define BLAKE2_INLINE __inline__
|
||||
#else
|
||||
#define BLAKE2_INLINE
|
||||
#endif
|
||||
#else
|
||||
#define BLAKE2_INLINE inline
|
||||
#endif
|
||||
|
||||
static BLAKE2_INLINE uint32_t load32( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint32_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint32_t )( p[0] ) << 0) |
|
||||
(( uint32_t )( p[1] ) << 8) |
|
||||
(( uint32_t )( p[2] ) << 16) |
|
||||
(( uint32_t )( p[3] ) << 24) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint64_t load64( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint64_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint64_t )( p[0] ) << 0) |
|
||||
(( uint64_t )( p[1] ) << 8) |
|
||||
(( uint64_t )( p[2] ) << 16) |
|
||||
(( uint64_t )( p[3] ) << 24) |
|
||||
(( uint64_t )( p[4] ) << 32) |
|
||||
(( uint64_t )( p[5] ) << 40) |
|
||||
(( uint64_t )( p[6] ) << 48) |
|
||||
(( uint64_t )( p[7] ) << 56) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint16_t load16( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint16_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return ( uint16_t )((( uint32_t )( p[0] ) << 0) |
|
||||
(( uint32_t )( p[1] ) << 8));
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
p[0] = (uint8_t)(w >> 0);
|
||||
p[1] = (uint8_t)(w >> 8);
|
||||
p[2] = (uint8_t)(w >> 16);
|
||||
p[3] = (uint8_t)(w >> 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store64( void *dst, uint64_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
p[0] = (uint8_t)(w >> 0);
|
||||
p[1] = (uint8_t)(w >> 8);
|
||||
p[2] = (uint8_t)(w >> 16);
|
||||
p[3] = (uint8_t)(w >> 24);
|
||||
p[4] = (uint8_t)(w >> 32);
|
||||
p[5] = (uint8_t)(w >> 40);
|
||||
p[6] = (uint8_t)(w >> 48);
|
||||
p[7] = (uint8_t)(w >> 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint64_t load48( const void *src )
|
||||
{
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint64_t )( p[0] ) << 0) |
|
||||
(( uint64_t )( p[1] ) << 8) |
|
||||
(( uint64_t )( p[2] ) << 16) |
|
||||
(( uint64_t )( p[3] ) << 24) |
|
||||
(( uint64_t )( p[4] ) << 32) |
|
||||
(( uint64_t )( p[5] ) << 40) ;
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store48( void *dst, uint64_t w )
|
||||
{
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
p[0] = (uint8_t)(w >> 0);
|
||||
p[1] = (uint8_t)(w >> 8);
|
||||
p[2] = (uint8_t)(w >> 16);
|
||||
p[3] = (uint8_t)(w >> 24);
|
||||
p[4] = (uint8_t)(w >> 32);
|
||||
p[5] = (uint8_t)(w >> 40);
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c )
|
||||
{
|
||||
return ( w >> c ) | ( w << ( 32 - c ) );
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c )
|
||||
{
|
||||
return ( w >> c ) | ( w << ( 64 - c ) );
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
|
||||
#else
|
||||
#define BLAKE2_PACKED(x) x __attribute__((packed))
|
||||
#endif
|
||||
|
||||
enum blake2b_constant
|
||||
{
|
||||
BLAKE2B_BLOCKBYTES = 128,
|
||||
BLAKE2B_OUTBYTES = 64,
|
||||
BLAKE2B_KEYBYTES = 64,
|
||||
BLAKE2B_SALTBYTES = 16,
|
||||
BLAKE2B_PERSONALBYTES = 16
|
||||
};
|
||||
|
||||
typedef struct blake2b_state__
|
||||
{
|
||||
uint64_t h[8];
|
||||
uint64_t t[2];
|
||||
uint64_t f[2];
|
||||
uint8_t buf[BLAKE2B_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
size_t outlen;
|
||||
uint8_t last_node;
|
||||
} blake2b_state;
|
||||
|
||||
BLAKE2_PACKED(struct blake2b_param__
|
||||
{
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint32_t leaf_length; /* 8 */
|
||||
uint32_t node_offset; /* 12 */
|
||||
uint32_t xof_length; /* 16 */
|
||||
uint8_t node_depth; /* 17 */
|
||||
uint8_t inner_length; /* 18 */
|
||||
uint8_t reserved[14]; /* 32 */
|
||||
uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
|
||||
uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
|
||||
});
|
||||
|
||||
typedef struct blake2b_param__ blake2b_param;
|
245
drivers/filesystems/btrfs/blake2b-ref.c
Normal file
245
drivers/filesystems/btrfs/blake2b-ref.c
Normal file
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2-impl.h"
|
||||
|
||||
static const uint64_t blake2b_IV[8] =
|
||||
{
|
||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
||||
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
||||
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
||||
};
|
||||
|
||||
static const uint8_t blake2b_sigma[12][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
||||
};
|
||||
|
||||
static int blake2b_update(blake2b_state* S, const void* in, size_t inlen);
|
||||
|
||||
static void blake2b_set_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = (uint64_t)-1;
|
||||
}
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
static int blake2b_is_lastblock( const blake2b_state *S )
|
||||
{
|
||||
return S->f[0] != 0;
|
||||
}
|
||||
|
||||
static void blake2b_set_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_set_lastnode( S );
|
||||
|
||||
S->f[0] = (uint64_t)-1;
|
||||
}
|
||||
|
||||
static void blake2b_increment_counter( blake2b_state *S, const uint64_t inc )
|
||||
{
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
}
|
||||
|
||||
static void blake2b_init0( blake2b_state *S )
|
||||
{
|
||||
size_t i;
|
||||
memset( S, 0, sizeof( blake2b_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
|
||||
}
|
||||
|
||||
/* init xors IV with input parameter block */
|
||||
static void blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
||||
{
|
||||
const uint8_t *p = ( const uint8_t * )( P );
|
||||
size_t i;
|
||||
|
||||
blake2b_init0( S );
|
||||
|
||||
/* IV XOR ParamBlock */
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
|
||||
|
||||
S->outlen = P->digest_length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void blake2b_init( blake2b_state *S, size_t outlen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
P->digest_length = (uint8_t)outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store32( &P->node_offset, 0 );
|
||||
store32( &P->xof_length, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
|
||||
blake2b_init_param( S, P );
|
||||
}
|
||||
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
||||
d = rotr64(d ^ a, 32); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 24); \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
||||
d = rotr64(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 63); \
|
||||
} while(0)
|
||||
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
|
||||
static void blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
|
||||
{
|
||||
uint64_t m[16];
|
||||
uint64_t v[16];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < 16; ++i ) {
|
||||
m[i] = load64( block + i * sizeof( m[i] ) );
|
||||
}
|
||||
|
||||
for( i = 0; i < 8; ++i ) {
|
||||
v[i] = S->h[i];
|
||||
}
|
||||
|
||||
v[ 8] = blake2b_IV[0];
|
||||
v[ 9] = blake2b_IV[1];
|
||||
v[10] = blake2b_IV[2];
|
||||
v[11] = blake2b_IV[3];
|
||||
v[12] = blake2b_IV[4] ^ S->t[0];
|
||||
v[13] = blake2b_IV[5] ^ S->t[1];
|
||||
v[14] = blake2b_IV[6] ^ S->f[0];
|
||||
v[15] = blake2b_IV[7] ^ S->f[1];
|
||||
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
ROUND( 10 );
|
||||
ROUND( 11 );
|
||||
|
||||
for( i = 0; i < 8; ++i ) {
|
||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
||||
}
|
||||
}
|
||||
|
||||
#undef G
|
||||
#undef ROUND
|
||||
|
||||
static int blake2b_update( blake2b_state *S, const void *pin, size_t inlen )
|
||||
{
|
||||
const unsigned char * in = (const unsigned char *)pin;
|
||||
if( inlen > 0 )
|
||||
{
|
||||
size_t left = S->buflen;
|
||||
size_t fill = BLAKE2B_BLOCKBYTES - left;
|
||||
if( inlen > fill )
|
||||
{
|
||||
S->buflen = 0;
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf ); /* Compress */
|
||||
in += fill; inlen -= fill;
|
||||
while(inlen > BLAKE2B_BLOCKBYTES) {
|
||||
blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES);
|
||||
blake2b_compress( S, in );
|
||||
in += BLAKE2B_BLOCKBYTES;
|
||||
inlen -= BLAKE2B_BLOCKBYTES;
|
||||
}
|
||||
}
|
||||
memcpy( S->buf + S->buflen, in, inlen );
|
||||
S->buflen += inlen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int blake2b_final( blake2b_state *S, void *out, size_t outlen )
|
||||
{
|
||||
uint8_t buffer[BLAKE2B_OUTBYTES] = {0};
|
||||
size_t i;
|
||||
|
||||
if( out == NULL || outlen < S->outlen )
|
||||
return -1;
|
||||
|
||||
if( blake2b_is_lastblock( S ) )
|
||||
return -1;
|
||||
|
||||
blake2b_increment_counter( S, S->buflen );
|
||||
blake2b_set_lastblock( S );
|
||||
memset( S->buf + S->buflen, 0, BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
|
||||
blake2b_compress( S, S->buf );
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
memcpy( out, buffer, S->outlen );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen, at least, should be uint64_t. Others can be size_t. */
|
||||
void blake2b( void *out, size_t outlen, const void *in, size_t inlen )
|
||||
{
|
||||
blake2b_state S[1];
|
||||
|
||||
blake2b_init( S, outlen );
|
||||
|
||||
blake2b_update( S, ( const uint8_t * )in, inlen );
|
||||
blake2b_final( S, out, outlen );
|
||||
}
|
|
@ -30,6 +30,9 @@ extern LIST_ENTRY pdo_list;
|
|||
extern ERESOURCE boot_lock;
|
||||
extern PDRIVER_OBJECT drvobj;
|
||||
|
||||
BTRFS_UUID boot_uuid; // initialized to 0
|
||||
uint64_t boot_subvol = 0;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
NTSTATUS RtlUnicodeStringPrintf(PUNICODE_STRING DestinationString, const WCHAR* pszFormat, ...); // not in mingw
|
||||
#endif
|
||||
|
@ -47,113 +50,198 @@ typedef struct {
|
|||
ULONG ExtensionFlags;
|
||||
} DEVOBJ_EXTENSION2;
|
||||
|
||||
static bool get_system_root_partition(uint32_t* disk_num, uint32_t* partition_num) {
|
||||
typedef enum {
|
||||
system_root_unknown,
|
||||
system_root_partition,
|
||||
system_root_btrfs
|
||||
} system_root_type;
|
||||
|
||||
typedef struct {
|
||||
uint32_t disk_num;
|
||||
uint32_t partition_num;
|
||||
BTRFS_UUID uuid;
|
||||
system_root_type type;
|
||||
} system_root;
|
||||
|
||||
static void get_system_root(system_root* sr) {
|
||||
NTSTATUS Status;
|
||||
HANDLE h;
|
||||
UNICODE_STRING us, target;
|
||||
OBJECT_ATTRIBUTES objatt;
|
||||
WCHAR* s;
|
||||
ULONG retlen = 0, left;
|
||||
ULONG retlen = 0;
|
||||
bool second_time = false;
|
||||
|
||||
static const WCHAR system_root[] = L"\\SystemRoot";
|
||||
static const WCHAR boot_device[] = L"\\Device\\BootDevice";
|
||||
static const WCHAR arc_prefix[] = L"\\ArcName\\multi(0)disk(0)rdisk(";
|
||||
static const WCHAR arc_middle[] = L")partition(";
|
||||
static const WCHAR arc_btrfs_prefix[] = L"\\ArcName\\btrfs(";
|
||||
|
||||
us.Buffer = (WCHAR*)system_root;
|
||||
us.Length = us.MaximumLength = sizeof(system_root) - sizeof(WCHAR);
|
||||
|
||||
InitializeObjectAttributes(&objatt, &us, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||
|
||||
Status = ZwOpenSymbolicLinkObject(&h, GENERIC_READ, &objatt);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwOpenSymbolicLinkObject returned %08x\n", Status);
|
||||
return false;
|
||||
}
|
||||
while (true) {
|
||||
Status = ZwOpenSymbolicLinkObject(&h, GENERIC_READ, &objatt);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwOpenSymbolicLinkObject returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
target.Length = target.MaximumLength = 0;
|
||||
target.Length = target.MaximumLength = 0;
|
||||
|
||||
Status = ZwQuerySymbolicLinkObject(h, &target, &retlen);
|
||||
if (Status != STATUS_BUFFER_TOO_SMALL) {
|
||||
ERR("ZwQuerySymbolicLinkObject returned %08lx\n", Status);
|
||||
NtClose(h);
|
||||
return;
|
||||
}
|
||||
|
||||
if (retlen == 0) {
|
||||
NtClose(h);
|
||||
return;
|
||||
}
|
||||
|
||||
target.Buffer = ExAllocatePoolWithTag(NonPagedPool, retlen, ALLOC_TAG);
|
||||
if (!target.Buffer) {
|
||||
ERR("out of memory\n");
|
||||
NtClose(h);
|
||||
return;
|
||||
}
|
||||
|
||||
target.Length = target.MaximumLength = (USHORT)retlen;
|
||||
|
||||
Status = ZwQuerySymbolicLinkObject(h, &target, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwQuerySymbolicLinkObject returned %08lx\n", Status);
|
||||
NtClose(h);
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = ZwQuerySymbolicLinkObject(h, &target, &retlen);
|
||||
if (Status != STATUS_BUFFER_TOO_SMALL) {
|
||||
ERR("ZwQuerySymbolicLinkObject returned %08x\n", Status);
|
||||
NtClose(h);
|
||||
return false;
|
||||
|
||||
if (second_time) {
|
||||
TRACE("boot device is %.*S\n", (int)(target.Length / sizeof(WCHAR)), target.Buffer);
|
||||
} else {
|
||||
TRACE("system root is %.*S\n", (int)(target.Length / sizeof(WCHAR)), target.Buffer);
|
||||
}
|
||||
|
||||
if (!second_time && target.Length >= sizeof(boot_device) - sizeof(WCHAR) &&
|
||||
RtlCompareMemory(target.Buffer, boot_device, sizeof(boot_device) - sizeof(WCHAR)) == sizeof(boot_device) - sizeof(WCHAR)) {
|
||||
ExFreePool(target.Buffer);
|
||||
|
||||
us.Buffer = (WCHAR*)boot_device;
|
||||
us.Length = us.MaximumLength = sizeof(boot_device) - sizeof(WCHAR);
|
||||
|
||||
second_time = true;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
if (retlen == 0) {
|
||||
NtClose(h);
|
||||
return false;
|
||||
}
|
||||
sr->type = system_root_unknown;
|
||||
|
||||
target.Buffer = ExAllocatePoolWithTag(NonPagedPool, retlen, ALLOC_TAG);
|
||||
if (!target.Buffer) {
|
||||
ERR("out of memory\n");
|
||||
NtClose(h);
|
||||
return false;
|
||||
}
|
||||
if (target.Length >= sizeof(arc_prefix) - sizeof(WCHAR) &&
|
||||
RtlCompareMemory(target.Buffer, arc_prefix, sizeof(arc_prefix) - sizeof(WCHAR)) == sizeof(arc_prefix) - sizeof(WCHAR)) {
|
||||
WCHAR* s = &target.Buffer[(sizeof(arc_prefix) / sizeof(WCHAR)) - 1];
|
||||
ULONG left = ((target.Length - sizeof(arc_prefix)) / sizeof(WCHAR)) + 1;
|
||||
|
||||
target.Length = target.MaximumLength = (USHORT)retlen;
|
||||
if (left == 0 || s[0] < '0' || s[0] > '9') {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = ZwQuerySymbolicLinkObject(h, &target, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwQuerySymbolicLinkObject returned %08x\n", Status);
|
||||
NtClose(h);
|
||||
ExFreePool(target.Buffer);
|
||||
return false;
|
||||
}
|
||||
sr->disk_num = 0;
|
||||
|
||||
NtClose(h);
|
||||
while (left > 0 && s[0] >= '0' && s[0] <= '9') {
|
||||
sr->disk_num *= 10;
|
||||
sr->disk_num += s[0] - '0';
|
||||
s++;
|
||||
left--;
|
||||
}
|
||||
|
||||
TRACE("system root is %.*S\n", target.Length / sizeof(WCHAR), target.Buffer);
|
||||
if (left <= (sizeof(arc_middle) / sizeof(WCHAR)) - 1 ||
|
||||
RtlCompareMemory(s, arc_middle, sizeof(arc_middle) - sizeof(WCHAR)) != sizeof(arc_middle) - sizeof(WCHAR)) {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.Length <= sizeof(arc_prefix) - sizeof(WCHAR) ||
|
||||
RtlCompareMemory(target.Buffer, arc_prefix, sizeof(arc_prefix) - sizeof(WCHAR)) != sizeof(arc_prefix) - sizeof(WCHAR)) {
|
||||
ExFreePool(target.Buffer);
|
||||
return false;
|
||||
}
|
||||
s = &s[(sizeof(arc_middle) / sizeof(WCHAR)) - 1];
|
||||
left -= (sizeof(arc_middle) / sizeof(WCHAR)) - 1;
|
||||
|
||||
s = &target.Buffer[(sizeof(arc_prefix) / sizeof(WCHAR)) - 1];
|
||||
left = ((target.Length - sizeof(arc_prefix)) / sizeof(WCHAR)) + 1;
|
||||
if (left == 0 || s[0] < '0' || s[0] > '9') {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (left == 0 || s[0] < '0' || s[0] > '9') {
|
||||
ExFreePool(target.Buffer);
|
||||
return false;
|
||||
}
|
||||
sr->partition_num = 0;
|
||||
|
||||
*disk_num = 0;
|
||||
while (left > 0 && s[0] >= '0' && s[0] <= '9') {
|
||||
sr->partition_num *= 10;
|
||||
sr->partition_num += s[0] - '0';
|
||||
s++;
|
||||
left--;
|
||||
}
|
||||
|
||||
while (left > 0 && s[0] >= '0' && s[0] <= '9') {
|
||||
*disk_num *= 10;
|
||||
*disk_num += s[0] - '0';
|
||||
s++;
|
||||
left--;
|
||||
}
|
||||
sr->type = system_root_partition;
|
||||
} else if (target.Length >= sizeof(arc_btrfs_prefix) - sizeof(WCHAR) &&
|
||||
RtlCompareMemory(target.Buffer, arc_btrfs_prefix, sizeof(arc_btrfs_prefix) - sizeof(WCHAR)) == sizeof(arc_btrfs_prefix) - sizeof(WCHAR)) {
|
||||
WCHAR* s = &target.Buffer[(sizeof(arc_btrfs_prefix) / sizeof(WCHAR)) - 1];
|
||||
#ifdef __REACTOS__
|
||||
unsigned int i;
|
||||
#endif // __REACTOS__
|
||||
|
||||
if (left <= (sizeof(arc_middle) / sizeof(WCHAR)) - 1 ||
|
||||
RtlCompareMemory(s, arc_middle, sizeof(arc_middle) - sizeof(WCHAR)) != sizeof(arc_middle) - sizeof(WCHAR)) {
|
||||
ExFreePool(target.Buffer);
|
||||
return false;
|
||||
}
|
||||
#ifndef __REACTOS__
|
||||
for (unsigned int i = 0; i < 16; i++) {
|
||||
#else
|
||||
for (i = 0; i < 16; i++) {
|
||||
#endif // __REACTOS__
|
||||
if (*s >= '0' && *s <= '9')
|
||||
sr->uuid.uuid[i] = (*s - '0') << 4;
|
||||
else if (*s >= 'a' && *s <= 'f')
|
||||
sr->uuid.uuid[i] = (*s - 'a' + 0xa) << 4;
|
||||
else if (*s >= 'A' && *s <= 'F')
|
||||
sr->uuid.uuid[i] = (*s - 'A' + 0xa) << 4;
|
||||
else {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
s = &s[(sizeof(arc_middle) / sizeof(WCHAR)) - 1];
|
||||
left -= (sizeof(arc_middle) / sizeof(WCHAR)) - 1;
|
||||
s++;
|
||||
|
||||
if (left == 0 || s[0] < '0' || s[0] > '9') {
|
||||
ExFreePool(target.Buffer);
|
||||
return false;
|
||||
}
|
||||
if (*s >= '0' && *s <= '9')
|
||||
sr->uuid.uuid[i] |= *s - '0';
|
||||
else if (*s >= 'a' && *s <= 'f')
|
||||
sr->uuid.uuid[i] |= *s - 'a' + 0xa;
|
||||
else if (*s >= 'A' && *s <= 'F')
|
||||
sr->uuid.uuid[i] |= *s - 'A' + 0xa;
|
||||
else {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
*partition_num = 0;
|
||||
s++;
|
||||
|
||||
while (left > 0 && s[0] >= '0' && s[0] <= '9') {
|
||||
*partition_num *= 10;
|
||||
*partition_num += s[0] - '0';
|
||||
s++;
|
||||
left--;
|
||||
if (i == 3 || i == 5 || i == 7 || i == 9) {
|
||||
if (*s != '-') {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
if (*s != ')') {
|
||||
ExFreePool(target.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
sr->type = system_root_btrfs;
|
||||
}
|
||||
|
||||
ExFreePool(target.Buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void change_symlink(uint32_t disk_num, uint32_t partition_num, BTRFS_UUID* uuid) {
|
||||
|
@ -170,13 +258,13 @@ static void change_symlink(uint32_t disk_num, uint32_t partition_num, BTRFS_UUID
|
|||
|
||||
Status = RtlUnicodeStringPrintf(&us, L"\\Device\\Harddisk%u\\Partition%u", disk_num, partition_num);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUnicodeStringPrintf returned %08x\n", Status);
|
||||
ERR("RtlUnicodeStringPrintf returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = IoDeleteSymbolicLink(&us);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoDeleteSymbolicLink returned %08x\n", Status);
|
||||
ERR("IoDeleteSymbolicLink returned %08lx\n", Status);
|
||||
|
||||
RtlCopyMemory(target, BTRFS_VOLUME_PREFIX, sizeof(BTRFS_VOLUME_PREFIX) - sizeof(WCHAR));
|
||||
|
||||
|
@ -203,7 +291,7 @@ static void change_symlink(uint32_t disk_num, uint32_t partition_num, BTRFS_UUID
|
|||
|
||||
Status = IoCreateSymbolicLink(&us, &us2);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoCreateSymbolicLink returned %08x\n", Status);
|
||||
ERR("IoCreateSymbolicLink returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
static void mountmgr_notification(BTRFS_UUID* uuid) {
|
||||
|
@ -221,7 +309,7 @@ static void mountmgr_notification(BTRFS_UUID* uuid) {
|
|||
RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
|
||||
Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &FileObject, &mountmgr);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -257,7 +345,7 @@ static void mountmgr_notification(BTRFS_UUID* uuid) {
|
|||
|
||||
Status = dev_ioctl(mountmgr, IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION, mmtn, mmtnlen, NULL, 0, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION returned %08lx\n", Status);
|
||||
ExFreePool(mmtn);
|
||||
return;
|
||||
}
|
||||
|
@ -265,6 +353,110 @@ static void mountmgr_notification(BTRFS_UUID* uuid) {
|
|||
ExFreePool(mmtn);
|
||||
}
|
||||
|
||||
static void check_boot_options() {
|
||||
NTSTATUS Status;
|
||||
WCHAR* s;
|
||||
|
||||
static const WCHAR pathw[] = L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control";
|
||||
static const WCHAR namew[] = L"SystemStartOptions";
|
||||
static const WCHAR subvol[] = L"SUBVOL=";
|
||||
|
||||
_SEH2_TRY {
|
||||
HANDLE control;
|
||||
OBJECT_ATTRIBUTES oa;
|
||||
UNICODE_STRING path;
|
||||
ULONG kvfilen = sizeof(KEY_VALUE_FULL_INFORMATION) - sizeof(WCHAR) + (255 * sizeof(WCHAR));
|
||||
KEY_VALUE_FULL_INFORMATION* kvfi;
|
||||
UNICODE_STRING name;
|
||||
WCHAR* options;
|
||||
|
||||
path.Buffer = (WCHAR*)pathw;
|
||||
path.Length = path.MaximumLength = sizeof(pathw) - sizeof(WCHAR);
|
||||
|
||||
InitializeObjectAttributes(&oa, &path, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||
|
||||
Status = ZwOpenKey(&control, KEY_QUERY_VALUE, &oa);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwOpenKey returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME - don't fail if value too long (can we query for the length?)
|
||||
|
||||
kvfi = ExAllocatePoolWithTag(PagedPool, kvfilen, ALLOC_TAG);
|
||||
if (!kvfi) {
|
||||
ERR("out of memory\n");
|
||||
NtClose(control);
|
||||
return;
|
||||
}
|
||||
|
||||
name.Buffer = (WCHAR*)namew;
|
||||
name.Length = name.MaximumLength = sizeof(namew) - sizeof(WCHAR);
|
||||
|
||||
Status = ZwQueryValueKey(control, &name, KeyValueFullInformation, kvfi,
|
||||
kvfilen, &kvfilen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwQueryValueKey returned %08lx\n", Status);
|
||||
NtClose(control);
|
||||
return;
|
||||
}
|
||||
|
||||
NtClose(control);
|
||||
|
||||
options = (WCHAR*)((uint8_t*)kvfi + kvfi->DataOffset);
|
||||
options[kvfi->DataLength / sizeof(WCHAR)] = 0; // FIXME - make sure buffer long enough to allow this
|
||||
|
||||
s = wcsstr(options, subvol);
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
s += (sizeof(subvol) / sizeof(WCHAR)) - 1;
|
||||
|
||||
boot_subvol = 0;
|
||||
|
||||
while (true) {
|
||||
if (*s >= '0' && *s <= '9') {
|
||||
boot_subvol <<= 4;
|
||||
boot_subvol |= *s - '0';
|
||||
} else if (*s >= 'a' && *s <= 'f') {
|
||||
boot_subvol <<= 4;
|
||||
boot_subvol |= *s - 'a' + 0xa;
|
||||
} else if (*s >= 'A' && *s <= 'F') {
|
||||
boot_subvol <<= 4;
|
||||
boot_subvol |= *s - 'A' + 0xa;
|
||||
} else
|
||||
break;
|
||||
|
||||
s++;
|
||||
}
|
||||
} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
|
||||
return;
|
||||
} _SEH2_END;
|
||||
|
||||
if (boot_subvol != 0) {
|
||||
TRACE("passed subvol %I64x in boot options\n", boot_subvol);
|
||||
}
|
||||
}
|
||||
|
||||
void boot_add_device(DEVICE_OBJECT* pdo) {
|
||||
pdo_device_extension* pdode = pdo->DeviceExtension;
|
||||
|
||||
AddDevice(drvobj, pdo);
|
||||
|
||||
// To stop Windows sneakily setting DOE_START_PENDING
|
||||
pdode->dont_report = true;
|
||||
|
||||
if (pdo->DeviceObjectExtension) {
|
||||
((DEVOBJ_EXTENSION2*)pdo->DeviceObjectExtension)->ExtensionFlags &= ~DOE_START_PENDING;
|
||||
|
||||
if (pdode && pdode->vde && pdode->vde->device)
|
||||
((DEVOBJ_EXTENSION2*)pdode->vde->device->DeviceObjectExtension)->ExtensionFlags &= ~DOE_START_PENDING;
|
||||
}
|
||||
|
||||
mountmgr_notification(&pdode->uuid);
|
||||
}
|
||||
|
||||
/* If booting from Btrfs, Windows will pass the device object for the raw partition to
|
||||
* mount_vol - which is no good to us, as we only use the \Device\Btrfs{} devices we
|
||||
* create so that RAID works correctly.
|
||||
|
@ -276,109 +468,156 @@ static void mountmgr_notification(BTRFS_UUID* uuid) {
|
|||
* point to.
|
||||
*/
|
||||
void __stdcall check_system_root(PDRIVER_OBJECT DriverObject, PVOID Context, ULONG Count) {
|
||||
uint32_t disk_num, partition_num;
|
||||
system_root sr;
|
||||
LIST_ENTRY* le;
|
||||
bool done = false;
|
||||
PDEVICE_OBJECT pdo_to_add = NULL;
|
||||
volume_child* boot_vc = NULL;
|
||||
|
||||
TRACE("(%p, %p, %u)\n", DriverObject, Context, Count);
|
||||
TRACE("(%p, %p, %lu)\n", DriverObject, Context, Count);
|
||||
|
||||
// wait for any PNP notifications in progress to finish
|
||||
ExAcquireResourceExclusiveLite(&boot_lock, TRUE);
|
||||
ExReleaseResourceLite(&boot_lock);
|
||||
|
||||
if (!get_system_root_partition(&disk_num, &partition_num))
|
||||
return;
|
||||
get_system_root(&sr);
|
||||
|
||||
TRACE("system boot partition is disk %u, partition %u\n", disk_num, partition_num);
|
||||
if (sr.type == system_root_partition) {
|
||||
TRACE("system boot partition is disk %u, partition %u\n", sr.disk_num, sr.partition_num);
|
||||
|
||||
ExAcquireResourceSharedLite(&pdo_list_lock, true);
|
||||
ExAcquireResourceSharedLite(&pdo_list_lock, true);
|
||||
|
||||
le = pdo_list.Flink;
|
||||
while (le != &pdo_list) {
|
||||
LIST_ENTRY* le2;
|
||||
pdo_device_extension* pdode = CONTAINING_RECORD(le, pdo_device_extension, list_entry);
|
||||
le = pdo_list.Flink;
|
||||
while (le != &pdo_list) {
|
||||
LIST_ENTRY* le2;
|
||||
pdo_device_extension* pdode = CONTAINING_RECORD(le, pdo_device_extension, list_entry);
|
||||
|
||||
ExAcquireResourceSharedLite(&pdode->child_lock, true);
|
||||
ExAcquireResourceSharedLite(&pdode->child_lock, true);
|
||||
|
||||
le2 = pdode->children.Flink;
|
||||
le2 = pdode->children.Flink;
|
||||
|
||||
while (le2 != &pdode->children) {
|
||||
volume_child* vc = CONTAINING_RECORD(le2, volume_child, list_entry);
|
||||
while (le2 != &pdode->children) {
|
||||
volume_child* vc = CONTAINING_RECORD(le2, volume_child, list_entry);
|
||||
|
||||
if (vc->disk_num == disk_num && vc->part_num == partition_num) {
|
||||
change_symlink(disk_num, partition_num, &pdode->uuid);
|
||||
done = true;
|
||||
if (vc->disk_num == sr.disk_num && vc->part_num == sr.partition_num) {
|
||||
change_symlink(sr.disk_num, sr.partition_num, &pdode->uuid);
|
||||
done = true;
|
||||
|
||||
vc->boot_volume = true;
|
||||
boot_uuid = pdode->uuid;
|
||||
|
||||
if (!pdode->vde)
|
||||
pdo_to_add = pdode->pdo;
|
||||
|
||||
boot_vc = vc;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
le2 = le2->Flink;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
le2 = pdode->children.Flink;
|
||||
|
||||
while (le2 != &pdode->children) {
|
||||
volume_child* vc = CONTAINING_RECORD(le2, volume_child, list_entry);
|
||||
|
||||
/* On Windows 7 we need to clear the DO_SYSTEM_BOOT_PARTITION flag of
|
||||
* all of our underlying partition objects - otherwise IopMountVolume
|
||||
* will bugcheck with UNMOUNTABLE_BOOT_VOLUME when it tries and fails
|
||||
* to mount one. */
|
||||
if (vc->devobj) {
|
||||
PDEVICE_OBJECT dev = vc->devobj;
|
||||
|
||||
ObReferenceObject(dev);
|
||||
|
||||
while (dev) {
|
||||
PDEVICE_OBJECT dev2 = IoGetLowerDeviceObject(dev);
|
||||
|
||||
dev->Flags &= ~DO_SYSTEM_BOOT_PARTITION;
|
||||
|
||||
ObDereferenceObject(dev);
|
||||
|
||||
dev = dev2;
|
||||
}
|
||||
}
|
||||
|
||||
le2 = le2->Flink;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pdode->child_lock);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pdode->child_lock);
|
||||
|
||||
le = le->Flink;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pdo_list_lock);
|
||||
} else if (sr.type == system_root_btrfs) {
|
||||
boot_uuid = sr.uuid;
|
||||
|
||||
ExAcquireResourceSharedLite(&pdo_list_lock, true);
|
||||
|
||||
le = pdo_list.Flink;
|
||||
while (le != &pdo_list) {
|
||||
pdo_device_extension* pdode = CONTAINING_RECORD(le, pdo_device_extension, list_entry);
|
||||
|
||||
if (RtlCompareMemory(&pdode->uuid, &sr.uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
|
||||
if (!pdode->vde)
|
||||
pdo_to_add = pdode->pdo;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
le2 = le2->Flink;
|
||||
le = le->Flink;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
le2 = pdode->children.Flink;
|
||||
|
||||
while (le2 != &pdode->children) {
|
||||
volume_child* vc = CONTAINING_RECORD(le2, volume_child, list_entry);
|
||||
|
||||
/* On Windows 7 we need to clear the DO_SYSTEM_BOOT_PARTITION flag of
|
||||
* all of our underlying partition objects - otherwise IopMountVolume
|
||||
* will bugcheck with UNMOUNTABLE_BOOT_VOLUME when it tries and fails
|
||||
* to mount one. */
|
||||
if (vc->devobj) {
|
||||
PDEVICE_OBJECT dev = vc->devobj;
|
||||
|
||||
ObReferenceObject(dev);
|
||||
|
||||
while (dev) {
|
||||
PDEVICE_OBJECT dev2 = IoGetLowerDeviceObject(dev);
|
||||
|
||||
dev->Flags &= ~DO_SYSTEM_BOOT_PARTITION;
|
||||
|
||||
ObDereferenceObject(dev);
|
||||
|
||||
dev = dev2;
|
||||
}
|
||||
}
|
||||
|
||||
le2 = le2->Flink;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pdode->child_lock);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pdode->child_lock);
|
||||
|
||||
le = le->Flink;
|
||||
ExReleaseResourceLite(&pdo_list_lock);
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&pdo_list_lock);
|
||||
if (boot_vc) {
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING name;
|
||||
|
||||
/* On Windows 8, mountmgr!MountMgrFindBootVolume returns the first volume in its database
|
||||
* with the DO_SYSTEM_BOOT_PARTITION flag set. We've cleared the bit on the underlying devices,
|
||||
* but as it caches it we need to disable and re-enable the volume so mountmgr receives a PNP
|
||||
* notification to refresh its list. */
|
||||
|
||||
static const WCHAR prefix[] = L"\\??";
|
||||
|
||||
name.Length = name.MaximumLength = boot_vc->pnp_name.Length + sizeof(prefix) - sizeof(WCHAR);
|
||||
|
||||
name.Buffer = ExAllocatePoolWithTag(PagedPool, name.MaximumLength, ALLOC_TAG);
|
||||
if (!name.Buffer)
|
||||
ERR("out of memory\n");
|
||||
else {
|
||||
RtlCopyMemory(name.Buffer, prefix, sizeof(prefix) - sizeof(WCHAR));
|
||||
RtlCopyMemory(&name.Buffer[(sizeof(prefix) / sizeof(WCHAR)) - 1], boot_vc->pnp_name.Buffer, boot_vc->pnp_name.Length);
|
||||
|
||||
Status = IoSetDeviceInterfaceState(&name, false);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoSetDeviceInterfaceState returned %08lx\n", Status);
|
||||
|
||||
Status = IoSetDeviceInterfaceState(&name, true);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoSetDeviceInterfaceState returned %08lx\n", Status);
|
||||
|
||||
ExFreePool(name.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (sr.type == system_root_btrfs || boot_vc)
|
||||
check_boot_options();
|
||||
|
||||
// If our FS depends on volumes that aren't there when we do our IoRegisterPlugPlayNotification calls
|
||||
// in DriverEntry, bus_query_device_relations won't get called until it's too late. We need to do our
|
||||
// own call to AddDevice here as a result. We need to clear the DOE_START_PENDING bits, or NtOpenFile
|
||||
// will return STATUS_NO_SUCH_DEVICE.
|
||||
if (pdo_to_add) {
|
||||
pdo_device_extension* pdode = pdo_to_add->DeviceExtension;
|
||||
|
||||
AddDevice(drvobj, pdo_to_add);
|
||||
|
||||
// To stop Windows sneakily setting DOE_START_PENDING
|
||||
pdode->dont_report = true;
|
||||
|
||||
if (pdo_to_add->DeviceObjectExtension) {
|
||||
((DEVOBJ_EXTENSION2*)pdo_to_add->DeviceObjectExtension)->ExtensionFlags &= ~DOE_START_PENDING;
|
||||
|
||||
if (pdode && pdode->vde && pdode->vde->device)
|
||||
((DEVOBJ_EXTENSION2*)pdode->vde->device->DeviceObjectExtension)->ExtensionFlags &= ~DOE_START_PENDING;
|
||||
}
|
||||
|
||||
mountmgr_notification(&pdode->uuid);
|
||||
}
|
||||
if (pdo_to_add)
|
||||
boot_add_device(pdo_to_add);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -80,6 +80,8 @@ static const uint64_t superblock_addrs[] = { 0x10000, 0x4000000, 0x4000000000, 0
|
|||
#define BLOCK_FLAG_RAID10 0x040
|
||||
#define BLOCK_FLAG_RAID5 0x080
|
||||
#define BLOCK_FLAG_RAID6 0x100
|
||||
#define BLOCK_FLAG_RAID1C3 0x200
|
||||
#define BLOCK_FLAG_RAID1C4 0x400
|
||||
|
||||
#define FREE_SPACE_CACHE_ID 0xFFFFFFFFFFFFFFF5
|
||||
#define EXTENT_CSUM_ID 0xFFFFFFFFFFFFFFF6
|
||||
|
@ -113,11 +115,18 @@ static const uint64_t superblock_addrs[] = { 0x10000, 0x4000000, 0x4000000000, 0
|
|||
#define BTRFS_INCOMPAT_FLAGS_RAID56 0x0080
|
||||
#define BTRFS_INCOMPAT_FLAGS_SKINNY_METADATA 0x0100
|
||||
#define BTRFS_INCOMPAT_FLAGS_NO_HOLES 0x0200
|
||||
#define BTRFS_INCOMPAT_FLAGS_METADATA_UUID 0x0400
|
||||
#define BTRFS_INCOMPAT_FLAGS_RAID1C34 0x0800
|
||||
|
||||
#define BTRFS_SUPERBLOCK_FLAGS_SEEDING 0x100000000
|
||||
|
||||
#define BTRFS_ORPHAN_INODE_OBJID 0xFFFFFFFFFFFFFFFB
|
||||
|
||||
#define CSUM_TYPE_CRC32C 0
|
||||
#define CSUM_TYPE_XXHASH 1
|
||||
#define CSUM_TYPE_SHA256 2
|
||||
#define CSUM_TYPE_BLAKE2 3
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
|
@ -236,7 +245,8 @@ typedef struct {
|
|||
char label[MAX_LABEL_SIZE];
|
||||
uint64_t cache_generation;
|
||||
uint64_t uuid_tree_generation;
|
||||
uint64_t reserved[30];
|
||||
BTRFS_UUID metadata_uuid;
|
||||
uint64_t reserved[28];
|
||||
uint8_t sys_chunk_array[SYS_CHUNK_ARRAY_SIZE];
|
||||
superblock_backup backup[BTRFS_NUM_BACKUP_ROOTS];
|
||||
uint8_t reserved2[565];
|
||||
|
|
|
@ -51,8 +51,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,5,0,0
|
||||
PRODUCTVERSION 1,5,0,0
|
||||
FILEVERSION 1,7,2,0
|
||||
PRODUCTVERSION 1,7,2,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -68,12 +68,12 @@ BEGIN
|
|||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "WinBtrfs"
|
||||
VALUE "FileVersion", "1.5"
|
||||
VALUE "FileVersion", "1.7.2"
|
||||
VALUE "InternalName", "btrfs"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-19"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-20"
|
||||
VALUE "OriginalFilename", "btrfs.sys"
|
||||
VALUE "ProductName", "WinBtrfs"
|
||||
VALUE "ProductVersion", "1.5"
|
||||
VALUE "ProductVersion", "1.7.2"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -63,13 +63,13 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#ifndef __REACTOS__
|
||||
// Not actually used
|
||||
#include <emmintrin.h>
|
||||
#endif /* __REACTOS__ */
|
||||
#include "btrfs.h"
|
||||
#include "btrfsioctl.h"
|
||||
|
||||
#if !defined(__REACTOS__) && (defined(_X86_) || defined(_AMD64_))
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
#ifdef __REACTOS__
|
||||
C_ASSERT(sizeof(bool) == 1);
|
||||
#endif
|
||||
|
@ -117,12 +117,16 @@ C_ASSERT(sizeof(bool) == 1);
|
|||
|
||||
#define READ_AHEAD_GRANULARITY COMPRESSED_EXTENT_SIZE // really ought to be a multiple of COMPRESSED_EXTENT_SIZE
|
||||
|
||||
#define IO_REPARSE_TAG_LXSS_SYMLINK 0xa000001d // undocumented?
|
||||
#ifndef IO_REPARSE_TAG_LX_SYMLINK
|
||||
|
||||
#define IO_REPARSE_TAG_LXSS_SOCKET 0x80000023
|
||||
#define IO_REPARSE_TAG_LXSS_FIFO 0x80000024
|
||||
#define IO_REPARSE_TAG_LXSS_CHARDEV 0x80000025
|
||||
#define IO_REPARSE_TAG_LXSS_BLOCKDEV 0x80000026
|
||||
#define IO_REPARSE_TAG_LX_SYMLINK 0xa000001d
|
||||
|
||||
#define IO_REPARSE_TAG_AF_UNIX 0x80000023
|
||||
#define IO_REPARSE_TAG_LX_FIFO 0x80000024
|
||||
#define IO_REPARSE_TAG_LX_CHR 0x80000025
|
||||
#define IO_REPARSE_TAG_LX_BLK 0x80000026
|
||||
|
||||
#endif
|
||||
|
||||
#define BTRFS_VOLUME_PREFIX L"\\Device\\Btrfs{"
|
||||
|
||||
|
@ -140,7 +144,7 @@ C_ASSERT(sizeof(bool) == 1);
|
|||
#ifdef __GNUC__
|
||||
#define InterlockedIncrement64(a) __sync_add_and_fetch(a, 1)
|
||||
#endif
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
#ifndef FILE_SUPPORTS_BLOCK_REFCOUNTING
|
||||
#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
|
||||
|
@ -154,10 +158,22 @@ C_ASSERT(sizeof(bool) == 1);
|
|||
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
|
||||
#endif
|
||||
|
||||
#ifndef __REACTOS__
|
||||
#ifndef _MSC_VER
|
||||
typedef struct _FILE_ID_128 {
|
||||
UCHAR Identifier[16];
|
||||
} FILE_ID_128, *PFILE_ID_128;
|
||||
|
||||
#define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
|
||||
#endif
|
||||
#else
|
||||
typedef struct _FILE_ID_128 {
|
||||
UCHAR Identifier[16];
|
||||
} FILE_ID_128, *PFILE_ID_128;
|
||||
|
||||
#define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
|
||||
#endif // __REACTOS__
|
||||
|
||||
typedef struct _DUPLICATE_EXTENTS_DATA {
|
||||
HANDLE FileHandle;
|
||||
LARGE_INTEGER SourceFileOffset;
|
||||
|
@ -190,9 +206,6 @@ typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER {
|
|||
#define _Requires_lock_held_(a)
|
||||
#define _Requires_exclusive_lock_held_(a)
|
||||
#define _Releases_lock_(a)
|
||||
#define _Out_writes_bytes_opt_(a)
|
||||
#define _Pre_satisfies_(a)
|
||||
#define _Post_satisfies_(a)
|
||||
#define _Releases_exclusive_lock_(a)
|
||||
#define _Dispatch_type_(a)
|
||||
#define _Create_lock_level_(a)
|
||||
|
@ -202,12 +215,14 @@ typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER {
|
|||
#define _Acquires_exclusive_lock_(a)
|
||||
#define _Acquires_shared_lock_(a)
|
||||
#endif
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
_Create_lock_level_(tree_lock)
|
||||
_Create_lock_level_(fcb_lock)
|
||||
_Lock_level_order_(tree_lock, fcb_lock)
|
||||
|
||||
#define MAX_HASH_SIZE 32
|
||||
|
||||
struct _device_extension;
|
||||
|
||||
typedef struct _fcb_nonpaged {
|
||||
|
@ -226,7 +241,7 @@ typedef struct {
|
|||
bool unique;
|
||||
bool ignore;
|
||||
bool inserted;
|
||||
uint32_t* csum;
|
||||
void* csum;
|
||||
|
||||
LIST_ENTRY list_entry;
|
||||
|
||||
|
@ -461,6 +476,7 @@ typedef struct _root {
|
|||
LONG send_ops;
|
||||
uint64_t fcbs_version;
|
||||
bool checked_for_orphans;
|
||||
bool dropped;
|
||||
LIST_ENTRY fcbs;
|
||||
LIST_ENTRY* fcbs_ptrs[256];
|
||||
LIST_ENTRY list_entry;
|
||||
|
@ -617,27 +633,42 @@ typedef struct {
|
|||
LIST_ENTRY list_entry;
|
||||
} sys_chunk;
|
||||
|
||||
enum calc_thread_type {
|
||||
calc_thread_crc32c,
|
||||
calc_thread_xxhash,
|
||||
calc_thread_sha256,
|
||||
calc_thread_blake2,
|
||||
calc_thread_decomp_zlib,
|
||||
calc_thread_decomp_lzo,
|
||||
calc_thread_decomp_zstd,
|
||||
calc_thread_comp_zlib,
|
||||
calc_thread_comp_lzo,
|
||||
calc_thread_comp_zstd,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8_t* data;
|
||||
uint32_t* csum;
|
||||
uint32_t sectors;
|
||||
LONG pos, done;
|
||||
KEVENT event;
|
||||
LONG refcount;
|
||||
LIST_ENTRY list_entry;
|
||||
void* in;
|
||||
void* out;
|
||||
unsigned int inlen, outlen, off, space_left;
|
||||
LONG left, not_started;
|
||||
KEVENT event;
|
||||
enum calc_thread_type type;
|
||||
NTSTATUS Status;
|
||||
} calc_job;
|
||||
|
||||
typedef struct {
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
HANDLE handle;
|
||||
KEVENT finished;
|
||||
unsigned int number;
|
||||
bool quit;
|
||||
} drv_calc_thread;
|
||||
|
||||
typedef struct {
|
||||
ULONG num_threads;
|
||||
LIST_ENTRY job_list;
|
||||
ERESOURCE lock;
|
||||
KSPIN_LOCK spinlock;
|
||||
drv_calc_thread* threads;
|
||||
KEVENT event;
|
||||
} drv_calc_threads;
|
||||
|
@ -744,6 +775,7 @@ typedef struct _device_extension {
|
|||
#endif
|
||||
uint64_t devices_loaded;
|
||||
superblock superblock;
|
||||
unsigned int csum_size;
|
||||
bool readonly;
|
||||
bool removing;
|
||||
bool locked;
|
||||
|
@ -839,6 +871,7 @@ typedef struct {
|
|||
void* notification_entry;
|
||||
ULONG disk_num;
|
||||
ULONG part_num;
|
||||
bool boot_volume;
|
||||
LIST_ENTRY list_entry;
|
||||
} volume_child;
|
||||
|
||||
|
@ -1134,6 +1167,7 @@ _Ret_maybenull_
|
|||
root* find_default_subvol(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, _In_opt_ PIRP Irp);
|
||||
|
||||
void do_shutdown(PIRP Irp);
|
||||
bool check_superblock_checksum(superblock* sb);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define funcname __FUNCTION__
|
||||
|
@ -1159,6 +1193,10 @@ extern uint32_t mount_readonly;
|
|||
extern uint32_t mount_no_root_dir;
|
||||
extern uint32_t no_pnp;
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
extern bool log_started;
|
||||
|
@ -1166,25 +1204,25 @@ extern uint32_t debug_log_level;
|
|||
|
||||
#ifdef DEBUG_LONG_MESSAGES
|
||||
|
||||
#define MSG(fn, file, line, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, file, line, s, ##__VA_ARGS__) : 0
|
||||
#define MSG(fn, file, line, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, file, line, s, ##__VA_ARGS__) : (void)0
|
||||
|
||||
#define TRACE(s, ...) MSG(funcname, __FILE__, __LINE__, s, 3, ##__VA_ARGS__)
|
||||
#define WARN(s, ...) MSG(funcname, __FILE__, __LINE__, s, 2, ##__VA_ARGS__)
|
||||
#define FIXME(s, ...) MSG(funcname, __FILE__, __LINE__, s, 1, ##__VA_ARGS__)
|
||||
#define ERR(s, ...) MSG(funcname, __FILE__, __LINE__, s, 1, ##__VA_ARGS__)
|
||||
|
||||
void _debug_message(_In_ const char* func, _In_ const char* file, _In_ unsigned int line, _In_ char* s, ...);
|
||||
void _debug_message(_In_ const char* func, _In_ const char* file, _In_ unsigned int line, _In_ char* s, ...) __attribute__((format(printf, 4, 5)));
|
||||
|
||||
#else
|
||||
|
||||
#define MSG(fn, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, s, ##__VA_ARGS__) : 0
|
||||
#define MSG(fn, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, s, ##__VA_ARGS__) : (void)0
|
||||
|
||||
#define TRACE(s, ...) MSG(funcname, s, 3, ##__VA_ARGS__)
|
||||
#define WARN(s, ...) MSG(funcname, s, 2, ##__VA_ARGS__)
|
||||
#define FIXME(s, ...) MSG(funcname, s, 1, ##__VA_ARGS__)
|
||||
#define ERR(s, ...) MSG(funcname, s, 1, ##__VA_ARGS__)
|
||||
|
||||
void _debug_message(_In_ const char* func, _In_ char* s, ...);
|
||||
void _debug_message(_In_ const char* func, _In_ char* s, ...) __attribute__((format(printf, 2, 3)));
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1205,8 +1243,13 @@ void _free_fcb(_Inout_ fcb* fcb, _In_ const char* func);
|
|||
// in fastio.c
|
||||
void init_fast_io_dispatch(FAST_IO_DISPATCH** fiod);
|
||||
|
||||
// in crc32c.c
|
||||
uint32_t calc_crc32c(_In_ uint32_t seed, _In_reads_bytes_(msglen) uint8_t* msg, _In_ ULONG msglen);
|
||||
// in sha256.c
|
||||
void calc_sha256(uint8_t* hash, const void* input, size_t len);
|
||||
#define SHA256_HASH_SIZE 32
|
||||
|
||||
// in blake2b-ref.c
|
||||
void blake2b(void *out, size_t outlen, const void* in, size_t inlen);
|
||||
#define BLAKE2_HASH_SIZE 32
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY* list;
|
||||
|
@ -1315,14 +1358,11 @@ bool insert_extent_chunk(_In_ device_extension* Vcb, _In_ fcb* fcb, _In_ chunk*
|
|||
_In_opt_ PIRP Irp, _In_ LIST_ENTRY* rollback, _In_ uint8_t compression, _In_ uint64_t decoded_size, _In_ bool file_write, _In_ uint64_t irp_offset);
|
||||
|
||||
NTSTATUS do_write_file(fcb* fcb, uint64_t start_data, uint64_t end_data, void* data, PIRP Irp, bool file_write, uint32_t irp_offset, LIST_ENTRY* rollback);
|
||||
NTSTATUS write_compressed(fcb* fcb, uint64_t start_data, uint64_t end_data, void* data, PIRP Irp, LIST_ENTRY* rollback);
|
||||
bool find_data_address_in_chunk(device_extension* Vcb, chunk* c, uint64_t length, uint64_t* address);
|
||||
void get_raid56_lock_range(chunk* c, uint64_t address, uint64_t length, uint64_t* lockaddr, uint64_t* locklen);
|
||||
NTSTATUS calc_csum(_In_ device_extension* Vcb, _In_reads_bytes_(sectors*Vcb->superblock.sector_size) uint8_t* data,
|
||||
_In_ uint32_t sectors, _Out_writes_bytes_(sectors*sizeof(uint32_t)) uint32_t* csum);
|
||||
void add_insert_extent_rollback(LIST_ENTRY* rollback, fcb* fcb, extent* ext);
|
||||
NTSTATUS add_extent_to_fcb(_In_ fcb* fcb, _In_ uint64_t offset, _In_reads_bytes_(edsize) EXTENT_DATA* ed, _In_ uint16_t edsize,
|
||||
_In_ bool unique, _In_opt_ _When_(return >= 0, __drv_aliasesMem) uint32_t* csum, _In_ LIST_ENTRY* rollback);
|
||||
_In_ bool unique, _In_opt_ _When_(return >= 0, __drv_aliasesMem) void* csum, _In_ LIST_ENTRY* rollback);
|
||||
void add_extent(_In_ fcb* fcb, _In_ LIST_ENTRY* prevextle, _In_ __drv_aliasesMem extent* newext);
|
||||
|
||||
// in dirctrl.c
|
||||
|
@ -1393,7 +1433,7 @@ NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusiv
|
|||
_In_ bool case_sensitive, _In_opt_ PIRP Irp);
|
||||
NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension* Vcb,
|
||||
root* subvol, uint64_t inode, uint8_t type, PANSI_STRING utf8, bool always_add_hl, fcb* parent, fcb** pfcb, POOL_TYPE pooltype, PIRP Irp);
|
||||
NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, uint32_t* csum, uint64_t start, uint64_t length, PIRP Irp);
|
||||
NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, void* csum, uint64_t start, uint64_t length, PIRP Irp);
|
||||
NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, fcb* fcb, bool ignore_size, PIRP Irp);
|
||||
NTSTATUS add_dir_child(fcb* fcb, uint64_t inode, bool subvol, PANSI_STRING utf8, PUNICODE_STRING name, uint8_t type, dir_child** pdc);
|
||||
NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension* Vcb,
|
||||
|
@ -1425,13 +1465,14 @@ NTSTATUS write_data_phys(_In_ PDEVICE_OBJECT device, _In_ PFILE_OBJECT fileobj,
|
|||
_In_reads_bytes_(length) void* data, _In_ uint32_t length);
|
||||
bool is_tree_unique(device_extension* Vcb, tree* t, PIRP Irp);
|
||||
NTSTATUS do_tree_writes(device_extension* Vcb, LIST_ENTRY* tree_writes, bool no_free);
|
||||
void add_checksum_entry(device_extension* Vcb, uint64_t address, ULONG length, uint32_t* csum, PIRP Irp);
|
||||
void add_checksum_entry(device_extension* Vcb, uint64_t address, ULONG length, void* csum, PIRP Irp);
|
||||
bool find_metadata_address_in_chunk(device_extension* Vcb, chunk* c, uint64_t* address);
|
||||
void add_trim_entry_avoid_sb(device_extension* Vcb, device* dev, uint64_t address, uint64_t size);
|
||||
NTSTATUS insert_tree_item_batch(LIST_ENTRY* batchlist, device_extension* Vcb, root* r, uint64_t objid, uint8_t objtype, uint64_t offset,
|
||||
_In_opt_ _When_(return >= 0, __drv_aliasesMem) void* data, uint16_t datalen, enum batch_operation operation);
|
||||
NTSTATUS flush_partial_stripe(device_extension* Vcb, chunk* c, partial_stripe* ps);
|
||||
NTSTATUS update_dev_item(device_extension* Vcb, device* device, PIRP Irp);
|
||||
void calc_tree_checksum(device_extension* Vcb, tree_header* th);
|
||||
|
||||
// in read.c
|
||||
|
||||
|
@ -1439,14 +1480,18 @@ _Dispatch_type_(IRP_MJ_READ)
|
|||
_Function_class_(DRIVER_DISPATCH)
|
||||
NTSTATUS __stdcall drv_read(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
|
||||
NTSTATUS read_data(_In_ device_extension* Vcb, _In_ uint64_t addr, _In_ uint32_t length, _In_reads_bytes_opt_(length*sizeof(uint32_t)/Vcb->superblock.sector_size) uint32_t* csum,
|
||||
NTSTATUS read_data(_In_ device_extension* Vcb, _In_ uint64_t addr, _In_ uint32_t length, _In_reads_bytes_opt_(length*sizeof(uint32_t)/Vcb->superblock.sector_size) void* csum,
|
||||
_In_ bool is_tree, _Out_writes_bytes_(length) uint8_t* buf, _In_opt_ chunk* c, _Out_opt_ chunk** pc, _In_opt_ PIRP Irp, _In_ uint64_t generation, _In_ bool file_read,
|
||||
_In_ ULONG priority);
|
||||
NTSTATUS read_file(fcb* fcb, uint8_t* data, uint64_t start, uint64_t length, ULONG* pbr, PIRP Irp);
|
||||
NTSTATUS read_stream(fcb* fcb, uint8_t* data, uint64_t start, ULONG length, ULONG* pbr);
|
||||
NTSTATUS do_read(PIRP Irp, bool wait, ULONG* bytes_read);
|
||||
NTSTATUS check_csum(device_extension* Vcb, uint8_t* data, uint32_t sectors, uint32_t* csum);
|
||||
NTSTATUS check_csum(device_extension* Vcb, uint8_t* data, uint32_t sectors, void* csum);
|
||||
void raid6_recover2(uint8_t* sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t* out);
|
||||
void get_tree_checksum(device_extension* Vcb, tree_header* th, void* csum);
|
||||
bool check_tree_checksum(device_extension* Vcb, tree_header* th);
|
||||
void get_sector_csum(device_extension* Vcb, void* buf, void* csum);
|
||||
bool check_sector_csum(device_extension* Vcb, void* buf, void* csum);
|
||||
|
||||
// in pnp.c
|
||||
|
||||
|
@ -1505,7 +1550,10 @@ void watch_registry(HANDLE regh);
|
|||
NTSTATUS zlib_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
|
||||
NTSTATUS lzo_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t inpageoff);
|
||||
NTSTATUS zstd_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
|
||||
NTSTATUS write_compressed_bit(fcb* fcb, uint64_t start_data, uint64_t end_data, void* data, bool* compressed, PIRP Irp, LIST_ENTRY* rollback);
|
||||
NTSTATUS write_compressed(fcb* fcb, uint64_t start_data, uint64_t end_data, void* data, PIRP Irp, LIST_ENTRY* rollback);
|
||||
NTSTATUS zlib_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int level, unsigned int* space_left);
|
||||
NTSTATUS lzo_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int* space_left);
|
||||
NTSTATUS zstd_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t level, unsigned int* space_left);
|
||||
|
||||
// in galois.c
|
||||
void galois_double(uint8_t* data, uint32_t len);
|
||||
|
@ -1525,8 +1573,12 @@ NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Ir
|
|||
_Function_class_(KSTART_ROUTINE)
|
||||
void __stdcall calc_thread(void* context);
|
||||
|
||||
NTSTATUS add_calc_job(device_extension* Vcb, uint8_t* data, uint32_t sectors, uint32_t* csum, calc_job** pcj);
|
||||
void free_calc_job(calc_job* cj);
|
||||
void do_calc_job(device_extension* Vcb, uint8_t* data, uint32_t sectors, void* csum);
|
||||
NTSTATUS add_calc_job_decomp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
|
||||
void* out, unsigned int outlen, unsigned int off, calc_job** pcj);
|
||||
NTSTATUS add_calc_job_comp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
|
||||
void* out, unsigned int outlen, calc_job** pcj);
|
||||
void calc_thread_main(device_extension* Vcb, calc_job* cj);
|
||||
|
||||
// in balance.c
|
||||
NTSTATUS start_balance(device_extension* Vcb, void* data, ULONG length, KPROCESSOR_MODE processor_mode);
|
||||
|
@ -1584,6 +1636,8 @@ NTSTATUS __stdcall compat_FsRtlValidateReparsePointBuffer(IN ULONG BufferLength,
|
|||
|
||||
// in boot.c
|
||||
void __stdcall check_system_root(PDRIVER_OBJECT DriverObject, PVOID Context, ULONG Count);
|
||||
void boot_add_device(DEVICE_OBJECT* pdo);
|
||||
extern BTRFS_UUID boot_uuid;
|
||||
|
||||
// based on function in sys/sysmacros.h
|
||||
#define makedev(major, minor) (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))
|
||||
|
@ -1624,7 +1678,7 @@ typedef struct {
|
|||
} FSRTL_ADVANCED_FCB_HEADER_NEW;
|
||||
|
||||
#define FSRTL_FCB_HEADER_V2 2
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
static __inline POPLOCK fcb_oplock(fcb* fcb) {
|
||||
if (fcb->Header.Version >= FSRTL_FCB_HEADER_V2)
|
||||
|
@ -1675,10 +1729,9 @@ static __inline bool write_fcb_compressed(fcb* fcb) {
|
|||
static __inline void do_xor(uint8_t* buf1, uint8_t* buf2, uint32_t len) {
|
||||
uint32_t j;
|
||||
#ifndef __REACTOS__
|
||||
#if defined(_X86_) || defined(_AMD64_)
|
||||
__m128i x1, x2;
|
||||
#endif
|
||||
|
||||
#ifndef __REACTOS__
|
||||
if (have_sse2 && ((uintptr_t)buf1 & 0xf) == 0 && ((uintptr_t)buf2 & 0xf) == 0) {
|
||||
while (len >= 16) {
|
||||
x1 = _mm_load_si128((__m128i*)buf1);
|
||||
|
@ -1686,12 +1739,28 @@ static __inline void do_xor(uint8_t* buf1, uint8_t* buf2, uint32_t len) {
|
|||
x1 = _mm_xor_si128(x1, x2);
|
||||
_mm_store_si128((__m128i*)buf1, x1);
|
||||
|
||||
buf1 += 16;
|
||||
buf2 += 16;
|
||||
len -= 16;
|
||||
}
|
||||
}
|
||||
#elif defined(_ARM_) || defined(_ARM64_)
|
||||
uint64x2_t x1, x2;
|
||||
|
||||
if (((uintptr_t)buf1 & 0xf) == 0 && ((uintptr_t)buf2 & 0xf) == 0) {
|
||||
while (len >= 16) {
|
||||
x1 = vld1q_u64((const uint64_t*)buf1);
|
||||
x2 = vld1q_u64((const uint64_t*)buf2);
|
||||
x1 = veorq_u64(x1, x2);
|
||||
vst1q_u64((uint64_t*)buf1, x1);
|
||||
|
||||
buf1 += 16;
|
||||
buf2 += 16;
|
||||
len -= 16;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
*buf1 ^= *buf2;
|
||||
|
@ -1895,7 +1964,7 @@ typedef struct _PEB {
|
|||
PVOID Reserved7[1];
|
||||
ULONG SessionId;
|
||||
} PEB,*PPEB;
|
||||
#endif
|
||||
#endif /* __REACTOS__ */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__kernel_entry
|
||||
|
|
|
@ -16,11 +16,174 @@
|
|||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "btrfs_drv.h"
|
||||
#include "xxhash.h"
|
||||
#include "crc32c.h"
|
||||
|
||||
#define SECTOR_BLOCK 16
|
||||
void calc_thread_main(device_extension* Vcb, calc_job* cj) {
|
||||
while (true) {
|
||||
KIRQL irql;
|
||||
calc_job* cj2;
|
||||
uint8_t* src;
|
||||
void* dest;
|
||||
bool last_one = false;
|
||||
|
||||
NTSTATUS add_calc_job(device_extension* Vcb, uint8_t* data, uint32_t sectors, uint32_t* csum, calc_job** pcj) {
|
||||
KeAcquireSpinLock(&Vcb->calcthreads.spinlock, &irql);
|
||||
|
||||
if (cj && cj->not_started == 0) {
|
||||
KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cj)
|
||||
cj2 = cj;
|
||||
else {
|
||||
if (IsListEmpty(&Vcb->calcthreads.job_list)) {
|
||||
KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
|
||||
break;
|
||||
}
|
||||
|
||||
cj2 = CONTAINING_RECORD(Vcb->calcthreads.job_list.Flink, calc_job, list_entry);
|
||||
}
|
||||
|
||||
src = cj2->in;
|
||||
dest = cj2->out;
|
||||
|
||||
switch (cj2->type) {
|
||||
case calc_thread_crc32c:
|
||||
case calc_thread_xxhash:
|
||||
case calc_thread_sha256:
|
||||
case calc_thread_blake2:
|
||||
cj2->in = (uint8_t*)cj2->in + Vcb->superblock.sector_size;
|
||||
cj2->out = (uint8_t*)cj2->out + Vcb->csum_size;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cj2->not_started--;
|
||||
|
||||
if (cj2->not_started == 0) {
|
||||
RemoveEntryList(&cj2->list_entry);
|
||||
last_one = true;
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
|
||||
|
||||
switch (cj2->type) {
|
||||
case calc_thread_crc32c:
|
||||
*(uint32_t*)dest = ~calc_crc32c(0xffffffff, src, Vcb->superblock.sector_size);
|
||||
break;
|
||||
|
||||
case calc_thread_xxhash:
|
||||
*(uint64_t*)dest = XXH64(src, Vcb->superblock.sector_size, 0);
|
||||
break;
|
||||
|
||||
case calc_thread_sha256:
|
||||
calc_sha256(dest, src, Vcb->superblock.sector_size);
|
||||
break;
|
||||
|
||||
case calc_thread_blake2:
|
||||
blake2b(dest, BLAKE2_HASH_SIZE, src, Vcb->superblock.sector_size);
|
||||
break;
|
||||
|
||||
case calc_thread_decomp_zlib:
|
||||
cj2->Status = zlib_decompress(src, cj2->inlen, dest, cj2->outlen);
|
||||
|
||||
if (!NT_SUCCESS(cj2->Status))
|
||||
ERR("zlib_decompress returned %08lx\n", cj2->Status);
|
||||
break;
|
||||
|
||||
case calc_thread_decomp_lzo:
|
||||
cj2->Status = lzo_decompress(src, cj2->inlen, dest, cj2->outlen, cj2->off);
|
||||
|
||||
if (!NT_SUCCESS(cj2->Status))
|
||||
ERR("lzo_decompress returned %08lx\n", cj2->Status);
|
||||
break;
|
||||
|
||||
case calc_thread_decomp_zstd:
|
||||
cj2->Status = zstd_decompress(src, cj2->inlen, dest, cj2->outlen);
|
||||
|
||||
if (!NT_SUCCESS(cj2->Status))
|
||||
ERR("zstd_decompress returned %08lx\n", cj2->Status);
|
||||
break;
|
||||
|
||||
case calc_thread_comp_zlib:
|
||||
cj2->Status = zlib_compress(src, cj2->inlen, dest, cj2->outlen, Vcb->options.zlib_level, &cj2->space_left);
|
||||
|
||||
if (!NT_SUCCESS(cj2->Status))
|
||||
ERR("zlib_compress returned %08lx\n", cj2->Status);
|
||||
break;
|
||||
|
||||
case calc_thread_comp_lzo:
|
||||
cj2->Status = lzo_compress(src, cj2->inlen, dest, cj2->outlen, &cj2->space_left);
|
||||
|
||||
if (!NT_SUCCESS(cj2->Status))
|
||||
ERR("lzo_compress returned %08lx\n", cj2->Status);
|
||||
break;
|
||||
|
||||
case calc_thread_comp_zstd:
|
||||
cj2->Status = zstd_compress(src, cj2->inlen, dest, cj2->outlen, Vcb->options.zstd_level, &cj2->space_left);
|
||||
|
||||
if (!NT_SUCCESS(cj2->Status))
|
||||
ERR("zstd_compress returned %08lx\n", cj2->Status);
|
||||
break;
|
||||
}
|
||||
|
||||
if (InterlockedDecrement(&cj2->left) == 0)
|
||||
KeSetEvent(&cj2->event, 0, false);
|
||||
|
||||
if (last_one)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void do_calc_job(device_extension* Vcb, uint8_t* data, uint32_t sectors, void* csum) {
|
||||
KIRQL irql;
|
||||
calc_job cj;
|
||||
|
||||
cj.in = data;
|
||||
cj.out = csum;
|
||||
cj.left = cj.not_started = sectors;
|
||||
|
||||
switch (Vcb->superblock.csum_type) {
|
||||
case CSUM_TYPE_CRC32C:
|
||||
cj.type = calc_thread_crc32c;
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_XXHASH:
|
||||
cj.type = calc_thread_xxhash;
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_SHA256:
|
||||
cj.type = calc_thread_sha256;
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_BLAKE2:
|
||||
cj.type = calc_thread_blake2;
|
||||
break;
|
||||
}
|
||||
|
||||
KeInitializeEvent(&cj.event, NotificationEvent, false);
|
||||
|
||||
KeAcquireSpinLock(&Vcb->calcthreads.spinlock, &irql);
|
||||
|
||||
InsertTailList(&Vcb->calcthreads.job_list, &cj.list_entry);
|
||||
|
||||
KeSetEvent(&Vcb->calcthreads.event, 0, false);
|
||||
KeClearEvent(&Vcb->calcthreads.event);
|
||||
|
||||
KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
|
||||
|
||||
calc_thread_main(Vcb, &cj);
|
||||
|
||||
KeWaitForSingleObject(&cj.event, Executive, KernelMode, false, NULL);
|
||||
}
|
||||
|
||||
NTSTATUS add_calc_job_decomp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
|
||||
void* out, unsigned int outlen, unsigned int off, calc_job** pcj) {
|
||||
calc_job* cj;
|
||||
KIRQL irql;
|
||||
|
||||
cj = ExAllocatePoolWithTag(NonPagedPool, sizeof(calc_job), ALLOC_TAG);
|
||||
if (!cj) {
|
||||
|
@ -28,67 +191,100 @@ NTSTATUS add_calc_job(device_extension* Vcb, uint8_t* data, uint32_t sectors, ui
|
|||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
cj->data = data;
|
||||
cj->sectors = sectors;
|
||||
cj->csum = csum;
|
||||
cj->pos = 0;
|
||||
cj->done = 0;
|
||||
cj->refcount = 1;
|
||||
cj->in = in;
|
||||
cj->inlen = inlen;
|
||||
cj->out = out;
|
||||
cj->outlen = outlen;
|
||||
cj->off = off;
|
||||
cj->left = cj->not_started = 1;
|
||||
cj->Status = STATUS_SUCCESS;
|
||||
|
||||
switch (compression) {
|
||||
case BTRFS_COMPRESSION_ZLIB:
|
||||
cj->type = calc_thread_decomp_zlib;
|
||||
break;
|
||||
|
||||
case BTRFS_COMPRESSION_LZO:
|
||||
cj->type = calc_thread_decomp_lzo;
|
||||
break;
|
||||
|
||||
case BTRFS_COMPRESSION_ZSTD:
|
||||
cj->type = calc_thread_decomp_zstd;
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("unexpected compression type %x\n", compression);
|
||||
ExFreePool(cj);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
KeInitializeEvent(&cj->event, NotificationEvent, false);
|
||||
|
||||
ExAcquireResourceExclusiveLite(&Vcb->calcthreads.lock, true);
|
||||
KeAcquireSpinLock(&Vcb->calcthreads.spinlock, &irql);
|
||||
|
||||
InsertTailList(&Vcb->calcthreads.job_list, &cj->list_entry);
|
||||
|
||||
KeSetEvent(&Vcb->calcthreads.event, 0, false);
|
||||
KeClearEvent(&Vcb->calcthreads.event);
|
||||
|
||||
ExReleaseResourceLite(&Vcb->calcthreads.lock);
|
||||
KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
|
||||
|
||||
*pcj = cj;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void free_calc_job(calc_job* cj) {
|
||||
LONG rc = InterlockedDecrement(&cj->refcount);
|
||||
NTSTATUS add_calc_job_comp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
|
||||
void* out, unsigned int outlen, calc_job** pcj) {
|
||||
calc_job* cj;
|
||||
KIRQL irql;
|
||||
|
||||
if (rc == 0)
|
||||
ExFreePool(cj);
|
||||
}
|
||||
|
||||
static bool do_calc(device_extension* Vcb, calc_job* cj) {
|
||||
LONG pos, done;
|
||||
uint32_t* csum;
|
||||
uint8_t* data;
|
||||
ULONG blocksize, i;
|
||||
|
||||
pos = InterlockedIncrement(&cj->pos) - 1;
|
||||
|
||||
if ((uint32_t)pos * SECTOR_BLOCK >= cj->sectors)
|
||||
return false;
|
||||
|
||||
csum = &cj->csum[pos * SECTOR_BLOCK];
|
||||
data = cj->data + (pos * SECTOR_BLOCK * Vcb->superblock.sector_size);
|
||||
|
||||
blocksize = min(SECTOR_BLOCK, cj->sectors - (pos * SECTOR_BLOCK));
|
||||
for (i = 0; i < blocksize; i++) {
|
||||
*csum = ~calc_crc32c(0xffffffff, data, Vcb->superblock.sector_size);
|
||||
csum++;
|
||||
data += Vcb->superblock.sector_size;
|
||||
cj = ExAllocatePoolWithTag(NonPagedPool, sizeof(calc_job), ALLOC_TAG);
|
||||
if (!cj) {
|
||||
ERR("out of memory\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
done = InterlockedIncrement(&cj->done);
|
||||
cj->in = in;
|
||||
cj->inlen = inlen;
|
||||
cj->out = out;
|
||||
cj->outlen = outlen;
|
||||
cj->left = cj->not_started = 1;
|
||||
cj->Status = STATUS_SUCCESS;
|
||||
|
||||
if ((uint32_t)done * SECTOR_BLOCK >= cj->sectors) {
|
||||
ExAcquireResourceExclusiveLite(&Vcb->calcthreads.lock, true);
|
||||
RemoveEntryList(&cj->list_entry);
|
||||
ExReleaseResourceLite(&Vcb->calcthreads.lock);
|
||||
switch (compression) {
|
||||
case BTRFS_COMPRESSION_ZLIB:
|
||||
cj->type = calc_thread_comp_zlib;
|
||||
break;
|
||||
|
||||
KeSetEvent(&cj->event, 0, false);
|
||||
case BTRFS_COMPRESSION_LZO:
|
||||
cj->type = calc_thread_comp_lzo;
|
||||
break;
|
||||
|
||||
case BTRFS_COMPRESSION_ZSTD:
|
||||
cj->type = calc_thread_comp_zstd;
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("unexpected compression type %x\n", compression);
|
||||
ExFreePool(cj);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
return true;
|
||||
KeInitializeEvent(&cj->event, NotificationEvent, false);
|
||||
|
||||
KeAcquireSpinLock(&Vcb->calcthreads.spinlock, &irql);
|
||||
|
||||
InsertTailList(&Vcb->calcthreads.job_list, &cj->list_entry);
|
||||
|
||||
KeSetEvent(&Vcb->calcthreads.event, 0, false);
|
||||
KeClearEvent(&Vcb->calcthreads.event);
|
||||
|
||||
KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
|
||||
|
||||
*pcj = cj;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Function_class_(KSTART_ROUTINE)
|
||||
|
@ -98,32 +294,12 @@ void __stdcall calc_thread(void* context) {
|
|||
|
||||
ObReferenceObject(thread->DeviceObject);
|
||||
|
||||
KeSetSystemAffinityThread((KAFFINITY)(1 << thread->number));
|
||||
|
||||
while (true) {
|
||||
KeWaitForSingleObject(&Vcb->calcthreads.event, Executive, KernelMode, false, NULL);
|
||||
|
||||
while (true) {
|
||||
calc_job* cj;
|
||||
bool b;
|
||||
|
||||
ExAcquireResourceExclusiveLite(&Vcb->calcthreads.lock, true);
|
||||
|
||||
if (IsListEmpty(&Vcb->calcthreads.job_list)) {
|
||||
ExReleaseResourceLite(&Vcb->calcthreads.lock);
|
||||
break;
|
||||
}
|
||||
|
||||
cj = CONTAINING_RECORD(Vcb->calcthreads.job_list.Flink, calc_job, list_entry);
|
||||
cj->refcount++;
|
||||
|
||||
ExReleaseResourceLite(&Vcb->calcthreads.lock);
|
||||
|
||||
b = do_calc(Vcb, cj);
|
||||
|
||||
free_calc_job(cj);
|
||||
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
calc_thread_main(Vcb, NULL);
|
||||
|
||||
if (thread->quit)
|
||||
break;
|
||||
|
|
File diff suppressed because it is too large
Load diff
112
drivers/filesystems/btrfs/crc32c-amd64.S
Normal file
112
drivers/filesystems/btrfs/crc32c-amd64.S
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* Copyright (c) Mark Harmstone 2020
|
||||
*
|
||||
* This file is part of WinBtrfs.
|
||||
*
|
||||
* WinBtrfs is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public Licence as published by
|
||||
* the Free Software Foundation, either version 3 of the Licence, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WinBtrfs is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public Licence for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public Licence
|
||||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
EXTERN _crctable:QWORD
|
||||
|
||||
.code64
|
||||
|
||||
|
||||
/* uint32_t __stdcall calc_crc32c_sw(uint32_t seed, uint8_t* msg, uint32_t msglen); */
|
||||
|
||||
PUBLIC _calc_crc32c_sw@12
|
||||
_calc_crc32c_sw@12:
|
||||
|
||||
/* rax = crc / seed
|
||||
* rdx = buf
|
||||
* r8 = len
|
||||
* rcx = tmp
|
||||
* r10 = tmp2 */
|
||||
|
||||
mov rax, rcx
|
||||
|
||||
crcloop:
|
||||
test r8, r8
|
||||
jz crcend
|
||||
|
||||
mov rcx, rax
|
||||
shr rcx, 8
|
||||
mov r10b, byte ptr [rdx]
|
||||
xor al, r10b
|
||||
and rax, 255
|
||||
shl rax, 2
|
||||
mov rax, dword ptr [_crctable + rax]
|
||||
xor rax, rcx
|
||||
|
||||
inc rdx
|
||||
dec r8
|
||||
|
||||
jmp crcloop
|
||||
|
||||
crcend:
|
||||
ret
|
||||
|
||||
/****************************************************/
|
||||
|
||||
/* uint32_t __stdcall calc_crc32c_hw(uint32_t seed, uint8_t* msg, uint32_t msglen); */
|
||||
|
||||
PUBLIC _calc_crc32c_hw@12:
|
||||
_calc_crc32c_hw@12:
|
||||
|
||||
/* rax = crc / seed
|
||||
* rdx = buf
|
||||
* r8 = len */
|
||||
|
||||
mov rax, rcx
|
||||
|
||||
crchw_loop:
|
||||
cmp r8, 8
|
||||
jl crchw_stragglers
|
||||
|
||||
crc32 rax, qword ptr [rdx]
|
||||
|
||||
add rdx, 8
|
||||
sub r8, 8
|
||||
jmp crchw_loop
|
||||
|
||||
crchw_stragglers:
|
||||
cmp r8, 4
|
||||
jl crchw_stragglers2
|
||||
|
||||
crc32 eax, dword ptr [rdx]
|
||||
|
||||
add rdx, 4
|
||||
sub r8, 4
|
||||
|
||||
crchw_stragglers2:
|
||||
cmp r8, 2
|
||||
jl crchw_stragglers3
|
||||
|
||||
crc32 eax, word ptr [rdx]
|
||||
|
||||
add rdx, 2
|
||||
sub r8, 2
|
||||
|
||||
crchw_stragglers3:
|
||||
test r8, r8
|
||||
jz crchw_end
|
||||
|
||||
crc32 eax, byte ptr [rdx]
|
||||
inc rdx
|
||||
dec r8
|
||||
jmp crchw_stragglers3
|
||||
|
||||
crchw_end:
|
||||
ret
|
||||
|
||||
END
|
122
drivers/filesystems/btrfs/crc32c-x86.S
Normal file
122
drivers/filesystems/btrfs/crc32c-x86.S
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* Copyright (c) Mark Harmstone 2020
|
||||
*
|
||||
* This file is part of WinBtrfs.
|
||||
*
|
||||
* WinBtrfs is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public Licence as published by
|
||||
* the Free Software Foundation, either version 3 of the Licence, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WinBtrfs is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public Licence for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public Licence
|
||||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
EXTERN _crctable:DWORD
|
||||
|
||||
.code
|
||||
|
||||
/* uint32_t __stdcall calc_crc32c_sw(uint32_t seed, uint8_t* msg, uint32_t msglen); */
|
||||
|
||||
PUBLIC _calc_crc32c_sw@12
|
||||
_calc_crc32c_sw@12:
|
||||
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov eax, [ebp+8]
|
||||
mov edx, [ebp+12]
|
||||
mov ebx, [ebp+16]
|
||||
|
||||
/* eax = crc / seed
|
||||
* ebx = len
|
||||
* esi = tmp
|
||||
* edx = buf
|
||||
* ecx = tmp2 */
|
||||
|
||||
crcloop:
|
||||
test ebx, ebx
|
||||
jz crcend
|
||||
|
||||
mov esi, eax
|
||||
shr esi, 8
|
||||
mov cl, byte ptr [edx]
|
||||
xor al, cl
|
||||
and eax, 255
|
||||
shl eax, 2
|
||||
mov eax, [_crctable + eax]
|
||||
xor eax, esi
|
||||
|
||||
inc edx
|
||||
dec ebx
|
||||
|
||||
jmp crcloop
|
||||
|
||||
crcend:
|
||||
pop ebx
|
||||
pop esi
|
||||
|
||||
pop ebp
|
||||
|
||||
ret 12
|
||||
|
||||
/****************************************************/
|
||||
|
||||
/* uint32_t __stdcall calc_crc32c_hw(uint32_t seed, uint8_t* msg, uint32_t msglen); */
|
||||
|
||||
PUBLIC _calc_crc32c_hw@12
|
||||
_calc_crc32c_hw@12:
|
||||
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
mov eax, [ebp+8]
|
||||
mov edx, [ebp+12]
|
||||
mov ecx, [ebp+16]
|
||||
|
||||
/* eax = crc / seed
|
||||
* ecx = len
|
||||
* edx = buf */
|
||||
|
||||
crchw_loop:
|
||||
cmp ecx, 4
|
||||
jl crchw_stragglers
|
||||
|
||||
crc32 eax, dword ptr [edx]
|
||||
|
||||
add edx, 4
|
||||
sub ecx, 4
|
||||
jmp crchw_loop
|
||||
|
||||
crchw_stragglers:
|
||||
cmp ecx, 2
|
||||
jl crchw_stragglers2
|
||||
|
||||
crc32 eax, word ptr [edx]
|
||||
|
||||
add edx, 2
|
||||
sub ecx, 2
|
||||
|
||||
crchw_stragglers2:
|
||||
test ecx, ecx
|
||||
jz crchw_end
|
||||
|
||||
crc32 eax, byte ptr [edx]
|
||||
inc edx
|
||||
dec ecx
|
||||
jmp crchw_stragglers2
|
||||
|
||||
crchw_end:
|
||||
pop ebp
|
||||
|
||||
ret 12
|
||||
|
||||
END
|
|
@ -15,18 +15,14 @@
|
|||
* You should have received a copy of the GNU Lesser General Public Licence
|
||||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <windef.h>
|
||||
#ifndef __REACTOS__
|
||||
#include <smmintrin.h>
|
||||
#endif /* __REACTOS__ */
|
||||
#include "crc32c.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sal.h>
|
||||
|
||||
#ifndef __REACTOS__
|
||||
extern bool have_sse42;
|
||||
#endif /* __REACTOS__ */
|
||||
crc_func calc_crc32c = calc_crc32c_sw;
|
||||
|
||||
static const uint32_t crctable[] = {
|
||||
const uint32_t crctable[] = {
|
||||
0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb,
|
||||
0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24,
|
||||
0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
|
||||
|
@ -61,75 +57,15 @@ static const uint32_t crctable[] = {
|
|||
0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351,
|
||||
};
|
||||
|
||||
#ifndef __REACTOS__
|
||||
// HW code taken from https://github.com/rurban/smhasher/blob/master/crc32_hw.c
|
||||
#define ALIGN_SIZE 0x08UL
|
||||
#define ALIGN_MASK (ALIGN_SIZE - 1)
|
||||
#define CALC_CRC(op, crc, type, buf, len) \
|
||||
do { \
|
||||
for (; (len) >= sizeof (type); (len) -= sizeof(type), buf += sizeof (type)) { \
|
||||
(crc) = op((crc), *(type *) (buf)); \
|
||||
} \
|
||||
} while(0)
|
||||
// x86 and amd64 versions live in asm files
|
||||
#if !defined(_X86_) && !defined(_AMD64_)
|
||||
uint32_t __stdcall calc_crc32c_sw(_In_ uint32_t seed, _In_reads_bytes_(msglen) uint8_t* msg, _In_ uint32_t msglen) {
|
||||
uint32_t rem = seed;
|
||||
|
||||
static uint32_t crc32c_hw(const void *input, ULONG len, uint32_t crc) {
|
||||
const char* buf = (const char*)input;
|
||||
|
||||
// Annoyingly, the CRC32 intrinsics don't work properly in modern versions of MSVC -
|
||||
// it compiles _mm_crc32_u8 as if it was _mm_crc32_u32. And because we're apparently
|
||||
// not allowed to use inline asm on amd64, there's no easy way to fix this!
|
||||
|
||||
for (; (len > 0) && ((size_t)buf & ALIGN_MASK); len--, buf++) {
|
||||
#ifdef _MSC_VER
|
||||
crc = crctable[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
||||
#else
|
||||
crc = _mm_crc32_u8(crc, *buf);
|
||||
#endif
|
||||
for (uint32_t i = 0; i < msglen; i++) {
|
||||
rem = crctable[(rem ^ msg[i]) & 0xff] ^ (rem >> 8);
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4244) // _mm_crc32_u64 wants to return uint64_t(!)
|
||||
#pragma warning(disable:4242)
|
||||
#endif
|
||||
CALC_CRC(_mm_crc32_u64, crc, uint64_t, buf, len);
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
CALC_CRC(_mm_crc32_u32, crc, uint32_t, buf, len);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
for (; len > 0; len--, buf++) {
|
||||
crc = crctable[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
||||
}
|
||||
#else
|
||||
CALC_CRC(_mm_crc32_u16, crc, uint16_t, buf, len);
|
||||
CALC_CRC(_mm_crc32_u8, crc, uint8_t, buf, len);
|
||||
#endif
|
||||
|
||||
return crc;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t calc_crc32c(_In_ uint32_t seed, _In_reads_bytes_(msglen) uint8_t* msg, _In_ ULONG msglen) {
|
||||
uint32_t rem;
|
||||
ULONG i;
|
||||
|
||||
#ifndef __REACTOS__
|
||||
if (have_sse42) {
|
||||
return crc32c_hw(msg, msglen, seed);
|
||||
} else {
|
||||
#endif
|
||||
rem = seed;
|
||||
|
||||
for (i = 0; i < msglen; i++) {
|
||||
rem = crctable[(rem ^ msg[i]) & 0xff] ^ (rem >> 8);
|
||||
}
|
||||
#ifndef __REACTOS__
|
||||
}
|
||||
#endif
|
||||
|
||||
return rem;
|
||||
}
|
||||
#endif
|
||||
|
|
13
drivers/filesystems/btrfs/crc32c.h
Normal file
13
drivers/filesystems/btrfs/crc32c.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_X86_) || defined(_AMD64_)
|
||||
uint32_t __stdcall calc_crc32c_hw(uint32_t seed, uint8_t* msg, uint32_t msglen);
|
||||
#endif
|
||||
|
||||
uint32_t __stdcall calc_crc32c_sw(uint32_t seed, uint8_t* msg, uint32_t msglen);
|
||||
|
||||
typedef uint32_t (__stdcall *crc_func)(uint32_t seed, uint8_t* msg, uint32_t msglen);
|
||||
|
||||
extern crc_func calc_crc32c;
|
|
@ -19,6 +19,7 @@
|
|||
#include <sys/stat.h>
|
||||
#endif /* __REACTOS__ */
|
||||
#include "btrfs_drv.h"
|
||||
#include "crc32c.h"
|
||||
#include <ntddstor.h>
|
||||
|
||||
extern PDEVICE_OBJECT master_devobj;
|
||||
|
@ -33,8 +34,21 @@ static const WCHAR root_dir_utf16[] = L"$Root";
|
|||
|
||||
// Windows 10
|
||||
#define ATOMIC_CREATE_ECP_IN_FLAG_REPARSE_POINT_SPECIFIED 0x0002
|
||||
#define ATOMIC_CREATE_ECP_IN_FLAG_OP_FLAGS_SPECIFIED 0x0080
|
||||
#define ATOMIC_CREATE_ECP_IN_FLAG_BEST_EFFORT 0x0100
|
||||
|
||||
#define ATOMIC_CREATE_ECP_OUT_FLAG_REPARSE_POINT_SET 0x0002
|
||||
#define ATOMIC_CREATE_ECP_OUT_FLAG_OP_FLAGS_HONORED 0x0080
|
||||
|
||||
#define ATOMIC_CREATE_ECP_IN_OP_FLAG_CASE_SENSITIVE_FLAGS_SPECIFIED 1
|
||||
#define ATOMIC_CREATE_ECP_OUT_OP_FLAG_CASE_SENSITIVE_FLAGS_SET 1
|
||||
|
||||
typedef struct _FILE_TIMESTAMPS {
|
||||
LARGE_INTEGER CreationTime;
|
||||
LARGE_INTEGER LastAccessTime;
|
||||
LARGE_INTEGER LastWriteTime;
|
||||
LARGE_INTEGER ChangeTime;
|
||||
} FILE_TIMESTAMPS, *PFILE_TIMESTAMPS;
|
||||
|
||||
typedef struct _ATOMIC_CREATE_ECP_CONTEXT {
|
||||
USHORT Size;
|
||||
|
@ -44,9 +58,23 @@ typedef struct _ATOMIC_CREATE_ECP_CONTEXT {
|
|||
PREPARSE_DATA_BUFFER ReparseBuffer;
|
||||
LONGLONG FileSize;
|
||||
LONGLONG ValidDataLength;
|
||||
PFILE_TIMESTAMPS FileTimestamps;
|
||||
ULONG FileAttributes;
|
||||
ULONG UsnSourceInfo;
|
||||
USN Usn;
|
||||
ULONG SuppressFileAttributeInheritanceMask;
|
||||
ULONG InOpFlags;
|
||||
ULONG OutOpFlags;
|
||||
ULONG InGenFlags;
|
||||
ULONG OutGenFlags;
|
||||
ULONG CaseSensitiveFlagsMask;
|
||||
ULONG InCaseSensitiveFlags;
|
||||
ULONG OutCaseSensitiveFlags;
|
||||
} ATOMIC_CREATE_ECP_CONTEXT, *PATOMIC_CREATE_ECP_CONTEXT;
|
||||
|
||||
static const GUID GUID_ECP_ATOMIC_CREATE = { 0x4720bd83, 0x52ac, 0x4104, { 0xa1, 0x30, 0xd1, 0xec, 0x6a, 0x8c, 0xc8, 0xe5 } };
|
||||
static const GUID GUID_ECP_QUERY_ON_CREATE = { 0x1aca62e9, 0xabb4, 0x4ff2, { 0xbb, 0x5c, 0x1c, 0x79, 0x02, 0x5e, 0x41, 0x7f } };
|
||||
static const GUID GUID_ECP_CREATE_REDIRECTION = { 0x188d6bd6, 0xa126, 0x4fa8, { 0xbd, 0xf2, 0x1c, 0xcd, 0xf8, 0x96, 0xf3, 0xe0 } };
|
||||
|
||||
fcb* create_fcb(device_extension* Vcb, POOL_TYPE pool_type) {
|
||||
fcb* fcb;
|
||||
|
@ -160,7 +188,7 @@ NTSTATUS find_file_in_dir(PUNICODE_STRING filename, fcb* fcb, root** subvol, uin
|
|||
Status = RtlUpcaseUnicodeString(&fnus, filename, true);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else
|
||||
|
@ -415,12 +443,13 @@ cleanup:
|
|||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, uint32_t* csum, uint64_t start, uint64_t length, PIRP Irp) {
|
||||
NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, void* csum, uint64_t start, uint64_t length, PIRP Irp) {
|
||||
NTSTATUS Status;
|
||||
KEY searchkey;
|
||||
traverse_ptr tp, next_tp;
|
||||
uint64_t i, j;
|
||||
bool b;
|
||||
void* ptr = csum;
|
||||
|
||||
searchkey.obj_id = EXTENT_CSUM_ID;
|
||||
searchkey.obj_type = TYPE_EXTENT_CSUM;
|
||||
|
@ -428,7 +457,7 @@ NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb
|
|||
|
||||
Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -442,13 +471,15 @@ NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb
|
|||
else
|
||||
j = ((start - tp.item->key.offset) / Vcb->superblock.sector_size) + i;
|
||||
|
||||
if (j * sizeof(uint32_t) > tp.item->size || tp.item->key.offset > start + (i * Vcb->superblock.sector_size)) {
|
||||
if (j * Vcb->csum_size > tp.item->size || tp.item->key.offset > start + (i * Vcb->superblock.sector_size)) {
|
||||
ERR("checksum not found for %I64x\n", start + (i * Vcb->superblock.sector_size));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
readlen = (ULONG)min((tp.item->size / sizeof(uint32_t)) - j, length - i);
|
||||
RtlCopyMemory(&csum[i], tp.item->data + (j * sizeof(uint32_t)), readlen * sizeof(uint32_t));
|
||||
readlen = (ULONG)min((tp.item->size / Vcb->csum_size) - j, length - i);
|
||||
RtlCopyMemory(ptr, tp.item->data + (j * Vcb->csum_size), readlen * Vcb->csum_size);
|
||||
|
||||
ptr = (uint8_t*)ptr + (readlen * Vcb->csum_size);
|
||||
i += readlen;
|
||||
|
||||
if (i == length)
|
||||
|
@ -501,7 +532,7 @@ NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
|
||||
Status = find_item(Vcb, fcb->subvol, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -518,7 +549,7 @@ NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
ULONG utf16len;
|
||||
|
||||
if (tp.item->size < sizeof(DIR_ITEM)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(DIR_ITEM));
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(DIR_ITEM));
|
||||
goto cont;
|
||||
}
|
||||
|
||||
|
@ -529,7 +560,7 @@ NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &utf16len, di->name, di->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
goto cont;
|
||||
}
|
||||
|
||||
|
@ -568,7 +599,7 @@ NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
|
||||
Status = utf8_to_utf16(dc->name.Buffer, utf16len, &utf16len, di->name, di->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -577,7 +608,7 @@ NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&dc->name_uc, &dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -646,7 +677,7 @@ cont:
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&dc->name_uc, &dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -750,7 +781,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = find_item(Vcb, subvol, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -822,7 +853,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, ir->name, ir->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
ExFreePool(hl);
|
||||
reap_fcb(fcb);
|
||||
return Status;
|
||||
|
@ -844,7 +875,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = utf8_to_utf16(hl->name.Buffer, stringlen, &stringlen, ir->name, ir->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(hl->name.Buffer);
|
||||
ExFreePool(hl);
|
||||
reap_fcb(fcb);
|
||||
|
@ -887,7 +918,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, ier->name, ier->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
ExFreePool(hl);
|
||||
reap_fcb(fcb);
|
||||
return Status;
|
||||
|
@ -909,7 +940,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = utf8_to_utf16(hl->name.Buffer, stringlen, &stringlen, ier->name, ier->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(hl->name.Buffer);
|
||||
ExFreePool(hl);
|
||||
reap_fcb(fcb);
|
||||
|
@ -929,7 +960,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
static const char xapref[] = "user.";
|
||||
|
||||
if (tp.item->size < offsetof(DIR_ITEM, name[0])) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, offsetof(DIR_ITEM, name[0]));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, offsetof(DIR_ITEM, name[0]));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -961,7 +992,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
Status = IoCheckEaBufferValidity((FILE_FULL_EA_INFORMATION*)&di->name[di->n], di->m, &offset);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoCheckEaBufferValidity returned %08x (error at offset %u)\n", Status, offset);
|
||||
WARN("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
|
||||
else {
|
||||
FILE_FULL_EA_INFORMATION* eainfo;
|
||||
|
||||
|
@ -1055,7 +1086,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &utf16len, &di->name[sizeof(xapref) - 1], di->n + 1 - sizeof(xapref));
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1092,7 +1123,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = utf8_to_utf16(dc->name.Buffer, utf16len, &utf16len, dc->utf8.Buffer, dc->utf8.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -1102,7 +1133,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&dc->name_uc, &dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -1145,7 +1176,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
ed = (EXTENT_DATA*)tp.item->data;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_DATA)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_DATA));
|
||||
|
||||
reap_fcb(fcb);
|
||||
|
@ -1156,7 +1187,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
EXTENT_DATA2* ed2 = (EXTENT_DATA2*)&ed->data[0];
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_DATA) - 1 + sizeof(EXTENT_DATA2)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_DATA) - 1 + sizeof(EXTENT_DATA2));
|
||||
|
||||
reap_fcb(fcb);
|
||||
|
@ -1192,7 +1223,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
if (fcb->type == BTRFS_TYPE_DIRECTORY) {
|
||||
Status = load_dir_children(Vcb, fcb, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("load_dir_children returned %08x\n", Status);
|
||||
ERR("load_dir_children returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1309,7 +1340,7 @@ NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lo
|
|||
}
|
||||
}
|
||||
|
||||
if (fcb->inode == SUBVOL_ROOT_INODE && fcb->subvol->id == BTRFS_ROOT_FSTREE)
|
||||
if (fcb->inode == SUBVOL_ROOT_INODE && fcb->subvol->id == BTRFS_ROOT_FSTREE && fcb->subvol != Vcb->root_fileref->fcb->subvol)
|
||||
fcb->atts |= FILE_ATTRIBUTE_HIDDEN;
|
||||
|
||||
subvol->fcbs_version++;
|
||||
|
@ -1382,7 +1413,7 @@ static NTSTATUS open_fcb_stream(_Requires_lock_held_(_Curr_->tree_lock) _Require
|
|||
|
||||
Status = find_item(Vcb, parent->subvol, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1439,7 +1470,7 @@ NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_ex
|
|||
if (!case_sensitive) {
|
||||
Status = RtlUpcaseUnicodeString(&name_uc, name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1496,7 +1527,7 @@ NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_ex
|
|||
|
||||
Status = open_fcb_stream(Vcb, dc, sf->fcb, &fcb, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb_stream returned %08x\n", Status);
|
||||
ERR("open_fcb_stream returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1569,11 +1600,11 @@ NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_ex
|
|||
|
||||
Status = find_file_in_dir(name, sf->fcb, &subvol, &inode, &dc, case_sensitive);
|
||||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND) {
|
||||
TRACE("could not find %.*S\n", name->Length / sizeof(WCHAR), name->Buffer);
|
||||
TRACE("could not find %.*S\n", (int)(name->Length / sizeof(WCHAR)), name->Buffer);
|
||||
|
||||
return lastpart ? STATUS_OBJECT_NAME_NOT_FOUND : STATUS_OBJECT_PATH_NOT_FOUND;
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_file_in_dir returned %08x\n", Status);
|
||||
ERR("find_file_in_dir returned %08lx\n", Status);
|
||||
return Status;
|
||||
} else {
|
||||
fcb* fcb;
|
||||
|
@ -1597,7 +1628,7 @@ NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_ex
|
|||
Status = open_fcb(Vcb, subvol, inode, dc->type, &dc->utf8, false, sf->fcb, &fcb, pooltype, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb returned %08x\n", Status);
|
||||
ERR("open_fcb returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1679,7 +1710,7 @@ NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusiv
|
|||
dir = related;
|
||||
} else {
|
||||
if (fnus2.Buffer[0] != '\\') {
|
||||
ERR("error - filename %.*S did not begin with \\\n", fnus2.Length / sizeof(WCHAR), fnus2.Buffer);
|
||||
ERR("error - filename %.*S did not begin with \\\n", (int)(fnus2.Length / sizeof(WCHAR)), fnus2.Buffer);
|
||||
return STATUS_OBJECT_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -1713,7 +1744,7 @@ NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusiv
|
|||
|
||||
if (dir->fcb->type != BTRFS_TYPE_DIRECTORY && (fnus->Length < sizeof(WCHAR) || fnus->Buffer[0] != ':')) {
|
||||
WARN("passed related fileref which isn't a directory (fnus = %.*S)\n",
|
||||
fnus->Length / sizeof(WCHAR), fnus->Buffer);
|
||||
(int)(fnus->Length / sizeof(WCHAR)), fnus->Buffer);
|
||||
return STATUS_OBJECT_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -1723,7 +1754,7 @@ NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusiv
|
|||
(fnus->Length != sizeof(datastring) - sizeof(WCHAR) || RtlCompareMemory(fnus->Buffer, datastring, sizeof(datastring) - sizeof(WCHAR)) != sizeof(datastring) - sizeof(WCHAR))) {
|
||||
Status = split_path(Vcb, &fnus2, &parts, &has_stream);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("split_path returned %08x\n", Status);
|
||||
ERR("split_path returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1773,9 +1804,9 @@ NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusiv
|
|||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
if (Status == STATUS_OBJECT_PATH_NOT_FOUND || Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
TRACE("open_fileref_child returned %08x\n", Status);
|
||||
TRACE("open_fileref_child returned %08lx\n", Status);
|
||||
else
|
||||
ERR("open_fileref_child returned %08x\n", Status);
|
||||
ERR("open_fileref_child returned %08lx\n", Status);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
@ -1822,7 +1853,7 @@ end:
|
|||
}
|
||||
|
||||
end2:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -1867,7 +1898,7 @@ NTSTATUS add_dir_child(fcb* fcb, uint64_t inode, bool subvol, PANSI_STRING utf8,
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&dc->name_uc, name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -2161,7 +2192,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
|
||||
Status = utf16_to_utf8(NULL, 0, &utf8len, fpus->Buffer, fpus->Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 returned %08x\n", Status);
|
||||
ERR("utf16_to_utf8 returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2173,7 +2204,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
|
||||
Status = utf16_to_utf8(utf8, utf8len, &utf8len, fpus->Buffer, fpus->Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 returned %08x\n", Status);
|
||||
ERR("utf16_to_utf8 returned %08lx\n", Status);
|
||||
ExFreePool(utf8);
|
||||
return Status;
|
||||
}
|
||||
|
@ -2183,7 +2214,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
KeQuerySystemTime(&time);
|
||||
win_time_to_unix(time, &now);
|
||||
|
||||
TRACE("create file %.*S\n", fpus->Length / sizeof(WCHAR), fpus->Buffer);
|
||||
TRACE("create file %.*S\n", (int)(fpus->Length / sizeof(WCHAR)), fpus->Buffer);
|
||||
ExAcquireResourceExclusiveLite(parfileref->fcb->Header.Resource, true);
|
||||
TRACE("parfileref->fcb->inode_item.st_size (inode %I64x) was %I64x\n", parfileref->fcb->inode, parfileref->fcb->inode_item.st_size);
|
||||
parfileref->fcb->inode_item.st_size += utf8len * 2;
|
||||
|
@ -2365,7 +2396,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
Status = fcb_get_new_sd(fcb, parfileref, IrpSp->Parameters.Create.SecurityContext->AccessState);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("fcb_get_new_sd returned %08x\n", Status);
|
||||
ERR("fcb_get_new_sd returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
|
||||
ExAcquireResourceExclusiveLite(parfileref->fcb->Header.Resource, true);
|
||||
|
@ -2382,7 +2413,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
if (ea && ealen > 0) {
|
||||
Status = file_create_parse_ea(fcb, ea);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("file_create_parse_ea returned %08x\n", Status);
|
||||
ERR("file_create_parse_ea returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
|
||||
ExAcquireResourceExclusiveLite(parfileref->fcb->Header.Resource, true);
|
||||
|
@ -2415,7 +2446,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
Status = extend_file(fcb, fileref, Irp->Overlay.AllocationSize.QuadPart, true, NULL, rollback);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("extend_file returned %08x\n", Status);
|
||||
ERR("extend_file returned %08lx\n", Status);
|
||||
reap_fileref(Vcb, fileref);
|
||||
|
||||
ExAcquireResourceExclusiveLite(parfileref->fcb->Header.Resource, true);
|
||||
|
@ -2501,7 +2532,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
Status = RtlUpcaseUnicodeString(&fpusuc, fpus, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ExReleaseResourceLite(&parfileref->fcb->nonpaged->dir_children_lock);
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
reap_fileref(Vcb, fileref);
|
||||
|
||||
ExAcquireResourceExclusiveLite(parfileref->fcb->Header.Resource, true);
|
||||
|
@ -2517,7 +2548,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
uint32_t dc_hash = calc_crc32c(0xffffffff, (uint8_t*)fpusuc.Buffer, fpusuc.Length);
|
||||
#else
|
||||
dc_hash = calc_crc32c(0xffffffff, (uint8_t*)fpusuc.Buffer, fpusuc.Length);
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
if (parfileref->fcb->hash_ptrs_uc[dc_hash >> 24]) {
|
||||
LIST_ENTRY* le = parfileref->fcb->hash_ptrs_uc[dc_hash >> 24];
|
||||
|
@ -2556,7 +2587,7 @@ static NTSTATUS file_create2(_In_ PIRP Irp, _Requires_exclusive_lock_held_(_Curr
|
|||
Status = add_dir_child(parfileref->fcb, fcb->inode, false, &utf8as, fpus, fcb->type, &dc);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ExReleaseResourceLite(&parfileref->fcb->nonpaged->dir_children_lock);
|
||||
ERR("add_dir_child returned %08x\n", Status);
|
||||
ERR("add_dir_child returned %08lx\n", Status);
|
||||
reap_fileref(Vcb, fileref);
|
||||
|
||||
ExAcquireResourceExclusiveLite(parfileref->fcb->Header.Resource, true);
|
||||
|
@ -2617,8 +2648,8 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
LIST_ENTRY* le;
|
||||
#endif
|
||||
|
||||
TRACE("fpus = %.*S\n", fpus->Length / sizeof(WCHAR), fpus->Buffer);
|
||||
TRACE("stream = %.*S\n", stream->Length / sizeof(WCHAR), stream->Buffer);
|
||||
TRACE("fpus = %.*S\n", (int)(fpus->Length / sizeof(WCHAR)), fpus->Buffer);
|
||||
TRACE("stream = %.*S\n", (int)(stream->Length / sizeof(WCHAR)), stream->Buffer);
|
||||
|
||||
parfileref = *pparfileref;
|
||||
|
||||
|
@ -2658,7 +2689,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
Status = file_create2(Irp, Vcb, &fpus2, parfileref, options, NULL, 0, &newpar, case_sensitive, rollback);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("file_create2 returned %08x\n", Status);
|
||||
ERR("file_create2 returned %08lx\n", Status);
|
||||
ExFreePool(fpus2.Buffer);
|
||||
return Status;
|
||||
} else if (Status != STATUS_OBJECT_NAME_COLLISION) {
|
||||
|
@ -2668,7 +2699,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
|
||||
ExFreePool(fpus2.Buffer);
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2740,7 +2771,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
|
||||
Status = utf16_to_utf8(NULL, 0, &utf8len, stream->Buffer, stream->Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 1 returned %08x\n", Status);
|
||||
ERR("utf16_to_utf8 1 returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
free_fileref(parfileref);
|
||||
return Status;
|
||||
|
@ -2760,7 +2791,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
|
||||
Status = utf16_to_utf8(&fcb->adsxattr.Buffer[sizeof(xapref) - 1], utf8len, &utf8len, stream->Buffer, stream->Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 2 returned %08x\n", Status);
|
||||
ERR("utf16_to_utf8 2 returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
free_fileref(parfileref);
|
||||
return Status;
|
||||
|
@ -2779,7 +2810,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
|
||||
Status = find_item(Vcb, parfileref->fcb->subvol, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
free_fileref(parfileref);
|
||||
return Status;
|
||||
|
@ -2793,7 +2824,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
fcb->adsmaxlen = Vcb->superblock.node_size - sizeof(tree_header) - sizeof(leaf_node) - (sizeof(DIR_ITEM) - 1);
|
||||
|
||||
if (utf8len + sizeof(xapref) - 1 + overhead > fcb->adsmaxlen) {
|
||||
WARN("not enough room for new DIR_ITEM (%u + %u > %u)", utf8len + sizeof(xapref) - 1, overhead, fcb->adsmaxlen);
|
||||
WARN("not enough room for new DIR_ITEM (%Iu + %lu > %lu)", utf8len + sizeof(xapref) - 1, overhead, fcb->adsmaxlen);
|
||||
reap_fcb(fcb);
|
||||
free_fileref(parfileref);
|
||||
return STATUS_DISK_FULL;
|
||||
|
@ -2858,7 +2889,7 @@ static NTSTATUS create_stream(_Requires_lock_held_(_Curr_->tree_lock) _Requires_
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&dc->name_uc, &dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(dc->utf8.Buffer);
|
||||
ExFreePool(dc->name.Buffer);
|
||||
ExFreePool(dc);
|
||||
|
@ -2948,7 +2979,7 @@ static __inline bool called_from_lxss() {
|
|||
Status = ZwQueryInformationProcess(NtCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &retlen);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwQueryInformationProcess returned %08x\n", Status);
|
||||
ERR("ZwQueryInformationProcess returned %08lx\n", Status);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2975,7 +3006,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
LONG oc;
|
||||
#endif
|
||||
|
||||
TRACE("(%p, %p, %p, %.*S, %x, %x)\n", Irp, Vcb, FileObject, fnus->Length / sizeof(WCHAR), fnus->Buffer, disposition, options);
|
||||
TRACE("(%p, %p, %p, %.*S, %lx, %lx)\n", Irp, Vcb, FileObject, (int)(fnus->Length / sizeof(WCHAR)), fnus->Buffer, disposition, options);
|
||||
|
||||
if (Vcb->readonly)
|
||||
return STATUS_MEDIA_WRITE_PROTECTED;
|
||||
|
@ -2997,11 +3028,15 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
if (ctxsize >= sizeof(ATOMIC_CREATE_ECP_CONTEXT))
|
||||
acec = ctx;
|
||||
else {
|
||||
ERR("GUID_ECP_ATOMIC_CREATE context was too short: %u bytes, expected %u\n", ctxsize,
|
||||
ERR("GUID_ECP_ATOMIC_CREATE context was too short: %lu bytes, expected %Iu\n", ctxsize,
|
||||
sizeof(ATOMIC_CREATE_ECP_CONTEXT));
|
||||
}
|
||||
} else {
|
||||
WARN("unhandled ECP {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", type.Data1, type.Data2,
|
||||
} else if (RtlCompareMemory(&type, &GUID_ECP_QUERY_ON_CREATE, sizeof(GUID)) == sizeof(GUID))
|
||||
WARN("unhandled ECP GUID_ECP_QUERY_ON_CREATE\n");
|
||||
else if (RtlCompareMemory(&type, &GUID_ECP_CREATE_REDIRECTION, sizeof(GUID)) == sizeof(GUID))
|
||||
WARN("unhandled ECP GUID_ECP_CREATE_REDIRECTION\n");
|
||||
else {
|
||||
WARN("unhandled ECP {%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", type.Data1, type.Data2,
|
||||
type.Data3, type.Data4[0], type.Data4[1], type.Data4[2], type.Data4[3], type.Data4[4], type.Data4[5],
|
||||
type.Data4[6], type.Data4[7]);
|
||||
}
|
||||
|
@ -3058,7 +3093,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
lb.Buffer = &fpus.Buffer[(fpus.Length - dsus.Length)/sizeof(WCHAR)];
|
||||
lb.Length = lb.MaximumLength = dsus.Length;
|
||||
|
||||
TRACE("lb = %.*S\n", lb.Length/sizeof(WCHAR), lb.Buffer);
|
||||
TRACE("lb = %.*S\n", (int)(lb.Length/sizeof(WCHAR)), lb.Buffer);
|
||||
|
||||
if (FsRtlAreNamesEqual(&dsus, &lb, true, NULL)) {
|
||||
TRACE("ignoring :$DATA suffix\n");
|
||||
|
@ -3068,7 +3103,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
if (fpus.Length > sizeof(WCHAR) && fpus.Buffer[(fpus.Length-1)/sizeof(WCHAR)] == ':')
|
||||
fpus.Length -= sizeof(WCHAR);
|
||||
|
||||
TRACE("fpus = %.*S\n", fpus.Length / sizeof(WCHAR), fpus.Buffer);
|
||||
TRACE("fpus = %.*S\n", (int)(fpus.Length / sizeof(WCHAR)), fpus.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3087,7 +3122,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
if (stream.Length > 0) {
|
||||
Status = create_stream(Vcb, &fileref, &parfileref, &fpus, &stream, Irp, options, pool_type, IrpSp->Flags & SL_CASE_SENSITIVE, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("create_stream returned %08x\n", Status);
|
||||
ERR("create_stream returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3118,7 +3153,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
|
||||
Status = IoCheckEaBufferValidity(Irp->AssociatedIrp.SystemBuffer, IrpSp->Parameters.Create.EaLength, &offset);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoCheckEaBufferValidity returned %08x (error at offset %u)\n", Status, offset);
|
||||
ERR("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -3130,7 +3165,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
*existing_fileref = fileref;
|
||||
goto end;
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("file_create2 returned %08x\n", Status);
|
||||
ERR("file_create2 returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3201,7 +3236,7 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
} else {
|
||||
Status = set_reparse_point2(fileref->fcb, acec->ReparseBuffer, acec->ReparseBufferLength, NULL, NULL, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("set_reparse_point2 returned %08x\n", Status);
|
||||
ERR("set_reparse_point2 returned %08lx\n", Status);
|
||||
fileref->deleted = true;
|
||||
fileref->fcb->deleted = true;
|
||||
|
||||
|
@ -3219,6 +3254,20 @@ static NTSTATUS file_create(PIRP Irp, _Requires_lock_held_(_Curr_->tree_lock) _R
|
|||
acec->OutFlags |= ATOMIC_CREATE_ECP_OUT_FLAG_REPARSE_POINT_SET;
|
||||
}
|
||||
|
||||
if (acec && acec->InFlags & ATOMIC_CREATE_ECP_IN_FLAG_OP_FLAGS_SPECIFIED) {
|
||||
if (acec->InOpFlags & ATOMIC_CREATE_ECP_IN_OP_FLAG_CASE_SENSITIVE_FLAGS_SPECIFIED && fileref->fcb->atts & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
if ((acec->InCaseSensitiveFlags & acec->CaseSensitiveFlagsMask) & FILE_CS_FLAG_CASE_SENSITIVE_DIR) {
|
||||
acec->OutCaseSensitiveFlags = FILE_CS_FLAG_CASE_SENSITIVE_DIR;
|
||||
fileref->fcb->case_sensitive = true;
|
||||
ccb->case_sensitive = true;
|
||||
}
|
||||
|
||||
acec->OutOpFlags |= ATOMIC_CREATE_ECP_OUT_OP_FLAG_CASE_SENSITIVE_FLAGS_SET;
|
||||
}
|
||||
|
||||
acec->OutFlags |= ATOMIC_CREATE_ECP_OUT_FLAG_OP_FLAGS_HONORED;
|
||||
}
|
||||
|
||||
fileref->dc->type = fileref->fcb->type;
|
||||
|
||||
end:
|
||||
|
@ -3350,7 +3399,7 @@ static __inline void debug_create_options(ULONG RequestedOptions) {
|
|||
}
|
||||
|
||||
if (options)
|
||||
TRACE(" unknown options: %x\n", options);
|
||||
TRACE(" unknown options: %lx\n", options);
|
||||
} else {
|
||||
TRACE("requested options: (none)\n");
|
||||
}
|
||||
|
@ -3381,7 +3430,7 @@ static NTSTATUS get_reparse_block(fcb* fcb, uint8_t** data) {
|
|||
|
||||
Status = read_file(fcb, *data, 0, size, &bytes_read, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file_fcb returned %08x\n", Status);
|
||||
ERR("read_file_fcb returned %08lx\n", Status);
|
||||
ExFreePool(*data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -3393,7 +3442,7 @@ static NTSTATUS get_reparse_block(fcb* fcb, uint8_t** data) {
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, (char*)*data, bytes_read);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
ExFreePool(*data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -3424,7 +3473,7 @@ static NTSTATUS get_reparse_block(fcb* fcb, uint8_t** data) {
|
|||
stringlen, &stringlen, (char*)*data, size);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(rdb);
|
||||
ExFreePool(*data);
|
||||
return Status;
|
||||
|
@ -3445,7 +3494,7 @@ static NTSTATUS get_reparse_block(fcb* fcb, uint8_t** data) {
|
|||
} else {
|
||||
Status = fFsRtlValidateReparsePointBuffer(bytes_read, (REPARSE_DATA_BUFFER*)*data);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("FsRtlValidateReparsePointBuffer returned %08x\n", Status);
|
||||
ERR("FsRtlValidateReparsePointBuffer returned %08lx\n", Status);
|
||||
ExFreePool(*data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -3461,7 +3510,7 @@ static NTSTATUS get_reparse_block(fcb* fcb, uint8_t** data) {
|
|||
|
||||
Status = fFsRtlValidateReparsePointBuffer(fcb->reparse_xattr.Length, (REPARSE_DATA_BUFFER*)fcb->reparse_xattr.Buffer);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("FsRtlValidateReparsePointBuffer returned %08x\n", Status);
|
||||
ERR("FsRtlValidateReparsePointBuffer returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -3498,7 +3547,7 @@ static void fcb_load_csums(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
|
||||
len = (ext->extent_data.compression == BTRFS_COMPRESSION_NONE ? ed2->num_bytes : ed2->size) / Vcb->superblock.sector_size;
|
||||
|
||||
ext->csum = ExAllocatePoolWithTag(NonPagedPool, (ULONG)(len * sizeof(uint32_t)), ALLOC_TAG);
|
||||
ext->csum = ExAllocatePoolWithTag(NonPagedPool, (ULONG)(len * Vcb->csum_size), ALLOC_TAG);
|
||||
if (!ext->csum) {
|
||||
ERR("out of memory\n");
|
||||
goto end;
|
||||
|
@ -3507,7 +3556,7 @@ static void fcb_load_csums(_Requires_lock_held_(_Curr_->tree_lock) device_extens
|
|||
Status = load_csum(Vcb, ext->csum, ed2->address + (ext->extent_data.compression == BTRFS_COMPRESSION_NONE ? ed2->offset : 0), len, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("load_csum returned %08x\n", Status);
|
||||
ERR("load_csum returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -3559,7 +3608,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
IoGetFileObjectGenericMapping(), IrpSp->Flags & SL_FORCE_ACCESS_CHECK ? UserMode : Irp->RequestorMode,
|
||||
granted_access, &Status)) {
|
||||
SeUnlockSubjectContext(&IrpSp->Parameters.Create.SecurityContext->AccessState->SubjectSecurityContext);
|
||||
TRACE("SeAccessCheck failed, returning %08x\n", Status);
|
||||
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
|
@ -3636,7 +3685,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
Status = get_reparse_block(fileref->fcb, (uint8_t**)&data);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("get_reparse_block returned %08x\n", Status);
|
||||
ERR("get_reparse_block returned %08lx\n", Status);
|
||||
Status = STATUS_SUCCESS;
|
||||
} else {
|
||||
Irp->IoStatus.Information = data->ReparseTag;
|
||||
|
@ -3671,9 +3720,9 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
if (Status == STATUS_SHARING_VIOLATION)
|
||||
TRACE("IoCheckShareAccess failed, returning %08x\n", Status);
|
||||
TRACE("IoCheckShareAccess failed, returning %08lx\n", Status);
|
||||
else
|
||||
WARN("IoCheckShareAccess failed, returning %08x\n", Status);
|
||||
WARN("IoCheckShareAccess failed, returning %08lx\n", Status);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
|
@ -3698,7 +3747,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
// FIXME - this can block waiting for network IO, while we're holding fileref_lock and tree_lock
|
||||
Status = FsRtlCheckOplock(fcb_oplock(fileref->fcb), Irp, NULL, NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("FsRtlCheckOplock returned %08x\n", Status);
|
||||
WARN("FsRtlCheckOplock returned %08lx\n", Status);
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
|
@ -3730,7 +3779,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
if (fileref->fcb->ads) {
|
||||
Status = stream_set_end_of_file_information(Vcb, 0, fileref->fcb, fileref, false);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("stream_set_end_of_file_information returned %08x\n", Status);
|
||||
ERR("stream_set_end_of_file_information returned %08lx\n", Status);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
|
@ -3741,7 +3790,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
} else {
|
||||
Status = truncate_file(fileref->fcb, 0, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("truncate_file returned %08x\n", Status);
|
||||
ERR("truncate_file returned %08lx\n", Status);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
|
@ -3755,7 +3804,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
Status = extend_file(fileref->fcb, fileref, Irp->Overlay.AllocationSize.QuadPart, true, NULL, rollback);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("extend_file returned %08x\n", Status);
|
||||
ERR("extend_file returned %08lx\n", Status);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
|
@ -3774,7 +3823,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
Status = IoCheckEaBufferValidity(Irp->AssociatedIrp.SystemBuffer, IrpSp->Parameters.Create.EaLength, &offset);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoCheckEaBufferValidity returned %08x (error at offset %u)\n", Status, offset);
|
||||
ERR("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
|
@ -3842,7 +3891,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
Status = open_fileref_child(Vcb, fileref, &dc->name, true, true, true, PagedPool, &fr2, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("open_fileref_child returned %08x\n", Status);
|
||||
WARN("open_fileref_child returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (dc->fileref) {
|
||||
|
@ -3850,7 +3899,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
Status = delete_fileref(dc->fileref, NULL, false, NULL, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
|
@ -4027,7 +4076,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = open_fcb(Vcb, subvol, inode, 0, NULL, true, NULL, &fcb, PagedPool, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb returned %08x\n", Status);
|
||||
ERR("open_fcb returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -4081,7 +4130,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = find_item(Vcb, subvol, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4111,7 +4160,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, ir->name, ir->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4131,7 +4180,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = utf8_to_utf16(name.Buffer, stringlen, &stringlen, ir->name, ir->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(name.Buffer);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
|
@ -4161,7 +4210,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, ier->name, ier->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4181,7 +4230,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = utf8_to_utf16(name.Buffer, stringlen, &stringlen, ier->name, ier->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(name.Buffer);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
|
@ -4227,7 +4276,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4239,13 +4288,13 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
ULONG stringlen;
|
||||
|
||||
if (tp.item->size < sizeof(ROOT_REF)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(ROOT_REF));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(ROOT_REF));
|
||||
free_fcb(fcb);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (tp.item->size < offsetof(ROOT_REF, name[0]) + rr->n) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, offsetof(ROOT_REF, name[0]) + rr->n);
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, offsetof(ROOT_REF, name[0]) + rr->n);
|
||||
free_fcb(fcb);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -4270,14 +4319,14 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = open_fileref_by_inode(Vcb, r, rr->dir, &parfr, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_by_inode returned %08x\n", Status);
|
||||
ERR("open_fileref_by_inode returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, rr->name, rr->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4300,7 +4349,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
|
||||
Status = utf8_to_utf16(name.Buffer, stringlen, &stringlen, rr->name, rr->n);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(name.Buffer);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
|
@ -4312,7 +4361,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
if (!Vcb->options.no_root_dir && subvol->id == BTRFS_ROOT_FSTREE && Vcb->root_fileref->fcb->subvol != subvol) {
|
||||
Status = open_fileref_by_inode(Vcb, Vcb->root_fileref->fcb->subvol, SUBVOL_ROOT_INODE, &parfr, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_by_inode returned %08x\n", Status);
|
||||
ERR("open_fileref_by_inode returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4328,7 +4377,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
} else {
|
||||
Status = open_fileref_by_inode(Vcb, subvol, parent, &parfr, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_by_inode returned %08x\n", Status);
|
||||
ERR("open_fileref_by_inode returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -4340,7 +4389,7 @@ NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock)
|
|||
ExFreePool(name.Buffer);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_child returned %08x\n", Status);
|
||||
ERR("open_fileref_child returned %08lx\n", Status);
|
||||
|
||||
free_fcb(fcb);
|
||||
free_fileref(parfr);
|
||||
|
@ -4422,14 +4471,14 @@ static NTSTATUS open_file(PDEVICE_OBJECT DeviceObject, _Requires_lock_held_(_Cur
|
|||
break;
|
||||
|
||||
default:
|
||||
ERR("unknown disposition: %x\n", RequestedDisposition);
|
||||
ERR("unknown disposition: %lx\n", RequestedDisposition);
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
fn = FileObject->FileName;
|
||||
|
||||
TRACE("(%.*S)\n", fn.Length / sizeof(WCHAR), fn.Buffer);
|
||||
TRACE("(%.*S)\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
|
||||
TRACE("FileObject = %p\n", FileObject);
|
||||
|
||||
if (Vcb->readonly && (RequestedDisposition == FILE_SUPERSEDE || RequestedDisposition == FILE_CREATE || RequestedDisposition == FILE_OVERWRITE)) {
|
||||
|
@ -4453,7 +4502,7 @@ static NTSTATUS open_file(PDEVICE_OBJECT DeviceObject, _Requires_lock_held_(_Cur
|
|||
goto exit;
|
||||
}
|
||||
|
||||
RtlCopyMemory(&inode, fn.Buffer, sizeof(uint64_t));
|
||||
inode = (*(uint64_t*)fn.Buffer) & 0xffffffffff;
|
||||
|
||||
if (related->fcb == Vcb->root_fileref->fcb && inode == 0)
|
||||
inode = Vcb->root_fileref->fcb->inode;
|
||||
|
@ -4548,7 +4597,7 @@ loaded:
|
|||
ExReleaseResourceLite(fileref->fcb->Header.Resource);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("get_reparse_block returned %08x\n", Status);
|
||||
ERR("get_reparse_block returned %08lx\n", Status);
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
} else {
|
||||
|
@ -4583,10 +4632,10 @@ loaded:
|
|||
goto exit;
|
||||
}
|
||||
} else if (Status == STATUS_OBJECT_PATH_NOT_FOUND) {
|
||||
TRACE("open_fileref returned %08x\n", Status);
|
||||
TRACE("open_fileref returned %08lx\n", Status);
|
||||
goto exit;
|
||||
} else {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -4639,7 +4688,7 @@ exit:
|
|||
fcb_load_csums(Vcb, fcb2, Irp);
|
||||
ExReleaseResourceLite(fcb2->Header.Resource);
|
||||
} else if (Status != STATUS_REPARSE && Status != STATUS_OBJECT_NAME_NOT_FOUND && Status != STATUS_OBJECT_PATH_NOT_FOUND)
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -4662,10 +4711,10 @@ static NTSTATUS verify_vcb(device_extension* Vcb, PIRP Irp) {
|
|||
Status = dev_ioctl(dev->devobj, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, &cc, sizeof(ULONG), true, &iosb);
|
||||
|
||||
if (IoIsErrorUserInduced(Status)) {
|
||||
ERR("IOCTL_STORAGE_CHECK_VERIFY returned %08x (user-induced)\n", Status);
|
||||
ERR("IOCTL_STORAGE_CHECK_VERIFY returned %08lx (user-induced)\n", Status);
|
||||
need_verify = true;
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_STORAGE_CHECK_VERIFY returned %08x\n", Status);
|
||||
ERR("IOCTL_STORAGE_CHECK_VERIFY returned %08lx\n", Status);
|
||||
goto end;
|
||||
} else if (iosb.Information < sizeof(ULONG)) {
|
||||
ERR("iosb.Information was too short\n");
|
||||
|
@ -4727,7 +4776,7 @@ NTSTATUS __stdcall drv_create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
|
||||
FsRtlEnterFileSystem();
|
||||
|
||||
TRACE("create (flags = %x)\n", Irp->Flags);
|
||||
TRACE("create (flags = %lx)\n", Irp->Flags);
|
||||
|
||||
top_level = is_top_level(Irp);
|
||||
|
||||
|
@ -4759,7 +4808,7 @@ NTSTATUS __stdcall drv_create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
|
||||
Status = verify_vcb(Vcb, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("verify_vcb returned %08x\n", Status);
|
||||
ERR("verify_vcb returned %08lx\n", Status);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -4884,7 +4933,7 @@ NTSTATUS __stdcall drv_create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
|
||||
InitializeListHead(&rollback);
|
||||
|
||||
TRACE("file name: %.*S\n", IrpSp->FileObject->FileName.Length / sizeof(WCHAR), IrpSp->FileObject->FileName.Buffer);
|
||||
TRACE("file name: %.*S\n", (int)(IrpSp->FileObject->FileName.Length / sizeof(WCHAR)), IrpSp->FileObject->FileName.Buffer);
|
||||
|
||||
if (IrpSp->FileObject->RelatedFileObject)
|
||||
TRACE("related file = %p\n", IrpSp->FileObject->RelatedFileObject);
|
||||
|
@ -4914,7 +4963,7 @@ exit:
|
|||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest( Irp, NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT );
|
||||
|
||||
TRACE("create returning %08x\n", Status);
|
||||
TRACE("create returning %08lx\n", Status);
|
||||
|
||||
if (locked)
|
||||
ExReleaseResourceLite(&Vcb->load_lock);
|
||||
|
|
|
@ -119,7 +119,7 @@ static NTSTATUS query_filesystems(void* data, ULONG length) {
|
|||
Status = dev_ioctl(dev->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, &mdn, sizeof(MOUNTDEV_NAME), true, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ static NTSTATUS query_filesystems(void* data, ULONG length) {
|
|||
Status = dev_ioctl(dev->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, &bfd->name_length, (ULONG)offsetof(MOUNTDEV_NAME, Name[0]) + mdn.NameLength, true, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ static NTSTATUS probe_volume(void* data, ULONG length, KPROCESSOR_MODE processor
|
|||
if (length < offsetof(MOUNTDEV_NAME, Name[0]) + mdn->NameLength)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
TRACE("%.*S\n", mdn->NameLength / sizeof(WCHAR), mdn->Name);
|
||||
TRACE("%.*S\n", (int)(mdn->NameLength / sizeof(WCHAR)), mdn->Name);
|
||||
|
||||
if (!SeSinglePrivilegeCheck(RtlConvertLongToLuid(SE_MANAGE_VOLUME_PRIVILEGE), processor_mode))
|
||||
return STATUS_PRIVILEGE_NOT_HELD;
|
||||
|
@ -183,13 +183,13 @@ static NTSTATUS probe_volume(void* data, ULONG length, KPROCESSOR_MODE processor
|
|||
|
||||
Status = IoGetDeviceObjectPointer(&path, FILE_READ_ATTRIBUTES, &FileObject, &DeviceObject);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = get_device_pnp_name(DeviceObject, &pnp_name, &guid);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("get_device_pnp_name returned %08x\n", Status);
|
||||
ERR("get_device_pnp_name returned %08lx\n", Status);
|
||||
ObDereferenceObject(FileObject);
|
||||
return Status;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ static NTSTATUS probe_volume(void* data, ULONG length, KPROCESSOR_MODE processor
|
|||
if (RtlCompareMemory(guid, &GUID_DEVINTERFACE_DISK, sizeof(GUID)) == sizeof(GUID)) {
|
||||
Status = dev_ioctl(DeviceObject, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IOCTL_DISK_UPDATE_PROPERTIES returned %08x\n", Status);
|
||||
WARN("IOCTL_DISK_UPDATE_PROPERTIES returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
ObDereferenceObject(FileObject);
|
||||
|
@ -241,7 +241,7 @@ static NTSTATUS control_ioctl(PIRP Irp) {
|
|||
break;
|
||||
|
||||
default:
|
||||
TRACE("unhandled ioctl %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||
TRACE("unhandled ioctl %lx\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
@ -279,11 +279,6 @@ NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Ir
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (!IrpSp->FileObject || IrpSp->FileObject->FsContext != Vcb->volume_fcb) {
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
goto end;
|
||||
}
|
||||
|
||||
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
|
||||
case IOCTL_MOUNTDEV_QUERY_STABLE_GUID:
|
||||
Status = mountdev_query_stable_guid(Vcb, Irp);
|
||||
|
@ -294,7 +289,7 @@ NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Ir
|
|||
goto end;
|
||||
|
||||
default:
|
||||
TRACE("unhandled control code %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||
TRACE("unhandled control code %lx\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -311,7 +306,7 @@ end:
|
|||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
end2:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "btrfs_drv.h"
|
||||
#include "crc32c.h"
|
||||
|
||||
#ifndef __REACTOS__
|
||||
// not currently in mingw
|
||||
|
@ -63,7 +64,7 @@ typedef struct _FILE_ID_EXTD_BOTH_DIR_INFORMATION {
|
|||
#else
|
||||
#define FileIdExtdDirectoryInformation (enum _FILE_INFORMATION_CLASS)60
|
||||
#define FileIdExtdBothDirectoryInformation (enum _FILE_INFORMATION_CLASS)63
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
enum DirEntryType {
|
||||
DirEntryType_File,
|
||||
|
@ -95,7 +96,7 @@ ULONG get_reparse_tag_fcb(fcb* fcb) {
|
|||
|
||||
Status = read_file(fcb, (uint8_t*)&tag, 0, sizeof(ULONG), &br, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -112,13 +113,13 @@ ULONG get_reparse_tag(device_extension* Vcb, root* subvol, uint64_t inode, uint8
|
|||
return IO_REPARSE_TAG_SYMLINK;
|
||||
else if (lxss) {
|
||||
if (type == BTRFS_TYPE_SOCKET)
|
||||
return IO_REPARSE_TAG_LXSS_SOCKET;
|
||||
return IO_REPARSE_TAG_AF_UNIX;
|
||||
else if (type == BTRFS_TYPE_FIFO)
|
||||
return IO_REPARSE_TAG_LXSS_FIFO;
|
||||
return IO_REPARSE_TAG_LX_FIFO;
|
||||
else if (type == BTRFS_TYPE_CHARDEV)
|
||||
return IO_REPARSE_TAG_LXSS_CHARDEV;
|
||||
return IO_REPARSE_TAG_LX_CHR;
|
||||
else if (type == BTRFS_TYPE_BLOCKDEV)
|
||||
return IO_REPARSE_TAG_LXSS_BLOCKDEV;
|
||||
return IO_REPARSE_TAG_LX_BLK;
|
||||
}
|
||||
|
||||
if (type != BTRFS_TYPE_FILE && type != BTRFS_TYPE_DIRECTORY)
|
||||
|
@ -129,7 +130,7 @@ ULONG get_reparse_tag(device_extension* Vcb, root* subvol, uint64_t inode, uint8
|
|||
|
||||
Status = open_fcb(Vcb, subvol, inode, type, NULL, false, NULL, &fcb, PagedPool, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb returned %08x\n", Status);
|
||||
ERR("open_fcb returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -155,7 +156,7 @@ static ULONG get_ea_len(device_extension* Vcb, root* subvol, uint64_t inode, PIR
|
|||
Status = IoCheckEaBufferValidity((FILE_FULL_EA_INFORMATION*)eadata, len, &offset);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("IoCheckEaBufferValidity returned %08x (error at offset %u)\n", Status, offset);
|
||||
WARN("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
|
||||
ExFreePool(eadata);
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -251,7 +252,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
|
||||
Status = find_item(fcb->Vcb, r, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -328,7 +329,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = sizeof(FILE_BOTH_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -368,7 +369,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = sizeof(FILE_DIRECTORY_INFORMATION) - sizeof(WCHAR) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -406,7 +407,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = sizeof(FILE_FULL_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -445,7 +446,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = sizeof(FILE_ID_BOTH_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -486,7 +487,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = sizeof(FILE_ID_FULL_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -531,7 +532,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = offsetof(FILE_ID_EXTD_DIR_INFORMATION, FileName[0]) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -574,7 +575,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = offsetof(FILE_ID_EXTD_BOTH_DIR_INFORMATION, FileName[0]) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -624,7 +625,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir
|
|||
needed = sizeof(FILE_NAMES_INFORMATION) - sizeof(WCHAR) + de->name.Length;
|
||||
|
||||
if (needed > *len) {
|
||||
TRACE("buffer overflow - %u > %u\n", needed, *len);
|
||||
TRACE("buffer overflow - %li > %lu\n", needed, *len);
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
|
@ -812,7 +813,7 @@ static NTSTATUS query_directory(PIRP Irp) {
|
|||
}
|
||||
|
||||
if (flags != 0)
|
||||
TRACE(" unknown flags: %u\n", flags);
|
||||
TRACE(" unknown flags: %lu\n", flags);
|
||||
}
|
||||
|
||||
if (IrpSp->Flags & SL_RESTART_SCAN) {
|
||||
|
@ -830,7 +831,7 @@ static NTSTATUS query_directory(PIRP Irp) {
|
|||
initial = !ccb->query_string.Buffer;
|
||||
|
||||
if (IrpSp->Parameters.QueryDirectory.FileName && IrpSp->Parameters.QueryDirectory.FileName->Length > 1) {
|
||||
TRACE("QD filename: %.*S\n", IrpSp->Parameters.QueryDirectory.FileName->Length / sizeof(WCHAR), IrpSp->Parameters.QueryDirectory.FileName->Buffer);
|
||||
TRACE("QD filename: %.*S\n", (int)(IrpSp->Parameters.QueryDirectory.FileName->Length / sizeof(WCHAR)), IrpSp->Parameters.QueryDirectory.FileName->Buffer);
|
||||
|
||||
if (IrpSp->Parameters.QueryDirectory.FileName->Length > sizeof(WCHAR) || IrpSp->Parameters.QueryDirectory.FileName->Buffer[0] != L'*') {
|
||||
specific_file = true;
|
||||
|
@ -872,7 +873,7 @@ static NTSTATUS query_directory(PIRP Irp) {
|
|||
}
|
||||
|
||||
if (ccb->query_string.Buffer) {
|
||||
TRACE("query string = %.*S\n", ccb->query_string.Length / sizeof(WCHAR), ccb->query_string.Buffer);
|
||||
TRACE("query string = %.*S\n", (int)(ccb->query_string.Length / sizeof(WCHAR)), ccb->query_string.Buffer);
|
||||
}
|
||||
|
||||
newoffset = ccb->query_dir_offset;
|
||||
|
@ -913,7 +914,7 @@ static NTSTATUS query_directory(PIRP Irp) {
|
|||
if (!ccb->case_sensitive) {
|
||||
Status = RtlUpcaseUnicodeString(&us, &ccb->query_string, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -996,8 +997,8 @@ static NTSTATUS query_directory(PIRP Irp) {
|
|||
}
|
||||
}
|
||||
|
||||
TRACE("file(0) = %.*S\n", de.name.Length / sizeof(WCHAR), de.name.Buffer);
|
||||
TRACE("offset = %u\n", ccb->query_dir_offset - 1);
|
||||
TRACE("file(0) = %.*S\n", (int)(de.name.Length / sizeof(WCHAR)), de.name.Buffer);
|
||||
TRACE("offset = %I64u\n", ccb->query_dir_offset - 1);
|
||||
|
||||
Status = query_dir_item(fcb, ccb, buf, &length, Irp, &de, fcb->subvol);
|
||||
|
||||
|
@ -1041,8 +1042,8 @@ static NTSTATUS query_directory(PIRP Irp) {
|
|||
curitem = (uint8_t*)buf + IrpSp->Parameters.QueryDirectory.Length - length;
|
||||
count++;
|
||||
|
||||
TRACE("file(%u) %u = %.*S\n", count, curitem - (uint8_t*)buf, de.name.Length / sizeof(WCHAR), de.name.Buffer);
|
||||
TRACE("offset = %u\n", ccb->query_dir_offset - 1);
|
||||
TRACE("file(%lu) %Iu = %.*S\n", count, curitem - (uint8_t*)buf, (int)(de.name.Length / sizeof(WCHAR)), de.name.Buffer);
|
||||
TRACE("offset = %I64u\n", ccb->query_dir_offset - 1);
|
||||
|
||||
status2 = query_dir_item(fcb, ccb, curitem, &length, Irp, &de, fcb->subvol);
|
||||
|
||||
|
@ -1075,7 +1076,7 @@ end:
|
|||
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -1135,11 +1136,11 @@ static NTSTATUS notify_change_directory(device_extension* Vcb, PIRP Irp) {
|
|||
|
||||
Status = fileref_get_filename(fileref, &ccb->filename, NULL, &reqlen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1196,7 +1197,7 @@ NTSTATUS __stdcall drv_directory_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP
|
|||
break;
|
||||
|
||||
default:
|
||||
WARN("unknown minor %u\n", func);
|
||||
WARN("unknown minor %lu\n", func);
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
Irp->IoStatus.Status = Status;
|
||||
break;
|
||||
|
@ -1211,7 +1212,7 @@ end:
|
|||
IoCompleteRequest(Irp, IO_DISK_INCREMENT);
|
||||
|
||||
exit:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "btrfs_drv.h"
|
||||
#include "crc32c.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
|
@ -314,7 +315,7 @@ static NTSTATUS construct_extent_item(device_extension* Vcb, uint64_t address, u
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, address, TYPE_EXTENT_ITEM, size, ei, inline_len, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(ei);
|
||||
return Status;
|
||||
}
|
||||
|
@ -356,7 +357,7 @@ static NTSTATUS construct_extent_item(device_extension* Vcb, uint64_t address, u
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, address, er->type, er->hash, data, len, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
if (data) ExFreePool(data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -383,7 +384,7 @@ static NTSTATUS convert_old_extent(device_extension* Vcb, uint64_t address, bool
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -396,7 +397,7 @@ static NTSTATUS convert_old_extent(device_extension* Vcb, uint64_t address, bool
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -410,27 +411,27 @@ static NTSTATUS convert_old_extent(device_extension* Vcb, uint64_t address, bool
|
|||
if (tp.item->key.offset == tp.item->key.obj_id) { // top of the tree
|
||||
Status = add_tree_block_extent_ref(&extent_refs, erv0->root);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_tree_block_extent_ref returned %08x\n", Status);
|
||||
ERR("add_tree_block_extent_ref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
Status = add_shared_block_extent_ref(&extent_refs, tp.item->key.offset);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_shared_block_extent_ref returned %08x\n", Status);
|
||||
ERR("add_shared_block_extent_ref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Status = add_shared_data_extent_ref(&extent_refs, tp.item->key.offset, erv0->count);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_shared_data_extent_ref returned %08x\n", Status);
|
||||
ERR("add_shared_data_extent_ref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -442,7 +443,7 @@ static NTSTATUS convert_old_extent(device_extension* Vcb, uint64_t address, bool
|
|||
Status = construct_extent_item(Vcb, address, size, tree ? (EXTENT_ITEM_TREE_BLOCK | EXTENT_ITEM_SHARED_BACKREFS) : EXTENT_ITEM_DATA,
|
||||
&extent_refs, firstitem, level, Irp);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("construct_extent_item returned %08x\n", Status);
|
||||
ERR("construct_extent_item returned %08lx\n", Status);
|
||||
|
||||
end:
|
||||
free_extent_refs(&extent_refs);
|
||||
|
@ -475,7 +476,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -516,7 +517,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
Status = insert_tree_item(Vcb, Vcb->extent_root, address, TYPE_EXTENT_ITEM, size, ei, eisize, NULL, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -532,7 +533,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
Status = convert_old_extent(Vcb, address, is_tree, firstitem, level, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("convert_old_extent returned %08x\n", Status);
|
||||
ERR("convert_old_extent returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -540,7 +541,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -551,7 +552,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
if (ei->flags & EXTENT_ITEM_TREE_BLOCK && !skinny) {
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -571,7 +572,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
len--;
|
||||
|
||||
if (sectlen > len) {
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
ERR("(%I64x,%x,%I64x): %lx bytes left, expecting at least %lx\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -606,13 +607,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -655,13 +656,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -729,13 +730,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size + sizeof(uint8_t) + datalen, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -753,13 +754,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp2, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (!keycmp(tp2.item->key, searchkey)) {
|
||||
if (type == TYPE_SHARED_DATA_REF && tp2.item->size < sizeof(uint32_t)) {
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expecting %x\n", tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, tp2.item->size, sizeof(uint32_t));
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expecting %Ix\n", tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, tp2.item->size, sizeof(uint32_t));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
} else if (type != TYPE_SHARED_DATA_REF && tp2.item->size < datalen) {
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expecting %x\n", tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, tp2.item->size, datalen);
|
||||
|
@ -794,13 +795,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, data2, tp2.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -816,13 +817,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -859,7 +860,7 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, address, type, offset, data2, datalen, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -875,13 +876,13 @@ NTSTATUS increase_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -919,7 +920,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -934,7 +935,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -952,7 +953,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
Status = convert_old_extent(Vcb, address, is_tree, firstitem, level, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("convert_old_extent returned %08x\n", Status);
|
||||
ERR("convert_old_extent returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -961,7 +962,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -972,7 +973,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
if (ei->flags & EXTENT_ITEM_TREE_BLOCK && !skinny) {
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -997,7 +998,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
len--;
|
||||
|
||||
if (sectlen > len) {
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
ERR("(%I64x,%x,%I64x): %lx bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1019,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == edr->count) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1061,13 +1062,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, neweilen, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1085,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == sectsdr->count) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1127,13 +1128,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, neweilen, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1150,7 +1151,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == 1) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1174,13 +1175,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, neweilen, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1197,7 +1198,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == 1) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1221,13 +1222,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, neweilen, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1260,7 +1261,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp2, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1270,7 +1271,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
}
|
||||
|
||||
if (tp2.item->size < datalen) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, tp2.item->size, datalen);
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %lu\n", tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, tp2.item->size, datalen);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1284,13 +1285,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == edr->count) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1307,7 +1308,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1326,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, newedr, tp2.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1342,13 +1343,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1367,13 +1368,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == sdr->count) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1390,7 +1391,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1406,7 +1407,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp2.item->key.obj_id, tp2.item->key.obj_type, tp2.item->key.offset, newsdr, tp2.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1423,13 +1424,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1444,13 +1445,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == 1) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1459,7 +1460,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1475,13 +1476,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1493,13 +1494,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
if (ei->refcount == erv0->count) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1512,7 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp2);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1527,13 +1528,13 @@ NTSTATUS decrease_extent_refcount(device_extension* Vcb, uint64_t address, uint6
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = insert_tree_item(Vcb, Vcb->extent_root, tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, newei, tp.item->size, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1576,7 +1577,7 @@ static uint32_t find_extent_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1603,7 +1604,7 @@ static uint32_t find_extent_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
len--;
|
||||
|
||||
if (sectlen > len) {
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %lx\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1630,13 +1631,13 @@ static uint32_t find_extent_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!keycmp(searchkey, tp.item->key)) {
|
||||
if (tp.item->size < sizeof(EXTENT_DATA_REF))
|
||||
ERR("(%I64x,%x,%I64x) has size %u, not %u as expected\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_DATA_REF));
|
||||
ERR("(%I64x,%x,%I64x) has size %u, not %Iu as expected\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_DATA_REF));
|
||||
else {
|
||||
EXTENT_DATA_REF* edr = (EXTENT_DATA_REF*)tp.item->data;
|
||||
|
||||
|
@ -1659,7 +1660,7 @@ uint64_t get_extent_refcount(device_extension* Vcb, uint64_t address, uint64_t s
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1683,8 +1684,8 @@ uint64_t get_extent_refcount(device_extension* Vcb, uint64_t address, uint64_t s
|
|||
|
||||
return eiv0->refcount;
|
||||
} else if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expected at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type,
|
||||
tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expected at least %Ix\n", tp.item->key.obj_id, tp.item->key.obj_type,
|
||||
tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1717,7 +1718,7 @@ bool is_extent_unique(device_extension* Vcb, uint64_t address, uint64_t size, PI
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("error - find_item returned %08x\n", Status);
|
||||
WARN("error - find_item returned %08lx\n", Status);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1731,7 @@ bool is_extent_unique(device_extension* Vcb, uint64_t address, uint64_t size, PI
|
|||
return false;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1741,7 +1742,7 @@ bool is_extent_unique(device_extension* Vcb, uint64_t address, uint64_t size, PI
|
|||
|
||||
if (ei->flags & EXTENT_ITEM_TREE_BLOCK) {
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1761,7 +1762,7 @@ bool is_extent_unique(device_extension* Vcb, uint64_t address, uint64_t size, PI
|
|||
len--;
|
||||
|
||||
if (sectlen > len) {
|
||||
WARN("(%I64x,%x,%I64x): %x bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
WARN("(%I64x,%x,%I64x): %x bytes left, expecting at least %lx\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1799,7 +1800,7 @@ bool is_extent_unique(device_extension* Vcb, uint64_t address, uint64_t size, PI
|
|||
EXTENT_DATA_REF* edr = (EXTENT_DATA_REF*)tp.item->data;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_DATA_REF)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
return false;
|
||||
}
|
||||
|
@ -1843,7 +1844,7 @@ uint64_t get_extent_flags(device_extension* Vcb, uint64_t address, PIRP Irp) {
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1862,8 +1863,8 @@ uint64_t get_extent_flags(device_extension* Vcb, uint64_t address, PIRP Irp) {
|
|||
if (tp.item->size == sizeof(EXTENT_ITEM_V0))
|
||||
return 0;
|
||||
else if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expected at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type,
|
||||
tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expected at least %Ix\n", tp.item->key.obj_id, tp.item->key.obj_type,
|
||||
tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1884,7 +1885,7 @@ void update_extent_flags(device_extension* Vcb, uint64_t address, uint64_t flags
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1903,8 +1904,8 @@ void update_extent_flags(device_extension* Vcb, uint64_t address, uint64_t flags
|
|||
if (tp.item->size == sizeof(EXTENT_ITEM_V0))
|
||||
return;
|
||||
else if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expected at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type,
|
||||
tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %x bytes, expected at least %Ix\n", tp.item->key.obj_id, tp.item->key.obj_type,
|
||||
tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1974,7 +1975,7 @@ NTSTATUS update_changed_extent_ref(device_extension* Vcb, chunk* c, uint64_t add
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1999,7 +2000,7 @@ NTSTATUS update_changed_extent_ref(device_extension* Vcb, chunk* c, uint64_t add
|
|||
|
||||
ce->count = ce->old_count = ei->refcount;
|
||||
} else {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
Status = STATUS_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
@ -2130,7 +2131,7 @@ uint64_t find_extent_shared_tree_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2140,12 +2141,12 @@ uint64_t find_extent_shared_tree_refcount(device_extension* Vcb, uint64_t addres
|
|||
}
|
||||
|
||||
if (tp.item->key.obj_type == TYPE_EXTENT_ITEM && tp.item->key.offset != Vcb->superblock.node_size) {
|
||||
ERR("extent %I64x had size %I64x, not %I64x as expected\n", address, tp.item->key.offset, Vcb->superblock.node_size);
|
||||
ERR("extent %I64x had size %I64x, not %x as expected\n", address, tp.item->key.offset, Vcb->superblock.node_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x): size was %u, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x): size was %u, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2157,8 +2158,8 @@ uint64_t find_extent_shared_tree_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
if (searchkey.obj_type == TYPE_EXTENT_ITEM && ei->flags & EXTENT_ITEM_TREE_BLOCK) {
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2)) {
|
||||
ERR("(%I64x,%x,%I64x): size was %u, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
ERR("(%I64x,%x,%I64x): size was %u, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2174,7 +2175,7 @@ uint64_t find_extent_shared_tree_refcount(device_extension* Vcb, uint64_t addres
|
|||
len--;
|
||||
|
||||
if (sectlen > len) {
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %lx\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2206,7 +2207,7 @@ uint64_t find_extent_shared_tree_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2231,7 +2232,7 @@ uint32_t find_extent_shared_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2241,7 +2242,7 @@ uint32_t find_extent_shared_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x): size was %u, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x): size was %u, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2259,7 +2260,7 @@ uint32_t find_extent_shared_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
len--;
|
||||
|
||||
if (sectlen > len) {
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %x\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
ERR("(%I64x,%x,%I64x): %x bytes left, expecting at least %lx\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, len, sectlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2291,13 +2292,13 @@ uint32_t find_extent_shared_data_refcount(device_extension* Vcb, uint64_t addres
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!keycmp(searchkey, tp.item->key)) {
|
||||
if (tp.item->size < sizeof(uint32_t))
|
||||
ERR("(%I64x,%x,%I64x) has size %u, not %u as expected\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(uint32_t));
|
||||
ERR("(%I64x,%x,%I64x) has size %u, not %Iu as expected\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(uint32_t));
|
||||
else {
|
||||
uint32_t* count = (uint32_t*)tp.item->data;
|
||||
return *count;
|
||||
|
|
|
@ -372,7 +372,7 @@ static BOOLEAN __stdcall fast_io_lock(PFILE_OBJECT FileObject, PLARGE_INTEGER Fi
|
|||
BOOLEAN ret;
|
||||
fcb* fcb = FileObject->FsContext;
|
||||
|
||||
TRACE("(%p, %I64x, %I64x, %p, %x, %u, %u, %p, %p)\n", FileObject, FileOffset ? FileOffset->QuadPart : 0, Length ? Length->QuadPart : 0,
|
||||
TRACE("(%p, %I64x, %I64x, %p, %lx, %u, %u, %p, %p)\n", FileObject, FileOffset ? FileOffset->QuadPart : 0, Length ? Length->QuadPart : 0,
|
||||
ProcessId, Key, FailImmediately, ExclusiveLock, IoStatus, DeviceObject);
|
||||
|
||||
if (fcb->type != BTRFS_TYPE_FILE) {
|
||||
|
@ -402,7 +402,7 @@ static BOOLEAN __stdcall fast_io_unlock_single(PFILE_OBJECT FileObject, PLARGE_I
|
|||
ULONG Key, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) {
|
||||
fcb* fcb = FileObject->FsContext;
|
||||
|
||||
TRACE("(%p, %I64x, %I64x, %p, %x, %p, %p)\n", FileObject, FileOffset ? FileOffset->QuadPart : 0, Length ? Length->QuadPart : 0,
|
||||
TRACE("(%p, %I64x, %I64x, %p, %lx, %p, %p)\n", FileObject, FileOffset ? FileOffset->QuadPart : 0, Length ? Length->QuadPart : 0,
|
||||
ProcessId, Key, IoStatus, DeviceObject);
|
||||
|
||||
IoStatus->Information = 0;
|
||||
|
@ -458,7 +458,7 @@ static BOOLEAN __stdcall fast_io_unlock_all_by_key(PFILE_OBJECT FileObject, PVOI
|
|||
PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) {
|
||||
fcb* fcb = FileObject->FsContext;
|
||||
|
||||
TRACE("(%p, %p, %x, %p, %p)\n", FileObject, ProcessId, Key, IoStatus, DeviceObject);
|
||||
TRACE("(%p, %p, %lx, %p, %p)\n", FileObject, ProcessId, Key, IoStatus, DeviceObject);
|
||||
|
||||
IoStatus->Information = 0;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "btrfs_drv.h"
|
||||
#include "crc32c.h"
|
||||
|
||||
#if (NTDDI_VERSION >= NTDDI_WIN10)
|
||||
// not currently in mingw - introduced with Windows 10
|
||||
|
@ -28,6 +29,7 @@
|
|||
#define FileStatLxInformation (enum _FILE_INFORMATION_CLASS)70
|
||||
#define FileCaseSensitiveInformation (enum _FILE_INFORMATION_CLASS)71
|
||||
#define FileLinkInformationEx (enum _FILE_INFORMATION_CLASS)72
|
||||
#define FileStorageReserveIdInformation (enum _FILE_INFORMATION_CLASS)74
|
||||
|
||||
typedef struct _FILE_ID_INFORMATION {
|
||||
ULONGLONG VolumeSerialNumber;
|
||||
|
@ -139,8 +141,6 @@ typedef struct _FILE_LINKS_FULL_ID_INFORMATION {
|
|||
#define FILE_LINK_FORCE_RESIZE_TARGET_SR 0x080
|
||||
#define FILE_LINK_FORCE_RESIZE_SOURCE_SR 0x100
|
||||
|
||||
#define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
|
||||
|
||||
#else
|
||||
|
||||
#define FILE_RENAME_INFORMATION_EX FILE_RENAME_INFORMATION
|
||||
|
@ -210,7 +210,7 @@ static NTSTATUS set_basic_information(device_extension* Vcb, PIRP Irp, PFILE_OBJ
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
TRACE("file = %p, attributes = %x\n", FileObject, fbi->FileAttributes);
|
||||
TRACE("file = %p, attributes = %lx\n", FileObject, fbi->FileAttributes);
|
||||
|
||||
ExAcquireResourceExclusiveLite(fcb->Header.Resource, true);
|
||||
|
||||
|
@ -389,7 +389,7 @@ static NTSTATUS set_disposition_information(device_extension* Vcb, PIRP Irp, PFI
|
|||
} else
|
||||
atts = fcb->atts;
|
||||
|
||||
TRACE("atts = %x\n", atts);
|
||||
TRACE("atts = %lx\n", atts);
|
||||
|
||||
if (atts & FILE_ATTRIBUTE_READONLY) {
|
||||
TRACE("not allowing readonly file to be deleted\n");
|
||||
|
@ -714,7 +714,7 @@ static NTSTATUS add_children_to_move_list(device_extension* Vcb, move_entry* me,
|
|||
Status = open_fileref_child(Vcb, me->fileref, &dc->name, true, true, dc->index == 0 ? true : false, PagedPool, &fr, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_child returned %08x\n", Status);
|
||||
ERR("open_fileref_child returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&me->fileref->fcb->nonpaged->dir_children_lock);
|
||||
return Status;
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ static NTSTATUS create_directory_fcb(device_extension* Vcb, root* r, fcb* parfcb
|
|||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
reap_fcb(fcb);
|
||||
ERR("SeAssignSecurity returned %08x\n", Status);
|
||||
ERR("SeAssignSecurity returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -830,7 +830,7 @@ static NTSTATUS create_directory_fcb(device_extension* Vcb, root* r, fcb* parfcb
|
|||
|
||||
Status = RtlGetOwnerSecurityDescriptor(fcb->sd, &owner, &defaulted);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlGetOwnerSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlGetOwnerSecurityDescriptor returned %08lx\n", Status);
|
||||
fcb->inode_item.st_uid = UID_NOBODY;
|
||||
fcb->sd_dirty = true;
|
||||
} else {
|
||||
|
@ -929,7 +929,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
Status = add_children_to_move_list(fileref->fcb->Vcb, me, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_children_to_move_list returned %08x\n", Status);
|
||||
ERR("add_children_to_move_list returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
|
||||
Status = duplicate_fcb(me->fileref->fcb, &me->dummyfcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("duplicate_fcb returned %08x\n", Status);
|
||||
ERR("duplicate_fcb returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(me->fileref->fcb->Header.Resource);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1031,7 +1031,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
ext->offset - ed2->offset, 1, me->fileref->fcb->inode_item.flags & BTRFS_INODE_NODATASUM, false, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_changed_extent_ref returned %08x\n", Status);
|
||||
ERR("update_changed_extent_ref returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(me->fileref->fcb->Header.Resource);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
|
||||
Status = create_directory_fcb(me->fileref->fcb->Vcb, r, me->fileref->parent->fcb, &me->fileref->fcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("create_directory_fcb returnd %08x\n", Status);
|
||||
ERR("create_directory_fcb returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&fileref->dc->name_uc, &fileref->dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1316,7 +1316,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
if (!me->dummyfileref->fcb->ads) {
|
||||
Status = delete_fileref(me->dummyfileref, NULL, false, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1372,7 +1372,7 @@ static NTSTATUS move_across_subvols(file_ref* fileref, ccb* ccb, file_ref* destd
|
|||
if (me->dummyfileref->fcb->ads && me->parent->dummyfileref->fcb->deleted) {
|
||||
Status = delete_fileref(me->dummyfileref, NULL, false, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1712,7 +1712,7 @@ static NTSTATUS rename_stream_to_file(device_extension* Vcb, file_ref* fileref,
|
|||
|
||||
Status = add_extent_to_fcb(fileref->fcb, 0, ed, (uint16_t)(offsetof(EXTENT_DATA, data[0]) + adsdata.Length), false, NULL, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_extent_to_fcb returned %08x\n", Status);
|
||||
ERR("add_extent_to_fcb returned %08lx\n", Status);
|
||||
ExFreePool(ed);
|
||||
reap_fcb(dummyfcb);
|
||||
return Status;
|
||||
|
@ -1740,7 +1740,7 @@ static NTSTATUS rename_stream_to_file(device_extension* Vcb, file_ref* fileref,
|
|||
if (!make_inline) {
|
||||
Status = do_write_file(fileref->fcb, 0, adsdata.Length, adsdata.Buffer, Irp, false, 0, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write_file returned %08x\n", Status);
|
||||
ERR("do_write_file returned %08lx\n", Status);
|
||||
ExFreePool(adsdata.Buffer);
|
||||
reap_fcb(dummyfcb);
|
||||
return Status;
|
||||
|
@ -1840,7 +1840,7 @@ static NTSTATUS rename_stream(device_extension* Vcb, file_ref* fileref, ccb* ccb
|
|||
return rename_stream_to_file(Vcb, fileref, ccb, flags, Irp, rollback);
|
||||
|
||||
if (!is_file_name_valid(&fn, false, true)) {
|
||||
WARN("invalid stream name %.*S\n", fn.Length / sizeof(WCHAR), fn.Buffer);
|
||||
WARN("invalid stream name %.*S\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
|
||||
return STATUS_OBJECT_NAME_INVALID;
|
||||
}
|
||||
|
||||
|
@ -1877,12 +1877,12 @@ static NTSTATUS rename_stream(device_extension* Vcb, file_ref* fileref, ccb* ccb
|
|||
|
||||
Status = delete_fileref(sf, NULL, false, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ERR("open_fileref_child returned %08x\n", Status);
|
||||
ERR("open_fileref_child returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1966,7 +1966,7 @@ static NTSTATUS rename_stream(device_extension* Vcb, file_ref* fileref, ccb* ccb
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&utf16uc, &fn, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n");
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(utf8.Buffer);
|
||||
ExFreePool(utf16.Buffer);
|
||||
ExFreePool(adsxattr.Buffer);
|
||||
|
@ -2079,7 +2079,7 @@ static NTSTATUS rename_file_to_stream(device_extension* Vcb, file_ref* fileref,
|
|||
}
|
||||
|
||||
if (!is_file_name_valid(&fn, false, true)) {
|
||||
WARN("invalid stream name %.*S\n", fn.Length / sizeof(WCHAR), fn.Buffer);
|
||||
WARN("invalid stream name %.*S\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
|
||||
return STATUS_OBJECT_NAME_INVALID;
|
||||
}
|
||||
|
||||
|
@ -2116,12 +2116,12 @@ static NTSTATUS rename_file_to_stream(device_extension* Vcb, file_ref* fileref,
|
|||
|
||||
Status = delete_fileref(sf, NULL, false, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ERR("open_fileref_child returned %08x\n", Status);
|
||||
ERR("open_fileref_child returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2205,7 +2205,7 @@ static NTSTATUS rename_file_to_stream(device_extension* Vcb, file_ref* fileref,
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&utf16uc, &fn, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n");
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExFreePool(utf8.Buffer);
|
||||
ExFreePool(utf16.Buffer);
|
||||
ExFreePool(adsxattr.Buffer);
|
||||
|
@ -2274,7 +2274,7 @@ static NTSTATUS rename_file_to_stream(device_extension* Vcb, file_ref* fileref,
|
|||
|
||||
Status = duplicate_fcb(fileref->fcb, &dummyfcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("duplicate_fcb returned %08x\n", Status);
|
||||
ERR("duplicate_fcb returned %08lx\n", Status);
|
||||
ExFreePool(utf8.Buffer);
|
||||
ExFreePool(utf16.Buffer);
|
||||
ExFreePool(utf16uc.Buffer);
|
||||
|
@ -2318,7 +2318,7 @@ static NTSTATUS rename_file_to_stream(device_extension* Vcb, file_ref* fileref,
|
|||
Status = excise_extents(Vcb, dummyfcb, 0, sector_align(fileref->fcb->inode_item.st_size, Vcb->superblock.sector_size),
|
||||
Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
ExFreePool(utf8.Buffer);
|
||||
ExFreePool(utf16.Buffer);
|
||||
ExFreePool(utf16uc.Buffer);
|
||||
|
@ -2480,9 +2480,9 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
flags = fri->ReplaceIfExists ? FILE_RENAME_REPLACE_IF_EXISTS : 0;
|
||||
|
||||
TRACE("tfo = %p\n", tfo);
|
||||
TRACE("Flags = %x\n", flags);
|
||||
TRACE("Flags = %lx\n", flags);
|
||||
TRACE("RootDirectory = %p\n", fri->RootDirectory);
|
||||
TRACE("FileName = %.*S\n", fri->FileNameLength / sizeof(WCHAR), fri->FileName);
|
||||
TRACE("FileName = %.*S\n", (int)(fri->FileNameLength / sizeof(WCHAR)), fri->FileName);
|
||||
|
||||
fn = fri->FileName;
|
||||
fnlen = fri->FileNameLength / sizeof(WCHAR);
|
||||
|
@ -2526,7 +2526,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, &iosb);
|
||||
if (!NT_SUCCESS(iosb.Status)) {
|
||||
ERR("CcFlushCache returned %08x\n", iosb.Status);
|
||||
ERR("CcFlushCache returned %08lx\n", iosb.Status);
|
||||
Status = iosb.Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -2540,7 +2540,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, &iosb);
|
||||
if (!NT_SUCCESS(iosb.Status)) {
|
||||
ERR("CcFlushCache returned %08x\n", iosb.Status);
|
||||
ERR("CcFlushCache returned %08lx\n", iosb.Status);
|
||||
Status = iosb.Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -2553,7 +2553,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
fnus.Buffer = fn;
|
||||
fnus.Length = fnus.MaximumLength = (uint16_t)(fnlen * sizeof(WCHAR));
|
||||
|
||||
TRACE("fnus = %.*S\n", fnus.Length / sizeof(WCHAR), fnus.Buffer);
|
||||
TRACE("fnus = %.*S\n", (int)(fnus.Length / sizeof(WCHAR)), fnus.Buffer);
|
||||
|
||||
#ifndef __REACTOS__
|
||||
for (unsigned int i = 0 ; i < fnus.Length / sizeof(WCHAR); i++) {
|
||||
|
@ -2632,7 +2632,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
Status = open_fileref(Vcb, &related, &fnus, NULL, true, NULL, NULL, PagedPool, ccb->case_sensitive, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2647,7 +2647,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
if (!SeAccessCheck(related->fcb->sd, &subjcont, false, fcb->type == BTRFS_TYPE_DIRECTORY ? FILE_ADD_SUBDIRECTORY : FILE_ADD_FILE, 0, NULL,
|
||||
IoGetFileObjectGenericMapping(), Irp->RequestorMode, &access, &Status)) {
|
||||
SeReleaseSubjectContext(&subjcont);
|
||||
TRACE("SeAccessCheck failed, returning %08x\n", Status);
|
||||
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2665,7 +2665,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
if (!SeAccessCheck(oldfileref->fcb->sd, &subjcont, false, DELETE, 0, NULL,
|
||||
IoGetFileObjectGenericMapping(), Irp->RequestorMode, &access, &Status)) {
|
||||
SeReleaseSubjectContext(&subjcont);
|
||||
TRACE("SeAccessCheck failed, returning %08x\n", Status);
|
||||
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2678,7 +2678,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = delete_fileref(oldfileref, NULL, oldfileref->open_count > 0 && flags & FILE_RENAME_POSIX_SEMANTICS, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2686,7 +2686,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
if (fileref->parent->fcb->subvol != related->fcb->subvol && (fileref->fcb->subvol == fileref->parent->fcb->subvol || fileref->fcb == Vcb->dummy_fcb)) {
|
||||
Status = move_across_subvols(fileref, ccb, related, &utf8, &fnus, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("move_across_subvols returned %08x\n", Status);
|
||||
ERR("move_across_subvols returned %08lx\n", Status);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
|
@ -2700,7 +2700,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = fileref_get_filename(fileref, &oldfn, &name_offset, &reqlen);
|
||||
if (Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2715,7 +2715,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = fileref_get_filename(fileref, &oldfn, &name_offset, &reqlen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
ExFreePool(oldfn.Buffer);
|
||||
goto end;
|
||||
}
|
||||
|
@ -2734,7 +2734,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
RtlCopyMemory(fileref->oldutf8.Buffer, fileref->dc->utf8.Buffer, fileref->dc->utf8.Length);
|
||||
}
|
||||
|
||||
TRACE("renaming %.*S to %.*S\n", fileref->dc->name.Length / sizeof(WCHAR), fileref->dc->name.Buffer, fnus.Length / sizeof(WCHAR), fnus.Buffer);
|
||||
TRACE("renaming %.*S to %.*S\n", (int)(fileref->dc->name.Length / sizeof(WCHAR)), fileref->dc->name.Buffer, (int)(fnus.Length / sizeof(WCHAR)), fnus.Buffer);
|
||||
|
||||
mark_fileref_dirty(fileref);
|
||||
|
||||
|
@ -2771,7 +2771,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&fileref->dc->name_uc, &fileref->dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&fileref->parent->fcb->nonpaged->dir_children_lock);
|
||||
ExFreePool(oldfn.Buffer);
|
||||
goto end;
|
||||
|
@ -2791,7 +2791,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = fileref_get_filename(fileref, &newfn, &name_offset, &reqlen);
|
||||
if (Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
ExFreePool(oldfn.Buffer);
|
||||
goto end;
|
||||
}
|
||||
|
@ -2808,7 +2808,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = fileref_get_filename(fileref, &newfn, &name_offset, &reqlen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
ExFreePool(oldfn.Buffer);
|
||||
ExFreePool(newfn.Buffer);
|
||||
goto end;
|
||||
|
@ -2941,7 +2941,7 @@ static NTSTATUS set_rename_information(device_extension* Vcb, PIRP Irp, PFILE_OB
|
|||
|
||||
Status = RtlUpcaseUnicodeString(&fileref->dc->name_uc, &fileref->dc->name, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
|
||||
ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3108,7 +3108,7 @@ NTSTATUS stream_set_end_of_file_information(device_extension* Vcb, uint16_t end,
|
|||
LARGE_INTEGER time;
|
||||
BTRFS_TIME now;
|
||||
|
||||
TRACE("setting new end to %I64x bytes (currently %x)\n", end, fcb->adsdata.Length);
|
||||
TRACE("setting new end to %x bytes (currently %x)\n", end, fcb->adsdata.Length);
|
||||
|
||||
if (!fileref || !fileref->parent) {
|
||||
ERR("no fileref for stream\n");
|
||||
|
@ -3119,14 +3119,14 @@ NTSTATUS stream_set_end_of_file_information(device_extension* Vcb, uint16_t end,
|
|||
if (advance_only)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
TRACE("truncating stream to %I64x bytes\n", end);
|
||||
TRACE("truncating stream to %x bytes\n", end);
|
||||
|
||||
fcb->adsdata.Length = end;
|
||||
} else if (end > fcb->adsdata.Length) {
|
||||
TRACE("extending stream to %I64x bytes\n", end);
|
||||
TRACE("extending stream to %x bytes\n", end);
|
||||
|
||||
if (end > fcb->adsmaxlen) {
|
||||
ERR("error - xattr too long (%u > %u)\n", end, fcb->adsmaxlen);
|
||||
ERR("error - xattr too long (%u > %lu)\n", end, fcb->adsmaxlen);
|
||||
return STATUS_DISK_FULL;
|
||||
}
|
||||
|
||||
|
@ -3264,12 +3264,6 @@ static NTSTATUS set_end_of_file_information(device_extension* Vcb, PIRP Irp, PFI
|
|||
goto end;
|
||||
}
|
||||
} else if ((uint64_t)feofi->EndOfFile.QuadPart > fcb->inode_item.st_size) {
|
||||
if (Irp->Flags & IRP_PAGING_IO) {
|
||||
TRACE("paging IO tried to extend file size\n");
|
||||
Status = STATUS_SUCCESS;
|
||||
goto end;
|
||||
}
|
||||
|
||||
TRACE("extending file to %I64x bytes\n", feofi->EndOfFile.QuadPart);
|
||||
|
||||
Status = extend_file(fcb, fileref, feofi->EndOfFile.QuadPart, prealloc, NULL, &rollback);
|
||||
|
@ -3317,7 +3311,7 @@ end:
|
|||
} _SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("CcSetFileSizes threw exception %08x\n", Status);
|
||||
ERR("CcSetFileSizes threw exception %08lx\n", Status);
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
|
@ -3366,10 +3360,10 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
else
|
||||
flags = fli->ReplaceIfExists ? FILE_LINK_REPLACE_IF_EXISTS : 0;
|
||||
|
||||
TRACE("flags = %x\n", flags);
|
||||
TRACE("flags = %lx\n", flags);
|
||||
TRACE("RootDirectory = %p\n", fli->RootDirectory);
|
||||
TRACE("FileNameLength = %x\n", fli->FileNameLength);
|
||||
TRACE("FileName = %.*S\n", fli->FileNameLength / sizeof(WCHAR), fli->FileName);
|
||||
TRACE("FileNameLength = %lx\n", fli->FileNameLength);
|
||||
TRACE("FileName = %.*S\n", (int)(fli->FileNameLength / sizeof(WCHAR)), fli->FileName);
|
||||
|
||||
fn = fli->FileName;
|
||||
fnlen = fli->FileNameLength / sizeof(WCHAR);
|
||||
|
@ -3427,7 +3421,7 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
fnus.Buffer = fn;
|
||||
fnus.Length = fnus.MaximumLength = (uint16_t)(fnlen * sizeof(WCHAR));
|
||||
|
||||
TRACE("fnus = %.*S\n", fnus.Length / sizeof(WCHAR), fnus.Buffer);
|
||||
TRACE("fnus = %.*S\n", (int)(fnus.Length / sizeof(WCHAR)), fnus.Buffer);
|
||||
|
||||
Status = utf16_to_utf8(NULL, 0, &utf8len, fn, (ULONG)fnlen * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -3487,7 +3481,7 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
Status = open_fileref(Vcb, &related, &fnus, NULL, true, NULL, NULL, PagedPool, ccb->case_sensitive, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -3497,7 +3491,7 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
if (!SeAccessCheck(related->fcb->sd, &subjcont, false, FILE_ADD_FILE, 0, NULL,
|
||||
IoGetFileObjectGenericMapping(), Irp->RequestorMode, &access, &Status)) {
|
||||
SeReleaseSubjectContext(&subjcont);
|
||||
TRACE("SeAccessCheck failed, returning %08x\n", Status);
|
||||
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3515,7 +3509,7 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
if (!SeAccessCheck(oldfileref->fcb->sd, &subjcont, false, DELETE, 0, NULL,
|
||||
IoGetFileObjectGenericMapping(), Irp->RequestorMode, &access, &Status)) {
|
||||
SeReleaseSubjectContext(&subjcont);
|
||||
TRACE("SeAccessCheck failed, returning %08x\n", Status);
|
||||
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3528,7 +3522,7 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
|
||||
Status = delete_fileref(oldfileref, NULL, oldfileref->open_count > 0 && flags & FILE_RENAME_POSIX_SEMANTICS, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_fileref returned %08x\n", Status);
|
||||
ERR("delete_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -3543,7 +3537,7 @@ static NTSTATUS set_link_information(device_extension* Vcb, PIRP Irp, PFILE_OBJE
|
|||
|
||||
Status = add_dir_child(related->fcb, fcb->inode, false, &utf8, &fnus, fcb->type, &dc);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("add_dir_child returned %08x\n", Status);
|
||||
WARN("add_dir_child returned %08lx\n", Status);
|
||||
|
||||
fr2->dc = dc;
|
||||
dc->fileref = fr2;
|
||||
|
@ -3700,7 +3694,7 @@ static NTSTATUS set_valid_data_length_information(device_extension* Vcb, PIRP Ir
|
|||
ULONG filter;
|
||||
|
||||
if (IrpSp->Parameters.SetFile.Length < sizeof(FILE_VALID_DATA_LENGTH_INFORMATION)) {
|
||||
ERR("input buffer length was %u, expected %u\n", IrpSp->Parameters.SetFile.Length, sizeof(FILE_VALID_DATA_LENGTH_INFORMATION));
|
||||
ERR("input buffer length was %lu, expected %Iu\n", IrpSp->Parameters.SetFile.Length, sizeof(FILE_VALID_DATA_LENGTH_INFORMATION));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -3771,7 +3765,7 @@ end:
|
|||
} _SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("CcSetFileSizes threw exception %08x\n", Status);
|
||||
ERR("CcSetFileSizes threw exception %08lx\n", Status);
|
||||
else
|
||||
fcb->Header.AllocationSize = ccfs.AllocationSize;
|
||||
}
|
||||
|
@ -4008,6 +4002,11 @@ NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP I
|
|||
|
||||
Status = set_case_sensitive_information(Irp);
|
||||
break;
|
||||
|
||||
case FileStorageReserveIdInformation:
|
||||
WARN("unimplemented FileInformationClass FileStorageReserveIdInformation\n");
|
||||
break;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
@ -4020,7 +4019,7 @@ NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP I
|
|||
end:
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
|
@ -4267,7 +4266,7 @@ static NTSTATUS fill_in_file_name_information(FILE_NAME_INFORMATION* fni, fcb* f
|
|||
|
||||
*length -= (LONG)offsetof(FILE_NAME_INFORMATION, FileName[0]);
|
||||
|
||||
TRACE("maximum length is %u\n", *length);
|
||||
TRACE("maximum length is %li\n", *length);
|
||||
fni->FileNameLength = 0;
|
||||
|
||||
fni->FileName[0] = 0;
|
||||
|
@ -4278,7 +4277,7 @@ static NTSTATUS fill_in_file_name_information(FILE_NAME_INFORMATION* fni, fcb* f
|
|||
|
||||
Status = fileref_get_filename(fileref, &fn, NULL, &reqlen);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -4300,11 +4299,11 @@ static NTSTATUS fill_in_file_name_information(FILE_NAME_INFORMATION* fni, fcb* f
|
|||
if (Status == STATUS_BUFFER_OVERFLOW) {
|
||||
*length = -1;
|
||||
fni->FileNameLength = reqlen;
|
||||
TRACE("%.*S (truncated)\n", fn.Length / sizeof(WCHAR), fn.Buffer);
|
||||
TRACE("%.*S (truncated)\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
|
||||
} else {
|
||||
*length -= fn.Length;
|
||||
fni->FileNameLength = fn.Length;
|
||||
TRACE("%.*S\n", fn.Length / sizeof(WCHAR), fn.Buffer);
|
||||
TRACE("%.*S\n", (int)(fn.Length / sizeof(WCHAR)), fn.Buffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
@ -4368,7 +4367,7 @@ static NTSTATUS fill_in_file_stream_information(FILE_STREAM_INFORMATION* fsi, fi
|
|||
le = le->Flink;
|
||||
}
|
||||
|
||||
TRACE("length = %i, reqsize = %u\n", *length, reqsize);
|
||||
TRACE("length = %li, reqsize = %lu\n", *length, reqsize);
|
||||
|
||||
if (reqsize > *length) {
|
||||
Status = STATUS_BUFFER_OVERFLOW;
|
||||
|
@ -4537,12 +4536,12 @@ static NTSTATUS fill_in_hard_link_information(FILE_LINKS_INFORMATION* fli, file_
|
|||
hardlink* hl = CONTAINING_RECORD(le, hardlink, list_entry);
|
||||
file_ref* parfr;
|
||||
|
||||
TRACE("parent %I64x, index %I64x, name %.*S\n", hl->parent, hl->index, hl->name.Length / sizeof(WCHAR), hl->name.Buffer);
|
||||
TRACE("parent %I64x, index %I64x, name %.*S\n", hl->parent, hl->index, (int)(hl->name.Length / sizeof(WCHAR)), hl->name.Buffer);
|
||||
|
||||
Status = open_fileref_by_inode(fcb->Vcb, fcb->subvol, hl->parent, &parfr, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_by_inode returned %08x\n", Status);
|
||||
ERR("open_fileref_by_inode returned %08lx\n", Status);
|
||||
} else if (!parfr->deleted) {
|
||||
LIST_ENTRY* le2;
|
||||
bool found = false, deleted = false;
|
||||
|
@ -4569,7 +4568,7 @@ static NTSTATUS fill_in_hard_link_information(FILE_LINKS_INFORMATION* fli, file_
|
|||
fn = &hl->name;
|
||||
|
||||
if (!deleted) {
|
||||
TRACE("fn = %.*S (found = %u)\n", fn->Length / sizeof(WCHAR), fn->Buffer, found);
|
||||
TRACE("fn = %.*S (found = %u)\n", (int)(fn->Length / sizeof(WCHAR)), fn->Buffer, found);
|
||||
|
||||
if (feli)
|
||||
bytes_needed = (LONG)sector_align(bytes_needed, 8);
|
||||
|
@ -4705,12 +4704,12 @@ static NTSTATUS fill_in_hard_link_full_id_information(FILE_LINKS_FULL_ID_INFORMA
|
|||
hardlink* hl = CONTAINING_RECORD(le, hardlink, list_entry);
|
||||
file_ref* parfr;
|
||||
|
||||
TRACE("parent %I64x, index %I64x, name %.*S\n", hl->parent, hl->index, hl->name.Length / sizeof(WCHAR), hl->name.Buffer);
|
||||
TRACE("parent %I64x, index %I64x, name %.*S\n", hl->parent, hl->index, (int)(hl->name.Length / sizeof(WCHAR)), hl->name.Buffer);
|
||||
|
||||
Status = open_fileref_by_inode(fcb->Vcb, fcb->subvol, hl->parent, &parfr, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref_by_inode returned %08x\n", Status);
|
||||
ERR("open_fileref_by_inode returned %08lx\n", Status);
|
||||
} else if (!parfr->deleted) {
|
||||
LIST_ENTRY* le2;
|
||||
bool found = false, deleted = false;
|
||||
|
@ -4737,7 +4736,7 @@ static NTSTATUS fill_in_hard_link_full_id_information(FILE_LINKS_FULL_ID_INFORMA
|
|||
fn = &hl->name;
|
||||
|
||||
if (!deleted) {
|
||||
TRACE("fn = %.*S (found = %u)\n", fn->Length / sizeof(WCHAR), fn->Buffer, found);
|
||||
TRACE("fn = %.*S (found = %u)\n", (int)(fn->Length / sizeof(WCHAR)), fn->Buffer, found);
|
||||
|
||||
if (flefii)
|
||||
bytes_needed = (LONG)sector_align(bytes_needed, 8);
|
||||
|
@ -4802,8 +4801,7 @@ static NTSTATUS fill_in_file_id_information(FILE_ID_INFORMATION* fii, fcb* fcb,
|
|||
static NTSTATUS fill_in_file_stat_information(FILE_STAT_INFORMATION* fsi, fcb* fcb, ccb* ccb, LONG* length) {
|
||||
INODE_ITEM* ii;
|
||||
|
||||
fsi->FileId.LowPart = (uint32_t)fcb->inode;
|
||||
fsi->FileId.HighPart = (uint32_t)fcb->subvol->id;
|
||||
fsi->FileId.QuadPart = make_file_id(fcb->subvol, fcb->inode);
|
||||
|
||||
if (fcb->ads)
|
||||
ii = &ccb->fileref->parent->fcb->inode_item;
|
||||
|
@ -4832,13 +4830,13 @@ static NTSTATUS fill_in_file_stat_information(FILE_STAT_INFORMATION* fsi, fcb* f
|
|||
}
|
||||
|
||||
if (fcb->type == BTRFS_TYPE_SOCKET)
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LXSS_SOCKET;
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_AF_UNIX;
|
||||
else if (fcb->type == BTRFS_TYPE_FIFO)
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LXSS_FIFO;
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LX_FIFO;
|
||||
else if (fcb->type == BTRFS_TYPE_CHARDEV)
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LXSS_CHARDEV;
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LX_CHR;
|
||||
else if (fcb->type == BTRFS_TYPE_BLOCKDEV)
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LXSS_BLOCKDEV;
|
||||
fsi->ReparseTag = IO_REPARSE_TAG_LX_BLK;
|
||||
else if (!(fsi->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
|
||||
fsi->ReparseTag = 0;
|
||||
else
|
||||
|
@ -4862,8 +4860,7 @@ static NTSTATUS fill_in_file_stat_information(FILE_STAT_INFORMATION* fsi, fcb* f
|
|||
static NTSTATUS fill_in_file_stat_lx_information(FILE_STAT_LX_INFORMATION* fsli, fcb* fcb, ccb* ccb, LONG* length) {
|
||||
INODE_ITEM* ii;
|
||||
|
||||
fsli->FileId.LowPart = (uint32_t)fcb->inode;
|
||||
fsli->FileId.HighPart = (uint32_t)fcb->subvol->id;
|
||||
fsli->FileId.QuadPart = make_file_id(fcb->subvol, fcb->inode);
|
||||
|
||||
if (fcb->ads)
|
||||
ii = &ccb->fileref->parent->fcb->inode_item;
|
||||
|
@ -4892,13 +4889,13 @@ static NTSTATUS fill_in_file_stat_lx_information(FILE_STAT_LX_INFORMATION* fsli,
|
|||
}
|
||||
|
||||
if (fcb->type == BTRFS_TYPE_SOCKET)
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LXSS_SOCKET;
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_AF_UNIX;
|
||||
else if (fcb->type == BTRFS_TYPE_FIFO)
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LXSS_FIFO;
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LX_FIFO;
|
||||
else if (fcb->type == BTRFS_TYPE_CHARDEV)
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LXSS_CHARDEV;
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LX_CHR;
|
||||
else if (fcb->type == BTRFS_TYPE_BLOCKDEV)
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LXSS_BLOCKDEV;
|
||||
fsli->ReparseTag = IO_REPARSE_TAG_LX_BLK;
|
||||
else if (!(fsli->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
|
||||
fsli->ReparseTag = 0;
|
||||
else
|
||||
|
@ -4942,7 +4939,21 @@ static NTSTATUS fill_in_file_case_sensitive_information(FILE_CASE_SENSITIVE_INFO
|
|||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __REACTOS__
|
||||
|
||||
static NTSTATUS fill_in_file_compression_information(FILE_COMPRESSION_INFORMATION* fci, LONG* length, fcb* fcb) {
|
||||
*length -= sizeof(FILE_COMPRESSION_INFORMATION);
|
||||
|
||||
memset(fci, 0, sizeof(FILE_COMPRESSION_INFORMATION));
|
||||
|
||||
if (fcb->ads)
|
||||
fci->CompressedFileSize.QuadPart = fcb->adsdata.Length;
|
||||
else if (!S_ISDIR(fcb->inode_item.st_mode))
|
||||
fci->CompressedFileSize.QuadPart = fcb->inode_item.st_size;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS query_info(device_extension* Vcb, PFILE_OBJECT FileObject, PIRP Irp) {
|
||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
@ -5073,9 +5084,14 @@ static NTSTATUS query_info(device_extension* Vcb, PFILE_OBJECT FileObject, PIRP
|
|||
}
|
||||
|
||||
case FileCompressionInformation:
|
||||
FIXME("STUB: FileCompressionInformation\n");
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
goto exit;
|
||||
{
|
||||
FILE_COMPRESSION_INFORMATION* fci = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
TRACE("FileCompressionInformation\n");
|
||||
|
||||
Status = fill_in_file_compression_information(fci, &length, fcb);
|
||||
break;
|
||||
}
|
||||
|
||||
case FileEaInformation:
|
||||
{
|
||||
|
@ -5310,7 +5326,7 @@ static NTSTATUS query_info(device_extension* Vcb, PFILE_OBJECT FileObject, PIRP
|
|||
Irp->IoStatus.Information = IrpSp->Parameters.QueryFile.Length - length;
|
||||
|
||||
exit:
|
||||
TRACE("query_info returning %08x\n", Status);
|
||||
TRACE("query_info returning %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -5349,7 +5365,7 @@ NTSTATUS __stdcall drv_query_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP
|
|||
Status = query_info(fcb->Vcb, IrpSp->FileObject, Irp);
|
||||
|
||||
end:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
|
@ -5577,7 +5593,7 @@ end2:
|
|||
ExReleaseResourceLite(fcb->Header.Resource);
|
||||
|
||||
end:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW ? retlen : 0;
|
||||
|
@ -5640,7 +5656,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
|
||||
Status = IoCheckEaBufferValidity(ffei, IrpSp->Parameters.SetEa.Length, &offset);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoCheckEaBufferValidity returned %08x (error at offset %u)\n", Status, offset);
|
||||
ERR("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -5936,7 +5952,7 @@ end2:
|
|||
}
|
||||
|
||||
end:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,7 @@
|
|||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "btrfs_drv.h"
|
||||
#include "crc32c.h"
|
||||
|
||||
// Number of increments in the size of each cache inode, in sectors. Should
|
||||
// this be a constant number of sectors, a constant 256 KB, or what?
|
||||
|
@ -27,7 +28,7 @@ static NTSTATUS remove_free_space_inode(device_extension* Vcb, uint64_t inode, L
|
|||
|
||||
Status = open_fcb(Vcb, Vcb->root_root, inode, BTRFS_TYPE_FILE, NULL, false, NULL, &fcb, PagedPool, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb returned %08x\n", Status);
|
||||
ERR("open_fcb returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,7 @@ static NTSTATUS remove_free_space_inode(device_extension* Vcb, uint64_t inode, L
|
|||
if (fcb->inode_item.st_size > 0) {
|
||||
Status = excise_extents(fcb->Vcb, fcb, 0, sector_align(fcb->inode_item.st_size, fcb->Vcb->superblock.sector_size), Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ static NTSTATUS remove_free_space_inode(device_extension* Vcb, uint64_t inode, L
|
|||
|
||||
Status = flush_fcb(fcb, false, batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("flush_fcb returned %08x\n", Status);
|
||||
ERR("flush_fcb returned %08lx\n", Status);
|
||||
free_fcb(fcb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -70,7 +71,7 @@ NTSTATUS clear_free_space_cache(device_extension* Vcb, LIST_ENTRY* batchlist, PI
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ NTSTATUS clear_free_space_cache(device_extension* Vcb, LIST_ENTRY* batchlist, PI
|
|||
if (tp.item->key.obj_id == searchkey.obj_id && tp.item->key.obj_type == searchkey.obj_type) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ NTSTATUS clear_free_space_cache(device_extension* Vcb, LIST_ENTRY* batchlist, PI
|
|||
Status = remove_free_space_inode(Vcb, fsi->key.obj_id, batchlist, Irp, &rollback);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("remove_free_space_inode for (%I64x,%x,%I64x) returned %08x\n", fsi->key.obj_id, fsi->key.obj_type, fsi->key.offset, Status);
|
||||
ERR("remove_free_space_inode for (%I64x,%x,%I64x) returned %08lx\n", fsi->key.obj_id, fsi->key.obj_type, fsi->key.offset, Status);
|
||||
|
||||
le = Vcb->chunks.Flink;
|
||||
while (le != &Vcb->chunks) {
|
||||
|
@ -111,7 +112,7 @@ NTSTATUS clear_free_space_cache(device_extension* Vcb, LIST_ENTRY* batchlist, PI
|
|||
}
|
||||
}
|
||||
} else
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
}
|
||||
|
||||
b = find_next_item(Vcb, &tp, &next_tp, false, Irp);
|
||||
|
@ -133,14 +134,14 @@ NTSTATUS clear_free_space_cache(device_extension* Vcb, LIST_ENTRY* batchlist, PI
|
|||
|
||||
Status = find_item(Vcb, Vcb->space_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
do {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,7 @@ NTSTATUS clear_free_space_cache(device_extension* Vcb, LIST_ENTRY* batchlist, PI
|
|||
|
||||
Status = load_cache_chunk(Vcb, c, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("load_cache_chunk(%I64x) returned %08x\n", c->offset, Status);
|
||||
ERR("load_cache_chunk(%I64x) returned %08lx\n", c->offset, Status);
|
||||
release_chunk_lock(c, Vcb);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
return Status;
|
||||
|
@ -385,7 +386,7 @@ static NTSTATUS get_superblock_size(chunk* c, uint64_t* size) {
|
|||
|
||||
Status = add_superblock_stripe(&stripes, off_start / ci->stripe_length, 1);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_superblock_stripe returned %08x\n", Status);
|
||||
ERR("add_superblock_stripe returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +404,7 @@ static NTSTATUS get_superblock_size(chunk* c, uint64_t* size) {
|
|||
|
||||
Status = add_superblock_stripe(&stripes, off_start / ci->stripe_length, (off_end - off_start) / ci->stripe_length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_superblock_stripe returned %08x\n", Status);
|
||||
ERR("add_superblock_stripe returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -421,12 +422,12 @@ static NTSTATUS get_superblock_size(chunk* c, uint64_t* size) {
|
|||
|
||||
Status = add_superblock_stripe(&stripes, off_start / ci->stripe_length, (off_end - off_start) / ci->stripe_length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_superblock_stripe returned %08x\n", Status);
|
||||
ERR("add_superblock_stripe returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // SINGLE, DUPLICATE, RAID1
|
||||
} else { // SINGLE, DUPLICATE, RAID1, RAID1C3, RAID1C4
|
||||
for (j = 0; j < ci->num_stripes; j++) {
|
||||
if (cis[j].offset + ci->size > superblock_addrs[i] && cis[j].offset <= superblock_addrs[i] + sizeof(superblock)) {
|
||||
off_start = ((superblock_addrs[i] - cis[j].offset) / c->chunk_item->stripe_length) * c->chunk_item->stripe_length;
|
||||
|
@ -434,7 +435,7 @@ static NTSTATUS get_superblock_size(chunk* c, uint64_t* size) {
|
|||
|
||||
Status = add_superblock_stripe(&stripes, off_start / ci->stripe_length, (off_end - off_start) / ci->stripe_length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_superblock_stripe returned %08x\n", Status);
|
||||
ERR("add_superblock_stripe returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +485,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -494,7 +495,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(FREE_SPACE_ITEM)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -511,7 +512,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
|
||||
Status = open_fcb(Vcb, Vcb->root_root, inode, BTRFS_TYPE_FILE, NULL, false, NULL, &c->cache, PagedPool, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb returned %08x\n", Status);
|
||||
ERR("open_fcb returned %08lx\n", Status);
|
||||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -548,7 +549,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
|
||||
Status = read_file(c->cache, data, 0, c->cache->inode_item.st_size, NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
|
||||
c->cache->deleted = true;
|
||||
|
@ -576,7 +577,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
num_valid_sectors = (ULONG)((sector_align(extent_length, Vcb->superblock.sector_size) / Vcb->superblock.sector_size) + num_bitmaps);
|
||||
|
||||
if (num_valid_sectors > num_sectors) {
|
||||
ERR("free space cache for %I64x was %I64x sectors, expected at least %I64x\n", c->offset, num_sectors, num_valid_sectors);
|
||||
ERR("free space cache for %I64x was %u sectors, expected at least %u\n", c->offset, num_sectors, num_valid_sectors);
|
||||
goto clearcache;
|
||||
}
|
||||
|
||||
|
@ -591,7 +592,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
crc32 = ~calc_crc32c(0xffffffff, &data[sizeof(uint32_t) * num_sectors], ((i + 1) * Vcb->superblock.sector_size) - (sizeof(uint32_t) * num_sectors));
|
||||
|
||||
if (crc32 != checksums[i]) {
|
||||
WARN("checksum %I64u was %08x, expected %08x\n", i, crc32, checksums[i]);
|
||||
WARN("checksum %u was %08x, expected %08x\n", i, crc32, checksums[i]);
|
||||
goto clearcache;
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +609,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
if (fse->type == FREE_SPACE_EXTENT) {
|
||||
Status = add_space_entry(&c->space, &c->space_size, fse->offset, fse->size);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_space_entry returned %08x\n", Status);
|
||||
ERR("add_space_entry returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -645,7 +646,7 @@ NTSTATUS load_stored_free_space_cache(device_extension* Vcb, chunk* c, bool load
|
|||
|
||||
Status = get_superblock_size(c, &superblock_size);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("get_superblock_size returned %08x\n", Status);
|
||||
ERR("get_superblock_size returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -691,13 +692,13 @@ clearcache:
|
|||
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = excise_extents(Vcb, c->cache, 0, c->cache->inode_item.st_size, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
do_rollback(Vcb, &rollback);
|
||||
return Status;
|
||||
}
|
||||
|
@ -744,7 +745,7 @@ static NTSTATUS load_stored_free_space_tree(device_extension* Vcb, chunk* c, PIR
|
|||
|
||||
Status = find_item(Vcb, Vcb->space_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -754,7 +755,7 @@ static NTSTATUS load_stored_free_space_tree(device_extension* Vcb, chunk* c, PIR
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(FREE_SPACE_INFO)) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_INFO));
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_INFO));
|
||||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -767,7 +768,7 @@ static NTSTATUS load_stored_free_space_tree(device_extension* Vcb, chunk* c, PIR
|
|||
if (tp.item->key.obj_type == TYPE_FREE_SPACE_EXTENT) {
|
||||
Status = add_space_entry(&c->space, &c->space_size, tp.item->key.obj_id, tp.item->key.offset);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_space_entry returned %08x\n", Status);
|
||||
ERR("add_space_entry returned %08lx\n", Status);
|
||||
if (bmparr) ExFreePool(bmparr);
|
||||
return Status;
|
||||
}
|
||||
|
@ -780,7 +781,7 @@ static NTSTATUS load_stored_free_space_tree(device_extension* Vcb, chunk* c, PIR
|
|||
explen = (ULONG)(tp.item->key.offset / (Vcb->superblock.sector_size * 8));
|
||||
|
||||
if (tp.item->size < explen) {
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, explen);
|
||||
WARN("(%I64x,%x,%I64x) was %u bytes, expected %lu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, explen);
|
||||
return STATUS_NOT_FOUND;
|
||||
} else if (tp.item->size == 0) {
|
||||
WARN("(%I64x,%x,%I64x) has size of 0\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset);
|
||||
|
@ -829,7 +830,7 @@ static NTSTATUS load_stored_free_space_tree(device_extension* Vcb, chunk* c, PIR
|
|||
if (runstart > lastoff) {
|
||||
Status = add_space_entry(&c->space, &c->space_size, lastoff, runstart - lastoff);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_space_entry returned %08x\n", Status);
|
||||
ERR("add_space_entry returned %08lx\n", Status);
|
||||
if (bmparr) ExFreePool(bmparr);
|
||||
return Status;
|
||||
}
|
||||
|
@ -843,7 +844,7 @@ static NTSTATUS load_stored_free_space_tree(device_extension* Vcb, chunk* c, PIR
|
|||
if (lastoff < tp.item->key.obj_id + tp.item->key.offset) {
|
||||
Status = add_space_entry(&c->space, &c->space_size, lastoff, tp.item->key.obj_id + tp.item->key.offset - lastoff);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_space_entry returned %08x\n", Status);
|
||||
ERR("add_space_entry returned %08lx\n", Status);
|
||||
if (bmparr) ExFreePool(bmparr);
|
||||
return Status;
|
||||
}
|
||||
|
@ -894,14 +895,14 @@ static NTSTATUS load_free_space_cache(device_extension* Vcb, chunk* c, PIRP Irp)
|
|||
Status = load_stored_free_space_tree(Vcb, c, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("load_stored_free_space_tree returned %08x\n", Status);
|
||||
ERR("load_stored_free_space_tree returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (Vcb->superblock.generation - 1 == Vcb->superblock.cache_generation) {
|
||||
Status = load_stored_free_space_cache(Vcb, c, false, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("load_stored_free_space_cache returned %08x\n", Status);
|
||||
ERR("load_stored_free_space_cache returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else
|
||||
|
@ -916,7 +917,7 @@ static NTSTATUS load_free_space_cache(device_extension* Vcb, chunk* c, PIRP Irp)
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -984,7 +985,7 @@ NTSTATUS load_cache_chunk(device_extension* Vcb, chunk* c, PIRP Irp) {
|
|||
|
||||
Status = load_free_space_cache(Vcb, c, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("load_free_space_cache returned %08x\n", Status);
|
||||
ERR("load_free_space_cache returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1024,7 @@ static NTSTATUS insert_cache_extent(fcb* fcb, uint64_t start, uint64_t length, L
|
|||
Status = alloc_chunk(fcb->Vcb, flags, &c, false);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("alloc_chunk returned %08x\n", Status);
|
||||
ERR("alloc_chunk returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1170,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
ExFreePool(fsi);
|
||||
reap_fcb(c->cache);
|
||||
c->cache = NULL;
|
||||
|
@ -1179,7 +1180,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
if (!keycmp(searchkey, tp.item->key)) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(fsi);
|
||||
reap_fcb(c->cache);
|
||||
c->cache = NULL;
|
||||
|
@ -1193,7 +1194,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->root_root, FREE_SPACE_CACHE_ID, 0, c->offset, fsi, sizeof(FREE_SPACE_ITEM), NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(fsi);
|
||||
reap_fcb(c->cache);
|
||||
c->cache = NULL;
|
||||
|
@ -1204,7 +1205,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = insert_cache_extent(c->cache, 0, new_cache_size, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_cache_extent returned %08x\n", Status);
|
||||
ERR("insert_cache_extent returned %08lx\n", Status);
|
||||
reap_fcb(c->cache);
|
||||
c->cache = NULL;
|
||||
return Status;
|
||||
|
@ -1215,7 +1216,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = flush_fcb(c->cache, true, batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("flush_fcb returned %08x\n", Status);
|
||||
ERR("flush_fcb returned %08lx\n", Status);
|
||||
free_fcb(c->cache);
|
||||
c->cache = NULL;
|
||||
return Status;
|
||||
|
@ -1236,7 +1237,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1246,7 +1247,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(FREE_SPACE_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1279,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = excise_extents(Vcb, c->cache, 0, c->cache->inode_item.st_size, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1287,7 +1288,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = insert_cache_extent(c->cache, 0, new_cache_size, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_cache_extent returned %08x\n", Status);
|
||||
ERR("insert_cache_extent returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1298,7 +1299,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = flush_fcb(c->cache, true, batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("flush_fcb returned %08x\n", Status);
|
||||
ERR("flush_fcb returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1315,7 +1316,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1333,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->root_root, c->cache->inode, TYPE_INODE_ITEM, 0, ii, sizeof(INODE_ITEM), NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(ii);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1340,7 +1341,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
*changed = true;
|
||||
} else {
|
||||
if (tp.item->size < sizeof(INODE_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(INODE_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(INODE_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1353,7 +1354,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1363,7 +1364,7 @@ static NTSTATUS allocate_cache_chunk(device_extension* Vcb, chunk* c, bool* chan
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(FREE_SPACE_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1401,7 @@ NTSTATUS allocate_cache(device_extension* Vcb, bool* changed, PIRP Irp, LIST_ENT
|
|||
*changed = true;
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("allocate_cache_chunk(%I64x) returned %08x\n", c->offset, Status);
|
||||
ERR("allocate_cache_chunk(%I64x) returned %08lx\n", c->offset, Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
clear_batch_list(Vcb, &batchlist);
|
||||
return Status;
|
||||
|
@ -1414,7 +1415,7 @@ NTSTATUS allocate_cache(device_extension* Vcb, bool* changed, PIRP Irp, LIST_ENT
|
|||
|
||||
Status = commit_batch_list(Vcb, &batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("commit_batch_list returned %08x\n", Status);
|
||||
ERR("commit_batch_list returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1720,7 @@ static NTSTATUS update_chunk_cache(device_extension* Vcb, chunk* c, BTRFS_TIME*
|
|||
|
||||
Status = flush_fcb(c->cache, true, batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("flush_fcb returned %08x\n", Status);
|
||||
ERR("flush_fcb returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1731,7 +1732,7 @@ static NTSTATUS update_chunk_cache(device_extension* Vcb, chunk* c, BTRFS_TIME*
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1742,7 +1743,7 @@ static NTSTATUS update_chunk_cache(device_extension* Vcb, chunk* c, BTRFS_TIME*
|
|||
}
|
||||
|
||||
if (tp.item->size < sizeof(FREE_SPACE_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(FREE_SPACE_ITEM));
|
||||
Status = STATUS_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1777,7 +1778,7 @@ static NTSTATUS update_chunk_cache(device_extension* Vcb, chunk* c, BTRFS_TIME*
|
|||
|
||||
Status = do_write_file(c->cache, 0, c->cache->inode_item.st_size, data, NULL, false, 0, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write_file returned %08x\n", Status);
|
||||
ERR("do_write_file returned %08lx\n", Status);
|
||||
|
||||
// Writing the cache isn't critical, so we don't return an error if writing fails. This means
|
||||
// we can still flush on a degraded mount if metadata is RAID1 but data is RAID0.
|
||||
|
@ -1816,7 +1817,7 @@ static NTSTATUS update_chunk_cache_tree(device_extension* Vcb, chunk* c, LIST_EN
|
|||
Status = insert_tree_item_batch(batchlist, Vcb, Vcb->space_root, s->address, TYPE_FREE_SPACE_EXTENT, s->size,
|
||||
NULL, 0, Batch_Insert);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item_batch returned %08x\n", Status);
|
||||
ERR("insert_tree_item_batch returned %08lx\n", Status);
|
||||
ExFreePool(fsi);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1827,7 +1828,7 @@ static NTSTATUS update_chunk_cache_tree(device_extension* Vcb, chunk* c, LIST_EN
|
|||
Status = insert_tree_item_batch(batchlist, Vcb, Vcb->space_root, c->offset, TYPE_FREE_SPACE_INFO, c->chunk_item->size,
|
||||
NULL, 0, Batch_DeleteFreeSpace);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item_batch returned %08x\n", Status);
|
||||
ERR("insert_tree_item_batch returned %08lx\n", Status);
|
||||
ExFreePool(fsi);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1835,7 +1836,7 @@ static NTSTATUS update_chunk_cache_tree(device_extension* Vcb, chunk* c, LIST_EN
|
|||
Status = insert_tree_item_batch(batchlist, Vcb, Vcb->space_root, c->offset, TYPE_FREE_SPACE_INFO, c->chunk_item->size,
|
||||
fsi, sizeof(FREE_SPACE_INFO), Batch_Insert);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item_batch returned %08x\n", Status);
|
||||
ERR("insert_tree_item_batch returned %08lx\n", Status);
|
||||
ExFreePool(fsi);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1865,7 +1866,7 @@ NTSTATUS update_chunk_caches(device_extension* Vcb, PIRP Irp, LIST_ENTRY* rollba
|
|||
release_chunk_lock(c, Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_chunk_cache(%I64x) returned %08x\n", c->offset, Status);
|
||||
ERR("update_chunk_cache(%I64x) returned %08lx\n", c->offset, Status);
|
||||
clear_batch_list(Vcb, &batchlist);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1876,7 +1877,7 @@ NTSTATUS update_chunk_caches(device_extension* Vcb, PIRP Irp, LIST_ENTRY* rollba
|
|||
|
||||
Status = commit_batch_list(Vcb, &batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("commit_batch_list returned %08x\n", Status);
|
||||
ERR("commit_batch_list returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1898,7 +1899,7 @@ NTSTATUS update_chunk_caches(device_extension* Vcb, PIRP Irp, LIST_ENTRY* rollba
|
|||
ExFreePool(ps);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("flush_partial_stripe returned %08x\n", Status);
|
||||
ERR("flush_partial_stripe returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&c->partial_stripes_lock);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1934,7 +1935,7 @@ NTSTATUS update_chunk_caches_tree(device_extension* Vcb, PIRP Irp) {
|
|||
release_chunk_lock(c, Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_chunk_cache_tree(%I64x) returned %08x\n", c->offset, Status);
|
||||
ERR("update_chunk_cache_tree(%I64x) returned %08lx\n", c->offset, Status);
|
||||
ExReleaseResourceLite(&Vcb->chunk_lock);
|
||||
clear_batch_list(Vcb, &batchlist);
|
||||
return Status;
|
||||
|
@ -1948,7 +1949,7 @@ NTSTATUS update_chunk_caches_tree(device_extension* Vcb, PIRP Irp) {
|
|||
|
||||
Status = commit_batch_list(Vcb, &batchlist, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("commit_batch_list returned %08x\n", Status);
|
||||
ERR("commit_batch_list returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ static NTSTATUS snapshot_tree_copy(device_extension* Vcb, uint64_t addr, root* s
|
|||
|
||||
Status = read_data(Vcb, addr, Vcb->superblock.node_size, NULL, true, buf, NULL, NULL, Irp, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ static NTSTATUS snapshot_tree_copy(device_extension* Vcb, uint64_t addr, root* s
|
|||
|
||||
Status = get_tree_new_address(Vcb, &t, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("get_tree_new_address returned %08x\n", Status);
|
||||
ERR("get_tree_new_address returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ static NTSTATUS snapshot_tree_copy(device_extension* Vcb, uint64_t addr, root* s
|
|||
th->address = t.new_address;
|
||||
th->tree_id = subvol->id;
|
||||
th->generation = Vcb->superblock.generation;
|
||||
th->fs_uuid = Vcb->superblock.uuid;
|
||||
th->fs_uuid = Vcb->superblock.metadata_uuid;
|
||||
|
||||
if (th->level == 0) {
|
||||
uint32_t i;
|
||||
|
@ -160,7 +160,7 @@ static NTSTATUS snapshot_tree_copy(device_extension* Vcb, uint64_t addr, root* s
|
|||
Status = increase_extent_refcount_data(Vcb, ed2->address, ed2->size, subvol->id, ln[i].key.obj_id, ln[i].key.offset - ed2->offset, 1, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("increase_extent_refcount_data returned %08x\n", Status);
|
||||
ERR("increase_extent_refcount_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -178,13 +178,13 @@ static NTSTATUS snapshot_tree_copy(device_extension* Vcb, uint64_t addr, root* s
|
|||
|
||||
Status = increase_extent_refcount(Vcb, in[i].address, Vcb->superblock.node_size, TYPE_TREE_BLOCK_REF, &tbr, NULL, th->level - 1, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("increase_extent_refcount returned %08x\n", Status);
|
||||
ERR("increase_extent_refcount returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*((uint32_t*)buf) = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
calc_tree_checksum(Vcb, th);
|
||||
|
||||
KeInitializeEvent(&wtc.Event, NotificationEvent, false);
|
||||
InitializeListHead(&wtc.stripes);
|
||||
|
@ -192,7 +192,7 @@ static NTSTATUS snapshot_tree_copy(device_extension* Vcb, uint64_t addr, root* s
|
|||
|
||||
Status = write_data(Vcb, t.new_address, buf, Vcb->superblock.node_size, &wtc, NULL, NULL, false, 0, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data returned %08x\n", Status);
|
||||
ERR("write_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
free_trees(Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
Status = create_root(Vcb, id, &r, true, Vcb->superblock.generation, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("create_root returned %08x\n", Status);
|
||||
ERR("create_root returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
Status = create_root(Vcb, BTRFS_ROOT_UUID, &uuid_root, false, 0, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("create_root returned %08x\n", Status);
|
||||
ERR("create_root returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->uuid_root, searchkey.obj_id, searchkey.obj_type, searchkey.offset, root_num, sizeof(uint64_t), NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(root_num);
|
||||
goto end;
|
||||
}
|
||||
|
@ -372,13 +372,13 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = snapshot_tree_copy(Vcb, subvol->root_item.block_number, r, &address, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("snapshot_tree_copy returned %08x\n", Status);
|
||||
ERR("snapshot_tree_copy returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
|
||||
Status = open_fcb(Vcb, r, r->root_item.objid, BTRFS_TYPE_DIRECTORY, utf8, false, fcb, &fr->fcb, PagedPool, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fcb returned %08x\n", Status);
|
||||
ERR("open_fcb returned %08lx\n", Status);
|
||||
free_fileref(fr);
|
||||
goto end;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
|
||||
Status = add_dir_child(fileref->fcb, r->id, true, utf8, name, BTRFS_TYPE_DIRECTORY, &dc);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("add_dir_child returned %08x\n", Status);
|
||||
WARN("add_dir_child returned %08lx\n", Status);
|
||||
|
||||
fr->dc = dc;
|
||||
dc->fileref = fr;
|
||||
|
@ -509,7 +509,7 @@ static NTSTATUS do_create_snapshot(device_extension* Vcb, PFILE_OBJECT parent, f
|
|||
free_trees(Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
|
||||
end:
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -607,7 +607,7 @@ static NTSTATUS create_snapshot(device_extension* Vcb, PFILE_OBJECT FileObject,
|
|||
|
||||
Status = utf16_to_utf8(NULL, 0, &len, nameus.Buffer, nameus.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 failed with error %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ static NTSTATUS create_snapshot(device_extension* Vcb, PFILE_OBJECT FileObject,
|
|||
|
||||
Status = utf16_to_utf8(utf8.Buffer, len, &len, nameus.Buffer, nameus.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 failed with error %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
|
||||
|
@ -649,13 +649,13 @@ static NTSTATUS create_snapshot(device_extension* Vcb, PFILE_OBJECT FileObject,
|
|||
} else
|
||||
free_fileref(fr2);
|
||||
} else if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_NOT_FOUND) {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
goto end3;
|
||||
}
|
||||
|
||||
Status = ObReferenceObjectByHandle(subvolh, 0, *IoFileObjectType, Irp->RequestorMode, (void**)&subvol_obj, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ObReferenceObjectByHandle returned %08x\n", Status);
|
||||
ERR("ObReferenceObjectByHandle returned %08lx\n", Status);
|
||||
goto end3;
|
||||
}
|
||||
|
||||
|
@ -724,7 +724,7 @@ static NTSTATUS create_snapshot(device_extension* Vcb, PFILE_OBJECT FileObject,
|
|||
Status = open_fileref(Vcb, &fr, &nameus, fileref, false, NULL, NULL, PagedPool, false, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
Status = STATUS_SUCCESS;
|
||||
} else {
|
||||
send_notification_fileref(fr, FILE_NOTIFY_CHANGE_DIR_NAME, FILE_ACTION_ADDED, NULL);
|
||||
|
@ -829,7 +829,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
|
||||
Status = utf16_to_utf8(NULL, 0, &len, nameus.Buffer, nameus.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 failed with error %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -853,7 +853,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
|
||||
Status = utf16_to_utf8(utf8.Buffer, len, &len, nameus.Buffer, nameus.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 failed with error %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
} else
|
||||
free_fileref(fr2);
|
||||
} else if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_NOT_FOUND) {
|
||||
ERR("open_fileref returned %08x\n", Status);
|
||||
ERR("open_fileref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -882,7 +882,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
Status = create_root(Vcb, id, &r, false, 0, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("create_root returned %08x\n", Status);
|
||||
ERR("create_root returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
Status = create_root(Vcb, BTRFS_ROOT_UUID, &uuid_root, false, 0, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("create_root returned %08x\n", Status);
|
||||
ERR("create_root returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -926,7 +926,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->uuid_root, searchkey.obj_id, searchkey.obj_type, searchkey.offset, root_num, sizeof(uint64_t), NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(root_num);
|
||||
goto end;
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
Status = SeAssignSecurity(fcb->sd, NULL, (void**)&rootfcb->sd, true, &subjcont, IoGetFileObjectGenericMapping(), PagedPool);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("SeAssignSecurity returned %08x\n", Status);
|
||||
ERR("SeAssignSecurity returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -992,7 +992,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
|
||||
Status = RtlGetOwnerSecurityDescriptor(rootfcb->sd, &owner, &defaulted);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlGetOwnerSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlGetOwnerSecurityDescriptor returned %08lx\n", Status);
|
||||
rootfcb->inode_item.st_uid = UID_NOBODY;
|
||||
rootfcb->sd_dirty = true;
|
||||
} else {
|
||||
|
@ -1041,7 +1041,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
|
||||
Status = insert_tree_item(Vcb, r, r->root_item.objid, TYPE_INODE_REF, r->root_item.objid, ir, irsize, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(ir);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1066,7 +1066,7 @@ static NTSTATUS create_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
|
||||
Status = add_dir_child(fileref->fcb, r->id, true, &utf8, &nameus, BTRFS_TYPE_DIRECTORY, &dc);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("add_dir_child returned %08x\n", Status);
|
||||
WARN("add_dir_child returned %08lx\n", Status);
|
||||
|
||||
fr->dc = dc;
|
||||
dc->fileref = fr;
|
||||
|
@ -1523,7 +1523,7 @@ static NTSTATUS get_usage(device_extension* Vcb, void* data, ULONG length, PIRP
|
|||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_chunk_usage returned %08x\n", Status);
|
||||
ERR("find_chunk_usage returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1841,7 +1841,7 @@ static NTSTATUS zero_data(device_extension* Vcb, fcb* fcb, uint64_t start, uint6
|
|||
Status = read_file(fcb, data + buf_head, start_data, end_data - start_data, NULL, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1855,7 +1855,7 @@ static NTSTATUS zero_data(device_extension* Vcb, fcb* fcb, uint64_t start, uint6
|
|||
|
||||
Status = excise_extents(Vcb, fcb, 0, sector_align(end_data, Vcb->superblock.sector_size), Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1871,7 +1871,7 @@ static NTSTATUS zero_data(device_extension* Vcb, fcb* fcb, uint64_t start, uint6
|
|||
|
||||
Status = add_extent_to_fcb(fcb, 0, ed, edsize, false, NULL, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_extent_to_fcb returned %08x\n", Status);
|
||||
ERR("add_extent_to_fcb returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
return Status;
|
||||
}
|
||||
|
@ -1885,7 +1885,7 @@ static NTSTATUS zero_data(device_extension* Vcb, fcb* fcb, uint64_t start, uint6
|
|||
ExFreePool(data);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_compressed returned %08x\n", Status);
|
||||
ERR("write_compressed returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
|
@ -1894,7 +1894,7 @@ static NTSTATUS zero_data(device_extension* Vcb, fcb* fcb, uint64_t start, uint6
|
|||
ExFreePool(data);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write_file returned %08x\n", Status);
|
||||
ERR("do_write_file returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -1999,7 +1999,7 @@ static NTSTATUS set_zero_data(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
if (ext->extent_data.type == EXTENT_TYPE_INLINE) {
|
||||
Status = zero_data(Vcb, fcb, fzdi->FileOffset.QuadPart, fzdi->BeyondFinalZero.QuadPart - fzdi->FileOffset.QuadPart, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("zero_data returned %08x\n", Status);
|
||||
ERR("zero_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
|
@ -2013,14 +2013,14 @@ static NTSTATUS set_zero_data(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
if (end <= start) {
|
||||
Status = zero_data(Vcb, fcb, fzdi->FileOffset.QuadPart, fzdi->BeyondFinalZero.QuadPart - fzdi->FileOffset.QuadPart, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("zero_data returned %08x\n", Status);
|
||||
ERR("zero_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (start > (uint64_t)fzdi->FileOffset.QuadPart) {
|
||||
Status = zero_data(Vcb, fcb, fzdi->FileOffset.QuadPart, start - fzdi->FileOffset.QuadPart, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("zero_data returned %08x\n", Status);
|
||||
ERR("zero_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2028,7 +2028,7 @@ static NTSTATUS set_zero_data(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
if (end < (uint64_t)fzdi->BeyondFinalZero.QuadPart) {
|
||||
Status = zero_data(Vcb, fcb, end, fzdi->BeyondFinalZero.QuadPart - end, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("zero_data returned %08x\n", Status);
|
||||
ERR("zero_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2036,7 +2036,7 @@ static NTSTATUS set_zero_data(device_extension* Vcb, PFILE_OBJECT FileObject, vo
|
|||
if (end > start) {
|
||||
Status = excise_extents(Vcb, fcb, start, end, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2182,7 +2182,7 @@ end:
|
|||
static NTSTATUS get_object_id(device_extension* Vcb, PFILE_OBJECT FileObject, FILE_OBJECTID_BUFFER* buf, ULONG buflen, ULONG_PTR* retlen) {
|
||||
fcb* fcb;
|
||||
|
||||
TRACE("(%p, %p, %p, %x, %p)\n", Vcb, FileObject, buf, buflen, retlen);
|
||||
TRACE("(%p, %p, %p, %lx, %p)\n", Vcb, FileObject, buf, buflen, retlen);
|
||||
|
||||
if (!FileObject) {
|
||||
ERR("FileObject was NULL\n");
|
||||
|
@ -2285,7 +2285,7 @@ static NTSTATUS lock_volume(device_extension* Vcb, PIRP Irp) {
|
|||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2382,7 +2382,7 @@ static NTSTATUS invalidate_volumes(PIRP Irp) {
|
|||
Status = ObReferenceObjectByHandle(h, 0, *IoFileObjectType, Irp->RequestorMode, (void**)&fileobj, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ObReferenceObjectByHandle returned %08x\n", Status);
|
||||
ERR("ObReferenceObjectByHandle returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2410,6 +2410,8 @@ static NTSTATUS invalidate_volumes(PIRP Irp) {
|
|||
|
||||
RtlZeroMemory(newvpb, sizeof(VPB));
|
||||
|
||||
ObReferenceObject(devobj);
|
||||
|
||||
ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
|
||||
|
||||
Vcb->removing = true;
|
||||
|
@ -2430,9 +2432,10 @@ static NTSTATUS invalidate_volumes(PIRP Irp) {
|
|||
free_trees(Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
ExFreePool(newvpb);
|
||||
ObDereferenceObject(devobj);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2459,6 +2462,8 @@ static NTSTATUS invalidate_volumes(PIRP Irp) {
|
|||
|
||||
if (Vcb->open_files == 0)
|
||||
uninit(Vcb);
|
||||
|
||||
ObDereferenceObject(devobj);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -2587,7 +2592,7 @@ NTSTATUS dismount_volume(device_extension* Vcb, bool shutdown, PIRP Irp) {
|
|||
|
||||
Status = FsRtlNotifyVolumeEvent(Vcb->root_file, FSRTL_VOLUME_DISMOUNT);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("FsRtlNotifyVolumeEvent returned %08x\n", Status);
|
||||
WARN("FsRtlNotifyVolumeEvent returned %08lx\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2600,7 +2605,7 @@ NTSTATUS dismount_volume(device_extension* Vcb, bool shutdown, PIRP Irp) {
|
|||
Status = do_write(Vcb, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2627,7 +2632,6 @@ static NTSTATUS is_device_part_of_mounted_btrfs_raid(PDEVICE_OBJECT devobj, PFIL
|
|||
NTSTATUS Status;
|
||||
ULONG to_read;
|
||||
superblock* sb;
|
||||
uint32_t crc32;
|
||||
BTRFS_UUID fsuuid, devuuid;
|
||||
LIST_ENTRY* le;
|
||||
|
||||
|
@ -2641,7 +2645,7 @@ static NTSTATUS is_device_part_of_mounted_btrfs_raid(PDEVICE_OBJECT devobj, PFIL
|
|||
|
||||
Status = sync_read_phys(devobj, fileobj, superblock_addrs[0], to_read, (uint8_t*)sb, true);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("sync_read_phys returned %08x\n", Status);
|
||||
ERR("sync_read_phys returned %08lx\n", Status);
|
||||
ExFreePool(sb);
|
||||
return Status;
|
||||
}
|
||||
|
@ -2652,9 +2656,7 @@ static NTSTATUS is_device_part_of_mounted_btrfs_raid(PDEVICE_OBJECT devobj, PFIL
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&sb->uuid, (ULONG)sizeof(superblock) - sizeof(sb->checksum));
|
||||
|
||||
if (crc32 != *((uint32_t*)sb->checksum)) {
|
||||
if (!check_superblock_checksum(sb)) {
|
||||
TRACE("device has Btrfs magic, but invalid superblock checksum\n");
|
||||
ExFreePool(sb);
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -2721,7 +2723,7 @@ void trim_whole_device(device* dev) {
|
|||
|
||||
Status = dev_ioctl(dev->devobj, IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES, &dmdsa, sizeof(DEVICE_MANAGE_DATA_SET_ATTRIBUTES), NULL, 0, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES returned %08x\n", Status);
|
||||
WARN("IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE processor_mode) {
|
||||
|
@ -2779,7 +2781,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
Status = ObReferenceObjectByHandle(h, 0, *IoFileObjectType, Irp->RequestorMode, (void**)&fileobj, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ObReferenceObjectByHandle returned %08x\n", Status);
|
||||
ERR("ObReferenceObjectByHandle returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2787,7 +2789,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = get_device_pnp_name(DeviceObject, &pnp_name, &pnp_guid);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("get_device_pnp_name returned %08x\n", Status);
|
||||
ERR("get_device_pnp_name returned %08lx\n", Status);
|
||||
ObDereferenceObject(fileobj);
|
||||
return Status;
|
||||
}
|
||||
|
@ -2798,14 +2800,14 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = dev_ioctl(DeviceObject, IOCTL_DISK_IS_WRITABLE, NULL, 0, NULL, 0, true, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_DISK_IS_WRITABLE returned %08x\n", Status);
|
||||
ERR("IOCTL_DISK_IS_WRITABLE returned %08lx\n", Status);
|
||||
ObDereferenceObject(fileobj);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = is_device_part_of_mounted_btrfs_raid(DeviceObject, fileobj);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("is_device_part_of_mounted_btrfs_raid returned %08x\n", Status);
|
||||
ERR("is_device_part_of_mounted_btrfs_raid returned %08lx\n", Status);
|
||||
ObDereferenceObject(fileobj);
|
||||
return Status;
|
||||
}
|
||||
|
@ -2859,7 +2861,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
Status = dev_ioctl(DeviceObject, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0,
|
||||
&gli, sizeof(gli), true, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error reading length information: %08x\n", Status);
|
||||
ERR("error reading length information: %08lx\n", Status);
|
||||
ObDereferenceObject(fileobj);
|
||||
return Status;
|
||||
}
|
||||
|
@ -2884,7 +2886,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
free_trees(Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2907,7 +2909,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
if (size > 0x100000) { // add disk hole - the first MB is marked as used
|
||||
Status = add_space_entry(&dev->space, NULL, 0x100000, size - 0x100000);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_space_entry returned %08x\n", Status);
|
||||
ERR("add_space_entry returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -2951,7 +2953,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->chunk_root, 1, TYPE_DEV_ITEM, di->dev_id, di, sizeof(DEV_ITEM), NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(di);
|
||||
goto end;
|
||||
}
|
||||
|
@ -2972,7 +2974,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = find_item(Vcb, Vcb->dev_root, &tp, &searchkey, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
ExFreePool(stats);
|
||||
goto end;
|
||||
}
|
||||
|
@ -2980,7 +2982,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
if (!keycmp(tp.item->key, searchkey)) {
|
||||
Status = delete_tree_item(Vcb, &tp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("delete_tree_item returned %08x\n", Status);
|
||||
ERR("delete_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(stats);
|
||||
goto end;
|
||||
}
|
||||
|
@ -2988,7 +2990,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = insert_tree_item(Vcb, Vcb->dev_root, 0, TYPE_DEV_STATS, di->dev_id, stats, sizeof(uint64_t) * 5, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("insert_tree_item returned %08x\n", Status);
|
||||
ERR("insert_tree_item returned %08lx\n", Status);
|
||||
ExFreePool(stats);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3008,7 +3010,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = write_data_phys(DeviceObject, fileobj, 0, mb, 0x100000);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_phys returned %08x\n", Status);
|
||||
ERR("write_data_phys returned %08lx\n", Status);
|
||||
ExFreePool(mb);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3031,11 +3033,12 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
vc->devobj = DeviceObject;
|
||||
vc->fileobj = fileobj;
|
||||
vc->notification_entry = NULL;
|
||||
vc->boot_volume = false;
|
||||
|
||||
Status = IoRegisterPlugPlayNotification(EventCategoryTargetDeviceChange, 0, fileobj,
|
||||
drvobj, pnp_removal, vde->pdode, &vc->notification_entry);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoRegisterPlugPlayNotification returned %08x\n", Status);
|
||||
WARN("IoRegisterPlugPlayNotification returned %08lx\n", Status);
|
||||
|
||||
pnp_name2 = pnp_name;
|
||||
|
||||
|
@ -3076,11 +3079,11 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
|
||||
Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &mountmgrfo, &mountmgr);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
else {
|
||||
Status = remove_drive_letter(mountmgr, &pnp_name);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND)
|
||||
WARN("remove_drive_letter returned %08x\n", Status);
|
||||
WARN("remove_drive_letter returned %08lx\n", Status);
|
||||
|
||||
vc->had_drive_letter = NT_SUCCESS(Status);
|
||||
|
||||
|
@ -3098,7 +3101,7 @@ static NTSTATUS add_device(device_extension* Vcb, PIRP Irp, KPROCESSOR_MODE proc
|
|||
|
||||
Status = do_write(Vcb, Irp);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
|
||||
ObReferenceObject(fileobj);
|
||||
|
||||
|
@ -3287,7 +3290,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
|
||||
Status = ObReferenceObjectByHandle(ded->FileHandle, 0, *IoFileObjectType, Irp->RequestorMode, (void**)&sourcefo, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ObReferenceObjectByHandle returned %08x\n", Status);
|
||||
ERR("ObReferenceObjectByHandle returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -3400,7 +3403,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
Status = read_file(fcb, data2, ded->TargetFileOffset.QuadPart - dataoff, dataoff, NULL, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
ExFreePool(data2);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3409,14 +3412,14 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
if (sourcefcb->ads) {
|
||||
Status = read_stream(sourcefcb, data2 + dataoff, ded->SourceFileOffset.QuadPart, (ULONG)ded->ByteCount.QuadPart, &bytes_read);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_stream returned %08x\n", Status);
|
||||
ERR("read_stream returned %08lx\n", Status);
|
||||
ExFreePool(data2);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
Status = read_file(sourcefcb, data2 + dataoff, ded->SourceFileOffset.QuadPart, ded->ByteCount.QuadPart, &bytes_read, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
ExFreePool(data2);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3433,7 +3436,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
|
||||
Status = excise_extents(Vcb, fcb, 0, sector_align(fcb->inode_item.st_size, Vcb->superblock.sector_size), Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
ExFreePool(data2);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3459,7 +3462,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
|
||||
Status = add_extent_to_fcb(fcb, 0, ed, edsize, false, NULL, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("add_extent_to_fcb returned %08x\n", Status);
|
||||
ERR("add_extent_to_fcb returned %08lx\n", Status);
|
||||
ExFreePool(data2);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3470,7 +3473,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
|
||||
Status = do_write_file(fcb, start, start + datalen2, data2, Irp, false, 0, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write_file returned %08x\n", Status);
|
||||
ERR("do_write_file returned %08lx\n", Status);
|
||||
ExFreePool(data2);
|
||||
goto end;
|
||||
}
|
||||
|
@ -3540,7 +3543,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
|
||||
if (ext->csum) {
|
||||
if (ext->extent_data.compression == BTRFS_COMPRESSION_NONE) {
|
||||
ext2->csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(ed2d->num_bytes * sizeof(uint32_t) / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
ext2->csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(ed2d->num_bytes * Vcb->csum_size / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
if (!ext2->csum) {
|
||||
ERR("out of memory\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -3548,10 +3551,10 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
goto end;
|
||||
}
|
||||
|
||||
RtlCopyMemory(ext2->csum, &ext->csum[(ed2d->offset - ed2s->offset) / Vcb->superblock.sector_size],
|
||||
(ULONG)(ed2d->num_bytes * sizeof(uint32_t) / Vcb->superblock.sector_size));
|
||||
RtlCopyMemory(ext2->csum, (uint8_t*)ext->csum + ((ed2d->offset - ed2s->offset) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
(ULONG)(ed2d->num_bytes * Vcb->csum_size / Vcb->superblock.sector_size));
|
||||
} else {
|
||||
ext2->csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(ed2d->size * sizeof(uint32_t) / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
ext2->csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(ed2d->size * Vcb->csum_size / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
if (!ext2->csum) {
|
||||
ERR("out of memory\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -3559,7 +3562,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
goto end;
|
||||
}
|
||||
|
||||
RtlCopyMemory(ext2->csum, ext->csum, (ULONG)(ed2s->size * sizeof(uint32_t) / Vcb->superblock.sector_size));
|
||||
RtlCopyMemory(ext2->csum, ext->csum, (ULONG)(ed2s->size * Vcb->csum_size / Vcb->superblock.sector_size));
|
||||
}
|
||||
} else
|
||||
ext2->csum = NULL;
|
||||
|
@ -3576,7 +3579,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
Status = update_changed_extent_ref(Vcb, c, ed2s->address, ed2s->size, fcb->subvol->id, fcb->inode, ext2->offset - ed2d->offset,
|
||||
1, fcb->inode_item.flags & BTRFS_INODE_NODATASUM, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_changed_extent_ref returned %08x\n", Status);
|
||||
ERR("update_changed_extent_ref returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3589,7 +3592,7 @@ static NTSTATUS duplicate_extents(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
|
||||
Status = excise_extents(Vcb, fcb, ded->TargetFileOffset.QuadPart, ded->TargetFileOffset.QuadPart + ded->ByteCount.QuadPart, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("excise_extents returned %08x\n", Status);
|
||||
ERR("excise_extents returned %08lx\n", Status);
|
||||
|
||||
while (!IsListEmpty(&newexts)) {
|
||||
extent* ext = CONTAINING_RECORD(RemoveHeadList(&newexts), extent, list_entry);
|
||||
|
@ -3708,7 +3711,7 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
PSID owner;
|
||||
BOOLEAN defaulted;
|
||||
|
||||
TRACE("(%p, %p, %p, %u)\n", Vcb, FileObject, data, datalen);
|
||||
TRACE("(%p, %p, %p, %lu)\n", Vcb, FileObject, data, datalen);
|
||||
|
||||
if (!FileObject || !FileObject->FsContext || !FileObject->FsContext2 || FileObject->FsContext == Vcb->volume_fcb)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -3765,7 +3768,7 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
|
||||
Status = utf16_to_utf8(NULL, 0, &len, bmn->name, bmn->namelen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 return %08x\n", Status);
|
||||
ERR("utf16_to_utf8 returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -3775,7 +3778,7 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
}
|
||||
|
||||
if (len > 0xffff) {
|
||||
ERR("len was too long (%x)\n", len);
|
||||
ERR("len was too long (%lx)\n", len);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -3789,7 +3792,7 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
|
||||
Status = utf16_to_utf8(utf8.Buffer, len, &len, bmn->name, bmn->namelen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 failed with error %08lx\n", Status);
|
||||
ExFreePool(utf8.Buffer);
|
||||
return Status;
|
||||
}
|
||||
|
@ -3799,7 +3802,7 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
|
||||
Status = find_file_in_dir(&name, parfcb, &subvol, &inode, &dc, true);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_NOT_FOUND) {
|
||||
ERR("find_file_in_dir returned %08x\n", Status);
|
||||
ERR("find_file_in_dir returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3901,14 +3904,14 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
SEF_SACL_AUTO_INHERIT, &subjcont, IoGetFileObjectGenericMapping(), PagedPool);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("SeAssignSecurityEx returned %08x\n", Status);
|
||||
ERR("SeAssignSecurityEx returned %08lx\n", Status);
|
||||
reap_fcb(fcb);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = RtlGetOwnerSecurityDescriptor(fcb->sd, &owner, &defaulted);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("RtlGetOwnerSecurityDescriptor returned %08x\n", Status);
|
||||
WARN("RtlGetOwnerSecurityDescriptor returned %08lx\n", Status);
|
||||
fcb->sd_dirty = true;
|
||||
} else {
|
||||
fcb->inode_item.st_uid = sid_to_uid(owner);
|
||||
|
@ -3982,7 +3985,7 @@ static NTSTATUS mknod(device_extension* Vcb, PFILE_OBJECT FileObject, void* data
|
|||
|
||||
Status = add_dir_child(fileref->parent->fcb, fcb->inode, false, &utf8, &name, fcb->type, &dc);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("add_dir_child returned %08x\n", Status);
|
||||
WARN("add_dir_child returned %08lx\n", Status);
|
||||
|
||||
fileref->dc = dc;
|
||||
dc->fileref = fileref;
|
||||
|
@ -4080,7 +4083,7 @@ static NTSTATUS recvd_subvol(device_extension* Vcb, PFILE_OBJECT FileObject, voi
|
|||
LARGE_INTEGER time;
|
||||
BTRFS_TIME now;
|
||||
|
||||
TRACE("(%p, %p, %p, %u)\n", Vcb, FileObject, data, datalen);
|
||||
TRACE("(%p, %p, %p, %lu)\n", Vcb, FileObject, data, datalen);
|
||||
|
||||
if (!data || datalen < sizeof(btrfs_received_subvol))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -4198,7 +4201,7 @@ static NTSTATUS fsctl_set_xattr(device_extension* Vcb, PFILE_OBJECT FileObject,
|
|||
|
||||
static const char stream_pref[] = "user.";
|
||||
|
||||
TRACE("(%p, %p, %p, %u)\n", Vcb, FileObject, data, datalen);
|
||||
TRACE("(%p, %p, %p, %lu)\n", Vcb, FileObject, data, datalen);
|
||||
|
||||
if (!data || datalen < sizeof(btrfs_set_xattr))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -4346,7 +4349,7 @@ static NTSTATUS fsctl_set_xattr(device_extension* Vcb, PFILE_OBJECT FileObject,
|
|||
Status = IoCheckEaBufferValidity((FILE_FULL_EA_INFORMATION*)(bsxa->data + bsxa->namelen), bsxa->valuelen, &offset);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoCheckEaBufferValidity returned %08x (error at offset %u)\n", Status, offset);
|
||||
WARN("IoCheckEaBufferValidity returned %08lx (error at offset %lu)\n", Status, offset);
|
||||
else {
|
||||
FILE_FULL_EA_INFORMATION* eainfo;
|
||||
|
||||
|
@ -4517,7 +4520,7 @@ static NTSTATUS get_subvol_path(device_extension* Vcb, uint64_t id, WCHAR* out,
|
|||
Status = open_fileref_by_inode(Vcb, r, r->root_item.objid, &fr, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ExReleaseResourceLite(&Vcb->fileref_lock);
|
||||
ERR("open_fileref_by_inode returned %08x\n", Status);
|
||||
ERR("open_fileref_by_inode returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -4530,7 +4533,7 @@ static NTSTATUS get_subvol_path(device_extension* Vcb, uint64_t id, WCHAR* out,
|
|||
if (NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW)
|
||||
out[us.Length / sizeof(WCHAR)] = 0;
|
||||
else
|
||||
ERR("fileref_get_filename returned %08x\n", Status);
|
||||
ERR("fileref_get_filename returned %08lx\n", Status);
|
||||
|
||||
free_fileref(fr);
|
||||
|
||||
|
@ -4571,7 +4574,7 @@ static NTSTATUS find_subvol(device_extension* Vcb, void* in, ULONG inlen, void*
|
|||
Status = find_item(Vcb, Vcb->uuid_root, &tp, &searchkey, false, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4588,7 +4591,7 @@ static NTSTATUS find_subvol(device_extension* Vcb, void* in, ULONG inlen, void*
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp2, &searchkey2, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4614,7 +4617,7 @@ static NTSTATUS find_subvol(device_extension* Vcb, void* in, ULONG inlen, void*
|
|||
Status = find_item(Vcb, Vcb->uuid_root, &tp, &searchkey, false, Irp);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4633,7 +4636,7 @@ static NTSTATUS find_subvol(device_extension* Vcb, void* in, ULONG inlen, void*
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp2, &searchkey2, false, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4669,7 +4672,7 @@ static NTSTATUS resize_device(device_extension* Vcb, void* data, ULONG len, PIRP
|
|||
LIST_ENTRY* le;
|
||||
device* dev = NULL;
|
||||
|
||||
TRACE("(%p, %p, %u)\n", Vcb, data, len);
|
||||
TRACE("(%p, %p, %lu)\n", Vcb, data, len);
|
||||
|
||||
if (!data || len < sizeof(btrfs_resize) || (br->size % Vcb->superblock.sector_size) != 0)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -4766,7 +4769,7 @@ static NTSTATUS resize_device(device_extension* Vcb, void* data, ULONG len, PIRP
|
|||
|
||||
Status = PsCreateSystemThread(&Vcb->balance.thread, 0, &oa, NULL, NULL, balance_thread, Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("PsCreateSystemThread returned %08x\n", Status);
|
||||
ERR("PsCreateSystemThread returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4780,7 +4783,7 @@ static NTSTATUS resize_device(device_extension* Vcb, void* data, ULONG len, PIRP
|
|||
|
||||
Status = update_dev_item(Vcb, dev, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_dev_item returned %08x\n", Status);
|
||||
ERR("update_dev_item returned %08lx\n", Status);
|
||||
dev->devitem.num_bytes = old_size;
|
||||
goto end;
|
||||
}
|
||||
|
@ -4795,7 +4798,7 @@ static NTSTATUS resize_device(device_extension* Vcb, void* data, ULONG len, PIRP
|
|||
Status = dev_ioctl(dev->devobj, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0,
|
||||
&gli, sizeof(gli), true, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_DISK_GET_LENGTH_INFO returned %08x\n", Status);
|
||||
ERR("IOCTL_DISK_GET_LENGTH_INFO returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -4826,7 +4829,7 @@ static NTSTATUS resize_device(device_extension* Vcb, void* data, ULONG len, PIRP
|
|||
|
||||
Status = update_dev_item(Vcb, dev, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("update_dev_item returned %08x\n", Status);
|
||||
ERR("update_dev_item returned %08lx\n", Status);
|
||||
dev->devitem.num_bytes = old_size;
|
||||
goto end;
|
||||
}
|
||||
|
@ -5556,7 +5559,7 @@ NTSTATUS fsctl_request(PDEVICE_OBJECT DeviceObject, PIRP* Pirp, uint32_t type) {
|
|||
break;
|
||||
|
||||
default:
|
||||
WARN("unknown control code %x (DeviceType = %x, Access = %x, Function = %x, Method = %x)\n",
|
||||
WARN("unknown control code %lx (DeviceType = %lx, Access = %lx, Function = %lx, Method = %lx)\n",
|
||||
IrpSp->Parameters.FileSystemControl.FsControlCode, (IrpSp->Parameters.FileSystemControl.FsControlCode & 0xff0000) >> 16,
|
||||
(IrpSp->Parameters.FileSystemControl.FsControlCode & 0xc000) >> 14, (IrpSp->Parameters.FileSystemControl.FsControlCode & 0x3ffc) >> 2,
|
||||
IrpSp->Parameters.FileSystemControl.FsControlCode & 0x3);
|
||||
|
|
|
@ -94,7 +94,7 @@ uint8_t gdiv(uint8_t a, uint8_t b) {
|
|||
// "The mathematics of RAID-6", by H. Peter Anvin.
|
||||
// https://www.kernel.org/pub/linux/kernel/people/hpa/raid6.pdf
|
||||
|
||||
#ifdef _AMD64_
|
||||
#if defined(_AMD64_) || defined(_ARM64_)
|
||||
__inline static uint64_t galois_double_mask64(uint64_t v) {
|
||||
v &= 0x8080808080808080;
|
||||
return (v << 1) - (v >> 7);
|
||||
|
@ -109,7 +109,7 @@ __inline static uint32_t galois_double_mask32(uint32_t v) {
|
|||
void galois_double(uint8_t* data, uint32_t len) {
|
||||
// FIXME - SIMD?
|
||||
|
||||
#ifdef _AMD64_
|
||||
#if defined(_AMD64_) || defined(_ARM64_)
|
||||
while (len > sizeof(uint64_t)) {
|
||||
uint64_t v = *((uint64_t*)data), vv;
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ static NTSTATUS pnp_cancel_remove_device(PDEVICE_OBJECT DeviceObject) {
|
|||
|
||||
Status = send_disks_pnp_message(Vcb, IRP_MN_CANCEL_REMOVE_DEVICE);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("send_disks_pnp_message returned %08x\n", Status);
|
||||
WARN("send_disks_pnp_message returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ NTSTATUS pnp_query_remove_device(PDEVICE_OBJECT DeviceObject, PIRP Irp) {
|
|||
|
||||
Status = send_disks_pnp_message(Vcb, IRP_MN_QUERY_REMOVE_DEVICE);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("send_disks_pnp_message returned %08x\n", Status);
|
||||
WARN("send_disks_pnp_message returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
return Status;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ NTSTATUS pnp_query_remove_device(PDEVICE_OBJECT DeviceObject, PIRP Irp) {
|
|||
free_trees(Vcb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
return Status;
|
||||
}
|
||||
|
@ -227,14 +227,14 @@ static NTSTATUS pnp_remove_device(PDEVICE_OBJECT DeviceObject) {
|
|||
Status = send_disks_pnp_message(Vcb, IRP_MN_REMOVE_DEVICE);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("send_disks_pnp_message returned %08x\n", Status);
|
||||
WARN("send_disks_pnp_message returned %08lx\n", Status);
|
||||
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
|
||||
if (DeviceObject->Vpb->Flags & VPB_MOUNTED) {
|
||||
Status = FsRtlNotifyVolumeEvent(Vcb->root_file, FSRTL_VOLUME_DISMOUNT);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("FsRtlNotifyVolumeEvent returned %08x\n", Status);
|
||||
WARN("FsRtlNotifyVolumeEvent returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (Vcb->vde)
|
||||
|
@ -532,7 +532,7 @@ static NTSTATUS pdo_device_usage_notification(pdo_device_extension* pdode, PIRP
|
|||
KeWaitForSingleObject(&context.Event, Executive, KernelMode, false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(context.Status)) {
|
||||
ERR("IoCallDriver returned %08x\n", context.Status);
|
||||
ERR("IoCallDriver returned %08lx\n", context.Status);
|
||||
ExReleaseResourceLite(&pdode->child_lock);
|
||||
return context.Status;
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ end:
|
|||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
exit:
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -101,7 +101,7 @@ NTSTATUS registry_load_volume_options(device_extension* Vcb) {
|
|||
Status = STATUS_SUCCESS;
|
||||
goto end;
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwOpenKey returned %08x\n", Status);
|
||||
ERR("ZwOpenKey returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ NTSTATUS registry_load_volume_options(device_extension* Vcb) {
|
|||
options->no_root_dir = *val;
|
||||
}
|
||||
} else if (Status != STATUS_NO_MORE_ENTRIES) {
|
||||
ERR("ZwEnumerateValueKey returned %08x\n", Status);
|
||||
ERR("ZwEnumerateValueKey returned %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
} while (NT_SUCCESS(Status));
|
||||
|
@ -270,7 +270,7 @@ NTSTATUS registry_mark_volume_mounted(BTRFS_UUID* uuid) {
|
|||
|
||||
Status = ZwCreateKey(&h, KEY_SET_VALUE, &oa, 0, NULL, REG_OPTION_NON_VOLATILE, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwCreateKey returned %08x\n", Status);
|
||||
ERR("ZwCreateKey returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ NTSTATUS registry_mark_volume_mounted(BTRFS_UUID* uuid) {
|
|||
|
||||
Status = ZwSetValueKey(h, &mountedus, 0, REG_DWORD, &data, sizeof(DWORD));
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwSetValueKey returned %08x\n", Status);
|
||||
ERR("ZwSetValueKey returned %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ static NTSTATUS registry_mark_volume_unmounted_path(PUNICODE_STRING path) {
|
|||
|
||||
Status = ZwOpenKey(&h, KEY_QUERY_VALUE | KEY_SET_VALUE | DELETE, &oa);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwOpenKey returned %08x\n", Status);
|
||||
ERR("ZwOpenKey returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ static NTSTATUS registry_mark_volume_unmounted_path(PUNICODE_STRING path) {
|
|||
break;
|
||||
}
|
||||
} else if (Status != STATUS_NO_MORE_ENTRIES) {
|
||||
ERR("ZwEnumerateValueKey returned %08x\n", Status);
|
||||
ERR("ZwEnumerateValueKey returned %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
} while (NT_SUCCESS(Status));
|
||||
|
@ -353,13 +353,13 @@ static NTSTATUS registry_mark_volume_unmounted_path(PUNICODE_STRING path) {
|
|||
|
||||
Status = ZwSetValueKey(h, &mountedus, 0, REG_DWORD, &data, sizeof(DWORD));
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwSetValueKey returned %08x\n", Status);
|
||||
ERR("ZwSetValueKey returned %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
} else {
|
||||
Status = ZwDeleteKey(h);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwDeleteKey returned %08x\n", Status);
|
||||
ERR("ZwDeleteKey returned %08lx\n", Status);
|
||||
goto end2;
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ NTSTATUS registry_mark_volume_unmounted(BTRFS_UUID* uuid) {
|
|||
|
||||
Status = registry_mark_volume_unmounted_path(&path);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("registry_mark_volume_unmounted_path returned %08x\n", Status);
|
||||
ERR("registry_mark_volume_unmounted_path returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ static void reset_subkeys(HANDLE h, PUNICODE_STRING reg_path) {
|
|||
if (NT_SUCCESS(Status)) {
|
||||
key_name* kn;
|
||||
|
||||
TRACE("key: %.*S\n", kbi->NameLength / sizeof(WCHAR), kbi->Name);
|
||||
TRACE("key: %.*S\n", (int)(kbi->NameLength / sizeof(WCHAR)), kbi->Name);
|
||||
|
||||
if (is_uuid(kbi->NameLength, kbi->Name)) {
|
||||
kn = ExAllocatePoolWithTag(PagedPool, sizeof(key_name), ALLOC_TAG);
|
||||
|
@ -489,7 +489,7 @@ static void reset_subkeys(HANDLE h, PUNICODE_STRING reg_path) {
|
|||
InsertTailList(&key_names, &kn->list_entry);
|
||||
}
|
||||
} else if (Status != STATUS_NO_MORE_ENTRIES)
|
||||
ERR("ZwEnumerateKey returned %08x\n", Status);
|
||||
ERR("ZwEnumerateKey returned %08lx\n", Status);
|
||||
} while (NT_SUCCESS(Status));
|
||||
|
||||
le = key_names.Flink;
|
||||
|
@ -511,7 +511,7 @@ static void reset_subkeys(HANDLE h, PUNICODE_STRING reg_path) {
|
|||
|
||||
Status = registry_mark_volume_unmounted_path(&path);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("registry_mark_volume_unmounted_path returned %08x\n", Status);
|
||||
WARN("registry_mark_volume_unmounted_path returned %08lx\n", Status);
|
||||
|
||||
ExFreePool(path.Buffer);
|
||||
|
||||
|
@ -568,7 +568,7 @@ static void read_mappings(PUNICODE_STRING regpath) {
|
|||
Status = ZwCreateKey(&h, KEY_QUERY_VALUE, &oa, 0, NULL, REG_OPTION_NON_VOLATILE, &dispos);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwCreateKey returned %08x\n", Status);
|
||||
ERR("ZwCreateKey returned %08lx\n", Status);
|
||||
ExFreePool(path);
|
||||
return;
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ static void read_mappings(PUNICODE_STRING regpath) {
|
|||
|
||||
RtlCopyMemory(&val, (uint8_t*)kvfi + kvfi->DataOffset, min(kvfi->DataLength, sizeof(uint32_t)));
|
||||
|
||||
TRACE("entry %u = %.*S = %u\n", i, kvfi->NameLength / sizeof(WCHAR), kvfi->Name, val);
|
||||
TRACE("entry %lu = %.*S = %u\n", i, (int)(kvfi->NameLength / sizeof(WCHAR)), kvfi->Name, val);
|
||||
|
||||
add_user_mapping(kvfi->Name, kvfi->NameLength / sizeof(WCHAR), val);
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ static void read_group_mappings(PUNICODE_STRING regpath) {
|
|||
Status = ZwCreateKey(&h, KEY_QUERY_VALUE, &oa, 0, NULL, REG_OPTION_NON_VOLATILE, &dispos);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwCreateKey returned %08x\n", Status);
|
||||
ERR("ZwCreateKey returned %08lx\n", Status);
|
||||
ExFreePool(path);
|
||||
return;
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ static void read_group_mappings(PUNICODE_STRING regpath) {
|
|||
|
||||
RtlCopyMemory(&val, (uint8_t*)kvfi + kvfi->DataOffset, min(kvfi->DataLength, sizeof(uint32_t)));
|
||||
|
||||
TRACE("entry %u = %.*S = %u\n", i, kvfi->NameLength / sizeof(WCHAR), kvfi->Name, val);
|
||||
TRACE("entry %lu = %.*S = %u\n", i, (int)(kvfi->NameLength / sizeof(WCHAR)), kvfi->Name, val);
|
||||
|
||||
add_group_mapping(kvfi->Name, kvfi->NameLength / sizeof(WCHAR), val);
|
||||
}
|
||||
|
@ -685,7 +685,8 @@ static void read_group_mappings(PUNICODE_STRING regpath) {
|
|||
|
||||
ExFreePool(kvfi);
|
||||
} else if (dispos == REG_CREATED_NEW_KEY) {
|
||||
WCHAR* builtin_users = L"S-1-5-32-545";
|
||||
static const WCHAR builtin_users[] = L"S-1-5-32-545";
|
||||
|
||||
UNICODE_STRING us2;
|
||||
DWORD val;
|
||||
|
||||
|
@ -701,7 +702,7 @@ static void read_group_mappings(PUNICODE_STRING regpath) {
|
|||
val = 100;
|
||||
Status = ZwSetValueKey(h, &us2, 0, REG_DWORD, &val, sizeof(DWORD));
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwSetValueKey returned %08x\n", Status);
|
||||
ERR("ZwSetValueKey returned %08lx\n", Status);
|
||||
ZwClose(h);
|
||||
return;
|
||||
}
|
||||
|
@ -744,12 +745,12 @@ static void get_registry_value(HANDLE h, WCHAR* string, ULONG type, void* val, U
|
|||
} else {
|
||||
Status = ZwDeleteValueKey(h, &us);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwDeleteValueKey returned %08x\n", Status);
|
||||
ERR("ZwDeleteValueKey returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
Status = ZwSetValueKey(h, &us, 0, type, val, size);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwSetValueKey returned %08x\n", Status);
|
||||
ERR("ZwSetValueKey returned %08lx\n", Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -759,10 +760,10 @@ static void get_registry_value(HANDLE h, WCHAR* string, ULONG type, void* val, U
|
|||
Status = ZwSetValueKey(h, &us, 0, type, val, size);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwSetValueKey returned %08x\n", Status);
|
||||
ERR("ZwSetValueKey returned %08lx\n", Status);
|
||||
}
|
||||
} else {
|
||||
ERR("ZwQueryValueKey returned %08x\n", Status);
|
||||
ERR("ZwQueryValueKey returned %08lx\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -791,7 +792,7 @@ void read_registry(PUNICODE_STRING regpath, bool refresh) {
|
|||
Status = ZwCreateKey(&h, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &oa, 0, NULL, REG_OPTION_NON_VOLATILE, &dispos);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwCreateKey returned %08x\n", Status);
|
||||
ERR("ZwCreateKey returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -861,18 +862,18 @@ void read_registry(PUNICODE_STRING regpath, bool refresh) {
|
|||
if (log_device.Buffer[(log_device.Length / sizeof(WCHAR)) - 1] == 0)
|
||||
log_device.Length -= sizeof(WCHAR);
|
||||
} else {
|
||||
ERR("LogDevice was type %u, length %u\n", kvfi->Type, kvfi->DataLength);
|
||||
ERR("LogDevice was type %lu, length %lu\n", kvfi->Type, kvfi->DataLength);
|
||||
|
||||
Status = ZwDeleteValueKey(h, &us);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwDeleteValueKey returned %08x\n", Status);
|
||||
ERR("ZwDeleteValueKey returned %08lx\n", Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExFreePool(kvfi);
|
||||
} else if (Status != STATUS_OBJECT_NAME_NOT_FOUND) {
|
||||
ERR("ZwQueryValueKey returned %08x\n", Status);
|
||||
ERR("ZwQueryValueKey returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
ExAcquireResourceExclusiveLite(&log_lock, true);
|
||||
|
@ -893,7 +894,7 @@ void read_registry(PUNICODE_STRING regpath, bool refresh) {
|
|||
if (log_device.Length > 0 && debug_log_level > 0) {
|
||||
Status = IoGetDeviceObjectPointer(&log_device, FILE_WRITE_DATA, &comfo, &comdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
DbgPrint("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
DbgPrint("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -938,16 +939,16 @@ void read_registry(PUNICODE_STRING regpath, bool refresh) {
|
|||
if (log_file.Buffer[(log_file.Length / sizeof(WCHAR)) - 1] == 0)
|
||||
log_file.Length -= sizeof(WCHAR);
|
||||
} else {
|
||||
ERR("LogFile was type %u, length %u\n", kvfi->Type, kvfi->DataLength);
|
||||
ERR("LogFile was type %lu, length %lu\n", kvfi->Type, kvfi->DataLength);
|
||||
|
||||
Status = ZwDeleteValueKey(h, &us);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("ZwDeleteValueKey returned %08x\n", Status);
|
||||
ERR("ZwDeleteValueKey returned %08lx\n", Status);
|
||||
|
||||
log_file.Length = 0;
|
||||
}
|
||||
} else {
|
||||
ERR("ZwQueryValueKey returned %08\n", Status);
|
||||
ERR("ZwQueryValueKey returned %08lx\n", Status);
|
||||
log_file.Length = 0;
|
||||
}
|
||||
|
||||
|
@ -956,11 +957,11 @@ void read_registry(PUNICODE_STRING regpath, bool refresh) {
|
|||
Status = ZwSetValueKey(h, &us, 0, REG_SZ, (void*)def_log_file, sizeof(def_log_file));
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("ZwSetValueKey returned %08x\n", Status);
|
||||
ERR("ZwSetValueKey returned %08lx\n", Status);
|
||||
|
||||
log_file.Length = 0;
|
||||
} else {
|
||||
ERR("ZwQueryValueKey returned %08x\n", Status);
|
||||
ERR("ZwQueryValueKey returned %08lx\n", Status);
|
||||
log_file.Length = 0;
|
||||
}
|
||||
|
||||
|
@ -994,7 +995,7 @@ void read_registry(PUNICODE_STRING regpath, bool refresh) {
|
|||
Status = ZwCreateFile(&log_handle, FILE_WRITE_DATA, &oa, &iosb, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ,
|
||||
FILE_OPEN_IF, FILE_NON_DIRECTORY_FILE | FILE_WRITE_THROUGH | FILE_SYNCHRONOUS_IO_ALERT, NULL, 0);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
DbgPrint("ZwCreateFile returned %08x\n", Status);
|
||||
DbgPrint("ZwCreateFile returned %08lx\n", Status);
|
||||
log_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1021,7 +1022,7 @@ static void __stdcall registry_work_item(PVOID Parameter) {
|
|||
|
||||
Status = ZwNotifyChangeKey(regh, NULL, (PVOID)&wqi, (PVOID)DelayedWorkQueue, &iosb, REG_NOTIFY_CHANGE_LAST_SET, true, NULL, 0, true);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("ZwNotifyChangeKey returned %08x\n", Status);
|
||||
ERR("ZwNotifyChangeKey returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
void watch_registry(HANDLE regh) {
|
||||
|
@ -1032,5 +1033,5 @@ void watch_registry(HANDLE regh) {
|
|||
|
||||
Status = ZwNotifyChangeKey(regh, NULL, (PVOID)&wqi, (PVOID)DelayedWorkQueue, &iosb, REG_NOTIFY_CHANGE_LAST_SET, true, NULL, 0, true);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("ZwNotifyChangeKey returned %08x\n", Status);
|
||||
ERR("ZwNotifyChangeKey returned %08lx\n", Status);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ NTSTATUS get_reparse_point(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
ccb* ccb = FileObject->FsContext2;
|
||||
NTSTATUS Status;
|
||||
|
||||
TRACE("(%p, %p, %p, %x, %p)\n", DeviceObject, FileObject, buffer, buflen, retlen);
|
||||
TRACE("(%p, %p, %p, %lx, %p)\n", DeviceObject, FileObject, buffer, buflen, retlen);
|
||||
|
||||
if (!ccb)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -45,7 +45,7 @@ NTSTATUS get_reparse_point(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
goto end;
|
||||
}
|
||||
|
||||
rdb->ReparseTag = IO_REPARSE_TAG_LXSS_SYMLINK;
|
||||
rdb->ReparseTag = IO_REPARSE_TAG_LX_SYMLINK;
|
||||
rdb->ReparseDataLength = offsetof(REPARSE_DATA_BUFFER, GenericReparseBuffer.DataBuffer) + sizeof(uint32_t);
|
||||
rdb->Reserved = 0;
|
||||
|
||||
|
@ -67,18 +67,18 @@ NTSTATUS get_reparse_point(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
goto end;
|
||||
}
|
||||
|
||||
TRACE("data = %p, size = %x\n", data, fcb->inode_item.st_size);
|
||||
TRACE("data = %p, size = %I64x\n", data, fcb->inode_item.st_size);
|
||||
Status = read_file(fcb, (uint8_t*)data, 0, fcb->inode_item.st_size, NULL, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = utf8_to_utf16(NULL, 0, &stringlen, data, (ULONG)fcb->inode_item.st_size);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
goto end;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ NTSTATUS get_reparse_point(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
stringlen, &stringlen, data, (ULONG)fcb->inode_item.st_size);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(data);
|
||||
goto end;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ NTSTATUS get_reparse_point(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
Status = read_file(fcb, buffer, 0, buflen, &len, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_file returned %08x\n", Status);
|
||||
ERR("read_file returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
*retlen = len;
|
||||
|
@ -184,7 +184,7 @@ static NTSTATUS set_symlink(PIRP Irp, file_ref* fileref, fcb* fcb, ccb* ccb, REP
|
|||
if (write) {
|
||||
minlen = offsetof(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer) + sizeof(WCHAR);
|
||||
if (buflen < minlen) {
|
||||
WARN("buffer was less than minimum length (%u < %u)\n", buflen, minlen);
|
||||
WARN("buffer was less than minimum length (%lu < %lu)\n", buflen, minlen);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ static NTSTATUS set_symlink(PIRP Irp, file_ref* fileref, fcb* fcb, ccb* ccb, REP
|
|||
subname.Buffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)];
|
||||
subname.MaximumLength = subname.Length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength;
|
||||
|
||||
TRACE("substitute name = %.*S\n", subname.Length / sizeof(WCHAR), subname.Buffer);
|
||||
TRACE("substitute name = %.*S\n", (int)(subname.Length / sizeof(WCHAR)), subname.Buffer);
|
||||
}
|
||||
|
||||
fcb->type = BTRFS_TYPE_SYMLINK;
|
||||
|
@ -209,13 +209,13 @@ static NTSTATUS set_symlink(PIRP Irp, file_ref* fileref, fcb* fcb, ccb* ccb, REP
|
|||
if (write) {
|
||||
Status = truncate_file(fcb, 0, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("truncate_file returned %08x\n", Status);
|
||||
ERR("truncate_file returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = utf16_to_utf8(NULL, 0, (PULONG)&target.Length, subname.Buffer, subname.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 1 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 1 failed with error %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ static NTSTATUS set_symlink(PIRP Irp, file_ref* fileref, fcb* fcb, ccb* ccb, REP
|
|||
|
||||
Status = utf16_to_utf8(target.Buffer, target.Length, (PULONG)&target.Length, subname.Buffer, subname.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf16_to_utf8 2 failed with error %08x\n", Status);
|
||||
ERR("utf16_to_utf8 2 failed with error %08lx\n", Status);
|
||||
ExFreePool(target.Buffer);
|
||||
return Status;
|
||||
}
|
||||
|
@ -290,14 +290,14 @@ NTSTATUS set_reparse_point2(fcb* fcb, REPARSE_DATA_BUFFER* rdb, ULONG buflen, cc
|
|||
|
||||
Status = fFsRtlValidateReparsePointBuffer(buflen, rdb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("FsRtlValidateReparsePointBuffer returned %08x\n", Status);
|
||||
ERR("FsRtlValidateReparsePointBuffer returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlCopyMemory(&tag, rdb, sizeof(ULONG));
|
||||
|
||||
if (fcb->type == BTRFS_TYPE_FILE &&
|
||||
((tag == IO_REPARSE_TAG_SYMLINK && rdb->SymbolicLinkReparseBuffer.Flags & SYMLINK_FLAG_RELATIVE) || tag == IO_REPARSE_TAG_LXSS_SYMLINK)) {
|
||||
((tag == IO_REPARSE_TAG_SYMLINK && rdb->SymbolicLinkReparseBuffer.Flags & SYMLINK_FLAG_RELATIVE) || tag == IO_REPARSE_TAG_LX_SYMLINK)) {
|
||||
Status = set_symlink(Irp, fileref, fcb, ccb, rdb, buflen, tag == IO_REPARSE_TAG_SYMLINK, rollback);
|
||||
fcb->atts |= FILE_ATTRIBUTE_REPARSE_POINT;
|
||||
} else {
|
||||
|
@ -326,7 +326,7 @@ NTSTATUS set_reparse_point2(fcb* fcb, REPARSE_DATA_BUFFER* rdb, ULONG buflen, cc
|
|||
} else { // otherwise, store as file data
|
||||
Status = truncate_file(fcb, 0, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("truncate_file returned %08x\n", Status);
|
||||
ERR("truncate_file returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ NTSTATUS set_reparse_point2(fcb* fcb, REPARSE_DATA_BUFFER* rdb, ULONG buflen, cc
|
|||
|
||||
Status = write_file2(fcb->Vcb, Irp, offset, rdb, &buflen, false, true, true, false, false, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_file2 returned %08x\n", Status);
|
||||
ERR("write_file2 returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ NTSTATUS set_reparse_point(PDEVICE_OBJECT DeviceObject, PIRP Irp) {
|
|||
|
||||
Status = set_reparse_point2(fcb, rdb, buflen, ccb, fileref, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("set_reparse_point2 returned %08x\n", Status);
|
||||
ERR("set_reparse_point2 returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ NTSTATUS delete_reparse_point(PDEVICE_OBJECT DeviceObject, PIRP Irp) {
|
|||
|
||||
Status = truncate_file(fcb, 0, Irp, &rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("truncate_file returned %08x\n", Status);
|
||||
ERR("truncate_file returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by btrfs.rc
|
||||
//
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef struct {
|
|||
IO_STATUS_BLOCK iosb;
|
||||
uint8_t* buf;
|
||||
bool csum_error;
|
||||
uint32_t* bad_csums;
|
||||
void* bad_csums;
|
||||
} scrub_context_stripe;
|
||||
|
||||
typedef struct _scrub_context {
|
||||
|
@ -88,7 +88,7 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
|
||||
Status = find_item(Vcb, Vcb->root_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -97,12 +97,12 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
path_part* pp;
|
||||
|
||||
if (tp.item->size < sizeof(ROOT_REF)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(ROOT_REF));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(ROOT_REF));
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (tp.item->size < offsetof(ROOT_REF, name[0]) + rr->n) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, offsetof(ROOT_REF, name[0]) + rr->n);
|
||||
goto end;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
|
||||
Status = find_item(Vcb, r, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -160,12 +160,12 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
path_part* pp;
|
||||
|
||||
if (tp.item->size < sizeof(INODE_REF)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(INODE_REF));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(INODE_REF));
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (tp.item->size < offsetof(INODE_REF, name[0]) + ir->n) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, offsetof(INODE_REF, name[0]) + ir->n);
|
||||
goto end;
|
||||
}
|
||||
|
@ -191,13 +191,13 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
path_part* pp;
|
||||
|
||||
if (tp.item->size < sizeof(INODE_EXTREF)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(INODE_EXTREF));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(INODE_EXTREF));
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (tp.item->size < offsetof(INODE_EXTREF, name[0]) + ier->n) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, offsetof(INODE_EXTREF, name[0]) + ier->n);
|
||||
goto end;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
|
||||
Status = utf8_to_utf16(NULL, 0, &utf16len, fn.Buffer, fn.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 1 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 1 returned %08lx\n", Status);
|
||||
ExFreePool(fn.Buffer);
|
||||
goto end;
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ static void log_file_checksum_error(device_extension* Vcb, uint64_t addr, uint64
|
|||
|
||||
Status = utf8_to_utf16(err->data.filename, utf16len, &utf16len, fn.Buffer, fn.Length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("utf8_to_utf16 2 returned %08x\n", Status);
|
||||
ERR("utf8_to_utf16 2 returned %08lx\n", Status);
|
||||
ExFreePool(fn.Buffer);
|
||||
ExFreePool(err);
|
||||
goto end;
|
||||
|
@ -341,7 +341,7 @@ static void log_file_checksum_error_shared(device_extension* Vcb, uint64_t treea
|
|||
|
||||
Status = read_data(Vcb, treeaddr, Vcb->superblock.node_size, NULL, true, (uint8_t*)tree, NULL, NULL, NULL, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ static void log_tree_checksum_error_shared(device_extension* Vcb, uint64_t offse
|
|||
|
||||
Status = read_data(Vcb, offset, Vcb->superblock.node_size, NULL, true, (uint8_t*)tree, NULL, NULL, NULL, 0, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned %08x\n", Status);
|
||||
ERR("read_data returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
return;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -479,8 +479,8 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
|
||||
if (tp.item->key.obj_id == TYPE_EXTENT_ITEM && ei->flags & EXTENT_ITEM_TREE_BLOCK) {
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_ITEM) + sizeof(EXTENT_ITEM2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
TREE_BLOCK_REF* tbr;
|
||||
|
||||
if (len < sizeof(TREE_BLOCK_REF)) {
|
||||
ERR("TREE_BLOCK_REF takes up %u bytes, but only %u remaining\n", sizeof(TREE_BLOCK_REF), len);
|
||||
ERR("TREE_BLOCK_REF takes up %Iu bytes, but only %lu remaining\n", sizeof(TREE_BLOCK_REF), len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
EXTENT_DATA_REF* edr;
|
||||
|
||||
if (len < sizeof(EXTENT_DATA_REF)) {
|
||||
ERR("EXTENT_DATA_REF takes up %u bytes, but only %u remaining\n", sizeof(EXTENT_DATA_REF), len);
|
||||
ERR("EXTENT_DATA_REF takes up %Iu bytes, but only %lu remaining\n", sizeof(EXTENT_DATA_REF), len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -534,7 +534,7 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
SHARED_BLOCK_REF* sbr;
|
||||
|
||||
if (len < sizeof(SHARED_BLOCK_REF)) {
|
||||
ERR("SHARED_BLOCK_REF takes up %u bytes, but only %u remaining\n", sizeof(SHARED_BLOCK_REF), len);
|
||||
ERR("SHARED_BLOCK_REF takes up %Iu bytes, but only %lu remaining\n", sizeof(SHARED_BLOCK_REF), len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
SHARED_DATA_REF* sdr;
|
||||
|
||||
if (len < sizeof(SHARED_DATA_REF)) {
|
||||
ERR("SHARED_DATA_REF takes up %u bytes, but only %u remaining\n", sizeof(SHARED_DATA_REF), len);
|
||||
ERR("SHARED_DATA_REF takes up %Iu bytes, but only %lu remaining\n", sizeof(SHARED_DATA_REF), len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -584,8 +584,8 @@ static void log_unrecoverable_error(device_extension* Vcb, uint64_t address, uin
|
|||
EXTENT_DATA_REF* edr;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_DATA_REF)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_DATA_REF));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset,
|
||||
tp.item->size, sizeof(EXTENT_DATA_REF));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -664,7 +664,7 @@ static NTSTATUS __stdcall scrub_read_completion(PDEVICE_OBJECT DeviceObject, PIR
|
|||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
}
|
||||
|
||||
static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offset, uint32_t* csum, scrub_context* context) {
|
||||
static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offset, void* csum, scrub_context* context) {
|
||||
NTSTATUS Status;
|
||||
bool csum_error = false;
|
||||
ULONG i;
|
||||
|
@ -693,7 +693,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
csum_error = true;
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("check_csum returned %08x\n", Status);
|
||||
ERR("check_csum returned %08lx\n", Status);
|
||||
return Status;
|
||||
} else
|
||||
good_stripe = i;
|
||||
|
@ -718,9 +718,8 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
} else {
|
||||
for (j = 0; j < context->stripes[i].length / Vcb->superblock.node_size; j++) {
|
||||
tree_header* th = (tree_header*)&context->stripes[i].buf[j * Vcb->superblock.node_size];
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
if (crc32 != *((uint32_t*)th->csum) || th->address != offset + UInt32x32To64(j, Vcb->superblock.node_size)) {
|
||||
if (!check_tree_checksum(Vcb, th) || th->address != offset + UInt32x32To64(j, Vcb->superblock.node_size)) {
|
||||
context->stripes[i].csum_error = true;
|
||||
csum_error = true;
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
@ -742,21 +741,17 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
for (i = 0; i < c->chunk_item->num_stripes; i++) {
|
||||
if (context->stripes[i].csum_error) {
|
||||
if (csum) {
|
||||
context->stripes[i].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[i].length * sizeof(uint32_t) / Vcb->superblock.sector_size, ALLOC_TAG);
|
||||
context->stripes[i].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[i].length * Vcb->csum_size / Vcb->superblock.sector_size, ALLOC_TAG);
|
||||
if (!context->stripes[i].bad_csums) {
|
||||
ERR("out of memory\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Status = calc_csum(Vcb, context->stripes[i].buf, context->stripes[i].length / Vcb->superblock.sector_size, context->stripes[i].bad_csums);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("calc_csum returned %08x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
do_calc_job(Vcb, context->stripes[i].buf, context->stripes[i].length / Vcb->superblock.sector_size, context->stripes[i].bad_csums);
|
||||
} else {
|
||||
ULONG j;
|
||||
|
||||
context->stripes[i].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[i].length * sizeof(uint32_t) / Vcb->superblock.node_size, ALLOC_TAG);
|
||||
context->stripes[i].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[i].length * Vcb->csum_size / Vcb->superblock.node_size, ALLOC_TAG);
|
||||
if (!context->stripes[i].bad_csums) {
|
||||
ERR("out of memory\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -764,9 +759,8 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
|
||||
for (j = 0; j < context->stripes[i].length / Vcb->superblock.node_size; j++) {
|
||||
tree_header* th = (tree_header*)&context->stripes[i].buf[j * Vcb->superblock.node_size];
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
context->stripes[i].bad_csums[j] = crc32;
|
||||
get_tree_checksum(Vcb, th, (uint8_t*)context->stripes[i].bad_csums + (Vcb->csum_size * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +785,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
|
||||
if (csum) {
|
||||
for (j = 0; j < context->stripes[i].length / Vcb->superblock.sector_size; j++) {
|
||||
if (context->stripes[i].bad_csums[j] != csum[j]) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[i].bad_csums + (j * Vcb->csum_size), (uint8_t*)csum + (j + Vcb->csum_size), Vcb->csum_size) != Vcb->csum_size) {
|
||||
uint64_t addr = offset + UInt32x32To64(j, Vcb->superblock.sector_size);
|
||||
|
||||
log_error(Vcb, addr, c->devices[i]->devitem.dev_id, false, true, false);
|
||||
|
@ -803,7 +797,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
tree_header* th = (tree_header*)&context->stripes[i].buf[j * Vcb->superblock.node_size];
|
||||
uint64_t addr = offset + UInt32x32To64(j, Vcb->superblock.node_size);
|
||||
|
||||
if (context->stripes[i].bad_csums[j] != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[i].bad_csums + (j * Vcb->csum_size), th, Vcb->csum_size) != Vcb->csum_size || th->address != addr) {
|
||||
log_error(Vcb, addr, c->devices[i]->devitem.dev_id, true, true, false);
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
}
|
||||
|
@ -820,7 +814,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
context->stripes[good_stripe].buf, context->stripes[i].length);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_phys returned %08x\n", Status);
|
||||
ERR("write_data_phys returned %08lx\n", Status);
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_WRITE_ERRORS);
|
||||
return Status;
|
||||
}
|
||||
|
@ -838,13 +832,15 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
if (c->devices[i]->devobj) {
|
||||
if (csum) {
|
||||
for (j = 0; j < context->stripes[i].length / Vcb->superblock.sector_size; j++) {
|
||||
if (context->stripes[i].bad_csums[j] != csum[j]) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[i].bad_csums + (j * Vcb->csum_size), (uint8_t*)csum + (j * Vcb->csum_size), Vcb->csum_size) != Vcb->csum_size) {
|
||||
ULONG k;
|
||||
uint64_t addr = offset + UInt32x32To64(j, Vcb->superblock.sector_size);
|
||||
bool recovered = false;
|
||||
|
||||
for (k = 0; k < c->chunk_item->num_stripes; k++) {
|
||||
if (i != k && c->devices[k]->devobj && context->stripes[k].bad_csums[j] == csum[j]) {
|
||||
if (i != k && c->devices[k]->devobj &&
|
||||
RtlCompareMemory((uint8_t*)context->stripes[k].bad_csums + (j * Vcb->csum_size),
|
||||
(uint8_t*)csum + (j * Vcb->csum_size), Vcb->csum_size) == Vcb->csum_size) {
|
||||
log_error(Vcb, addr, c->devices[i]->devitem.dev_id, false, true, false);
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
||||
|
@ -867,7 +863,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
tree_header* th = (tree_header*)&context->stripes[i].buf[j * Vcb->superblock.node_size];
|
||||
uint64_t addr = offset + UInt32x32To64(j, Vcb->superblock.node_size);
|
||||
|
||||
if (context->stripes[i].bad_csums[j] != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[i].bad_csums + (j * Vcb->csum_size), th, Vcb->csum_size) != Vcb->csum_size || th->address != addr) {
|
||||
ULONG k;
|
||||
bool recovered = false;
|
||||
|
||||
|
@ -875,7 +871,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
if (i != k && c->devices[k]->devobj) {
|
||||
tree_header* th2 = (tree_header*)&context->stripes[k].buf[j * Vcb->superblock.node_size];
|
||||
|
||||
if (context->stripes[k].bad_csums[j] == *((uint32_t*)th2->csum) && th2->address == addr) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[k].bad_csums + (j * Vcb->csum_size), th2, Vcb->csum_size) == Vcb->csum_size && th2->address == addr) {
|
||||
log_error(Vcb, addr, c->devices[i]->devitem.dev_id, true, true, false);
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
||||
|
@ -904,7 +900,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
Status = write_data_phys(c->devices[i]->devobj, c->devices[i]->fileobj, cis[i].offset + offset - c->offset,
|
||||
context->stripes[i].buf, context->stripes[i].length);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_phys returned %08x\n", Status);
|
||||
ERR("write_data_phys returned %08lx\n", Status);
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
return Status;
|
||||
}
|
||||
|
@ -920,7 +916,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
|
||||
if (csum) {
|
||||
for (j = 0; j < context->stripes[i].length / Vcb->superblock.sector_size; j++) {
|
||||
if (context->stripes[i].bad_csums[j] != csum[j]) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[i].bad_csums + (j * Vcb->csum_size), (uint8_t*)csum + (j + Vcb->csum_size), Vcb->csum_size) != Vcb->csum_size) {
|
||||
uint64_t addr = offset + UInt32x32To64(j, Vcb->superblock.sector_size);
|
||||
|
||||
log_error(Vcb, addr, c->devices[i]->devitem.dev_id, false, false, false);
|
||||
|
@ -931,7 +927,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
tree_header* th = (tree_header*)&context->stripes[i].buf[j * Vcb->superblock.node_size];
|
||||
uint64_t addr = offset + UInt32x32To64(j, Vcb->superblock.node_size);
|
||||
|
||||
if (context->stripes[i].bad_csums[j] != *((uint32_t*)th->csum) || th->address != addr)
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[i].bad_csums + (j * Vcb->csum_size), th, Vcb->csum_size) != Vcb->csum_size || th->address != addr)
|
||||
log_error(Vcb, addr, c->devices[i]->devitem.dev_id, true, false, false);
|
||||
}
|
||||
}
|
||||
|
@ -941,7 +937,7 @@ static NTSTATUS scrub_extent_dup(device_extension* Vcb, chunk* c, uint64_t offse
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS scrub_extent_raid0(device_extension* Vcb, chunk* c, uint64_t offset, uint32_t length, uint16_t startoffstripe, uint32_t* csum, scrub_context* context) {
|
||||
static NTSTATUS scrub_extent_raid0(device_extension* Vcb, chunk* c, uint64_t offset, uint32_t length, uint16_t startoffstripe, void* csum, scrub_context* context) {
|
||||
ULONG j;
|
||||
uint16_t stripe;
|
||||
uint32_t pos, *stripeoff;
|
||||
|
@ -966,9 +962,7 @@ static NTSTATUS scrub_extent_raid0(device_extension* Vcb, chunk* c, uint64_t off
|
|||
|
||||
if (csum) {
|
||||
for (j = 0; j < readlen; j += Vcb->superblock.sector_size) {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, context->stripes[stripe].buf + stripeoff[stripe], Vcb->superblock.sector_size);
|
||||
|
||||
if (crc32 != csum[pos / Vcb->superblock.sector_size]) {
|
||||
if (!check_sector_csum(Vcb, context->stripes[stripe].buf + stripeoff[stripe], (uint8_t*)csum + (pos * Vcb->csum_size / Vcb->superblock.sector_size))) {
|
||||
uint64_t addr = offset + pos;
|
||||
|
||||
log_error(Vcb, addr, c->devices[stripe]->devitem.dev_id, false, false, false);
|
||||
|
@ -981,10 +975,9 @@ static NTSTATUS scrub_extent_raid0(device_extension* Vcb, chunk* c, uint64_t off
|
|||
} else {
|
||||
for (j = 0; j < readlen; j += Vcb->superblock.node_size) {
|
||||
tree_header* th = (tree_header*)(context->stripes[stripe].buf + stripeoff[stripe]);
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
uint64_t addr = offset + pos;
|
||||
|
||||
if (crc32 != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (!check_tree_checksum(Vcb, th) || th->address != addr) {
|
||||
log_error(Vcb, addr, c->devices[stripe]->devitem.dev_id, true, false, false);
|
||||
log_device_error(Vcb, c->devices[stripe], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
}
|
||||
|
@ -1002,7 +995,7 @@ static NTSTATUS scrub_extent_raid0(device_extension* Vcb, chunk* c, uint64_t off
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t offset, uint32_t length, uint16_t startoffstripe, uint32_t* csum, scrub_context* context) {
|
||||
static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t offset, uint32_t length, uint16_t startoffstripe, void* csum, scrub_context* context) {
|
||||
ULONG j;
|
||||
uint16_t stripe, sub_stripes = max(c->chunk_item->sub_stripes, 1);
|
||||
uint32_t pos, *stripeoff;
|
||||
|
@ -1045,9 +1038,8 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
}
|
||||
} else {
|
||||
for (j = 0; j < readlen; j += Vcb->superblock.sector_size) {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, context->stripes[(stripe * sub_stripes) + k].buf + stripeoff[stripe] + j, Vcb->superblock.sector_size);
|
||||
|
||||
if (crc32 != csum[(pos + j) / Vcb->superblock.sector_size]) {
|
||||
if (!check_sector_csum(Vcb, context->stripes[(stripe * sub_stripes) + k].buf + stripeoff[stripe] + j,
|
||||
(uint8_t*)csum + ((pos + j) * Vcb->csum_size / Vcb->superblock.sector_size))) {
|
||||
csum_error = true;
|
||||
context->stripes[(stripe * sub_stripes) + k].csum_error = true;
|
||||
log_device_error(Vcb, c->devices[(stripe * sub_stripes) + k], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
@ -1081,10 +1073,9 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
} else {
|
||||
for (j = 0; j < readlen; j += Vcb->superblock.node_size) {
|
||||
tree_header* th = (tree_header*)(context->stripes[(stripe * sub_stripes) + k].buf + stripeoff[stripe] + j);
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
uint64_t addr = offset + pos + j;
|
||||
|
||||
if (crc32 != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (!check_tree_checksum(Vcb, th) || th->address != addr) {
|
||||
csum_error = true;
|
||||
context->stripes[(stripe * sub_stripes) + k].csum_error = true;
|
||||
log_device_error(Vcb, c->devices[(stripe * sub_stripes) + k], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
@ -1198,7 +1189,7 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
context->stripes[j + goodstripe].buf, context->stripes[j + goodstripe].length);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_phys returned %08x\n", Status);
|
||||
ERR("write_data_phys returned %08lx\n", Status);
|
||||
log_device_error(Vcb, c->devices[j + k], BTRFS_DEV_STAT_WRITE_ERRORS);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1213,18 +1204,15 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
if (csum) {
|
||||
for (k = 0; k < sub_stripes; k++) {
|
||||
if (c->devices[j + k]->devobj) {
|
||||
context->stripes[j + k].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[j + k].length * sizeof(uint32_t) / Vcb->superblock.sector_size, ALLOC_TAG);
|
||||
context->stripes[j + k].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[j + k].length * Vcb->csum_size / Vcb->superblock.sector_size,
|
||||
ALLOC_TAG);
|
||||
if (!context->stripes[j + k].bad_csums) {
|
||||
ERR("out of memory\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = calc_csum(Vcb, context->stripes[j + k].buf, context->stripes[j + k].length / Vcb->superblock.sector_size, context->stripes[j + k].bad_csums);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("calc_csum returned %08x\n", Status);
|
||||
goto end;
|
||||
}
|
||||
do_calc_job(Vcb, context->stripes[j + k].buf, context->stripes[j + k].length / Vcb->superblock.sector_size, context->stripes[j + k].bad_csums);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1232,7 +1220,8 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
if (c->devices[j + k]->devobj) {
|
||||
ULONG l;
|
||||
|
||||
context->stripes[j + k].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[j + k].length * sizeof(uint32_t) / Vcb->superblock.node_size, ALLOC_TAG);
|
||||
context->stripes[j + k].bad_csums = ExAllocatePoolWithTag(PagedPool, context->stripes[j + k].length * Vcb->csum_size / Vcb->superblock.node_size,
|
||||
ALLOC_TAG);
|
||||
if (!context->stripes[j + k].bad_csums) {
|
||||
ERR("out of memory\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -1241,9 +1230,8 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
|
||||
for (l = 0; l < context->stripes[j + k].length / Vcb->superblock.node_size; l++) {
|
||||
tree_header* th = (tree_header*)&context->stripes[j + k].buf[l * Vcb->superblock.node_size];
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
context->stripes[j + k].bad_csums[l] = crc32;
|
||||
get_tree_checksum(Vcb, th, (uint8_t*)context->stripes[j + k].bad_csums + (Vcb->csum_size * l));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1266,15 +1254,16 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
|
||||
if (csum) {
|
||||
for (l = 0; l < readlen; l += Vcb->superblock.sector_size) {
|
||||
uint32_t crc32 = csum[pos / Vcb->superblock.sector_size];
|
||||
bool has_error = false;
|
||||
|
||||
goodstripe = 0xffffffff;
|
||||
for (k = 0; k < sub_stripes; k++) {
|
||||
if (c->devices[j + k]->devobj) {
|
||||
if (context->stripes[j + k].bad_csums[so / Vcb->superblock.sector_size] != crc32)
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[j + k].bad_csums + (so * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
(uint8_t*)csum + (pos * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
Vcb->csum_size) != Vcb->csum_size) {
|
||||
has_error = true;
|
||||
else
|
||||
} else
|
||||
goodstripe = k;
|
||||
}
|
||||
}
|
||||
|
@ -1282,7 +1271,10 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
if (has_error) {
|
||||
if (goodstripe != 0xffffffff) {
|
||||
for (k = 0; k < sub_stripes; k++) {
|
||||
if (c->devices[j + k]->devobj && context->stripes[j + k].bad_csums[so / Vcb->superblock.sector_size] != crc32) {
|
||||
if (c->devices[j + k]->devobj &&
|
||||
RtlCompareMemory((uint8_t*)context->stripes[j + k].bad_csums + (so * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
(uint8_t*)csum + (pos * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
Vcb->csum_size) != Vcb->csum_size) {
|
||||
uint64_t addr = offset + pos;
|
||||
|
||||
log_error(Vcb, addr, c->devices[j + k]->devitem.dev_id, false, true, false);
|
||||
|
@ -1315,7 +1307,7 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
tree_header* th = (tree_header*)&context->stripes[j + k].buf[so];
|
||||
uint64_t addr = offset + pos;
|
||||
|
||||
if (context->stripes[j + k].bad_csums[so / Vcb->superblock.node_size] != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[j + k].bad_csums + (so * Vcb->csum_size / Vcb->superblock.node_size), th, Vcb->csum_size) != Vcb->csum_size || th->address != addr) {
|
||||
ULONG m;
|
||||
|
||||
recovered = false;
|
||||
|
@ -1324,7 +1316,7 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
if (m != k) {
|
||||
tree_header* th2 = (tree_header*)&context->stripes[j + m].buf[so];
|
||||
|
||||
if (context->stripes[j + m].bad_csums[so / Vcb->superblock.node_size] == *((uint32_t*)th2->csum) && th2->address == addr) {
|
||||
if (RtlCompareMemory((uint8_t*)context->stripes[j + m].bad_csums + (so * Vcb->csum_size / Vcb->superblock.node_size), th2, Vcb->csum_size) == Vcb->csum_size && th2->address == addr) {
|
||||
log_error(Vcb, addr, c->devices[j + k]->devitem.dev_id, true, true, false);
|
||||
|
||||
RtlCopyMemory(th, th2, Vcb->superblock.node_size);
|
||||
|
@ -1363,7 +1355,7 @@ static NTSTATUS scrub_extent_raid10(device_extension* Vcb, chunk* c, uint64_t of
|
|||
context->stripes[j + k].buf, context->stripes[j + k].length);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_phys returned %08x\n", Status);
|
||||
ERR("write_data_phys returned %08lx\n", Status);
|
||||
log_device_error(Vcb, c->devices[j + k], BTRFS_DEV_STAT_WRITE_ERRORS);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1382,14 +1374,14 @@ end:
|
|||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS scrub_extent(device_extension* Vcb, chunk* c, ULONG type, uint64_t offset, uint32_t size, uint32_t* csum) {
|
||||
static NTSTATUS scrub_extent(device_extension* Vcb, chunk* c, ULONG type, uint64_t offset, uint32_t size, void* csum) {
|
||||
ULONG i;
|
||||
scrub_context context;
|
||||
CHUNK_ITEM_STRIPE* cis;
|
||||
NTSTATUS Status;
|
||||
uint16_t startoffstripe, num_missing, allowed_missing;
|
||||
|
||||
TRACE("(%p, %p, %I64x, %I64x, %p)\n", Vcb, c, offset, size, csum);
|
||||
TRACE("(%p, %p, %lx, %I64x, %x, %p)\n", Vcb, c, type, offset, size, csum);
|
||||
|
||||
context.stripes = ExAllocatePoolWithTag(NonPagedPool, sizeof(scrub_context_stripe) * c->chunk_item->num_stripes, ALLOC_TAG);
|
||||
if (!context.stripes) {
|
||||
|
@ -1481,7 +1473,7 @@ static NTSTATUS scrub_extent(device_extension* Vcb, chunk* c, ULONG type, uint64
|
|||
context.stripes[i].start = offset - c->offset;
|
||||
context.stripes[i].length = size;
|
||||
} else if (type != BLOCK_FLAG_RAID0 && type != BLOCK_FLAG_RAID10) {
|
||||
ERR("unexpected chunk type %x\n", type);
|
||||
ERR("unexpected chunk type %lx\n", type);
|
||||
Status = STATUS_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1543,7 +1535,7 @@ static NTSTATUS scrub_extent(device_extension* Vcb, chunk* c, ULONG type, uint64
|
|||
} _SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("MmProbeAndLockPages threw exception %08x\n", Status);
|
||||
ERR("MmProbeAndLockPages threw exception %08lx\n", Status);
|
||||
IoFreeMdl(context.stripes[i].Irp->MdlAddress);
|
||||
context.stripes[i].Irp->MdlAddress = NULL;
|
||||
goto end;
|
||||
|
@ -1591,19 +1583,19 @@ static NTSTATUS scrub_extent(device_extension* Vcb, chunk* c, ULONG type, uint64
|
|||
if (type == BLOCK_FLAG_DUPLICATE) {
|
||||
Status = scrub_extent_dup(Vcb, c, offset, csum, &context);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_extent_dup returned %08x\n", Status);
|
||||
ERR("scrub_extent_dup returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
} else if (type == BLOCK_FLAG_RAID0) {
|
||||
Status = scrub_extent_raid0(Vcb, c, offset, size, startoffstripe, csum, &context);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_extent_raid0 returned %08x\n", Status);
|
||||
ERR("scrub_extent_raid0 returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
} else if (type == BLOCK_FLAG_RAID10) {
|
||||
Status = scrub_extent_raid10(Vcb, c, offset, size, startoffstripe, csum, &context);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_extent_raid10 returned %08x\n", Status);
|
||||
ERR("scrub_extent_raid10 returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1632,7 +1624,7 @@ end:
|
|||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS scrub_data_extent(device_extension* Vcb, chunk* c, uint64_t offset, ULONG type, uint32_t* csum, RTL_BITMAP* bmp, ULONG bmplen) {
|
||||
static NTSTATUS scrub_data_extent(device_extension* Vcb, chunk* c, uint64_t offset, ULONG type, void* csum, RTL_BITMAP* bmp, ULONG bmplen) {
|
||||
NTSTATUS Status;
|
||||
ULONG runlength, index;
|
||||
|
||||
|
@ -1657,9 +1649,10 @@ static NTSTATUS scrub_data_extent(device_extension* Vcb, chunk* c, uint64_t offs
|
|||
else
|
||||
rl = runlength;
|
||||
|
||||
Status = scrub_extent(Vcb, c, type, offset + UInt32x32To64(index, Vcb->superblock.sector_size), rl * Vcb->superblock.sector_size, &csum[index]);
|
||||
Status = scrub_extent(Vcb, c, type, offset + UInt32x32To64(index, Vcb->superblock.sector_size),
|
||||
rl * Vcb->superblock.sector_size, (uint8_t*)csum + (index * Vcb->csum_size));
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_data_extent_dup returned %08x\n", Status);
|
||||
ERR("scrub_data_extent_dup returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1691,7 +1684,7 @@ typedef struct {
|
|||
RTL_BITMAP alloc;
|
||||
RTL_BITMAP has_csum;
|
||||
RTL_BITMAP is_tree;
|
||||
uint32_t* csum;
|
||||
void* csum;
|
||||
uint8_t* parity_scratch;
|
||||
uint8_t* parity_scratch2;
|
||||
} scrub_context_raid56;
|
||||
|
@ -1733,9 +1726,8 @@ static void scrub_raid5_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
if (RtlCheckBit(&context->is_tree, off)) {
|
||||
tree_header* th = (tree_header*)&context->stripes[stripe].buf[stripeoff * Vcb->superblock.sector_size];
|
||||
uint64_t addr = c->offset + (stripe_start * (c->chunk_item->num_stripes - 1) * c->chunk_item->stripe_length) + (off * Vcb->superblock.sector_size);
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
if (crc32 != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (!check_tree_checksum(Vcb, th) || th->address != addr) {
|
||||
RtlSetBits(&context->stripes[stripe].error, i, Vcb->superblock.node_size / Vcb->superblock.sector_size);
|
||||
log_device_error(Vcb, c->devices[stripe], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
||||
|
@ -1749,9 +1741,7 @@ static void scrub_raid5_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
|
||||
continue;
|
||||
} else if (RtlCheckBit(&context->has_csum, off)) {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, context->stripes[stripe].buf + (stripeoff * Vcb->superblock.sector_size), Vcb->superblock.sector_size);
|
||||
|
||||
if (crc32 != context->csum[off]) {
|
||||
if (!check_sector_csum(Vcb, context->stripes[stripe].buf + (stripeoff * Vcb->superblock.sector_size), (uint8_t*)context->csum + (Vcb->csum_size * off))) {
|
||||
RtlSetBit(&context->stripes[stripe].error, i);
|
||||
log_device_error(Vcb, c->devices[stripe], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
||||
|
@ -1843,7 +1833,6 @@ static void scrub_raid5_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
log_error(Vcb, addr, c->devices[parity]->devitem.dev_id, false, true, true);
|
||||
log_device_error(Vcb, c->devices[parity], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
} else if (num_errors == 1) {
|
||||
uint32_t crc32;
|
||||
uint64_t addr = c->offset + (stripe_start * (c->chunk_item->num_stripes - 1) * c->chunk_item->stripe_length) + (bad_off * Vcb->superblock.sector_size);
|
||||
|
||||
if (RtlCheckBit(&context->is_tree, bad_off)) {
|
||||
|
@ -1854,9 +1843,8 @@ static void scrub_raid5_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
Vcb->superblock.node_size);
|
||||
|
||||
th = (tree_header*)&context->parity_scratch[i * Vcb->superblock.sector_size];
|
||||
crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
if (crc32 == *((uint32_t*)th->csum) && th->address == addr) {
|
||||
if (check_tree_checksum(Vcb, th) && th->address == addr) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.node_size);
|
||||
|
||||
|
@ -1868,13 +1856,15 @@ static void scrub_raid5_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
} else
|
||||
log_error(Vcb, addr, c->devices[bad_stripe]->devitem.dev_id, true, false, false);
|
||||
} else {
|
||||
uint8_t hash[MAX_HASH_SIZE];
|
||||
|
||||
do_xor(&context->parity_scratch[i * Vcb->superblock.sector_size],
|
||||
&context->stripes[bad_stripe].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
Vcb->superblock.sector_size);
|
||||
|
||||
crc32 = ~calc_crc32c(0xffffffff, &context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
get_sector_csum(Vcb, &context->parity_scratch[i * Vcb->superblock.sector_size], hash);
|
||||
|
||||
if (crc32 == context->csum[bad_off]) {
|
||||
if (RtlCompareMemory(hash, (uint8_t*)context->csum + (Vcb->csum_size * bad_off), Vcb->csum_size) == Vcb->csum_size) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
|
||||
|
@ -1929,9 +1919,8 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
if (RtlCheckBit(&context->is_tree, off)) {
|
||||
tree_header* th = (tree_header*)&context->stripes[stripe].buf[stripeoff * Vcb->superblock.sector_size];
|
||||
uint64_t addr = c->offset + (stripe_start * (c->chunk_item->num_stripes - 2) * c->chunk_item->stripe_length) + (off * Vcb->superblock.sector_size);
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
if (crc32 != *((uint32_t*)th->csum) || th->address != addr) {
|
||||
if (!check_tree_checksum(Vcb, th) || th->address != addr) {
|
||||
RtlSetBits(&context->stripes[stripe].error, i, Vcb->superblock.node_size / Vcb->superblock.sector_size);
|
||||
log_device_error(Vcb, c->devices[stripe], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
|
||||
|
@ -1945,9 +1934,11 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
|
||||
continue;
|
||||
} else if (RtlCheckBit(&context->has_csum, off)) {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, context->stripes[stripe].buf + (stripeoff * Vcb->superblock.sector_size), Vcb->superblock.sector_size);
|
||||
uint8_t hash[MAX_HASH_SIZE];
|
||||
|
||||
if (crc32 != context->csum[off]) {
|
||||
get_sector_csum(Vcb, context->stripes[stripe].buf + (stripeoff * Vcb->superblock.sector_size), hash);
|
||||
|
||||
if (RtlCompareMemory(hash, (uint8_t*)context->csum + (Vcb->csum_size * off), Vcb->csum_size) != Vcb->csum_size) {
|
||||
uint64_t addr = c->offset + (stripe_start * (c->chunk_item->num_stripes - 2) * c->chunk_item->stripe_length) + (off * Vcb->superblock.sector_size);
|
||||
|
||||
RtlSetBit(&context->stripes[stripe].error, i);
|
||||
|
@ -2081,7 +2072,7 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
log_device_error(Vcb, c->devices[parity2], BTRFS_DEV_STAT_CORRUPTION_ERRORS);
|
||||
}
|
||||
} else if (num_errors == 1) {
|
||||
uint32_t crc32a, crc32b, len;
|
||||
uint32_t len;
|
||||
uint16_t stripe_num, bad_stripe_num;
|
||||
uint64_t addr = c->offset + (stripe_start * (c->chunk_item->num_stripes - 2) * c->chunk_item->stripe_length) + (bad_off1 * Vcb->superblock.sector_size);
|
||||
uint8_t* scratch;
|
||||
|
@ -2122,21 +2113,23 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
}
|
||||
|
||||
if (RtlCheckBit(&context->is_tree, bad_off1)) {
|
||||
uint8_t hash1[MAX_HASH_SIZE];
|
||||
uint8_t hash2[MAX_HASH_SIZE];
|
||||
tree_header *th1 = NULL, *th2 = NULL;
|
||||
|
||||
if (c->devices[parity1]->devobj) {
|
||||
th1 = (tree_header*)&context->parity_scratch[i * Vcb->superblock.sector_size];
|
||||
crc32a = ~calc_crc32c(0xffffffff, (uint8_t*)&th1->fs_uuid, Vcb->superblock.node_size - sizeof(th1->csum));
|
||||
get_tree_checksum(Vcb, th1, hash1);
|
||||
}
|
||||
|
||||
if (c->devices[parity2]->devobj) {
|
||||
th2 = (tree_header*)scratch;
|
||||
crc32b = ~calc_crc32c(0xffffffff, (uint8_t*)&th2->fs_uuid, Vcb->superblock.node_size - sizeof(th2->csum));
|
||||
get_tree_checksum(Vcb, th2, hash2);
|
||||
}
|
||||
|
||||
if ((c->devices[parity1]->devobj && crc32a == *((uint32_t*)th1->csum) && th1->address == addr) ||
|
||||
(c->devices[parity2]->devobj && crc32b == *((uint32_t*)th2->csum) && th2->address == addr)) {
|
||||
if (!c->devices[parity1]->devobj || crc32a != *((uint32_t*)th1->csum) || th1->address != addr) {
|
||||
if ((c->devices[parity1]->devobj && RtlCompareMemory(hash1, th1, Vcb->csum_size) == Vcb->csum_size && th1->address == addr) ||
|
||||
(c->devices[parity2]->devobj && RtlCompareMemory(hash2, th2, Vcb->csum_size) == Vcb->csum_size && th2->address == addr)) {
|
||||
if (!c->devices[parity1]->devobj || RtlCompareMemory(hash1, th1, Vcb->csum_size) != Vcb->csum_size || th1->address != addr) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe1].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
scratch, Vcb->superblock.node_size);
|
||||
|
||||
|
@ -2168,7 +2161,7 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
RtlCopyMemory(&context->stripes[bad_stripe1].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.node_size);
|
||||
|
||||
if (!c->devices[parity2]->devobj || crc32b != *((uint32_t*)th2->csum) || th2->address != addr) {
|
||||
if (!c->devices[parity2]->devobj || RtlCompareMemory(hash2, th2, Vcb->csum_size) != Vcb->csum_size || th2->address != addr) {
|
||||
// fix parity 2
|
||||
stripe = parity1 == 0 ? (c->chunk_item->num_stripes - 1) : (parity1 - 1);
|
||||
|
||||
|
@ -2205,18 +2198,22 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
} else
|
||||
log_error(Vcb, addr, c->devices[bad_stripe1]->devitem.dev_id, true, false, false);
|
||||
} else {
|
||||
uint8_t hash1[MAX_HASH_SIZE];
|
||||
uint8_t hash2[MAX_HASH_SIZE];
|
||||
|
||||
if (c->devices[parity1]->devobj)
|
||||
crc32a = ~calc_crc32c(0xffffffff, &context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
get_sector_csum(Vcb, &context->parity_scratch[i * Vcb->superblock.sector_size], hash1);
|
||||
|
||||
if (c->devices[parity2]->devobj)
|
||||
crc32b = ~calc_crc32c(0xffffffff, scratch, Vcb->superblock.sector_size);
|
||||
get_sector_csum(Vcb, scratch, hash2);
|
||||
|
||||
if ((c->devices[parity1]->devobj && crc32a == context->csum[bad_off1]) || (c->devices[parity2]->devobj && crc32b == context->csum[bad_off1])) {
|
||||
if (c->devices[parity2]->devobj && crc32b == context->csum[bad_off1]) {
|
||||
if ((c->devices[parity1]->devobj && RtlCompareMemory(hash1, (uint8_t*)context->csum + (bad_off1 * Vcb->csum_size), Vcb->csum_size) == Vcb->csum_size) ||
|
||||
(c->devices[parity2]->devobj && RtlCompareMemory(hash2, (uint8_t*)context->csum + (bad_off1 * Vcb->csum_size), Vcb->csum_size) == Vcb->csum_size)) {
|
||||
if (c->devices[parity2]->devobj && RtlCompareMemory(hash2, (uint8_t*)context->csum + (bad_off1 * Vcb->csum_size), Vcb->csum_size) == Vcb->csum_size) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe1].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
scratch, Vcb->superblock.sector_size);
|
||||
|
||||
if (c->devices[parity1]->devobj && crc32a != context->csum[bad_off1]) {
|
||||
if (c->devices[parity1]->devobj && RtlCompareMemory(hash1, (uint8_t*)context->csum + (bad_off1 * Vcb->csum_size), Vcb->csum_size) != Vcb->csum_size) {
|
||||
// fix parity 1
|
||||
|
||||
stripe = (parity1 + 2) % c->chunk_item->num_stripes;
|
||||
|
@ -2244,7 +2241,7 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
RtlCopyMemory(&context->stripes[bad_stripe1].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
|
||||
if (c->devices[parity2]->devobj && crc32b != context->csum[bad_off1]) {
|
||||
if (c->devices[parity2]->devobj && RtlCompareMemory(hash2, (uint8_t*)context->csum + (bad_off1 * Vcb->csum_size), Vcb->csum_size) != Vcb->csum_size) {
|
||||
// fix parity 2
|
||||
stripe = parity1 == 0 ? (c->chunk_item->num_stripes - 1) : (parity1 - 1);
|
||||
|
||||
|
@ -2355,9 +2352,8 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
|
||||
if (RtlCheckBit(&context->is_tree, bad_off1)) {
|
||||
tree_header* th = (tree_header*)&context->parity_scratch[i * Vcb->superblock.sector_size];
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
if (crc32 == *((uint32_t*)th->csum) && th->address == addr) {
|
||||
if (check_tree_checksum(Vcb, th) && th->address == addr) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe1].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.node_size);
|
||||
|
||||
|
@ -2369,9 +2365,7 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
} else
|
||||
log_error(Vcb, addr, c->devices[bad_stripe1]->devitem.dev_id, true, false, false);
|
||||
} else {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, &context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
|
||||
if (crc32 == context->csum[bad_off1]) {
|
||||
if (check_sector_csum(Vcb, &context->parity_scratch[i * Vcb->superblock.sector_size], (uint8_t*)context->csum + (Vcb->csum_size * bad_off1))) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe1].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
|
||||
|
@ -2386,9 +2380,8 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
|
||||
if (RtlCheckBit(&context->is_tree, bad_off2)) {
|
||||
tree_header* th = (tree_header*)&context->parity_scratch2[i * Vcb->superblock.sector_size];
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, Vcb->superblock.node_size - sizeof(th->csum));
|
||||
|
||||
if (crc32 == *((uint32_t*)th->csum) && th->address == addr) {
|
||||
if (check_tree_checksum(Vcb, th) && th->address == addr) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe2].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch2[i * Vcb->superblock.sector_size], Vcb->superblock.node_size);
|
||||
|
||||
|
@ -2400,9 +2393,7 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
|
|||
} else
|
||||
log_error(Vcb, addr, c->devices[bad_stripe2]->devitem.dev_id, true, false, false);
|
||||
} else {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, &context->parity_scratch2[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
|
||||
if (crc32 == context->csum[bad_off2]) {
|
||||
if (check_sector_csum(Vcb, &context->parity_scratch2[i * Vcb->superblock.sector_size], (uint8_t*)context->csum + (Vcb->csum_size * bad_off2))) {
|
||||
RtlCopyMemory(&context->stripes[bad_stripe2].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)],
|
||||
&context->parity_scratch2[i * Vcb->superblock.sector_size], Vcb->superblock.sector_size);
|
||||
|
||||
|
@ -2456,7 +2447,7 @@ static NTSTATUS scrub_chunk_raid56_stripe_run(device_extension* Vcb, chunk* c, u
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2503,7 +2494,7 @@ static NTSTATUS scrub_chunk_raid56_stripe_run(device_extension* Vcb, chunk* c, u
|
|||
RtlInitializeBitMap(&context.has_csum, csumarr, num_sectors);
|
||||
RtlClearAllBits(&context.has_csum);
|
||||
|
||||
context.csum = ExAllocatePoolWithTag(PagedPool, num_sectors * sizeof(uint32_t), ALLOC_TAG);
|
||||
context.csum = ExAllocatePoolWithTag(PagedPool, num_sectors * Vcb->csum_size, ALLOC_TAG);
|
||||
if (!context.csum) {
|
||||
ERR("out of memory\n");
|
||||
ExFreePool(allocarr);
|
||||
|
@ -2553,7 +2544,7 @@ static NTSTATUS scrub_chunk_raid56_stripe_run(device_extension* Vcb, chunk* c, u
|
|||
EXTENT_ITEM* ei = (EXTENT_ITEM*)tp.item->data;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
Status = STATUS_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
@ -2574,7 +2565,7 @@ static NTSTATUS scrub_chunk_raid56_stripe_run(device_extension* Vcb, chunk* c, u
|
|||
|
||||
Status = find_item(Vcb, Vcb->checksum_root, &tp2, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2586,13 +2577,13 @@ static NTSTATUS scrub_chunk_raid56_stripe_run(device_extension* Vcb, chunk* c, u
|
|||
|
||||
if (tp2.item->key.offset >= extent_start) {
|
||||
uint64_t csum_start = max(extent_start, tp2.item->key.offset);
|
||||
uint64_t csum_end = min(extent_end, tp2.item->key.offset + (tp2.item->size * Vcb->superblock.sector_size / sizeof(uint32_t)));
|
||||
uint64_t csum_end = min(extent_end, tp2.item->key.offset + (tp2.item->size * Vcb->superblock.sector_size / Vcb->csum_size));
|
||||
|
||||
RtlSetBits(&context.has_csum, (ULONG)((csum_start - run_start) / Vcb->superblock.sector_size), (ULONG)((csum_end - csum_start) / Vcb->superblock.sector_size));
|
||||
|
||||
RtlCopyMemory(&context.csum[(csum_start - run_start) / Vcb->superblock.sector_size],
|
||||
tp2.item->data + ((csum_start - tp2.item->key.offset) * sizeof(uint32_t) / Vcb->superblock.sector_size),
|
||||
(ULONG)((csum_end - csum_start) * sizeof(uint32_t) / Vcb->superblock.sector_size));
|
||||
RtlCopyMemory((uint8_t*)context.csum + ((csum_start - run_start) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
tp2.item->data + ((csum_start - tp2.item->key.offset) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
(ULONG)((csum_end - csum_start) * Vcb->csum_size / Vcb->superblock.sector_size));
|
||||
}
|
||||
|
||||
b2 = find_next_item(Vcb, &tp2, &next_tp2, false, NULL);
|
||||
|
@ -2723,7 +2714,7 @@ static NTSTATUS scrub_chunk_raid56_stripe_run(device_extension* Vcb, chunk* c, u
|
|||
} _SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("MmProbeAndLockPages threw exception %08x\n", Status);
|
||||
ERR("MmProbeAndLockPages threw exception %08lx\n", Status);
|
||||
IoFreeMdl(context.stripes[i].Irp->MdlAddress);
|
||||
goto end3;
|
||||
}
|
||||
|
@ -2806,7 +2797,7 @@ end3:
|
|||
context.stripes[i].buf, (uint32_t)(read_stripes * c->chunk_item->stripe_length));
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("write_data_phys returned %08x\n", Status);
|
||||
ERR("write_data_phys returned %08lx\n", Status);
|
||||
log_device_error(Vcb, c->devices[i], BTRFS_DEV_STAT_WRITE_ERRORS);
|
||||
goto end2;
|
||||
}
|
||||
|
@ -2862,7 +2853,7 @@ static NTSTATUS scrub_chunk_raid56(device_extension* Vcb, chunk* c, uint64_t* of
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2880,7 +2871,7 @@ static NTSTATUS scrub_chunk_raid56(device_extension* Vcb, chunk* c, uint64_t* of
|
|||
TRACE("%I64x\n", tp.item->key.obj_id);
|
||||
|
||||
if (size < Vcb->superblock.sector_size) {
|
||||
ERR("extent %I64x has size less than sector_size (%I64x < %x)\n", tp.item->key.obj_id, Vcb->superblock.sector_size);
|
||||
ERR("extent %I64x has size less than sector_size (%I64x < %x)\n", tp.item->key.obj_id, size, Vcb->superblock.sector_size);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -2890,7 +2881,7 @@ static NTSTATUS scrub_chunk_raid56(device_extension* Vcb, chunk* c, uint64_t* of
|
|||
if (stripe > stripe_end + 1) {
|
||||
Status = scrub_chunk_raid56_stripe_run(Vcb, c, stripe_start, stripe_end);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_chunk_raid56_stripe_run returned %08x\n", Status);
|
||||
ERR("scrub_chunk_raid56_stripe_run returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2920,7 +2911,7 @@ static NTSTATUS scrub_chunk_raid56(device_extension* Vcb, chunk* c, uint64_t* of
|
|||
if (*changed) {
|
||||
Status = scrub_chunk_raid56_stripe_run(Vcb, c, stripe_start, stripe_end);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_chunk_raid56_stripe_run returned %08x\n", Status);
|
||||
ERR("scrub_chunk_raid56_stripe_run returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2956,7 +2947,11 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
} else if (c->chunk_item->type & BLOCK_FLAG_RAID6) {
|
||||
Status = scrub_chunk_raid56(Vcb, c, offset, changed);
|
||||
goto end;
|
||||
} else // SINGLE
|
||||
} else if (c->chunk_item->type & BLOCK_FLAG_RAID1C3)
|
||||
type = BLOCK_FLAG_DUPLICATE;
|
||||
else if (c->chunk_item->type & BLOCK_FLAG_RAID1C4)
|
||||
type = BLOCK_FLAG_DUPLICATE;
|
||||
else // SINGLE
|
||||
type = BLOCK_FLAG_DUPLICATE;
|
||||
|
||||
searchkey.obj_id = *offset;
|
||||
|
@ -2965,7 +2960,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
|
||||
Status = find_item(Vcb, Vcb->extent_root, &tp, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error - find_item returned %08x\n", Status);
|
||||
ERR("error - find_item returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -2978,7 +2973,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
if (tp.item->key.obj_id >= *offset && (tp.item->key.obj_type == TYPE_EXTENT_ITEM || tp.item->key.obj_type == TYPE_METADATA_ITEM)) {
|
||||
uint64_t size = tp.item->key.obj_type == TYPE_METADATA_ITEM ? Vcb->superblock.node_size : tp.item->key.offset;
|
||||
bool is_tree;
|
||||
uint32_t* csum = NULL;
|
||||
void* csum = NULL;
|
||||
RTL_BITMAP bmp;
|
||||
ULONG* bmparr = NULL, bmplen;
|
||||
|
||||
|
@ -2992,7 +2987,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
EXTENT_ITEM* ei = (EXTENT_ITEM*)tp.item->data;
|
||||
|
||||
if (tp.item->size < sizeof(EXTENT_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", tp.item->key.obj_id, tp.item->key.obj_type, tp.item->key.offset, tp.item->size, sizeof(EXTENT_ITEM));
|
||||
Status = STATUS_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3002,7 +2997,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
}
|
||||
|
||||
if (size < Vcb->superblock.sector_size) {
|
||||
ERR("extent %I64x has size less than sector_size (%I64x < %x)\n", tp.item->key.obj_id, Vcb->superblock.sector_size);
|
||||
ERR("extent %I64x has size less than sector_size (%I64x < %x)\n", tp.item->key.obj_id, size, Vcb->superblock.sector_size);
|
||||
Status = STATUS_INTERNAL_ERROR;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3011,7 +3006,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
if (!is_tree) {
|
||||
traverse_ptr tp2;
|
||||
|
||||
csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(sizeof(uint32_t) * size / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
csum = ExAllocatePoolWithTag(PagedPool, (ULONG)(Vcb->csum_size * size / Vcb->superblock.sector_size), ALLOC_TAG);
|
||||
if (!csum) {
|
||||
ERR("out of memory\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -3037,7 +3032,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
|
||||
Status = find_item(Vcb, Vcb->checksum_root, &tp2, &searchkey, false, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -3050,13 +3045,13 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
if (tp2.item->key.obj_type == TYPE_EXTENT_CSUM) {
|
||||
if (tp2.item->key.offset >= tp.item->key.obj_id + size)
|
||||
break;
|
||||
else if (tp2.item->size >= sizeof(uint32_t) && tp2.item->key.offset + (tp2.item->size * Vcb->superblock.sector_size / sizeof(uint32_t)) >= tp.item->key.obj_id) {
|
||||
else if (tp2.item->size >= Vcb->csum_size && tp2.item->key.offset + (tp2.item->size * Vcb->superblock.sector_size / Vcb->csum_size) >= tp.item->key.obj_id) {
|
||||
uint64_t cs = max(tp.item->key.obj_id, tp2.item->key.offset);
|
||||
uint64_t ce = min(tp.item->key.obj_id + size, tp2.item->key.offset + (tp2.item->size * Vcb->superblock.sector_size / sizeof(uint32_t)));
|
||||
uint64_t ce = min(tp.item->key.obj_id + size, tp2.item->key.offset + (tp2.item->size * Vcb->superblock.sector_size / Vcb->csum_size));
|
||||
|
||||
RtlCopyMemory(csum + ((cs - tp.item->key.obj_id) / Vcb->superblock.sector_size),
|
||||
tp2.item->data + ((cs - tp2.item->key.offset) * sizeof(uint32_t) / Vcb->superblock.sector_size),
|
||||
(ULONG)((ce - cs) * sizeof(uint32_t) / Vcb->superblock.sector_size));
|
||||
RtlCopyMemory((uint8_t*)csum + ((cs - tp.item->key.obj_id) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
tp2.item->data + ((cs - tp2.item->key.offset) * Vcb->csum_size / Vcb->superblock.sector_size),
|
||||
(ULONG)((ce - cs) * Vcb->csum_size / Vcb->superblock.sector_size));
|
||||
|
||||
RtlClearBits(&bmp, (ULONG)((cs - tp.item->key.obj_id) / Vcb->superblock.sector_size), (ULONG)((ce - cs) / Vcb->superblock.sector_size));
|
||||
|
||||
|
@ -3077,7 +3072,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
if (!is_tree || tp.item->key.obj_id > tree_run_end) {
|
||||
Status = scrub_extent(Vcb, c, type, tree_run_start, (uint32_t)(tree_run_end - tree_run_start), NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_extent returned %08x\n", Status);
|
||||
ERR("scrub_extent returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3098,7 +3093,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
if (!is_tree) {
|
||||
Status = scrub_data_extent(Vcb, c, tp.item->key.obj_id, type, csum, &bmp, bmplen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_data_extent returned %08x\n", Status);
|
||||
ERR("scrub_data_extent returned %08lx\n", Status);
|
||||
ExFreePool(csum);
|
||||
ExFreePool(bmparr);
|
||||
goto end;
|
||||
|
@ -3128,7 +3123,7 @@ static NTSTATUS scrub_chunk(device_extension* Vcb, chunk* c, uint64_t* offset, b
|
|||
if (tree_run) {
|
||||
Status = scrub_extent(Vcb, c, type, tree_run_start, (uint32_t)(tree_run_end - tree_run_start), NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_extent returned %08x\n", Status);
|
||||
ERR("scrub_extent returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -3163,7 +3158,7 @@ static void __stdcall scrub_thread(void* context) {
|
|||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ExReleaseResourceLite(&Vcb->tree_lock);
|
||||
ERR("do_write returned %08x\n", Status);
|
||||
ERR("do_write returned %08lx\n", Status);
|
||||
Vcb->scrub.error = Status;
|
||||
goto end;
|
||||
}
|
||||
|
@ -3226,7 +3221,7 @@ static void __stdcall scrub_thread(void* context) {
|
|||
|
||||
Status = scrub_chunk(Vcb, c, &offset, &changed);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("scrub_chunk returned %08x\n", Status);
|
||||
ERR("scrub_chunk returned %08lx\n", Status);
|
||||
Vcb->scrub.stopping = true;
|
||||
Vcb->scrub.error = Status;
|
||||
break;
|
||||
|
@ -3297,7 +3292,7 @@ NTSTATUS start_scrub(device_extension* Vcb, KPROCESSOR_MODE processor_mode) {
|
|||
|
||||
Status = PsCreateSystemThread(&Vcb->scrub.thread, 0, &oa, NULL, NULL, scrub_thread, Vcb);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("PsCreateSystemThread returned %08x\n", Status);
|
||||
ERR("PsCreateSystemThread returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ static bool fs_ignored(BTRFS_UUID* uuid) {
|
|||
Status = ZwCreateKey(&h, KEY_QUERY_VALUE, &oa, 0, NULL, REG_OPTION_NON_VOLATILE, &dispos);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
TRACE("ZwCreateKey returned %08x\n", Status);
|
||||
TRACE("ZwCreateKey returned %08lx\n", Status);
|
||||
ExFreePool(path.Buffer);
|
||||
return false;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ static void test_vol(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
uint8_t* data = NULL;
|
||||
uint32_t sector_size;
|
||||
|
||||
TRACE("%.*S\n", devpath->Length / sizeof(WCHAR), devpath->Buffer);
|
||||
TRACE("%.*S\n", (int)(devpath->Length / sizeof(WCHAR)), devpath->Buffer);
|
||||
|
||||
sector_size = DeviceObject->SectorSize;
|
||||
|
||||
|
@ -134,20 +134,20 @@ static void test_vol(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
&geometry, sizeof(DISK_GEOMETRY), true, &iosb);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("%.*S had a sector size of 0, and IOCTL_DISK_GET_DRIVE_GEOMETRY returned %08x\n",
|
||||
devpath->Length / sizeof(WCHAR), devpath->Buffer, Status);
|
||||
ERR("%.*S had a sector size of 0, and IOCTL_DISK_GET_DRIVE_GEOMETRY returned %08lx\n",
|
||||
(int)(devpath->Length / sizeof(WCHAR)), devpath->Buffer, Status);
|
||||
goto deref;
|
||||
}
|
||||
|
||||
if (iosb.Information < sizeof(DISK_GEOMETRY)) {
|
||||
ERR("%.*S: IOCTL_DISK_GET_DRIVE_GEOMETRY returned %u bytes, expected %u\n",
|
||||
devpath->Length / sizeof(WCHAR), devpath->Buffer, iosb.Information, sizeof(DISK_GEOMETRY));
|
||||
ERR("%.*S: IOCTL_DISK_GET_DRIVE_GEOMETRY returned %Iu bytes, expected %Iu\n",
|
||||
(int)(devpath->Length / sizeof(WCHAR)), devpath->Buffer, iosb.Information, sizeof(DISK_GEOMETRY));
|
||||
}
|
||||
|
||||
sector_size = geometry.BytesPerSector;
|
||||
|
||||
if (sector_size == 0) {
|
||||
ERR("%.*S had a sector size of 0\n", devpath->Length / sizeof(WCHAR), devpath->Buffer);
|
||||
ERR("%.*S had a sector size of 0\n", (int)(devpath->Length / sizeof(WCHAR)), devpath->Buffer);
|
||||
goto deref;
|
||||
}
|
||||
}
|
||||
|
@ -163,11 +163,8 @@ static void test_vol(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
|
||||
if (NT_SUCCESS(Status) && ((superblock*)data)->magic == BTRFS_MAGIC) {
|
||||
superblock* sb = (superblock*)data;
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&sb->uuid, (ULONG)sizeof(superblock) - sizeof(sb->checksum));
|
||||
|
||||
if (crc32 != *((uint32_t*)sb->checksum))
|
||||
ERR("checksum error on superblock\n");
|
||||
else {
|
||||
if (check_superblock_checksum(sb)) {
|
||||
TRACE("volume found\n");
|
||||
|
||||
if (length >= superblock_addrs[1] + toread) {
|
||||
|
@ -183,9 +180,7 @@ static void test_vol(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject,
|
|||
Status = sync_read_phys(DeviceObject, FileObject, superblock_addrs[i], toread, (PUCHAR)sb2, true);
|
||||
|
||||
if (NT_SUCCESS(Status) && sb2->magic == BTRFS_MAGIC) {
|
||||
crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&sb2->uuid, (ULONG)sizeof(superblock) - sizeof(sb2->checksum));
|
||||
|
||||
if (crc32 == *((uint32_t*)sb2->checksum) && sb2->generation > sb->generation)
|
||||
if (check_superblock_checksum(sb2) && sb2->generation > sb->generation)
|
||||
RtlCopyMemory(sb, sb2, toread);
|
||||
}
|
||||
|
||||
|
@ -232,7 +227,7 @@ NTSTATUS remove_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath) {
|
|||
Status = dev_ioctl(mountmgr, IOCTL_MOUNTMGR_DELETE_POINTS, mmp, mmpsize, &mmps1, sizeof(MOUNTMGR_MOUNT_POINTS), false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ERR("IOCTL_MOUNTMGR_DELETE_POINTS 1 returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_DELETE_POINTS 1 returned %08lx\n", Status);
|
||||
ExFreePool(mmp);
|
||||
return Status;
|
||||
}
|
||||
|
@ -252,7 +247,7 @@ NTSTATUS remove_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath) {
|
|||
Status = dev_ioctl(mountmgr, IOCTL_MOUNTMGR_DELETE_POINTS, mmp, mmpsize, mmps2, mmps1.Size, false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IOCTL_MOUNTMGR_DELETE_POINTS 2 returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_DELETE_POINTS 2 returned %08lx\n", Status);
|
||||
|
||||
ExFreePool(mmps2);
|
||||
ExFreePool(mmp);
|
||||
|
@ -277,7 +272,7 @@ void disk_arrival(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath) {
|
|||
Status = IoGetDeviceObjectPointer(devpath, FILE_READ_ATTRIBUTES, &fileobj, &devobj);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ExReleaseResourceLite(&boot_lock);
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -311,18 +306,18 @@ void disk_arrival(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath) {
|
|||
&gli, sizeof(gli), true, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("error reading length information: %08x\n", Status);
|
||||
ERR("error reading length information: %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = dev_ioctl(devobj, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0,
|
||||
&sdn, sizeof(STORAGE_DEVICE_NUMBER), true, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
TRACE("IOCTL_STORAGE_GET_DEVICE_NUMBER returned %08x\n", Status);
|
||||
TRACE("IOCTL_STORAGE_GET_DEVICE_NUMBER returned %08lx\n", Status);
|
||||
sdn.DeviceNumber = 0xffffffff;
|
||||
sdn.PartitionNumber = 0;
|
||||
} else
|
||||
TRACE("DeviceType = %u, DeviceNumber = %u, PartitionNumber = %u\n", sdn.DeviceType, sdn.DeviceNumber, sdn.PartitionNumber);
|
||||
TRACE("DeviceType = %lu, DeviceNumber = %lu, PartitionNumber = %lu\n", sdn.DeviceType, sdn.DeviceNumber, sdn.PartitionNumber);
|
||||
|
||||
test_vol(devobj, fileobj, devpath, sdn.DeviceNumber, sdn.PartitionNumber, gli.Length.QuadPart);
|
||||
|
||||
|
@ -348,13 +343,13 @@ void remove_volume_child(_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lo
|
|||
if (vde->mounted_device && (!Vcb || !Vcb->options.allow_degraded)) {
|
||||
Status = pnp_surprise_removal(vde->mounted_device, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("pnp_surprise_removal returned %08x\n", Status);
|
||||
ERR("pnp_surprise_removal returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (!Vcb || !Vcb->options.allow_degraded) {
|
||||
Status = IoSetDeviceInterfaceState(&vde->bus_name, false);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoSetDeviceInterfaceState returned %08x\n", Status);
|
||||
WARN("IoSetDeviceInterfaceState returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (pdode->children_loaded > 0) {
|
||||
|
@ -367,7 +362,7 @@ void remove_volume_child(_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lo
|
|||
RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
|
||||
Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &FileObject, &mountmgr);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
else {
|
||||
le = pdode->children.Flink;
|
||||
|
||||
|
@ -379,7 +374,7 @@ void remove_volume_child(_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lo
|
|||
|
||||
Status = dev_ioctl(vc2->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, &mdn, sizeof(MOUNTDEV_NAME), true, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
else {
|
||||
MOUNTDEV_NAME* mdn2;
|
||||
ULONG mdnsize = (ULONG)offsetof(MOUNTDEV_NAME, Name[0]) + mdn.NameLength;
|
||||
|
@ -390,7 +385,7 @@ void remove_volume_child(_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lo
|
|||
else {
|
||||
Status = dev_ioctl(vc2->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, mdn2, mdnsize, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
else {
|
||||
UNICODE_STRING name;
|
||||
|
||||
|
@ -399,7 +394,7 @@ void remove_volume_child(_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lo
|
|||
|
||||
Status = mountmgr_add_drive_letter(mountmgr, &name);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("mountmgr_add_drive_letter returned %08x\n", Status);
|
||||
WARN("mountmgr_add_drive_letter returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
ExFreePool(mdn2);
|
||||
|
@ -463,7 +458,7 @@ void remove_volume_child(_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lo
|
|||
|
||||
Status = IoSetDeviceInterfaceState(&vde->bus_name, false);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoSetDeviceInterfaceState returned %08x\n", Status);
|
||||
WARN("IoSetDeviceInterfaceState returned %08lx\n", Status);
|
||||
|
||||
if (vde->pdo->AttachedDevice)
|
||||
IoDetachDevice(vde->pdo);
|
||||
|
@ -501,14 +496,14 @@ void volume_arrival(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath) {
|
|||
GET_LENGTH_INFORMATION gli;
|
||||
NTSTATUS Status;
|
||||
|
||||
TRACE("%.*S\n", devpath->Length / sizeof(WCHAR), devpath->Buffer);
|
||||
TRACE("%.*S\n", (int)(devpath->Length / sizeof(WCHAR)), devpath->Buffer);
|
||||
|
||||
ExAcquireResourceSharedLite(&boot_lock, TRUE);
|
||||
|
||||
Status = IoGetDeviceObjectPointer(devpath, FILE_READ_ATTRIBUTES, &fileobj, &devobj);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ExReleaseResourceLite(&boot_lock);
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -519,22 +514,22 @@ void volume_arrival(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath) {
|
|||
|
||||
Status = dev_ioctl(devobj, IOCTL_VOLUME_ONLINE, NULL, 0, NULL, 0, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
TRACE("IOCTL_VOLUME_ONLINE returned %08x\n", Status);
|
||||
TRACE("IOCTL_VOLUME_ONLINE returned %08lx\n", Status);
|
||||
|
||||
Status = dev_ioctl(devobj, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &gli, sizeof(gli), true, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_DISK_GET_LENGTH_INFO returned %08x\n", Status);
|
||||
ERR("IOCTL_DISK_GET_LENGTH_INFO returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = dev_ioctl(devobj, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0,
|
||||
&sdn, sizeof(STORAGE_DEVICE_NUMBER), true, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
TRACE("IOCTL_STORAGE_GET_DEVICE_NUMBER returned %08x\n", Status);
|
||||
TRACE("IOCTL_STORAGE_GET_DEVICE_NUMBER returned %08lx\n", Status);
|
||||
sdn.DeviceNumber = 0xffffffff;
|
||||
sdn.PartitionNumber = 0;
|
||||
} else
|
||||
TRACE("DeviceType = %u, DeviceNumber = %u, PartitionNumber = %u\n", sdn.DeviceType, sdn.DeviceNumber, sdn.PartitionNumber);
|
||||
TRACE("DeviceType = %lu, DeviceNumber = %lu, PartitionNumber = %lu\n", sdn.DeviceType, sdn.DeviceNumber, sdn.PartitionNumber);
|
||||
|
||||
// If we've just added a partition to a whole-disk filesystem, unmount it
|
||||
if (sdn.DeviceNumber != 0xffffffff && sdn.PartitionNumber != 0) {
|
||||
|
@ -592,7 +587,7 @@ void volume_removal(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath) {
|
|||
LIST_ENTRY* le;
|
||||
UNICODE_STRING devpath2;
|
||||
|
||||
TRACE("%.*S\n", devpath->Length / sizeof(WCHAR), devpath->Buffer);
|
||||
TRACE("%.*S\n", (int)(devpath->Length / sizeof(WCHAR)), devpath->Buffer);
|
||||
|
||||
UNUSED(DriverObject);
|
||||
|
||||
|
@ -624,8 +619,10 @@ void volume_removal(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath) {
|
|||
if (vc->pnp_name.Length == devpath2.Length && RtlCompareMemory(vc->pnp_name.Buffer, devpath2.Buffer, devpath2.Length) == devpath2.Length) {
|
||||
TRACE("removing device\n");
|
||||
|
||||
remove_volume_child(pdode->vde, vc, false);
|
||||
changed = true;
|
||||
if (!vc->boot_volume) {
|
||||
remove_volume_child(pdode->vde, vc, false);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -761,7 +758,7 @@ static void mountmgr_process_drive(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devi
|
|||
|
||||
Status = dev_ioctl(vc->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, &mdn, sizeof(MOUNTDEV_NAME), true, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
else {
|
||||
MOUNTDEV_NAME* mdn2;
|
||||
ULONG mdnsize = (ULONG)offsetof(MOUNTDEV_NAME, Name[0]) + mdn.NameLength;
|
||||
|
@ -772,7 +769,7 @@ static void mountmgr_process_drive(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devi
|
|||
else {
|
||||
Status = dev_ioctl(vc->devobj, IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, NULL, 0, mdn2, mdnsize, true, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTDEV_QUERY_DEVICE_NAME returned %08lx\n", Status);
|
||||
else {
|
||||
if (mdn2->NameLength == device_name->Length && RtlCompareMemory(mdn2->Name, device_name->Buffer, device_name->Length) == device_name->Length) {
|
||||
vc2 = vc;
|
||||
|
@ -802,7 +799,7 @@ static void mountmgr_process_drive(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devi
|
|||
if (need_remove) {
|
||||
Status = remove_drive_letter(mountmgr, device_name);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("remove_drive_letter returned %08x\n", Status);
|
||||
ERR("remove_drive_letter returned %08lx\n", Status);
|
||||
else
|
||||
vc2->had_drive_letter = true;
|
||||
}
|
||||
|
@ -851,7 +848,7 @@ void __stdcall mountmgr_thread(_In_ void* context) {
|
|||
RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
|
||||
Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &FileObject, &mountmgr);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -884,7 +881,7 @@ void __stdcall mountmgr_thread(_In_ void* context) {
|
|||
break;
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_MOUNTMGR_CHANGE_NOTIFY returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_CHANGE_NOTIFY returned %08lx\n", Status);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -896,7 +893,7 @@ void __stdcall mountmgr_thread(_In_ void* context) {
|
|||
false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
|
||||
ERR("IOCTL_MOUNTMGR_QUERY_POINTS 1 returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_QUERY_POINTS 1 returned %08lx\n", Status);
|
||||
else if (mmps.Size > 0) {
|
||||
MOUNTMGR_MOUNT_POINTS* mmps2;
|
||||
|
||||
|
@ -909,7 +906,7 @@ void __stdcall mountmgr_thread(_In_ void* context) {
|
|||
Status = dev_ioctl(mountmgr, IOCTL_MOUNTMGR_QUERY_POINTS, &mmp, sizeof(MOUNTMGR_MOUNT_POINTS), mmps2, mmps.Size,
|
||||
false, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IOCTL_MOUNTMGR_QUERY_POINTS returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_QUERY_POINTS returned %08lx\n", Status);
|
||||
else
|
||||
mountmgr_updated(mountmgr, mmps2);
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ void add_user_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t uid) {
|
|||
}
|
||||
|
||||
i++;
|
||||
TRACE("val = %u, i = %u, ssl = %u\n", (uint32_t)val, i, sidstringlength);
|
||||
TRACE("val = %u, i = %u, ssl = %lu\n", (uint32_t)val, i, sidstringlength);
|
||||
|
||||
if (np == 0) {
|
||||
sid->auth[0] = (uint8_t)((val & 0xff0000000000) >> 40);
|
||||
|
@ -191,7 +191,7 @@ void add_group_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t gid) {
|
|||
}
|
||||
|
||||
i++;
|
||||
TRACE("val = %u, i = %u, ssl = %u\n", (uint32_t)val, i, sidstringlength);
|
||||
TRACE("val = %u, i = %u, ssl = %lu\n", (uint32_t)val, i, sidstringlength);
|
||||
|
||||
if (np == 0) {
|
||||
sid->auth[0] = (uint8_t)((val & 0xff0000000000) >> 40);
|
||||
|
@ -422,20 +422,20 @@ static void get_top_level_sd(fcb* fcb) {
|
|||
Status = RtlCreateSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlCreateSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlCreateSecurityDescriptor returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = uid_to_sid(fcb->inode_item.st_uid, &usersid);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("uid_to_sid returned %08x\n", Status);
|
||||
ERR("uid_to_sid returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
Status = RtlSetOwnerSecurityDescriptor(&sd, usersid, false);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlSetOwnerSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlSetOwnerSecurityDescriptor returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ static void get_top_level_sd(fcb* fcb) {
|
|||
Status = RtlSetGroupSecurityDescriptor(&sd, groupsid, false);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlSetGroupSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlSetGroupSecurityDescriptor returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ static void get_top_level_sd(fcb* fcb) {
|
|||
Status = RtlSetDaclSecurityDescriptor(&sd, true, acl, false);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlSetDaclSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlSetDaclSecurityDescriptor returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ static void get_top_level_sd(fcb* fcb) {
|
|||
// get sd size
|
||||
Status = RtlAbsoluteToSelfRelativeSD(&sd, NULL, &buflen);
|
||||
if (Status != STATUS_SUCCESS && Status != STATUS_BUFFER_TOO_SMALL) {
|
||||
ERR("RtlAbsoluteToSelfRelativeSD 1 returned %08x\n", Status);
|
||||
ERR("RtlAbsoluteToSelfRelativeSD 1 returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ static void get_top_level_sd(fcb* fcb) {
|
|||
Status = RtlAbsoluteToSelfRelativeSD(&sd, fcb->sd, &buflen);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlAbsoluteToSelfRelativeSD 2 returned %08x\n", Status);
|
||||
ERR("RtlAbsoluteToSelfRelativeSD 2 returned %08lx\n", Status);
|
||||
ExFreePool(fcb->sd);
|
||||
fcb->sd = NULL;
|
||||
goto end;
|
||||
|
@ -513,6 +513,12 @@ void fcb_get_sd(fcb* fcb, struct _fcb* parent, bool look_for_xattr, PIRP Irp) {
|
|||
PSID usersid = NULL, groupsid = NULL;
|
||||
SECURITY_SUBJECT_CONTEXT subjcont;
|
||||
ULONG buflen;
|
||||
PSECURITY_DESCRIPTOR* abssd;
|
||||
PSECURITY_DESCRIPTOR newsd;
|
||||
PACL dacl, sacl;
|
||||
PSID owner, group;
|
||||
ULONG abssdlen = 0, dacllen = 0, sacllen = 0, ownerlen = 0, grouplen = 0;
|
||||
uint8_t* buf;
|
||||
|
||||
if (look_for_xattr && get_xattr(fcb->Vcb, fcb->subvol, fcb->inode, EA_NTACL, EA_NTACL_HASH, (uint8_t**)&fcb->sd, (uint16_t*)&buflen, Irp))
|
||||
return;
|
||||
|
@ -527,29 +533,104 @@ void fcb_get_sd(fcb* fcb, struct _fcb* parent, bool look_for_xattr, PIRP Irp) {
|
|||
Status = SeAssignSecurityEx(parent->sd, NULL, (void**)&fcb->sd, NULL, fcb->type == BTRFS_TYPE_DIRECTORY, SEF_DACL_AUTO_INHERIT,
|
||||
&subjcont, IoGetFileObjectGenericMapping(), PagedPool);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("SeAssignSecurityEx returned %08x\n", Status);
|
||||
ERR("SeAssignSecurityEx returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = RtlSelfRelativeToAbsoluteSD(fcb->sd, NULL, &abssdlen, NULL, &dacllen, NULL, &sacllen, NULL, &ownerlen,
|
||||
NULL, &grouplen);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_TOO_SMALL) {
|
||||
ERR("RtlSelfRelativeToAbsoluteSD returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
if (abssdlen + dacllen + sacllen + ownerlen + grouplen == 0) {
|
||||
ERR("RtlSelfRelativeToAbsoluteSD returned zero lengths\n");
|
||||
return;
|
||||
}
|
||||
|
||||
buf = (uint8_t*)ExAllocatePoolWithTag(PagedPool, abssdlen + dacllen + sacllen + ownerlen + grouplen, ALLOC_TAG);
|
||||
if (!buf) {
|
||||
ERR("out of memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
abssd = (PSECURITY_DESCRIPTOR)buf;
|
||||
dacl = (PACL)(buf + abssdlen);
|
||||
sacl = (PACL)(buf + abssdlen + dacllen);
|
||||
owner = (PSID)(buf + abssdlen + dacllen + sacllen);
|
||||
group = (PSID)(buf + abssdlen + dacllen + sacllen + ownerlen);
|
||||
|
||||
Status = RtlSelfRelativeToAbsoluteSD(fcb->sd, abssd, &abssdlen, dacl, &dacllen, sacl, &sacllen, owner, &ownerlen,
|
||||
group, &grouplen);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_TOO_SMALL) {
|
||||
ERR("RtlSelfRelativeToAbsoluteSD returned %08lx\n", Status);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = uid_to_sid(fcb->inode_item.st_uid, &usersid);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("uid_to_sid returned %08x\n", Status);
|
||||
ERR("uid_to_sid returned %08lx\n", Status);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
RtlSetOwnerSecurityDescriptor(&fcb->sd, usersid, false);
|
||||
RtlSetOwnerSecurityDescriptor(abssd, usersid, false);
|
||||
|
||||
gid_to_sid(fcb->inode_item.st_gid, &groupsid);
|
||||
if (!groupsid) {
|
||||
ERR("out of memory\n");
|
||||
ExFreePool(usersid);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
RtlSetGroupSecurityDescriptor(&fcb->sd, groupsid, false);
|
||||
RtlSetGroupSecurityDescriptor(abssd, groupsid, false);
|
||||
|
||||
buflen = 0;
|
||||
|
||||
Status = RtlAbsoluteToSelfRelativeSD(abssd, NULL, &buflen);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_TOO_SMALL) {
|
||||
ERR("RtlAbsoluteToSelfRelativeSD returned %08lx\n", Status);
|
||||
ExFreePool(usersid);
|
||||
ExFreePool(groupsid);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (buflen == 0) {
|
||||
ERR("RtlAbsoluteToSelfRelativeSD returned a buffer size of 0\n");
|
||||
ExFreePool(usersid);
|
||||
ExFreePool(groupsid);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
newsd = ExAllocatePoolWithTag(PagedPool, buflen, ALLOC_TAG);
|
||||
if (!newsd) {
|
||||
ERR("out of memory\n");
|
||||
ExFreePool(usersid);
|
||||
ExFreePool(groupsid);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = RtlAbsoluteToSelfRelativeSD(abssd, newsd, &buflen);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlAbsoluteToSelfRelativeSD returned %08lx\n", Status);
|
||||
ExFreePool(usersid);
|
||||
ExFreePool(groupsid);
|
||||
ExFreePool(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
ExFreePool(fcb->sd);
|
||||
fcb->sd = newsd;
|
||||
|
||||
ExFreePool(usersid);
|
||||
ExFreePool(groupsid);
|
||||
ExFreePool(buf);
|
||||
}
|
||||
|
||||
static NTSTATUS get_file_security(PFILE_OBJECT FileObject, SECURITY_DESCRIPTOR* relsd, ULONG* buflen, SECURITY_INFORMATION flags) {
|
||||
|
@ -571,9 +652,9 @@ static NTSTATUS get_file_security(PFILE_OBJECT FileObject, SECURITY_DESCRIPTOR*
|
|||
Status = SeQuerySecurityDescriptorInfo(&flags, relsd, buflen, (void**)&fcb->sd);
|
||||
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
TRACE("SeQuerySecurityDescriptorInfo returned %08x\n", Status);
|
||||
TRACE("SeQuerySecurityDescriptorInfo returned %08lx\n", Status);
|
||||
else if (!NT_SUCCESS(Status))
|
||||
ERR("SeQuerySecurityDescriptorInfo returned %08x\n", Status);
|
||||
ERR("SeQuerySecurityDescriptorInfo returned %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -632,7 +713,7 @@ NTSTATUS __stdcall drv_query_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Ir
|
|||
if (IrpSp->Parameters.QuerySecurity.SecurityInformation & SACL_SECURITY_INFORMATION)
|
||||
TRACE("SACL_SECURITY_INFORMATION\n");
|
||||
|
||||
TRACE("length = %u\n", IrpSp->Parameters.QuerySecurity.Length);
|
||||
TRACE("length = %lu\n", IrpSp->Parameters.QuerySecurity.Length);
|
||||
|
||||
sd = map_user_buffer(Irp, NormalPagePriority);
|
||||
TRACE("sd = %p\n", sd);
|
||||
|
@ -656,7 +737,7 @@ NTSTATUS __stdcall drv_query_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Ir
|
|||
Irp->IoStatus.Information = 0;
|
||||
|
||||
end:
|
||||
TRACE("Irp->IoStatus.Information = %u\n", Irp->IoStatus.Information);
|
||||
TRACE("Irp->IoStatus.Information = %Iu\n", Irp->IoStatus.Information);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
|
@ -665,7 +746,7 @@ end:
|
|||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
FsRtlExitFileSystem();
|
||||
|
||||
|
@ -681,7 +762,7 @@ static NTSTATUS set_file_security(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
LARGE_INTEGER time;
|
||||
BTRFS_TIME now;
|
||||
|
||||
TRACE("(%p, %p, %p, %x)\n", Vcb, FileObject, sd, *flags);
|
||||
TRACE("(%p, %p, %p, %lx)\n", Vcb, FileObject, sd, *flags);
|
||||
|
||||
if (Vcb->readonly)
|
||||
return STATUS_MEDIA_WRITE_PROTECTED;
|
||||
|
@ -710,7 +791,7 @@ static NTSTATUS set_file_security(device_extension* Vcb, PFILE_OBJECT FileObject
|
|||
Status = SeSetSecurityDescriptorInfo(NULL, flags, sd, (void**)&fcb->sd, PagedPool, IoGetFileObjectGenericMapping());
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("SeSetSecurityDescriptorInfo returned %08x\n", Status);
|
||||
ERR("SeSetSecurityDescriptorInfo returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -812,7 +893,7 @@ end:
|
|||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
@ -860,7 +941,7 @@ void find_gid(struct _fcb* fcb, struct _fcb* parfcb, PSECURITY_SUBJECT_CONTEXT s
|
|||
|
||||
Status = SeQueryInformationToken(subjcont->PrimaryToken, TokenOwner, (void**)&to);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("SeQueryInformationToken returned %08x\n", Status);
|
||||
ERR("SeQueryInformationToken returned %08lx\n", Status);
|
||||
else {
|
||||
if (search_for_gid(fcb, to->Owner)) {
|
||||
ExReleaseResourceLite(&mapping_lock);
|
||||
|
@ -873,7 +954,7 @@ void find_gid(struct _fcb* fcb, struct _fcb* parfcb, PSECURITY_SUBJECT_CONTEXT s
|
|||
|
||||
Status = SeQueryInformationToken(subjcont->PrimaryToken, TokenPrimaryGroup, (void**)&tpg);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("SeQueryInformationToken returned %08x\n", Status);
|
||||
ERR("SeQueryInformationToken returned %08lx\n", Status);
|
||||
else {
|
||||
if (search_for_gid(fcb, tpg->PrimaryGroup)) {
|
||||
ExReleaseResourceLite(&mapping_lock);
|
||||
|
@ -886,7 +967,7 @@ void find_gid(struct _fcb* fcb, struct _fcb* parfcb, PSECURITY_SUBJECT_CONTEXT s
|
|||
|
||||
Status = SeQueryInformationToken(subjcont->PrimaryToken, TokenGroups, (void**)&tg);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("SeQueryInformationToken returned %08x\n", Status);
|
||||
ERR("SeQueryInformationToken returned %08lx\n", Status);
|
||||
else {
|
||||
ULONG i;
|
||||
|
||||
|
@ -913,13 +994,13 @@ NTSTATUS fcb_get_new_sd(fcb* fcb, file_ref* parfileref, ACCESS_STATE* as) {
|
|||
SEF_SACL_AUTO_INHERIT, &as->SubjectSecurityContext, IoGetFileObjectGenericMapping(), PagedPool);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("SeAssignSecurityEx returned %08x\n", Status);
|
||||
ERR("SeAssignSecurityEx returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = RtlGetOwnerSecurityDescriptor(fcb->sd, &owner, &defaulted);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("RtlGetOwnerSecurityDescriptor returned %08x\n", Status);
|
||||
ERR("RtlGetOwnerSecurityDescriptor returned %08lx\n", Status);
|
||||
fcb->inode_item.st_uid = UID_NOBODY;
|
||||
} else {
|
||||
fcb->inode_item.st_uid = sid_to_uid(owner);
|
||||
|
|
File diff suppressed because it is too large
Load diff
221
drivers/filesystems/btrfs/sha256.c
Normal file
221
drivers/filesystems/btrfs/sha256.c
Normal file
|
@ -0,0 +1,221 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// Public domain code from https://github.com/amosnier/sha-2
|
||||
|
||||
// FIXME - x86 SHA extensions
|
||||
|
||||
#define CHUNK_SIZE 64
|
||||
#define TOTAL_LEN_LEN 8
|
||||
|
||||
/*
|
||||
* ABOUT bool: this file does not use bool in order to be as pre-C99 compatible as possible.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Comments from pseudo-code at https://en.wikipedia.org/wiki/SHA-2 are reproduced here.
|
||||
* When useful for clarification, portions of the pseudo-code are reproduced here too.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize array of round constants:
|
||||
* (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311):
|
||||
*/
|
||||
static const uint32_t k[] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
struct buffer_state {
|
||||
const uint8_t * p;
|
||||
size_t len;
|
||||
size_t total_len;
|
||||
int single_one_delivered; /* bool */
|
||||
int total_len_delivered; /* bool */
|
||||
};
|
||||
|
||||
static inline uint32_t right_rot(uint32_t value, unsigned int count)
|
||||
{
|
||||
/*
|
||||
* Defined behaviour in standard C for all count where 0 < count < 32,
|
||||
* which is what we need here.
|
||||
*/
|
||||
return value >> count | value << (32 - count);
|
||||
}
|
||||
|
||||
static void init_buf_state(struct buffer_state * state, const void * input, size_t len)
|
||||
{
|
||||
state->p = input;
|
||||
state->len = len;
|
||||
state->total_len = len;
|
||||
state->single_one_delivered = 0;
|
||||
state->total_len_delivered = 0;
|
||||
}
|
||||
|
||||
/* Return value: bool */
|
||||
static int calc_chunk(uint8_t chunk[CHUNK_SIZE], struct buffer_state * state)
|
||||
{
|
||||
size_t space_in_chunk;
|
||||
|
||||
if (state->total_len_delivered) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (state->len >= CHUNK_SIZE) {
|
||||
memcpy(chunk, state->p, CHUNK_SIZE);
|
||||
state->p += CHUNK_SIZE;
|
||||
state->len -= CHUNK_SIZE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
memcpy(chunk, state->p, state->len);
|
||||
chunk += state->len;
|
||||
space_in_chunk = CHUNK_SIZE - state->len;
|
||||
state->p += state->len;
|
||||
state->len = 0;
|
||||
|
||||
/* If we are here, space_in_chunk is one at minimum. */
|
||||
if (!state->single_one_delivered) {
|
||||
*chunk++ = 0x80;
|
||||
space_in_chunk -= 1;
|
||||
state->single_one_delivered = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now:
|
||||
* - either there is enough space left for the total length, and we can conclude,
|
||||
* - or there is too little space left, and we have to pad the rest of this chunk with zeroes.
|
||||
* In the latter case, we will conclude at the next invokation of this function.
|
||||
*/
|
||||
if (space_in_chunk >= TOTAL_LEN_LEN) {
|
||||
const size_t left = space_in_chunk - TOTAL_LEN_LEN;
|
||||
size_t len = state->total_len;
|
||||
int i;
|
||||
memset(chunk, 0x00, left);
|
||||
chunk += left;
|
||||
|
||||
/* Storing of len * 8 as a big endian 64-bit without overflow. */
|
||||
chunk[7] = (uint8_t) (len << 3);
|
||||
len >>= 5;
|
||||
for (i = 6; i >= 0; i--) {
|
||||
chunk[i] = (uint8_t) len;
|
||||
len >>= 8;
|
||||
}
|
||||
state->total_len_delivered = 1;
|
||||
} else {
|
||||
memset(chunk, 0x00, space_in_chunk);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Limitations:
|
||||
* - Since input is a pointer in RAM, the data to hash should be in RAM, which could be a problem
|
||||
* for large data sizes.
|
||||
* - SHA algorithms theoretically operate on bit strings. However, this implementation has no support
|
||||
* for bit string lengths that are not multiples of eight, and it really operates on arrays of bytes.
|
||||
* In particular, the len parameter is a number of bytes.
|
||||
*/
|
||||
void calc_sha256(uint8_t* hash, const void* input, size_t len)
|
||||
{
|
||||
/*
|
||||
* Note 1: All integers (expect indexes) are 32-bit unsigned integers and addition is calculated modulo 2^32.
|
||||
* Note 2: For each round, there is one round constant k[i] and one entry in the message schedule array w[i], 0 = i = 63
|
||||
* Note 3: The compression function uses 8 working variables, a through h
|
||||
* Note 4: Big-endian convention is used when expressing the constants in this pseudocode,
|
||||
* and when parsing message block data from bytes to words, for example,
|
||||
* the first word of the input message "abc" after padding is 0x61626380
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize hash values:
|
||||
* (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
||||
*/
|
||||
uint32_t h[] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
|
||||
unsigned i, j;
|
||||
|
||||
/* 512-bit chunks is what we will operate on. */
|
||||
uint8_t chunk[64];
|
||||
|
||||
struct buffer_state state;
|
||||
|
||||
init_buf_state(&state, input, len);
|
||||
|
||||
while (calc_chunk(chunk, &state)) {
|
||||
uint32_t ah[8];
|
||||
|
||||
const uint8_t *p = chunk;
|
||||
|
||||
/* Initialize working variables to current hash value: */
|
||||
for (i = 0; i < 8; i++)
|
||||
ah[i] = h[i];
|
||||
|
||||
/* Compression function main loop: */
|
||||
for (i = 0; i < 4; i++) {
|
||||
/*
|
||||
* The w-array is really w[64], but since we only need
|
||||
* 16 of them at a time, we save stack by calculating
|
||||
* 16 at a time.
|
||||
*
|
||||
* This optimization was not there initially and the
|
||||
* rest of the comments about w[64] are kept in their
|
||||
* initial state.
|
||||
*/
|
||||
|
||||
/*
|
||||
* create a 64-entry message schedule array w[0..63] of 32-bit words
|
||||
* (The initial values in w[0..63] don't matter, so many implementations zero them here)
|
||||
* copy chunk into first 16 words w[0..15] of the message schedule array
|
||||
*/
|
||||
uint32_t w[16];
|
||||
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (i == 0) {
|
||||
w[j] = (uint32_t) p[0] << 24 | (uint32_t) p[1] << 16 |
|
||||
(uint32_t) p[2] << 8 | (uint32_t) p[3];
|
||||
p += 4;
|
||||
} else {
|
||||
/* Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: */
|
||||
const uint32_t s0 = right_rot(w[(j + 1) & 0xf], 7) ^ right_rot(w[(j + 1) & 0xf], 18) ^ (w[(j + 1) & 0xf] >> 3);
|
||||
const uint32_t s1 = right_rot(w[(j + 14) & 0xf], 17) ^ right_rot(w[(j + 14) & 0xf], 19) ^ (w[(j + 14) & 0xf] >> 10);
|
||||
w[j] = w[j] + s0 + w[(j + 9) & 0xf] + s1;
|
||||
}
|
||||
const uint32_t s1 = right_rot(ah[4], 6) ^ right_rot(ah[4], 11) ^ right_rot(ah[4], 25);
|
||||
const uint32_t ch = (ah[4] & ah[5]) ^ (~ah[4] & ah[6]);
|
||||
const uint32_t temp1 = ah[7] + s1 + ch + k[i << 4 | j] + w[j];
|
||||
const uint32_t s0 = right_rot(ah[0], 2) ^ right_rot(ah[0], 13) ^ right_rot(ah[0], 22);
|
||||
const uint32_t maj = (ah[0] & ah[1]) ^ (ah[0] & ah[2]) ^ (ah[1] & ah[2]);
|
||||
const uint32_t temp2 = s0 + maj;
|
||||
|
||||
ah[7] = ah[6];
|
||||
ah[6] = ah[5];
|
||||
ah[5] = ah[4];
|
||||
ah[4] = ah[3] + temp1;
|
||||
ah[3] = ah[2];
|
||||
ah[2] = ah[1];
|
||||
ah[1] = ah[0];
|
||||
ah[0] = temp1 + temp2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the compressed chunk to the current hash value: */
|
||||
for (i = 0; i < 8; i++)
|
||||
h[i] += ah[i];
|
||||
}
|
||||
|
||||
/* Produce the final hash value (big-endian): */
|
||||
for (i = 0, j = 0; i < 8; i++)
|
||||
{
|
||||
hash[j++] = (uint8_t) (h[i] >> 24);
|
||||
hash[j++] = (uint8_t) (h[i] >> 16);
|
||||
hash[j++] = (uint8_t) (h[i] >> 8);
|
||||
hash[j++] = (uint8_t) h[i];
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
* along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "btrfs_drv.h"
|
||||
#include "crc32c.h"
|
||||
|
||||
NTSTATUS load_tree(device_extension* Vcb, uint64_t addr, uint8_t* buf, root* r, tree** pt) {
|
||||
tree_header* th;
|
||||
|
@ -66,7 +67,7 @@ NTSTATUS load_tree(device_extension* Vcb, uint64_t addr, uint8_t* buf, root* r,
|
|||
unsigned int i;
|
||||
|
||||
if ((t->header.num_items * sizeof(leaf_node)) + sizeof(tree_header) > Vcb->superblock.node_size) {
|
||||
ERR("tree at %I64x has more items than expected (%x)\n", t->header.num_items);
|
||||
ERR("tree at %I64x has more items than expected (%x)\n", addr, t->header.num_items);
|
||||
ExFreePool(t);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ NTSTATUS load_tree(device_extension* Vcb, uint64_t addr, uint8_t* buf, root* r,
|
|||
td->data = NULL;
|
||||
|
||||
if (ln[i].size + sizeof(tree_header) + sizeof(leaf_node) > Vcb->superblock.node_size) {
|
||||
ERR("overlarge item in tree %I64x: %u > %u\n", addr, ln[i].size, Vcb->superblock.node_size - sizeof(tree_header) - sizeof(leaf_node));
|
||||
ERR("overlarge item in tree %I64x: %u > %Iu\n", addr, ln[i].size, Vcb->superblock.node_size - sizeof(tree_header) - sizeof(leaf_node));
|
||||
ExFreeToPagedLookasideList(&t->Vcb->tree_data_lookaside, td);
|
||||
ExFreePool(t);
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
|
@ -109,7 +110,7 @@ NTSTATUS load_tree(device_extension* Vcb, uint64_t addr, uint8_t* buf, root* r,
|
|||
unsigned int i;
|
||||
|
||||
if ((t->header.num_items * sizeof(internal_node)) + sizeof(tree_header) > Vcb->superblock.node_size) {
|
||||
ERR("tree at %I64x has more items than expected (%x)\n", t->header.num_items);
|
||||
ERR("tree at %I64x has more items than expected (%x)\n", addr, t->header.num_items);
|
||||
ExFreePool(t);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
@ -197,7 +198,7 @@ static NTSTATUS do_load_tree2(device_extension* Vcb, tree_holder* th, uint8_t* b
|
|||
|
||||
Status = load_tree(Vcb, th->address, buf, r, &nt);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("load_tree returned %08x\n", Status);
|
||||
ERR("load_tree returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -229,7 +230,7 @@ NTSTATUS do_load_tree(device_extension* Vcb, tree_holder* th, root* r, tree* t,
|
|||
Status = read_data(Vcb, th->address, Vcb->superblock.node_size, NULL, true, buf, NULL,
|
||||
&c, Irp, th->generation, false, NormalPagePriority);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("read_data returned 0x%08x\n", Status);
|
||||
ERR("read_data returned 0x%08lx\n", Status);
|
||||
ExFreePool(buf);
|
||||
return Status;
|
||||
}
|
||||
|
@ -250,7 +251,7 @@ NTSTATUS do_load_tree(device_extension* Vcb, tree_holder* th, root* r, tree* t,
|
|||
ExFreePool(buf);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree2 returned %08x\n", Status);
|
||||
ERR("do_load_tree2 returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -387,7 +388,7 @@ NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_pt
|
|||
if (Status == STATUS_NOT_FOUND)
|
||||
*ended1 = true;
|
||||
else if (!NT_SUCCESS(Status)) {
|
||||
ERR("next_item2 returned %08x\n", Status);
|
||||
ERR("next_item2 returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -395,7 +396,7 @@ NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_pt
|
|||
if (Status == STATUS_NOT_FOUND)
|
||||
*ended2 = true;
|
||||
else if (!NT_SUCCESS(Status)) {
|
||||
ERR("next_item2 returned %08x\n", Status);
|
||||
ERR("next_item2 returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -403,13 +404,13 @@ NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_pt
|
|||
if (!*ended1) {
|
||||
Status = find_item(Vcb, t1->root, tp, &tp3.item->key, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (!*ended2) {
|
||||
Status = find_item(Vcb, t2->root, tp2, &tp4.item->key, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -420,13 +421,13 @@ NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_pt
|
|||
if (tp3.tree->header.address != tp4.tree->header.address) {
|
||||
Status = find_item(Vcb, t1->root, tp, &tp3.item->key, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = find_item(Vcb, t2->root, tp2, &tp4.item->key, false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -534,7 +535,7 @@ static NTSTATUS find_item_in_tree(device_extension* Vcb, tree* t, traverse_ptr*
|
|||
if (!td->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &td->treeholder, t->root, t, td, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -552,14 +553,14 @@ NTSTATUS find_item(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension
|
|||
if (!r->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &r->treeholder, r, NULL, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Status = find_item_in_tree(Vcb, r->treeholder.tree, tp, searchkey, ignore, 0, Irp);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("find_item_in_tree returned %08x\n", Status);
|
||||
ERR("find_item_in_tree returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
@ -571,14 +572,14 @@ NTSTATUS find_item_to_level(device_extension* Vcb, root* r, traverse_ptr* tp, co
|
|||
if (!r->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &r->treeholder, r, NULL, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Status = find_item_in_tree(Vcb, r->treeholder.tree, tp, searchkey, ignore, level, Irp);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_FOUND) {
|
||||
ERR("find_item_in_tree returned %08x\n", Status);
|
||||
ERR("find_item_in_tree returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
if (Status == STATUS_NOT_FOUND) {
|
||||
|
@ -635,7 +636,7 @@ bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vc
|
|||
if (!td->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &td->treeholder, t->parent->root, t->parent, td, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -650,7 +651,7 @@ bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vc
|
|||
if (!fi->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &fi->treeholder, t->parent->root, t, fi, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +725,7 @@ bool find_prev_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vc
|
|||
if (!td->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &td->treeholder, t->parent->root, t->parent, td, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -739,7 +740,7 @@ bool find_prev_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vc
|
|||
if (!li->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &li->treeholder, t->parent->root, t, li, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -814,7 +815,7 @@ void free_trees(device_extension* Vcb) {
|
|||
r->treeholder.tree = NULL;
|
||||
|
||||
if (IsListEmpty(&Vcb->trees))
|
||||
return;
|
||||
break;
|
||||
} else if (t->header.level > level)
|
||||
empty = false;
|
||||
|
||||
|
@ -880,7 +881,7 @@ NTSTATUS insert_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
if (!r->treeholder.tree) {
|
||||
Status = do_load_tree(Vcb, &r->treeholder, r, NULL, NULL, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("do_load_tree returned %08x\n", Status);
|
||||
ERR("do_load_tree returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -893,11 +894,11 @@ NTSTATUS insert_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock)
|
|||
return STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
ERR("error: find_item returned %08x\n", Status);
|
||||
ERR("error: find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
} else if (!NT_SUCCESS(Status)) {
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1074,7 @@ void do_rollback(device_extension* Vcb, LIST_ENTRY* rollback) {
|
|||
re->fcb->inode_item.flags & BTRFS_INODE_NODATASUM, false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("update_changed_extent_ref returned %08x\n", Status);
|
||||
ERR("update_changed_extent_ref returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
re->fcb->inode_item.st_blocks -= ed2->num_bytes;
|
||||
|
@ -1102,7 +1103,7 @@ void do_rollback(device_extension* Vcb, LIST_ENTRY* rollback) {
|
|||
re->fcb->inode_item.flags & BTRFS_INODE_NODATASUM, false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("update_changed_extent_ref returned %08x\n", Status);
|
||||
ERR("update_changed_extent_ref returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
re->fcb->inode_item.st_blocks += ed2->num_bytes;
|
||||
|
@ -1273,7 +1274,7 @@ static NTSTATUS handle_batch_collision(device_extension* Vcb, batch_item* bi, tr
|
|||
switch (bi->operation) {
|
||||
case Batch_SetXattr: {
|
||||
if (td->size < sizeof(DIR_ITEM)) {
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %u\n", bi->key.obj_id, bi->key.obj_type, bi->key.offset, td->size, sizeof(DIR_ITEM));
|
||||
ERR("(%I64x,%x,%I64x) was %u bytes, expected at least %Iu\n", bi->key.obj_id, bi->key.obj_type, bi->key.offset, td->size, sizeof(DIR_ITEM));
|
||||
} else {
|
||||
uint8_t* newdata;
|
||||
ULONG size = td->size;
|
||||
|
@ -1296,7 +1297,7 @@ static NTSTATUS handle_batch_collision(device_extension* Vcb, batch_item* bi, tr
|
|||
// replace
|
||||
|
||||
if (td->size + bi->datalen - oldxasize > maxlen)
|
||||
ERR("DIR_ITEM would be over maximum size, truncating (%u + %u - %u > %u)\n", td->size, bi->datalen, oldxasize, maxlen);
|
||||
ERR("DIR_ITEM would be over maximum size, truncating (%u + %u - %lu > %u)\n", td->size, bi->datalen, oldxasize, maxlen);
|
||||
|
||||
newdata = ExAllocatePoolWithTag(PagedPool, td->size + bi->datalen - oldxasize, ALLOC_TAG);
|
||||
if (!newdata) {
|
||||
|
@ -1492,7 +1493,7 @@ static NTSTATUS handle_batch_collision(device_extension* Vcb, batch_item* bi, tr
|
|||
|
||||
case Batch_DeleteDirItem: {
|
||||
if (td->size < sizeof(DIR_ITEM)) {
|
||||
ERR("DIR_ITEM was %u bytes, expected at least %u\n", td->size, sizeof(DIR_ITEM));
|
||||
ERR("DIR_ITEM was %u bytes, expected at least %Iu\n", td->size, sizeof(DIR_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
} else {
|
||||
DIR_ITEM *di, *deldi;
|
||||
|
@ -1567,7 +1568,7 @@ static NTSTATUS handle_batch_collision(device_extension* Vcb, batch_item* bi, tr
|
|||
|
||||
case Batch_DeleteInodeRef: {
|
||||
if (td->size < sizeof(INODE_REF)) {
|
||||
ERR("INODE_REF was %u bytes, expected at least %u\n", td->size, sizeof(INODE_REF));
|
||||
ERR("INODE_REF was %u bytes, expected at least %Iu\n", td->size, sizeof(INODE_REF));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
} else {
|
||||
INODE_REF *ir, *delir;
|
||||
|
@ -1664,7 +1665,7 @@ static NTSTATUS handle_batch_collision(device_extension* Vcb, batch_item* bi, tr
|
|||
|
||||
case Batch_DeleteInodeExtRef: {
|
||||
if (td->size < sizeof(INODE_EXTREF)) {
|
||||
ERR("INODE_EXTREF was %u bytes, expected at least %u\n", td->size, sizeof(INODE_EXTREF));
|
||||
ERR("INODE_EXTREF was %u bytes, expected at least %Iu\n", td->size, sizeof(INODE_EXTREF));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
} else {
|
||||
INODE_EXTREF *ier, *delier;
|
||||
|
@ -1745,7 +1746,7 @@ static NTSTATUS handle_batch_collision(device_extension* Vcb, batch_item* bi, tr
|
|||
|
||||
case Batch_DeleteXattr: {
|
||||
if (td->size < sizeof(DIR_ITEM)) {
|
||||
ERR("XATTR_ITEM was %u bytes, expected at least %u\n", td->size, sizeof(DIR_ITEM));
|
||||
ERR("XATTR_ITEM was %u bytes, expected at least %Iu\n", td->size, sizeof(DIR_ITEM));
|
||||
return STATUS_INTERNAL_ERROR;
|
||||
} else {
|
||||
DIR_ITEM *di, *deldi;
|
||||
|
@ -1870,7 +1871,7 @@ static NTSTATUS commit_batch_list_root(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
|
||||
Status = find_item(Vcb, br->r, &tp, &bi->key, true, Irp);
|
||||
if (!NT_SUCCESS(Status)) { // FIXME - handle STATUS_NOT_FOUND
|
||||
ERR("find_item returned %08x\n", Status);
|
||||
ERR("find_item returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2116,7 +2117,7 @@ static NTSTATUS commit_batch_list_root(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
} else {
|
||||
Status = handle_batch_collision(Vcb, bi, tp.tree, tp.item, td, &br->items, &ignore);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("handle_batch_collision returned %08x\n", Status);
|
||||
ERR("handle_batch_collision returned %08lx\n", Status);
|
||||
|
||||
if (td)
|
||||
ExFreeToPagedLookasideList(&Vcb->tree_data_lookaside, td);
|
||||
|
@ -2197,7 +2198,7 @@ static NTSTATUS commit_batch_list_root(_Requires_exclusive_lock_held_(_Curr_->tr
|
|||
} else {
|
||||
Status = handle_batch_collision(Vcb, bi2, tp.tree, td2, td, &br->items, &ignore);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("handle_batch_collision returned %08x\n", Status);
|
||||
ERR("handle_batch_collision returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -2286,7 +2287,7 @@ NTSTATUS commit_batch_list(_Requires_exclusive_lock_held_(_Curr_->tree_lock) dev
|
|||
|
||||
Status = commit_batch_list_root(Vcb, br2, Irp);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("commit_batch_list_root returned %08x\n", Status);
|
||||
ERR("commit_batch_list_root returned %08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ static NTSTATUS vol_get_disk_extents(volume_device_extension* vde, PIRP Irp) {
|
|||
|
||||
Status = dev_ioctl(vc->devobj, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &ext2, sizeof(VOLUME_DISK_EXTENTS), false, NULL);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) {
|
||||
ERR("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08x\n", Status);
|
||||
ERR("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ static NTSTATUS vol_get_disk_extents(volume_device_extension* vde, PIRP Irp) {
|
|||
Status = dev_ioctl(vc->devobj, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, ext3,
|
||||
(ULONG)offsetof(VOLUME_DISK_EXTENTS, Extents[0]) + (max_extents * sizeof(DISK_EXTENT)), false, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08x\n", Status);
|
||||
ERR("IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08lx\n", Status);
|
||||
ExFreePool(ext3);
|
||||
goto end;
|
||||
}
|
||||
|
@ -876,8 +876,21 @@ NTSTATUS vol_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS:
|
||||
return vol_get_disk_extents(vde, Irp);
|
||||
|
||||
default: // pass ioctl through if only one child device
|
||||
return vol_ioctl_passthrough(vde, Irp);
|
||||
default: { // pass ioctl through if only one child device
|
||||
ULONG code = IrpSp->Parameters.DeviceIoControl.IoControlCode;
|
||||
NTSTATUS Status = vol_ioctl_passthrough(vde, Irp);
|
||||
|
||||
#ifdef __REACTOS__
|
||||
&code;
|
||||
#endif
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
TRACE("passing through ioctl %lx (returning %08lx)\n", code, Status);
|
||||
else
|
||||
WARN("passing through ioctl %lx (returning %08lx)\n", code, Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
|
@ -917,12 +930,12 @@ NTSTATUS mountmgr_add_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devp
|
|||
|
||||
mmdlt->DeviceNameLength = devpath->Length;
|
||||
RtlCopyMemory(&mmdlt->DeviceName, devpath->Buffer, devpath->Length);
|
||||
TRACE("mmdlt = %.*S\n", mmdlt->DeviceNameLength / sizeof(WCHAR), mmdlt->DeviceName);
|
||||
TRACE("mmdlt = %.*S\n", (int)(mmdlt->DeviceNameLength / sizeof(WCHAR)), mmdlt->DeviceName);
|
||||
|
||||
Status = dev_ioctl(mountmgr, IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER, mmdlt, mmdltsize, &mmdli, sizeof(MOUNTMGR_DRIVE_LETTER_INFORMATION), false, NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER returned %08x\n", Status);
|
||||
ERR("IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER returned %08lx\n", Status);
|
||||
else
|
||||
TRACE("DriveLetterWasAssigned = %u, CurrentDriveLetter = %c\n", mmdli.DriveLetterWasAssigned, mmdli.CurrentDriveLetter);
|
||||
|
||||
|
@ -995,7 +1008,7 @@ static bool allow_degraded_mount(BTRFS_UUID* uuid) {
|
|||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
goto end;
|
||||
else if (!NT_SUCCESS(Status)) {
|
||||
ERR("ZwOpenKey returned %08x\n", Status);
|
||||
ERR("ZwOpenKey returned %08lx\n", Status);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1108,7 @@ static void drive_letter_callback2(pdo_device_extension* pdode, PDEVICE_OBJECT m
|
|||
dlr->Status = remove_drive_letter(mountmgr, &dlr->name);
|
||||
|
||||
if (!NT_SUCCESS(dlr->Status) && dlr->Status != STATUS_NOT_FOUND)
|
||||
WARN("remove_drive_letter returned %08x\n", dlr->Status);
|
||||
WARN("remove_drive_letter returned %08lx\n", dlr->Status);
|
||||
|
||||
le = le->Flink;
|
||||
}
|
||||
|
@ -1137,7 +1150,7 @@ static void __stdcall drive_letter_callback(pdo_device_extension* pdode) {
|
|||
RtlInitUnicodeString(&mmdevpath, MOUNTMGR_DEVICE_NAME);
|
||||
Status = IoGetDeviceObjectPointer(&mmdevpath, FILE_READ_ATTRIBUTES, &mountmgrfo, &mountmgr);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1177,7 +1190,7 @@ void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length,
|
|||
|
||||
Status = IoGetDeviceObjectPointer(devpath, FILE_READ_ATTRIBUTES, &FileObject, &DeviceObject);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoGetDeviceObjectPointer returned %08x\n", Status);
|
||||
ERR("IoGetDeviceObjectPointer returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&pdo_list_lock);
|
||||
return;
|
||||
}
|
||||
|
@ -1187,7 +1200,7 @@ void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length,
|
|||
Status = IoReportDetectedDevice(drvobj, InterfaceTypeUndefined, 0xFFFFFFFF, 0xFFFFFFFF, NULL, NULL, 0, &pdo);
|
||||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoReportDetectedDevice returned %08x\n", Status);
|
||||
ERR("IoReportDetectedDevice returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&pdo_list_lock);
|
||||
return;
|
||||
}
|
||||
|
@ -1203,7 +1216,7 @@ void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length,
|
|||
Status = IoCreateDevice(drvobj, sizeof(pdo_device_extension), NULL, FILE_DEVICE_DISK,
|
||||
FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN, false, &pdo);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("IoCreateDevice returned %08x\n", Status);
|
||||
ERR("IoCreateDevice returned %08lx\n", Status);
|
||||
ExReleaseResourceLite(&pdo_list_lock);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -1263,11 +1276,12 @@ void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length,
|
|||
vc->devid = sb->dev_item.dev_id;
|
||||
vc->generation = sb->generation;
|
||||
vc->notification_entry = NULL;
|
||||
vc->boot_volume = false;
|
||||
|
||||
Status = IoRegisterPlugPlayNotification(EventCategoryTargetDeviceChange, 0, FileObject,
|
||||
drvobj, pnp_removal, pdode, &vc->notification_entry);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoRegisterPlugPlayNotification returned %08x\n", Status);
|
||||
WARN("IoRegisterPlugPlayNotification returned %08lx\n", Status);
|
||||
|
||||
vc->devobj = DeviceObject;
|
||||
vc->fileobj = FileObject;
|
||||
|
@ -1354,7 +1368,7 @@ void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length,
|
|||
if ((!new_pdo || !no_pnp) && pdode->vde) {
|
||||
Status = IoSetDeviceInterfaceState(&pdode->vde->bus_name, true);
|
||||
if (!NT_SUCCESS(Status))
|
||||
WARN("IoSetDeviceInterfaceState returned %08x\n", Status);
|
||||
WARN("IoSetDeviceInterfaceState returned %08lx\n", Status);
|
||||
}
|
||||
|
||||
process_drive_letters = true;
|
||||
|
@ -1371,7 +1385,9 @@ void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length,
|
|||
drive_letter_callback(pdode);
|
||||
|
||||
if (new_pdo) {
|
||||
if (no_pnp)
|
||||
if (RtlCompareMemory(&sb->uuid, &boot_uuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID))
|
||||
boot_add_device(pdo);
|
||||
else if (no_pnp)
|
||||
AddDevice(drvobj, pdo);
|
||||
else {
|
||||
bus_device_extension* bde = busobj->DeviceExtension;
|
||||
|
|
|
@ -49,18 +49,18 @@ NTSTATUS do_read_job(PIRP Irp) {
|
|||
ExReleaseResourceLite(fcb->Header.Resource);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("do_read returned %08x\n", Status);
|
||||
ERR("do_read returned %08lx\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
TRACE("read %lu bytes\n", Irp->IoStatus.Information);
|
||||
TRACE("read %Iu bytes\n", Irp->IoStatus.Information);
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -76,18 +76,18 @@ NTSTATUS do_write_job(device_extension* Vcb, PIRP Irp) {
|
|||
} _SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
ERR("write_file returned %08x\n", Status);
|
||||
ERR("write_file returned %08lx\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
TRACE("wrote %u bytes\n", Irp->IoStatus.Information);
|
||||
TRACE("wrote %Iu bytes\n", Irp->IoStatus.Information);
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
if (top_level)
|
||||
IoSetTopLevelIrp(NULL);
|
||||
|
||||
TRACE("returning %08x\n", Status);
|
||||
TRACE("returning %08lx\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ bool add_thread_job(device_extension* Vcb, PIRP Irp) {
|
|||
_SEH2_TRY {
|
||||
MmProbeAndLockPages(Mdl, Irp->RequestorMode, op);
|
||||
} _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
|
||||
ERR("MmProbeAndLockPages raised status %08x\n", _SEH2_GetExceptionCode());
|
||||
ERR("MmProbeAndLockPages raised status %08lx\n", _SEH2_GetExceptionCode());
|
||||
|
||||
IoFreeMdl(Mdl);
|
||||
Irp->MdlAddress = NULL;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -99,8 +99,16 @@
|
|||
/* for malloc(), free() */
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h> /* size_t */
|
||||
#ifndef __REACTOS__
|
||||
#include <ntifs.h>
|
||||
#include <ntddk.h>
|
||||
#endif // __REACTOS__
|
||||
|
||||
#ifndef _USRDLL
|
||||
#ifdef __REACTOS__
|
||||
#include <ntifs.h>
|
||||
#include <ntddk.h>
|
||||
#endif // __REACTOS__
|
||||
|
||||
#define XXH_ALLOC_TAG 0x32485858 // "XXH "
|
||||
|
||||
|
@ -108,10 +116,32 @@ static void* XXH_malloc(size_t s) {
|
|||
return ExAllocatePoolWithTag(PagedPool, s, XXH_ALLOC_TAG);
|
||||
}
|
||||
|
||||
static void XXH_free (void* p) {
|
||||
static void XXH_free(void* p) {
|
||||
ExFreePool(p);
|
||||
}
|
||||
|
||||
#else
|
||||
#ifndef __REACTOS__
|
||||
static void* XXH_malloc(size_t s) {
|
||||
return malloc(s);
|
||||
}
|
||||
|
||||
static void XXH_free(void* p) {
|
||||
free(p);
|
||||
}
|
||||
#else
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
static void* XXH_malloc(size_t s) {
|
||||
return RtlAllocateHeap(RtlGetProcessHeap(), 0, s);
|
||||
}
|
||||
|
||||
static void XXH_free(void* p) {
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, p);
|
||||
}
|
||||
#endif // __REACTOS__
|
||||
#endif
|
||||
|
||||
/* for memcpy() */
|
||||
#include <string.h>
|
||||
static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
|
|
@ -32,7 +32,7 @@
|
|||
#ifndef XXH_STATIC_LINKING_ONLY
|
||||
# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
||||
#endif
|
||||
#include "xxhash.h" /* XXH_reset, update, digest */
|
||||
#include "../xxhash.h" /* XXH_reset, update, digest */
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
The following FSD are shared with: https://github.com/maharmstone/btrfs.
|
||||
|
||||
reactos/drivers/filesystems/btrfs # Synced to 1.5
|
||||
reactos/dll/shellext/shellbtrfs # Synced to 1.5
|
||||
reactos/sdk/lib/fslib/btrfslib # Synced to 1.5
|
||||
reactos/drivers/filesystems/btrfs # Synced to 1.7.2
|
||||
reactos/dll/shellext/shellbtrfs # Synced to 1.7.2
|
||||
reactos/sdk/lib/fslib/btrfslib # Synced to 1.7.2
|
||||
|
||||
The following FSD are shared with: http://www.ext2fsd.com/
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
;;; WinBtrfs
|
||||
;;;
|
||||
;;;
|
||||
;;; Copyright (c) 2016-19 Mark Harmstone
|
||||
;;; Copyright (c) 2016-20 Mark Harmstone
|
||||
;;;
|
||||
|
||||
[Version]
|
||||
|
@ -10,7 +10,7 @@ Signature = "$Windows NT$"
|
|||
Class = Volume
|
||||
ClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f}
|
||||
Provider = %Me%
|
||||
DriverVer = 06/08/2019,1.3.0.0
|
||||
DriverVer = 04/10/2020,1.7.2.0
|
||||
CatalogFile = btrfs.cat
|
||||
|
||||
[DestinationDirs]
|
||||
|
@ -32,21 +32,28 @@ CopyINF = btrfs.inf
|
|||
AddService = %ServiceName%,0x802,Btrfs.Service
|
||||
|
||||
[Manufacturer]
|
||||
%Me%=Standard,NTamd64,NTx86
|
||||
%Me%=Standard,NTamd64,NTx86,NTarm,NTarm64
|
||||
|
||||
[Standard.NTamd64]
|
||||
%VolumeName% = Btrfs_Install, BtrfsVolume
|
||||
%ControllerName% = Btrfs_Install, ROOT\btrfs
|
||||
%ControllerName% = Btrfs_Install, ROOT\btrfs
|
||||
%ControllerName% = Btrfs_Install, DETECTED\BTRFS
|
||||
|
||||
[Standard.NTx86]
|
||||
%VolumeName% = Btrfs_Install, BtrfsVolume
|
||||
%ControllerName% = Btrfs_Install, ROOT\btrfs
|
||||
%ControllerName% = Btrfs_Install, DETECTED\BTRFS
|
||||
|
||||
[Standard.NTarm]
|
||||
%VolumeName% = Btrfs_Install, BtrfsVolume
|
||||
%ControllerName% = Btrfs_Install, ROOT\btrfs
|
||||
|
||||
[Standard.NTarm64]
|
||||
%VolumeName% = Btrfs_Install, BtrfsVolume
|
||||
%ControllerName% = Btrfs_Install, ROOT\btrfs
|
||||
|
||||
[Btrfs_Install]
|
||||
OptionDesc = %ServiceDescription%
|
||||
CopyFiles = Btrfs.DriverFiles,Btrfs.DllFiles
|
||||
RegisterDlls = shellbtrfs
|
||||
|
||||
[Btrfs_Install.Services]
|
||||
AddService = %ServiceName%,2,Btrfs.Service
|
||||
|
@ -90,6 +97,11 @@ shellbtrfs.dll
|
|||
ubtrfs.dll
|
||||
mkbtrfs.exe
|
||||
|
||||
[SourceDisksFiles]
|
||||
btrfs.sys = 1,,
|
||||
shellbtrfs.dll = 1,,
|
||||
ubtrfs.dll = 1,,
|
||||
mkbtrfs.exe = 1,,
|
||||
|
||||
[SourceDisksNames.x86]
|
||||
1 = %DiskId1%,,,\x86
|
||||
|
@ -97,6 +109,12 @@ mkbtrfs.exe
|
|||
[SourceDisksNames.amd64]
|
||||
1 = %DiskId1%,,,\x64
|
||||
|
||||
[SourceDisksNames.arm]
|
||||
1 = %DiskId1%,,,\arm
|
||||
|
||||
[SourceDisksNames.arm64]
|
||||
1 = %DiskId1%,,,\aarch64
|
||||
|
||||
;;
|
||||
;; String Section
|
||||
;;
|
||||
|
|
|
@ -2,5 +2,21 @@
|
|||
include_directories(
|
||||
${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs)
|
||||
|
||||
add_library(btrfslib btrfslib.c)
|
||||
list(APPEND SOURCE
|
||||
${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs/blake2b-ref.c
|
||||
${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs/crc32c.c
|
||||
${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs/sha256.c
|
||||
${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs/xxhash.c
|
||||
btrfslib.c)
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
list(APPEND ASM_SOURCE ${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs/crc32c-x86.S)
|
||||
elseif(ARCH STREQUAL "amd64")
|
||||
list(APPEND ASM_SOURCE ${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs/crc32c-amd64.S)
|
||||
endif()
|
||||
|
||||
add_asm_files(btrfs_asm ${ASM_SOURCE})
|
||||
|
||||
add_library(btrfslib ${SOURCE} ${btrfs_asm})
|
||||
target_compile_definitions(btrfslib PRIVATE _USRDLL)
|
||||
add_dependencies(btrfslib psdk)
|
||||
|
|
|
@ -37,13 +37,33 @@
|
|||
#include <mountmgr.h>
|
||||
#ifdef __REACTOS__
|
||||
#include <winnls.h>
|
||||
#include <stdbool.h>
|
||||
#include "btrfs.h"
|
||||
#include "btrfsioctl.h"
|
||||
#include "crc32c.h"
|
||||
#include "xxhash.h"
|
||||
#else
|
||||
#include <stringapiset.h>
|
||||
#include <stdbool.h>
|
||||
#include "../btrfs.h"
|
||||
#include "../btrfsioctl.h"
|
||||
#include "../crc32c.h"
|
||||
#include "../xxhash.h"
|
||||
|
||||
#if defined(_X86_) || defined(_AMD64_)
|
||||
#ifndef _MSC_VER
|
||||
#include <cpuid.h>
|
||||
#else
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
#define SHA256_HASH_SIZE 32
|
||||
void calc_sha256(uint8_t* hash, const void* input, size_t len);
|
||||
|
||||
#define BLAKE2_HASH_SIZE 32
|
||||
void blake2b(void *out, size_t outlen, const void* in, size_t inlen);
|
||||
|
||||
#ifndef __REACTOS__
|
||||
#define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
@ -67,7 +87,7 @@ NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRo
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
// These are undocumented, and what comes from format.exe
|
||||
typedef struct {
|
||||
|
@ -154,6 +174,7 @@ typedef struct {
|
|||
HMODULE module;
|
||||
ULONG def_sector_size = 0, def_node_size = 0;
|
||||
uint64_t def_incompat_flags = BTRFS_INCOMPAT_FLAGS_EXTENDED_IREF | BTRFS_INCOMPAT_FLAGS_SKINNY_METADATA;
|
||||
uint16_t def_csum_type = CSUM_TYPE_CRC32C;
|
||||
|
||||
// the following definitions come from fmifs.h in ReactOS
|
||||
|
||||
|
@ -211,54 +232,6 @@ typedef enum {
|
|||
|
||||
typedef BOOLEAN (NTAPI* PFMIFSCALLBACK)(CALLBACKCOMMAND Command, ULONG SubAction, PVOID ActionInfo);
|
||||
|
||||
static const uint32_t crctable[] = {
|
||||
0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb,
|
||||
0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24,
|
||||
0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
|
||||
0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b,
|
||||
0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35,
|
||||
0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
|
||||
0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a,
|
||||
0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595,
|
||||
0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
|
||||
0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198,
|
||||
0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38,
|
||||
0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
|
||||
0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789,
|
||||
0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46,
|
||||
0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
|
||||
0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829,
|
||||
0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93,
|
||||
0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
|
||||
0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc,
|
||||
0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033,
|
||||
0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
|
||||
0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982,
|
||||
0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622,
|
||||
0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
|
||||
0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f,
|
||||
0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0,
|
||||
0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
|
||||
0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f,
|
||||
0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1,
|
||||
0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
|
||||
0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e,
|
||||
0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351,
|
||||
};
|
||||
|
||||
static uint32_t calc_crc32c(uint32_t seed, uint8_t* msg, ULONG msglen) {
|
||||
uint32_t rem;
|
||||
ULONG i;
|
||||
|
||||
rem = seed;
|
||||
|
||||
for (i = 0; i < msglen; i++) {
|
||||
rem = crctable[(rem ^ msg[i]) & 0xff] ^ (rem >> 8);
|
||||
}
|
||||
|
||||
return rem;
|
||||
}
|
||||
|
||||
#ifndef __REACTOS__
|
||||
NTSTATUS WINAPI ChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLEAN Verbose, BOOLEAN CheckOnlyIfDirty,
|
||||
#else
|
||||
|
@ -490,7 +463,7 @@ static btrfs_chunk* add_chunk(LIST_ENTRY* chunks, uint64_t flags, btrfs_root* ch
|
|||
return c;
|
||||
}
|
||||
|
||||
static BOOL superblock_collision(btrfs_chunk* c, uint64_t address) {
|
||||
static bool superblock_collision(btrfs_chunk* c, uint64_t address) {
|
||||
CHUNK_ITEM_STRIPE* cis = (CHUNK_ITEM_STRIPE*)&c->chunk_item[1];
|
||||
uint64_t stripe = (address - c->offset) / c->chunk_item->stripe_length;
|
||||
uint16_t i, j;
|
||||
|
@ -502,13 +475,13 @@ static BOOL superblock_collision(btrfs_chunk* c, uint64_t address) {
|
|||
uint64_t stripe2 = (superblock_addrs[j] - cis[i].offset) / c->chunk_item->stripe_length;
|
||||
|
||||
if (stripe2 == stripe)
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static uint64_t get_next_address(btrfs_chunk* c) {
|
||||
|
@ -540,7 +513,7 @@ typedef struct {
|
|||
} EXTENT_ITEM_METADATA2;
|
||||
|
||||
static void assign_addresses(LIST_ENTRY* roots, btrfs_chunk* sys_chunk, btrfs_chunk* metadata_chunk, uint32_t node_size,
|
||||
btrfs_root* root_root, btrfs_root* extent_root, BOOL skinny) {
|
||||
btrfs_root* root_root, btrfs_root* extent_root, bool skinny) {
|
||||
LIST_ENTRY* le;
|
||||
|
||||
le = roots->Flink;
|
||||
|
@ -632,6 +605,26 @@ static NTSTATUS write_data(HANDLE h, uint64_t address, btrfs_chunk* c, void* dat
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void calc_tree_checksum(tree_header* th, uint32_t node_size) {
|
||||
switch (def_csum_type) {
|
||||
case CSUM_TYPE_CRC32C:
|
||||
*(uint32_t*)th = ~calc_crc32c(0xffffffff, (uint8_t*)&th->fs_uuid, node_size - sizeof(th->csum));
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_XXHASH:
|
||||
*(uint64_t*)th = XXH64((uint8_t*)&th->fs_uuid, node_size - sizeof(th->csum), 0);
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_SHA256:
|
||||
calc_sha256((uint8_t*)th, &th->fs_uuid, node_size - sizeof(th->csum));
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_BLAKE2:
|
||||
blake2b((uint8_t*)th, BLAKE2_HASH_SIZE, &th->fs_uuid, node_size - sizeof(th->csum));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS write_roots(HANDLE h, LIST_ENTRY* roots, uint32_t node_size, BTRFS_UUID* fsuuid, BTRFS_UUID* chunkuuid) {
|
||||
LIST_ENTRY *le, *le2;
|
||||
NTSTATUS Status;
|
||||
|
@ -648,7 +641,6 @@ static NTSTATUS write_roots(HANDLE h, LIST_ENTRY* roots, uint32_t node_size, BTR
|
|||
btrfs_root* r = CONTAINING_RECORD(le, btrfs_root, list_entry);
|
||||
uint8_t* dp;
|
||||
leaf_node* ln;
|
||||
uint32_t crc32;
|
||||
|
||||
memset(tree, 0, node_size);
|
||||
|
||||
|
@ -674,7 +666,7 @@ static NTSTATUS write_roots(HANDLE h, LIST_ENTRY* roots, uint32_t node_size, BTR
|
|||
dp -= item->size;
|
||||
memcpy(dp, item->data, item->size);
|
||||
|
||||
ln->offset = dp - tree - sizeof(tree_header);
|
||||
ln->offset = (uint32_t)(dp - tree - sizeof(tree_header));
|
||||
} else
|
||||
ln->offset = 0;
|
||||
|
||||
|
@ -687,8 +679,7 @@ static NTSTATUS write_roots(HANDLE h, LIST_ENTRY* roots, uint32_t node_size, BTR
|
|||
|
||||
memcpy(tree, &r->header, sizeof(tree_header));
|
||||
|
||||
crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&((tree_header*)tree)->fs_uuid, node_size - sizeof(((tree_header*)tree)->csum));
|
||||
memcpy(tree, &crc32, sizeof(uint32_t));
|
||||
calc_tree_checksum((tree_header*)tree, node_size);
|
||||
|
||||
Status = write_data(h, r->header.address, r->c, tree, node_size);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
|
@ -758,13 +749,32 @@ static void init_device(btrfs_dev* dev, uint64_t id, uint64_t size, BTRFS_UUID*
|
|||
dev->last_alloc = 0x100000; // skip first megabyte
|
||||
}
|
||||
|
||||
static void calc_superblock_checksum(superblock* sb) {
|
||||
switch (def_csum_type) {
|
||||
case CSUM_TYPE_CRC32C:
|
||||
*(uint32_t*)sb = ~calc_crc32c(0xffffffff, (uint8_t*)&sb->uuid, (ULONG)sizeof(superblock) - sizeof(sb->checksum));
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_XXHASH:
|
||||
*(uint64_t*)sb = XXH64(&sb->uuid, sizeof(superblock) - sizeof(sb->checksum), 0);
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_SHA256:
|
||||
calc_sha256((uint8_t*)sb, &sb->uuid, sizeof(superblock) - sizeof(sb->checksum));
|
||||
break;
|
||||
|
||||
case CSUM_TYPE_BLAKE2:
|
||||
blake2b((uint8_t*)sb, BLAKE2_HASH_SIZE, &sb->uuid, sizeof(superblock) - sizeof(sb->checksum));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS write_superblocks(HANDLE h, btrfs_dev* dev, btrfs_root* chunk_root, btrfs_root* root_root, btrfs_root* extent_root,
|
||||
btrfs_chunk* sys_chunk, uint32_t node_size, BTRFS_UUID* fsuuid, uint32_t sector_size, PUNICODE_STRING label, uint64_t incompat_flags) {
|
||||
NTSTATUS Status;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
ULONG sblen;
|
||||
int i;
|
||||
uint32_t crc32;
|
||||
superblock* sb;
|
||||
KEY* key;
|
||||
uint64_t bytes_used;
|
||||
|
@ -812,6 +822,7 @@ static NTSTATUS write_superblocks(HANDLE h, btrfs_dev* dev, btrfs_root* chunk_ro
|
|||
sb->n = sizeof(KEY) + sizeof(CHUNK_ITEM) + (sys_chunk->chunk_item->num_stripes * sizeof(CHUNK_ITEM_STRIPE));
|
||||
sb->chunk_root_generation = 1;
|
||||
sb->incompat_flags = incompat_flags;
|
||||
sb->csum_type = def_csum_type;
|
||||
memcpy(&sb->dev_item, &dev->dev_item, sizeof(DEV_ITEM));
|
||||
|
||||
if (label->Length > 0) {
|
||||
|
@ -876,8 +887,7 @@ static NTSTATUS write_superblocks(HANDLE h, btrfs_dev* dev, btrfs_root* chunk_ro
|
|||
|
||||
sb->sb_phys_addr = superblock_addrs[i];
|
||||
|
||||
crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&sb->uuid, (ULONG)sizeof(superblock) - sizeof(sb->checksum));
|
||||
memcpy(&sb->checksum, &crc32, sizeof(uint32_t));
|
||||
calc_superblock_checksum(sb);
|
||||
|
||||
off.QuadPart = superblock_addrs[i];
|
||||
|
||||
|
@ -1017,7 +1027,7 @@ static NTSTATUS clear_first_megabyte(HANDLE h) {
|
|||
return Status;
|
||||
}
|
||||
|
||||
static BOOL is_ssd(HANDLE h) {
|
||||
static bool is_ssd(HANDLE h) {
|
||||
ULONG aptelen;
|
||||
ATA_PASS_THROUGH_EX* apte;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
|
@ -1051,7 +1061,7 @@ static BOOL is_ssd(HANDLE h) {
|
|||
#else
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, apte);
|
||||
#endif
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1071,7 @@ static BOOL is_ssd(HANDLE h) {
|
|||
RtlFreeHeap(RtlGetProcessHeap(), 0, apte);
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_dir_item(btrfs_root* root, uint64_t inode, uint32_t hash, uint64_t key_objid, uint8_t key_type,
|
||||
|
@ -1130,7 +1140,7 @@ static NTSTATUS write_btrfs(HANDLE h, uint64_t size, PUNICODE_STRING label, uint
|
|||
btrfs_chunk *sys_chunk, *metadata_chunk;
|
||||
btrfs_dev dev;
|
||||
BTRFS_UUID fsuuid, chunkuuid;
|
||||
BOOL ssd;
|
||||
bool ssd;
|
||||
uint64_t metadata_flags;
|
||||
#ifdef __REACTOS__
|
||||
ULONG seed;
|
||||
|
@ -1210,7 +1220,7 @@ static NTSTATUS write_btrfs(HANDLE h, uint64_t size, PUNICODE_STRING label, uint
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL look_for_device(btrfs_filesystem* bfs, BTRFS_UUID* devuuid) {
|
||||
static bool look_for_device(btrfs_filesystem* bfs, BTRFS_UUID* devuuid) {
|
||||
uint32_t i;
|
||||
btrfs_filesystem_device* dev;
|
||||
|
||||
|
@ -1221,26 +1231,60 @@ static BOOL look_for_device(btrfs_filesystem* bfs, BTRFS_UUID* devuuid) {
|
|||
dev = (btrfs_filesystem_device*)((uint8_t*)dev + offsetof(btrfs_filesystem_device, name[0]) + dev->name_length);
|
||||
|
||||
if (RtlCompareMemory(&dev->uuid, devuuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID))
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static BOOL is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
||||
static bool check_superblock_checksum(superblock* sb) {
|
||||
switch (sb->csum_type) {
|
||||
case CSUM_TYPE_CRC32C: {
|
||||
uint32_t crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&sb->uuid, (ULONG)sizeof(superblock) - sizeof(sb->checksum));
|
||||
|
||||
return crc32 == *(uint32_t*)sb;
|
||||
}
|
||||
|
||||
case CSUM_TYPE_XXHASH: {
|
||||
uint64_t hash = XXH64(&sb->uuid, sizeof(superblock) - sizeof(sb->checksum), 0);
|
||||
|
||||
return hash == *(uint64_t*)sb;
|
||||
}
|
||||
|
||||
case CSUM_TYPE_SHA256: {
|
||||
uint8_t hash[SHA256_HASH_SIZE];
|
||||
|
||||
calc_sha256(hash, &sb->uuid, sizeof(superblock) - sizeof(sb->checksum));
|
||||
|
||||
return !memcmp(hash, sb, SHA256_HASH_SIZE);
|
||||
}
|
||||
|
||||
case CSUM_TYPE_BLAKE2: {
|
||||
uint8_t hash[BLAKE2_HASH_SIZE];
|
||||
|
||||
blake2b(hash, sizeof(hash), &sb->uuid, sizeof(superblock) - sizeof(sb->checksum));
|
||||
|
||||
return !memcmp(hash, sb, BLAKE2_HASH_SIZE);
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
||||
NTSTATUS Status;
|
||||
superblock* sb;
|
||||
ULONG sblen;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
LARGE_INTEGER off;
|
||||
BTRFS_UUID fsuuid, devuuid;
|
||||
uint32_t crc32;
|
||||
UNICODE_STRING us;
|
||||
OBJECT_ATTRIBUTES atts;
|
||||
HANDLE h2;
|
||||
btrfs_filesystem *bfs = NULL, *bfs2;
|
||||
ULONG bfssize;
|
||||
BOOL ret = FALSE;
|
||||
bool ret = false;
|
||||
|
||||
static WCHAR btrfs[] = L"\\Btrfs";
|
||||
|
||||
|
@ -1263,7 +1307,7 @@ static BOOL is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
|||
#else
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, sb);
|
||||
#endif
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sb->magic != BTRFS_MAGIC) {
|
||||
|
@ -1272,17 +1316,16 @@ static BOOL is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
|||
#else
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, sb);
|
||||
#endif
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
crc32 = ~calc_crc32c(0xffffffff, (uint8_t*)&sb->uuid, (ULONG)sizeof(superblock) - sizeof(sb->checksum));
|
||||
if (crc32 != *((uint32_t*)sb)) {
|
||||
if (!check_superblock_checksum(sb)) {
|
||||
#ifndef __REACTOS__
|
||||
free(sb);
|
||||
#else
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, sb);
|
||||
#endif
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
fsuuid = sb->uuid;
|
||||
|
@ -1302,7 +1345,7 @@ static BOOL is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
|||
Status = NtOpenFile(&h2, SYNCHRONIZE | FILE_READ_ATTRIBUTES, &atts, &iosb,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_ALERT);
|
||||
if (!NT_SUCCESS(Status)) // not a problem, it usually just means the driver isn't loaded
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
bfssize = 0;
|
||||
|
||||
|
@ -1320,7 +1363,7 @@ static BOOL is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
|||
Status = NtDeviceIoControlFile(h2, NULL, NULL, NULL, &iosb, IOCTL_BTRFS_QUERY_FILESYSTEMS, NULL, 0, bfs, bfssize);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW) {
|
||||
NtClose(h2);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
} while (Status == STATUS_BUFFER_OVERFLOW);
|
||||
|
||||
|
@ -1329,10 +1372,10 @@ static BOOL is_mounted_multi_device(HANDLE h, uint32_t sector_size) {
|
|||
|
||||
if (bfs->num_devices != 0) {
|
||||
bfs2 = bfs;
|
||||
while (TRUE) {
|
||||
while (true) {
|
||||
if (RtlCompareMemory(&bfs2->uuid, &fsuuid, sizeof(BTRFS_UUID)) == sizeof(BTRFS_UUID)) {
|
||||
if (bfs2->num_devices == 1)
|
||||
ret = FALSE;
|
||||
ret = false;
|
||||
else
|
||||
ret = look_for_device(bfs2, &devuuid);
|
||||
|
||||
|
@ -1376,15 +1419,33 @@ static void do_full_trim(HANDLE h) {
|
|||
NtDeviceIoControlFile(h, NULL, NULL, NULL, &iosb, IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES, &dmdsa, sizeof(DEVICE_MANAGE_DATA_SET_ATTRIBUTES), NULL, 0);
|
||||
}
|
||||
|
||||
static BOOL is_power_of_two(ULONG i) {
|
||||
static bool is_power_of_two(ULONG i) {
|
||||
return ((i != 0) && !(i & (i - 1)));
|
||||
}
|
||||
|
||||
#if !defined(__REACTOS__) && (defined(_X86_) || defined(_AMD64_))
|
||||
static void check_cpu() {
|
||||
unsigned int cpuInfo[4];
|
||||
bool have_sse42;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
__get_cpuid(1, &cpuInfo[0], &cpuInfo[1], &cpuInfo[2], &cpuInfo[3]);
|
||||
have_sse42 = cpuInfo[2] & bit_SSE4_2;
|
||||
#else
|
||||
__cpuid(cpuInfo, 1);
|
||||
have_sse42 = cpuInfo[2] & (1 << 20);
|
||||
#endif
|
||||
|
||||
if (have_sse42)
|
||||
calc_crc32c = calc_crc32c_hw;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __REACTOS__
|
||||
static NTSTATUS NTAPI FormatEx2(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
|
||||
#else
|
||||
NTSTATUS NTAPI BtrfsFormatEx(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
BOOLEAN QuickFormat, ULONG ClusterSize, PFMIFSCALLBACK Callback)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
@ -1418,13 +1479,21 @@ NTSTATUS NTAPI BtrfsFormatEx(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFl
|
|||
tp.Privileges[0].Luid = luid;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if (!AdjustTokenPrivileges(token, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) {
|
||||
if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) {
|
||||
CloseHandle(token);
|
||||
return STATUS_PRIVILEGE_NOT_HELD;
|
||||
}
|
||||
|
||||
CloseHandle(token);
|
||||
|
||||
#if defined(_X86_) || defined(_AMD64_)
|
||||
check_cpu();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (def_csum_type != CSUM_TYPE_CRC32C && def_csum_type != CSUM_TYPE_XXHASH && def_csum_type != CSUM_TYPE_SHA256 &&
|
||||
def_csum_type != CSUM_TYPE_BLAKE2)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
InitializeObjectAttributes(&attr, DriveRoot, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||
|
||||
|
@ -1519,7 +1588,7 @@ end:
|
|||
MOUNTDEV_NAME* mdn;
|
||||
ULONG mdnsize;
|
||||
|
||||
mdnsize = offsetof(MOUNTDEV_NAME, Name[0]) + DriveRoot->Length;
|
||||
mdnsize = (ULONG)(offsetof(MOUNTDEV_NAME, Name[0]) + DriveRoot->Length);
|
||||
#ifndef __REACTOS__
|
||||
mdn = malloc(mdnsize);
|
||||
#else
|
||||
|
@ -1544,7 +1613,7 @@ end:
|
|||
}
|
||||
|
||||
if (Callback) {
|
||||
BOOL success = NT_SUCCESS(Status);
|
||||
bool success = NT_SUCCESS(Status);
|
||||
Callback(DONE, 0, (PVOID)&success);
|
||||
}
|
||||
|
||||
|
@ -1556,7 +1625,7 @@ BOOL __stdcall FormatEx(DSTRING* root, STREAM_MESSAGE* message, options* opts, u
|
|||
NTSTATUS Status;
|
||||
|
||||
if (!root || !root->string)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
DriveRoot.Length = DriveRoot.MaximumLength = (USHORT)(wcslen(root->string) * sizeof(WCHAR));
|
||||
DriveRoot.Buffer = root->string;
|
||||
|
@ -1590,10 +1659,14 @@ void __stdcall SetIncompatFlags(uint64_t incompat_flags) {
|
|||
def_incompat_flags = incompat_flags;
|
||||
}
|
||||
|
||||
void __stdcall SetCsumType(uint16_t csum_type) {
|
||||
def_csum_type = csum_type;
|
||||
}
|
||||
|
||||
BOOL __stdcall GetFilesystemInformation(uint32_t unk1, uint32_t unk2, void* unk3) {
|
||||
// STUB - undocumented
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef __REACTOS__
|
||||
|
@ -1601,6 +1674,6 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, void* lpReserved) {
|
|||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
module = (HMODULE)hModule;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue