Skip to content

Commit

Permalink
mkcomposefs: Inline small files by default
Browse files Browse the repository at this point in the history
Can be disabled with --disable-inline.

Signed-off-by: Alexander Larsson <[email protected]>
  • Loading branch information
alexlarsson committed Sep 13, 2023
1 parent 080c07b commit c3c7777
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/mkcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ static int fill_payload(struct lcfs_node_s *node, const char *path, size_t len,
ret = lcfs_node_set_payload(node, target);
if (ret < 0)
return ret;
} else if ((lcfs_node_get_mode(node) & S_IFMT) == S_IFREG) {
} else if ((lcfs_node_get_mode(node) & S_IFMT) == S_IFREG &&
lcfs_node_get_content(node) == NULL) {
const uint8_t *digest = NULL;

if (by_digest)
Expand Down Expand Up @@ -354,7 +355,7 @@ static int fill_payload(struct lcfs_node_s *node, const char *path, size_t len,
static void usage(const char *argv0)
{
fprintf(stderr,
"usage: %s [--use-epoch] [--skip-xattrs] [--absolute] [--by-digest] [--digest-store=path] [--print-digest] [--print-digest-only] [--skip-devices] [--compute-digest] SOURCEDIR IMAGE\n",
"usage: %s [--use-epoch] [--skip-xattrs] [--absolute] [--no-inline] [--by-digest] [--digest-store=path] [--print-digest] [--print-digest-only] [--skip-devices] [--compute-digest] SOURCEDIR IMAGE\n",
argv0);
}

Expand All @@ -368,6 +369,7 @@ static void usage(const char *argv0)
#define OPT_PRINT_DIGEST 109
#define OPT_FORMAT 110
#define OPT_PRINT_DIGEST_ONLY 111
#define OPT_NO_INLINE 112

static ssize_t write_cb(void *_file, void *buf, size_t count)
{
Expand Down Expand Up @@ -409,6 +411,12 @@ int main(int argc, char **argv)
flag: NULL,
val: OPT_COMPUTE_DIGEST
},
{
name: "no-inline",
has_arg: no_argument,
flag: NULL,
val: OPT_NO_INLINE
},
{
name: "by-digest",
has_arg: no_argument,
Expand Down Expand Up @@ -460,6 +468,7 @@ int main(int argc, char **argv)
FILE *out_file;
char *failed_path;

buildflags = LCFS_BUILD_INLINE_SMALL;
while ((opt = getopt_long(argc, argv, ":CR", longopts, NULL)) != -1) {
switch (opt) {
case OPT_USE_EPOCH:
Expand All @@ -474,6 +483,9 @@ int main(int argc, char **argv)
case OPT_COMPUTE_DIGEST:
buildflags |= LCFS_BUILD_COMPUTE_DIGEST;
break;
case OPT_NO_INLINE:
buildflags &= ~LCFS_BUILD_INLINE_SMALL;
break;
case OPT_ABSOLUTE:
absolute_path = true;
break;
Expand Down

0 comments on commit c3c7777

Please sign in to comment.