From 6011cc673f66170139053e1c84512bd83ca316af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 17 Mar 2008 13:07:57 +0000 Subject: [PATCH] * Implemented SetContentName(), and SetContentParameters(). * Added license. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24420 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../disk_device_manager/KFileSystem.cpp | 58 +++++++++++++++---- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/src/system/kernel/disk_device_manager/KFileSystem.cpp b/src/system/kernel/disk_device_manager/KFileSystem.cpp index 7bb2721616..44c40379bb 100644 --- a/src/system/kernel/disk_device_manager/KFileSystem.cpp +++ b/src/system/kernel/disk_device_manager/KFileSystem.cpp @@ -1,4 +1,12 @@ -// KFileSystem.cpp +/* + * Copyright 2003-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, bonefish@cs.tu-berlin.de + */ + +#include "KFileSystem.h" #include #include @@ -7,9 +15,7 @@ #include #include "ddm_modules.h" -//#include "KDiskDeviceJob.h" #include "KDiskDeviceUtils.h" -#include "KFileSystem.h" #include "KPartition.h" @@ -54,7 +60,7 @@ KFileSystem::Identify(KPartition *partition, void **cookie) if (partition->Open(O_RDONLY, &fd) != B_OK) return -1; float result = fModule->identify_partition(fd, partition->PartitionData(), - cookie); + cookie); close(fd); return result; } @@ -82,8 +88,7 @@ KFileSystem::FreeIdentifyCookie(KPartition *partition, void *cookie) { if (!partition || !fModule || !fModule->free_identify_partition_cookie) return; - fModule->free_identify_partition_cookie(partition->PartitionData(), - cookie); + fModule->free_identify_partition_cookie(partition->PartitionData(), cookie); } @@ -138,8 +143,24 @@ status_t KFileSystem::SetContentName(KPartition* partition, const char* name, disk_job_id job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !fModule) + return B_BAD_VALUE; + if (!fModule->set_content_name) + return B_NOT_SUPPORTED; + + // open partition device + int fd = -1; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + + // let the module do its job + result = fModule->set_content_name(fd, partition->ID(), name, job); + + // cleanup and return + close(fd); + return result; } @@ -148,8 +169,25 @@ status_t KFileSystem::SetContentParameters(KPartition* partition, const char* parameters, disk_job_id job) { - // to be implemented - return B_ERROR; + // check parameters + if (!partition || !fModule) + return B_BAD_VALUE; + if (!fModule->set_content_parameters) + return B_NOT_SUPPORTED; + + // open partition device + int fd = -1; + status_t result = partition->Open(O_RDWR, &fd); + if (result != B_OK) + return result; + + // let the module do its job + result = fModule->set_content_parameters(fd, partition->ID(), parameters, + job); + + // cleanup and return + close(fd); + return result; }