mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 08:56:15 +09:00
ioprio-util: move from basic/ to shared/
It is not used by libsystemd.
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "ioprio-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "string-table.h"
|
||||
|
||||
int ioprio_parse_priority(const char *s, int *ret) {
|
||||
int i, r;
|
||||
|
||||
assert(s);
|
||||
assert(ret);
|
||||
|
||||
r = safe_atoi(s, &i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!ioprio_priority_is_valid(i))
|
||||
return -EINVAL;
|
||||
|
||||
*ret = i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *const ioprio_class_table[] = {
|
||||
[IOPRIO_CLASS_NONE] = "none",
|
||||
[IOPRIO_CLASS_RT] = "realtime",
|
||||
[IOPRIO_CLASS_BE] = "best-effort",
|
||||
[IOPRIO_CLASS_IDLE] = "idle",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, IOPRIO_NR_CLASSES-1);
|
||||
@@ -1,40 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <linux/ioprio.h> /* IWYU pragma: export */
|
||||
|
||||
#include "forward.h"
|
||||
|
||||
static inline int ioprio_prio_class(int value) {
|
||||
return IOPRIO_PRIO_CLASS(value);
|
||||
}
|
||||
|
||||
static inline int ioprio_prio_data(int value) {
|
||||
return IOPRIO_PRIO_DATA(value);
|
||||
}
|
||||
|
||||
static inline int ioprio_prio_value(int class, int data) {
|
||||
return IOPRIO_PRIO_VALUE_HINT(class, IOPRIO_PRIO_LEVEL(data), IOPRIO_PRIO_HINT(data));
|
||||
}
|
||||
|
||||
int ioprio_class_to_string_alloc(int i, char **s);
|
||||
int ioprio_class_from_string(const char *s);
|
||||
|
||||
static inline bool ioprio_class_is_valid(int i) {
|
||||
return IN_SET(i, IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE);
|
||||
}
|
||||
|
||||
static inline bool ioprio_priority_is_valid(int i) {
|
||||
return i >= 0 && i < IOPRIO_NR_LEVELS;
|
||||
}
|
||||
|
||||
int ioprio_parse_priority(const char *s, int *ret);
|
||||
|
||||
/* IOPRIO_CLASS_NONE with any prio value is another way to say IOPRIO_CLASS_BE with level 4. Encode that in a
|
||||
* proper macro. */
|
||||
#define IOPRIO_DEFAULT_CLASS_AND_PRIO ioprio_prio_value(IOPRIO_CLASS_BE, 4)
|
||||
|
||||
static inline int ioprio_normalize(int v) {
|
||||
/* Converts IOPRIO_CLASS_NONE to what it actually means */
|
||||
return ioprio_prio_class(v) == IOPRIO_CLASS_NONE ? IOPRIO_DEFAULT_CLASS_AND_PRIO : v;
|
||||
}
|
||||
@@ -52,7 +52,6 @@ basic_sources = files(
|
||||
'initrd-util.c',
|
||||
'inotify-util.c',
|
||||
'io-util.c',
|
||||
'ioprio-util.c',
|
||||
'iovec-util.c',
|
||||
'iovec-wrapper.c',
|
||||
'label.c',
|
||||
|
||||
Reference in New Issue
Block a user