From 9dcd61afcc95c97aa925f62a4195fd4c1e440204 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 11 Feb 2026 21:20:27 -0700 Subject: [PATCH] cptofs: Add --mb cli option Fixes OOM panics when copying results in a very large filesystem. --mb matches the lklfuse mb option. Fixes #466 Signed-off-by: John Soo --- tools/lkl/cptofs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/lkl/cptofs.c b/tools/lkl/cptofs.c index 007f0ec85b99ff..9f0b0bfdcdee58 100644 --- a/tools/lkl/cptofs.c +++ b/tools/lkl/cptofs.c @@ -31,6 +31,8 @@ static struct argp_option options[] = { {"owner", 'o', "int", 0, "owner of the destination files"}, {"group", 'g', "int", 0, "group of the destination files"}, {"selinux", 's', "string", 0, "selinux attributes for destination"}, + {"mb", 'm', "int", 0, + "amount of memory to allocate in MB (default: 100)"}, {0}, }; @@ -44,6 +46,7 @@ static struct cl_args { const char *selinux; uid_t owner; gid_t group; + int mb; } cla; static int cptofs; @@ -74,6 +77,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 'g': cla->group = atoi(arg); break; + case 'm': + cla->mb = atoi(arg); + break; case ARGP_KEY_ARG: // Capture all remaining arguments in our paths array and stop // parsing here. We treat the last one as the destination and @@ -627,6 +633,7 @@ int main(int argc, char **argv) cla.owner = (uid_t)-1; cla.group = (gid_t)-1; + cla.mb = 100; if (strstr(argv[0], "cptofs")) { cptofs = 1; @@ -664,7 +671,7 @@ int main(int argc, char **argv) } disk_id = ret; - ret = lkl_start_kernel("mem=100M"); + ret = lkl_start_kernel("mem=%dM", cla.mb); if (ret < 0) { fprintf(stderr, "failed to start kernel: %s\n", lkl_strerror(ret));