Skip to content

Commit 7860c54

Browse files
committed
Volume: Open volume root using open_entry_ref
1 parent b04917a commit 7860c54

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/kits/storage/Volume.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ BVolume::SetTo(dev_t device)
7272
// uninitialize
7373
Unset();
7474
// check the parameter
75-
status_t error = (device >= 0 ? B_OK : B_BAD_VALUE);
75+
status_t error = (device != B_INVALID_DEV ? B_OK : B_BAD_VALUE);
7676
if (error == B_OK) {
7777
fs_info info;
7878
if (fs_stat_dev(device, &info) != 0)
@@ -117,7 +117,13 @@ BVolume::GetRootDirectory(BDirectory *directory) const
117117
error = errno;
118118
// init the directory
119119
if (error == B_OK) {
120-
node_ref ref(info.dev, info.root);
120+
int dirFd = _kern_open_entry_ref(info.dev, info.root, NULL,
121+
O_RDWR, 0);
122+
123+
if (dirFd < 0)
124+
return dirFd;
125+
126+
node_ref ref(dirFd);
121127
error = directory->SetTo(&ref);
122128
}
123129
return error;

0 commit comments

Comments
 (0)