* "mountvolume" now can also mount by device path.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32128 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+17
-8
@@ -368,17 +368,26 @@ main(int argc, char** argv)
|
|||||||
if (entry.GetPath(&path) != B_OK)
|
if (entry.GetPath(&path) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// a file with this name exists, so try to mount it
|
partition_id id = -1;
|
||||||
partition_id id = roster.RegisterFileDevice(path.Path());
|
|
||||||
if (id < B_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BDiskDevice device;
|
BDiskDevice device;
|
||||||
BPartition* partition;
|
BPartition* partition;
|
||||||
|
|
||||||
|
if (!strncmp(path.Path(), "/dev/", 5)) {
|
||||||
|
// seems to be a device path
|
||||||
|
if (roster.GetPartitionForPath(path.Path(), &device, &partition)
|
||||||
|
!= B_OK)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// a file with this name exists, so try to mount it
|
||||||
|
id = roster.RegisterFileDevice(path.Path());
|
||||||
|
if (id < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (roster.GetPartitionWithID(id, &device, &partition) != B_OK) {
|
if (roster.GetPartitionWithID(id, &device, &partition) != B_OK) {
|
||||||
roster.UnregisterFileDevice(id);
|
roster.UnregisterFileDevice(id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
status_t status = partition->Mount(NULL,
|
status_t status = partition->Mount(NULL,
|
||||||
mountVisitor.readOnly ? B_MOUNT_READ_ONLY : 0);
|
mountVisitor.readOnly ? B_MOUNT_READ_ONLY : 0);
|
||||||
@@ -386,14 +395,14 @@ main(int argc, char** argv)
|
|||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
BPath mountPoint;
|
BPath mountPoint;
|
||||||
partition->GetMountPoint(&mountPoint);
|
partition->GetMountPoint(&mountPoint);
|
||||||
printf("Image \"%s\" mounted successfully at \"%s\".\n", name,
|
printf("%s \"%s\" mounted successfully at \"%s\".\n",
|
||||||
mountPoint.Path());
|
id < 0 ? "Device" : "Image", name, mountPoint.Path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
// remove from list
|
// remove from list
|
||||||
mountVisitor.toMount.erase(name);
|
mountVisitor.toMount.erase(name);
|
||||||
} else
|
} else if (id >= 0)
|
||||||
roster.UnregisterFileDevice(id);
|
roster.UnregisterFileDevice(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user