Skip to content

Commit 91d10dc

Browse files
committed
cptofs: Add --mb cli option
Fixes OOM panics when copying results in a very large filesystem. --mb matches the lklfuse mb option. Fixes #466
1 parent f6d6f7d commit 91d10dc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/lkl/cptofs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ 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+
{"mb", 'm', "int", 0,
35+
"amount of memory to allocate in MB (default: 100)"},
3436
{0},
3537
};
3638

@@ -44,6 +46,7 @@ static struct cl_args {
4446
const char *selinux;
4547
uid_t owner;
4648
gid_t group;
49+
int mb;
4750
} cla;
4851

4952
static int cptofs;
@@ -74,6 +77,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
7477
case 'g':
7578
cla->group = atoi(arg);
7679
break;
80+
case 'm':
81+
cla->mb = atoi(arg);
82+
break;
7783
case ARGP_KEY_ARG:
7884
// Capture all remaining arguments in our paths array and stop
7985
// parsing here. We treat the last one as the destination and
@@ -627,6 +633,7 @@ int main(int argc, char **argv)
627633

628634
cla.owner = (uid_t)-1;
629635
cla.group = (gid_t)-1;
636+
cla.mb = 100;
630637

631638
if (strstr(argv[0], "cptofs")) {
632639
cptofs = 1;
@@ -664,7 +671,7 @@ int main(int argc, char **argv)
664671
}
665672
disk_id = ret;
666673

667-
ret = lkl_start_kernel("mem=100M");
674+
ret = lkl_start_kernel("mem=%dM", cla.mb);
668675
if (ret < 0) {
669676
fprintf(stderr, "failed to start kernel: %s\n",
670677
lkl_strerror(ret));

0 commit comments

Comments
 (0)