minor code changes

This commit is contained in:
Evgeny Zinoviev 2020-11-30 00:16:57 +03:00
parent ec0a39db5c
commit 7884649ce7
2 changed files with 9 additions and 11 deletions

View File

@ -26,10 +26,10 @@ should handle it.
voidnsrun [OPTIONS] [PROGRAM [ARGS]] voidnsrun [OPTIONS] [PROGRAM [ARGS]]
Options: Options:
-h: print this help
-m <path>: add bind mount -m <path>: add bind mount
-r <path>: altroot path. If this option is not present, -r <path>: altroot path. If this option is not present,
VOIDNSRUN_DIR environment variable is used. VOIDNSRUN_DIR environment variable is used.
-h: print this help
-v: print version -v: print version
``` ```

View File

@ -32,15 +32,15 @@ void usage(const char *progname)
printf("Usage: %s [OPTIONS] [PROGRAM [ARGS]]\n", progname); printf("Usage: %s [OPTIONS] [PROGRAM [ARGS]]\n", progname);
printf("\n" printf("\n"
"Options:\n" "Options:\n"
" -h: print this help\n"
" -m <path>: add bind mount\n" " -m <path>: add bind mount\n"
" -r <path>: altroot path. If this option is not present,\n" " -r <path>: altroot path. If this option is not present,\n"
" %s environment variable is used.\n" " %s environment variable is used.\n"
" -h: print this help\n"
" -v: print version\n", " -v: print version\n",
var_name); var_name);
} }
bool mount_list( bool mountlist(
const char *dirptr, const char *dirptr,
size_t dirlen, size_t dirlen,
const char **mountpoints, const char **mountpoints,
@ -54,14 +54,14 @@ bool mount_list(
ERROR("error: path %s%s is too large.\n", dirptr, mountpoints[i]); ERROR("error: path %s%s is too large.\n", dirptr, mountpoints[i]);
return false; return false;
} }
strcpy(buf, dirptr); strcpy(buf, dirptr);
strcat(buf, mountpoints[i]); strcat(buf, mountpoints[i]);
if (!isdir(buf)) { if (!isdir(buf)) {
if (!ignore_missing) { if (ignore_missing)
ERROR("error: source mount dir %s does not exists.\n", buf);
return false;
} else
continue; continue;
ERROR("error: source mount dir %s does not exists.\n", buf);
return false;
} }
if (!isdir(mountpoints[i])) { if (!isdir(mountpoints[i])) {
ERROR("error: mountpoint %s does not exists.\n", 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. */ /* Mount stuff from altroot to our private namespace. */
const char *mountpoints[] = {"/usr", "/var/db/xbps", "/etc/xbps.d"}; const char *mountpoints[] = {"/usr", "/var/db/xbps", "/etc/xbps.d"};
if (!mountlist(dir, dirlen, mountpoints, ARRAY_SIZE(mountpoints), true))
if (!mount_list(dir, dirlen, mountpoints, ARRAY_SIZE(mountpoints), true))
return 1; return 1;
if (usermounts_count > 0 && if (usermounts_count > 0 &&
!mount_list(dir, dirlen, usermounts, usermounts_count, false)) !mountlist(dir, dirlen, usermounts, usermounts_count, false))
return 1; return 1;
/* Drop root. */ /* Drop root. */