check if umount is succesfull

tomb-status now quits only when tomb is really unmounted
This commit is contained in:
Jaromil 2011-01-13 22:35:32 +01:00
parent 505442c394
commit 542bcb1577
2 changed files with 30 additions and 12 deletions

View File

@ -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}
@ -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`"
@ -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

View File

@ -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>
@ -54,6 +59,7 @@ int main(int argc, char **argv) {
gboolean push_in = true;
char tomb_file[512];
char tooltip[256];
gtk_set_locale();
gtk_init(&argc, &argv);
@ -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();
@ -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;
@ -166,7 +175,12 @@ gboolean cb_close(GtkWidget *w, GdkEvent *e) {
execlp("tomb","tomb","-S","umount",mapper,(char*)NULL);
exit(1);
}
waitpid(cpid, &res, 0);
if(res==0) {
gtk_main_quit();
notify_uninit();
exit(0);
}
}
// callbacks right click