diff --git a/headers/os/drivers/fs_interface.h b/headers/os/drivers/fs_interface.h index fa5893cd23..03d867b131 100644 --- a/headers/os/drivers/fs_interface.h +++ b/headers/os/drivers/fs_interface.h @@ -294,6 +294,8 @@ struct file_system_module_info { const char* parameters, disk_job_id job); status_t (*initialize)(int fd, partition_id partition, const char* name, const char* parameters, off_t partitionSize, disk_job_id job); + status_t (*uninitialize)(int fd, partition_id partition, + off_t partitionSize, uint32 blockSize, disk_job_id job); }; diff --git a/headers/private/fs_shell/fssh_fs_interface.h b/headers/private/fs_shell/fssh_fs_interface.h index b7c04d84b7..6a0fdd0a2b 100644 --- a/headers/private/fs_shell/fssh_fs_interface.h +++ b/headers/private/fs_shell/fssh_fs_interface.h @@ -326,6 +326,9 @@ typedef struct fssh_file_system_module_info { fssh_status_t (*initialize)(int fd, fssh_partition_id partition, const char *name, const char *parameters, fssh_off_t partitionSize, fssh_disk_job_id job); + fssh_status_t (*uninitialize)(int fd, fssh_partition_id partition, + fssh_off_t partitionSize, uint32_t blockSize, + fssh_disk_job_id job); } fssh_file_system_module_info; diff --git a/headers/private/kernel/disk_device_manager/KFileSystem.h b/headers/private/kernel/disk_device_manager/KFileSystem.h index bda46ecf6f..409cd9c4a0 100644 --- a/headers/private/kernel/disk_device_manager/KFileSystem.h +++ b/headers/private/kernel/disk_device_manager/KFileSystem.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2011, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -53,6 +53,8 @@ public: virtual status_t Initialize(KPartition* partition, const char* name, const char* parameters, disk_job_id job); + virtual status_t Uninitialize(KPartition* partition, + disk_job_id job); protected: virtual status_t LoadModule(); diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index 540ac9268e..8d265fb390 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -2293,6 +2293,28 @@ bfs_initialize(int fd, partition_id partitionID, const char* name, } +static status_t +bfs_uninitialize(int fd, partition_id partitionID, off_t partitionSize, + uint32 blockSize, disk_job_id job) +{ + if (blockSize == 0) + return B_BAD_VALUE; + + update_disk_device_job_progress(job, 0.0); + + // just overwrite the superblock + disk_super_block superBlock; + memset(&superBlock, 0, sizeof(superBlock)); + + if (write_pos(fd, 512, &superBlock, sizeof(superBlock)) < 0) + return errno; + + update_disk_device_job_progress(job, 1.0); + + return B_OK; +} + + // #pragma mark - @@ -2477,6 +2499,7 @@ static file_system_module_info sBeFileSystem = { NULL, // set_content_name NULL, // set_content_parameters bfs_initialize, + bfs_uninitialize }; module_info* modules[] = { diff --git a/src/system/kernel/disk_device_manager/KFileSystem.cpp b/src/system/kernel/disk_device_manager/KFileSystem.cpp index 669a1b8ae2..90f0018a7a 100644 --- a/src/system/kernel/disk_device_manager/KFileSystem.cpp +++ b/src/system/kernel/disk_device_manager/KFileSystem.cpp @@ -1,9 +1,9 @@ /* - * Copyright 2003-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2011, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: - * Ingo Weinhold, bonefish@cs.tu-berlin.de + * Ingo Weinhold, ingo_weinhold@gmx.de */ #include "KFileSystem.h" @@ -221,6 +221,31 @@ KFileSystem::Initialize(KPartition* partition, const char* name, } +status_t +KFileSystem::Uninitialize(KPartition* partition, disk_job_id job) +{ + // check parameters + if (partition == NULL || fModule == NULL) + return B_BAD_VALUE; + if (fModule->uninitialize == NULL) + 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->uninitialize(fd, partition->ID(), partition->Size(), + partition->BlockSize(), job); + + // cleanup and return + close(fd); + return result; +} + + // LoadModule status_t KFileSystem::LoadModule()