]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - tools-util.h
New upstream release
[bcachefs-tools-debian] / tools-util.h
index d1122f5d1556d34970d5704c06dedb8eb832b583..e7bdd2c3ff50dd01536696be09676da35fece8c3 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/uuid.h>
+#include "libbcachefs/bcachefs.h"
+#include "libbcachefs/bbpos.h"
 #include "libbcachefs/darray.h"
 
 #define noreturn __attribute__((noreturn))
@@ -113,8 +115,7 @@ static inline struct range hole_iter_next(struct hole_iter *iter)
 #include <linux/fiemap.h>
 
 struct fiemap_iter {
-       struct fiemap           f;
-       struct fiemap_extent    fe[1024];
+       struct fiemap           *f;
        unsigned                idx;
        int                     fd;
 };
@@ -123,11 +124,20 @@ static inline void fiemap_iter_init(struct fiemap_iter *iter, int fd)
 {
        memset(iter, 0, sizeof(*iter));
 
-       iter->f.fm_extent_count = ARRAY_SIZE(iter->fe);
-       iter->f.fm_length       = FIEMAP_MAX_OFFSET;
+       iter->f = xmalloc(sizeof(struct fiemap) +
+                         sizeof(struct fiemap_extent) * 1024);
+
+       iter->f->fm_extent_count        = 1024;
+       iter->f->fm_length      = FIEMAP_MAX_OFFSET;
        iter->fd                = fd;
 }
 
+static inline void fiemap_iter_exit(struct fiemap_iter *iter)
+{
+       free(iter->f);
+       memset(iter, 0, sizeof(*iter));
+}
+
 struct fiemap_extent fiemap_iter_next(struct fiemap_iter *);
 
 #define fiemap_for_each(fd, iter, extent)                              \
@@ -159,5 +169,6 @@ do {                                                                        \
 })
 
 struct bpos bpos_parse(char *);
+struct bbpos bbpos_parse(char *);
 
 #endif /* _TOOLS_UTIL_H */