summaryrefslogtreecommitdiff
path: root/tools-util.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-01-08 00:13:18 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2017-01-20 09:07:08 -0900
commitb33fc8298f7e13226b9895abc57c9bfce5e3fa2d (patch)
treea3d2a5a909b6372f7777c1c5c18cef5f81d123a9 /tools-util.h
parent7f4191a202ea4558ca2d5eb8a47daea33c9999c7 (diff)
bcache in userspace; userspace fsck
Diffstat (limited to 'tools-util.h')
-rw-r--r--tools-util.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/tools-util.h b/tools-util.h
new file mode 100644
index 0000000..5c8ea13
--- /dev/null
+++ b/tools-util.h
@@ -0,0 +1,64 @@
+#ifndef _TOOLS_UTIL_H
+#define _TOOLS_UTIL_H
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include <linux/byteorder.h>
+#include <linux/kernel.h>
+#include <linux/log2.h>
+#include <linux/string.h>
+#include <linux/types.h>
+
+#define die(arg, ...) \
+do { \
+ fprintf(stderr, arg "\n", ##__VA_ARGS__); \
+ exit(EXIT_FAILURE); \
+} while (0)
+
+enum units {
+ BYTES,
+ SECTORS,
+ HUMAN_READABLE,
+};
+
+struct units_buf pr_units(u64, enum units);
+
+struct units_buf {
+ char b[20];
+};
+
+long strtoul_or_die(const char *, size_t, const char *);
+
+u64 hatoi(const char *);
+unsigned hatoi_validate(const char *, const char *);
+unsigned nr_args(char * const *);
+
+char *read_file_str(int, const char *);
+u64 read_file_u64(int, const char *);
+
+ssize_t read_string_list(const char *, const char * const[]);
+ssize_t read_string_list_or_die(const char *, const char * const[],
+ const char *);
+void print_string_list(const char * const[], size_t);
+
+u64 get_size(const char *, int);
+unsigned get_blocksize(const char *, int);
+
+#include "linux/bcache.h"
+#include "linux/bcache-ioctl.h"
+
+int bcachectl_open(void);
+
+struct bcache_handle {
+ int ioctl_fd;
+ int sysfs_fd;
+};
+
+struct bcache_handle bcache_fs_open(const char *);
+
+bool ask_proceed(void);
+
+#endif /* _TOOLS_UTIL_H */