diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-05-26 16:26:53 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-05-26 16:37:13 -0400 |
commit | e142c4ca01fe36a2936e1287e22e57c491b65109 (patch) | |
tree | c4e09812b2098f891bd8f6df9da659a8ae6eec4f /tools-util.c | |
parent | fa7a74fcc8b3fdedb075cf2d04e70a20b326a632 (diff) | |
download | bcachefs-tools-e142c4ca01fe36a2936e1287e22e57c491b65109.tar.gz |
New subcommand: set-option
This is for setting superblock options on existing filesystems, either
online or offline.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'tools-util.c')
-rw-r--r-- | tools-util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools-util.c b/tools-util.c index baf24ae5..f29d2026 100644 --- a/tools-util.c +++ b/tools-util.c @@ -128,6 +128,17 @@ struct stat xstat(const char *path) /* File parsing (i.e. sysfs) */ +void write_file_str(int dirfd, const char *path, const char *str) +{ + int fd = xopenat(dirfd, path, O_WRONLY); + ssize_t wrote, len = strlen(str); + + wrote = write(fd, str, len); + if (wrote != len) + die("read error: %m"); + close(fd); +} + char *read_file_str(int dirfd, const char *path) { int fd = xopenat(dirfd, path, O_RDONLY); |