Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
bees
0001-fs-fix-FIEMAP_MAX_OFFSET-type-silliness-in...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-fs-fix-FIEMAP_MAX_OFFSET-type-silliness-in-fiemap.h.patch of Package bees
From 12e80658a8cfb5dc1d8676e3696681ad32fab552 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell <bees@furryterror.org> Date: Wed, 6 Oct 2021 15:05:28 -0400 Subject: [PATCH] fs: fix FIEMAP_MAX_OFFSET type silliness in fiemap.h In fiemap.h the members of struct fiemap are declared as __u64, but the FIEMAP_MAX_OFFSET macro is an unsigned long long value: $ grep FIEMAP_MAX_OFFSET -r /usr/include/ /usr/include/linux/fiemap.h:#define FIEMAP_MAX_OFFSET (~0ULL) $ grep fe_length -r /usr/include/ /usr/include/linux/fiemap.h: __u64 fe_length; /* length in bytes for this extent */ This results in a type mismatch error on architectures like ppc64le: fiemap.cc:31:35: note: deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int') 31 | fm.fm_length = min(fm.fm_length, FIEMAP_MAX_OFFSET - fm.fm_start); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Work around this by copying the macro into a uint64_t constant, and not using the macro any more. Fixes: https://github.com/Zygo/bees/issues/194 Signed-off-by: Zygo Blaxell <bees@furryterror.org> --- include/crucible/fs.h | 6 +++++- src/fiemap.cc | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/crucible/fs.h b/include/crucible/fs.h index fcd61e055197..dae574015f8c 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -143,8 +143,12 @@ namespace crucible { struct Fiemap : public fiemap { + // because fiemap.h insists on giving FIEMAP_MAX_OFFSET + // a different type from the struct fiemap members + static const uint64_t s_fiemap_max_offset = FIEMAP_MAX_OFFSET; + // Get entire file - Fiemap(uint64_t start = 0, uint64_t length = FIEMAP_MAX_OFFSET); + Fiemap(uint64_t start = 0, uint64_t length = s_fiemap_max_offset); void do_ioctl(int fd); diff --git a/src/fiemap.cc b/src/fiemap.cc index 1618d3b04308..fb6085ac9738 100644 --- a/src/fiemap.cc +++ b/src/fiemap.cc @@ -28,13 +28,13 @@ main(int argc, char **argv) if (argc > 2) { fm.fm_start = stoull(argv[2], nullptr, 0); } if (argc > 3) { fm.fm_length = stoull(argv[3], nullptr, 0); } if (argc > 4) { fm.fm_flags = stoull(argv[4], nullptr, 0); } - fm.fm_length = min(fm.fm_length, FIEMAP_MAX_OFFSET - fm.fm_start); + fm.fm_length = min(fm.fm_length, Fiemap::s_fiemap_max_offset - fm.fm_start); uint64_t stop_at = fm.fm_start + fm.fm_length; uint64_t last_byte = fm.fm_start; do { fm.do_ioctl(fd); // cerr << fm; - uint64_t last_logical = FIEMAP_MAX_OFFSET; + uint64_t last_logical = Fiemap::s_fiemap_max_offset; for (auto &extent : fm.m_extents) { if (extent.fe_logical > last_byte) { cout << "Log " << to_hex(last_byte) << ".." << to_hex(extent.fe_logical) << " Hole" << endl; -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor