From 14c58ad1bdefeeaeb65bb5f5e18a46b9aa6be811 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 6 Sep 2020 21:54:42 +0200 Subject: [PATCH] ufs2: implement scan_partition Not needed by fs_shell but required to use the driver natively in Haiku. Change-Id: I547ab4c0637230d447f437cb47a419734a0401e7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3196 Reviewed-by: waddlesplash --- .../file_systems/ufs2/kernel_interface.cpp | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp b/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp index 5e46824009..9607d29140 100644 --- a/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/ufs2/kernel_interface.cpp @@ -38,7 +38,7 @@ iterative_io_get_vecs_hook(void *cookie, io_request *request, off_t offset, //! ufs2_io() callback hook static status_t iterative_io_finished_hook(void *cookie, io_request *request, status_t status, - bool partialTransfer, size_t bytesTransferred) + bool partialTransfer, size_t bytesTransferred) { return B_NOT_SUPPORTED; } @@ -49,14 +49,14 @@ iterative_io_finished_hook(void *cookie, io_request *request, status_t status, static float ufs2_identify_partition(int fd, partition_data *partition, void **_cookie) { - ufs2_super_block superBlock; - status_t status = Volume::Identify(fd, &superBlock); - if (status != B_OK) - return -1; + ufs2_super_block superBlock; + status_t status = Volume::Identify(fd, &superBlock); + if (status != B_OK) + return -1; - identify_cookie* cookie = new identify_cookie; - memcpy(&cookie->super_block, &superBlock, sizeof(ufs2_super_block)); - *_cookie = cookie; + identify_cookie* cookie = new identify_cookie; + memcpy(&cookie->super_block, &superBlock, sizeof(ufs2_super_block)); + *_cookie = cookie; return 0.8f; } @@ -65,14 +65,26 @@ ufs2_identify_partition(int fd, partition_data *partition, void **_cookie) static status_t ufs2_scan_partition(int fd, partition_data *partition, void *_cookie) { - return B_NOT_SUPPORTED; + identify_cookie* cookie = (identify_cookie*)_cookie; + + partition->status = B_PARTITION_VALID; + partition->flags |= B_PARTITION_FILE_SYSTEM | B_PARTITION_READ_ONLY; + partition->block_size = cookie->super_block.fs_bsize; + partition->content_size = partition->block_size + * cookie->super_block.fs_size; + partition->content_name = strdup(cookie->super_block.fs_volname); + if (partition->content_name == NULL) + return B_NO_MEMORY; + + return B_OK; } static void ufs2_free_identify_partition_cookie(partition_data *partition, void *_cookie) { - dprintf("Unsupported in ufs2 currently.\n"); + identify_cookie* cookie = (identify_cookie*)_cookie; + delete cookie; return; }