Lines Matching full:fiemap
28 #include <linux/fiemap.h>
47 std::unique_ptr<struct fiemap> path_fiemap(const std::string &path, uint32_t extent_count);
48 bool check_fiemap(const struct fiemap &fiemap, const std::string &path);
49 std::unique_ptr<struct fiemap> alloc_fiemap(uint32_t extent_count);
99 auto fiemap = path_fiemap(path, max_extents);
100 if (!fiemap || !check_fiemap(*fiemap, path)) {
112 for (uint32_t i = 0; i < fiemap->fm_mapped_extents; i++) {
114 range[0] = fiemap->fm_extents[i].fe_physical;
115 range[1] = fiemap->fm_extents[i].fe_length;
124 // Read the file's FIEMAP
125 std::unique_ptr<struct fiemap> path_fiemap(const std::string &path, uint32_t extent_count)
136 auto fiemap = alloc_fiemap(extent_count);
137 if (ioctl(fd.get(), FS_IOC_FIEMAP, fiemap.get()) != 0) {
138 PLOG(ERROR) << "Unable to FIEMAP " << path;
141 auto mapped = fiemap->fm_mapped_extents;
147 return fiemap;
150 // Ensure that the FIEMAP covers the file and is OK to discard
151 bool check_fiemap(const struct fiemap &fiemap, const std::string &path) {
152 auto mapped = fiemap.fm_mapped_extents;
153 if (!(fiemap.fm_extents[mapped - 1].fe_flags & FIEMAP_EXTENT_LAST)) {
158 auto flags = fiemap.fm_extents[i].fe_flags;
167 std::unique_ptr<struct fiemap> alloc_fiemap(uint32_t extent_count)
169 size_t allocsize = offsetof(struct fiemap, fm_extents[extent_count]);
170 std::unique_ptr<struct fiemap> res(new (::operator new (allocsize)) struct fiemap);