From: Tobias Stoeckmann Date: Wed, 22 Apr 2026 19:16:19 +0000 (+0200) Subject: mkfs.cramfs: Consider -i only once X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=6e77a85bdb5db322ae29a2f3ac10379801684cf9;p=thirdparty%2Futil-linux.git mkfs.cramfs: Consider -i only once If multiple files are specified through -i, all sizes are added to estimated filesystem size, yet only the last given file will be added. Increase fslen_ub only once. Signed-off-by: Tobias Stoeckmann --- diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c index f99e8d995..244cfba16 100644 --- a/disk-utils/mkfs.cramfs.c +++ b/disk-utils/mkfs.cramfs.c @@ -761,10 +761,6 @@ int main(int argc, char **argv) break; case 'i': opt_image = optarg; - if (lstat(opt_image, &st) < 0) - err(MKFS_EX_USAGE, _("stat of %s failed"), opt_image); - image_length = st.st_size; /* may be padded later */ - fslen_ub += (image_length + 3); /* 3 is for padding */ break; case 'l': lockmode = "1"; @@ -803,6 +799,12 @@ int main(int argc, char **argv) dirname = argv[optind]; outfile = argv[optind + 1]; + if (opt_image != NULL) { + if (lstat(opt_image, &st) < 0) + err(MKFS_EX_USAGE, _("stat of %s failed"), opt_image); + image_length = st.st_size; /* may be padded later */ + fslen_ub += (image_length + 3); /* 3 is for padding */ + } fslen_ub += opt_pad; if (blksize == 0)