summaryrefslogtreecommitdiff
path: root/src/volatile-root
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-16 15:27:21 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-17 09:13:35 +0100
commit51e237864221f3edb0c0fb28684901f538341cb1 (patch)
tree95c588aba3e3d1f6a110d8559a2699523370074e /src/volatile-root
parent0420d20dd259278d6df3e06140870713c248a0dd (diff)
downloadsystemd-51e237864221f3edb0c0fb28684901f538341cb1.tar.gz
volatile-root: define main through macro
Diffstat (limited to 'src/volatile-root')
-rw-r--r--src/volatile-root/volatile-root.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/volatile-root/volatile-root.c b/src/volatile-root/volatile-root.c
index bc786c9734..ab7dca37b1 100644
--- a/src/volatile-root/volatile-root.c
+++ b/src/volatile-root/volatile-root.c
@@ -76,7 +76,7 @@ finish_rmdir:
return r;
}
-int main(int argc, char *argv[]) {
+static int run(int argc, char *argv[]) {
VolatileMode m = _VOLATILE_MODE_INVALID;
const char *path;
int r;
@@ -87,22 +87,18 @@ int main(int argc, char *argv[]) {
if (argc > 3) {
log_error("Too many arguments. Expected directory and mode.");
- r = -EINVAL;
- goto finish;
+ return -EINVAL;
}
r = query_volatile_mode(&m);
- if (r < 0) {
- log_error_errno(r, "Failed to determine volatile mode from kernel command line.");
- goto finish;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to determine volatile mode from kernel command line.");
if (r == 0 && argc >= 2) {
/* The kernel command line always wins. However if nothing was set there, the argument passed here wins instead. */
m = volatile_mode_from_string(argv[1]);
if (m < 0) {
log_error("Couldn't parse volatile mode: %s", argv[1]);
r = -EINVAL;
- goto finish;
}
}
@@ -113,28 +109,22 @@ int main(int argc, char *argv[]) {
if (isempty(path)) {
log_error("Directory name cannot be empty.");
- r = -EINVAL;
- goto finish;
+ return -EINVAL;
}
if (!path_is_absolute(path)) {
log_error("Directory must be specified as absolute path.");
- r = -EINVAL;
- goto finish;
+ return -EINVAL;
}
if (path_equal(path, "/")) {
log_error("Directory cannot be the root directory.");
- r = -EINVAL;
- goto finish;
+ return -EINVAL;
}
}
- if (m != VOLATILE_YES) {
- r = 0;
- goto finish;
- }
-
- r = make_volatile(path);
+ if (m != VOLATILE_YES)
+ return 0;
-finish:
- return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ return make_volatile(path);
}
+
+DEFINE_MAIN_FUNCTION(run);