kernel/fs: Block mounting partitions that are already mounted.
Previously this actually succeeded, which could obviously cause
disk corruption and other such problems.
While at it, clean up some code style.
Fixes #16734. Related to #19303.
Diff
src/system/kernel/fs/vfs.cpp | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
@@ -7522,7 +7522,7 @@
}
}
if (!partition) {
if (partition == NULL) {
TRACE(("fs_mount(): Partition `%s' not found.\n",
normalizedDevice.Path()));
return B_ENTRY_NOT_FOUND;
@@ -7538,28 +7538,31 @@
KDiskDevice* diskDevice = NULL;
if (partition) {
if (partition != NULL) {
diskDevice = ddm->WriteLockDevice(partition->Device()->ID());
if (!diskDevice) {
if (diskDevice == NULL) {
TRACE(("fs_mount(): Failed to lock disk device!\n"));
return B_ERROR;
}
}
DeviceWriteLocker writeLocker(diskDevice, true);
if (partition != NULL) {
if (partition->IsBusy()) {
TRACE(("fs_mount(): Partition is busy.\n"));
return B_BUSY;
}
if (partition->IsMounted()) {
TRACE(("fs_mount(): Partition is already mounted.\n"));
return B_BUSY;
}
if (fsName == NULL) {
KDiskSystem* diskSystem = partition->DiskSystem();
if (!diskSystem) {
if (diskSystem == NULL) {
TRACE(("fs_mount(): No FS name was given, and the DDM didn't "
"recognize it.\n"));
return B_BAD_VALUE;