btrfs tools: share the helpers the twelve tools were repeating - #142
Draft
Yury-MonZon wants to merge 3 commits into
Draft
btrfs tools: share the helpers the twelve tools were repeating#142Yury-MonZon wants to merge 3 commits into
Yury-MonZon wants to merge 3 commits into
Conversation
current_subvol()/current_fsuuid() replace the bare `findmnt -nro FSROOT /` and `findmnt -nro UUID /` calls in create-profile, create-snapshot and migrate-profile. findmnt reads /proc/self/mountinfo, needs no privileges and is authoritative on a booted system, so it stays the first source; it cannot answer inside a chroot and reports the path recorded at mount time, so the helpers fall back to `btrfs subvolume show /` and `btrfs filesystem show /`, which resolve live. flipper-bls.sh keeps its own copy deliberately, since kernel-install hooks source it without flipper-btrfs.sh; the comment now says so.
stamp() replaces the four copies of `date +%Y-%m-%d_%H-%M-%S` that name snapshots, aside copies and ro sends: list-profiles keys KIND=old off that exact shape, so the format needs one definition. path_of_uuid() takes over send-snapshot's private parent_path_of body, putting the uuid -> path scan of `btrfs subvolume list` in the lib next to build_uuid_map.
Ten tools repeated the -d,--device line and three the -y,--yes line verbatim in their usage() text (btrfs-maintenance with a column of drift). HELP_YES/HELP_DEVICE hold them in flipper-btrfs.sh and the heredocs interpolate them, so the wording cannot diverge. migrate-profile spells its own out: its -y also decides what happens to conflicts, and its help column is wider.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small DRY passes over the twelve btrfs tools, no behaviour change intended.
current_subvol()/current_fsuuid()replace barefindmnt -nro FSROOT /andfindmnt -nro UUID /calls. findmnt stays the first source, since it needs no privileges and is authoritative on a booted
system, but it cannot answer inside a chroot and reports the path recorded at mount time, so the
helpers fall back to asking btrfs.
flipper-bls.shkeeps its own copy on purpose, becausekernel-install hooks source it without this lib.
stamp()replaces the four copies ofdate +%Y-%m-%d_%H-%M-%Sthat name snapshots, aside copies andro sends.
list-profilesclassifiesKIND=oldby matching that exact shape, so the format needs onedefinition rather than four.
path_of_uuid()takes oversend-snapshot's private uuid-to-path scan.HELP_YES/HELP_DEVICEhold the two option lines that ten tools repeated verbatim, so the wordingcannot drift.
migrate-profilespells its own out, since its-yalso decides what happens toconflicts.
as one branch on hardware across five builds; splitting preserved the final tree byte for byte.
Split out of the closed #141. Only the combined final state was run on hardware; each
commit parses and defines the helpers it uses, and the stack tip is byte-identical to what
was tested.