Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BTRFS #232

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-btrfs.c \
image-file.c \
image-fip.c \
image-fit.c \
Expand Down Expand Up @@ -70,6 +71,7 @@ EXTRA_DIST += \
test/ext4test.0.dump \
test/ext4test.1.dump \
test/f2fs.config \
test/btrfs.config \
test/fip.config \
test/fit.its \
test/fit.config \
Expand Down
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -670,3 +670,13 @@ To include a ``"foo.cfg"`` config file, use the following statement::
include("foo.cfg")

This allows to re-use, for example flash configuration files, across different image configurations.

# To develop and run the test

```bash
./autogen.sh
./configure CFLAGS='-g -O2' --prefix=/usr
make
make check-TESTS
# and check error in test-suite.log
```
5 changes: 5 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ static struct config opts[] = {
.opt = CFG_STR("mkfsf2fs", NULL, CFGF_NONE),
.env = "GENIMAGE_MKFSF2FS",
.def = "mkfs.f2fs",
}, {
.name = "mkfsbtrfs",
.opt = CFG_STR("mkfsfbtrfs", NULL, CFGF_NONE),
.env = "GENIMAGE_MKFSBTRFS",
.def = "mkfs.btrfs",
}, {
.name = "sloadf2fs",
.opt = CFG_STR("sloadf2fs", NULL, CFGF_NONE),
Expand Down
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,
&btrfs_handler,
&file_handler,
&fit_handler,
&fip_handler,
Expand Down
1 change: 1 addition & 0 deletions genimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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 btrfs_handler;
extern struct image_handler file_handler;
extern struct image_handler flash_handler;
extern struct image_handler hdimage_handler;
Expand Down
60 changes: 60 additions & 0 deletions image-btrfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2022 Tomas Mudrunka <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <confuse.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>

#include "genimage.h"

static int btrfs_generate(struct image *image)
{
int ret;

char *label = cfg_getstr(image->imagesec, "label");

ret = prepare_image(image, image->size);
if(ret)
return ret;


ret = systemp(image, "%s %s %s %s '%s' '%s'",
get_opt("mkfsbtrfs"),
label ? "-L" : "",
label ? label : "",
label ? "-r" : "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. -r is the option for the rootfs and should not depend on the label, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im go look for this.

mountpath(image), /* source dir */
imageoutfile(image)); /* destination file */

if(ret || image->empty)
return ret;


return ret;
}

static cfg_opt_t btrfs_opts[] = {
CFG_STR("label", NULL, CFGF_NONE),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an extraargs option like in all other filesystem images.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

CFG_END()
};

struct image_handler btrfs_handler = {
.type = "btrfs",
.generate = btrfs_generate,
.opts = btrfs_opts,
};
6 changes: 6 additions & 0 deletions test/btrfs.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image test.btrfs {
btrfs {
label = "btrfstest"
}
size = 64M
}
8 changes: 8 additions & 0 deletions test/filesystem.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ test_expect_success mkfs_f2fs,sload_f2fs,fsck_f2fs "f2fs" "
fsck.f2fs images/test.f2fs
"

exec_test_set_prereq mkfs.btrfs
exec_test_set_prereq sload.btrfs
exec_test_set_prereq fsck.btrfs
test_expect_success mkfs_btrfs,fsck_btrfs "btrfs" "
run_genimage_root btrfs.config test.btrfs
liberodark marked this conversation as resolved.
Show resolved Hide resolved
btrfsck images/test.btrfs
"

exec_test_set_prereq mksquashfs
test_expect_success mksquashfs "squashfs" "
run_genimage_root squashfs.config test.squashfs &&
Expand Down
Loading