diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-01 20:18:33 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-01 22:13:03 -0400 |
commit | 87179c7a6e2a210ea57951d444a3055e883d08fa (patch) | |
tree | 3445e8b5d6724518cbc6f659f9d0b0ff59b08bfa /tools-util.h | |
parent | 2d7982de784b24e24baa20eee0a97dea451b8fa7 (diff) |
Update bcachefs sources to 33a60d9b05 bcachefs: Assorted fixes for clang
Diffstat (limited to 'tools-util.h')
-rw-r--r-- | tools-util.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools-util.h b/tools-util.h index aa7c0270..e7bdd2c3 100644 --- a/tools-util.h +++ b/tools-util.h @@ -115,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; }; @@ -125,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) \ |