Skip to content

Commit

Permalink
load_dir_children: initialize hash tables even if directory empty
Browse files Browse the repository at this point in the history
  • Loading branch information
maharmstone committed Dec 29, 2016
1 parent cce99f2 commit c93b7be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4006,7 +4006,7 @@ static NTSTATUS STDCALL mount_vol(PDEVICE_OBJECT DeviceObject, PIRP Irp) {
goto exit;
}

Status = load_dir_children(root_fcb, Irp);
Status = load_dir_children(root_fcb, TRUE, Irp);
if (!NT_SUCCESS(Status)) {
ERR("load_dir_children returned %08x\n", Status);
goto exit;
Expand Down
2 changes: 1 addition & 1 deletion src/btrfs_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ void insert_fileref_child(file_ref* parent, file_ref* child, BOOL do_lock);
NTSTATUS fcb_get_last_dir_index(fcb* fcb, UINT64* index, PIRP Irp);
NTSTATUS verify_vcb(device_extension* Vcb, PIRP Irp);
NTSTATUS load_csum(device_extension* Vcb, UINT32* csum, UINT64 start, UINT64 length, PIRP Irp);
NTSTATUS load_dir_children(fcb* fcb, PIRP Irp);
NTSTATUS load_dir_children(fcb* fcb, BOOL ignore_size, PIRP Irp);
NTSTATUS add_dir_child(fcb* fcb, UINT64 inode, BOOL subvol, UINT64 index, PANSI_STRING utf8, PUNICODE_STRING name, PUNICODE_STRING name_uc, UINT8 type, dir_child** pdc);

// in fsctl.c
Expand Down
9 changes: 6 additions & 3 deletions src/create.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ NTSTATUS load_csum(device_extension* Vcb, UINT32* csum, UINT64 start, UINT64 len
return STATUS_SUCCESS;
}

NTSTATUS load_dir_children(fcb* fcb, PIRP Irp) {
NTSTATUS load_dir_children(fcb* fcb, BOOL ignore_size, PIRP Irp) {
KEY searchkey;
traverse_ptr tp, next_tp;
NTSTATUS Status;
Expand All @@ -703,6 +703,9 @@ NTSTATUS load_dir_children(fcb* fcb, PIRP Irp) {

RtlZeroMemory(fcb->hash_ptrs_uc, sizeof(LIST_ENTRY*) * 256);

if (!ignore_size && fcb->inode_item.st_size == 0)
return STATUS_SUCCESS;

searchkey.obj_id = fcb->inode;
searchkey.obj_type = TYPE_DIR_INDEX;
searchkey.offset = 2;
Expand Down Expand Up @@ -1187,8 +1190,8 @@ NTSTATUS open_fcb(device_extension* Vcb, root* subvol, UINT64 inode, UINT8 type,
}
}

if (fcb->type == BTRFS_TYPE_DIRECTORY && fcb->inode_item.st_size > 0) {
Status = load_dir_children(fcb, Irp);
if (fcb->type == BTRFS_TYPE_DIRECTORY) {
Status = load_dir_children(fcb, FALSE, Irp);
if (!NT_SUCCESS(Status)) {
ERR("load_dir_children returned %08x\n", Status);
free_fcb(fcb);
Expand Down

0 comments on commit c93b7be

Please sign in to comment.