diff options
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) \ |