udev: String substitutions can be done in ENV, too
[systemd_ALT.git] / src / basic / ioprio-util.c
blobb63650b80b2aae49827d4338674074cdc9d55483
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 #include "ioprio-util.h"
4 #include "parse-util.h"
5 #include "string-table.h"
7 int ioprio_parse_priority(const char *s, int *ret) {
8 int i, r;
10 assert(s);
11 assert(ret);
13 r = safe_atoi(s, &i);
14 if (r < 0)
15 return r;
17 if (!ioprio_priority_is_valid(i))
18 return -EINVAL;
20 *ret = i;
21 return 0;
24 static const char *const ioprio_class_table[] = {
25 [IOPRIO_CLASS_NONE] = "none",
26 [IOPRIO_CLASS_RT] = "realtime",
27 [IOPRIO_CLASS_BE] = "best-effort",
28 [IOPRIO_CLASS_IDLE] = "idle",
31 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, IOPRIO_N_CLASSES);