From f2cff39f276b16ca2240a7a11b9ccfd7a8eac42c Mon Sep 17 00:00:00 2001 From: Lucjan Bryndza Date: Thu, 28 Jan 2021 14:03:35 +0100 Subject: [PATCH] [EGD-5515] Remove unused code lfxextension Remove unused code for detecting block size from user blocks --- .../include/littlefs/lfs_extension.h | 29 -------- .../lfsfs/lfsextension/src/lfs_extension.c | 67 ------------------- 2 files changed, 96 deletions(-) delete mode 100644 module-vfs/thirdparty/lfsfs/lfsextension/include/littlefs/lfs_extension.h delete mode 100644 module-vfs/thirdparty/lfsfs/lfsextension/src/lfs_extension.c diff --git a/module-vfs/thirdparty/lfsfs/lfsextension/include/littlefs/lfs_extension.h b/module-vfs/thirdparty/lfsfs/lfsextension/include/littlefs/lfs_extension.h deleted file mode 100644 index a352361b83da2805c273aae9ddac64fdd030c2c3..0000000000000000000000000000000000000000 --- a/module-vfs/thirdparty/lfsfs/lfsextension/include/littlefs/lfs_extension.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -/* NOTE: Currently littlefs doesn't support auto detecting block_size and block_count - * basing on the data stored in the the super block of formatted filesystem. - * It expect data passed during filesystem initialization. - * This extension implements really naive algorithm for finding first - *superblock entry and read block_size and blocks count from the super block - */ - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - /** - * Try to setup config structure based on the superblock information - * @param cfg LFS config structure - * @return 0 or success otherwise error - */ - int lfs_extension_read_config_from_superblock(struct lfs_config *cfg, size_t sector_size) - __attribute__((nonnull(1))); - -#ifdef __cplusplus -} -#endif diff --git a/module-vfs/thirdparty/lfsfs/lfsextension/src/lfs_extension.c b/module-vfs/thirdparty/lfsfs/lfsextension/src/lfs_extension.c deleted file mode 100644 index 4d1920d86ce90a1d6afca9747b5920ecfeaa82cc..0000000000000000000000000000000000000000 --- a/module-vfs/thirdparty/lfsfs/lfsextension/src/lfs_extension.c +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. -// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md - -#include - -static inline void lfs_superblock_fromle32(lfs_superblock_t *superblock) -{ - superblock->version = lfs_fromle32(superblock->version); - superblock->block_size = lfs_fromle32(superblock->block_size); - superblock->block_count = lfs_fromle32(superblock->block_count); - superblock->name_max = lfs_fromle32(superblock->name_max); - superblock->file_max = lfs_fromle32(superblock->file_max); - superblock->attr_max = lfs_fromle32(superblock->attr_max); -} - -static void *memstr(const void *mem, size_t memsize, const char *str) -{ - const size_t findstr_len = strlen(str); - const uint8_t *memu8p = mem; - if (findstr_len > memsize) { - return NULL; - } - uint8_t *match = memchr(memu8p, str[0], memsize); - if (match != NULL) { - size_t remaining = memsize - ((uint8_t *)match - memu8p); - if (findstr_len <= remaining) { - if (memcmp(match, str, findstr_len) == 0) { - return match; - } - } - } - return NULL; -} - -int lfs_extension_read_config_from_superblock(struct lfs_config *cfg, size_t sector_size) -{ - uint8_t sect_buf[sector_size] __attribute__((aligned)); - if (!cfg->read) { - return LFS_ERR_IO; - } - lfs_superblock_t *lfs_superblock; - if (sector_size <= sizeof(*lfs_superblock)) { - return LFS_ERR_IO; - } - lfs_size_t block_size_saved = cfg->block_size; - int err = cfg->read(cfg, 0, 0, sect_buf, sector_size); - cfg->block_size = block_size_saved; - if (err) { - return err; - } - const uint8_t *ptr = memstr(sect_buf, sizeof sect_buf, "littlefs"); - if (!ptr) { - return LFS_ERR_NOENT; - } - lfs_superblock = (lfs_superblock_t *)(ptr + 12); - lfs_superblock_fromle32(lfs_superblock); - // check version - uint16_t major_version = (0xffff & (lfs_superblock->version >> 16)); - uint16_t minor_version = (0xffff & (lfs_superblock->version >> 0)); - if ((major_version != LFS_DISK_VERSION_MAJOR || minor_version > LFS_DISK_VERSION_MINOR)) { - LFS_ERROR("Invalid version v%" PRIu16 ".%" PRIu16, major_version, minor_version); - return LFS_ERR_INVAL; - } - cfg->block_size = lfs_superblock->block_size; - cfg->block_count = lfs_superblock->block_count; - return LFS_ERR_OK; -}