diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-28 15:13:04 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-28 15:13:04 +0200 |
commit | abfa3ec0598ff431407224c6b81682f7d0d35495 (patch) | |
tree | e5387999595e1f0c383c4aced38fe5a24dd90ef0 | |
parent | aae428f0bf0fcd6cd0a2503b3a50de43785b8fd0 (diff) | |
download | busybox-abfa3ec0598ff431407224c6b81682f7d0d35495.tar.gz |
move storage helpers to libbb.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | e2fsprogs/tune2fs.c | 17 | ||||
-rw-r--r-- | include/libbb.h | 17 | ||||
-rw-r--r-- | util-linux/mkfs_ext2.c | 17 | ||||
-rw-r--r-- | util-linux/mkfs_reiser.c | 16 | ||||
-rw-r--r-- | util-linux/mkfs_vfat.c | 13 |
5 files changed, 17 insertions, 63 deletions
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index a1caf011c..f7fcd88bf 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c @@ -39,23 +39,6 @@ #include <linux/fs.h> #include "bb_e2fs_defs.h" -// storage helpers -char BUG_wrong_field_size(void); -#define STORE_LE(field, value) \ -do { \ - if (sizeof(field) == 4) \ - field = SWAP_LE32(value); \ - else if (sizeof(field) == 2) \ - field = SWAP_LE16(value); \ - else if (sizeof(field) == 1) \ - field = (value); \ - else \ - BUG_wrong_field_size(); \ -} while (0) - -#define FETCH_LE32(field) \ - (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) - enum { OPT_L = 1 << 0, // label OPT_c = 1 << 1, // max mount count diff --git a/include/libbb.h b/include/libbb.h index 7cad12c44..61fa1e03e 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -2127,6 +2127,23 @@ extern const char bb_default_login_shell[] ALIGN1; # define FB_0 "/dev/fb0" #endif +// storage helpers for mk*fs utilities +char BUG_wrong_field_size(void); +#define STORE_LE(field, value) \ +do { \ + if (sizeof(field) == 4) \ + field = SWAP_LE32((uint32_t)(value)); \ + else if (sizeof(field) == 2) \ + field = SWAP_LE16((uint16_t)(value)); \ + else if (sizeof(field) == 1) \ + field = (uint8_t)(value); \ + else \ + BUG_wrong_field_size(); \ +} while (0) + +#define FETCH_LE32(field) \ + (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) + #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index f524bc239..bda168f1e 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -78,23 +78,6 @@ #define EXT2_FLAGS_SIGNED_HASH 0x0001 #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 -// storage helpers -char BUG_wrong_field_size(void); -#define STORE_LE(field, value) \ -do { \ - if (sizeof(field) == 4) \ - field = SWAP_LE32((uint32_t)(value)); \ - else if (sizeof(field) == 2) \ - field = SWAP_LE16((uint16_t)(value)); \ - else if (sizeof(field) == 1) \ - field = (uint8_t)(value); \ - else \ - BUG_wrong_field_size(); \ -} while (0) - -#define FETCH_LE32(field) \ - (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) - // All fields are little-endian struct ext2_dir { uint32_t inode1; diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c index 390aef86c..b4c8dda6f 100644 --- a/util-linux/mkfs_reiser.c +++ b/util-linux/mkfs_reiser.c @@ -28,22 +28,6 @@ #include "libbb.h" #include <linux/fs.h> -char BUG_wrong_field_size(void); -#define STORE_LE(field, value) \ -do { \ - if (sizeof(field) == 4) \ - field = SWAP_LE32(value); \ - else if (sizeof(field) == 2) \ - field = SWAP_LE16(value); \ - else if (sizeof(field) == 1) \ - field = (value); \ - else \ - BUG_wrong_field_size(); \ -} while (0) - -#define FETCH_LE32(field) \ - (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) - struct journal_params { uint32_t jp_journal_1st_block; /* where does journal start from on its device */ uint32_t jp_journal_dev; /* journal device st_rdev */ diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 92f0e3b1a..6a6dc652f 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c @@ -206,19 +206,6 @@ static const char boot_code[] ALIGN1 = #define MARK_CLUSTER(cluster, value) \ ((uint32_t *)fat)[cluster] = SWAP_LE32(value) -void BUG_unsupported_field_size(void); -#define STORE_LE(field, value) \ -do { \ - if (sizeof(field) == 4) \ - field = SWAP_LE32((uint32_t)(value)); \ - else if (sizeof(field) == 2) \ - field = SWAP_LE16((uint16_t)(value)); \ - else if (sizeof(field) == 1) \ - field = (uint8_t)(value); \ - else \ - BUG_unsupported_field_size(); \ -} while (0) - /* compat: * mkdosfs 2.11 (12 Mar 2005) * Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] |