Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/btrfs compression #539

Merged
merged 2 commits into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions tomb
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ mount_tomb() {

_load_key # Try loading new key from option -k and set TOMBKEYFILE

tombmount="$2"
local tombmount="$2"
[[ -z "$tombmount" ]] && {
tombmount="/media/$TOMBNAME"
[[ -d /media ]] || { # no /media found, adopting /run/media/$USER (udisks2 compat)
Expand All @@ -2312,14 +2312,14 @@ mount_tomb() {

_message "This tomb is a valid LUKS encrypted device."

luksdump="`_sudo cryptsetup luksDump ${TOMBPATH}`"
tombdump=(`print $luksdump | awk '
local luksdump="`_sudo cryptsetup luksDump ${TOMBPATH}`"
local tombdump=(`print $luksdump | awk '
/^Cipher name/ {print $3}
/^Cipher mode/ {print $3}
/^Hash spec/ {print $3}'`)
_message "Cipher is \"::1 cipher::\" mode \"::2 mode::\" hash \"::3 hash::\"" $tombdump[1] $tombdump[2] $tombdump[3]

slotwarn=`print $luksdump | awk '
local slotwarn=`print $luksdump | awk '
BEGIN { zero=0 }
/^Key slot 0/ { zero=1 }
/^Key slot.*ENABLED/ { if(zero==1) print "WARN" }'`
Expand All @@ -2345,14 +2345,14 @@ mount_tomb() {
_failure "Failure mounting the encrypted file." }

# array: [ cipher, keysize, loopdevice ]
tombstat=(`_sudo cryptsetup status ${TOMBMAPPER} | awk '
local tombstat=(`_sudo cryptsetup status ${TOMBMAPPER} | awk '
/cipher:/ {print $2}
/keysize:/ {print $2}
/device:/ {print $2}'`)
_success "Success unlocking tomb ::1 tomb name::" $TOMBNAME
_verbose "Key size is ::1 size:: for cipher ::2 cipher::" $tombstat[2] $tombstat[1]

filesystem=`_detect_filesystem /dev/mapper/${TOMBMAPPER}`
local filesystem=`_detect_filesystem /dev/mapper/${TOMBMAPPER}`
_message "Filesystem detected: ::1 filesystem::" $filesystem
# TODO: check if FS is supported, else close luks

Expand Down Expand Up @@ -2383,10 +2383,18 @@ mount_tomb() {
_sudo mkdir -p "$tombmount"

# Default mount options are overridden with the -o switch
local oldmountopts
{ option_is_set -o } && {
local oldmountopts=$MOUNTOPTS
oldmountopts=$MOUNTOPTS
# TODO: safety check MOUNTOPTS coming from user
MOUNTOPTS="$(option_value -o)" }
# TODO: safety check MOUNTOPTS

# default btrfs compression zstd:1 (oportunistic according to pre-compression heuristics)
# see: https://btrfs.readthedocs.io/en/latest/Compression.html#pre-compression-heuristics
[[ "$filesystem" = "btrfs" ]] && {
MOUNTOPTS="$MOUNTOPTS,compress=zstd:1"
}

# safe_mount_options &&
_sudo mount -o $MOUNTOPTS /dev/mapper/${TOMBMAPPER} "${tombmount}"
# Clean up if the mount failed
Expand Down
Loading