Skip to content

Commit

Permalink
Merge pull request #277 from Harvie/master
Browse files Browse the repository at this point in the history
Initial MDRAID support, F2FS documentation
  • Loading branch information
michaelolbrich authored Jan 17, 2025
2 parents e9c769e + f3c7133 commit 32498b0
Show file tree
Hide file tree
Showing 10 changed files with 531 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
matrix:
include:
- os: ubuntu-22.04
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm
- os: ubuntu-22.04
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm
fake: sudo rm /usr/include/linux/fiemap.h /usr/include/linux/fs.h
env: ac_cv_func_fallocate=no
- os: ubuntu-20.04
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools mdadm

steps:
- name: Inspect environment
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ genimage_SOURCES = \
image-cramfs.c \
image-ext2.c \
image-f2fs.c \
image-mdraid.c \
image-btrfs.c \
image-file.c \
image-fip.c \
Expand Down Expand Up @@ -75,6 +76,7 @@ EXTRA_DIST += \
test/ext4test.1.dump \
test/ext4test.2.dump \
test/f2fs.config \
test/mdraid.config \
test/btrfs.config \
test/fip.config \
test/fit.its \
Expand Down
55 changes: 53 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Here are all options for images:
Additionally each image can have one of the following sections describing the
type of the image:

cpio, cramfs, ext2, ext3, ext4, file, flash, hdimage, iso, jffs2, qemu, squashfs,
tar, ubi, ubifs, vfat.
cpio, cramfs, ext2, ext3, ext4, f2fs, file, flash, hdimage, iso,
jffs2, mdraid, qemu, squashfs, tar, ubi, ubifs, vfat.

Partition options:

Expand Down Expand Up @@ -297,6 +297,15 @@ Options:
:usage-type: Specify the usage type for the filesystem. Only valid with mke2fs.
More details can be found in the mke2fs man-page.

f2fs
****
Generates F2FS images.

Options:

:label: Specify the volume-label.
:extraargs: Extra arguments passed to mkfs.f2fs

file
****

Expand Down Expand Up @@ -472,6 +481,44 @@ Options:

:extraargs: Extra arguments passed to mkfs.jffs2

mdraid
****
Generates MD RAID images.

Options:

:label: Text name of array (optional) eg: localhost:42
:level: RAID level, currently only level 1 (default) is supported
:devices: Number of devices in array (default 1)
:role: 0 based index of this image in whole array. (autoassigned by default)
:timestamp: Unix timestamp of array creation (current time by default, has to match across array devices)
:raid-uuid: UUID of whole array (has to be identical across all disks in array, random by default)
:disk-uuid: UUID of disk (has to be unique for each array member disk, random by default)
:image: Image of data to be preloaded into array (optional)
:parent: Image to inherit array identity/config from (when creating extra members of existing array).
Effectively overrides all array-wide options mentioned here and replaces them with values from parent.

For example here only the first image has configuration and the UUID/timestamp is generated on demand::

image mdraid-a.img {
mdraid {
level = 1
devices = 2
image = "mdraid-ext4.img"
}
}

Then to create second member to that array we just inherit config from the parent member::

image mdraid-b.img {
mdraid {
parent = "mdraid-a.img"
}
}

Default role number is 0 for the parent image and when other images inherit configuration from it, they are assigned roles from autoincrementing counter.


qemu
****
Generates a QEMU image. Needs at least one valid partition.
Expand Down Expand Up @@ -683,6 +730,7 @@ variable.
:mmd: path to the mmd program (default mmd)
:mkcramfs: path to the mkcramfs program (default mkcramfs)
:mkdosfs: path to the mkdosfs program (default mkdosfs)
:mkfsf2fs: path to the mkfs.f2fs program (default mkfs.f2fs)
:mkfsjffs2: path to the mkfs.jffs2 program (default mkfs.jffs2)
:mkfsubifs: path to the mkfs.ubifs program (default mkfs.ubifs)
:mksquashfs: path to the mksquashfs program (default mksquashfs)
Expand Down Expand Up @@ -742,3 +790,6 @@ commits (e.g. using ``git commit -s``) looking as follows:
Signed-off-by: Random J Developer <[email protected]>

with your identity and email address matching the commit meta data.

Before creating pull request, please make sure your tree is passing
all unit tests by running ``make distcheck``.
1 change: 1 addition & 0 deletions genimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static struct image_handler *handlers[] = {
&ext3_handler,
&ext4_handler,
&f2fs_handler,
&mdraid_handler,
&btrfs_handler,
&file_handler,
&fit_handler,
Expand Down
6 changes: 6 additions & 0 deletions genimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ void image_debug(struct image *image, const char *fmt, ...) __attribute__ ((form
void xasprintf(char **strp, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
void xstrcatf(char **strp, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));

unsigned long long roundup(unsigned long long value, unsigned long long align);
unsigned long long rounddown(unsigned long long value, unsigned long long align);
unsigned long long min_ull(unsigned long long x, unsigned long long y);
unsigned long long max_ull(unsigned long long x, unsigned long long y);

void disable_rootpath(void);
const char *imagepath(void);
const char *inputpath(void);
Expand Down Expand Up @@ -112,6 +117,7 @@ extern struct image_handler ext2_handler;
extern struct image_handler ext3_handler;
extern struct image_handler ext4_handler;
extern struct image_handler f2fs_handler;
extern struct image_handler mdraid_handler;
extern struct image_handler btrfs_handler;
extern struct image_handler file_handler;
extern struct image_handler flash_handler;
Expand Down
20 changes: 0 additions & 20 deletions image-hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,6 @@ ct_assert(sizeof(struct gpt_partition_entry) == 128);
#define GPT_PE_FLAG_HIDDEN (1ULL << 62)
#define GPT_PE_FLAG_NO_AUTO (1ULL << 63)

static unsigned long long roundup(unsigned long long value, unsigned long long align)
{
return ((value - 1)/align + 1) * align;
}

static unsigned long long rounddown(unsigned long long value, unsigned long long align)
{
return value - (value % align);
}

static unsigned long long min_ull(unsigned long long x, unsigned long long y)
{
return x < y ? x : y;
}

static unsigned long long max_ull(unsigned long long x, unsigned long long y)
{
return x > y ? x : y;
}

static unsigned long long partition_end(const struct partition *part)
{
return part->offset + part->size;
Expand Down
Loading

0 comments on commit 32498b0

Please sign in to comment.