tdocumentation for the new resize command - tomb - the crypto undertaker
 (HTM) git clone git://parazyd.org/tomb.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f645bc59e187dc44f155cec0953cd78fca643884
 (DIR) parent c72acdeaa9a40b7cf0acba179e8340dba16ad44e
 (HTM) Author: Jaromil <jaromil@dyne.org>
       Date:   Tue, 17 Jan 2012 12:36:41 +0100
       
       documentation for the new resize command
       
       along with some small fixes
       
       Diffstat:
         M doc/tomb.1                          |      12 ++++++++++--
         M src/tomb                            |      13 ++++++++-----
       
       2 files changed, 18 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/doc/tomb.1 b/doc/tomb.1
       t@@ -73,6 +73,14 @@ argument\fR. It will need the old password to decode the key file, it
        will then reencode it using the new password.
        
        .B
       +.IP "resize"
       +Increase the size of a tomb file to the amount of megabytes specified
       +by the \fI-s\fI option (total amount of the new size). Tombs cannot be
       +made smaller with this command, only bigger. This command makes use of
       +the cryptsetup resize feature and the resize2fs command, hence it
       +supports only tombs formatted with an EXT filesystem.
       +
       +.B
        .IP "slam"
        Closes a tomb like the command \fIclose\fR does, but in case it is in
        use looks for all the processes accessing its files and violently
       t@@ -97,8 +105,8 @@ given. This is used to recoved buried keys from unsuspected places.
        .B
        .B
        .IP "-s \fI<MBytes>\fR" 
       -When creating a tomb, this option  MUST be used to specify the size of
       -the new \fIfile\fR to be created, in megabytes.
       +When creating or resizing a tomb, this option MUST be used to specify
       +the size of the new \fIfile\fR to be created, in megabytes.
        .B
        .IP "-k \fI<keyfile>\fR"
        When opening a  tomb, this option can be used  to specify the location
 (DIR) diff --git a/src/tomb b/src/tomb
       t@@ -1145,6 +1145,7 @@ change_passwd() {
        # {{{ - Resize
        # resize tomb file size
        resize_tomb() {
       +    _message "Commanded to resize tomb $CMD2 to $opts[-s] megabytes"
            if ! [ ${CMD2} ]; then
                _failure "No tomb name specified for resizing"
            elif ! [ -r "${CMD2}" ]; then
       t@@ -1181,11 +1182,11 @@ resize_tomb() {
            local tmp_resize=`safe_filename tmbrsz`
            local newtombsize=$opts[-s]
            local oldtombsize=`stat -c %s "${CMD2}" 2>/dev/null`
       -        local mounted_tomb=`mount -l |
       +    local mounted_tomb=`mount -l |
                awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 }'`
        
            if [ "$mounted_tomb" ]; then
       -        _failure "the tomb $tombname is mounted: to resize, umount it ('tomb close $tombname' is your friend)."
       +        _failure "the tomb $tombname is open, to resize it it needs to be close."
            fi
        
            # MB to bytes conversion
       t@@ -1208,13 +1209,13 @@ resize_tomb() {
            "$DD" if=/dev/urandom bs=4k count=${tombsize_4k} of="${tmp_resize}"
        
            if [ $? = 0 -a -e "${tmp_resize}" ]; then
       -            act "OK: `ls -lh ${tmp_resize}`"
       +        xxx "OK: `ls -lh ${tmp_resize}`"
            else
       -            _failure "Error creating the extra resize $tmp_resize, operation aborted."
       +        _failure "Error creating the extra resize $tmp_resize, operation aborted."
            fi
            
            cat "${tmp_resize}" >> "${CMD2}"
       -    "${WIPE}" "${tmp_resize}"
       +    ${=WIPE} "${tmp_resize}"
            
            local nstloop=`losetup -f`
            if [ $? = 255 ]; then
       t@@ -1266,6 +1267,8 @@ resize_tomb() {
                _failure "resize2fs failed to resize $mapper"
            fi
        
       +    sleep 1 # needs to settle a bit
       +
            # close and free the loop device
            cryptsetup luksClose "${mapper}"
            losetup -d ${nstloop}