Skip to content

Commit 32498b0

Browse files
Merge pull request #277 from Harvie/master
Initial MDRAID support, F2FS documentation
2 parents e9c769e + f3c7133 commit 32498b0

10 files changed

+531
-25
lines changed

.github/workflows/tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
matrix:
1010
include:
1111
- os: ubuntu-22.04
12-
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools
12+
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm
1313
- os: ubuntu-22.04
14-
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools
14+
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm
1515
fake: sudo rm /usr/include/linux/fiemap.h /usr/include/linux/fs.h
1616
env: ac_cv_func_fallocate=no
1717
- os: ubuntu-20.04
18-
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools
18+
pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools mdadm
1919

2020
steps:
2121
- name: Inspect environment

Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ genimage_SOURCES = \
2323
image-cramfs.c \
2424
image-ext2.c \
2525
image-f2fs.c \
26+
image-mdraid.c \
2627
image-btrfs.c \
2728
image-file.c \
2829
image-fip.c \
@@ -75,6 +76,7 @@ EXTRA_DIST += \
7576
test/ext4test.1.dump \
7677
test/ext4test.2.dump \
7778
test/f2fs.config \
79+
test/mdraid.config \
7880
test/btrfs.config \
7981
test/fip.config \
8082
test/fit.its \

README.rst

+53-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Here are all options for images:
105105
Additionally each image can have one of the following sections describing the
106106
type of the image:
107107

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

111111
Partition options:
112112

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

300+
f2fs
301+
****
302+
Generates F2FS images.
303+
304+
Options:
305+
306+
:label: Specify the volume-label.
307+
:extraargs: Extra arguments passed to mkfs.f2fs
308+
300309
file
301310
****
302311

@@ -472,6 +481,44 @@ Options:
472481

473482
:extraargs: Extra arguments passed to mkfs.jffs2
474483

484+
mdraid
485+
****
486+
Generates MD RAID images.
487+
488+
Options:
489+
490+
:label: Text name of array (optional) eg: localhost:42
491+
:level: RAID level, currently only level 1 (default) is supported
492+
:devices: Number of devices in array (default 1)
493+
:role: 0 based index of this image in whole array. (autoassigned by default)
494+
:timestamp: Unix timestamp of array creation (current time by default, has to match across array devices)
495+
:raid-uuid: UUID of whole array (has to be identical across all disks in array, random by default)
496+
:disk-uuid: UUID of disk (has to be unique for each array member disk, random by default)
497+
:image: Image of data to be preloaded into array (optional)
498+
:parent: Image to inherit array identity/config from (when creating extra members of existing array).
499+
Effectively overrides all array-wide options mentioned here and replaces them with values from parent.
500+
501+
For example here only the first image has configuration and the UUID/timestamp is generated on demand::
502+
503+
image mdraid-a.img {
504+
mdraid {
505+
level = 1
506+
devices = 2
507+
image = "mdraid-ext4.img"
508+
}
509+
}
510+
511+
Then to create second member to that array we just inherit config from the parent member::
512+
513+
image mdraid-b.img {
514+
mdraid {
515+
parent = "mdraid-a.img"
516+
}
517+
}
518+
519+
Default role number is 0 for the parent image and when other images inherit configuration from it, they are assigned roles from autoincrementing counter.
520+
521+
475522
qemu
476523
****
477524
Generates a QEMU image. Needs at least one valid partition.
@@ -683,6 +730,7 @@ variable.
683730
:mmd: path to the mmd program (default mmd)
684731
:mkcramfs: path to the mkcramfs program (default mkcramfs)
685732
:mkdosfs: path to the mkdosfs program (default mkdosfs)
733+
:mkfsf2fs: path to the mkfs.f2fs program (default mkfs.f2fs)
686734
:mkfsjffs2: path to the mkfs.jffs2 program (default mkfs.jffs2)
687735
:mkfsubifs: path to the mkfs.ubifs program (default mkfs.ubifs)
688736
:mksquashfs: path to the mksquashfs program (default mksquashfs)
@@ -742,3 +790,6 @@ commits (e.g. using ``git commit -s``) looking as follows:
742790
Signed-off-by: Random J Developer <[email protected]>
743791

744792
with your identity and email address matching the commit meta data.
793+
794+
Before creating pull request, please make sure your tree is passing
795+
all unit tests by running ``make distcheck``.

genimage.c

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static struct image_handler *handlers[] = {
4545
&ext3_handler,
4646
&ext4_handler,
4747
&f2fs_handler,
48+
&mdraid_handler,
4849
&btrfs_handler,
4950
&file_handler,
5051
&fit_handler,

genimage.h

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ void image_debug(struct image *image, const char *fmt, ...) __attribute__ ((form
1919
void xasprintf(char **strp, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
2020
void xstrcatf(char **strp, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
2121

22+
unsigned long long roundup(unsigned long long value, unsigned long long align);
23+
unsigned long long rounddown(unsigned long long value, unsigned long long align);
24+
unsigned long long min_ull(unsigned long long x, unsigned long long y);
25+
unsigned long long max_ull(unsigned long long x, unsigned long long y);
26+
2227
void disable_rootpath(void);
2328
const char *imagepath(void);
2429
const char *inputpath(void);
@@ -112,6 +117,7 @@ extern struct image_handler ext2_handler;
112117
extern struct image_handler ext3_handler;
113118
extern struct image_handler ext4_handler;
114119
extern struct image_handler f2fs_handler;
120+
extern struct image_handler mdraid_handler;
115121
extern struct image_handler btrfs_handler;
116122
extern struct image_handler file_handler;
117123
extern struct image_handler flash_handler;

image-hd.c

-20
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,6 @@ ct_assert(sizeof(struct gpt_partition_entry) == 128);
109109
#define GPT_PE_FLAG_HIDDEN (1ULL << 62)
110110
#define GPT_PE_FLAG_NO_AUTO (1ULL << 63)
111111

112-
static unsigned long long roundup(unsigned long long value, unsigned long long align)
113-
{
114-
return ((value - 1)/align + 1) * align;
115-
}
116-
117-
static unsigned long long rounddown(unsigned long long value, unsigned long long align)
118-
{
119-
return value - (value % align);
120-
}
121-
122-
static unsigned long long min_ull(unsigned long long x, unsigned long long y)
123-
{
124-
return x < y ? x : y;
125-
}
126-
127-
static unsigned long long max_ull(unsigned long long x, unsigned long long y)
128-
{
129-
return x > y ? x : y;
130-
}
131-
132112
static unsigned long long partition_end(const struct partition *part)
133113
{
134114
return part->offset + part->size;

0 commit comments

Comments
 (0)