slitaz-tools rev 381
mountbox: add read-only status
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Aug 17 16:00:00 2009 +0200 (2009-08-17) |
parents | 648f7c61a977 |
children | e2afd816e6d3 |
files | lib/libmountbox tinyutils/mountbox |
line diff
1.1 --- a/lib/libmountbox Sat Aug 15 22:20:22 2009 +0200 1.2 +++ b/lib/libmountbox Mon Aug 17 16:00:00 2009 +0200 1.3 @@ -13,10 +13,17 @@ 1.4 Output commands: 1.5 list-mounted List all mounted devices in suitable GTK tree format. 1.6 list-umounted List all umounted in suitable GTK tree format. 1.7 + create-file Create an empty file with predefined size. 1.8 + add-old-crypto Create loop-eas device. 1.9 + remove-crypto Delete a crypto device. 1.10 1.11 GTKdialog boxes 1.12 mounted-fs-infos Display a mounted devices infos with actions. 1.13 - umounted-fs-infos Display a umounted devices infos with actions.\n" 1.14 + umounted-fs-infos Display a umounted devices infos with actions. 1.15 + remove-loop Confirmation box. 1.16 + new-file Parameter box for file creation. 1.17 + cryptomgr Manage crypto device with devmapper. 1.18 + add-crypto Pass phrase dialog.\n" 1.19 } 1.20 1.21 # Format df -h output for GTK tree. 1.22 @@ -79,9 +86,11 @@ 1.23 # 1.24 for dev in `df -h | grep ^/dev/ | cut -d " " -f 1` 1.25 do 1.26 + RO='read-only' 1.27 + mount | grep $dev | grep -q '(rw' && RO='' 1.28 RES=`df -h $dev | unwrap | grep ^$dev` 1.29 mounted_fs_data 1.30 - echo "$dev | $SIZE | $USED | $AVAILABLE | $PCT | $MOUNTED_ON" 1.31 + echo "$dev | $SIZE | $USED | $AVAILABLE | $PCT | $MOUNTED_ON | $RO" 1.32 done ;; 1.33 list-umounted) 1.34 # List all umounted fs found by: fdisk -l 1.35 @@ -185,7 +194,25 @@ 1.36 <input file icon=\"folder-open\"></input> 1.37 <action>pcmanfm $MOUNTED_ON &</action> 1.38 <action type=\"closewindow\">MOUNTED_DEVICE</action> 1.39 - </button> 1.40 + </button>" 1.41 +if mount | grep $MOUNTED_ON | grep -q '(rw'; then 1.42 + MOUNTED_DEVICE="$MOUNTED_DEVICE 1.43 + <button> 1.44 + <label>Remount read-only</label> 1.45 + <input file icon=\"redo\"></input> 1.46 + <action>mount -o remount,ro $MOUNTED_ON</action> 1.47 + <action type=\"closewindow\">MOUNTED_DEVICE</action> 1.48 + </button>" 1.49 +else 1.50 + MOUNTED_DEVICE="$MOUNTED_DEVICE 1.51 + <button> 1.52 + <label>Remount read-write</label> 1.53 + <input file icon=\"redo\"></input> 1.54 + <action>mount -o remount,rw $MOUNTED_ON</action> 1.55 + <action type=\"closewindow\">MOUNTED_DEVICE</action> 1.56 + </button>" 1.57 +fi 1.58 +MOUNTED_DEVICE="$MOUNTED_DEVICE 1.59 <button> 1.60 <label>Umount</label> 1.61 <input file icon=\"undo\"></input> 1.62 @@ -226,7 +253,14 @@ 1.63 1.64 <hbox> 1.65 <button> 1.66 - <label>Mount</label> 1.67 + <label>Mount read-only</label> 1.68 + <input file icon=\"edit-redo\"></input> 1.69 + <action>mkdir -p $MOUNT_POINT</action> 1.70 + <action>mount -r $DEVICE $MOUNT_POINT</action> 1.71 + <action type=\"closewindow\">MOUNTED_DEVICE</action> 1.72 + </button> 1.73 + <button> 1.74 + <label>Mount read-write</label> 1.75 <input file icon=\"edit-redo\"></input> 1.76 <action>mkdir -p $MOUNT_POINT</action> 1.77 <action>mount $DEVICE $MOUNT_POINT</action> 1.78 @@ -318,7 +352,7 @@ 1.79 <button> 1.80 <label>Enable</label> 1.81 <input file icon=\"add\"></input> 1.82 - <action>/usr/lib/slitaz/libmountbox add-loop</action> 1.83 + <action>losetup -o \$OFFSET \$(losetup -f) \$FILE</action> 1.84 <action>/usr/lib/slitaz/libmountbox loopmgr &</action> 1.85 <action type=\"closewindow\">LOOP_MANAGER</action> 1.86 </button> 1.87 @@ -368,9 +402,6 @@ 1.88 </vbox> 1.89 </window>" 1.90 gtkdialog --center --program=REMOVE_DEVICE ;; 1.91 - add-loop) 1.92 - losetup -o $OFFSET $(losetup -f) $FILE 1.93 - ;; 1.94 create-file) 1.95 file=$2 1.96 size=$3 1.97 @@ -512,8 +543,12 @@ 1.98 DEV=/dev/dm-$(ls -l /dev/mapper/$name | awk '{ print $6 }') 1.99 MOUNT=$(mount | egrep "^$DEV|/dev/mapper/$name" | awk '{ print $3 }') 1.100 getdevinfo $DEV 1.101 + case "$name" in 1.102 + *crypto*) item="item icon=\"passwd\"";; 1.103 + *) item="item icon=\"drive-harddisk\"";; 1.104 + esac 1.105 CRYPTO_MANAGER="$CRYPTO_MANAGER 1.106 - <item>$name|$DEV | $SIZE | $TYPE | $LABEL | $MOUNT | $UUID</item> 1.107 + <$item>$name|$DEV | $SIZE | $TYPE | $LABEL | $MOUNT | $UUID</item> 1.108 " 1.109 done <<EOT 1.110 $(ls /dev/mapper 2> /dev/null)
2.1 --- a/tinyutils/mountbox Sat Aug 15 22:20:22 2009 +0200 2.2 +++ b/tinyutils/mountbox Mon Aug 17 16:00:00 2009 +0200 2.3 @@ -63,7 +63,7 @@ 2.4 <tree> 2.5 <width>520</width><height>120</height> 2.6 <variable>MOUNTED</variable> 2.7 - <label>Mounted fs|Size|Used|Available|Use%|Mounted on</label>' 2.8 + <label>Mounted fs|Size|Used|Available|Use%|Mounted on|Option</label>' 2.9 2.10 # /dev/root 2.11 RES=`df -h / | grep rootfs` 2.12 @@ -152,7 +152,6 @@ 2.13 <label>Crypto</label> 2.14 <input file icon="passwd"></input> 2.15 <action>/usr/lib/slitaz/libmountbox cryptomgr</action> 2.16 - <action>refresh:MOUNTED</action> 2.17 <action>refresh:DEVICE</action> 2.18 </button> 2.19 <button help>