From 7884649ce73eedff00baab9bc86f439193400439 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Mon, 30 Nov 2020 00:16:57 +0300 Subject: minor code changes --- README.md | 2 +- voidnsrun.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6c9e785..9fcbdc2 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ should handle it. voidnsrun [OPTIONS] [PROGRAM [ARGS]] Options: - -h: print this help -m : add bind mount -r : altroot path. If this option is not present, VOIDNSRUN_DIR environment variable is used. + -h: print this help -v: print version ``` diff --git a/voidnsrun.c b/voidnsrun.c index e121c0f..c0db7c1 100644 --- a/voidnsrun.c +++ b/voidnsrun.c @@ -32,15 +32,15 @@ void usage(const char *progname) printf("Usage: %s [OPTIONS] [PROGRAM [ARGS]]\n", progname); printf("\n" "Options:\n" - " -h: print this help\n" " -m : add bind mount\n" " -r : altroot path. If this option is not present,\n" " %s environment variable is used.\n" + " -h: print this help\n" " -v: print version\n", var_name); } -bool mount_list( +bool mountlist( const char *dirptr, size_t dirlen, const char **mountpoints, @@ -54,14 +54,14 @@ bool mount_list( ERROR("error: path %s%s is too large.\n", dirptr, mountpoints[i]); return false; } + strcpy(buf, dirptr); strcat(buf, mountpoints[i]); if (!isdir(buf)) { - if (!ignore_missing) { - ERROR("error: source mount dir %s does not exists.\n", buf); - return false; - } else + if (ignore_missing) continue; + ERROR("error: source mount dir %s does not exists.\n", buf); + return false; } if (!isdir(mountpoints[i])) { ERROR("error: mountpoint %s does not exists.\n", mountpoints[i]); @@ -139,12 +139,10 @@ int main(int argc, char **argv) /* Mount stuff from altroot to our private namespace. */ const char *mountpoints[] = {"/usr", "/var/db/xbps", "/etc/xbps.d"}; - - if (!mount_list(dir, dirlen, mountpoints, ARRAY_SIZE(mountpoints), true)) + if (!mountlist(dir, dirlen, mountpoints, ARRAY_SIZE(mountpoints), true)) return 1; - if (usermounts_count > 0 && - !mount_list(dir, dirlen, usermounts, usermounts_count, false)) + !mountlist(dir, dirlen, usermounts, usermounts_count, false)) return 1; /* Drop root. */ -- cgit v1.2.3