mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 10:11:48 +00:00
[BTRFS][UBTRFS][SHELLBTRFS] Upgrade to 1.7.5 (#4417)
v1.7.5 (2020-10-31): - Fixed text display issue in shell extension - Added support for mingw 8 - Fixed LXSS permissions not working in new versions of Windows - Fixed issue where truncating an inline file wouldn't change its size - Fixed crash with Quibble where driver would try to use AVX2 before Windows had enabled it
This commit is contained in:
parent
0604273535
commit
b826992ab2
15 changed files with 166 additions and 195 deletions
|
@ -5923,7 +5923,7 @@ static void check_cpu() {
|
|||
|
||||
#ifndef _MSC_VER
|
||||
{
|
||||
uint32_t eax, ebx, ecx, edx, xcr0;
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
|
||||
__cpuid(1, eax, ebx, ecx, edx);
|
||||
|
||||
|
@ -5935,10 +5935,17 @@ static void check_cpu() {
|
|||
if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx))
|
||||
have_avx2 = ebx & bit_AVX2;
|
||||
|
||||
if (have_avx2) { // check if supported by OS
|
||||
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "edx" );
|
||||
if (have_avx2) {
|
||||
// check Windows has enabled AVX2 - Windows 10 doesn't immediately
|
||||
|
||||
if ((xcr0 & 6) != 6)
|
||||
if (__readcr4() & (1 << 18)) {
|
||||
uint32_t xcr0;
|
||||
|
||||
__asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "edx" );
|
||||
|
||||
if ((xcr0 & 6) != 6)
|
||||
have_avx2 = false;
|
||||
} else
|
||||
have_avx2 = false;
|
||||
}
|
||||
}
|
||||
|
@ -5954,9 +5961,14 @@ static void check_cpu() {
|
|||
have_avx2 = cpu_info[1] & (1 << 5);
|
||||
|
||||
if (have_avx2) {
|
||||
uint32_t xcr0 = (uint32_t)_xgetbv(0);
|
||||
// check Windows has enabled AVX2 - Windows 10 doesn't immediately
|
||||
|
||||
if ((xcr0 & 6) != 6)
|
||||
if (__readcr4() & (1 << 18)) {
|
||||
uint32_t xcr0 = (uint32_t)_xgetbv(0);
|
||||
|
||||
if ((xcr0 & 6) != 6)
|
||||
have_avx2 = false;
|
||||
} else
|
||||
have_avx2 = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ Signature = "$Windows NT$"
|
|||
Class = Volume
|
||||
ClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f}
|
||||
Provider = %Me%
|
||||
DriverVer = 05/24/2020,1.7.3.0
|
||||
DriverVer = 10/31/2020,1.7.5.0
|
||||
CatalogFile = btrfs.cat
|
||||
|
||||
[DestinationDirs]
|
||||
|
|
|
@ -51,8 +51,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,7,4,0
|
||||
PRODUCTVERSION 1,7,4,0
|
||||
FILEVERSION 1,7,5,0
|
||||
PRODUCTVERSION 1,7,5,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -68,12 +68,12 @@ BEGIN
|
|||
BLOCK "080904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "WinBtrfs"
|
||||
VALUE "FileVersion", "1.7.4"
|
||||
VALUE "FileVersion", "1.7.5"
|
||||
VALUE "InternalName", "btrfs"
|
||||
VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-20"
|
||||
VALUE "OriginalFilename", "btrfs.sys"
|
||||
VALUE "ProductName", "WinBtrfs"
|
||||
VALUE "ProductVersion", "1.7.4"
|
||||
VALUE "ProductVersion", "1.7.5"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -201,17 +201,8 @@ typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER {
|
|||
#ifndef __REACTOS__
|
||||
#ifndef _MSC_VER
|
||||
#define __drv_aliasesMem
|
||||
#define _Requires_lock_held_(a)
|
||||
#define _Requires_exclusive_lock_held_(a)
|
||||
#define _Releases_lock_(a)
|
||||
#define _Releases_exclusive_lock_(a)
|
||||
#define _Dispatch_type_(a)
|
||||
#define _Create_lock_level_(a)
|
||||
#define _Lock_level_order_(a,b)
|
||||
#define _Has_lock_level_(a)
|
||||
#define _Requires_lock_not_held_(a)
|
||||
#define _Acquires_exclusive_lock_(a)
|
||||
#define _Acquires_shared_lock_(a)
|
||||
#endif
|
||||
#endif // __REACTOS__
|
||||
|
||||
|
|
|
@ -3593,22 +3593,19 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
LARGE_INTEGER zero;
|
||||
|
||||
if (fileref->fcb->type == BTRFS_TYPE_DIRECTORY || is_subvol_readonly(fileref->fcb->subvol, Irp)) {
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_ACCESS_DENIED;
|
||||
Status = STATUS_ACCESS_DENIED;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (Vcb->readonly) {
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_MEDIA_WRITE_PROTECTED;
|
||||
Status = STATUS_MEDIA_WRITE_PROTECTED;
|
||||
goto end;
|
||||
}
|
||||
|
||||
zero.QuadPart = 0;
|
||||
if (!MmCanFileBeTruncated(&fileref->fcb->nonpaged->segment_object, &zero)) {
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_USER_MAPPED_FILE;
|
||||
Status = STATUS_USER_MAPPED_FILE;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3622,10 +3619,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
granted_access, &Status)) {
|
||||
SeUnlockSubjectContext(&IrpSp->Parameters.Create.SecurityContext->AccessState->SubjectSecurityContext);
|
||||
TRACE("SeAccessCheck failed, returning %08lx\n", Status);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end;
|
||||
}
|
||||
|
||||
SeUnlockSubjectContext(&IrpSp->Parameters.Create.SecurityContext->AccessState->SubjectSecurityContext);
|
||||
|
@ -3638,10 +3632,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
while (sf) {
|
||||
if (sf->delete_on_close) {
|
||||
TRACE("could not open as deletion pending\n");
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_DELETE_PENDING;
|
||||
Status = STATUS_DELETE_PENDING;
|
||||
goto end;
|
||||
}
|
||||
sf = sf->parent;
|
||||
}
|
||||
|
@ -3651,9 +3643,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
is_subvol_readonly(fileref->fcb->subvol, Irp) || fileref->fcb == Vcb->dummy_fcb || Vcb->readonly;
|
||||
|
||||
if (options & FILE_DELETE_ON_CLOSE && (fileref == Vcb->root_fileref || readonly)) {
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_CANNOT_DELETE;
|
||||
Status = STATUS_CANNOT_DELETE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (readonly) {
|
||||
|
@ -3681,9 +3672,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
*granted_access &= allowed;
|
||||
IrpSp->Parameters.Create.SecurityContext->AccessState->PreviouslyGrantedAccess &= allowed;
|
||||
} else if (*granted_access & ~allowed) {
|
||||
free_fileref(fileref);
|
||||
|
||||
return Vcb->readonly ? STATUS_MEDIA_WRITE_PROTECTED : STATUS_ACCESS_DENIED;
|
||||
Status = Vcb->readonly ? STATUS_MEDIA_WRITE_PROTECTED : STATUS_ACCESS_DENIED;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3709,24 +3699,20 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
Irp->Tail.Overlay.AuxiliaryBuffer = (void*)data;
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_REPARSE;
|
||||
Status = STATUS_REPARSE;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (fileref->fcb->type == BTRFS_TYPE_DIRECTORY && !fileref->fcb->ads) {
|
||||
if (options & FILE_NON_DIRECTORY_FILE && !(fileref->fcb->atts & FILE_ATTRIBUTE_REPARSE_POINT)) {
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_FILE_IS_A_DIRECTORY;
|
||||
Status = STATUS_FILE_IS_A_DIRECTORY;
|
||||
goto end;
|
||||
}
|
||||
} else if (options & FILE_DIRECTORY_FILE) {
|
||||
TRACE("returning STATUS_NOT_A_DIRECTORY (type = %u)\n", fileref->fcb->type);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_NOT_A_DIRECTORY;
|
||||
Status = STATUS_NOT_A_DIRECTORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (fileref->open_count > 0) {
|
||||
|
@ -3738,9 +3724,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
else
|
||||
WARN("IoCheckShareAccess failed, returning %08lx\n", Status);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end;
|
||||
}
|
||||
|
||||
IoUpdateShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
@ -3749,12 +3733,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
if (*granted_access & FILE_WRITE_DATA || options & FILE_DELETE_ON_CLOSE) {
|
||||
if (!MmFlushImageSection(&fileref->fcb->nonpaged->segment_object, MmFlushForWrite)) {
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return (options & FILE_DELETE_ON_CLOSE) ? STATUS_CANNOT_DELETE : STATUS_SHARING_VIOLATION;
|
||||
Status = (options & FILE_DELETE_ON_CLOSE) ? STATUS_CANNOT_DELETE : STATUS_SHARING_VIOLATION;
|
||||
goto end2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3762,9 +3742,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
Status = FsRtlCheckOplock(fcb_oplock(fileref->fcb), Irp, NULL, NULL, NULL);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WARN("FsRtlCheckOplock returned %08lx\n", Status);
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
if (RequestedDisposition == FILE_OVERWRITE || RequestedDisposition == FILE_OVERWRITE_IF || RequestedDisposition == FILE_SUPERSEDE) {
|
||||
|
@ -3774,43 +3752,26 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
if ((RequestedDisposition == FILE_OVERWRITE || RequestedDisposition == FILE_OVERWRITE_IF) && readonly) {
|
||||
WARN("cannot overwrite readonly file\n");
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_ACCESS_DENIED;
|
||||
Status = STATUS_ACCESS_DENIED;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
if (!fileref->fcb->ads && (IrpSp->Parameters.Create.FileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) != ((fileref->fcb->atts & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)))) {
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_ACCESS_DENIED;
|
||||
Status = STATUS_ACCESS_DENIED;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
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 %08lx\n", Status);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end2;
|
||||
}
|
||||
} else {
|
||||
Status = truncate_file(fileref->fcb, 0, Irp, rollback);
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("truncate_file returned %08lx\n", Status);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3819,12 +3780,7 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
ERR("extend_file returned %08lx\n", Status);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3838,12 +3794,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 %08lx (error at offset %lu)\n", Status, offset);
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
fileref->fcb->ealen = 4;
|
||||
|
@ -3872,12 +3823,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
fileref->fcb->ea_xattr.Buffer = ExAllocatePoolWithTag(pool_type, IrpSp->Parameters.Create.EaLength, ALLOC_TAG);
|
||||
if (!fileref->fcb->ea_xattr.Buffer) {
|
||||
ERR("out of memory\n");
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
fileref->fcb->ea_xattr.Length = fileref->fcb->ea_xattr.MaximumLength = (USHORT)IrpSp->Parameters.Create.EaLength;
|
||||
|
@ -3914,10 +3861,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 %08lx\n", Status);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
goto end2;
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -3973,11 +3917,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
if (ffei->Flags & FILE_NEED_EA) {
|
||||
WARN("returning STATUS_ACCESS_DENIED as no EA knowledge\n");
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_ACCESS_DENIED;
|
||||
Status = STATUS_ACCESS_DENIED;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
if (ffei->NextEntryOffset == 0)
|
||||
|
@ -3994,11 +3935,8 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
if (!ccb) {
|
||||
ERR("out of memory\n");
|
||||
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
free_fileref(fileref);
|
||||
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto end2;
|
||||
}
|
||||
|
||||
RtlZeroMemory(ccb, sizeof(*ccb));
|
||||
|
@ -4076,7 +4014,17 @@ static NTSTATUS open_file2(device_extension* Vcb, ULONG RequestedDisposition, PO
|
|||
#endif
|
||||
InterlockedIncrement(&Vcb->open_files);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
end2:
|
||||
if (!NT_SUCCESS(Status))
|
||||
IoRemoveShareAccess(FileObject, &fileref->fcb->share_access);
|
||||
|
||||
end:
|
||||
if (!NT_SUCCESS(Status))
|
||||
free_fileref(fileref);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension* Vcb,
|
||||
|
|
|
@ -5807,7 +5807,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
goto end2;
|
||||
}
|
||||
|
||||
if (Irp->RequestorMode == KernelMode) {
|
||||
if (Irp->RequestorMode == KernelMode || ccb->access & FILE_WRITE_ATTRIBUTES) {
|
||||
RtlCopyMemory(&fcb->inode_item.st_uid, item->value.Buffer, sizeof(uint32_t));
|
||||
fcb->sd_dirty = true;
|
||||
fcb->sd_deleted = false;
|
||||
|
@ -5822,7 +5822,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
goto end2;
|
||||
}
|
||||
|
||||
if (Irp->RequestorMode == KernelMode)
|
||||
if (Irp->RequestorMode == KernelMode || ccb->access & FILE_WRITE_ATTRIBUTES)
|
||||
RtlCopyMemory(&fcb->inode_item.st_gid, item->value.Buffer, sizeof(uint32_t));
|
||||
|
||||
RemoveEntryList(&item->list_entry);
|
||||
|
@ -5834,7 +5834,7 @@ NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
|
|||
goto end2;
|
||||
}
|
||||
|
||||
if (Irp->RequestorMode == KernelMode) {
|
||||
if (Irp->RequestorMode == KernelMode || ccb->access & FILE_WRITE_ATTRIBUTES) {
|
||||
uint32_t allowed = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID | S_ISVTX | S_ISUID;
|
||||
uint32_t val;
|
||||
|
||||
|
|
|
@ -3298,6 +3298,14 @@ NTSTATUS truncate_file(fcb* fcb, uint64_t end, PIRP Irp, LIST_ENTRY* rollback) {
|
|||
}
|
||||
|
||||
fcb->inode_item.st_blocks += end;
|
||||
|
||||
fcb->inode_item.st_size = end;
|
||||
fcb->inode_item_changed = true;
|
||||
TRACE("setting st_size to %I64x\n", end);
|
||||
|
||||
fcb->Header.AllocationSize.QuadPart = sector_align(fcb->inode_item.st_size, fcb->Vcb->superblock.sector_size);
|
||||
fcb->Header.FileSize.QuadPart = fcb->inode_item.st_size;
|
||||
fcb->Header.ValidDataLength.QuadPart = fcb->inode_item.st_size;
|
||||
}
|
||||
|
||||
ExFreePool(buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue