diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-12-08 21:37:12 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-12-12 14:07:48 +0100 |
commit | b40c8ebdc86b61df03207865b5a75cd37900ea4c (patch) | |
tree | dc4cdcb9109f6e52be7347a4ece4f47a55481e9c /src/libsystemd | |
parent | man: mention that sd_id128_get_boot() and friend may return -ENOSYS (diff) | |
download | systemd-b40c8ebdc86b61df03207865b5a75cd37900ea4c.tar.xz systemd-b40c8ebdc86b61df03207865b5a75cd37900ea4c.zip |
sd-id128: fold do_sync flag into Id128FormatFlag
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-id128/id128-util.c | 8 | ||||
-rw-r--r-- | src/libsystemd/sd-id128/id128-util.h | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/libsystemd/sd-id128/id128-util.c b/src/libsystemd/sd-id128/id128-util.c index 2cf8848981..3395ba2e58 100644 --- a/src/libsystemd/sd-id128/id128-util.c +++ b/src/libsystemd/sd-id128/id128-util.c @@ -109,7 +109,7 @@ int id128_read(const char *p, Id128FormatFlag f, sd_id128_t *ret) { return id128_read_fd(fd, f, ret); } -int id128_write_fd(int fd, Id128FormatFlag f, sd_id128_t id, bool do_sync) { +int id128_write_fd(int fd, Id128FormatFlag f, sd_id128_t id) { char buffer[SD_ID128_UUID_STRING_MAX + 1]; /* +1 is for trailing newline */ size_t sz; int r; @@ -130,7 +130,7 @@ int id128_write_fd(int fd, Id128FormatFlag f, sd_id128_t id, bool do_sync) { if (r < 0) return r; - if (do_sync) { + if (FLAGS_SET(f, ID128_SYNC_ON_WRITE)) { r = fsync_full(fd); if (r < 0) return r; @@ -139,14 +139,14 @@ int id128_write_fd(int fd, Id128FormatFlag f, sd_id128_t id, bool do_sync) { return 0; } -int id128_write(const char *p, Id128FormatFlag f, sd_id128_t id, bool do_sync) { +int id128_write(const char *p, Id128FormatFlag f, sd_id128_t id) { _cleanup_close_ int fd = -1; fd = open(p, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY|O_TRUNC, 0444); if (fd < 0) return -errno; - return id128_write_fd(fd, f, id, do_sync); + return id128_write_fd(fd, f, id); } void id128_hash_func(const sd_id128_t *p, struct siphash *state) { diff --git a/src/libsystemd/sd-id128/id128-util.h b/src/libsystemd/sd-id128/id128-util.h index bb237cb6cc..4b91a16bd1 100644 --- a/src/libsystemd/sd-id128/id128-util.h +++ b/src/libsystemd/sd-id128/id128-util.h @@ -14,13 +14,15 @@ typedef enum Id128FormatFlag { ID128_FORMAT_PLAIN = 1 << 0, /* formatted as 32 hex chars as-is */ ID128_FORMAT_UUID = 1 << 1, /* formatted as 36 character uuid string */ ID128_FORMAT_ANY = ID128_FORMAT_PLAIN | ID128_FORMAT_UUID, + + ID128_SYNC_ON_WRITE = 1 << 2, /* Sync the file after write. Used only when writing an ID. */ } Id128FormatFlag; int id128_read_fd(int fd, Id128FormatFlag f, sd_id128_t *ret); int id128_read(const char *p, Id128FormatFlag f, sd_id128_t *ret); -int id128_write_fd(int fd, Id128FormatFlag f, sd_id128_t id, bool do_sync); -int id128_write(const char *p, Id128FormatFlag f, sd_id128_t id, bool do_sync); +int id128_write_fd(int fd, Id128FormatFlag f, sd_id128_t id); +int id128_write(const char *p, Id128FormatFlag f, sd_id128_t id); void id128_hash_func(const sd_id128_t *p, struct siphash *state); int id128_compare_func(const sd_id128_t *a, const sd_id128_t *b) _pure_; |