From ccd8dcd43f0c903a94367817a0a9e94034a5cce4 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Thu, 4 Nov 2021 01:48:53 -0400 Subject: [PATCH] fiemap, fiewalk: drop dead example/test code These tools are obsolete. fiemap was a thin wrapper around FIEMAP, but FIEMAP is not useful on btrfs. fiewalk was a thin wrapper around BtrfsExtentWalker, but development on BtrfsExtentWalker has been abandoned. Signed-off-by: Zygo Blaxell --- src/Makefile | 12 +---------- src/fiemap.cc | 55 -------------------------------------------------- src/fiewalk.cc | 40 ------------------------------------ 3 files changed, 1 insertion(+), 106 deletions(-) delete mode 100644 src/fiemap.cc delete mode 100644 src/fiewalk.cc diff --git a/src/Makefile b/src/Makefile index b0d5367..997b8c8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,11 +1,6 @@ BEES = ../bin/bees -PROGRAMS = \ - ../bin/fiemap \ - ../bin/fiewalk \ -PROGRAM_OBJS = $(foreach b,$(PROGRAMS),$(patsubst ../bin/%,%.o,$(b))) - -all: $(BEES) $(PROGRAMS) +all: $(BEES) include ../makeflags -include ../localconf @@ -51,11 +46,6 @@ include depends.mk %.o: %.cc ../makeflags $(CXX) $(BEES_CXXFLAGS) -o $@ -c $< -$(PROGRAMS): ../bin/%: %.o - $(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $< $(LIBS) - -$(PROGRAMS): ../lib/libcrucible.a - $(BEES): $(BEES_OBJS) bees-version.o bees-usage.o ../lib/libcrucible.a $(CXX) $(BEES_CXXFLAGS) $(BEES_LDFLAGS) -o $@ $^ $(LIBS) diff --git a/src/fiemap.cc b/src/fiemap.cc deleted file mode 100644 index 2a2c0cf..0000000 --- a/src/fiemap.cc +++ /dev/null @@ -1,55 +0,0 @@ -#include "crucible/fd.h" -#include "crucible/fs.h" -#include "crucible/error.h" -#include "crucible/string.h" - -#include - -#include -#include -#include - -using namespace crucible; -using namespace std; - -int -main(int argc, char **argv) -{ - catch_all([&]() { - THROW_CHECK1(invalid_argument, argc, argc > 1); - string filename = argv[1]; - - - cout << "File: " << filename << endl; - Fd fd = open_or_die(filename, O_RDONLY); - uint64_t start = 0; - uint64_t length = Fiemap::s_fiemap_max_offset; - if (argc > 2) { start = stoull(argv[2], nullptr, 0); } - if (argc > 3) { length = stoull(argv[3], nullptr, 0); } - length = min(length, Fiemap::s_fiemap_max_offset - start); - Fiemap fm(start, length); - fm.m_flags &= ~(FIEMAP_FLAG_SYNC); - fm.m_max_count = 100; - if (argc > 4) { fm.m_flags = stoull(argv[4], nullptr, 0); } - uint64_t stop_at = start + length; - uint64_t last_byte = start; - do { - fm.do_ioctl(fd); - // cerr << fm; - 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; - } - cout << "Log " << to_hex(extent.fe_logical) << ".." << to_hex(extent.fe_logical + extent.fe_length) - << " Phy " << to_hex(extent.fe_physical) << ".." << to_hex(extent.fe_physical + extent.fe_length) - << " Flags " << fiemap_extent_flags_ntoa(extent.fe_flags) << endl; - last_logical = extent.fe_logical + extent.fe_length; - last_byte = last_logical; - } - fm.m_start = last_logical; - } while (fm.m_start < stop_at); - }); - exit(EXIT_SUCCESS); -} - diff --git a/src/fiewalk.cc b/src/fiewalk.cc deleted file mode 100644 index 91b906b..0000000 --- a/src/fiewalk.cc +++ /dev/null @@ -1,40 +0,0 @@ -#include "crucible/extentwalker.h" -#include "crucible/error.h" -#include "crucible/string.h" - -#include - -#include -#include - -using namespace crucible; -using namespace std; - -int -main(int argc, char **argv) -{ - catch_all([&]() { - THROW_CHECK1(invalid_argument, argc, argc > 1); - string filename = argv[1]; - - cout << "File: " << filename << endl; - Fd fd = open_or_die(filename, O_RDONLY); - BtrfsExtentWalker ew(fd); - off_t pos = 0; - if (argc > 2) { pos = stoull(argv[2], nullptr, 0); } - ew.seek(pos); - do { - // cout << "\n\n>>>" << ew.current() << "<<<\n\n" << endl; - cout << ew.current() << endl; - } while (ew.next()); -#if 0 - cout << "\n\n\nAnd now, backwards...\n\n\n" << endl; - do { - cout << "\n\n>>>" << ew.current() << "<<<\n\n" << endl; - } while (ew.prev()); - cout << "\n\n\nDone!\n\n\n" << endl; -#endif - }); - exit(EXIT_SUCCESS); -} -