tcheck if umount is succesfull tomb-status now quits only when tomb is really unmounted - tomb - the crypto undertaker
 (HTM) git clone git://parazyd.org/tomb.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 542bcb15774c3a6b86a12f5462c4d275ae8721bb
 (DIR) parent 505442c394ed3cdeaece2b9b37e2317433a1f70a
 (HTM) Author: Jaromil <jaromil@dyne.org>
       Date:   Thu, 13 Jan 2011 22:35:32 +0100
       
       check if umount is succesfull
       ttomb-status now quits only when tomb is really unmounted
       
       Diffstat:
         M src/tomb                            |      22 +++++++++++++---------
         M src/tomb-status.cpp                 |      20 +++++++++++++++++---
       
       2 files changed, 30 insertions(+), 12 deletions(-)
       ---
 (DIR) diff --git a/src/tomb b/src/tomb
       t@@ -413,9 +413,9 @@ mount_tomb() {
            fi
            
            act "encrypted storage filesystem check"
       -    fsck.ext4 -p -C0 /dev/mapper/${mapper}
       +    fsck -p -C0 /dev/mapper/${mapper}
            
       -    mount -t ext4 -o rw,noatime,nodev /dev/mapper/${mapper} ${MOUNT}
       +    mount -o rw,noatime,nodev /dev/mapper/${mapper} ${MOUNT}
            
            notice "encrypted storage $FILE succesfully mounted on $MOUNT"
            exec_as_user tomb-status ${mapper} ${FILE} ${MOUNT}
       t@@ -466,17 +466,20 @@ umount_tomb() {
            #         exit 1
            # fi
        
       -    umount ${mapper}
       -    # if ! [ $? = 0 ]; then
       -    #         error "error occurred in umount ${mapper}"
       -    # fi
       -
            basemap=`basename $mapper`
       +    tombname=`echo ${basemap} | cut -d. -f2`
       +
       +    errno=`umount ${mapper}`
       +    if ! [ $? = 0 ]; then
       +        exec_as_user tomb-notify "Tomb '$tombname' is too busy." \
       +            "Close all applications and file managers, then try again."
       +        exit 1
       +    fi
        
            cryptsetup luksClose $basemap
            if ! [ $? = 0 ]; then
                error "error occurred in cryptsetup luksClose ${basemap}"
       -        exit 0
       +        exit 1
            fi
        
            losetup -d "/dev/`echo $basemap | cut -d. -f4`"
       t@@ -492,7 +495,8 @@ umount_tomb() {
            # fi
        
            notice "crypt storage ${mapper} unmounted"
       -    exec_as_user tomb-notify "Tomb closed: `echo ${basemap} | cut -d. -f2`" "Your bones will Rest In Peace."
       +    exec_as_user tomb-notify "Tomb closed: $tombname" "Your bones will Rest In Peace."
       +    exit 0
        }
        
        # install mime-types, bells and whistles for the desktop
 (DIR) diff --git a/src/tomb-status.cpp b/src/tomb-status.cpp
       t@@ -20,6 +20,11 @@
        #include <stdio.h>
        #include <stdlib.h>
        #include <unistd.h>
       +#include <string.h>
       +#include <libgen.h>
       +
       +#include <sys/types.h>
       +#include <sys/wait.h>
        
        #include <gtk/gtk.h>
        #include <libnotify/notify.h>
       t@@ -54,7 +59,8 @@ int main(int argc, char **argv) {
          gboolean push_in = true;
        
          char tomb_file[512];
       -  
       +  char tooltip[256];
       +
          gtk_set_locale();
          gtk_init(&argc, &argv);
        
       t@@ -81,7 +87,9 @@ int main(int argc, char **argv) {
          status_tomb = gtk_status_icon_new_from_pixbuf(pb_monmort);
          //  gtk_status_icon_set_name(status_tomb, "tomb");
          gtk_status_icon_set_title(status_tomb, "Tomb");
       -  gtk_status_icon_set_tooltip_text (status_tomb, "Tomb - crypto undertaker");
       +
       +  snprintf(tooltip,255,"Tomb in %s",mountpoint);
       +  gtk_status_icon_set_tooltip_text (status_tomb, tooltip);
        
          // LEFT click menu
          menu_left = (GtkMenu*) gtk_menu_new();
       t@@ -158,6 +166,7 @@ gboolean cb_view(GtkWidget *w, GdkEvent *e) {
        
        gboolean cb_close(GtkWidget *w, GdkEvent *e) { 
          pid_t cpid = fork();
       +  int res;
          if (cpid == -1) {
            fprintf(stderr,"error: problem forking process\n");
            return false;
       t@@ -166,7 +175,12 @@ gboolean cb_close(GtkWidget *w, GdkEvent *e) {
            execlp("tomb","tomb","-S","umount",mapper,(char*)NULL);
            exit(1);
          }
       -  gtk_main_quit();
       +  waitpid(cpid, &res, 0);
       +  if(res==0) {
       +    gtk_main_quit();
       +    notify_uninit();
       +    exit(0);
       +  }
        }
        
        // callbacks right click