From ccee2a8b3513097cd457985e88c6a959320ffaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 5 Aug 2009 11:09:59 +0000 Subject: [PATCH] * "mountvolume" now can also mount by device path. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32128 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/mountvolume.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/bin/mountvolume.cpp b/src/bin/mountvolume.cpp index 4c3ff626da..16ba9fa392 100644 --- a/src/bin/mountvolume.cpp +++ b/src/bin/mountvolume.cpp @@ -368,16 +368,25 @@ main(int argc, char** argv) if (entry.GetPath(&path) != B_OK) continue; - // a file with this name exists, so try to mount it - partition_id id = roster.RegisterFileDevice(path.Path()); - if (id < B_OK) - continue; - + partition_id id = -1; BDiskDevice device; BPartition* partition; - if (roster.GetPartitionWithID(id, &device, &partition) != B_OK) { - roster.UnregisterFileDevice(id); - continue; + + 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) { + roster.UnregisterFileDevice(id); + continue; + } } status_t status = partition->Mount(NULL, @@ -386,14 +395,14 @@ main(int argc, char** argv) if (status >= B_OK) { BPath mountPoint; partition->GetMountPoint(&mountPoint); - printf("Image \"%s\" mounted successfully at \"%s\".\n", name, - mountPoint.Path()); + printf("%s \"%s\" mounted successfully at \"%s\".\n", + id < 0 ? "Device" : "Image", name, mountPoint.Path()); } } if (status >= B_OK) { // remove from list mountVisitor.toMount.erase(name); - } else + } else if (id >= 0) roster.UnregisterFileDevice(id); }