From 333912e54aa576459eb72a5bc4eb94dcfde8b9b5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 25 May 2024 13:30:16 +0200 Subject: [PATCH] mxqsub: Implement --tmpdir argument without units The usage string of mxqsub says, that any size can be given without units, in which case Mebibytes is assumed. This doesn't currently work for --tmpdir, because the function mx_strtobytes which is used to convert the string, doesn't accept numbers without units. Try mx_strtou64() first to process numerical argments without a unit. Because tmpdir size is stored in Gibibytes and not Mebibytes internally, the value needs to be divided by 1024. --- mxqsub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mxqsub.c b/mxqsub.c index 5ee8cee..478886a 100644 --- a/mxqsub.c +++ b/mxqsub.c @@ -989,7 +989,10 @@ int main(int argc, char *argv[]) break; case 7: - { + u_int64_t arg_tmpdir_mb; + if (mx_strtou64(optctl.optarg, &arg_tmpdir_mb) == 0) { + arg_tmpdir = (arg_tmpdir_mb+1024-1)/1024; + } else { unsigned long long int bytes; if(mx_strtobytes(optctl.optarg, &bytes) < 0) { mx_log_crit("--tmpdir '%s': %m", optctl.optarg);