]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/util.h
New upstream snapshot
[bcachefs-tools-debian] / libbcachefs / util.h
index 84ef4d6d36f62c31a62dcdc9efb1b5ec742a6cc1..e55407dc53249d1a93106cd9e4b37c9df74b523e 100644 (file)
@@ -18,9 +18,6 @@
 #include <linux/vmalloc.h>
 #include <linux/workqueue.h>
 
-#define PAGE_SECTOR_SHIFT      (PAGE_SHIFT - 9)
-#define PAGE_SECTORS           (1UL << PAGE_SECTOR_SHIFT)
-
 struct closure;
 
 #ifdef CONFIG_BCACHEFS_DEBUG
@@ -241,6 +238,7 @@ do {                                                                        \
 struct printbuf {
        char            *pos;
        char            *end;
+       unsigned        indent;
 };
 
 static inline size_t printbuf_remaining(struct printbuf *buf)
@@ -262,6 +260,27 @@ do {                                                                       \
                                 __VA_ARGS__);                          \
 } while (0)
 
+static inline void printbuf_indent_push(struct printbuf *buf, unsigned spaces)
+{
+       buf->indent += spaces;
+       while (spaces--)
+               pr_buf(buf, " ");
+}
+
+static inline void printbuf_indent_pop(struct printbuf *buf, unsigned spaces)
+{
+       buf->indent -= spaces;
+}
+
+static inline void printbuf_newline(struct printbuf *buf)
+{
+       unsigned i;
+
+       pr_buf(buf, "\n");
+       for (i = 0; i < buf->indent; i++)
+               pr_buf(buf, " ");
+}
+
 void bch_scnmemcpy(struct printbuf *, const char *, size_t);
 
 int bch2_strtoint_h(const char *, int *);
@@ -749,4 +768,13 @@ static inline int u8_cmp(u8 l, u8 r)
        return cmp_int(l, r);
 }
 
+#ifdef __KERNEL__
+static inline void uuid_unparse_lower(u8 *uuid, char *out)
+{
+       sprintf(out, "%plU", uuid);
+}
+#else
+#include <uuid/uuid.h>
+#endif
+
 #endif /* _BCACHEFS_UTIL_H */