X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fload-fragment.c;h=2e67eccc00bc1fe1e1e01a174cd053ed249ef6c2;hp=44b2cf06c115f88adb2e9d93052fed934ac93963;hb=4ce9faa9d283cbb4c46fd06138f6774579349fb7;hpb=ba035df230e41bf9d70ebb47915c9472b7884412 diff --git a/src/load-fragment.c b/src/load-fragment.c index 44b2cf06c..2e67eccc0 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -191,7 +191,6 @@ static int config_parse_listen( void *data, void *userdata) { - int r; SocketPort *p; Socket *s; @@ -217,7 +216,7 @@ static int config_parse_listen( } else { p->type = SOCKET_SOCKET; - if ((r = socket_address_parse(&p->address, rvalue)) < 0) { + if (socket_address_parse(&p->address, rvalue) < 0) { log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue); free(p); return 0; @@ -289,14 +288,14 @@ static int config_parse_nice( void *userdata) { ExecContext *c = data; - int priority, r; + int priority; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = safe_atoi(rvalue, &priority)) < 0) { + if (safe_atoi(rvalue, &priority) < 0) { log_error("[%s:%u] Failed to parse nice priority, ignoring: %s. ", filename, line, rvalue); return 0; } @@ -307,7 +306,7 @@ static int config_parse_nice( } c->nice = priority; - c->nice_set = false; + c->nice_set = true; return 0; } @@ -322,14 +321,14 @@ static int config_parse_oom_score_adjust( void *userdata) { ExecContext *c = data; - int oa, r; + int oa; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = safe_atoi(rvalue, &oa)) < 0) { + if (safe_atoi(rvalue, &oa) < 0) { log_error("[%s:%u] Failed to parse the OOM score adjust value, ignoring: %s", filename, line, rvalue); return 0; } @@ -506,14 +505,13 @@ static int config_parse_usec( void *userdata) { usec_t *usec = data; - int r; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = parse_usec(rvalue, usec)) < 0) { + if (parse_usec(rvalue, usec) < 0) { log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue); return 0; } @@ -893,14 +891,13 @@ static int config_parse_timer_slack_nsec( ExecContext *c = data; unsigned long u; - int r; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = safe_atolu(rvalue, &u)) < 0) { + if (safe_atolu(rvalue, &u) < 0) { log_error("[%s:%u] Failed to parse time slack value, ignoring: %s", filename, line, rvalue); return 0; } @@ -921,14 +918,13 @@ static int config_parse_limit( struct rlimit **rl = data; unsigned long long u; - int r; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = safe_atollu(rvalue, &u)) < 0) { + if (safe_atollu(rvalue, &u) < 0) { log_error("[%s:%u] Failed to parse resource value, ignoring: %s", filename, line, rvalue); return 0; } @@ -985,14 +981,14 @@ static int config_parse_sysv_priority( void *userdata) { int *priority = data; - int r, i; + int i; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) { + if (safe_atoi(rvalue, &i) < 0 || i < 0) { log_error("[%s:%u] Failed to parse SysV start priority, ignoring: %s", filename, line, rvalue); return 0; } @@ -1012,14 +1008,14 @@ static int config_parse_fsck_passno( void *userdata) { int *passno = data; - int r, i; + int i; assert(filename); assert(lvalue); assert(rvalue); assert(data); - if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) { + if (safe_atoi(rvalue, &i) || i < 0) { log_error("[%s:%u] Failed to parse fsck pass number, ignoring: %s", filename, line, rvalue); return 0; } @@ -1104,7 +1100,6 @@ static int config_parse_timer( Timer *t = data; usec_t u; - int r; TimerValue *v; TimerBase b; @@ -1118,7 +1113,7 @@ static int config_parse_timer( return 0; } - if ((r = parse_usec(rvalue, &u)) < 0) { + if (parse_usec(rvalue, &u) < 0) { log_error("[%s:%u] Failed to parse timer value, ignoring: %s", filename, line, rvalue); return 0; } @@ -1379,7 +1374,6 @@ static int config_parse_env_file( if (feof(f)) break; - r = -errno; log_error("[%s:%u] Failed to read environment file '%s', ignoring: %m", filename, line, rvalue); r = 0; goto finish; @@ -1431,7 +1425,6 @@ static int config_parse_ip_tos( void *userdata) { int *ip_tos = data, x; - int r; assert(filename); assert(lvalue); @@ -1439,7 +1432,7 @@ static int config_parse_ip_tos( assert(data); if ((x = ip_tos_from_string(rvalue)) < 0) - if ((r = safe_atoi(rvalue, &x)) < 0) { + if (safe_atoi(rvalue, &x) < 0) { log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue); return 0; } @@ -1510,6 +1503,34 @@ static int config_parse_condition_kernel( return 0; } +static int config_parse_condition_virt( + const char *filename, + unsigned line, + const char *section, + const char *lvalue, + const char *rvalue, + void *data, + void *userdata) { + + Unit *u = data; + bool negate; + Condition *c; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + if ((negate = rvalue[0] == '!')) + rvalue++; + + if (!(c = condition_new(CONDITION_VIRTUALIZATION, rvalue, negate))) + return -ENOMEM; + + LIST_PREPEND(Condition, conditions, u->meta.conditions, c); + return 0; +} + static int config_parse_condition_null( const char *filename, unsigned line, @@ -1721,6 +1742,7 @@ static void dump_items(FILE *f, const ConfigItem *items) { { config_parse_condition_path, "CONDITION" }, { config_parse_condition_kernel, "CONDITION" }, { config_parse_condition_null, "CONDITION" }, + { config_parse_condition_virt, "CONDITION" }, }; assert(f); @@ -1845,6 +1867,7 @@ static int load_from_path(Unit *u, const char *path) { { "ConditionPathExists", config_parse_condition_path, u, "Unit" }, { "ConditionDirectoryNotEmpty", config_parse_condition_path, u, "Unit" }, { "ConditionKernelCommandLine", config_parse_condition_kernel, u, "Unit" }, + { "ConditionVirtualization",config_parse_condition_virt, u, "Unit" }, { "ConditionNull", config_parse_condition_null, u, "Unit" }, { "PIDFile", config_parse_path, &u->service.pid_file, "Service" }, @@ -1861,6 +1884,7 @@ static int load_from_path(Unit *u, const char *path) { { "PermissionsStartOnly", config_parse_bool, &u->service.permissions_start_only, "Service" }, { "RootDirectoryStartOnly", config_parse_bool, &u->service.root_directory_start_only, "Service" }, { "RemainAfterExit", config_parse_bool, &u->service.remain_after_exit, "Service" }, + { "GuessMainPID", config_parse_bool, &u->service.guess_main_pid, "Service" }, #ifdef HAVE_SYSV_COMPAT { "SysVStartPriority", config_parse_sysv_priority, &u->service.sysv_start_priority, "Service" }, #else