aboutsummaryrefslogtreecommitdiffstats
path: root/tools-util.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-05-26 16:26:53 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-05-26 16:37:13 -0400
commite142c4ca01fe36a2936e1287e22e57c491b65109 (patch)
treec4e09812b2098f891bd8f6df9da659a8ae6eec4f /tools-util.c
parentfa7a74fcc8b3fdedb075cf2d04e70a20b326a632 (diff)
downloadbcachefs-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.c11
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);