Skip to content

Commit cab96cf

Browse files
committed
cptofs: Add --kernel-parameters cli option
Fixes OOM panics when copying results in a very large filesystem. Fixes #466
1 parent f6d6f7d commit cab96cf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tools/lkl/cptofs.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static struct argp_option options[] = {
3131
{"owner", 'o', "int", 0, "owner of the destination files"},
3232
{"group", 'g', "int", 0, "group of the destination files"},
3333
{"selinux", 's', "string", 0, "selinux attributes for destination"},
34+
{"kernel-parameters", 'k', "string", 0, "kernel parameters when booting linux"},
3435
{0},
3536
};
3637

@@ -44,6 +45,7 @@ static struct cl_args {
4445
const char *selinux;
4546
uid_t owner;
4647
gid_t group;
48+
const char *kernel_parameters;
4749
} cla;
4850

4951
static int cptofs;
@@ -74,6 +76,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
7476
case 'g':
7577
cla->group = atoi(arg);
7678
break;
79+
case 'k':
80+
cla->kernel_parameters = arg;
81+
break;
7782
case ARGP_KEY_ARG:
7883
// Capture all remaining arguments in our paths array and stop
7984
// parsing here. We treat the last one as the destination and
@@ -627,6 +632,7 @@ int main(int argc, char **argv)
627632

628633
cla.owner = (uid_t)-1;
629634
cla.group = (gid_t)-1;
635+
cla.kernel_parameters = "mem=100M";
630636

631637
if (strstr(argv[0], "cptofs")) {
632638
cptofs = 1;
@@ -664,7 +670,7 @@ int main(int argc, char **argv)
664670
}
665671
disk_id = ret;
666672

667-
ret = lkl_start_kernel("mem=100M");
673+
ret = lkl_start_kernel(cla.kernel_parameters);
668674
if (ret < 0) {
669675
fprintf(stderr, "failed to start kernel: %s\n",
670676
lkl_strerror(ret));

0 commit comments

Comments
 (0)