├── .clang-format ├── .github └── workflows │ ├── format.yml │ └── tests.yml ├── .gitignore ├── COPYING ├── Makefile.am ├── README.rst ├── autogen.sh ├── config.c ├── configure.ac ├── crc32.c ├── flash.conf ├── genimage.c ├── genimage.h ├── image-android-sparse.c ├── image-btrfs.c ├── image-cpio.c ├── image-cramfs.c ├── image-erofs.c ├── image-ext2.c ├── image-f2fs.c ├── image-file.c ├── image-fip.c ├── image-fit.c ├── image-flash.c ├── image-hd.c ├── image-iso.c ├── image-jffs2.c ├── image-mdraid.c ├── image-qemu.c ├── image-rauc.c ├── image-squashfs.c ├── image-tar.c ├── image-ubi.c ├── image-ubifs.c ├── image-vfat.c ├── list.h ├── m4 ├── .gitignore └── attributes.m4 ├── test.config ├── test ├── btrfs.config ├── cpio.config ├── cramfs.config ├── erofs.config ├── erofs.dump ├── exec-check.sh ├── exec-fail.config ├── exec.config ├── ext.test ├── ext2.config ├── ext2percent.config ├── ext2test-percent.0.dump ├── ext2test-percent.1.dump ├── ext2test-percent.2.dump ├── ext2test.0.dump ├── ext2test.1.dump ├── ext2test.2.dump ├── ext3.config ├── ext3test.0.dump ├── ext3test.1.dump ├── ext3test.2.dump ├── ext4.config ├── ext4test.0.dump ├── ext4test.1.dump ├── ext4test.2.dump ├── f2fs.config ├── filesystem.test ├── fip-size.config ├── fip.config ├── fit.config ├── fit.its ├── flash-types.config ├── flash.config ├── flash.md5 ├── flash.test ├── genimage.test ├── gpt-invalid-partition-type1.config ├── gpt-invalid-partition-type2.config ├── gpt-overlap1.config ├── gpt-overlap2.config ├── gpt-overlap3.config ├── gpt-partition-types.config ├── gpt-partition-types.fdisk ├── hdimage-fail1.config ├── hdimage-fail10.config ├── hdimage-fail11.config ├── hdimage-fail2.config ├── hdimage-fail3.config ├── hdimage-fail4.config ├── hdimage-fail5.config ├── hdimage-fail6.config ├── hdimage-fail7.config ├── hdimage-fail8.config ├── hdimage-fail9.config ├── hdimage-forced-primary.config ├── hdimage-forced-primary.fdisk ├── hdimage-hybrid.config ├── hdimage-hybrid.fdisk ├── hdimage-nopart.config ├── hdimage-nopart.hexdump ├── hdimage-sparse.config ├── hdimage.config ├── hdimage.fdisk ├── hdimage.fdisk-2 ├── hdimage.test ├── hdimage2.config ├── hdimage4.config ├── hdimage4.fdisk ├── hdimage5.config ├── hdimage5.fdisk ├── hdimage6.config ├── hdimage6.fdisk ├── hdimage7.config ├── hdimage7.fdisk ├── hole.config ├── include-aaa.fdisk ├── include-bbb.fdisk ├── include-ccc.fdisk ├── include-test.config ├── include.config ├── include │ ├── aaa │ │ └── include-test.config │ └── bbb │ │ └── include-test.config ├── iso.config ├── jffs2.config ├── jffs2.md5 ├── mdraid.config ├── misc.test ├── mke2fs.0.dump ├── mke2fs.1.dump ├── mke2fs.2.dump ├── mke2fs.3.dump ├── mke2fs.conf ├── mke2fs.config ├── qemu.config ├── qemu.qcow.gz ├── rauc-openssl-ca │ ├── ca.cert.pem │ ├── rauc.cert.pem │ └── rauc.key.pem ├── rauc.config ├── sharness.sh ├── sparse-fill.config ├── sparse.config ├── squashfs.config ├── tar.config ├── test-setup.sh ├── test.raucb.info.1 ├── test.raucb.info.2 ├── test.raucb.info.3 ├── test.raucb.info.4 ├── test2.raucb.info.1 ├── test2.raucb.info.2 ├── test2.raucb.info.3 ├── test2.raucb.info.4 ├── ubi.config ├── ubifs.config └── vfat.config └── util.c /.clang-format: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | # 3 | # copied and modified from the Linux kernel. 4 | # 5 | # clang-format configuration file. Intended for clang-format >= 11. 6 | # 7 | # For more information, see: 8 | # 9 | # Documentation/dev-tools/clang-format.rst 10 | # https://clang.llvm.org/docs/ClangFormat.html 11 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html 12 | # 13 | --- 14 | AccessModifierOffset: -4 15 | AlignAfterOpenBracket: Align 16 | AlignConsecutiveAssignments: false 17 | AlignConsecutiveDeclarations: false 18 | AlignConsecutiveMacros: true 19 | AlignEscapedNewlines: Left 20 | AlignOperands: true 21 | AlignTrailingComments: false 22 | AllowAllParametersOfDeclarationOnNextLine: false 23 | AllowShortBlocksOnASingleLine: false 24 | AllowShortCaseLabelsOnASingleLine: false 25 | AllowShortFunctionsOnASingleLine: None 26 | AllowShortIfStatementsOnASingleLine: false 27 | AllowShortLoopsOnASingleLine: false 28 | AlwaysBreakAfterDefinitionReturnType: None 29 | AlwaysBreakAfterReturnType: None 30 | AlwaysBreakBeforeMultilineStrings: false 31 | AlwaysBreakTemplateDeclarations: false 32 | BinPackArguments: true 33 | BinPackParameters: true 34 | BraceWrapping: 35 | AfterClass: false 36 | AfterControlStatement: false 37 | AfterEnum: false 38 | AfterFunction: true 39 | AfterNamespace: true 40 | AfterObjCDeclaration: false 41 | AfterStruct: false 42 | AfterUnion: false 43 | AfterExternBlock: false 44 | BeforeCatch: false 45 | BeforeElse: false 46 | IndentBraces: false 47 | SplitEmptyFunction: true 48 | SplitEmptyRecord: true 49 | SplitEmptyNamespace: true 50 | BreakBeforeBinaryOperators: None 51 | BreakBeforeBraces: Custom 52 | BreakBeforeInheritanceComma: false 53 | BreakBeforeTernaryOperators: false 54 | BreakConstructorInitializersBeforeComma: false 55 | BreakConstructorInitializers: BeforeComma 56 | BreakAfterJavaFieldAnnotations: false 57 | BreakStringLiterals: false 58 | ColumnLimit: 0 59 | CommentPragmas: '^ IWYU pragma:' 60 | CompactNamespaces: false 61 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 62 | ConstructorInitializerIndentWidth: 8 63 | ContinuationIndentWidth: 8 64 | Cpp11BracedListStyle: false 65 | DerivePointerAlignment: false 66 | DisableFormat: false 67 | ExperimentalAutoDetectBinPacking: false 68 | FixNamespaceComments: false 69 | 70 | ForEachMacros: 71 | - 'hlist_for_each' 72 | - 'hlist_for_each_entry' 73 | - 'hlist_for_each_entry_continue' 74 | - 'hlist_for_each_entry_from' 75 | - 'hlist_for_each_entry_safe' 76 | - 'hlist_for_each_safe' 77 | - 'list_for_each' 78 | - 'list_for_each_entry' 79 | - 'list_for_each_entry_continue' 80 | - 'list_for_each_entry_from' 81 | - 'list_for_each_entry_reverse' 82 | - 'list_for_each_entry_safe' 83 | - 'list_for_each_entry_safe_continue' 84 | - 'list_for_each_entry_safe_from' 85 | - 'list_for_each_entry_safe_reverse' 86 | - 'list_for_each_prev' 87 | - 'list_for_each_safe' 88 | 89 | IncludeBlocks: Preserve 90 | IncludeCategories: 91 | - Regex: '.*' 92 | Priority: 1 93 | IncludeIsMainRegex: '(Test)?$' 94 | IndentCaseLabels: false 95 | IndentGotoLabels: false 96 | IndentPPDirectives: None 97 | IndentWidth: 8 98 | IndentWrappedFunctionNames: false 99 | JavaScriptQuotes: Leave 100 | JavaScriptWrapImports: true 101 | KeepEmptyLinesAtTheStartOfBlocks: false 102 | MacroBlockBegin: '' 103 | MacroBlockEnd: '' 104 | MaxEmptyLinesToKeep: 1 105 | NamespaceIndentation: None 106 | ObjCBinPackProtocolList: Auto 107 | ObjCBlockIndentWidth: 8 108 | ObjCSpaceAfterProperty: true 109 | ObjCSpaceBeforeProtocolList: true 110 | 111 | # Taken from git's rules 112 | PenaltyBreakAssignment: 10 113 | PenaltyBreakBeforeFirstCallParameter: 30 114 | PenaltyBreakComment: 10 115 | PenaltyBreakFirstLessLess: 0 116 | PenaltyBreakString: 10 117 | PenaltyExcessCharacter: 100 118 | PenaltyReturnTypeOnItsOwnLine: 60 119 | 120 | PointerAlignment: Right 121 | ReflowComments: false 122 | SortIncludes: false 123 | SortUsingDeclarations: false 124 | SpaceAfterCStyleCast: false 125 | SpaceAfterTemplateKeyword: true 126 | SpaceBeforeAssignmentOperators: true 127 | SpaceBeforeCtorInitializerColon: true 128 | SpaceBeforeInheritanceColon: true 129 | SpaceBeforeParens: ControlStatementsExceptForEachMacros 130 | SpaceBeforeRangeBasedForLoopColon: true 131 | SpaceInEmptyParentheses: false 132 | SpacesBeforeTrailingComments: 1 133 | SpacesInAngles: false 134 | SpacesInContainerLiterals: false 135 | SpacesInCStyleCastParentheses: false 136 | SpacesInParentheses: false 137 | SpacesInSquareBrackets: false 138 | Standard: Cpp03 139 | TabWidth: 8 140 | UseTab: Always 141 | ... 142 | -------------------------------------------------------------------------------- /.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | name: format 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-24.04 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | 12 | - name: Install required packages 13 | run: | 14 | sudo apt-get install clang-format-16 15 | 16 | - name: Check format 17 | run: | 18 | clang-format-16 --dry-run --Werror *.c genimage.h 19 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | include: 11 | - os: ubuntu-22.04 12 | pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm 13 | - os: ubuntu-22.04 14 | pkgs: device-tree-compiler rauc simg2img u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm 15 | fake: sudo rm /usr/include/linux/fiemap.h /usr/include/linux/fs.h 16 | env: ac_cv_func_fallocate=no 17 | - os: ubuntu-24.04 18 | pkgs: device-tree-compiler rauc android-sdk-libsparse-utils u-boot-tools f2fs-tools arm-trusted-firmware-tools mdadm 19 | 20 | steps: 21 | - name: Inspect environment 22 | run: | 23 | whoami 24 | lsb_release -a 25 | gcc --version 26 | 27 | - uses: actions/checkout@v3 28 | 29 | - name: Install required packages 30 | run: | 31 | sudo apt-get update 32 | sudo apt-get install btrfs-progs dosfstools fakeroot genext2fs genisoimage libconfuse-dev mtd-utils mtools qemu-utils qemu-utils squashfs-tools ${{ matrix.pkgs }} 33 | ${{ matrix.fake }} 34 | 35 | - name: Build & Test (with ${{ matrix.options }}) 36 | run: | 37 | ./autogen.sh 38 | ./configure 39 | ${{ matrix.env }} M_COLOR_TESTS=always make distcheck 40 | 41 | - name: Dump test log 42 | if: ${{ failure() }} 43 | run: | 44 | find -name test-suite.log -print0 | xargs -0 cat 45 | 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | .deps/ 3 | Makefile 4 | Makefile.in 5 | aclocal.m4 6 | autom4te.cache/ 7 | build-aux/ 8 | config.h 9 | config.h.in 10 | config.log 11 | config.status 12 | configure 13 | genimage 14 | libtool 15 | stamp-h1 16 | /test/*.log 17 | /test/*.trs 18 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | if BUILD_SILENTLY 2 | AM_MAKEFLAGS = --no-print-directory 3 | endif 4 | 5 | EXTRA_DIST = \ 6 | README.rst \ 7 | test.config \ 8 | flash.conf 9 | 10 | ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} 11 | 12 | AM_CPPFLAGS = \ 13 | -include $(top_builddir)/config.h 14 | 15 | bin_PROGRAMS = genimage 16 | genimage_SOURCES = \ 17 | genimage.c \ 18 | config.c \ 19 | util.c \ 20 | crc32.c \ 21 | image-android-sparse.c \ 22 | image-cpio.c \ 23 | image-cramfs.c \ 24 | image-erofs.c \ 25 | image-ext2.c \ 26 | image-f2fs.c \ 27 | image-mdraid.c \ 28 | image-btrfs.c \ 29 | image-file.c \ 30 | image-fip.c \ 31 | image-fit.c \ 32 | image-flash.c \ 33 | image-hd.c \ 34 | image-iso.c \ 35 | image-jffs2.c \ 36 | image-qemu.c \ 37 | image-rauc.c \ 38 | image-squashfs.c \ 39 | image-tar.c \ 40 | image-ubi.c \ 41 | image-ubifs.c \ 42 | image-vfat.c 43 | 44 | genimage_CFLAGS = \ 45 | $(AM_CFLAGS) \ 46 | $(CONFUSE_CFLAGS) 47 | 48 | genimage_LDADD = \ 49 | $(CONFUSE_LIBS) 50 | 51 | noinst_HEADERS = \ 52 | genimage.h \ 53 | list.h 54 | 55 | EXTRA_DIST += \ 56 | $(TESTS) \ 57 | test/test-setup.sh \ 58 | test/cpio.config \ 59 | test/cramfs.config \ 60 | test/erofs.config \ 61 | test/erofs.dump \ 62 | test/exec-check.sh \ 63 | test/exec-fail.config \ 64 | test/exec.config \ 65 | test/ext2.config \ 66 | test/ext2test.0.dump \ 67 | test/ext2test.1.dump \ 68 | test/ext2test.2.dump \ 69 | test/ext2percent.config \ 70 | test/ext2test-percent.0.dump \ 71 | test/ext2test-percent.1.dump \ 72 | test/ext2test-percent.2.dump \ 73 | test/ext3.config \ 74 | test/ext3test.0.dump \ 75 | test/ext3test.1.dump \ 76 | test/ext3test.2.dump \ 77 | test/ext4.config \ 78 | test/ext4test.0.dump \ 79 | test/ext4test.1.dump \ 80 | test/ext4test.2.dump \ 81 | test/f2fs.config \ 82 | test/mdraid.config \ 83 | test/btrfs.config \ 84 | test/fip.config \ 85 | test/fip-size.config \ 86 | test/fit.its \ 87 | test/fit.config \ 88 | test/flash-types.config \ 89 | test/flash.config \ 90 | test/flash.md5 \ 91 | test/gpt-overlap1.config \ 92 | test/gpt-overlap2.config \ 93 | test/gpt-overlap3.config \ 94 | test/gpt-partition-types.config \ 95 | test/gpt-partition-types.fdisk \ 96 | test/gpt-invalid-partition-type1.config \ 97 | test/gpt-invalid-partition-type2.config \ 98 | test/hdimage.config \ 99 | test/hdimage2.config \ 100 | test/hdimage.fdisk \ 101 | test/hdimage.fdisk-2 \ 102 | test/hdimage4.config \ 103 | test/hdimage4.fdisk \ 104 | test/hdimage5.config \ 105 | test/hdimage5.fdisk \ 106 | test/hdimage6.config \ 107 | test/hdimage6.fdisk \ 108 | test/hdimage7.config \ 109 | test/hdimage7.fdisk \ 110 | test/hole.config \ 111 | test/hdimage-hybrid.config \ 112 | test/hdimage-hybrid.fdisk \ 113 | test/hdimage-fail1.config \ 114 | test/hdimage-fail2.config \ 115 | test/hdimage-fail3.config \ 116 | test/hdimage-fail4.config \ 117 | test/hdimage-fail5.config \ 118 | test/hdimage-fail6.config \ 119 | test/hdimage-fail7.config \ 120 | test/hdimage-fail8.config \ 121 | test/hdimage-fail9.config \ 122 | test/hdimage-fail10.config \ 123 | test/hdimage-fail11.config \ 124 | test/hdimage-nopart.config \ 125 | test/hdimage-nopart.hexdump \ 126 | test/hdimage-forced-primary.config \ 127 | test/hdimage-forced-primary.fdisk \ 128 | test/hdimage-sparse.config \ 129 | test/include-aaa.fdisk \ 130 | test/include-bbb.fdisk \ 131 | test/include-ccc.fdisk \ 132 | test/include-test.config \ 133 | test/include.config \ 134 | test/include/aaa/include-test.config \ 135 | test/include/bbb/include-test.config \ 136 | test/iso.config \ 137 | test/jffs2.config \ 138 | test/jffs2.md5 \ 139 | test/mke2fs.conf \ 140 | test/mke2fs.config \ 141 | test/mke2fs.0.dump \ 142 | test/mke2fs.1.dump \ 143 | test/mke2fs.2.dump \ 144 | test/mke2fs.3.dump \ 145 | test/qemu.config \ 146 | test/qemu.qcow.gz \ 147 | test/rauc-openssl-ca/ca.cert.pem \ 148 | test/rauc-openssl-ca/rauc.cert.pem \ 149 | test/rauc-openssl-ca/rauc.key.pem \ 150 | test/rauc.config \ 151 | test/sharness.sh \ 152 | test/sparse.config \ 153 | test/sparse-fill.config \ 154 | test/squashfs.config \ 155 | test/tar.config \ 156 | test/test.raucb.info.1 \ 157 | test/test.raucb.info.2 \ 158 | test/test.raucb.info.3 \ 159 | test/test.raucb.info.4 \ 160 | test/test2.raucb.info.1 \ 161 | test/test2.raucb.info.2 \ 162 | test/test2.raucb.info.3 \ 163 | test/test2.raucb.info.4 \ 164 | test/ubi.config \ 165 | test/ubifs.config \ 166 | test/vfat.config 167 | 168 | 169 | 170 | TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ 171 | $(top_srcdir)/build-aux/tap-driver.sh 172 | TEST_LOG_COMPILER = fakeroot 173 | 174 | TESTS = \ 175 | test/genimage.test \ 176 | test/ext.test \ 177 | test/filesystem.test \ 178 | test/flash.test \ 179 | test/hdimage.test \ 180 | test/misc.test 181 | 182 | # when "make clean" runs 183 | CLEANFILES = \ 184 | test-results/*.test*.counts 185 | 186 | # when "make distclean" runs 187 | DISTCLEAN = \ 188 | Makefile 189 | 190 | # when "make maintainer-clean" runs 191 | MAINTAINERCLEANFILES = \ 192 | configure \ 193 | autoscan.log \ 194 | config.h.in~ \ 195 | config.h.in \ 196 | configure.scan \ 197 | configure.ac~ \ 198 | aclocal.m4 \ 199 | Makefile.in \ 200 | build-aux/depcomp \ 201 | build-aux/install-sh \ 202 | build-aux/missing \ 203 | $(DIST_ARCHIVES) 204 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then 4 | cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \ 5 | chmod +x .git/hooks/pre-commit && \ 6 | echo "Activated pre-commit hook." 7 | fi 8 | 9 | autoreconf --install --symlink 10 | 11 | args="--prefix=/usr" 12 | 13 | echo 14 | echo "----------------------------------------------------------------" 15 | echo "Initialized build system. For a common configuration please run:" 16 | echo "----------------------------------------------------------------" 17 | echo 18 | echo "./configure CFLAGS='-g -O0' $args" 19 | echo 20 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ(2.60) 2 | AC_INIT([genimage], 3 | [18], 4 | [oss-tools@pengutronix.de], 5 | [genimage], 6 | [http://www.pengutronix.de/genimage/]) 7 | AC_CONFIG_SRCDIR([genimage.c]) 8 | AC_CONFIG_AUX_DIR([build-aux]) 9 | AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects]) 10 | AC_PROG_CC 11 | 12 | # If possible, enable extensions to Posix 13 | AC_USE_SYSTEM_EXTENSIONS 14 | AC_SYS_LARGEFILE 15 | 16 | # where to put extension macros 17 | AC_CONFIG_MACRO_DIR([m4]) 18 | 19 | # default is less output while building the package 20 | AM_SILENT_RULES([yes]) 21 | 22 | # Help the generated libtool script understand the characteristics of the host 23 | LT_INIT 24 | 25 | # change if 'usr/local' as the default install path isn't a good choice 26 | #AC_PREFIX_DEFAULT([/usr/local]) 27 | 28 | AC_CHECK_FUNCS([memset setenv strdup strcasecmp strerror strstr strtoull]) 29 | 30 | AC_C_INLINE 31 | AC_FUNC_ERROR_AT_LINE 32 | AC_FUNC_MALLOC 33 | AC_TYPE_SIZE_T 34 | AC_TYPE_UINT32_T 35 | 36 | AC_CACHE_CHECK([whether linux/fs.h is available], [genimage_cv_header_linux_fs_h], 37 | AC_CHECK_HEADERS([linux/fs.h], [genimage_cv_header_linux_fs_h=yes], 38 | [genimage_cv_header_linux_fs_h=no])) 39 | 40 | AC_CACHE_CHECK([whether linux/fiemap.h is available], [genimage_cv_header_fiemap_h], 41 | AC_CHECK_HEADERS([linux/fiemap.h], [genimage_cv_header_fiemap_h=yes], 42 | [genimage_cv_header_fiemap_h=no])) 43 | 44 | if test "x$genimage_cv_header_linux_fs_h" = "xyes"; then 45 | AC_DEFINE([HAVE_LINUX_FS_H], [1], [Define if linux/fs.h is available]) 46 | fi 47 | 48 | if test "x$genimage_cv_header_fiemap_h" = "xyes" -a "x$genimage_cv_header_linux_fs_h" = "xyes"; then 49 | AC_DEFINE([HAVE_FIEMAP], [1], [Define if fiemap can be used]) 50 | fi 51 | 52 | AC_CHECK_FUNCS(fallocate) 53 | 54 | # ----------- query user's settings ---------------------- 55 | AC_MSG_CHECKING([whether to enable debugging]) 56 | AC_ARG_ENABLE([debug], 57 | AS_HELP_STRING([--enable-debug], 58 | [enable debug messages @<:@default=disabled@:>@]), 59 | [], 60 | [enable_debug=no]) 61 | AC_MSG_RESULT([${enable_debug}]) 62 | 63 | # should the executable export all symbols? 64 | AC_MSG_CHECKING([whether to hide internal symbols]) 65 | AC_ARG_ENABLE([hide], 66 | [AS_HELP_STRING([--disable-hide], 67 | [do not hide all internal symbols @<:@default=enabled@:>@])], 68 | [], 69 | [enable_hide=yes]) 70 | # for debugging purposes we must disable the hiding feature 71 | AS_IF([test "x${enable_debug}" = "xyes"], 72 | [AC_MSG_RESULT([no (due to debug enabled)]) 73 | enable_hide=no], 74 | [AC_MSG_RESULT([${enable_hide}])]) 75 | 76 | # ----------- autodetect some settings ------------------- 77 | 78 | # add as much warnings and features as possible, but check what the compiler 79 | # is able to understand and use it only if possible 80 | 81 | CC_CHECK_CFLAGS_SILENT([-pipe],[AM_CFLAGS="${AM_CFLAGS} -pipe"]) 82 | CC_CHECK_CFLAGS_SILENT([-Wall],[AM_CFLAGS="${AM_CFLAGS} -Wall"]) 83 | CC_CHECK_CFLAGS_SILENT([-Wextra],[AM_CFLAGS="${AM_CFLAGS} -Wextra"]) 84 | CC_CHECK_CFLAGS_SILENT([-Wmissing-declarations],[AM_CFLAGS="${AM_CFLAGS} -Wmissing-declarations"]) 85 | CC_CHECK_CFLAGS_SILENT([-Wmissing-prototypes],[AM_CFLAGS="${AM_CFLAGS} -Wmissing-prototypes"]) 86 | CC_CHECK_CFLAGS_SILENT([-Wnested-externs],[AM_CFLAGS="${AM_CFLAGS} -Wnested-externs"]) 87 | CC_CHECK_CFLAGS_SILENT([-Wpointer-arith],[AM_CFLAGS="${AM_CFLAGS} -Wpointer-arith"]) 88 | CC_CHECK_CFLAGS_SILENT([-Wsign-compare],[AM_CFLAGS="${AM_CFLAGS} -Wsign-compare"]) 89 | CC_CHECK_CFLAGS_SILENT([-Wchar-subscripts],[AM_CFLAGS="${AM_CFLAGS} -Wchar-subscripts"]) 90 | CC_CHECK_CFLAGS_SILENT([-Wstrict-prototypes],[AM_CFLAGS="${AM_CFLAGS} -Wstrict-prototypes"]) 91 | CC_CHECK_CFLAGS_SILENT([-Wshadow],[AM_CFLAGS="${AM_CFLAGS} -Wshadow"]) 92 | CC_CHECK_CFLAGS_SILENT([-Wformat-security],[AM_CFLAGS="${AM_CFLAGS} -Wformat-security"]) 93 | CC_CHECK_CFLAGS_SILENT([-Wtype-limits],[AM_CFLAGS="${AM_CFLAGS} -Wtype-limits"]) 94 | CC_CHECK_CFLAGS_SILENT([-Wunused-parameter],[AM_CFLAGS="${AM_CFLAGS} -Wno-unused-parameter"]) 95 | CC_CHECK_CFLAGS_SILENT([-ffunction-sections],[AM_CFLAGS="${AM_CFLAGS} -ffunction-sections"]) 96 | CC_CHECK_CFLAGS_SILENT([-fdata-sections],[AM_CFLAGS="${AM_CFLAGS} -fdata-sections"]) 97 | 98 | # Add only those libraries which are really used 99 | CC_CHECK_LDFLAGS([-Wl,--as-needed], [AM_LDFLAGS="${AM_LDFLAGS} -Wl,--as-needed"],[]) 100 | CC_CHECK_LDFLAGS([-Wl,--gc-sections], [AM_LDFLAGS="${AM_LDFLAGS} -Wl,--gc-sections"],[]) 101 | 102 | PKG_CHECK_MODULES(CONFUSE, libconfuse >= 2.8, 103 | [AC_DEFINE([HAVE_SEARCHPATH], [1], [Define if cfg_add_searchpath() is available])], 104 | [PKG_CHECK_MODULES(CONFUSE, libconfuse)]) 105 | 106 | # ------- use all the settings ---------------------- 107 | 108 | AS_IF([test "x$enable_debug" = "xyes"], [ 109 | AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.]) 110 | ]) 111 | 112 | # Enable "-fvisibility=hidden" only if the used gcc supports it 113 | AS_IF([test "${enable_hide}" = "yes"], 114 | [AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden]) 115 | CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], [], [enable_hide=no]) 116 | # still enabled? 117 | if test "x${enable_hide}" = "xyes"; then 118 | AC_DEFINE(DSO_HIDDEN, 1, [hide internal library symbols]) 119 | AM_CFLAGS="${AM_CFLAGS} -fvisibility=hidden" 120 | fi 121 | 122 | AC_MSG_RESULT([${enable_hide}])]) 123 | 124 | AC_SUBST(AM_CFLAGS) 125 | 126 | # be very silent on request 127 | AM_CONDITIONAL(BUILD_SILENTLY, test "x$AM_DEFAULT_VERBOSITY" = x0) 128 | 129 | AC_CONFIG_HEADERS(config.h) 130 | AC_CONFIG_FILES([ 131 | Makefile 132 | ]) 133 | 134 | AC_REQUIRE_AUX_FILE([tap-driver.sh]) 135 | 136 | AC_OUTPUT 137 | AC_MSG_RESULT([ 138 | $PACKAGE $VERSION 139 | ===== 140 | 141 | prefix: ${prefix} 142 | 143 | compiler: ${CC} 144 | cflags: ${CFLAGS} ${AM_CFLAGS} 145 | ldflags: ${LDFLAGS} ${AM_LDFLAGS} 146 | 147 | debug: ${enable_debug} 148 | hide symbols: ${enable_hide} 149 | libconfuse: ${CONFUSE_LIBS} 150 | ]) 151 | -------------------------------------------------------------------------------- /crc32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "genimage.h" 4 | 5 | static const uint32_t crc32_tab[] = { 6 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 7 | 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 8 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 9 | 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 10 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 11 | 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 12 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 13 | 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 14 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 15 | 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 16 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 17 | 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 18 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 19 | 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 20 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 21 | 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 22 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 23 | 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 24 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 25 | 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 26 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 27 | 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 28 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 29 | 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 30 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 31 | 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 32 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 33 | 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 34 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 35 | 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 36 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 37 | 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 38 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 39 | 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 40 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 41 | 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 42 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 43 | 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 44 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 45 | 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 46 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 47 | 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 48 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 49 | }; 50 | 51 | uint32_t crc32_next(const void *data, size_t len, uint32_t last_crc) 52 | { 53 | uint32_t crc = ~last_crc; 54 | const char *p = data; 55 | 56 | while (len--) 57 | crc = crc32_tab[(crc ^ *p++) & 0xff] ^ (crc >> 8); 58 | 59 | return ~crc; 60 | } 61 | 62 | uint32_t crc32(const void *data, size_t len) 63 | { 64 | return crc32_next(data, len, 0); 65 | } 66 | -------------------------------------------------------------------------------- /flash.conf: -------------------------------------------------------------------------------- 1 | flash nand-64M-512 { 2 | pebsize = 16384 3 | lebsize = 15360 4 | numpebs = 4096 5 | minimum-io-unit-size = 512 6 | vid-header-offset = 512 7 | sub-page-size = 512 8 | } 9 | 10 | flash nor-64M-128k { 11 | pebsize = 131072 12 | lebsize = 130944 13 | numpebs = 256 14 | minimum-io-unit-size = 1 15 | vid-header-offset = 64 16 | sub-page-size = 1 17 | } 18 | 19 | -------------------------------------------------------------------------------- /image-btrfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Tomas Mudrunka 3 | * Copyright (c) 2024 Fiona Klute 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "genimage.h" 25 | 26 | static int btrfs_generate(struct image *image) 27 | { 28 | int ret; 29 | 30 | const char *label = cfg_getstr(image->imagesec, "label"); 31 | const char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 32 | 33 | ret = prepare_image(image, image->size); 34 | if (ret) 35 | return ret; 36 | 37 | ret = systemp(image, "%s %s %s %s %s%s%s %s '%s'", 38 | get_opt("mkfsbtrfs"), 39 | label ? "-L" : "", 40 | label ? label : "", 41 | /* initial filesystem content, if any */ 42 | image->empty ? "" : "-r", 43 | image->empty ? "" : "'", 44 | image->empty ? "" : mountpath(image), 45 | image->empty ? "" : "'", 46 | extraargs, 47 | imageoutfile(image)); /* destination file */ 48 | 49 | if (ret || image->empty) 50 | return ret; 51 | 52 | return ret; 53 | } 54 | 55 | static cfg_opt_t btrfs_opts[] = { 56 | CFG_STR("label", NULL, CFGF_NONE), 57 | CFG_STR("extraargs", "", CFGF_NONE), 58 | CFG_END() 59 | }; 60 | 61 | struct image_handler btrfs_handler = { 62 | .type = "btrfs", 63 | .generate = btrfs_generate, 64 | .opts = btrfs_opts, 65 | }; 66 | -------------------------------------------------------------------------------- /image-cpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int cpio_generate(struct image *image) 26 | { 27 | int ret; 28 | char *format = cfg_getstr(image->imagesec, "format"); 29 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 30 | char *comp = cfg_getstr(image->imagesec, "compress"); 31 | 32 | ret = systemp(image, "(cd '%s' && find . | %s -H '%s' %s -o %s %s) > '%s'", 33 | mountpath(image), 34 | get_opt("cpio"), 35 | format, extraargs, comp[0] != '\0' ? "|" : "", comp, 36 | imageoutfile(image)); 37 | 38 | return ret; 39 | } 40 | 41 | static cfg_opt_t cpio_opts[] = { 42 | CFG_STR("format", "newc", CFGF_NONE), 43 | CFG_STR("extraargs", "", CFGF_NONE), 44 | CFG_STR("compress", "", CFGF_NONE), 45 | CFG_END() 46 | }; 47 | 48 | struct image_handler cpio_handler = { 49 | .type = "cpio", 50 | .generate = cpio_generate, 51 | .opts = cpio_opts, 52 | }; 53 | -------------------------------------------------------------------------------- /image-cramfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Julien Viard de Galbert 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int cram_generate(struct image *image) 26 | { 27 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 28 | 29 | return systemp(image, "%s%s%s %s '%s' '%s'", 30 | get_opt("mkcramfs"), 31 | image->name ? " -n " : "", 32 | image->name ? image->name : "", /* name */ 33 | extraargs, 34 | mountpath(image), /* source dir */ 35 | imageoutfile(image)); /* destination file */ 36 | } 37 | 38 | static cfg_opt_t cram_opts[] = { 39 | CFG_STR("extraargs", "", CFGF_NONE), 40 | CFG_END() 41 | }; 42 | 43 | struct image_handler cramfs_handler = { 44 | .type = "cramfs", 45 | .generate = cram_generate, 46 | .opts = cram_opts, 47 | }; 48 | -------------------------------------------------------------------------------- /image-erofs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Sebastian Muxel , Entner Electronics 3 | * (c) 2025 Michael Olbrich 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 7 | * as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | struct erofs { 26 | const char *label; 27 | }; 28 | 29 | static int erofs_generate(struct image *image) 30 | { 31 | struct erofs *erofs = image->handler_priv; 32 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 33 | const char *fs_timestamp = cfg_getstr(image->imagesec, "fs-timestamp"); 34 | int ret; 35 | 36 | ret = systemp(image, "%s %s%s%s %s%s %s '%s' '%s'", 37 | get_opt("mkfserofs"), 38 | erofs->label ? "-L '" : "", 39 | erofs->label ? erofs->label : "", 40 | erofs->label ? "'" : "", 41 | fs_timestamp ? "-T " : "", 42 | fs_timestamp ? fs_timestamp : "", 43 | extraargs, 44 | imageoutfile(image), 45 | mountpath(image)); 46 | 47 | return ret; 48 | } 49 | 50 | static int erofs_setup(struct image *image, cfg_t *cfg) 51 | { 52 | struct erofs *erofs = xzalloc(sizeof(*erofs)); 53 | const char *label = cfg_getstr(image->imagesec, "label"); 54 | 55 | if (label && label[0] == '\0') 56 | label = NULL; 57 | 58 | if (label && strlen(label) > 15) { 59 | image_error(image, "Label '%s' is longer that allowes (15 bytes)\n", label); 60 | return -EINVAL; 61 | } 62 | 63 | erofs->label = label; 64 | 65 | image->handler_priv = erofs; 66 | return 0; 67 | } 68 | 69 | static cfg_opt_t erofs_opts[] = { 70 | CFG_STR("extraargs", "", CFGF_NONE), 71 | CFG_STR("label", NULL, CFGF_NONE), 72 | CFG_STR("fs-timestamp", NULL, CFGF_NONE), 73 | CFG_END() 74 | }; 75 | 76 | struct image_handler erofs_handler = { 77 | .type = "erofs", 78 | .generate = erofs_generate, 79 | .setup = erofs_setup, 80 | .opts = erofs_opts, 81 | }; 82 | -------------------------------------------------------------------------------- /image-ext2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "genimage.h" 26 | 27 | struct ext { 28 | int use_mke2fs; 29 | const char *features; 30 | char *usage_type_args; 31 | char *conf_env; 32 | char *size_features; 33 | }; 34 | 35 | static int ext2_generate_genext2fs(struct image *image) 36 | { 37 | int ret; 38 | struct ext *ext = image->handler_priv; 39 | const char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 40 | const char *label = cfg_getstr(image->imagesec, "label"); 41 | 42 | ret = systemp(image, "%s %s%s%s --size-in-blocks=%lld -i 16384 '%s' %s", 43 | get_opt("genext2fs"), 44 | image->empty ? "" : "-d '", 45 | image->empty ? "" : mountpath(image), 46 | image->empty ? "" : "'", 47 | image->size / 1024, imageoutfile(image), extraargs); 48 | 49 | if (ret) 50 | return ret; 51 | 52 | if (ext->features && ext->features[0] != '\0') { 53 | ret = systemp(image, "%s -O '%s' '%s'", get_opt("tune2fs"), 54 | ext->features, imageoutfile(image)); 55 | if (ret) 56 | return ret; 57 | } 58 | if (label && label[0] != '\0') { 59 | ret = systemp(image, "%s -L '%s' '%s'", get_opt("tune2fs"), 60 | label, imageoutfile(image)); 61 | if (ret) 62 | return ret; 63 | } 64 | return 0; 65 | } 66 | 67 | static int ext2_generate_mke2fs(struct image *image) 68 | { 69 | struct ext *ext = image->handler_priv; 70 | const char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 71 | const char *label = cfg_getstr(image->imagesec, "label"); 72 | const char *root_owner = cfg_getstr(image->imagesec, "root-owner"); 73 | const char *options = "lazy_itable_init=0,lazy_journal_init=0"; 74 | const char *features = ext->features; 75 | int ret; 76 | 77 | if (features && features[0] == '\0') 78 | features = NULL; 79 | if (label && label[0] == '\0') 80 | label = NULL; 81 | 82 | ret = prepare_image(image, image->size); 83 | if (ret < 0) 84 | return ret; 85 | 86 | return systemp(image, "%s%s -t %s%s -I 256 -E 'root_owner=%s,%s'%s %s%s%s %s %s%s%s %s%s%s '%s' %lldk", 87 | ext->conf_env, get_opt("mke2fs"), image->handler->type, 88 | ext->usage_type_args, root_owner, options, ext->size_features, 89 | image->empty ? "" : "-d '", 90 | image->empty ? "" : mountpath(image), 91 | image->empty ? "" : "'", 92 | extraargs, 93 | label ? "-L '" : "", 94 | label ? label : "", 95 | label ? "'" : "", 96 | features ? "-O '" : "", 97 | features ? features : "", 98 | features ? "'" : "", 99 | imageoutfile(image), image->size / 1024); 100 | } 101 | 102 | static int ext2_generate(struct image *image) 103 | { 104 | struct ext *ext = image->handler_priv; 105 | const char *fs_timestamp = cfg_getstr(image->imagesec, "fs-timestamp"); 106 | int ret; 107 | 108 | if (ext->use_mke2fs) 109 | ret = ext2_generate_mke2fs(image); 110 | else 111 | ret = ext2_generate_genext2fs(image); 112 | 113 | if (ret) 114 | return ret; 115 | 116 | ret = systemp(image, "%s -pvfD '%s'", get_opt("e2fsck"), 117 | imageoutfile(image)); 118 | 119 | /* e2fsck return 1 when the filesystem was successfully modified */ 120 | if (ret > 2) 121 | return ret; 122 | 123 | if (fs_timestamp) { 124 | ret = systemp(image, "echo '" 125 | "set_current_time %s\n" 126 | "set_super_value mkfs_time %s\n" 127 | "set_super_value lastcheck %s\n" 128 | "set_super_value mtime 00000000' | %s -w '%s'", 129 | fs_timestamp, fs_timestamp, fs_timestamp, 130 | get_opt("debugfs"), imageoutfile(image)); 131 | if (ret) 132 | return ret; 133 | } 134 | return 0; 135 | } 136 | 137 | static int ext2_setup(struct image *image, cfg_t *cfg) 138 | { 139 | struct ext *ext = xzalloc(sizeof(*ext)); 140 | const char *conf = cfg_getstr(image->imagesec, "mke2fs-conf"); 141 | const char *usage_type = cfg_getstr(image->imagesec, "usage-type"); 142 | 143 | if (!conf) { 144 | conf = cfg_getstr(image->imagesec, "mke2fs_conf"); 145 | if (conf) 146 | image_info(image, "option 'mke2fs_conf' is deprecated, use mke2fs-conf instead.\n"); 147 | } 148 | 149 | if (!image->size) { 150 | image_error(image, "no size given or must not be zero\n"); 151 | return -EINVAL; 152 | } 153 | 154 | ext->use_mke2fs = cfg_getbool(cfg, "use-mke2fs"); 155 | 156 | ext->features = cfg_getstr(image->imagesec, "features"); 157 | if (!ext->features) { 158 | if (!ext->use_mke2fs) { 159 | if (!strcmp(image->handler->type, "ext3")) 160 | ext->features = "has_journal"; 161 | else if (!strcmp(image->handler->type, "ext4")) 162 | ext->features = "extents,uninit_bg,dir_index,has_journal"; 163 | } 164 | } 165 | 166 | if (ext->use_mke2fs) { 167 | int is_large = image->size >= 4ll * 1024 * 1024 * 1024; 168 | int is_huge = image->size >= 2048ll * 1024 * 1024 * 1024; 169 | struct stat s; 170 | int ret; 171 | 172 | if (conf) { 173 | /* mke2fs ignores a missing config file, so make sure it exists. */ 174 | ret = stat(conf, &s); 175 | if (ret) { 176 | image_error(image, "mke2fs.conf(%s) does not exist: %s\n", 177 | conf, strerror(errno)); 178 | return -errno; 179 | } 180 | xasprintf(&ext->conf_env, "MKE2FS_CONFIG=\"%s\" ", conf); 181 | } else 182 | ext->conf_env = ""; 183 | 184 | if (usage_type) 185 | xasprintf(&ext->usage_type_args, " -T '%s'", usage_type); 186 | else 187 | ext->usage_type_args = ""; 188 | 189 | xasprintf(&ext->size_features, "%s%s", 190 | is_large ? "" : " -O '^large_file'", 191 | is_huge ? "" : " -O '^huge_file'"); 192 | } else { 193 | if (conf) { 194 | image_error(image, "'mke2fs.conf' is only used for 'mke2fs'\n"); 195 | return -EINVAL; 196 | } 197 | if (usage_type) { 198 | image_error(image, "'usage_type' is only used for 'mke2fs'\n"); 199 | return -EINVAL; 200 | } 201 | } 202 | 203 | image->handler_priv = ext; 204 | 205 | return 0; 206 | } 207 | 208 | static cfg_opt_t ext_opts[] = { 209 | CFG_STR("root-owner", "0:0", CFGF_NONE), 210 | CFG_STR("extraargs", "", CFGF_NONE), 211 | CFG_STR("features", NULL, CFGF_NONE), 212 | CFG_STR("label", NULL, CFGF_NONE), 213 | CFG_STR("fs-timestamp", NULL, CFGF_NONE), 214 | CFG_BOOL("use-mke2fs", cfg_true, CFGF_NONE), 215 | CFG_STR("usage-type", NULL, CFGF_NONE), 216 | CFG_STR("mke2fs-conf", NULL, CFGF_NONE), 217 | CFG_STR("mke2fs_conf", NULL, CFGF_NONE), 218 | CFG_END() 219 | }; 220 | 221 | struct image_handler ext2_handler = { 222 | .type = "ext2", 223 | .generate = ext2_generate, 224 | .setup = ext2_setup, 225 | .opts = ext_opts, 226 | }; 227 | 228 | struct image_handler ext3_handler = { 229 | .type = "ext3", 230 | .generate = ext2_generate, 231 | .setup = ext2_setup, 232 | .opts = ext_opts, 233 | }; 234 | 235 | struct image_handler ext4_handler = { 236 | .type = "ext4", 237 | .generate = ext2_generate, 238 | .setup = ext2_setup, 239 | .opts = ext_opts, 240 | }; 241 | -------------------------------------------------------------------------------- /image-f2fs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Tomas Mudrunka 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int f2fs_generate(struct image *image) 26 | { 27 | int ret; 28 | 29 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 30 | char *label = cfg_getstr(image->imagesec, "label"); 31 | 32 | extraargs = cfg_getstr(image->imagesec, "extraargs"); 33 | 34 | ret = prepare_image(image, image->size); 35 | if (ret) 36 | return ret; 37 | 38 | ret = systemp(image, "%s %s %s%s%s %s '%s'", 39 | get_opt("mkfsf2fs"), 40 | label ? "-l" : "", 41 | label ? "'" : "", 42 | label ? label : "", 43 | label ? "'" : "", 44 | extraargs, 45 | imageoutfile(image)); 46 | 47 | if (ret || image->empty) 48 | return ret; 49 | 50 | ret = systemp(image, "%s -f '%s' '%s'", 51 | get_opt("sloadf2fs"), 52 | mountpath(image), 53 | imageoutfile(image)); 54 | 55 | return ret; 56 | } 57 | 58 | static cfg_opt_t f2fs_opts[] = { 59 | CFG_STR("extraargs", "", CFGF_NONE), 60 | CFG_STR("label", NULL, CFGF_NONE), 61 | CFG_END() 62 | }; 63 | 64 | struct image_handler f2fs_handler = { 65 | .type = "f2fs", 66 | .generate = f2fs_generate, 67 | .opts = f2fs_opts, 68 | }; 69 | -------------------------------------------------------------------------------- /image-file.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "genimage.h" 25 | 26 | struct file { 27 | char *name; 28 | char *infile; 29 | cfg_bool_t copy; 30 | }; 31 | 32 | static int file_generate(struct image *image) 33 | { 34 | struct file *f = image->handler_priv; 35 | int ret; 36 | 37 | if (!f->copy) 38 | return 0; 39 | 40 | if (!strcmp(f->infile, imageoutfile(image))) 41 | return 0; 42 | 43 | ret = systemp(image, "cp '%s' '%s'", f->infile, imageoutfile(image)); 44 | 45 | return ret; 46 | } 47 | 48 | static int file_setup(struct image *image, cfg_t *cfg) 49 | { 50 | struct file *f = xzalloc(sizeof(*f)); 51 | struct stat s; 52 | int ret; 53 | 54 | if (cfg) 55 | f->name = cfg_getstr(cfg, "name"); 56 | if (!f->name) 57 | f->name = strdup(image->file); 58 | 59 | if (f->name[0] == '/') 60 | f->infile = strdup(f->name); 61 | else 62 | xasprintf(&f->infile, "%s/%s", inputpath(), f->name); 63 | 64 | ret = stat(f->infile, &s); 65 | if (ret) { 66 | ret = -errno; 67 | image_error(image, "stat(%s) failed: %s\n", f->infile, 68 | strerror(errno)); 69 | return ret; 70 | } 71 | if (!image->size) 72 | image->size = s.st_size; 73 | 74 | if (cfg) 75 | f->copy = cfg_getbool(cfg, "copy"); 76 | else 77 | f->copy = cfg_false; 78 | 79 | if (!f->copy) { 80 | free(image->outfile); 81 | image->outfile = strdup(f->infile); 82 | } 83 | ret = parse_holes(image, cfg); 84 | if (ret) 85 | return ret; 86 | 87 | image->handler_priv = f; 88 | 89 | return 0; 90 | } 91 | 92 | static int file_parse(struct image *image, cfg_t *cfg) 93 | { 94 | /* File type images are used for custom types so assume that the 95 | * rootpath is need when a pre/post command is defined */ 96 | if (!image->exec_pre && !image->exec_post) 97 | image->empty = cfg_true; 98 | 99 | return 0; 100 | } 101 | 102 | static cfg_opt_t file_opts[] = { 103 | CFG_STR("name", NULL, CFGF_NONE), 104 | CFG_BOOL("copy", cfg_true, CFGF_NONE), 105 | CFG_STR_LIST("holes", NULL, CFGF_NONE), 106 | CFG_END() 107 | }; 108 | 109 | struct image_handler file_handler = { 110 | .type = "file", 111 | .generate = file_generate, 112 | .setup = file_setup, 113 | .parse = file_parse, 114 | .opts = file_opts, 115 | }; 116 | -------------------------------------------------------------------------------- /image-fip.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Ahmad Fatoum 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "genimage.h" 25 | 26 | static int fip_generate(struct image *image) 27 | { 28 | struct partition *part; 29 | char *args = strdup(""); 30 | const char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 31 | int ret; 32 | 33 | list_for_each_entry(part, &image->partitions, list) { 34 | struct image *child = image_get(part->image); 35 | char *oldargs; 36 | 37 | oldargs = args; 38 | xasprintf(&args, "%s --%s '%s'", args, part->name, imageoutfile(child)); 39 | free(oldargs); 40 | } 41 | 42 | ret = systemp(image, "%s create %s %s '%s'", get_opt("fiptool"), 43 | args, extraargs, imageoutfile(image)); 44 | 45 | free(args); 46 | 47 | if (ret == 0) { 48 | struct stat statbuf; 49 | ret = stat(imageoutfile(image), &statbuf); 50 | 51 | if (ret) 52 | return ret; 53 | 54 | image->size = statbuf.st_size; 55 | } 56 | 57 | return ret; 58 | } 59 | 60 | static void fip_add_part(struct image *image, 61 | const char *name, const char *path) 62 | { 63 | struct partition *part; 64 | 65 | part = xzalloc(sizeof *part); 66 | part->image = path; 67 | part->name = name; 68 | list_add_tail(&part->list, &image->partitions); 69 | } 70 | 71 | /* clang-format off */ 72 | static cfg_opt_t fip_opts[] = { 73 | CFG_STR("extraargs", "", CFGF_NONE), 74 | CFG_STR_LIST("tos-fw", NULL, CFGF_NONE), /* Secure Payload BL32 (Trusted OS, Extra1, Extra 2) */ 75 | /* CFGF_NODEFAULT marks options passed as-is */ 76 | CFG_STR("scp-fwu-cfg", NULL, CFGF_NODEFAULT), /* SCP Firmware Updater Configuration FWU SCP_BL2U */ 77 | CFG_STR("ap-fwu-cfg", NULL, CFGF_NODEFAULT), /* AP Firmware Updater Configuration BL2U */ 78 | CFG_STR("fwu", NULL, CFGF_NODEFAULT), /* Firmware Updater NS_BL2U */ 79 | CFG_STR("fwu-cert", NULL, CFGF_NODEFAULT), /* Non-Trusted Firmware Updater certificate */ 80 | CFG_STR("tb-fw", NULL, CFGF_NODEFAULT), /* Trusted Boot Firmware BL2 */ 81 | CFG_STR("scp-fw", NULL, CFGF_NODEFAULT), /* SCP Firmware SCP_BL2 */ 82 | CFG_STR("soc-fw", NULL, CFGF_NODEFAULT), /* EL3 Runtime Firmware BL31 */ 83 | CFG_STR("nt-fw", NULL, CFGF_NODEFAULT), /* Non-Trusted Firmware BL33 */ 84 | CFG_STR("fw-config", NULL, CFGF_NODEFAULT), /* FW_CONFIG */ 85 | CFG_STR("hw-config", NULL, CFGF_NODEFAULT), /* HW_CONFIG */ 86 | CFG_STR("tb-fw-config", NULL, CFGF_NODEFAULT), /* TB_FW_CONFIG */ 87 | CFG_STR("soc-fw-config", NULL, CFGF_NODEFAULT), /* SOC_FW_CONFIG */ 88 | CFG_STR("tos-fw-config", NULL, CFGF_NODEFAULT), /* TOS_FW_CONFIG */ 89 | CFG_STR("nt-fw-config", NULL, CFGF_NODEFAULT), /* NT_FW_CONFIG */ 90 | 91 | CFG_STR("rot-cert", NULL, CFGF_NODEFAULT), /* Root Of Trust key certificate */ 92 | 93 | CFG_STR("trusted-key-cert", NULL, CFGF_NODEFAULT), /* Trusted key certificate */ 94 | CFG_STR("scp-fw-key-cert", NULL, CFGF_NODEFAULT), /* SCP Firmware key certificate */ 95 | CFG_STR("soc-fw-key-cert", NULL, CFGF_NODEFAULT), /* SoC Firmware key certificate */ 96 | CFG_STR("tos-fw-key-cert", NULL, CFGF_NODEFAULT), /* Trusted OS Firmware key certificate */ 97 | CFG_STR("nt-fw-key-cert", NULL, CFGF_NODEFAULT), /* Non-Trusted Firmware key certificate */ 98 | 99 | CFG_STR("tb-fw-cert", NULL, CFGF_NODEFAULT), /* Trusted Boot Firmware BL2 certificate */ 100 | CFG_STR("scp-fw-cert", NULL, CFGF_NODEFAULT), /* SCP Firmware content certificate */ 101 | CFG_STR("soc-fw-cert", NULL, CFGF_NODEFAULT), /* SoC Firmware content certificate */ 102 | CFG_STR("tos-fw-cert", NULL, CFGF_NODEFAULT), /* Trusted OS Firmware content certificate */ 103 | CFG_STR("nt-fw-cert", NULL, CFGF_NODEFAULT), /* Non-Trusted Firmware content certificate */ 104 | 105 | CFG_STR("sip-sp-cert", NULL, CFGF_NODEFAULT), /* SiP owned Secure Partition content certificate */ 106 | CFG_STR("plat-sp-cert", NULL, CFGF_NODEFAULT), /* Platform owned Secure Partition content certificate */ 107 | 108 | CFG_END() 109 | }; 110 | /* clang-format on */ 111 | 112 | static const char *tos_fw[] = { "tos-fw", "tos-fw-extra1", "tos-fw-extra2" }; 113 | 114 | static int fip_parse(struct image *image, cfg_t *cfg) 115 | { 116 | unsigned int i, num_tos_fw; 117 | cfg_opt_t *opt; 118 | 119 | num_tos_fw = cfg_size(cfg, "tos-fw"); 120 | if (num_tos_fw > ARRAY_SIZE(tos_fw)) { 121 | image_error(image, "%u tos-fw binaries given, but maximum is %zu\n", 122 | num_tos_fw, ARRAY_SIZE(tos_fw)); 123 | return -EINVAL; 124 | } 125 | 126 | for (i = 0; i < num_tos_fw; i++) 127 | fip_add_part(image, tos_fw[i], cfg_getnstr(cfg, "tos-fw", i)); 128 | 129 | for (opt = fip_opts; opt->type; opt++) { 130 | const char *file; 131 | 132 | if (opt->flags != CFGF_NODEFAULT) 133 | continue; 134 | 135 | file = cfg_getstr(cfg, opt->name); 136 | if (file) 137 | fip_add_part(image, opt->name, file); 138 | } 139 | 140 | return 0; 141 | } 142 | 143 | struct image_handler fip_handler = { 144 | .type = "fip", 145 | .no_rootpath = cfg_true, 146 | .generate = fip_generate, 147 | .parse = fip_parse, 148 | .opts = fip_opts, 149 | }; 150 | -------------------------------------------------------------------------------- /image-fit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Sascha Hauer 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "genimage.h" 28 | 29 | static struct partition *partition_by_name(struct image *image, const char *name) 30 | { 31 | struct partition *part; 32 | 33 | list_for_each_entry(part, &image->partitions, list) 34 | if (!strcmp(part->name, name)) 35 | return part; 36 | return NULL; 37 | } 38 | 39 | static int fit_generate(struct image *image) 40 | { 41 | int ret; 42 | struct partition *part, *its; 43 | char *itspath; 44 | int itsfd; 45 | char *keydir = cfg_getstr(image->imagesec, "keydir"); 46 | char *keyopt = NULL; 47 | 48 | its = partition_by_name(image, "its"); 49 | if (!its) 50 | return -EINVAL; 51 | 52 | struct image *itsimg = image_get(its->image); 53 | 54 | xasprintf(&itspath, "%s/fit.its", tmppath()); 55 | 56 | /* Copy input its file to temporary path. Use 'cat' to ignore permissions */ 57 | ret = systemp(image, "cat '%s' > '%s'", imageoutfile(itsimg), itspath); 58 | if (ret) 59 | return ret; 60 | 61 | itsfd = open(itspath, O_WRONLY | O_APPEND); 62 | if (itsfd < 0) { 63 | printf("Cannot open %s: %s\n", itspath, strerror(errno)); 64 | return -errno; 65 | } 66 | 67 | dprintf(itsfd, "\n"); 68 | 69 | /* Add /incbin/ to each /images// node */ 70 | list_for_each_entry(part, &image->partitions, list) { 71 | struct image *child = image_get(part->image); 72 | const char *file = imageoutfile(child); 73 | const char *target = part->name; 74 | 75 | if (part == its) 76 | continue; 77 | 78 | dprintf(itsfd, "/ { images { %s { data = /incbin/(\"%s\"); };};};\n", target, file); 79 | } 80 | 81 | close(itsfd); 82 | 83 | if (keydir && *keydir) { 84 | if (*keydir != '/') { 85 | image_error(image, "'keydir' must be an absolute path\n"); 86 | return -EINVAL; 87 | } 88 | xasprintf(&keyopt, "-k '%s'", keydir); 89 | } 90 | 91 | ret = systemp(image, "%s -r %s -f '%s' '%s'", 92 | get_opt("mkimage"), keyopt ? keyopt : "", itspath, imageoutfile(image)); 93 | 94 | if (ret) 95 | image_error(image, "Failed to create FIT image\n"); 96 | 97 | return ret; 98 | } 99 | 100 | static int fit_parse(struct image *image, cfg_t *cfg) 101 | { 102 | struct partition *part; 103 | char *its = cfg_getstr(image->imagesec, "its"); 104 | 105 | part = xzalloc(sizeof *part); 106 | part->name = "its"; 107 | part->image = its; 108 | list_add_tail(&part->list, &image->partitions); 109 | 110 | return 0; 111 | } 112 | 113 | static cfg_opt_t fit_opts[] = { 114 | CFG_STR("keydir", "", CFGF_NONE), 115 | CFG_STR("its", "", CFGF_NONE), 116 | CFG_END() 117 | }; 118 | 119 | struct image_handler fit_handler = { 120 | .type = "fit", 121 | .no_rootpath = cfg_true, 122 | .generate = fit_generate, 123 | .parse = fit_parse, 124 | .opts = fit_opts, 125 | }; 126 | -------------------------------------------------------------------------------- /image-flash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "list.h" 27 | #include "genimage.h" 28 | 29 | struct flash_image { 30 | }; 31 | 32 | static int flash_generate(struct image *image) 33 | { 34 | struct partition *part; 35 | unsigned long long end = 0; 36 | int ret; 37 | 38 | ret = prepare_image(image, image->size); 39 | if (ret < 0) 40 | return ret; 41 | 42 | list_for_each_entry(part, &image->partitions, list) { 43 | struct image *child = NULL; 44 | 45 | image_info(image, "writing image partition '%s' (0x%llx@0x%llx)\n", 46 | part->name, part->size, part->offset); 47 | 48 | if (part->offset > end) { 49 | ret = insert_image(image, NULL, part->offset - end, end, 0xFF, cfg_false); 50 | if (ret) { 51 | image_error(image, "failed to pad image to size %lld\n", 52 | part->offset); 53 | return ret; 54 | } 55 | } 56 | 57 | if (part->image) 58 | child = image_get(part->image); 59 | 60 | ret = insert_image(image, child, part->size, part->offset, 0xFF, cfg_false); 61 | if (ret) { 62 | image_error(image, "failed to write image partition '%s'\n", 63 | part->name); 64 | return ret; 65 | } 66 | end = part->offset + part->size; 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | static int flash_setup(struct image *image, cfg_t *cfg) 73 | { 74 | struct flash_image *f = xzalloc(sizeof(*f)); 75 | struct partition *part; 76 | int last = 0; 77 | unsigned long long partsize = 0, flashsize; 78 | 79 | image->handler_priv = f; 80 | 81 | if (!image->flash_type) { 82 | image_error(image, "no flash type given\n"); 83 | return -EINVAL; 84 | } 85 | 86 | flashsize = (unsigned long long)image->flash_type->pebsize * image->flash_type->numpebs; 87 | 88 | list_for_each_entry(part, &image->partitions, list) { 89 | if (last) { 90 | image_error(image, "only last partition may have size 0\n"); 91 | return -EINVAL; 92 | } 93 | 94 | if (!part->size) { 95 | last = 1; 96 | if (partsize > flashsize) 97 | goto err_exceed; 98 | part->size = flashsize - partsize; 99 | } 100 | if (part->size % image->flash_type->pebsize) { 101 | image_error(image, "part %s size (%lld) must be a " 102 | "multiple of erase block size (%i bytes)\n", 103 | part->name, part->size, image->flash_type->pebsize); 104 | return -EINVAL; 105 | } 106 | if (part->offset % image->flash_type->pebsize) { 107 | image_error(image, "part %s offset (%lld) must be a " 108 | "multiple of erase block size (%i bytes)\n", 109 | part->name, part->offset, image->flash_type->pebsize); 110 | return -EINVAL; 111 | } 112 | if (part->offset) { 113 | if (partsize > part->offset) { 114 | image_error(image, "part %s overlaps with previous partition\n", 115 | part->name); 116 | return -EINVAL; 117 | } 118 | } else { 119 | part->offset = partsize; 120 | } 121 | if (part->image) { 122 | struct image *child = image_get(part->image); 123 | if (!child) { 124 | image_error(image, "could not find %s\n", 125 | part->image); 126 | return -EINVAL; 127 | } 128 | if (child->size > part->size) { 129 | image_error(image, "part %s size (%lld) too small for %s (%lld)\n", 130 | part->name, part->size, child->file, child->size); 131 | return -EINVAL; 132 | } 133 | } 134 | 135 | partsize = part->offset + part->size; 136 | } 137 | 138 | if (partsize > flashsize) { 139 | err_exceed: 140 | image_error(image, "size of partitions (%lld) exceeds flash size (%lld)\n", 141 | partsize, flashsize); 142 | return -EINVAL; 143 | } 144 | if (!image->size) 145 | image->size = partsize; 146 | 147 | return 0; 148 | } 149 | 150 | static cfg_opt_t flash_opts[] = { 151 | CFG_END() 152 | }; 153 | 154 | struct image_handler flash_handler = { 155 | .type = "flash", 156 | .no_rootpath = cfg_true, 157 | .generate = flash_generate, 158 | .setup = flash_setup, 159 | .opts = flash_opts, 160 | }; 161 | -------------------------------------------------------------------------------- /image-iso.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Michael Olbrich 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int iso_generate(struct image *image) 26 | { 27 | int ret; 28 | char *boot; 29 | char *boot_image = cfg_getstr(image->imagesec, "boot-image"); 30 | char *bootargs = cfg_getstr(image->imagesec, "bootargs"); 31 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 32 | char *input_charset = cfg_getstr(image->imagesec, "input-charset"); 33 | char *volume_id = cfg_getstr(image->imagesec, "volume-id"); 34 | 35 | if (boot_image) 36 | xasprintf(&boot, "-b '%s' %s", boot_image, bootargs); 37 | else 38 | boot = ""; 39 | 40 | ret = systemp(image, "%s -input-charset %s -R -hide-rr-moved %s -V '%s' %s -o '%s' '%s'", 41 | get_opt("genisoimage"), 42 | input_charset, 43 | boot, 44 | volume_id, 45 | extraargs, 46 | imageoutfile(image), 47 | mountpath(image)); 48 | return ret; 49 | } 50 | 51 | static cfg_opt_t iso_opts[] = { 52 | CFG_STR("boot-image", NULL, CFGF_NONE), 53 | CFG_STR("bootargs", "-no-emul-boot -boot-load-size 4 -boot-info-table -c boot.cat -hide boot.cat", CFGF_NONE), 54 | CFG_STR("extraargs", "", CFGF_NONE), 55 | CFG_STR("input-charset", "default", CFGF_NONE), 56 | CFG_STR("volume-id", "", CFGF_NONE), 57 | CFG_END() 58 | }; 59 | 60 | struct image_handler iso_handler = { 61 | .type = "iso", 62 | .generate = iso_generate, 63 | .opts = iso_opts, 64 | }; 65 | -------------------------------------------------------------------------------- /image-jffs2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int jffs2_generate(struct image *image) 26 | { 27 | int ret; 28 | char *extraargs; 29 | 30 | extraargs = cfg_getstr(image->imagesec, "extraargs"); 31 | 32 | ret = systemp(image, "%s --eraseblock=%d %s%s%s -o '%s' %s", 33 | get_opt("mkfsjffs2"), 34 | image->flash_type->pebsize, 35 | image->empty ? "" : "-d '", 36 | image->empty ? "" : mountpath(image), 37 | image->empty ? "" : "'", 38 | imageoutfile(image), extraargs); 39 | 40 | return ret; 41 | } 42 | 43 | static int jffs2_setup(struct image *image, cfg_t *cfg) 44 | { 45 | if (!image->flash_type) { 46 | image_error(image, "no flash type given\n"); 47 | return -EINVAL; 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | static cfg_opt_t jffs2_opts[] = { 54 | CFG_STR("extraargs", "", CFGF_NONE), 55 | CFG_END() 56 | }; 57 | 58 | struct image_handler jffs2_handler = { 59 | .type = "jffs2", 60 | .generate = jffs2_generate, 61 | .setup = jffs2_setup, 62 | .opts = jffs2_opts, 63 | }; 64 | -------------------------------------------------------------------------------- /image-qemu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Alexandre Fournier , Kiplink 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | struct qemu { 26 | const char *format; 27 | const char *extraargs; 28 | }; 29 | 30 | static int qemu_generate(struct image *image) 31 | { 32 | struct partition *part; 33 | struct qemu *qemu = image->handler_priv; 34 | char *partitions = NULL; 35 | int ret; 36 | 37 | list_for_each_entry(part, &image->partitions, list) { 38 | struct image *child; 39 | const char *infile; 40 | 41 | if (!part->image) { 42 | image_debug(image, "skipping partition %s\n", 43 | part->name); 44 | continue; 45 | } 46 | 47 | image_info(image, "adding partition %s from %s ...\n", 48 | part->name, part->image); 49 | 50 | child = image_get(part->image); 51 | infile = imageoutfile(child); 52 | 53 | if (!partitions) 54 | xasprintf(&partitions, "'%s'", infile); 55 | else 56 | xasprintf(&partitions, "%s '%s'", partitions, infile); 57 | } 58 | 59 | ret = systemp(image, "qemu-img convert %s -O %s %s '%s'", 60 | qemu->extraargs, 61 | qemu->format, 62 | partitions, 63 | imageoutfile(image)); 64 | 65 | return ret; 66 | } 67 | 68 | static int qemu_setup(struct image *image, cfg_t *cfg) 69 | { 70 | struct qemu *qemu = xzalloc(sizeof(*qemu)); 71 | struct partition *part; 72 | int partitions_count = 0; 73 | 74 | list_for_each_entry(part, &image->partitions, list) { 75 | if (part->image) 76 | partitions_count++; 77 | } 78 | 79 | if (partitions_count == 0) { 80 | image_error(image, "no partition given\n"); 81 | return -EINVAL; 82 | } 83 | 84 | qemu->format = cfg_getstr(cfg, "format"); 85 | qemu->extraargs = cfg_getstr(cfg, "extraargs"); 86 | 87 | image->handler_priv = qemu; 88 | 89 | return 0; 90 | } 91 | 92 | static cfg_opt_t qemu_opts[] = { 93 | CFG_STR("format", "qcow2", CFGF_NONE), 94 | CFG_STR("extraargs", "", CFGF_NONE), 95 | CFG_END() 96 | }; 97 | 98 | struct image_handler qemu_handler = { 99 | .type = "qemu", 100 | .no_rootpath = cfg_true, 101 | .generate = qemu_generate, 102 | .setup = qemu_setup, 103 | .opts = qemu_opts, 104 | }; 105 | -------------------------------------------------------------------------------- /image-squashfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Juergen Beisert 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "genimage.h" 27 | 28 | static int squash_generate(struct image *image) 29 | { 30 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 31 | char compression[128]; 32 | char *comp_setup = cfg_getstr(image->imagesec, "compression"); 33 | unsigned block_size = cfg_getint_suffix(image->imagesec, "block-size"); 34 | unsigned long long file_size; 35 | struct stat sb; 36 | int ret; 37 | 38 | /* 39 | * 'mksquashfs' currently defaults to 'gzip' compression. Provide a shortcut 40 | * to be able to disable all kind of compression and force the current 41 | * default behaviour for the future. Disabling compression is very useful 42 | * to handle binary diffs. 43 | */ 44 | if (!strcasecmp(comp_setup, "none")) 45 | strncpy(compression, "-comp gzip -noInodeCompression -noDataCompression -noFragmentCompression -noXattrCompression", sizeof(compression)); 46 | else 47 | snprintf(compression, sizeof(compression), "-comp %s", comp_setup); 48 | 49 | ret = systemp(image, "%s '%s' '%s' -b %u -noappend %s %s", 50 | get_opt("mksquashfs"), 51 | mountpath(image), /* source dir */ 52 | imageoutfile(image), /* destination file */ 53 | block_size, compression, extraargs); 54 | if (ret) 55 | return ret; 56 | ret = stat(imageoutfile(image), &sb); 57 | if (ret) { 58 | ret = -errno; 59 | image_error(image, "stat(%s) failed: %s\n", imageoutfile(image), strerror(errno)); 60 | return ret; 61 | } 62 | file_size = sb.st_size; 63 | 64 | if (image->size && file_size > image->size) { 65 | image_error(image, "generated image %s is larger than given image size (%llu v %llu)\n", 66 | imageoutfile(image), file_size, image->size); 67 | return -E2BIG; 68 | } 69 | 70 | image_debug(image, "setting image size to %llu bytes\n", file_size); 71 | image->size = file_size; 72 | 73 | return 0; 74 | } 75 | 76 | /** 77 | * 'compression' can be 'gzip' (the current default), 'lzo', 'xz' or 'none' 78 | * @note 'none' is a special keyword to add the parameters '-noInodeCompression -noDataCompression -noFragmentCompression -noXattrCompression' 79 | */ 80 | static cfg_opt_t squash_opts[] = { 81 | CFG_STR("extraargs", "", CFGF_NONE), 82 | CFG_STR("compression", "gzip", CFGF_NONE), 83 | CFG_STR("block-size", "4096", CFGF_NONE), 84 | CFG_END() 85 | }; 86 | 87 | struct image_handler squashfs_handler = { 88 | .type = "squashfs", 89 | .generate = squash_generate, 90 | .opts = squash_opts, 91 | }; 92 | -------------------------------------------------------------------------------- /image-tar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int tar_generate(struct image *image) 26 | { 27 | int ret; 28 | char *comp = "a"; 29 | 30 | if (strstr(image->file, ".tar.gz") || strstr(image->file, "tgz")) 31 | comp = "z"; 32 | if (strstr(image->file, ".tar.bz2")) 33 | comp = "j"; 34 | 35 | ret = systemp(image, "%s c%s -f '%s' -C '%s' .", 36 | get_opt("tar"), 37 | comp, 38 | imageoutfile(image), mountpath(image)); 39 | 40 | return ret; 41 | } 42 | 43 | static cfg_opt_t tar_opts[] = { 44 | CFG_END() 45 | }; 46 | 47 | struct image_handler tar_handler = { 48 | .type = "tar", 49 | .generate = tar_generate, 50 | .opts = tar_opts, 51 | }; 52 | -------------------------------------------------------------------------------- /image-ubi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | struct ubi { 26 | }; 27 | 28 | static int ubi_generate(struct image *image) 29 | { 30 | int ret; 31 | FILE *fini; 32 | char *tempfile; 33 | int i = 0; 34 | struct partition *part; 35 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 36 | 37 | xasprintf(&tempfile, "%s/ubi.ini", tmppath()); 38 | if (!tempfile) 39 | return -ENOMEM; 40 | 41 | fini = fopen(tempfile, "w"); 42 | if (!fini) { 43 | ret = -errno; 44 | image_error(image, "creating temp file failed: %s\n", strerror(errno)); 45 | goto err_free; 46 | } 47 | 48 | list_for_each_entry(part, &image->partitions, list) { 49 | struct image *child = NULL; 50 | unsigned long long size = part->size; 51 | if (part->image) 52 | child = image_get(part->image); 53 | if (!size) { 54 | if (!child) { 55 | image_error(image, "could not find %s\n", part->image); 56 | fclose(fini); 57 | ret = -EINVAL; 58 | goto err_free; 59 | } 60 | size = child->size; 61 | } 62 | 63 | fprintf(fini, "[%s]\n", part->name); 64 | fprintf(fini, "mode=ubi\n"); 65 | if (child) 66 | fprintf(fini, "image=%s\n", imageoutfile(child)); 67 | fprintf(fini, "vol_id=%d\n", i); 68 | fprintf(fini, "vol_size=%lld\n", size); 69 | fprintf(fini, "vol_type=%s\n", part->read_only ? "static" : "dynamic"); 70 | fprintf(fini, "vol_name=%s\n", part->name); 71 | if (part->autoresize) 72 | fprintf(fini, "vol_flags=autoresize\n"); 73 | fprintf(fini, "vol_alignment=1\n"); 74 | i++; 75 | } 76 | 77 | fclose(fini); 78 | 79 | ret = systemp(image, "%s -s %d -O %d -p %d -m %d -o '%s' '%s' %s", 80 | get_opt("ubinize"), 81 | image->flash_type->sub_page_size, 82 | image->flash_type->vid_header_offset, 83 | image->flash_type->pebsize, 84 | image->flash_type->minimum_io_unit_size, 85 | imageoutfile(image), 86 | tempfile, 87 | extraargs); 88 | 89 | err_free: 90 | free(tempfile); 91 | 92 | return ret; 93 | } 94 | 95 | static int ubi_setup(struct image *image, cfg_t *cfg) 96 | { 97 | struct ubi *ubi = xzalloc(sizeof(*ubi)); 98 | int autoresize = 0; 99 | struct partition *part; 100 | 101 | if (!image->flash_type) { 102 | image_error(image, "no flash type given\n"); 103 | return -EINVAL; 104 | } 105 | 106 | image->handler_priv = ubi; 107 | 108 | list_for_each_entry(part, &image->partitions, list) 109 | autoresize += part->autoresize; 110 | 111 | if (autoresize > 1) { 112 | image_error(image, "more than one volume has the autoresize flag set\n"); 113 | return -EINVAL; 114 | } 115 | 116 | return 0; 117 | } 118 | 119 | static cfg_opt_t ubi_opts[] = { 120 | CFG_STR("extraargs", "", CFGF_NONE), 121 | CFG_END() 122 | }; 123 | 124 | struct image_handler ubi_handler = { 125 | .type = "ubi", 126 | .no_rootpath = cfg_true, 127 | .generate = ubi_generate, 128 | .setup = ubi_setup, 129 | .opts = ubi_opts, 130 | }; 131 | -------------------------------------------------------------------------------- /image-ubifs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Sascha Hauer , Pengutronix 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int ubifs_generate(struct image *image) 26 | { 27 | int max_leb_cnt; 28 | int ret; 29 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 30 | unsigned long long max_size = cfg_getint_suffix(image->imagesec, "max-size"); 31 | cfg_bool_t space_fixup = cfg_getbool(image->imagesec, "space-fixup"); 32 | 33 | if (max_size) 34 | max_leb_cnt = max_size / image->flash_type->lebsize; 35 | else 36 | max_leb_cnt = image->size / image->flash_type->lebsize; 37 | 38 | ret = systemp(image, "%s %s%s%s %s -e %d -m %d -c %d -o '%s' %s", 39 | get_opt("mkfsubifs"), 40 | image->empty ? "" : "-d '", 41 | image->empty ? "" : mountpath(image), 42 | image->empty ? "" : "'", 43 | space_fixup ? "-F" : "", 44 | image->flash_type->lebsize, 45 | image->flash_type->minimum_io_unit_size, 46 | max_leb_cnt, 47 | imageoutfile(image), 48 | extraargs); 49 | 50 | return ret; 51 | } 52 | 53 | static int ubifs_setup(struct image *image, cfg_t *cfg) 54 | { 55 | if (!image->flash_type) { 56 | image_error(image, "no flash type given\n"); 57 | return -EINVAL; 58 | } 59 | if (image->flash_type->lebsize <= 0) { 60 | image_error(image, "invalid lebsize (%d) in %s\n", 61 | image->flash_type->lebsize, image->flash_type->name); 62 | return -EINVAL; 63 | } 64 | 65 | return 0; 66 | } 67 | 68 | static cfg_opt_t ubifs_opts[] = { 69 | CFG_STR("extraargs", "", CFGF_NONE), 70 | CFG_STR("max-size", NULL, CFGF_NONE), 71 | CFG_BOOL("space-fixup", 0, CFGF_NONE), 72 | CFG_END() 73 | }; 74 | 75 | struct image_handler ubifs_handler = { 76 | .type = "ubifs", 77 | .generate = ubifs_generate, 78 | .setup = ubifs_setup, 79 | .opts = ubifs_opts, 80 | }; 81 | -------------------------------------------------------------------------------- /image-vfat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Michael Olbrich 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "genimage.h" 24 | 25 | static int vfat_generate(struct image *image) 26 | { 27 | int ret; 28 | struct partition *part; 29 | char *extraargs = cfg_getstr(image->imagesec, "extraargs"); 30 | char *label = cfg_getstr(image->imagesec, "label"); 31 | 32 | if (label && label[0] != '\0') 33 | xasprintf(&label, "-n '%s'", label); 34 | else 35 | label = ""; 36 | 37 | ret = prepare_image(image, image->size); 38 | if (ret) 39 | return ret; 40 | 41 | ret = systemp(image, "%s %s %s '%s'", get_opt("mkdosfs"), 42 | extraargs, label, imageoutfile(image)); 43 | if (ret) 44 | return ret; 45 | 46 | list_for_each_entry(part, &image->partitions, list) { 47 | struct image *child = image_get(part->image); 48 | const char *file = imageoutfile(child); 49 | const char *target = part->name; 50 | char *path = strdupa(target); 51 | char *next = path; 52 | 53 | while ((next = strchr(next, '/')) != NULL) { 54 | *next = '\0'; 55 | /* ignore the error: mdd fails if the target exists. */ 56 | systemp(image, "MTOOLS_SKIP_CHECK=1 %s -DsS -i %s '::%s'", 57 | get_opt("mmd"), imageoutfile(image), path); 58 | *next = '/'; 59 | ++next; 60 | } 61 | 62 | image_info(image, "adding file '%s' as '%s' ...\n", 63 | child->file, *target ? target : child->file); 64 | ret = systemp(image, "MTOOLS_SKIP_CHECK=1 %s -sp -i '%s' '%s' '::%s'", 65 | get_opt("mcopy"), imageoutfile(image), 66 | file, target); 67 | if (ret) 68 | return ret; 69 | } 70 | if (!list_empty(&image->partitions)) 71 | return 0; 72 | 73 | if (!image->empty) 74 | ret = systemp(image, "MTOOLS_SKIP_CHECK=1 %s -sp -i '%s' '%s'/* ::", 75 | get_opt("mcopy"), imageoutfile(image), mountpath(image)); 76 | return ret; 77 | } 78 | 79 | static int vfat_setup(struct image *image, cfg_t *cfg) 80 | { 81 | char *label = cfg_getstr(image->imagesec, "label"); 82 | 83 | if (!image->size) { 84 | image_error(image, "no size given or must not be zero\n"); 85 | return -EINVAL; 86 | } 87 | 88 | if (label && strlen(label) > 11) { 89 | image_error(image, "vfat volume name cannot be longer than 11 characters\n"); 90 | return -EINVAL; 91 | } 92 | 93 | return 0; 94 | } 95 | 96 | static int vfat_parse(struct image *image, cfg_t *cfg) 97 | { 98 | unsigned int i; 99 | unsigned int num_files; 100 | struct partition *part; 101 | 102 | num_files = cfg_size(cfg, "file"); 103 | for (i = 0; i < num_files; i++) { 104 | cfg_t *filesec = cfg_getnsec(cfg, "file", i); 105 | part = xzalloc(sizeof *part); 106 | part->name = cfg_title(filesec); 107 | part->image = cfg_getstr(filesec, "image"); 108 | list_add_tail(&part->list, &image->partitions); 109 | } 110 | 111 | for (i = 0; i < cfg_size(cfg, "files"); i++) { 112 | part = xzalloc(sizeof *part); 113 | part->image = cfg_getnstr(cfg, "files", i); 114 | part->name = ""; 115 | list_add_tail(&part->list, &image->partitions); 116 | } 117 | 118 | return 0; 119 | } 120 | 121 | static cfg_opt_t file_opts[] = { 122 | CFG_STR("image", NULL, CFGF_NONE), 123 | CFG_END() 124 | }; 125 | 126 | static cfg_opt_t vfat_opts[] = { 127 | CFG_STR("extraargs", "", CFGF_NONE), 128 | CFG_STR("label", "", CFGF_NONE), 129 | CFG_STR_LIST("files", NULL, CFGF_NONE), 130 | CFG_SEC("file", file_opts, CFGF_MULTI | CFGF_TITLE), 131 | CFG_END() 132 | }; 133 | 134 | struct image_handler vfat_handler = { 135 | .type = "vfat", 136 | .generate = vfat_generate, 137 | .setup = vfat_setup, 138 | .parse = vfat_parse, 139 | .opts = vfat_opts, 140 | }; 141 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | libtool.m4 2 | ltoptions.m4 3 | ltsugar.m4 4 | ltversion.m4 5 | lt~obsolete.m4 6 | 7 | -------------------------------------------------------------------------------- /test.config: -------------------------------------------------------------------------------- 1 | 2 | include("flash.conf") 3 | 4 | #----------------------------------- 5 | 6 | image data.tgz { 7 | tar {} 8 | mountpoint = "/data" 9 | } 10 | 11 | image nand-pcm038.img { 12 | flash { 13 | } 14 | flashtype = "nand-64M-512" 15 | partition barebox { 16 | image = "barebox-pcm038.bin" 17 | size = 512K 18 | } 19 | partition bareboxenv { 20 | image = "bareboxenv-pcm038.bin" 21 | size = 512K 22 | } 23 | partition kernel { 24 | image = "kernel-imx.bin" 25 | size = 4M 26 | } 27 | partition root { 28 | image = "root-nand.ubi" 29 | size = 20M 30 | } 31 | partition data { 32 | image = "data-nand.ubi" 33 | size = 0 34 | } 35 | } 36 | 37 | image root-nor-32M-64k.jffs2 { 38 | name = "root" 39 | flashtype = "nor-64M-128k" 40 | jffs2 {} 41 | size = 24M 42 | mountpoint = "/" 43 | } 44 | 45 | image data-nor-32M-64k.jffs2 { 46 | name = "data" 47 | flashtype = "nor-64M-128k" 48 | size = 0 49 | jffs2 { 50 | extraargs = "-l" 51 | } 52 | mountpoint = "/data" 53 | } 54 | 55 | image nand-pcm037.img { 56 | flash { 57 | } 58 | flashtype = "nand-64M-512" 59 | partition barebox { 60 | image = "barebox-pcm037.bin" 61 | size = 512K 62 | } 63 | partition bareboxenv { 64 | image = "bareboxenv-pcm037.bin" 65 | size = 512K 66 | } 67 | partition kernel { 68 | image = "kernel-imx.bin" 69 | size = 4M 70 | } 71 | partition root { 72 | image = "root-nand.ubi" 73 | size = 20M 74 | } 75 | partition data { 76 | image = "data-nand.ubi" 77 | size = 0 78 | } 79 | } 80 | 81 | image data-nand.ubi { 82 | ubi {} 83 | partition data { 84 | autoresize = true 85 | image = "data-nand.ubifs" 86 | } 87 | partition root { 88 | image = "data-nand.ubifs" 89 | } 90 | } 91 | 92 | image data-nand.ubifs { 93 | ubifs {} 94 | name = "data" 95 | size = 128M 96 | mountpoint = "/data" 97 | } 98 | 99 | image barebox-pcm038.bin { 100 | name = "barebox" 101 | file {} 102 | } 103 | 104 | image bareboxenv-pcm038.bin { 105 | name = "bareboxenv" 106 | file {} 107 | } 108 | 109 | image barebox-pcm037.bin { 110 | name = "barebox" 111 | file {} 112 | } 113 | 114 | image bareboxenv-pcm037.bin { 115 | name = "bareboxenv" 116 | file {} 117 | } 118 | 119 | image kernel-imx.bin { 120 | name = "kernel" 121 | file { 122 | name = "zImage-linux-2.6.39-imx" 123 | } 124 | } 125 | 126 | image root-nand.ubi { 127 | name = "root" 128 | ubi {} 129 | 130 | partition root { 131 | image = "root-nand.ubifs" 132 | } 133 | } 134 | 135 | image root-nand.ubifs { 136 | name = "root" 137 | size = 128M 138 | ubifs {} 139 | mountpoint = "/" 140 | } 141 | 142 | image hdimg.img { 143 | hdimage {} 144 | 145 | partition root { 146 | offset = 2M 147 | size = 128M 148 | partition-type = 0x78 149 | image = "root.ext2" 150 | } 151 | partition data { 152 | size = 20M 153 | partition-type = 0x1a 154 | image = "data.ext2" 155 | } 156 | 157 | size = 2G 158 | } 159 | 160 | image root.ext2 { 161 | ext2 {} 162 | size = 128M 163 | mountpoint = "/" 164 | } 165 | 166 | image data.ext2 { 167 | ext2 {} 168 | size = 20M 169 | mountpoint = "/data" 170 | } 171 | 172 | config { 173 | outputpath = images 174 | inputpath = input 175 | rootpath = root 176 | tmppath = tmp 177 | } 178 | 179 | -------------------------------------------------------------------------------- /test/btrfs.config: -------------------------------------------------------------------------------- 1 | image test.btrfs { 2 | btrfs { 3 | label = "btrfstest" 4 | # set UUID to test if extraargs works 5 | extraargs = "--uuid 47e790af-a2e1-42ff-92c7-83f45f7b2228" 6 | } 7 | size = 64M 8 | } 9 | -------------------------------------------------------------------------------- /test/cpio.config: -------------------------------------------------------------------------------- 1 | image test.cpio { 2 | cpio { 3 | format = "newc" 4 | compress = "gzip" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/cramfs.config: -------------------------------------------------------------------------------- 1 | image test.cramfs { 2 | cramfs { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /test/erofs.config: -------------------------------------------------------------------------------- 1 | image test.erofs { 2 | erofs { 3 | fs-timestamp = "20000101000000" 4 | extraargs = "-U 83d9e40a-fb96-469e-abb9-24fb3c3bd0ff" 5 | } 6 | size = 4M 7 | } 8 | -------------------------------------------------------------------------------- /test/erofs.dump: -------------------------------------------------------------------------------- 1 | Filesystem magic number: 0xE0F5E1E2 2 | Filesystem blocks: 1 3 | Filesystem inode metadata start block: 0 4 | Filesystem shared xattr metadata start block: 0 5 | Filesystem root nid: 36 6 | Filesystem inode count: 41 7 | Filesystem created: Thu Dec 21 11:06:40 635747 8 | Filesystem features: sb_csum mtime 9 | Filesystem UUID: 83d9e40a-fb96-469e-abb9-24fb3c3bd0ff 10 | Filesystem total file count: 41 11 | Filesystem unknown type count: 0 12 | Filesystem regular file count: 24 13 | Filesystem directory count: 17 14 | Filesystem char dev count: 0 15 | Filesystem block dev count: 0 16 | Filesystem FIFO file count: 0 17 | Filesystem SOCK file count: 0 18 | Filesystem symlink file count: 0 19 | Filesystem compressed files: 0 20 | Filesystem uncompressed files: 41 21 | Filesystem total original file size: 0 Bytes 22 | Filesystem total file size: 0 Bytes 23 | Filesystem compress rate: -nan% 24 | 25 | Original file size distribution: 26 | >=(KB) .. <(KB) count ratio |distribution | 27 | 0 .. 1 24 100.00% |##################################################| 28 | 1 .. 2 0 0.00% | | 29 | 2 .. 4 0 0.00% | | 30 | 4 .. 8 0 0.00% | | 31 | 8 .. 16 0 0.00% | | 32 | 16 .. 32 0 0.00% | | 33 | 32 .. 64 0 0.00% | | 34 | 64 .. 128 0 0.00% | | 35 | 128 .. 256 0 0.00% | | 36 | 256 .. 512 0 0.00% | | 37 | 512 .. 1024 0 0.00% | | 38 | 1024 .. 2048 0 0.00% | | 39 | 2048 .. 4096 0 0.00% | | 40 | 4096 .. 8192 0 0.00% | | 41 | 8192 .. 16384 0 0.00% | | 42 | 16384 .. 32768 0 0.00% | | 43 | 32768 .. 0 0.00% | | 44 | 45 | On-disk file size distribution: 46 | >=(KB) .. <(KB) count ratio |distribution | 47 | 0 .. 1 24 100.00% |##################################################| 48 | 1 .. 2 0 0.00% | | 49 | 2 .. 4 0 0.00% | | 50 | 4 .. 8 0 0.00% | | 51 | 8 .. 16 0 0.00% | | 52 | 16 .. 32 0 0.00% | | 53 | 32 .. 64 0 0.00% | | 54 | 64 .. 128 0 0.00% | | 55 | 128 .. 256 0 0.00% | | 56 | 256 .. 512 0 0.00% | | 57 | 512 .. 1024 0 0.00% | | 58 | 1024 .. 2048 0 0.00% | | 59 | 2048 .. 4096 0 0.00% | | 60 | 4096 .. 8192 0 0.00% | | 61 | 8192 .. 16384 0 0.00% | | 62 | 16384 .. 32768 0 0.00% | | 63 | 32768 .. 0 0.00% | | 64 | 65 | File type distribution: 66 | type count ratio |distribution | 67 | .txt 0 0.00% | | 68 | .so 0 0.00% | | 69 | .xml 0 0.00% | | 70 | .apk 0 0.00% | | 71 | .odex 0 0.00% | | 72 | .vdex 0 0.00% | | 73 | .oat 0 0.00% | | 74 | .rc 0 0.00% | | 75 | .otf 0 0.00% | | 76 | .txt 0 0.00% | | 77 | others 24 100.00% |##################################################| 78 | File : / 79 | Size: 95 On-disk size: 95 directory 80 | NID: 36 Links: 6 Layout: 2 Compression ratio: 100.00% 81 | Inode size: 32 Extent size: 0 Xattr size: 0 82 | Uid: 0 Gid: 0 Access: 0755/rwxr-xr-x 83 | Timestamp: 635747-12-21 11:06:40.000000000 84 | 85 | NID TYPE FILENAME 86 | 36 2 . 87 | 36 2 .. 88 | 40 2 bar 89 | 59 2 baz 90 | 78 2 foo 91 | 97 2 with spaces 92 | -------------------------------------------------------------------------------- /test/exec-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec >&2 4 | 5 | name="${1}" 6 | empty="${2}" 7 | 8 | set -ex 9 | 10 | : OUTPUTPATH 11 | test "${OUTPUTPATH}" = "${PWD}/images" 12 | : INPUTPATH 13 | test "${INPUTPATH}" = "${PWD}/input" 14 | : ROOTPATH 15 | test "${ROOTPATH}" = "${PWD}/root.orig" 16 | : TMPPATH 17 | test "${TMPPATH}" = "${PWD}/tmp" 18 | : IMAGE 19 | test "${IMAGE}" = "${name}" 20 | : IMAGEOUTFILE 21 | test "${IMAGEOUTFILE}" = "${PWD}/images/${name}" 22 | : IMAGENAME 23 | test "${IMAGENAME}" = "exec-test" 24 | : IMAGESIZE 25 | test "${IMAGESIZE}" = "3584" 26 | : IMAGEMOUNTPOINT 27 | test "${IMAGEMOUNTPOINT}" = "" 28 | : IMAGEMOUNTPATH 29 | if [ "${empty}" = "empty" ]; then 30 | test "${IMAGEMOUNTPATH}" = "" 31 | else 32 | test "${IMAGEMOUNTPATH}" = "${PWD}/tmp/root" 33 | fi 34 | -------------------------------------------------------------------------------- /test/exec-fail.config: -------------------------------------------------------------------------------- 1 | image file1.img { 2 | file {} 3 | exec-pre = "false" 4 | } 5 | -------------------------------------------------------------------------------- /test/exec.config: -------------------------------------------------------------------------------- 1 | image file1.img { 2 | file {} 3 | name = "exec-test" 4 | exec-pre = "./exec-check.sh file1.img" 5 | } 6 | 7 | image file2.img { 8 | file {} 9 | name = "exec-test" 10 | mountpoint = "/" 11 | exec-post = "./exec-check.sh file2.img" 12 | } 13 | 14 | image file3.img { 15 | file {} 16 | name = "exec-test" 17 | empty = true 18 | exec-pre = "./exec-check.sh file3.img empty" 19 | } 20 | 21 | image file4.img { 22 | file {} 23 | name = "exec-test" 24 | empty = true 25 | mountpoint = "/" 26 | exec-post = "./exec-check.sh file4.img empty" 27 | } 28 | -------------------------------------------------------------------------------- /test/ext.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | test_description="extX Image Tests" 3 | 4 | . "$(dirname "${0}")/test-setup.sh" 5 | 6 | check_root() { 7 | diff -ru "${root_orig}" "${root_test}" 8 | } 9 | 10 | func_check() { 11 | local ret="$?" 12 | set +x 13 | if [ "${ret}" != 0 ]; then 14 | echo "Failed to execute '${FUNCNAME[1]}'!" >&2 15 | return "${ret}" 16 | fi 17 | } 18 | 19 | compare_label() { 20 | if [ "${1}" != "${2}" ]; then 21 | echo "Filesystem Label does not match: exprected: '${2}' found '${1}'" 22 | return 1 23 | fi 24 | } 25 | 26 | version_leq() { 27 | first="$(printf "${1}\n${2}" | sort -V | head -n1)" 28 | test "${first}" == "${1}" 29 | } 30 | 31 | check_ext() { 32 | [ "$verbose" = "t" ] && set -x 33 | # UUID is randomly generated 34 | uuid="Filesystem UUID" 35 | # Hash Seed is randomly generated 36 | seed="Directory Hash Seed:" 37 | # checksum depends on random data 38 | csum1="Checksum: \|Group 0: (Blocks 1-4095) csum" 39 | # format change 40 | csum2="Group 0: (Blocks 1-4095) \\[ITABLE_ZEROED\\]\| Checksum .*, unused inodes 205" 41 | dumpe2fs "${1}" | grep -v "^\($uuid\|$seed\|$csum1\|$csum2\)" > "dump" && 42 | # some architectures (including arm64) use unsigned char 43 | sed -i 's/un\(signed_directory_hash\)/\1/' "dump" && 44 | if [ "${4}" = "genext2fs" ]; then 45 | if [ "$(genext2fs --version)" = "genext2fs 1.4.1" ]; then 46 | version=0 47 | else 48 | dumpe2fs_version="$(dumpe2fs -V |& sed -n 's/^dumpe2fs \([^ ]*\) .*/\1/p')" 49 | if version_leq "${dumpe2fs_version}" "1.46.2"; then 50 | # Debian Bullseye 51 | version=1 52 | else 53 | version=2 54 | fi 55 | fi 56 | else 57 | mke2fs_version="$(mke2fs -V |& sed -n 's/^mke2fs \([^ ]*\) .*/\1/p')" 58 | if version_leq "${mke2fs_version}" "1.45.5"; then 59 | # Ubuntu 20.04 60 | version=0 61 | elif version_leq "${mke2fs_version}" "1.46.5"; then 62 | # Ubuntu 22.04 63 | version=1 64 | elif version_leq "${mke2fs_version}" "1.47.0"; then 65 | # Ubuntu 24.04 66 | version=2 67 | else 68 | # at least 1.47.0 69 | version=3 70 | fi 71 | fi 72 | export TEST_CMP="diff --ignore-space-change -u" && 73 | test_cmp "${testdir}/${2}.${version}.dump" "dump" && 74 | e2fsck -nf "${1}" && 75 | # old versions of debugfs cannot dump '/' 76 | debugfs -R "ls -p" "${1}" | ( 77 | IFS=/ 78 | while read a b c d e x f; do 79 | case "${x}" in 80 | .|..|lost+found|"") continue ;; 81 | esac 82 | debugfs -R "rdump \"${x}\" \"${root_test}\"" "${1}" || break 83 | done 84 | ) && 85 | check_size "${1}" "${3}" && 86 | check_root 87 | func_check 88 | } 89 | 90 | exec_test_set_prereq genext2fs 91 | exec_test_set_prereq e2fsck 92 | test_expect_success genext2fs,e2fsck "ext2" " 93 | run_genimage_root ext2.config test.ext2 && 94 | check_ext images/test.ext2 ext2test 4194304 genext2fs 95 | " 96 | 97 | test_expect_success genext2fs,e2fsck "ext2percent" " 98 | run_genimage_root ext2percent.config test.ext2 && 99 | check_ext images/test.ext2 ext2test-percent 69632 genext2fs 100 | " 101 | 102 | test_expect_success genext2fs,e2fsck "ext3" " 103 | run_genimage_root ext3.config test.ext3 && 104 | check_ext images/test.ext3 ext3test 4194304 genext2fs 105 | " 106 | 107 | test_expect_success genext2fs,e2fsck "ext4" " 108 | run_genimage ext4.config test.ext4 && 109 | check_ext images/test.ext4 ext4test 4194304 genext2fs 110 | " 111 | 112 | test_expect_success mke2fs,e2fsck "mke2fs" " 113 | run_genimage_root mke2fs.config mke2fs.ext4 && 114 | check_ext images/mke2fs.ext4 mke2fs 33554432 mke2fs 115 | " 116 | 117 | test_done 118 | 119 | # vim: syntax=sh 120 | -------------------------------------------------------------------------------- /test/ext2.config: -------------------------------------------------------------------------------- 1 | image test.ext2 { 2 | ext2 { 3 | label = "ext2test" 4 | use-mke2fs = false 5 | fs-timestamp = "20000101000000" 6 | } 7 | size = 4M 8 | } 9 | -------------------------------------------------------------------------------- /test/ext2percent.config: -------------------------------------------------------------------------------- 1 | image test.ext2 { 2 | ext2 { 3 | label = "ext2test" 4 | use-mke2fs = false 5 | fs-timestamp = "20000101000000" 6 | } 7 | size = 100% 8 | } 9 | -------------------------------------------------------------------------------- /test/ext2test-percent.0.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext2test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 0 (original) 5 | Filesystem features: (none) 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 56 11 | Block count: 68 12 | Reserved block count: 3 13 | Free blocks: 36 14 | Free inodes: 5 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 72 19 | Fragments per group: 72 20 | Inodes per group: 56 21 | Inode blocks per group: 7 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | 32 | 33 | Group 0: (Blocks 1-67) 34 | Primary superblock at 1, Group descriptors at 2-2 35 | Block bitmap at 3 (+2) 36 | Inode bitmap at 4 (+3) 37 | Inode table at 5-11 (+4) 38 | 36 free blocks, 5 free inodes, 18 directories 39 | Free blocks: 32-67 40 | Free inodes: 52-56 41 | -------------------------------------------------------------------------------- /test/ext2test-percent.1.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext2test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: (none) 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 56 11 | Block count: 68 12 | Reserved block count: 3 13 | Free blocks: 22 14 | Free inodes: 5 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 72 19 | Fragments per group: 72 20 | Inodes per group: 56 21 | Inode blocks per group: 7 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | First inode: 11 32 | Inode size: 128 33 | 34 | 35 | Group 0: (Blocks 1-67) 36 | Primary superblock at 1, Group descriptors at 2-2 37 | Block bitmap at 3 (+2) 38 | Inode bitmap at 4 (+3) 39 | Inode table at 5-11 (+4) 40 | 22 free blocks, 5 free inodes, 18 directories 41 | Free blocks: 46-67 42 | Free inodes: 52-56 43 | -------------------------------------------------------------------------------- /test/ext2test-percent.2.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext2test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: (none) 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 56 11 | Block count: 68 12 | Reserved block count: 3 13 | Free blocks: 22 14 | Free inodes: 5 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 72 19 | Fragments per group: 72 20 | Inodes per group: 56 21 | Inode blocks per group: 7 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | First inode: 11 32 | Inode size: 128 33 | 34 | 35 | Group 0: (Blocks 1-67) 36 | Primary superblock at 1, Group descriptors at 2-2 37 | Block bitmap at 3 (+2) 38 | Inode bitmap at 4 (+3) 39 | Inode table at 5-11 (+4) 40 | 22 free blocks, 5 free inodes, 18 directories 41 | Free blocks: 46-67 42 | Free inodes: 52-56 43 | -------------------------------------------------------------------------------- /test/ext2test.0.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext2test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 0 (original) 5 | Filesystem features: (none) 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 256 11 | Block count: 4096 12 | Reserved block count: 204 13 | Free blocks: 3837 14 | Free inodes: 205 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 4096 19 | Fragments per group: 4096 20 | Inodes per group: 256 21 | Inode blocks per group: 32 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | 32 | 33 | Group 0: (Blocks 1-4095) 34 | Primary superblock at 1, Group descriptors at 2-2 35 | Block bitmap at 3 (+2) 36 | Inode bitmap at 4 (+3) 37 | Inode table at 5-36 (+4) 38 | 3837 free blocks, 205 free inodes, 18 directories 39 | Free blocks: 259-4095 40 | Free inodes: 52-256 41 | -------------------------------------------------------------------------------- /test/ext2test.1.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext2test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: (none) 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 256 11 | Block count: 4096 12 | Reserved block count: 204 13 | Free blocks: 4025 14 | Free inodes: 205 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 4096 19 | Fragments per group: 4096 20 | Inodes per group: 256 21 | Inode blocks per group: 32 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | First inode: 11 32 | Inode size: 128 33 | 34 | 35 | Group 0: (Blocks 1-4095) 36 | Primary superblock at 1, Group descriptors at 2-2 37 | Block bitmap at 3 (+2) 38 | Inode bitmap at 4 (+3) 39 | Inode table at 5-36 (+4) 40 | 4025 free blocks, 205 free inodes, 18 directories 41 | Free blocks: 71-4095 42 | Free inodes: 52-256 43 | -------------------------------------------------------------------------------- /test/ext2test.2.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext2test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: (none) 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 256 11 | Block count: 4096 12 | Reserved block count: 204 13 | Free blocks: 4025 14 | Free inodes: 205 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 4096 19 | Fragments per group: 4096 20 | Inodes per group: 256 21 | Inode blocks per group: 32 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | First inode: 11 32 | Inode size: 128 33 | 34 | 35 | Group 0: (Blocks 1-4095) 36 | Primary superblock at 1, Group descriptors at 2-2 37 | Block bitmap at 3 (+2) 38 | Inode bitmap at 4 (+3) 39 | Inode table at 5-36 (+4) 40 | 4025 free blocks, 205 free inodes, 18 directories 41 | Free blocks: 71-4095 42 | Free inodes: 52-256 43 | -------------------------------------------------------------------------------- /test/ext3.config: -------------------------------------------------------------------------------- 1 | image test.ext3 { 2 | ext3 { 3 | label = "ext3test" 4 | use-mke2fs = false 5 | fs-timestamp = "20000101000000" 6 | } 7 | size = 4M 8 | } 9 | -------------------------------------------------------------------------------- /test/ext3test.0.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext3test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 256 11 | Block count: 4096 12 | Reserved block count: 204 13 | Free blocks: 2808 14 | Free inodes: 205 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 4096 19 | Fragments per group: 4096 20 | Inodes per group: 256 21 | Inode blocks per group: 32 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | First inode: 11 32 | Inode size: 128 33 | Journal inode: 8 34 | Journal backup: inode blocks 35 | Journal features: (none) 36 | Journal size: 1024k 37 | Journal length: 1024 38 | Journal sequence: 0x00000001 39 | Journal start: 0 40 | 41 | 42 | Group 0: (Blocks 1-4095) 43 | Primary superblock at 1, Group descriptors at 2-2 44 | Block bitmap at 3 (+2) 45 | Inode bitmap at 4 (+3) 46 | Inode table at 5-36 (+4) 47 | 2808 free blocks, 205 free inodes, 18 directories 48 | Free blocks: 1288-4095 49 | Free inodes: 52-256 50 | -------------------------------------------------------------------------------- /test/ext3test.1.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext3test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 256 11 | Block count: 4096 12 | Reserved block count: 204 13 | Free blocks: 2996 14 | Free inodes: 205 15 | First block: 1 16 | Block size: 1024 17 | Fragment size: 1024 18 | Blocks per group: 4096 19 | Fragments per group: 4096 20 | Inodes per group: 256 21 | Inode blocks per group: 32 22 | Filesystem created: Sat Jan 1 00:00:00 2000 23 | Last mount time: n/a 24 | Last write time: Sat Jan 1 00:00:00 2000 25 | Mount count: 0 26 | Maximum mount count: 20 27 | Last checked: Sat Jan 1 00:00:00 2000 28 | Check interval: 0 () 29 | Reserved blocks uid: 0 (user root) 30 | Reserved blocks gid: 0 (group root) 31 | First inode: 11 32 | Inode size: 128 33 | Journal inode: 8 34 | Journal backup: inode blocks 35 | Journal features: (none) 36 | Total journal size: 1024k 37 | Total journal blocks: 1024 38 | Max transaction length: 1024 39 | Fast commit length: 0 40 | Journal sequence: 0x00000001 41 | Journal start: 0 42 | 43 | 44 | Group 0: (Blocks 1-4095) 45 | Primary superblock at 1, Group descriptors at 2-2 46 | Block bitmap at 3 (+2) 47 | Inode bitmap at 4 (+3) 48 | Inode table at 5-36 (+4) 49 | 2996 free blocks, 205 free inodes, 18 directories 50 | Free blocks: 1100-4095 51 | Free inodes: 52-256 52 | -------------------------------------------------------------------------------- /test/ext3test.2.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext3test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal 6 | Default mount options: (none) 7 | Filesystem state: clean 8 | Errors behavior: Unknown (continue) 9 | Filesystem OS type: Linux 10 | Inode count: 256 11 | Block count: 4096 12 | Reserved block count: 204 13 | Overhead clusters: 1024 14 | Free blocks: 2996 15 | Free inodes: 205 16 | First block: 1 17 | Block size: 1024 18 | Fragment size: 1024 19 | Blocks per group: 4096 20 | Fragments per group: 4096 21 | Inodes per group: 256 22 | Inode blocks per group: 32 23 | Filesystem created: Sat Jan 1 00:00:00 2000 24 | Last mount time: n/a 25 | Last write time: Sat Jan 1 00:00:00 2000 26 | Mount count: 0 27 | Maximum mount count: 20 28 | Last checked: Sat Jan 1 00:00:00 2000 29 | Check interval: 0 () 30 | Reserved blocks uid: 0 (user root) 31 | Reserved blocks gid: 0 (group root) 32 | First inode: 11 33 | Inode size: 128 34 | Journal inode: 8 35 | Journal backup: inode blocks 36 | Journal features: (none) 37 | Total journal size: 1024k 38 | Total journal blocks: 1024 39 | Max transaction length: 1024 40 | Fast commit length: 0 41 | Journal sequence: 0x00000001 42 | Journal start: 0 43 | 44 | 45 | Group 0: (Blocks 1-4095) 46 | Primary superblock at 1, Group descriptors at 2-2 47 | Block bitmap at 3 (+2) 48 | Inode bitmap at 4 (+3) 49 | Inode table at 5-36 (+4) 50 | 2996 free blocks, 205 free inodes, 18 directories 51 | Free blocks: 1100-4095 52 | Free inodes: 52-256 53 | -------------------------------------------------------------------------------- /test/ext4.config: -------------------------------------------------------------------------------- 1 | image test.ext4 { 2 | ext4 { 3 | label = "ext4test" 4 | fs-timestamp = "20000101000000" 5 | use-mke2fs = false 6 | } 7 | srcpath = "root.orig" 8 | size = 4M 9 | } 10 | -------------------------------------------------------------------------------- /test/ext4test.0.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext4test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal dir_index extent uninit_bg 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: (none) 8 | Filesystem state: clean 9 | Errors behavior: Unknown (continue) 10 | Filesystem OS type: Linux 11 | Inode count: 256 12 | Block count: 4096 13 | Reserved block count: 204 14 | Free blocks: 2813 15 | Free inodes: 205 16 | First block: 1 17 | Block size: 1024 18 | Fragment size: 1024 19 | Blocks per group: 4096 20 | Fragments per group: 4096 21 | Inodes per group: 256 22 | Inode blocks per group: 32 23 | Filesystem created: Sat Jan 1 00:00:00 2000 24 | Last mount time: n/a 25 | Last write time: Sat Jan 1 00:00:00 2000 26 | Mount count: 0 27 | Maximum mount count: 20 28 | Last checked: Sat Jan 1 00:00:00 2000 29 | Check interval: 0 () 30 | Reserved blocks uid: 0 (user root) 31 | Reserved blocks gid: 0 (group root) 32 | First inode: 11 33 | Inode size: 128 34 | Journal inode: 8 35 | Default directory hash: half_md4 36 | Journal backup: inode blocks 37 | Journal features: (none) 38 | Journal size: 1024k 39 | Journal length: 1024 40 | Journal sequence: 0x00000001 41 | Journal start: 0 42 | 43 | 44 | Primary superblock at 1, Group descriptors at 2-2 45 | Block bitmap at 3 (+2) 46 | Inode bitmap at 4 (+3) 47 | Inode table at 5-36 (+4) 48 | 2813 free blocks, 205 free inodes, 18 directories, 205 unused inodes 49 | Free blocks: 1283-4095 50 | Free inodes: 52-256 51 | -------------------------------------------------------------------------------- /test/ext4test.1.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext4test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal dir_index extent uninit_bg 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: (none) 8 | Filesystem state: clean 9 | Errors behavior: Unknown (continue) 10 | Filesystem OS type: Linux 11 | Inode count: 256 12 | Block count: 4096 13 | Reserved block count: 204 14 | Free blocks: 3001 15 | Free inodes: 205 16 | First block: 1 17 | Block size: 1024 18 | Fragment size: 1024 19 | Blocks per group: 4096 20 | Fragments per group: 4096 21 | Inodes per group: 256 22 | Inode blocks per group: 32 23 | Filesystem created: Sat Jan 1 00:00:00 2000 24 | Last mount time: n/a 25 | Last write time: Sat Jan 1 00:00:00 2000 26 | Mount count: 0 27 | Maximum mount count: 20 28 | Last checked: Sat Jan 1 00:00:00 2000 29 | Check interval: 0 () 30 | Reserved blocks uid: 0 (user root) 31 | Reserved blocks gid: 0 (group root) 32 | First inode: 11 33 | Inode size: 128 34 | Journal inode: 8 35 | Default directory hash: half_md4 36 | Journal backup: inode blocks 37 | Journal features: (none) 38 | Total journal size: 1024k 39 | Total journal blocks: 1024 40 | Max transaction length: 1024 41 | Fast commit length: 0 42 | Journal sequence: 0x00000001 43 | Journal start: 0 44 | 45 | 46 | Primary superblock at 1, Group descriptors at 2-2 47 | Block bitmap at 3 (+2) 48 | Inode bitmap at 4 (+3) 49 | Inode table at 5-36 (+4) 50 | 3001 free blocks, 205 free inodes, 18 directories, 205 unused inodes 51 | Free blocks: 1095-4095 52 | Free inodes: 52-256 53 | -------------------------------------------------------------------------------- /test/ext4test.2.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: ext4test 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal dir_index extent uninit_bg 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: (none) 8 | Filesystem state: clean 9 | Errors behavior: Unknown (continue) 10 | Filesystem OS type: Linux 11 | Inode count: 256 12 | Block count: 4096 13 | Reserved block count: 204 14 | Overhead clusters: 1024 15 | Free blocks: 3001 16 | Free inodes: 205 17 | First block: 1 18 | Block size: 1024 19 | Fragment size: 1024 20 | Blocks per group: 4096 21 | Fragments per group: 4096 22 | Inodes per group: 256 23 | Inode blocks per group: 32 24 | Filesystem created: Sat Jan 1 00:00:00 2000 25 | Last mount time: n/a 26 | Last write time: Sat Jan 1 00:00:00 2000 27 | Mount count: 0 28 | Maximum mount count: 20 29 | Last checked: Sat Jan 1 00:00:00 2000 30 | Check interval: 0 () 31 | Reserved blocks uid: 0 (user root) 32 | Reserved blocks gid: 0 (group root) 33 | First inode: 11 34 | Inode size: 128 35 | Journal inode: 8 36 | Default directory hash: half_md4 37 | Journal backup: inode blocks 38 | Journal features: (none) 39 | Total journal size: 1024k 40 | Total journal blocks: 1024 41 | Max transaction length: 1024 42 | Fast commit length: 0 43 | Journal sequence: 0x00000001 44 | Journal start: 0 45 | 46 | 47 | Primary superblock at 1, Group descriptors at 2-2 48 | Block bitmap at 3 (+2) 49 | Inode bitmap at 4 (+3) 50 | Inode table at 5-36 (+4) 51 | 3001 free blocks, 205 free inodes, 18 directories, 205 unused inodes 52 | Free blocks: 1095-4095 53 | Free inodes: 52-256 54 | -------------------------------------------------------------------------------- /test/f2fs.config: -------------------------------------------------------------------------------- 1 | image test.f2fs { 2 | f2fs { 3 | label = "f2fstest" 4 | } 5 | size = 64M 6 | } 7 | -------------------------------------------------------------------------------- /test/filesystem.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | test_description="Filesystem Image Tests" 3 | 4 | . "$(dirname "${0}")/test-setup.sh" 5 | 6 | check_filelist() { 7 | test_cmp "${filelist_orig}" "${filelist_test}" 8 | } 9 | 10 | exec_test_set_prereq cpio 11 | test_expect_success cpio "cpio" " 12 | run_genimage_root cpio.config test.cpio && 13 | zcat images/test.cpio | cpio --extract -t | grep -v '^\.$' | sort > '${filelist_test}' && 14 | check_size_range images/test.cpio 400 550 && 15 | check_filelist 16 | " 17 | 18 | exec_test_set_prereq mkcramfs 19 | test_expect_success mkcramfs "cramfs" " 20 | run_genimage_root cramfs.config test.cramfs && 21 | check_size images/test.cramfs 4096 22 | " 23 | 24 | exec_test_set_prereq genisoimage 25 | test_expect_success genisoimage "iso" " 26 | run_genimage_root iso.config test.iso && 27 | check_size_range images/test.iso 300000 400000 28 | " 29 | 30 | exec_test_set_prereq mkfs.f2fs 31 | exec_test_set_prereq sload.f2fs 32 | exec_test_set_prereq fsck.f2fs 33 | test_expect_success mkfs_f2fs,sload_f2fs,fsck_f2fs "f2fs" " 34 | run_genimage_root f2fs.config test.f2fs && 35 | fsck.f2fs images/test.f2fs 36 | " 37 | 38 | exec_test_set_prereq btrfs 39 | exec_test_set_prereq mkfs.btrfs 40 | test_expect_success mkfs_btrfs,btrfs "btrfs" " 41 | run_genimage_root btrfs.config test.btrfs 42 | btrfs check images/test.btrfs 43 | test \"\$(btrfs filesystem label images/test.btrfs)\" = btrfstest 44 | btrfs filesystem show images/test.btrfs | grep \"uuid: 47e790af-a2e1-42ff-92c7-83f45f7b2228\" 45 | " 46 | 47 | exec_test_set_prereq mksquashfs 48 | test_expect_success mksquashfs "squashfs" " 49 | run_genimage_root squashfs.config test.squashfs && 50 | check_size_range images/test.squashfs 4000 4100 && 51 | unsquashfs -ls images/test.squashfs | sed -n '/squashfs-root/s;squashfs-root/;;p' | sort > '${filelist_test}' && 52 | check_filelist 53 | " 54 | 55 | exec_test_set_prereq tar 56 | test_expect_success tar "tar" " 57 | run_genimage_root tar.config test.tar.gz && 58 | check_size_range images/test.tar.gz 500 600 && 59 | zcat images/test.tar.gz | tar -t | sed -n -e 's;/$;;' -e 's;^\./\(..*\)$;\1;p' | sort > '${filelist_test}' && 60 | check_filelist 61 | " 62 | 63 | exec_test_set_prereq dd 64 | exec_test_set_prereq mkdosfs 65 | exec_test_set_prereq mcopy 66 | test_expect_success dd,mkdosfs,mcopy "vfat" " 67 | run_genimage_root vfat.config test.vfat && 68 | fsck.fat -p images/test.vfat | tee fsck.log && 69 | test_must_fail grep -q 'Filesystem was changed' fsck.log && 70 | check_size images/test.vfat 4193280 && 71 | MTOOLS_SKIP_CHECK=1 mdir -/ -f -b -i images/test.vfat / | sed -e 's;^::/;;' -e 's;/$;;' | sort > '${filelist_test}' && 72 | check_filelist 73 | " 74 | 75 | exec_test_set_prereq mkfs.erofs 76 | exec_test_set_prereq fsck.erofs 77 | test_expect_success mkfs_erofs,fsck_erofs "erofs" " 78 | run_genimage_root erofs.config test.erofs && 79 | fsck.erofs -p images/test.erofs | tee erofs.log && 80 | test_must_fail grep -q 'Filesystem was changed' erofs.log && 81 | check_size images/test.erofs 4096 && 82 | dump.erofs -s -S --ls --path=/ images/test.erofs > erofs.dump && 83 | test_cmp ${testdir}/erofs.dump erofs.dump 84 | " 85 | 86 | test_done 87 | 88 | # vim: syntax=sh 89 | -------------------------------------------------------------------------------- /test/fip-size.config: -------------------------------------------------------------------------------- 1 | image test.fip { 2 | fip { 3 | extraargs = "--align 64" 4 | fw-config = "part1.img" 5 | tos-fw = { "part2.img", "part1.img" } 6 | /* will be about 12k in size */ 7 | } 8 | } 9 | 10 | image test.hdimage { 11 | hdimage {} 12 | partition part1 { 13 | image = test.fip 14 | size = 512 /* too small for fip image */ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/fip.config: -------------------------------------------------------------------------------- 1 | image test.fip { 2 | fip { 3 | extraargs = "--align 64" 4 | fw-config = "part1.img" 5 | tos-fw = { "part2.img", "part1.img" } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fit.config: -------------------------------------------------------------------------------- 1 | image test.fit { 2 | fit { 3 | its = "fit.its" 4 | } 5 | 6 | partition kernel { 7 | image = "part1.img" 8 | } 9 | 10 | partition ramdisk { 11 | image = "part2.img" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/fit.its: -------------------------------------------------------------------------------- 1 | /dts-v1/; 2 | 3 | / { 4 | description = "Test FIT image"; 5 | #address-cells = <1>; 6 | 7 | images { 8 | kernel { 9 | description = "kernel"; 10 | type = "kernel"; 11 | arch = "arm"; 12 | os = "linux"; 13 | compression = "none"; 14 | }; 15 | 16 | ramdisk { 17 | description = "ramdisk"; 18 | type = "ramdisk"; 19 | arch = "arm"; 20 | os = "linux"; 21 | compression = "none"; 22 | }; 23 | }; 24 | 25 | configurations { 26 | default = "conf"; 27 | conf { 28 | description = "test dummy config"; 29 | kernel = "kernel"; 30 | ramdisk = "ramdisk"; 31 | }; 32 | }; 33 | }; 34 | -------------------------------------------------------------------------------- /test/flash-types.config: -------------------------------------------------------------------------------- 1 | flash nand-64M-512 { 2 | pebsize = 16384 3 | lebsize = 15360 4 | numpebs = 4096 5 | minimum-io-unit-size = 512 6 | vid-header-offset = 512 7 | sub-page-size = 512 8 | } 9 | 10 | flash nor-64M-128k { 11 | pebsize = 131072 12 | lebsize = 130944 13 | numpebs = 256 14 | minimum-io-unit-size = 1 15 | vid-header-offset = 64 16 | sub-page-size = 1 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/flash.config: -------------------------------------------------------------------------------- 1 | include("flash-types.config") 2 | 3 | image test.flash { 4 | flash { 5 | } 6 | flashtype = "nand-64M-512" 7 | partition part1 { 8 | image = "part1.img" 9 | size = 1M 10 | } 11 | partition part2 { 12 | image = "part2.img" 13 | size = 1M 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/flash.md5: -------------------------------------------------------------------------------- 1 | 3ac27658859853c3c49b1c8f4524e9cc images/test.flash 2 | -------------------------------------------------------------------------------- /test/flash.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | test_description="Flash Image Tests" 3 | 4 | . "$(dirname "${0}")/test-setup.sh" 5 | 6 | exec_test_set_prereq dd 7 | test_expect_success "flash" " 8 | setup_test_images && 9 | run_genimage flash.config test.flash && 10 | md5sum -c '${testdir}/flash.md5' 11 | " 12 | 13 | exec_test_set_prereq mkfs.jffs2 14 | test_expect_success mkfs_jffs2 "jffs2" " 15 | run_genimage_root jffs2.config test.jffs2 && 16 | md5sum -c '${testdir}/jffs2.md5' 17 | " 18 | 19 | exec_test_set_prereq mkfs.ubifs 20 | test_expect_success mkfs_ubifs "ubifs" " 21 | run_genimage_root ubifs.config test.ubifs && 22 | check_size_range images/test.ubifs 200000 300000 23 | " 24 | 25 | setup_ubi_images() { 26 | rm -rf input && 27 | mkdir input && 28 | cp images/test.ubifs input/ 29 | } 30 | 31 | exec_test_set_prereq ubinize 32 | test_expect_success ubinize "ubi" " 33 | setup_ubi_images && 34 | run_genimage ubi.config test.ubi && 35 | check_size_range images/test.ubi 550000 600000 36 | " 37 | 38 | test_done 39 | 40 | # vim: syntax=sh 41 | -------------------------------------------------------------------------------- /test/genimage.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | test_description="Genimage Basic Functionality Tests" 3 | 4 | . "$(dirname "${0}")/test-setup.sh" 5 | 6 | setup_exec_files() { 7 | rm -rf input && 8 | mkdir input && 9 | dd if=/dev/zero of=input/file1.img bs=512 count=7 && 10 | dd if=/dev/zero of=input/file2.img bs=512 count=7 && 11 | dd if=/dev/zero of=input/file3.img bs=512 count=7 && 12 | dd if=/dev/zero of=input/file4.img bs=512 count=7 13 | } 14 | 15 | test_expect_success "exec" " 16 | setup_exec_files && 17 | run_genimage_root exec.config" 18 | 19 | test_expect_success "exec-fail" " 20 | setup_exec_files && 21 | test_must_fail run_genimage_root exec-fail.config" 22 | 23 | 24 | "$genimage" --help | grep -q 'GENIMAGE_INCLUDEPATH' && test_set_prereq "includepath" 25 | 26 | test_expect_success fdisk-gpt,sfdisk-gpt "includepath1" " 27 | run_genimage include.config && 28 | sanitized_fdisk_sfdisk images/include.hdimage > include.fdisk && 29 | test_cmp '${testdir}/include-ccc.fdisk' include.fdisk 30 | " 31 | 32 | test_expect_success fdisk-gpt,sfdisk-gpt,includepath "includepath2" " 33 | extra_opts='--includepath=${testdir}/include/aaa' run_genimage include.config && 34 | sanitized_fdisk_sfdisk images/include.hdimage > include.fdisk && 35 | test_cmp '${testdir}/include-aaa.fdisk' include.fdisk 36 | " 37 | 38 | test_expect_success fdisk-gpt,sfdisk-gpt,includepath "includepath3" " 39 | extra_opts='--includepath=${testdir}/include/bbb:${testdir}/include/aaa' run_genimage include.config && 40 | sanitized_fdisk_sfdisk images/include.hdimage > include.fdisk && 41 | test_cmp '${testdir}/include-bbb.fdisk' include.fdisk 42 | " 43 | 44 | test_expect_success fdisk-gpt,sfdisk-gpt,includepath "includepath4" " 45 | extra_opts='--includepath=.:${testdir}/include/bbb' run_genimage include.config && 46 | sanitized_fdisk_sfdisk images/include.hdimage > include.fdisk && 47 | test_cmp '${testdir}/include-ccc.fdisk' include.fdisk 48 | " 49 | 50 | test_expect_success !includepath "includepath5" " 51 | extra_opts='--includepath=${testdir}/include/aaa' test_must_fail run_genimage include.config 52 | " 53 | 54 | test_done 55 | 56 | # vim: syntax=sh 57 | -------------------------------------------------------------------------------- /test/gpt-invalid-partition-type1.config: -------------------------------------------------------------------------------- 1 | image gpt-partition-types-fail.img { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | } 5 | partition part1 { 6 | partition-type-uuid = "unknown-shortcut" 7 | size = 1M 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/gpt-invalid-partition-type2.config: -------------------------------------------------------------------------------- 1 | image gpt-partition-types-fail.img { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | } 5 | partition part1 { 6 | partition-type-uuid = "30f239f3-275c-4e0d-9b61-Ka385b7b80f9" 7 | size = 1M 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/gpt-overlap1.config: -------------------------------------------------------------------------------- 1 | image test.gpt-overlap1 { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | } 5 | 6 | partition SPL { 7 | # This should fail due to placing something on top of the GPT array. 8 | offset = 1K 9 | size = 24K 10 | in-partition-table = false 11 | image = "3K.img" 12 | } 13 | 14 | partition aaa { 15 | in-partition-table = true 16 | offset = 1M 17 | image = "70K.img" 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /test/gpt-overlap2.config: -------------------------------------------------------------------------------- 1 | image test.gpt-overlap2 { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | gpt-location = 32K 5 | } 6 | 7 | partition SPL { 8 | offset = 1K 9 | size = 24K 10 | in-partition-table = false 11 | image = "3K.img" 12 | } 13 | 14 | partition aaa { 15 | in-partition-table = true 16 | offset = 1M 17 | image = "70K.img" 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /test/gpt-overlap3.config: -------------------------------------------------------------------------------- 1 | image test.gpt-overlap3 { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | gpt-location = 30K 5 | } 6 | 7 | partition SPL { 8 | offset = 1K 9 | size = 24K 10 | in-partition-table = false 11 | image = "3K.img" 12 | } 13 | 14 | partition aaa { 15 | # The GPT partition table array occupies 16K, so this should fail. 16 | in-partition-table = true 17 | offset = 32K 18 | image = "70K.img" 19 | size = 1M 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/gpt-partition-types.config: -------------------------------------------------------------------------------- 1 | image gpt-partition-types.img { 2 | /* note: set non-random disk-uuid and partition-uuid */ 3 | hdimage { 4 | partition-table-type = "gpt" 5 | disk-uuid = "b0326371-955b-42e3-ad81-ad0151d813ec" 6 | } 7 | partition part1 { 8 | partition-type-uuid = "linux" 9 | partition-uuid = "3c1e674d-4bfd-4347-a1ab-4bb5d258b361" 10 | size = 1M 11 | } 12 | partition part2 { 13 | partition-type-uuid = "U" 14 | partition-uuid = "6a879323-b5f9-4275-9bb0-1c881048cba2" 15 | size = 1M 16 | } 17 | partition part3 { 18 | partition-type-uuid = "swap" 19 | partition-uuid = "9ea7f2d5-ea3f-431a-a9a5-16cabbca7f1b" 20 | size = 1M 21 | } 22 | partition part4 { 23 | partition-type-uuid = "3df8f8b0-4464-4fe6-8df4-2a5e2f6c4949" 24 | partition-uuid = "7dd9bebe-1c35-4886-a26c-2b784f172d89" 25 | size = 1M 26 | } 27 | partition part5 { 28 | partition-type-uuid = "usr-loongarch64-verity-sig" 29 | partition-uuid = "ae7784a0-a0b7-4ef4-94c4-c3ef78b00176" 30 | size = 1M 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/gpt-partition-types.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: B0326371-955B-42E3-AD81-AD0151D813EC 2 | images/gpt-partition-types.img1:start=34,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=3C1E674D-4BFD-4347-A1AB-4BB5D258B361,name="part1" 3 | images/gpt-partition-types.img2:start=2082,size=2048,type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B,uuid=6A879323-B5F9-4275-9BB0-1C881048CBA2,name="part2" 4 | images/gpt-partition-types.img3:start=4130,size=2048,type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F,uuid=9EA7F2D5-EA3F-431A-A9A5-16CABBCA7F1B,name="part3" 5 | images/gpt-partition-types.img4:start=6178,size=2048,type=3DF8F8B0-4464-4FE6-8DF4-2A5E2F6C4949,uuid=7DD9BEBE-1C35-4886-A26C-2B784F172D89,name="part4" 6 | images/gpt-partition-types.img5:start=8226,size=2048,type=B024F315-D330-444C-8461-44BBDE524E99,uuid=AE7784A0-A0B7-4EF4-94C4-C3EF78B00176,name="part5" 7 | -------------------------------------------------------------------------------- /test/hdimage-fail1.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "mbr" 4 | } 5 | partition part1 { 6 | /* partition-type-uuid not valid for mbr */ 7 | partition-type-uuid = "L" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/hdimage-fail10.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | extended-partition = 3 5 | } 6 | partition primary1 { 7 | image = "part1.img" 8 | partition-type = 0x83 9 | } 10 | partition primary2 { 11 | image = "part1.img" 12 | partition-type = 0x83 13 | } 14 | partition extended1 { 15 | image = "part1.img" 16 | partition-type = 0x83 17 | } 18 | partition extended2 { 19 | image = "part1.img" 20 | partition-type = 0x83 21 | } 22 | partition primary3 { 23 | image = "part1.img" 24 | partition-type = 0x83 25 | forced-primary = "yes" 26 | } 27 | partition primary4 { 28 | image = "part1.img" 29 | partition-type = 0x83 30 | /* would be 5th primary partition */ 31 | forced-primary = "yes" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/hdimage-fail11.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | extended-partition = 1 5 | } 6 | partition extended1 { 7 | image = "part1.img" 8 | partition-type = 0x83 9 | } 10 | partition extended2 { 11 | image = "part1.img" 12 | partition-type = 0x83 13 | } 14 | partition extended3 { 15 | image = "part1.img" 16 | partition-type = 0x83 17 | } 18 | partition extended4 { 19 | image = "part1.img" 20 | partition-type = 0x83 21 | } 22 | partition primary2 { 23 | image = "part1.img" 24 | partition-type = 0x83 25 | forced-primary = "yes" 26 | } 27 | partition extended5 { 28 | image = "part1.img" 29 | partition-type = 0x83 30 | /* extended partition would overlap the forced-primary one */ 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/hdimage-fail2.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | } 5 | partition part1 { 6 | /* partition-type not valid for gpt */ 7 | partition-type = 0x83 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/hdimage-fail3.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "hybrid" 4 | } 5 | partition part1 { 6 | /* missing partition-type */ 7 | partition-type-uuid = "L" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/hdimage-fail4.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "mbr" 4 | /* disk-uuid is only valid for gpt */ 5 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/hdimage-fail5.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | /* disk-signature is only valid for mbr */ 5 | disk-signature = 0x12345678 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/hdimage-fail6.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | disk-signature = 0x12345678 4 | } 5 | partition part1 { 6 | offset = 1M 7 | size = 1M 8 | partition-type = 0x83 9 | } 10 | partition part2 { 11 | offset = 2M 12 | size = 1M 13 | partition-type = 0x83 14 | } 15 | partition part3 { 16 | offset = 3M 17 | size = 1M 18 | partition-type = 0x83 19 | } 20 | partition part4 { 21 | /* this will overlap with the EBR */ 22 | offset = 4M 23 | size = 1M 24 | partition-type = 0x83 25 | } 26 | partition part5 { 27 | offset = 5M 28 | size = 1M 29 | partition-type = 0x83 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/hdimage-fail7.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "hybrid" 4 | disk-signature = 0x12345678 5 | } 6 | partition part1 { 7 | size = 1M 8 | partition-type-uuid = L 9 | } 10 | partition part2 { 11 | size = 1M 12 | partition-type = 0x83 13 | } 14 | partition part3 { 15 | size = 1M 16 | partition-type = 0x83 17 | } 18 | partition part4 { 19 | size = 1M 20 | partition-type = 0x83 21 | } 22 | partition part5 { 23 | size = 1M 24 | /* at most 3 MBR partitions are allowed in hybrid mode */ 25 | partition-type = 0x83 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/hdimage-fail8.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | extended-partition = 1 5 | } 6 | partition part1 { 7 | image = "part1.img" 8 | partition-type = 0x83 9 | forced-primary = "yes" 10 | /* forced-primary can be only used for partitions defined after the extended partition */ 11 | } 12 | partition part2 { 13 | image = "part1.img" 14 | partition-type = 0x83 15 | } 16 | partition part3 { 17 | image = "part1.img" 18 | partition-type = 0x83 19 | } 20 | partition part4 { 21 | image = "part1.img" 22 | partition-type = 0x83 23 | } 24 | partition part5 { 25 | image = "part1.img" 26 | partition-type = 0x83 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/hdimage-fail9.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | } 5 | partition primary1 { 6 | image = "part1.img" 7 | partition-type = 0x83 8 | } 9 | partition primary2 { 10 | image = "part1.img" 11 | partition-type = 0x83 12 | } 13 | partition primary3 { 14 | image = "part1.img" 15 | partition-type = 0x83 16 | } 17 | partition primary4 { 18 | image = "part1.img" 19 | partition-type = 0x83 20 | } 21 | partition primary5 { 22 | image = "part1.img" 23 | partition-type = 0x83 24 | /* part4 is implicitly extended -> too many primary entries */ 25 | forced-primary = "yes" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/hdimage-forced-primary.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | disk-signature = 0x12345678 5 | extended-partition = 2 6 | } 7 | partition part1 { 8 | image = "part1.img" 9 | partition-type = 0xc 10 | bootable = "yes" 11 | } 12 | /* 13 | * partition 2 will be the extended partition entry 14 | * partitions 3-4 will be primary partitions at the end 15 | * partition 5 is first logical partition of the extended partition 16 | */ 17 | partition part5-logical { 18 | image = "part1.img" 19 | partition-type = 0x83 20 | } 21 | partition part6-logical { 22 | image = "part2.img" 23 | partition-type = 0x83 24 | } 25 | partition part7-logical { 26 | image = "part1.img" 27 | partition-type = 0x83 28 | } 29 | partition part8-logical { 30 | image = "part2.img" 31 | partition-type = 0x83 32 | } 33 | partition part9-logical { 34 | image = "part1.img" 35 | partition-type = 0x83 36 | } 37 | partition part3 { 38 | image = "part1.img" 39 | partition-type = 0x83 40 | forced-primary = "yes" 41 | } 42 | partition part4 { 43 | image = "part2.img" 44 | partition-type = 0x82 45 | forced-primary = "yes" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/hdimage-forced-primary.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: 0x12345678 2 | images/test.hdimage1:start=2048,size=2048,type=c,bootable 3 | images/test.hdimage2:start=4096,size=20480,type=f 4 | images/test.hdimage3:start=24576,size=2048,type=83 5 | images/test.hdimage4:start=26624,size=2048,type=82 6 | images/test.hdimage5:start=6144,size=2048,type=83 7 | images/test.hdimage6:start=10240,size=2048,type=83 8 | images/test.hdimage7:start=14336,size=2048,type=83 9 | images/test.hdimage8:start=18432,size=2048,type=83 10 | images/test.hdimage9:start=22528,size=2048,type=83 11 | -------------------------------------------------------------------------------- /test/hdimage-hybrid.config: -------------------------------------------------------------------------------- 1 | image hybrid.hdimage { 2 | hdimage { 3 | partition-table-type = "hybrid" 4 | fill = "true" 5 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 6 | } 7 | partition part1 { 8 | align = 1M 9 | image = "part1.img" 10 | size = 1M 11 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 12 | partition-type = 0x83 13 | } 14 | partition part2 { 15 | image = "part2.img" 16 | size = 1M 17 | partition-type-uuid = "L" 18 | partition-uuid = "41061242-1d5a-4657-892d-fcc1fdb11a6c" 19 | partition-type = 0x83 20 | } 21 | partition part3 { 22 | image = "part1.img" 23 | size = 1M 24 | partition-type-uuid = "S" 25 | partition-uuid = "954532ea-bd86-4992-a1ed-2cdb2c18581a" 26 | partition-type = 0x83 27 | } 28 | partition part4 { 29 | image = "part2.img" 30 | size = 1M 31 | partition-type-uuid = "F" 32 | partition-uuid = "6d04bf47-3ddf-4a75-919b-c7bf46f2ef92" 33 | } 34 | partition part5 { 35 | image = "part1.img" 36 | size = 1M 37 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 38 | } 39 | partition part6 { 40 | image = "part2.img" 41 | size = 1M 42 | partition-uuid = "c9460c06-fbc0-48ae-b4f3-3e897d3ebe71" 43 | } 44 | } 45 | 46 | image mbr.hdimage { 47 | hdimage { 48 | partition-table-type = "mbr" 49 | fill = "true" 50 | } 51 | partition part1 { 52 | align = 1M 53 | image = "part1.img" 54 | size = 1M 55 | partition-type = 0x83 56 | } 57 | partition part2 { 58 | image = "part2.img" 59 | size = 1M 60 | partition-type = 0x83 61 | } 62 | partition part3 { 63 | image = "part1.img" 64 | size = 1M 65 | partition-type = 0x83 66 | } 67 | partition fake-gpt { 68 | /* position of the GPT */ 69 | offset = 1s 70 | /* size of the GPT header + table */ 71 | size = 33s 72 | /* type of the protective enty */ 73 | partition-type = 0xEE 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /test/hdimage-hybrid.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: AFCFEA87-E41A-40E0-85AE-295C60773C7A 2 | images/hybrid.hdimage1:start=2048,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=92762261-E854-45C1-B4C9-FC5E752034AB,name="part1" 3 | images/hybrid.hdimage2:start=4096,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=41061242-1D5A-4657-892D-FCC1FDB11A6C,name="part2" 4 | images/hybrid.hdimage3:start=6144,size=2048,type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F,uuid=954532EA-BD86-4992-A1ED-2CDB2C18581A,name="part3" 5 | images/hybrid.hdimage4:start=8192,size=2048,type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7,uuid=6D04BF47-3DDF-4A75-919B-C7BF46F2EF92,name="part4" 6 | images/hybrid.hdimage5:start=10240,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=92762261-E854-45C1-B4C9-FC5E752034AB,name="part5" 7 | images/hybrid.hdimage6:start=12288,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=C9460C06-FBC0-48AE-B4F3-3E897D3EBE71,name="part6" 8 | -------------------------------------------------------------------------------- /test/hdimage-nopart.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = none 4 | align = 128 5 | fill = true 6 | } 7 | size = 512 8 | partition part1 { 9 | image = "block1.img" 10 | } 11 | partition part2 { 12 | image = "block2.img" 13 | align = 8 14 | } 15 | partition part3 { 16 | image = "block3.img" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/hdimage-nopart.hexdump: -------------------------------------------------------------------------------- 1 | 00000000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 2 | * 3 | 00000060 ff ff ff ff 00 00 00 00 aa aa aa aa aa aa aa aa |................| 4 | 00000070 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa |................| 5 | * 6 | 00000090 aa aa aa aa aa aa aa aa aa aa 00 00 00 00 00 00 |................| 7 | 000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 8 | * 9 | 00000100 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 |wwwwwwwwwwwwwwww| 10 | * 11 | 00000140 77 77 77 77 77 77 77 77 77 77 77 00 00 00 00 00 |wwwwwwwwwww.....| 12 | 00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 13 | * 14 | 00000200 15 | -------------------------------------------------------------------------------- /test/hdimage-sparse.config: -------------------------------------------------------------------------------- 1 | image test.ext4 { 2 | ext4 { 3 | label = "mke2fs" 4 | fs-timestamp = "20000101000000" 5 | use-mke2fs = true 6 | mke2fs-conf = "mke2fs.conf" 7 | extraargs = "-U 12345678-1234-1234-1234-1234567890ab -E quotatype=" 8 | features = "^resize_inode,quota" 9 | } 10 | size = 32M 11 | } 12 | 13 | image test.hdimage { 14 | hdimage { 15 | align = 1M 16 | fill = true 17 | disk-signature = 0x12345678 18 | } 19 | partition part1 { 20 | image = "part1.img" 21 | size = 1M 22 | partition-type = 0x83 23 | } 24 | partition part2 { 25 | image = "test.ext4" 26 | partition-type = 0x83 27 | sparse = false 28 | } 29 | partition part3 { 30 | image = "part1.img" 31 | size = 1M 32 | partition-type = 0x83 33 | } 34 | partition part4 { 35 | image = "part2.img" 36 | size = 1M 37 | partition-type = 0x83 38 | fill = true 39 | sparse = false 40 | } 41 | partition part5 { 42 | image = "part1.img" 43 | size = 1M 44 | partition-type = 0x83 45 | } 46 | partition part6 { 47 | image = "part2.img" 48 | size = 1M 49 | partition-type = 0x83 50 | fill = true 51 | sparse = false 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/hdimage.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | fill = true 5 | disk-signature = 0x12345678 6 | } 7 | partition part1 { 8 | image = "part1.img" 9 | size = 1M 10 | partition-type = 0x83 11 | } 12 | partition part2 { 13 | image = "part3.img" 14 | size = 1M 15 | partition-type = 0x83 16 | } 17 | partition part3 { 18 | image = "part1.img" 19 | size = 1M 20 | partition-type = 0x83 21 | } 22 | partition part4 { 23 | image = "part2.img" 24 | size = 1M 25 | partition-type = 0x83 26 | } 27 | partition part5 { 28 | image = "part1.img" 29 | size = 1M 30 | partition-type = 0x83 31 | } 32 | partition part6 { 33 | image = "part2.img" 34 | size = 1M 35 | partition-type = 0x83 36 | } 37 | } 38 | 39 | image test.hdimage-2 { 40 | hdimage { 41 | align = 1M 42 | disk-signature = 0x12345678 43 | extended-partition = 2 44 | } 45 | partition part1 { 46 | image = "part1.img" 47 | size = 1M 48 | partition-type = 0x83 49 | } 50 | partition part2 { 51 | image = "part2.img" 52 | size = 1M 53 | partition-type = 0x83 54 | } 55 | partition part3 { 56 | image = "part1.img" 57 | size = 1M 58 | partition-type = 0x83 59 | } 60 | partition part4 { 61 | image = "part2.img" 62 | size = 1M 63 | partition-type = 0x83 64 | } 65 | partition part5 { 66 | image = "part1.img" 67 | size = 1M 68 | partition-type = 0x83 69 | } 70 | partition part6 { 71 | image = "part2.img" 72 | autoresize = true 73 | partition-type = 0x83 74 | } 75 | size = 12M 76 | } 77 | -------------------------------------------------------------------------------- /test/hdimage.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: 0x12345678 2 | images/test.hdimage1:start=2048,size=2048,type=83 3 | images/test.hdimage2:start=4096,size=2048,type=83 4 | images/test.hdimage3:start=6144,size=2048,type=83 5 | images/test.hdimage4:start=8192,size=12288,type=f 6 | images/test.hdimage5:start=10240,size=2048,type=83 7 | images/test.hdimage6:start=14336,size=2048,type=83 8 | images/test.hdimage7:start=18432,size=2048,type=83 9 | -------------------------------------------------------------------------------- /test/hdimage.fdisk-2: -------------------------------------------------------------------------------- 1 | Disk identifier: 0x12345678 2 | images/test.hdimage-2p1:start=2048,size=2048,type=83 3 | images/test.hdimage-2p2:start=4096,size=20480,type=f 4 | images/test.hdimage-2p5:start=6144,size=2048,type=83 5 | images/test.hdimage-2p6:start=10240,size=2048,type=83 6 | images/test.hdimage-2p7:start=14336,size=2048,type=83 7 | images/test.hdimage-2p8:start=18432,size=2048,type=83 8 | images/test.hdimage-2p9:start=22528,size=2048,type=83 9 | -------------------------------------------------------------------------------- /test/hdimage.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | test_description="hdimage Image Tests" 3 | 4 | . "$(dirname "${0}")/test-setup.sh" 5 | 6 | get_disk_usage() { 7 | local file="${1}" 8 | if [ ! -f "${file}" ]; then 9 | echo "Failed to check file disk usage: '${file}' does not exist!" 10 | return 1 11 | fi 12 | set -- $(du -B 1 "${file}") 13 | usage="${1}" 14 | } 15 | 16 | check_disk_usage_range() { 17 | local usage 18 | get_disk_usage "${1}" || return 19 | if [ "${usage}" -lt "${2}" -o "${usage}" -gt "${3}" ]; then 20 | echo "Incorrect file disk usage for '${1}': expected min: ${2} max: ${3} found: ${usage}" 21 | return 1 22 | fi 23 | } 24 | 25 | exec_test_set_prereq fdisk 26 | exec_test_set_prereq sfdisk 27 | test_expect_success fdisk,sfdisk "hdimage" " 28 | setup_test_images && 29 | run_genimage hdimage.config test.hdimage && 30 | check_size images/test.hdimage 10485760 && 31 | sfdisk_validate images/test.hdimage && 32 | check_disk_usage_range images/test.hdimage 40960 57344 && 33 | sanitized_fdisk_sfdisk images/test.hdimage > hdimage.fdisk && 34 | test_cmp '${testdir}/hdimage.fdisk' hdimage.fdisk && 35 | check_size images/test.hdimage-2 11539968 && 36 | sfdisk_validate images/test.hdimage-2 && 37 | check_disk_usage_range images/test.hdimage-2 61290 65536 && 38 | sanitized_fdisk_sfdisk images/test.hdimage-2 > hdimage.fdisk-2 && 39 | test_cmp '${testdir}/hdimage.fdisk-2' hdimage.fdisk-2 40 | " 41 | 42 | test_expect_success "hdimage2" " 43 | setup_test_images && 44 | test_must_fail run_genimage hdimage2.config test.hdimage 45 | " 46 | 47 | test_expect_success fdisk-gpt,sfdisk-gpt "hdimage4" " 48 | setup_test_images && 49 | run_genimage hdimage4.config test.hdimage && 50 | check_size images/test.hdimage 7360512 && 51 | sfdisk_validate images/test.hdimage && 52 | sanitized_fdisk_sfdisk images/test.hdimage > hdimage4.fdisk && 53 | test_cmp '${testdir}/hdimage4.fdisk' hdimage4.fdisk 54 | " 55 | 56 | test_expect_success fdisk-gpt,sfdisk-gpt "hdimage5" " 57 | setup_test_images && 58 | run_genimage hdimage5.config test.hdimage && 59 | check_size images/test.hdimage 7360512 && 60 | sanitized_fdisk_sfdisk images/test.hdimage > hdimage5.fdisk && 61 | test_cmp '${testdir}/hdimage5.fdisk' hdimage5.fdisk 62 | " 63 | 64 | test_expect_success fdisk,sfdisk "hdimage6" " 65 | setup_test_images && 66 | run_genimage hdimage6.config test.hdimage && 67 | check_size images/test.hdimage 28082176 && 68 | sanitized_fdisk_sfdisk images/test.hdimage > hdimage6.fdisk && 69 | test_cmp '${testdir}/hdimage6.fdisk' hdimage6.fdisk 70 | " 71 | 72 | test_expect_success fdisk-gpt,sfdisk-gpt "hdimage7" " 73 | setup_test_images && 74 | run_genimage hdimage7.config && 75 | sfdisk_validate images/test.hdimage && 76 | sanitized_fdisk_sfdisk images/test.hdimage > hdimage7.fdisk && 77 | test_cmp '${testdir}/hdimage7.fdisk' hdimage7.fdisk 78 | " 79 | 80 | exec_test_set_prereq hexdump 81 | test_expect_success fdisk-gpt,sfdisk-gpt,hexdump "hdimage-hybrid" " 82 | setup_test_images && 83 | run_genimage hdimage-hybrid.config && 84 | sfdisk_validate images/hybrid.hdimage && 85 | sanitized_fdisk_sfdisk images/hybrid.hdimage > hdimage-hybrid.fdisk && 86 | test_cmp '${testdir}/hdimage-hybrid.fdisk' hdimage-hybrid.fdisk && 87 | dd if=images/hybrid.hdimage count=1 | hexdump -C > hybrid.sector0 && 88 | dd if=images/mbr.hdimage count=1 | hexdump -C > mbr.sector0 && 89 | test_cmp hybrid.sector0 mbr.sector0 90 | " 91 | 92 | test_expect_success "hdimage syntax" " 93 | setup_test_images && 94 | test_must_fail run_genimage hdimage-fail1.config && 95 | test_must_fail run_genimage hdimage-fail2.config && 96 | test_must_fail run_genimage hdimage-fail3.config && 97 | test_must_fail run_genimage hdimage-fail4.config && 98 | test_must_fail run_genimage hdimage-fail5.config && 99 | test_must_fail run_genimage hdimage-fail6.config && 100 | test_must_fail run_genimage hdimage-fail7.config && 101 | test_must_fail run_genimage hdimage-fail8.config && 102 | test_must_fail run_genimage hdimage-fail9.config && 103 | test_must_fail run_genimage hdimage-fail10.config && 104 | test_must_fail run_genimage hdimage-fail11.config 105 | " 106 | 107 | setup_gpt_files() { 108 | rm -rf input && 109 | mkdir input && 110 | truncate -s 3k input/3K.img && 111 | truncate -s 70k input/70K.img 112 | } 113 | 114 | test_expect_success "gpt-overlap1" " 115 | setup_gpt_files && 116 | test_must_fail run_genimage gpt-overlap1.config" 117 | 118 | test_expect_success "gpt-overlap2" " 119 | setup_gpt_files && 120 | run_genimage gpt-overlap2.config" 121 | 122 | test_expect_success "gpt-overlap3" " 123 | setup_gpt_files && 124 | test_must_fail run_genimage gpt-overlap3.config" 125 | 126 | test_expect_success fdisk,sfdisk "gpt-partition-types" " 127 | run_genimage gpt-partition-types.config && 128 | sfdisk_validate images/gpt-partition-types.img && 129 | sanitized_fdisk_sfdisk images/gpt-partition-types.img > gpt-partition-types.fdisk && 130 | test_cmp '${testdir}/gpt-partition-types.fdisk' gpt-partition-types.fdisk" 131 | 132 | test_expect_success "gpt-invalid-partition-types" " 133 | test_must_fail run_genimage gpt-invalid-partition-type1.config && 134 | test_must_fail run_genimage gpt-invalid-partition-type2.config" 135 | 136 | # A bootloader image with a don't-care region extending over MBR 137 | # table, GPT header and (usual) placement of GPT array. 138 | test_expect_success "bootloader-hole1" " 139 | setup_gpt_files && 140 | run_genimage hole.config" 141 | 142 | # Oops, if we move the GPT array we're no longer covered by the hole. 143 | test_expect_success "bootloader-hole2" " 144 | setup_gpt_files && 145 | GPT_LOCATION=64K test_must_fail run_genimage hole.config" 146 | 147 | # But it's ok if the array is moved beyond the bootloader. 148 | test_expect_success "bootloader-hole3" " 149 | setup_gpt_files && 150 | GPT_LOCATION=70K run_genimage hole.config" 151 | 152 | # If the 70K bootloader starts at 64K, it will overlap a partition at 129K. 153 | test_expect_success "bootloader-hole4" " 154 | setup_gpt_files && 155 | OFFSET=64K test_must_fail run_genimage hole.config" 156 | 157 | # But if it starts at 128K, its hole will cover the small 3K partition. 158 | test_expect_success "bootloader-hole5" " 159 | setup_gpt_files && 160 | OFFSET=128K run_genimage hole.config" 161 | 162 | test_expect_success hexdump "hdimage no-partition" " 163 | dd if=/dev/zero bs=1 count=100 | tr '\000' '\377' > input/block1.img && 164 | dd if=/dev/zero bs=1 count=50 | tr '\000' '\252' > input/block2.img && 165 | dd if=/dev/zero bs=1 count=75 | tr '\000' '\167' > input/block3.img && 166 | run_genimage hdimage-nopart.config && 167 | hexdump -C images/test.hdimage > 'hdimage-nopart.hexdump' && 168 | test_cmp 'hdimage-nopart.hexdump' '${testdir}/hdimage-nopart.hexdump' 169 | " 170 | 171 | test_expect_success sfdisk "hdimage forced-primary" " 172 | setup_test_images && 173 | run_genimage hdimage-forced-primary.config && 174 | sfdisk_validate images/test.hdimage && 175 | sanitized_fdisk_sfdisk images/test.hdimage > hdimage.fdisk && 176 | test_cmp '${testdir}/hdimage-forced-primary.fdisk' hdimage.fdisk 177 | " 178 | 179 | test_expect_success fdisk,sfdisk,mke2fs "hdimage sparse" " 180 | setup_test_images && 181 | run_genimage_root hdimage-sparse.config test.hdimage && 182 | check_size images/test.hdimage 42991616 && 183 | sfdisk_validate images/test.hdimage && 184 | check_disk_usage_range images/test.hdimage 34000000 37000000 185 | " 186 | 187 | test_done 188 | 189 | # vim: syntax=sh 190 | -------------------------------------------------------------------------------- /test/hdimage2.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | disk-signature = 0x12345678 5 | } 6 | partition part1 { 7 | image = "part2.img" 8 | size = 5k 9 | partition-type = 0x83 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/hdimage4.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | partition-table-type = "gpt" 5 | fill = "true" 6 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 7 | } 8 | partition part1 { 9 | image = "part1.img" 10 | size = 1M 11 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 12 | } 13 | partition part2 { 14 | image = "part2.img" 15 | size = 1M 16 | partition-type-uuid = "L" 17 | partition-uuid = "41061242-1d5a-4657-892d-fcc1fdb11a6c" 18 | } 19 | partition part3 { 20 | image = "part1.img" 21 | size = 1M 22 | partition-type-uuid = "S" 23 | partition-uuid = "954532ea-bd86-4992-a1ed-2cdb2c18581a" 24 | } 25 | partition part4 { 26 | image = "part2.img" 27 | size = 1M 28 | partition-type-uuid = "F" 29 | partition-uuid = "6d04bf47-3ddf-4a75-919b-c7bf46f2ef92" 30 | } 31 | partition part5 { 32 | image = "part1.img" 33 | size = 1M 34 | partition-type-uuid = "forty-two" 35 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 36 | } 37 | partition part6 { 38 | image = "part2.img" 39 | size = 1M 40 | partition-uuid = "c9460c06-fbc0-48ae-b4f3-3e897d3ebe71" 41 | } 42 | } 43 | 44 | config { 45 | gpt-shortcuts { 46 | forty-two = "2a422a42-2a42-2a42-2a42-2a422a422a42" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/hdimage4.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: AFCFEA87-E41A-40E0-85AE-295C60773C7A 2 | images/test.hdimage1:start=2048,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=92762261-E854-45C1-B4C9-FC5E752034AB,name="part1" 3 | images/test.hdimage2:start=4096,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=41061242-1D5A-4657-892D-FCC1FDB11A6C,name="part2" 4 | images/test.hdimage3:start=6144,size=2048,type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F,uuid=954532EA-BD86-4992-A1ED-2CDB2C18581A,name="part3" 5 | images/test.hdimage4:start=8192,size=2048,type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7,uuid=6D04BF47-3DDF-4A75-919B-C7BF46F2EF92,name="part4" 6 | images/test.hdimage5:start=10240,size=2048,type=2A422A42-2A42-2A42-2A42-2A422A422A42,uuid=92762261-E854-45C1-B4C9-FC5E752034AB,name="part5" 7 | images/test.hdimage6:start=12288,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=C9460C06-FBC0-48AE-B4F3-3E897D3EBE71,name="part6" 8 | -------------------------------------------------------------------------------- /test/hdimage5.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | partition-table-type = "gpt" 5 | gpt-no-backup = "true" 6 | fill = "true" 7 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 8 | } 9 | partition part1 { 10 | image = "part1.img" 11 | size = 1M 12 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 13 | } 14 | partition part2 { 15 | image = "part2.img" 16 | size = 1M 17 | partition-type-uuid = "L" 18 | partition-uuid = "41061242-1d5a-4657-892d-fcc1fdb11a6c" 19 | } 20 | partition part3 { 21 | image = "part1.img" 22 | size = 1M 23 | partition-type-uuid = "S" 24 | partition-uuid = "954532ea-bd86-4992-a1ed-2cdb2c18581a" 25 | } 26 | partition part4 { 27 | image = "part2.img" 28 | size = 1M 29 | partition-type-uuid = "F" 30 | partition-uuid = "6d04bf47-3ddf-4a75-919b-c7bf46f2ef92" 31 | } 32 | partition part5 { 33 | image = "part1.img" 34 | size = 1M 35 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 36 | } 37 | partition part6 { 38 | image = "part2.img" 39 | size = 1M 40 | partition-uuid = "c9460c06-fbc0-48ae-b4f3-3e897d3ebe71" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/hdimage5.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: AFCFEA87-E41A-40E0-85AE-295C60773C7A 2 | images/test.hdimage1:start=2048,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=92762261-E854-45C1-B4C9-FC5E752034AB,name="part1" 3 | images/test.hdimage2:start=4096,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=41061242-1D5A-4657-892D-FCC1FDB11A6C,name="part2" 4 | images/test.hdimage3:start=6144,size=2048,type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F,uuid=954532EA-BD86-4992-A1ED-2CDB2C18581A,name="part3" 5 | images/test.hdimage4:start=8192,size=2048,type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7,uuid=6D04BF47-3DDF-4A75-919B-C7BF46F2EF92,name="part4" 6 | images/test.hdimage5:start=10240,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=92762261-E854-45C1-B4C9-FC5E752034AB,name="part5" 7 | images/test.hdimage6:start=12288,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=C9460C06-FBC0-48AE-B4F3-3E897D3EBE71,name="part6" 8 | -------------------------------------------------------------------------------- /test/hdimage6.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | extended-partition = 3 4 | } 5 | partition part1 { 6 | offset = 128K 7 | size = 256K 8 | partition-type = 0x83 9 | } 10 | partition part2 { 11 | size = 3072K 12 | partition-type = 0x83 13 | } 14 | partition part3 { 15 | offset = 3686400 16 | size = 8126464 17 | partition-type = 0x83 18 | } 19 | partition part4 { 20 | offset = 11821056 21 | size = 16252928 22 | partition-type = 0x83 23 | } 24 | partition part5 { 25 | offset = 28082176 26 | size = 16252928 27 | partition-type = 0x83 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/hdimage6.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: 0x00000000 2 | images/test.hdimage1:start=256,size=512,type=83 3 | images/test.hdimage2:start=768,size=6144,type=83 4 | images/test.hdimage3:start=7199,size=79393,type=f 5 | images/test.hdimage5:start=7200,size=15872,type=83 6 | images/test.hdimage6:start=23088,size=31744,type=83 7 | images/test.hdimage7:start=54848,size=31744,type=83 8 | -------------------------------------------------------------------------------- /test/hdimage7.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | gpt-location = 768K 5 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 6 | } 7 | partition rescue { 8 | image = "part1.img" 9 | offset = 2M 10 | size = 1M 11 | partition-uuid = "9f60b7f0-f4c8-42d4-8469-be6c19904994" 12 | } 13 | partition rootfs-A { 14 | image = "part2.img" 15 | align = 2M 16 | size = 8M 17 | partition-type-uuid = "L" 18 | partition-uuid = "0cfa71d4-3388-4f08-8fa0-f66e46ec5a0e" 19 | } 20 | partition rootfs-B { 21 | image = "part2.img" 22 | align = 2M 23 | size = 8M 24 | partition-type-uuid = "L" 25 | partition-uuid = "b9cc42b2-d030-4eca-9922-5f88e32c94bc" 26 | } 27 | partition reserved { 28 | image = "part1.img" 29 | size = 128K 30 | partition-uuid = "cb597eaf-5662-44d9-8127-dc5e8c1b830d" 31 | } 32 | partition sys { 33 | image = "part1.img" 34 | size = 4M 35 | partition-type-uuid = "L" 36 | partition-uuid = "c9d69b9a-a561-42ef-88df-2ba25328e6ef" 37 | } 38 | partition data { 39 | image = "part1.img" 40 | size = 4M 41 | partition-uuid = "b7104ed8-6ac9-4f80-96e2-9d57ff5f3453" 42 | } 43 | 44 | partition bootloader { 45 | image = "part2.img" 46 | size = 1M 47 | offset = 1M 48 | partition-uuid = "de9980f1-0449-4e83-84bd-98e4b1ca3fe3" 49 | } 50 | partition env-1 { 51 | image = "part1.img" 52 | offset = 800K 53 | size = 16K 54 | partition-uuid = "eb3b107b-ae9d-4c6b-994a-ec412d36959b" 55 | } 56 | partition env-2 { 57 | image = "part1.img" 58 | offset = 832K 59 | size = 16K 60 | partition-uuid = "6e7c8caa-c119-43b9-8031-fcdfa34c3fae" 61 | } 62 | partition ucode { 63 | image = "part1.img" 64 | offset = 960K 65 | size = 64K 66 | partition-uuid = "b1a7539f-8e86-4a31-94c6-090c08f5a3d3" 67 | } 68 | 69 | partition SPL { 70 | image = "part1.img" 71 | in-partition-table = false 72 | offset = 1K 73 | size = 512K 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /test/hdimage7.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: AFCFEA87-E41A-40E0-85AE-295C60773C7A 2 | images/test.hdimage1:start=4096,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=9F60B7F0-F4C8-42D4-8469-BE6C19904994,name="rescue" 3 | images/test.hdimage2:start=8192,size=16384,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=0CFA71D4-3388-4F08-8FA0-F66E46EC5A0E,name="rootfs-A" 4 | images/test.hdimage3:start=24576,size=16384,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=B9CC42B2-D030-4ECA-9922-5F88E32C94BC,name="rootfs-B" 5 | images/test.hdimage4:start=40960,size=256,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=CB597EAF-5662-44D9-8127-DC5E8C1B830D,name="reserved" 6 | images/test.hdimage5:start=41216,size=8192,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=C9D69B9A-A561-42EF-88DF-2BA25328E6EF,name="sys" 7 | images/test.hdimage6:start=49408,size=8192,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=B7104ED8-6AC9-4F80-96E2-9D57FF5F3453,name="data" 8 | images/test.hdimage7:start=2048,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=DE9980F1-0449-4E83-84BD-98E4B1CA3FE3,name="bootloader" 9 | images/test.hdimage8:start=1600,size=32,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=EB3B107B-AE9D-4C6B-994A-EC412D36959B,name="env-1" 10 | images/test.hdimage9:start=1664,size=32,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=6E7C8CAA-C119-43B9-8031-FCDFA34C3FAE,name="env-2" 11 | images/test.hdimage10:start=1920,size=128,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=B1A7539F-8E86-4A31-94C6-090C08F5A3D3,name="ucode" 12 | -------------------------------------------------------------------------------- /test/hole.config: -------------------------------------------------------------------------------- 1 | image test.hole { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | gpt-location = ${GPT_LOCATION:-1K} 5 | } 6 | 7 | partition bootloader { 8 | in-partition-table = false 9 | offset = ${OFFSET:-0} 10 | image = "70K.img" 11 | } 12 | 13 | partition foo { 14 | offset = 129K 15 | image = "3K.img" 16 | } 17 | } 18 | 19 | image 70K.img { 20 | file { 21 | holes = "(440; 33K)" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/include-aaa.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: 6A921DBB-823D-44C4-8EDC-ECB038E6D743 2 | images/include.hdimage1:start=34,size=2048,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=59DA602D-C2EA-4F18-818F-CF7947BAD0CA,name="aaa" 3 | -------------------------------------------------------------------------------- /test/include-bbb.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: 6A921DBB-823D-44C4-8EDC-ECB038E6D743 2 | images/include.hdimage1:start=34,size=4096,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=284635E9-6B62-41CA-A02A-357C01517279,name="bbb" 3 | -------------------------------------------------------------------------------- /test/include-ccc.fdisk: -------------------------------------------------------------------------------- 1 | Disk identifier: 6A921DBB-823D-44C4-8EDC-ECB038E6D743 2 | images/include.hdimage1:start=34,size=6144,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,uuid=088813B5-7028-4540-99DA-B10015FD07DA,name="ccc" 3 | -------------------------------------------------------------------------------- /test/include-test.config: -------------------------------------------------------------------------------- 1 | partition ccc { 2 | size = 3M 3 | partition-type-uuid = "L" 4 | partition-uuid = "088813b5-7028-4540-99da-b10015fd07da" 5 | } 6 | -------------------------------------------------------------------------------- /test/include.config: -------------------------------------------------------------------------------- 1 | image include.hdimage { 2 | hdimage { 3 | partition-table-type = "gpt" 4 | disk-uuid = "6a921dbb-823d-44c4-8edc-ecb038e6d743" 5 | } 6 | include("include-test.config") 7 | } 8 | -------------------------------------------------------------------------------- /test/include/aaa/include-test.config: -------------------------------------------------------------------------------- 1 | partition aaa { 2 | size = 1M 3 | partition-type-uuid = "L" 4 | partition-uuid = "59da602d-c2ea-4f18-818f-cf7947bad0ca" 5 | } 6 | -------------------------------------------------------------------------------- /test/include/bbb/include-test.config: -------------------------------------------------------------------------------- 1 | partition bbb { 2 | size = 2M 3 | partition-type-uuid = "L" 4 | partition-uuid = "284635e9-6b62-41ca-a02a-357c01517279" 5 | } 6 | -------------------------------------------------------------------------------- /test/iso.config: -------------------------------------------------------------------------------- 1 | image test.iso { 2 | iso { 3 | volume-id = "iso-test" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/jffs2.config: -------------------------------------------------------------------------------- 1 | include("flash-types.config") 2 | 3 | image test.jffs2 { 4 | jffs2 { 5 | } 6 | flashtype = "nor-64M-128k" 7 | size = 4M 8 | } 9 | -------------------------------------------------------------------------------- /test/jffs2.md5: -------------------------------------------------------------------------------- 1 | 4c37f72de7a902286f0cfcbf13b4fde8 images/test.jffs2 2 | -------------------------------------------------------------------------------- /test/mdraid.config: -------------------------------------------------------------------------------- 1 | image test.mdraid-a { 2 | mdraid { 3 | level = 1 4 | devices = 2 5 | timestamp = 638022222 6 | raid-uuid = "de9980f1-0449-4e83-84bd-98e4b1ca3fe3" 7 | disk-uuid = "eb3b107b-ae9d-4c6b-994a-ec412d36959b" 8 | } 9 | size = 5M 10 | } 11 | 12 | image test.mdraid-b { 13 | mdraid { 14 | parent = "test.mdraid-a" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/misc.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | test_description="Misc Image Tests" 3 | 4 | . "$(dirname "${0}")/test-setup.sh" 5 | 6 | exec_test_set_prereq dd 7 | exec_test_set_prereq diff 8 | exec_test_set_prereq qemu-img 9 | test_expect_success dd,diff,qemu-img "qemu" " 10 | setup_test_images && 11 | run_genimage qemu.config test.qcow && 12 | qemu-img check images/test.qcow && 13 | zcat '${testdir}/qemu.qcow.gz' > qemu.qcow && 14 | qemu-img compare images/test.qcow qemu.qcow 15 | " 16 | 17 | setup_fit_its() { 18 | setup_test_images && 19 | cp ${testdir}/fit.its input/ 20 | } 21 | 22 | exec_test_set_prereq mkimage 23 | exec_test_set_prereq dtc 24 | test_expect_success mkimage,dtc "fit" " 25 | setup_fit_its && 26 | run_genimage fit.config test.fit 27 | " 28 | 29 | setup_rauc() { 30 | rm -rf input && 31 | mkdir input && 32 | cp -r "${testdir}"/rauc-openssl-ca input/ && 33 | echo "test" > input/rauc.content && 34 | echo "xtest2" > input/rauc2.content 35 | } 36 | 37 | version_lt() { 38 | first="$(printf "${1}\n${2}" | sort -V | head -n1)" 39 | test "${first}" == "${1}" && test "${1}" != "${2}" 40 | } 41 | 42 | rauc_cmp() { 43 | if version_lt "${rauc_version}" "1.6"; then 44 | test_cmp "${testdir}/${1}.raucb.info.1" "${1}.raucb.info" 45 | elif version_lt "${rauc_version}" "1.9"; then 46 | test_cmp "${testdir}/${1}.raucb.info.2" "${1}.raucb.info" 47 | elif version_lt "${rauc_version}" "1.10"; then 48 | test_cmp "${testdir}/${1}.raucb.info.3" "${1}.raucb.info" 49 | else 50 | test_cmp "${testdir}/${1}.raucb.info.4" "${1}.raucb.info" 51 | fi 52 | } 53 | 54 | exec_test_set_prereq rauc 55 | test_expect_success rauc "rauc" " 56 | rauc_version="$(rauc --version | sed 's/rauc //')" 57 | setup_rauc && 58 | run_genimage rauc.config test.raucb && 59 | rauc info \ 60 | --keyring input/rauc-openssl-ca/ca.cert.pem \ 61 | --cert input/rauc-openssl-ca/ca.cert.pem \ 62 | images/test.raucb | grep -v cms_get_enveloped_type \ 63 | | sed -e 's;O = Test Org, CN = ;/O=Test Org/CN=;' \ 64 | -e '/Bundle Format:[ \t]*plain$/d' \ 65 | > test.raucb.info && 66 | rauc_cmp test 67 | rauc info \ 68 | --keyring input/rauc-openssl-ca/ca.cert.pem \ 69 | --cert input/rauc-openssl-ca/ca.cert.pem \ 70 | images/test2.raucb | grep -v cms_get_enveloped_type \ 71 | | sed -e 's;O = Test Org, CN = ;/O=Test Org/CN=;' \ 72 | -e '/Bundle Format:[ \t]*plain$/d' \ 73 | > test2.raucb.info && 74 | rauc_cmp test2 75 | " 76 | 77 | exec_test_set_prereq simg2img 78 | test_expect_success simg2img "android-sparse" " 79 | setup_test_images && 80 | # make sure there is a 4*32k hole at the end 81 | i=16 82 | truncate --size=\$[i*(i+1)*i*i*512+32768*4] input/interleaved 83 | for i in \`seq 16\`; do 84 | dd if=/dev/urandom of=input/interleaved conv=notrunc seek=\$[i*i] count=\$[i] bs=\$[i*i*512] || break 85 | done && 86 | dd if=/dev/urandom of=input/not-aligned count=9 bs=1024 87 | run_genimage sparse.config && 88 | # simg2img will expand the partial block 89 | truncate --size=12k input/not-aligned 90 | md5sum images/test.hdimage input/interleaved input/not-aligned > md5sum && 91 | rm images/test.hdimage input/interleaved input/not-aligned && 92 | check_size_range images/interleaved.sparse 9732408 9732580 && 93 | simg2img images/test.sparse images/test.hdimage && 94 | simg2img images/interleaved.sparse input/interleaved && 95 | simg2img images/not-aligned.sparse input/not-aligned && 96 | md5sum -c md5sum && 97 | 98 | run_genimage sparse-fill.config && 99 | # simg2img will expand the partial block 100 | truncate --size=12k input/not-aligned 101 | md5sum images/test.hdimage input/interleaved input/not-aligned > md5sum && 102 | rm images/test.hdimage input/interleaved input/not-aligned && 103 | check_size_range images/interleaved.sparse 9732408 9732580 && 104 | simg2img images/test.sparse images/test.hdimage && 105 | simg2img images/interleaved.sparse input/interleaved && 106 | simg2img images/not-aligned.sparse input/not-aligned && 107 | md5sum -c md5sum 108 | " 109 | 110 | exec_test_set_prereq fiptool 111 | test_expect_success fiptool "fip" " 112 | setup_test_images && 113 | run_genimage fip.config test.fip && 114 | check_size_range images/test.fip 12804 13056 && 115 | fiptool info images/test.fip 116 | " 117 | 118 | test_expect_success fiptool "fip-size" " 119 | setup_test_images && 120 | test_must_fail run_genimage fip-size.config test.fip 121 | " 122 | 123 | exec_test_set_prereq mdadm 124 | test_expect_success mdadm "mdraid" " 125 | run_genimage_root mdraid.config test.mdraid-a && 126 | LANG=C mdadm --examine images/test.mdraid-a | tee images/test.mdraid-a.txt && 127 | LANG=C mdadm --examine images/test.mdraid-b | tee images/test.mdraid-b.txt && 128 | grep 'Checksum.*correct$' images/test.mdraid-a.txt && 129 | grep 'State.*active$' images/test.mdraid-a.txt && 130 | grep 'Internal Bitmap.*sectors' images/test.mdraid-a.txt && 131 | grep 'Bad Block Log.*entries available' images/test.mdraid-a.txt && 132 | grep -Ev '(Device UUID|Checksum|Device Role) :' images/test.mdraid-a.txt | tail -n +2 > images/test.mdraid-a.arr.txt && 133 | grep -Ev '(Device UUID|Checksum|Device Role) :' images/test.mdraid-b.txt | tail -n +2 > images/test.mdraid-b.arr.txt && 134 | diff images/test.mdraid-a.arr.txt images/test.mdraid-b.arr.txt 135 | " 136 | 137 | test_done 138 | 139 | # vim: syntax=sh 140 | -------------------------------------------------------------------------------- /test/mke2fs.0.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: mke2fs 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal ext_attr dir_index filetype extent 64bit flex_bg sparse_super dir_nlink extra_isize quota metadata_csum 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: user_xattr acl 8 | Filesystem state: clean 9 | Errors behavior: Continue 10 | Filesystem OS type: Linux 11 | Inode count: 8192 12 | Block count: 32768 13 | Reserved block count: 1638 14 | Free blocks: 26580 15 | Free inodes: 8141 16 | First block: 1 17 | Block size: 1024 18 | Fragment size: 1024 19 | Group descriptor size: 64 20 | Blocks per group: 8192 21 | Fragments per group: 8192 22 | Inodes per group: 2048 23 | Inode blocks per group: 512 24 | Flex block group size: 16 25 | Filesystem created: Sat Jan 1 00:00:00 2000 26 | Last mount time: n/a 27 | Last write time: Sat Jan 1 00:00:00 2000 28 | Mount count: 0 29 | Maximum mount count: -1 30 | Last checked: Sat Jan 1 00:00:00 2000 31 | Check interval: 0 () 32 | Lifetime writes: 107 kB 33 | Reserved blocks uid: 0 (user root) 34 | Reserved blocks gid: 0 (group root) 35 | First inode: 11 36 | Inode size: 256 37 | Required extra isize: 32 38 | Desired extra isize: 32 39 | Journal inode: 8 40 | Default directory hash: half_md4 41 | Journal backup: inode blocks 42 | Checksum type: crc32c 43 | Journal features: (none) 44 | Journal size: 4096k 45 | Journal length: 4096 46 | Journal sequence: 0x00000001 47 | Journal start: 0 48 | 49 | 50 | Group 0: (Blocks 1-8192) csum 0xd0bb [ITABLE_ZEROED] 51 | Primary superblock at 1, Group descriptors at 2-2 52 | Block bitmap at 3 (+2), csum 0xde29f1cb 53 | Inode bitmap at 7 (+6), csum 0xb1052088 54 | Inode table at 11-522 (+10) 55 | 6105 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes 56 | Free blocks: 2088-8192 57 | Free inodes: 52-2048 58 | Group 1: (Blocks 8193-16384) csum 0x8fde [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED] 59 | Backup superblock at 8193, Group descriptors at 8194-8194 60 | Block bitmap at 4 (bg #0 + 3), csum 0x00000000 61 | Inode bitmap at 8 (bg #0 + 7), csum 0x00000000 62 | Inode table at 523-1034 (bg #0 + 522) 63 | 8190 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 64 | Free blocks: 8195-16384 65 | Free inodes: 2049-4096 66 | Group 2: (Blocks 16385-24576) csum 0x720f [INODE_UNINIT, ITABLE_ZEROED] 67 | Block bitmap at 5 (bg #0 + 4), csum 0x040008b2 68 | Inode bitmap at 9 (bg #0 + 8), csum 0x00000000 69 | Inode table at 1035-1546 (bg #0 + 1034) 70 | 4096 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 71 | Free blocks: 20481-24576 72 | Free inodes: 4097-6144 73 | Group 3: (Blocks 24577-32767) csum 0xd0be [INODE_UNINIT, ITABLE_ZEROED] 74 | Backup superblock at 24577, Group descriptors at 24578-24578 75 | Block bitmap at 6 (bg #0 + 5), csum 0x4327ef1c 76 | Inode bitmap at 10 (bg #0 + 9), csum 0x00000000 77 | Inode table at 1547-2058 (bg #0 + 1546) 78 | 8189 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 79 | Free blocks: 24579-32767 80 | Free inodes: 6145-8192 81 | -------------------------------------------------------------------------------- /test/mke2fs.1.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: mke2fs 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal ext_attr dir_index filetype extent 64bit flex_bg sparse_super dir_nlink extra_isize quota metadata_csum 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: user_xattr acl 8 | Filesystem state: clean 9 | Errors behavior: Continue 10 | Filesystem OS type: Linux 11 | Inode count: 8192 12 | Block count: 32768 13 | Reserved block count: 1638 14 | Overhead clusters: 6159 15 | Free blocks: 26580 16 | Free inodes: 8141 17 | First block: 1 18 | Block size: 1024 19 | Fragment size: 1024 20 | Group descriptor size: 64 21 | Blocks per group: 8192 22 | Fragments per group: 8192 23 | Inodes per group: 2048 24 | Inode blocks per group: 512 25 | Flex block group size: 16 26 | Filesystem created: Sat Jan 1 00:00:00 2000 27 | Last mount time: n/a 28 | Last write time: Sat Jan 1 00:00:00 2000 29 | Mount count: 0 30 | Maximum mount count: -1 31 | Last checked: Sat Jan 1 00:00:00 2000 32 | Check interval: 0 () 33 | Lifetime writes: 107 kB 34 | Reserved blocks uid: 0 (user root) 35 | Reserved blocks gid: 0 (group root) 36 | First inode: 11 37 | Inode size: 256 38 | Required extra isize: 32 39 | Desired extra isize: 32 40 | Journal inode: 8 41 | Default directory hash: half_md4 42 | Journal backup: inode blocks 43 | Checksum type: crc32c 44 | Journal features: (none) 45 | Total journal size: 4096k 46 | Total journal blocks: 4096 47 | Max transaction length: 4096 48 | Fast commit length: 0 49 | Journal sequence: 0x00000001 50 | Journal start: 0 51 | 52 | 53 | Group 0: (Blocks 1-8192) csum 0xd0bb [ITABLE_ZEROED] 54 | Primary superblock at 1, Group descriptors at 2-2 55 | Block bitmap at 3 (+2), csum 0xde29f1cb 56 | Inode bitmap at 7 (+6), csum 0xb1052088 57 | Inode table at 11-522 (+10) 58 | 6105 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes 59 | Free blocks: 2088-8192 60 | Free inodes: 52-2048 61 | Group 1: (Blocks 8193-16384) csum 0x8fde [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED] 62 | Backup superblock at 8193, Group descriptors at 8194-8194 63 | Block bitmap at 4 (bg #0 + 3), csum 0x00000000 64 | Inode bitmap at 8 (bg #0 + 7), csum 0x00000000 65 | Inode table at 523-1034 (bg #0 + 522) 66 | 8190 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 67 | Free blocks: 8195-16384 68 | Free inodes: 2049-4096 69 | Group 2: (Blocks 16385-24576) csum 0x720f [INODE_UNINIT, ITABLE_ZEROED] 70 | Block bitmap at 5 (bg #0 + 4), csum 0x040008b2 71 | Inode bitmap at 9 (bg #0 + 8), csum 0x00000000 72 | Inode table at 1035-1546 (bg #0 + 1034) 73 | 4096 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 74 | Free blocks: 20481-24576 75 | Free inodes: 4097-6144 76 | Group 3: (Blocks 24577-32767) csum 0xd0be [INODE_UNINIT, ITABLE_ZEROED] 77 | Backup superblock at 24577, Group descriptors at 24578-24578 78 | Block bitmap at 6 (bg #0 + 5), csum 0x4327ef1c 79 | Inode bitmap at 10 (bg #0 + 9), csum 0x00000000 80 | Inode table at 1547-2058 (bg #0 + 1546) 81 | 8189 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 82 | Free blocks: 24579-32767 83 | Free inodes: 6145-8192 84 | -------------------------------------------------------------------------------- /test/mke2fs.2.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: mke2fs 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal ext_attr dir_index filetype extent 64bit flex_bg sparse_super dir_nlink extra_isize quota metadata_csum 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: user_xattr acl 8 | Filesystem state: clean 9 | Errors behavior: Continue 10 | Filesystem OS type: Linux 11 | Inode count: 8192 12 | Block count: 32768 13 | Reserved block count: 1638 14 | Overhead clusters: 6159 15 | Free blocks: 26580 16 | Free inodes: 8141 17 | First block: 1 18 | Block size: 1024 19 | Fragment size: 1024 20 | Group descriptor size: 64 21 | Blocks per group: 8192 22 | Fragments per group: 8192 23 | Inodes per group: 2048 24 | Inode blocks per group: 512 25 | Flex block group size: 16 26 | Filesystem created: Sat Jan 1 00:00:00 2000 27 | Last mount time: n/a 28 | Last write time: Sat Jan 1 00:00:00 2000 29 | Mount count: 0 30 | Maximum mount count: -1 31 | Last checked: Sat Jan 1 00:00:00 2000 32 | Check interval: 0 () 33 | Lifetime writes: 107 kB 34 | Reserved blocks uid: 0 (user root) 35 | Reserved blocks gid: 0 (group root) 36 | First inode: 11 37 | Inode size: 256 38 | Required extra isize: 32 39 | Desired extra isize: 32 40 | Journal inode: 8 41 | Default directory hash: half_md4 42 | Journal backup: inode blocks 43 | Checksum type: crc32c 44 | Journal features: (none) 45 | Total journal size: 4096k 46 | Total journal blocks: 4096 47 | Max transaction length: 4096 48 | Fast commit length: 0 49 | Journal sequence: 0x00000001 50 | Journal start: 0 51 | 52 | 53 | Group 0: (Blocks 1-8192) csum 0xd0bb [ITABLE_ZEROED] 54 | Primary superblock at 1, Group descriptors at 2-2 55 | Block bitmap at 3 (+2), csum 0xde29f1cb 56 | Inode bitmap at 7 (+6), csum 0xb1052088 57 | Inode table at 11-522 (+10) 58 | 6105 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes 59 | Free blocks: 2088-8192 60 | Free inodes: 52-2048 61 | Group 1: (Blocks 8193-16384) csum 0x8fde [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED] 62 | Backup superblock at 8193, Group descriptors at 8194-8194 63 | Block bitmap at 4 (bg #0 + 3), csum 0x00000000 64 | Inode bitmap at 8 (bg #0 + 7), csum 0x00000000 65 | Inode table at 523-1034 (bg #0 + 522) 66 | 8190 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 67 | Free blocks: 8195-16384 68 | Free inodes: 2049-4096 69 | Group 2: (Blocks 16385-24576) csum 0x720f [INODE_UNINIT, ITABLE_ZEROED] 70 | Block bitmap at 5 (bg #0 + 4), csum 0x040008b2 71 | Inode bitmap at 9 (bg #0 + 8), csum 0x00000000 72 | Inode table at 1035-1546 (bg #0 + 1034) 73 | 4096 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 74 | Free blocks: 20481-24576 75 | Free inodes: 4097-6144 76 | Group 3: (Blocks 24577-32767) csum 0xd0be [INODE_UNINIT, ITABLE_ZEROED] 77 | Backup superblock at 24577, Group descriptors at 24578-24578 78 | Block bitmap at 6 (bg #0 + 5), csum 0x4327ef1c 79 | Inode bitmap at 10 (bg #0 + 9), csum 0x00000000 80 | Inode table at 1547-2058 (bg #0 + 1546) 81 | 8189 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 82 | Free blocks: 24579-32767 83 | Free inodes: 6145-8192 84 | -------------------------------------------------------------------------------- /test/mke2fs.3.dump: -------------------------------------------------------------------------------- 1 | Filesystem volume name: mke2fs 2 | Last mounted on: 3 | Filesystem magic number: 0xEF53 4 | Filesystem revision #: 1 (dynamic) 5 | Filesystem features: has_journal ext_attr dir_index filetype extent 64bit flex_bg sparse_super dir_nlink extra_isize quota metadata_csum 6 | Filesystem flags: signed_directory_hash 7 | Default mount options: user_xattr acl 8 | Filesystem state: clean 9 | Errors behavior: Continue 10 | Filesystem OS type: Linux 11 | Inode count: 8192 12 | Block count: 32768 13 | Reserved block count: 1638 14 | Overhead clusters: 6159 15 | Free blocks: 26580 16 | Free inodes: 8141 17 | First block: 1 18 | Block size: 1024 19 | Fragment size: 1024 20 | Group descriptor size: 64 21 | Blocks per group: 8192 22 | Fragments per group: 8192 23 | Inodes per group: 2048 24 | Inode blocks per group: 512 25 | Flex block group size: 16 26 | Filesystem created: Sat Jan 1 00:00:00 2000 27 | Last mount time: n/a 28 | Last write time: Sat Jan 1 00:00:00 2000 29 | Mount count: 0 30 | Maximum mount count: -1 31 | Last checked: Sat Jan 1 00:00:00 2000 32 | Check interval: 0 () 33 | Lifetime writes: 110 kB 34 | Reserved blocks uid: 0 (user root) 35 | Reserved blocks gid: 0 (group root) 36 | First inode: 11 37 | Inode size: 256 38 | Required extra isize: 32 39 | Desired extra isize: 32 40 | Journal inode: 8 41 | Default directory hash: half_md4 42 | Journal backup: inode blocks 43 | Checksum type: crc32c 44 | Journal features: (none) 45 | Total journal size: 4096k 46 | Total journal blocks: 4096 47 | Max transaction length: 4096 48 | Fast commit length: 0 49 | Journal sequence: 0x00000001 50 | Journal start: 0 51 | 52 | 53 | Group 0: (Blocks 1-8192) csum 0xd0bb [ITABLE_ZEROED] 54 | Primary superblock at 1, Group descriptors at 2-2 55 | Block bitmap at 3 (+2), csum 0xde29f1cb 56 | Inode bitmap at 7 (+6), csum 0xb1052088 57 | Inode table at 11-522 (+10) 58 | 6105 free blocks, 1997 free inodes, 18 directories, 1997 unused inodes 59 | Free blocks: 2088-8192 60 | Free inodes: 52-2048 61 | Group 1: (Blocks 8193-16384) csum 0x1510 [INODE_UNINIT, ITABLE_ZEROED] 62 | Backup superblock at 8193, Group descriptors at 8194-8194 63 | Block bitmap at 4 (bg #0 + 3), csum 0xc1d1d464 64 | Inode bitmap at 8 (bg #0 + 7), csum 0x00000000 65 | Inode table at 523-1034 (bg #0 + 522) 66 | 8190 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 67 | Free blocks: 8195-16384 68 | Free inodes: 2049-4096 69 | Group 2: (Blocks 16385-24576) csum 0x720f [INODE_UNINIT, ITABLE_ZEROED] 70 | Block bitmap at 5 (bg #0 + 4), csum 0x040008b2 71 | Inode bitmap at 9 (bg #0 + 8), csum 0x00000000 72 | Inode table at 1035-1546 (bg #0 + 1034) 73 | 4096 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 74 | Free blocks: 20481-24576 75 | Free inodes: 4097-6144 76 | Group 3: (Blocks 24577-32767) csum 0xd0be [INODE_UNINIT, ITABLE_ZEROED] 77 | Backup superblock at 24577, Group descriptors at 24578-24578 78 | Block bitmap at 6 (bg #0 + 5), csum 0x4327ef1c 79 | Inode bitmap at 10 (bg #0 + 9), csum 0x00000000 80 | Inode table at 1547-2058 (bg #0 + 1546) 81 | 8189 free blocks, 2048 free inodes, 0 directories, 2048 unused inodes 82 | Free blocks: 24579-32767 83 | Free inodes: 6145-8192 84 | -------------------------------------------------------------------------------- /test/mke2fs.conf: -------------------------------------------------------------------------------- 1 | [defaults] 2 | base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr 3 | default_mntopts = acl,user_xattr 4 | enable_periodic_fsck = 0 5 | blocksize = 4096 6 | inode_size = 256 7 | inode_ratio = 16384 8 | 9 | [fs_types] 10 | ext3 = { 11 | features = has_journal 12 | } 13 | ext4 = { 14 | features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize 15 | inode_size = 256 16 | } 17 | small = { 18 | blocksize = 1024 19 | inode_size = 128 20 | inode_ratio = 4096 21 | } 22 | floppy = { 23 | blocksize = 1024 24 | inode_size = 128 25 | inode_ratio = 8192 26 | } 27 | big = { 28 | inode_ratio = 32768 29 | } 30 | huge = { 31 | inode_ratio = 65536 32 | } 33 | news = { 34 | inode_ratio = 4096 35 | } 36 | largefile = { 37 | inode_ratio = 1048576 38 | blocksize = -1 39 | } 40 | largefile4 = { 41 | inode_ratio = 4194304 42 | blocksize = -1 43 | } 44 | hurd = { 45 | blocksize = 4096 46 | inode_size = 128 47 | } 48 | -------------------------------------------------------------------------------- /test/mke2fs.config: -------------------------------------------------------------------------------- 1 | image mke2fs.ext4 { 2 | ext4 { 3 | label = "mke2fs" 4 | fs-timestamp = "20000101000000" 5 | use-mke2fs = true 6 | mke2fs-conf = "mke2fs.conf" 7 | extraargs = "-U 12345678-1234-1234-1234-1234567890ab -E quotatype=" 8 | features = "^resize_inode,quota" 9 | } 10 | size = 32M 11 | } 12 | -------------------------------------------------------------------------------- /test/qemu.config: -------------------------------------------------------------------------------- 1 | image test.qcow { 2 | qemu { 3 | format = "qcow2" 4 | } 5 | partition part1 { 6 | image = "part1.img" 7 | } 8 | partition part2 { 9 | image = "part2.img" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/qemu.qcow.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pengutronix/genimage/d816d0d0d39ce9dd951d7c426fb7447dff6dd8d4/test/qemu.qcow.gz -------------------------------------------------------------------------------- /test/rauc-openssl-ca/ca.cert.pem: -------------------------------------------------------------------------------- 1 | Certificate: 2 | Data: 3 | Version: 3 (0x2) 4 | Serial Number: 1 (0x1) 5 | Signature Algorithm: sha256WithRSAEncryption 6 | Issuer: O=Test Org, CN=Test Org rauc CA Development 7 | Validity 8 | Not Before: Jan 1 00:00:00 1970 GMT 9 | Not After : Dec 31 23:59:59 9999 GMT 10 | Subject: O=Test Org, CN=Test Org rauc CA Development 11 | Subject Public Key Info: 12 | Public Key Algorithm: rsaEncryption 13 | RSA Public-Key: (2048 bit) 14 | Modulus: 15 | 00:e8:fd:f7:69:39:25:dd:9a:b8:c2:59:32:e6:49: 16 | 12:85:f3:c3:54:2e:ff:be:87:e8:5c:31:7e:c0:9c: 17 | 9f:67:a4:12:01:b2:e7:8e:23:c2:ae:ee:7d:d6:0c: 18 | 44:b2:38:60:2d:e7:14:6d:a2:56:63:03:55:f1:1f: 19 | 4b:27:9d:51:ac:e7:c4:bd:dd:b3:57:92:47:02:06: 20 | 9c:97:c1:2a:97:ac:de:0f:96:a2:6c:c0:bc:03:bd: 21 | 43:30:0d:c3:11:03:54:2b:16:4d:08:21:d3:15:9e: 22 | 9c:fb:64:a6:52:8b:34:eb:b4:60:21:d6:7b:e4:09: 23 | 17:75:2f:e9:61:9b:93:6e:f7:09:45:67:e6:50:9f: 24 | 31:86:e5:01:d3:14:c3:b2:16:18:fe:5a:78:b5:9f: 25 | aa:ee:d6:71:bb:92:c8:ac:e6:38:17:ef:3f:cc:ae: 26 | 92:e0:d6:fa:30:a9:82:db:dc:c2:e0:0a:c6:83:a5: 27 | 2a:f6:02:70:4c:f6:82:50:1b:e4:94:18:ae:0a:6b: 28 | 18:82:10:ab:7a:b4:11:33:0d:bc:4b:0c:36:24:fc: 29 | 6f:b7:09:c2:64:44:af:7f:24:d0:c3:ee:d1:03:c6: 30 | fa:4d:5c:67:83:75:ce:c7:b9:e5:d5:11:c7:23:f3: 31 | d1:f9:4d:98:27:a8:6a:bd:54:58:10:41:a9:44:94: 32 | 1c:1d 33 | Exponent: 65537 (0x10001) 34 | X509v3 extensions: 35 | X509v3 Subject Key Identifier: 36 | 9B:70:24:C6:A5:5A:39:78:0A:EB:25:27:13:D3:F1:C6:B4:52:76:79 37 | X509v3 Authority Key Identifier: 38 | keyid:9B:70:24:C6:A5:5A:39:78:0A:EB:25:27:13:D3:F1:C6:B4:52:76:79 39 | DirName:/O=Test Org/CN=Test Org rauc CA Development 40 | serial:01 41 | 42 | X509v3 Basic Constraints: 43 | CA:TRUE 44 | Signature Algorithm: sha256WithRSAEncryption 45 | 75:1b:17:97:83:e6:37:52:c0:06:06:ff:04:92:4f:f1:7d:7f: 46 | 14:f5:3f:e2:12:c5:c9:ff:6f:51:f4:6e:85:21:0b:bf:2e:68: 47 | d0:31:8e:90:e9:f4:cd:bb:00:9f:c4:32:90:d3:c1:80:48:92: 48 | 5b:64:39:94:25:1f:23:a7:db:e1:42:51:50:6b:3e:2f:c3:bd: 49 | 0e:02:f3:a3:bb:03:9c:26:4d:58:82:dd:f1:53:e7:5b:8c:e3: 50 | 4b:23:75:5c:e1:e5:2b:03:41:1a:8a:00:81:ae:fb:b9:70:09: 51 | 9c:14:28:3e:2c:df:50:eb:cf:82:c1:4d:ca:f6:cc:a9:37:22: 52 | 77:36:0c:d6:c3:8a:85:64:25:c5:e3:05:41:05:1c:fe:4f:97: 53 | e3:dc:a4:16:b4:35:23:8a:43:64:64:9f:78:71:70:9a:6a:ed: 54 | e2:5e:08:65:07:f7:2e:d1:4a:59:fc:1c:52:7b:36:66:ae:ac: 55 | 0d:21:1c:0e:ae:8f:d0:d8:82:3f:b9:5a:d6:f7:6c:26:6f:f7: 56 | 61:20:99:99:ee:ec:c6:09:af:73:99:b1:d8:c5:45:1c:de:1e: 57 | 30:34:e5:f4:94:41:bd:3c:e5:34:c4:53:80:1f:43:62:28:a4: 58 | 6f:5d:67:c2:7d:ec:84:20:33:20:42:f6:60:d1:b9:cb:26:69: 59 | 9b:04:a6:f8 60 | -----BEGIN CERTIFICATE----- 61 | MIIDhjCCAm6gAwIBAgIBATANBgkqhkiG9w0BAQsFADA6MREwDwYDVQQKDAhUZXN0 62 | IE9yZzElMCMGA1UEAwwcVGVzdCBPcmcgcmF1YyBDQSBEZXZlbG9wbWVudDAgFw03 63 | MDAxMDEwMDAwMDBaGA85OTk5MTIzMTIzNTk1OVowOjERMA8GA1UECgwIVGVzdCBP 64 | cmcxJTAjBgNVBAMMHFRlc3QgT3JnIHJhdWMgQ0EgRGV2ZWxvcG1lbnQwggEiMA0G 65 | CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDo/fdpOSXdmrjCWTLmSRKF88NULv++ 66 | h+hcMX7AnJ9npBIBsueOI8Ku7n3WDESyOGAt5xRtolZjA1XxH0snnVGs58S93bNX 67 | kkcCBpyXwSqXrN4PlqJswLwDvUMwDcMRA1QrFk0IIdMVnpz7ZKZSizTrtGAh1nvk 68 | CRd1L+lhm5Nu9wlFZ+ZQnzGG5QHTFMOyFhj+Wni1n6ru1nG7ksis5jgX7z/MrpLg 69 | 1vowqYLb3MLgCsaDpSr2AnBM9oJQG+SUGK4KaxiCEKt6tBEzDbxLDDYk/G+3CcJk 70 | RK9/JNDD7tEDxvpNXGeDdc7HueXVEccj89H5TZgnqGq9VFgQQalElBwdAgMBAAGj 71 | gZQwgZEwHQYDVR0OBBYEFJtwJMalWjl4CuslJxPT8ca0UnZ5MGIGA1UdIwRbMFmA 72 | FJtwJMalWjl4CuslJxPT8ca0UnZ5oT6kPDA6MREwDwYDVQQKDAhUZXN0IE9yZzEl 73 | MCMGA1UEAwwcVGVzdCBPcmcgcmF1YyBDQSBEZXZlbG9wbWVudIIBATAMBgNVHRME 74 | BTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQB1GxeXg+Y3UsAGBv8Ekk/xfX8U9T/i 75 | EsXJ/29R9G6FIQu/LmjQMY6Q6fTNuwCfxDKQ08GASJJbZDmUJR8jp9vhQlFQaz4v 76 | w70OAvOjuwOcJk1Ygt3xU+dbjONLI3Vc4eUrA0EaigCBrvu5cAmcFCg+LN9Q68+C 77 | wU3K9sypNyJ3NgzWw4qFZCXF4wVBBRz+T5fj3KQWtDUjikNkZJ94cXCaau3iXghl 78 | B/cu0UpZ/BxSezZmrqwNIRwOro/Q2II/uVrW92wmb/dhIJmZ7uzGCa9zmbHYxUUc 79 | 3h4wNOX0lEG9POU0xFOAH0NiKKRvXWfCfeyEIDMgQvZg0bnLJmmbBKb4 80 | -----END CERTIFICATE----- 81 | -------------------------------------------------------------------------------- /test/rauc-openssl-ca/rauc.cert.pem: -------------------------------------------------------------------------------- 1 | Certificate: 2 | Data: 3 | Version: 3 (0x2) 4 | Serial Number: 2 (0x2) 5 | Signature Algorithm: sha256WithRSAEncryption 6 | Issuer: O=Test Org, CN=Test Org rauc CA Development 7 | Validity 8 | Not Before: Jan 1 00:00:00 1970 GMT 9 | Not After : Dec 31 23:59:59 9999 GMT 10 | Subject: O=Test Org, CN=Test Org Development-1 11 | Subject Public Key Info: 12 | Public Key Algorithm: rsaEncryption 13 | RSA Public-Key: (2048 bit) 14 | Modulus: 15 | 00:ad:98:3e:f6:c6:6d:8c:23:b2:1c:7e:7a:6d:6e: 16 | b4:fd:be:31:77:c6:59:48:bd:f9:27:65:ec:35:74: 17 | cf:6f:2b:04:3f:0b:4b:e0:0e:6f:b2:92:2a:46:d8: 18 | 72:87:49:a8:22:5e:f8:6a:f3:50:68:35:3c:df:18: 19 | 5e:1b:9a:c3:c1:26:60:cb:fb:78:d1:8f:d8:74:32: 20 | ca:a3:34:13:f9:a5:7f:f6:cc:37:d6:b6:c9:16:f8: 21 | 66:d3:fb:01:94:d3:92:9d:43:bf:1f:fc:cd:5e:6a: 22 | 98:0a:e8:c1:b2:26:6e:43:4b:0b:2d:b2:47:87:dd: 23 | 54:a6:c3:74:94:38:10:12:cd:b0:bd:af:80:cc:d5: 24 | c2:2b:29:9c:55:45:95:50:8b:96:66:a3:4f:e6:54: 25 | 25:51:8f:c3:4c:e2:94:f3:cb:a0:b2:4b:6c:d3:5f: 26 | 36:66:39:4e:ee:fe:60:c9:f4:06:ae:7e:80:9a:4b: 27 | 08:7b:ce:93:23:e0:21:da:88:0e:2e:3d:42:33:20: 28 | bb:c2:25:ce:ee:68:2e:0c:72:0a:97:f8:8c:d4:01: 29 | 12:46:4d:08:fd:27:f4:e4:f7:af:e1:69:f1:19:c4: 30 | a1:76:02:8b:d8:45:e7:e7:31:5c:8f:f2:88:d5:55: 31 | 1a:31:30:34:72:89:b0:28:62:72:b2:03:d1:a0:1b: 32 | 70:47 33 | Exponent: 65537 (0x10001) 34 | X509v3 extensions: 35 | X509v3 Subject Key Identifier: 36 | 14:EB:9D:17:A0:17:50:60:D2:4E:52:9E:58:C4:0A:FA:00:66:13:73 37 | X509v3 Authority Key Identifier: 38 | keyid:9B:70:24:C6:A5:5A:39:78:0A:EB:25:27:13:D3:F1:C6:B4:52:76:79 39 | DirName:/O=Test Org/CN=Test Org rauc CA Development 40 | serial:01 41 | 42 | X509v3 Basic Constraints: 43 | CA:FALSE 44 | Signature Algorithm: sha256WithRSAEncryption 45 | cf:5f:a1:98:7f:4a:39:c8:30:3e:77:f0:cb:5d:bd:9f:b8:a3: 46 | f3:f7:5a:2c:d7:ed:13:60:c8:09:b9:a5:67:7f:73:2d:94:27: 47 | ef:32:e7:8f:82:87:38:a6:c3:2b:7f:2b:d8:47:8c:cf:52:c3: 48 | 4e:8d:ed:38:b1:d6:26:b2:4d:b0:2c:d7:95:05:26:c8:17:78: 49 | 60:2e:01:91:75:44:d9:7b:f3:db:69:8e:b0:9c:ca:28:72:bf: 50 | 96:49:29:07:1c:98:4d:19:d7:50:0b:46:81:d5:fa:f3:2b:49: 51 | 59:f4:4d:b7:32:7e:8b:e4:b0:db:db:81:00:14:e8:b0:2f:69: 52 | f0:2c:1d:45:9e:9c:92:20:a9:2e:a7:e5:0e:39:94:66:f3:a7: 53 | 1b:9e:26:ad:09:76:16:5b:28:2f:a0:6f:97:de:32:e4:26:ee: 54 | 79:87:0e:a9:14:c7:a3:d7:cc:c2:05:93:b7:50:35:72:2d:87: 55 | c7:e3:23:3e:f6:8c:26:07:22:dd:b9:4f:4a:b9:de:bd:7f:16: 56 | 37:48:db:d1:d8:cd:35:0e:86:18:bb:5c:d4:e1:d6:23:d5:53: 57 | 15:56:2f:08:a1:bb:d1:3c:92:de:b3:1e:e0:e1:71:f7:bc:1e: 58 | 0f:47:67:c5:02:b7:ec:06:4a:28:02:c1:7b:58:95:10:09:e1: 59 | aa:07:9d:07 60 | -----BEGIN CERTIFICATE----- 61 | MIIDfTCCAmWgAwIBAgIBAjANBgkqhkiG9w0BAQsFADA6MREwDwYDVQQKDAhUZXN0 62 | IE9yZzElMCMGA1UEAwwcVGVzdCBPcmcgcmF1YyBDQSBEZXZlbG9wbWVudDAgFw03 63 | MDAxMDEwMDAwMDBaGA85OTk5MTIzMTIzNTk1OVowNDERMA8GA1UECgwIVGVzdCBP 64 | cmcxHzAdBgNVBAMMFlRlc3QgT3JnIERldmVsb3BtZW50LTEwggEiMA0GCSqGSIb3 65 | DQEBAQUAA4IBDwAwggEKAoIBAQCtmD72xm2MI7IcfnptbrT9vjF3xllIvfknZew1 66 | dM9vKwQ/C0vgDm+ykipG2HKHSagiXvhq81BoNTzfGF4bmsPBJmDL+3jRj9h0Msqj 67 | NBP5pX/2zDfWtskW+GbT+wGU05KdQ78f/M1eapgK6MGyJm5DSwstskeH3VSmw3SU 68 | OBASzbC9r4DM1cIrKZxVRZVQi5Zmo0/mVCVRj8NM4pTzy6CyS2zTXzZmOU7u/mDJ 69 | 9AaufoCaSwh7zpMj4CHaiA4uPUIzILvCJc7uaC4McgqX+IzUARJGTQj9J/Tk96/h 70 | afEZxKF2AovYRefnMVyP8ojVVRoxMDRyibAoYnKyA9GgG3BHAgMBAAGjgZEwgY4w 71 | HQYDVR0OBBYEFBTrnRegF1Bg0k5SnljECvoAZhNzMGIGA1UdIwRbMFmAFJtwJMal 72 | Wjl4CuslJxPT8ca0UnZ5oT6kPDA6MREwDwYDVQQKDAhUZXN0IE9yZzElMCMGA1UE 73 | AwwcVGVzdCBPcmcgcmF1YyBDQSBEZXZlbG9wbWVudIIBATAJBgNVHRMEAjAAMA0G 74 | CSqGSIb3DQEBCwUAA4IBAQDPX6GYf0o5yDA+d/DLXb2fuKPz91os1+0TYMgJuaVn 75 | f3MtlCfvMuePgoc4psMrfyvYR4zPUsNOje04sdYmsk2wLNeVBSbIF3hgLgGRdUTZ 76 | e/PbaY6wnMoocr+WSSkHHJhNGddQC0aB1frzK0lZ9E23Mn6L5LDb24EAFOiwL2nw 77 | LB1FnpySIKkup+UOOZRm86cbniatCXYWWygvoG+X3jLkJu55hw6pFMej18zCBZO3 78 | UDVyLYfH4yM+9owmByLduU9Kud69fxY3SNvR2M01DoYYu1zU4dYj1VMVVi8IobvR 79 | PJLesx7g4XH3vB4PR2fFArfsBkooAsF7WJUQCeGqB50H 80 | -----END CERTIFICATE----- 81 | -------------------------------------------------------------------------------- /test/rauc-openssl-ca/rauc.key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCtmD72xm2MI7Ic 3 | fnptbrT9vjF3xllIvfknZew1dM9vKwQ/C0vgDm+ykipG2HKHSagiXvhq81BoNTzf 4 | GF4bmsPBJmDL+3jRj9h0MsqjNBP5pX/2zDfWtskW+GbT+wGU05KdQ78f/M1eapgK 5 | 6MGyJm5DSwstskeH3VSmw3SUOBASzbC9r4DM1cIrKZxVRZVQi5Zmo0/mVCVRj8NM 6 | 4pTzy6CyS2zTXzZmOU7u/mDJ9AaufoCaSwh7zpMj4CHaiA4uPUIzILvCJc7uaC4M 7 | cgqX+IzUARJGTQj9J/Tk96/hafEZxKF2AovYRefnMVyP8ojVVRoxMDRyibAoYnKy 8 | A9GgG3BHAgMBAAECggEBAIvaAa/RwGOMRmvKQVt0Ov/JgBTciQWfduCUri2Kw6rt 9 | 3ufjc+c3+ijEtKaKrgnr/zZhiISxLPAnI7kf6oEWt+odvxHWsEk0N8+1M6czx3vy 10 | Jxtu/vVOIMcOq9jPeUCrCo0EDS/5/IG6Im93gMTDTUWNaZ4Q6Ku+VfpbsMnQOLLM 11 | C0MBg3GG9OHFwAvmrkTA8fLsI9lsjh2euczD8Gnxy8gIkTGxd3/atzjJwfU7drTk 12 | +p5YrlAwswa/Or98OqYLoUUs3KlR3FZdhJdfLOBeCN7ycBoH/vrqUGCZxPf7hG1V 13 | WQ/MXIErEIThEVmPVpawN2uuaE2xr18aEDmCc8GkITECgYEA2/9emIs6b1ncXR9a 14 | bP+slWPlh6TmOc/r0f82QLPuHfegCJ9kIK1V3ad/rKE02MSVFukptEmE8/YvOrWz 15 | NVCNcZ5M2D3mgeIzQZnZz1JqZ3ooEnSfU+Dy1BgPCV2EFyn1NtoiZ4V8vpZKkXOO 16 | o9Du11KdqugG1Afv6veUYCTeV4UCgYEAygDdd80IeYkXoZd/1hNV60KeBQzgpsBe 17 | Tw9KnO579O9/t+ZF2HUuO5tfRWQxu/pcJ3PinO6TbB1v4nxV4RaFgjQdkeSqVQcJ 18 | 68YyT7JOdR3TEbLcJKKE4eikeHa5/P+KVyQJ5avRslH9WSoFdhHf9laqQcy3BsCe 19 | /G2XINt3RFsCgYBe2P+Qpt4fqc9e+qiCu8xNcA9CZu63WBQkqnJafPiZROxjK00A 20 | 5ZpSgOeDptDg8AgTI51OVDAU+jushS/pOXxx0rzwsedSchKFIu6L+s1TJZBnPI6A 21 | nEg09tZsxDuxvO4youMYXK3GgYdOpFKIAAkpHj5Js9VVzsI6PFllBiAx/QKBgDH1 22 | 7tCfjFYK2yZjQwHefGSYcF7NZY64i1rAbHLN5SiaR5tjP6keqlWhwvl1o3tbm4lC 23 | dyzbMOkPismYeOEX4eNnIl0gEiS/feurdGwTrKX4v2hkNWB2NaluEaedrbhuN3f/ 24 | +NauHUoeTyvLYdhm6V6S5r8pc6ce4vOJ41QEE8Z7AoGALDpRTNPk4GOjuXMwCJrO 25 | 3pNOjG4/VYT3uKl9m6XDT7/Xaut5mvVTg5ydHfLFx+wCnlpjDkB4hzlv/jLZoscd 26 | HAV700G8gIsDvIIVHn9XaGmb535C3NgKlU6k4zCxnv9rFX9whaesWTzGSA4i8RwA 27 | X+B3KymaDhAuzRpSfNO+sCY= 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /test/rauc.config: -------------------------------------------------------------------------------- 1 | image test.raucb { 2 | rauc { 3 | file content { image = "rauc.content" } 4 | manifest = " 5 | [update] 6 | compatible=genimage-test 7 | version=42 8 | build=23 9 | description='genimage rauc test' 10 | 11 | [image.rootfs] 12 | filename=content 13 | " 14 | cert = "rauc-openssl-ca/rauc.cert.pem" 15 | key = "rauc-openssl-ca/rauc.key.pem" 16 | keyring = "rauc-openssl-ca/ca.cert.pem" 17 | } 18 | } 19 | image test2.raucb { 20 | rauc { 21 | file data { 22 | image = "rauc2.content" 23 | offset = 1 24 | } 25 | manifest = " 26 | [update] 27 | compatible=genimage-test 28 | version=42 29 | build=23 30 | description='genimage rauc test' 31 | 32 | [image.rootfs] 33 | filename=data 34 | " 35 | cert = "rauc-openssl-ca/rauc.cert.pem" 36 | key = "rauc-openssl-ca/rauc.key.pem" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/sparse-fill.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | partition-table-type = "gpt" 5 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 6 | } 7 | partition part1 { 8 | image = "part1.img" 9 | size = 10M 10 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 11 | } 12 | partition part2 { 13 | image = "part2.img" 14 | size = 10M 15 | partition-type-uuid = "L" 16 | partition-uuid = "41061242-1d5a-4657-892d-fcc1fdb11a6c" 17 | } 18 | size = 22M 19 | } 20 | 21 | image test.sparse { 22 | android-sparse { 23 | image = test.hdimage 24 | fill-holes = true 25 | } 26 | } 27 | 28 | image interleaved.sparse { 29 | android-sparse { 30 | image = interleaved 31 | block-size = 32k 32 | fill-holes = true 33 | } 34 | } 35 | 36 | image not-aligned.sparse { 37 | android-sparse { 38 | image = not-aligned 39 | block-size = 4k 40 | fill-holes = true 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/sparse.config: -------------------------------------------------------------------------------- 1 | image test.hdimage { 2 | hdimage { 3 | align = 1M 4 | partition-table-type = "gpt" 5 | disk-uuid = "afcfea87-e41a-40e0-85ae-295c60773c7a" 6 | } 7 | partition part1 { 8 | image = "part1.img" 9 | size = 10M 10 | partition-uuid = "92762261-e854-45c1-b4c9-fc5e752034ab" 11 | } 12 | partition part2 { 13 | image = "part2.img" 14 | size = 10M 15 | partition-type-uuid = "L" 16 | partition-uuid = "41061242-1d5a-4657-892d-fcc1fdb11a6c" 17 | } 18 | size = 22M 19 | } 20 | 21 | image test.sparse { 22 | android-sparse { 23 | image = test.hdimage 24 | add-crc = true 25 | } 26 | } 27 | 28 | image interleaved.sparse { 29 | android-sparse { 30 | image = interleaved 31 | block-size = 32k 32 | } 33 | } 34 | 35 | image not-aligned.sparse { 36 | android-sparse { 37 | image = not-aligned 38 | block-size = 4k 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/squashfs.config: -------------------------------------------------------------------------------- 1 | image test.squashfs { 2 | squashfs { 3 | compression = "lzo" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/tar.config: -------------------------------------------------------------------------------- 1 | image test.tar.gz { 2 | tar { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /test/test-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | testdir="$(readlink -f $(dirname "${0}"))" 4 | genimage="$(pwd)/genimage" 5 | 6 | PATH="$PATH:/sbin:/usr/sbin" 7 | 8 | set -- -v "$@" 9 | 10 | 11 | . "${testdir}/sharness.sh" 12 | 13 | filelist_orig="$(pwd)/file-list.orig" 14 | filelist_test="$(pwd)/file-list.test" 15 | root_orig="$(pwd)/root.orig" 16 | root_test="$(pwd)/root.test" 17 | 18 | setup_data() { 19 | umask 0022 20 | mkdir -p "${root_orig}"/{foo,bar,baz,"with spaces"}/{1,2,3} 21 | touch "${root_orig}"/{foo,bar,baz,"with spaces"}/{1,2,3}/{one,two} 22 | find "${root_orig}" -print0 | xargs -0 touch -c -d "2011-11-11 UTC" 23 | find "${root_orig}"/ -mindepth 1 -printf "%P\n" | sort > "${filelist_orig}" 24 | 25 | cp "${testdir}"/*.conf* "${testdir}"/*.sh . 26 | } 27 | 28 | run_genimage_impl() { 29 | if [ ! -e "${1}" ]; then 30 | echo "ERROR: genimage config file '${1}' missing!" 31 | return 130 32 | fi 33 | if [ "$verbose" = "t" ]; then 34 | vargs="--loglevel=3" 35 | fi 36 | rm -rf tmp images "${root_test}" 37 | mkdir "${root_test}" images 38 | if [ -n "${2}" ]; then 39 | # create a larger output image to make sure it is recreated properly 40 | dd if=/dev/zero of="images/${2}" bs=1M seek=30 count=1 41 | fi 42 | "${genimage}" \ 43 | ${vargs} \ 44 | --outputpath=images \ 45 | --inputpath=input \ 46 | --rootpath="${root}" \ 47 | --tmppath=tmp \ 48 | ${extra_opts} \ 49 | --config "${1}" 50 | } 51 | 52 | run_genimage_root() { 53 | root="root.orig" run_genimage_impl "${@}" 54 | } 55 | 56 | run_genimage() { 57 | root="/this/directory/does/not/exist" run_genimage_impl "${@}" 58 | } 59 | 60 | get_size() { 61 | local file="${1}" 62 | if [ ! -f "${file}" ]; then 63 | echo "Failed to check file size: '${file}' does not exist!" 64 | return 1 65 | fi 66 | set -- $(du -b "${file}") 67 | size="${1}" 68 | } 69 | 70 | check_size_range() { 71 | local size 72 | get_size "${1}" || return 73 | if [ "${size}" -lt "${2}" -o "${size}" -gt "${3}" ]; then 74 | echo "Incorrect file size for '${1}': expected min: ${2} max: ${3} found: ${size}" 75 | return 1 76 | fi 77 | } 78 | 79 | check_size() { 80 | local size 81 | get_size "${1}" || return 82 | if [ "${size}" -ne "${2}" ]; then 83 | echo "Incorrect file size for '${1}': expected: ${2} found: ${size}" 84 | return 1 85 | fi 86 | } 87 | 88 | sfdisk_validate() { 89 | if [ -n "$(sfdisk -q -V "${1}" 2>&1 | grep -v unallocated)" ]; then 90 | echo "'sfdisk -V' failed with:" 91 | sfdisk -V "${1}" 2>&1 92 | return 1 93 | fi 94 | } 95 | 96 | setup_test_images() { 97 | rm -rf input && 98 | mkdir input && 99 | dd if=/dev/zero of=input/part1.img bs=512 count=7 && 100 | dd if=/dev/zero of=input/part2.img bs=512 count=11 && 101 | touch input/part3.img 102 | } 103 | 104 | sanitized_fdisk_sfdisk() { 105 | # check the disk identifier 106 | fdisk -l "${1}" | grep identifier: && 107 | # check partitions; filter output to handle different sfdisk versions 108 | sfdisk -d "${1}" 2>/dev/null | grep '^images/' | \ 109 | sed -e 's/ *//g' -e 's;Id=;type=;' 110 | } 111 | 112 | exec_test_set_prereq() { 113 | command -v "${1}" > /dev/null && test_set_prereq "${1/./_}" 114 | } 115 | 116 | set -o pipefail 117 | 118 | setup_data 119 | 120 | sfdisk -h | grep -q gpt && test_set_prereq sfdisk-gpt 121 | fdisk -h | grep -q gpt && test_set_prereq fdisk-gpt 122 | # make sure mke2fs supports '-d root-directory' 123 | [ "$(mke2fs |& sed -n 's/.*\(-d \).*/\1/p')" = "-d " ] && test_set_prereq mke2fs 124 | -------------------------------------------------------------------------------- /test/test.raucb.info.1: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | 1 Image: 7 | (1) content 8 | Slotclass: rootfs 9 | Checksum: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 10 | Size: 5 11 | Hooks: 12 | 0 Files 13 | 14 | Certificate Chain: 15 | 0 Subject: /O=Test Org/CN=Test Org Development-1 16 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 17 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 18 | Not Before: Jan 1 00:00:00 1970 GMT 19 | Not After: Dec 31 23:59:59 9999 GMT 20 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 21 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 22 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 23 | Not Before: Jan 1 00:00:00 1970 GMT 24 | Not After: Dec 31 23:59:59 9999 GMT 25 | 26 | -------------------------------------------------------------------------------- /test/test.raucb.info.2: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | 7 | 1 Image: 8 | [rootfs] 9 | Filename: content 10 | Checksum: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 11 | Size: 5 12 | Hooks: 13 | 14 | Certificate Chain: 15 | 0 Subject: /O=Test Org/CN=Test Org Development-1 16 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 17 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 18 | Not Before: Jan 1 00:00:00 1970 GMT 19 | Not After: Dec 31 23:59:59 9999 GMT 20 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 21 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 22 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 23 | Not Before: Jan 1 00:00:00 1970 GMT 24 | Not After: Dec 31 23:59:59 9999 GMT 25 | 26 | -------------------------------------------------------------------------------- /test/test.raucb.info.3: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | Manifest Hash: '396427d8c699c8c1f1c89836dc9883448d1b176477848fff63cdd1bdae1cd1a0' 7 | 8 | 9 | 1 Image: 10 | [rootfs] 11 | Filename: content 12 | Checksum: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 13 | Size: 5 14 | Hooks: 15 | 16 | Certificate Chain: 17 | 0 Subject: /O=Test Org/CN=Test Org Development-1 18 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 19 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 20 | Not Before: Jan 1 00:00:00 1970 GMT 21 | Not After: Dec 31 23:59:59 9999 GMT 22 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 23 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 24 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 25 | Not Before: Jan 1 00:00:00 1970 GMT 26 | Not After: Dec 31 23:59:59 9999 GMT 27 | 28 | -------------------------------------------------------------------------------- /test/test.raucb.info.4: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | Manifest Hash: '396427d8c699c8c1f1c89836dc9883448d1b176477848fff63cdd1bdae1cd1a0' 7 | 8 | 9 | 1 Image: 10 | [rootfs] 11 | Filename: content 12 | Checksum: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 13 | Size: 5 bytes 14 | Hooks: 15 | 16 | Certificate Chain: 17 | 0 Subject: /O=Test Org/CN=Test Org Development-1 18 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 19 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 20 | Not Before: Jan 1 00:00:00 1970 GMT 21 | Not After: Dec 31 23:59:59 9999 GMT 22 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 23 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 24 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 25 | Not Before: Jan 1 00:00:00 1970 GMT 26 | Not After: Dec 31 23:59:59 9999 GMT 27 | 28 | -------------------------------------------------------------------------------- /test/test2.raucb.info.1: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | 1 Image: 7 | (1) data 8 | Slotclass: rootfs 9 | Checksum: 7d6fd7774f0d87624da6dcf16d0d3d104c3191e771fbe2f39c86aed4b2bf1a0f 10 | Size: 6 11 | Hooks: 12 | 0 Files 13 | 14 | Certificate Chain: 15 | 0 Subject: /O=Test Org/CN=Test Org Development-1 16 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 17 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 18 | Not Before: Jan 1 00:00:00 1970 GMT 19 | Not After: Dec 31 23:59:59 9999 GMT 20 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 21 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 22 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 23 | Not Before: Jan 1 00:00:00 1970 GMT 24 | Not After: Dec 31 23:59:59 9999 GMT 25 | 26 | -------------------------------------------------------------------------------- /test/test2.raucb.info.2: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | 7 | 1 Image: 8 | [rootfs] 9 | Filename: data 10 | Checksum: 7d6fd7774f0d87624da6dcf16d0d3d104c3191e771fbe2f39c86aed4b2bf1a0f 11 | Size: 6 12 | Hooks: 13 | 14 | Certificate Chain: 15 | 0 Subject: /O=Test Org/CN=Test Org Development-1 16 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 17 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 18 | Not Before: Jan 1 00:00:00 1970 GMT 19 | Not After: Dec 31 23:59:59 9999 GMT 20 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 21 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 22 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 23 | Not Before: Jan 1 00:00:00 1970 GMT 24 | Not After: Dec 31 23:59:59 9999 GMT 25 | 26 | -------------------------------------------------------------------------------- /test/test2.raucb.info.3: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | Manifest Hash: 'ef0e93a54af2689a033ad524522c4b6b97115bad3ac0b907e01a41221f41e729' 7 | 8 | 9 | 1 Image: 10 | [rootfs] 11 | Filename: data 12 | Checksum: 7d6fd7774f0d87624da6dcf16d0d3d104c3191e771fbe2f39c86aed4b2bf1a0f 13 | Size: 6 14 | Hooks: 15 | 16 | Certificate Chain: 17 | 0 Subject: /O=Test Org/CN=Test Org Development-1 18 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 19 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 20 | Not Before: Jan 1 00:00:00 1970 GMT 21 | Not After: Dec 31 23:59:59 9999 GMT 22 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 23 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 24 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 25 | Not Before: Jan 1 00:00:00 1970 GMT 26 | Not After: Dec 31 23:59:59 9999 GMT 27 | 28 | -------------------------------------------------------------------------------- /test/test2.raucb.info.4: -------------------------------------------------------------------------------- 1 | Compatible: 'genimage-test' 2 | Version: '42' 3 | Description: ''genimage rauc test'' 4 | Build: '23' 5 | Hooks: '' 6 | Manifest Hash: 'ef0e93a54af2689a033ad524522c4b6b97115bad3ac0b907e01a41221f41e729' 7 | 8 | 9 | 1 Image: 10 | [rootfs] 11 | Filename: data 12 | Checksum: 7d6fd7774f0d87624da6dcf16d0d3d104c3191e771fbe2f39c86aed4b2bf1a0f 13 | Size: 6 bytes 14 | Hooks: 15 | 16 | Certificate Chain: 17 | 0 Subject: /O=Test Org/CN=Test Org Development-1 18 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 19 | SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 20 | Not Before: Jan 1 00:00:00 1970 GMT 21 | Not After: Dec 31 23:59:59 9999 GMT 22 | 1 Subject: /O=Test Org/CN=Test Org rauc CA Development 23 | Issuer: /O=Test Org/CN=Test Org rauc CA Development 24 | SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD 25 | Not Before: Jan 1 00:00:00 1970 GMT 26 | Not After: Dec 31 23:59:59 9999 GMT 27 | 28 | -------------------------------------------------------------------------------- /test/ubi.config: -------------------------------------------------------------------------------- 1 | include("flash-types.config") 2 | 3 | image test.ubi { 4 | ubi { 5 | } 6 | partition ubifs1 { 7 | image = "test.ubifs" 8 | } 9 | partition ubifs2 { 10 | image = "test.ubifs" 11 | autoresize = true 12 | } 13 | flashtype = "nand-64M-512" 14 | } 15 | -------------------------------------------------------------------------------- /test/ubifs.config: -------------------------------------------------------------------------------- 1 | include("flash-types.config") 2 | 3 | image test.ubifs { 4 | ubifs { 5 | max-size = 16M 6 | } 7 | flashtype = "nand-64M-512" 8 | size = 4M 9 | } 10 | -------------------------------------------------------------------------------- /test/vfat.config: -------------------------------------------------------------------------------- 1 | image test.vfat { 2 | vfat { 3 | extraargs = "-n 'vfat-test'" 4 | } 5 | size = 4095K 6 | } 7 | --------------------------------------------------------------------------------