slitaz-tools rev 368
mountbox: add devmapper support + misc fixes
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Aug 02 15:15:19 2009 +0200 (2009-08-02) |
parents | a54075776256 |
children | d3586136f92a |
files | lib/libmountbox tinyutils/mountbox |
line diff
1.1 --- a/lib/libmountbox Wed Jul 22 13:30:04 2009 +0000 1.2 +++ b/lib/libmountbox Sun Aug 02 15:15:19 2009 +0200 1.3 @@ -29,11 +29,27 @@ 1.4 MOUNTED_ON=`echo $RES | cut -d " " -f 6` 1.5 } 1.6 1.7 +# human readable size from 512 block count 1.8 +blocks2size() 1.9 +{ 1.10 + if [ $BLOCKS -gt 2097152 ]; then 1.11 + unit=G 1.12 + n=$(($1 * 10 / 2097152)) 1.13 + elif [ $BLOCKS -gt 2048 ]; then 1.14 + unit=M 1.15 + n=$(($1 * 10 / 2048)) 1.16 + else 1.17 + unit=K 1.18 + n=$(($1 * 5)) 1.19 + fi 1.20 + echo $(($n/10)).$(($n%10))$unit 1.21 +} 1.22 + 1.23 case $1 in 1.24 list-mounted) 1.25 # List all fs found by: df -h 1.26 # 1.27 - for dev in `df -h | grep ^/dev/[c-s]d | cut -d " " -f 1` 1.28 + for dev in `df -h | grep ^/dev/ | cut -d " " -f 1` 1.29 do 1.30 RES=`df -h $dev | grep ^$dev` 1.31 mounted_fs_data 1.32 @@ -50,9 +66,10 @@ 1.33 BLOCKS=`echo $RES | cut -d " " -f 4` 1.34 ID=`echo $RES | cut -d " " -f 5` 1.35 SYSTEM=`echo $RES | cut -d " " -f 6-` 1.36 + SIZE=$(blocks2size $BLOCKS) 1.37 # Bootable... 1.38 if fdisk -l | grep $dev | grep -q "*"; then 1.39 - BOOT="*" 1.40 + BOOT="yes" 1.41 else 1.42 BOOT="-" 1.43 fi 1.44 @@ -65,10 +82,23 @@ 1.45 UUID=`blkid | grep ^$dev | grep UUID= | sed 's/.*UUID=\"\([^\"]*\)\".*/\1/'` 1.46 TYPE=`blkid | grep ^$dev | grep TYPE= | sed 's/.*TYPE=\"\([^\"]*\)\".*/\1/'` 1.47 LABEL=`blkid | grep ^$dev | grep LABEL= | sed 's/.*LABEL=\"\([^\"]*\)\".*/\1/'` 1.48 - echo "$dev | $BOOT | $START | $END | $BLOCKS | $ID | $SYSTEM | $TYPE | $LABEL | $UUID" 1.49 + echo "$dev | $SIZE | $SYSTEM | $TYPE | $LABEL | $BOOT | $START | $END | $BLOCKS | $ID | $UUID" 1.50 fi 1.51 done 1.52 - echo "/dev/cdrom | - | - | - | CD/DVD | - | iso9660 | - | - | -" 1.53 + for dev in /dev/mapper/* ; do 1.54 + [ -b $dev ] || continue 1.55 + mount | grep -q "^$dev " && continue 1.56 + mdev=dm-$(ls -l $dev | awk '{ print $6 }') 1.57 + mount | grep -q "^/dev/$mdev " && continue 1.58 + BLOCKS=`cat /sys/block/$mdev/size` 1.59 + SIZE=$(blocks2size $BLOCKS) 1.60 + UUID=`blkid | grep ^/dev/$mdev: | grep UUID= | sed 's/.*UUID=\"\([^\"]*\)\".*/\1/'` 1.61 + TYPE=`blkid | grep ^/dev/$mdev: | grep TYPE= | sed 's/.*TYPE=\"\([^\"]*\)\".*/\1/'` 1.62 + LABEL=`blkid | grep ^/dev/$mdev: | grep LABEL= | sed 's/.*LABEL=\"\([^\"]*\)\".*/\1/'` 1.63 + echo "$dev | $SIZE | - | $TYPE | $LABEL | - | - | - | $BLOCKS | - | $UUID" 1.64 + done 1.65 + [ -e /dev/cdrom ] && 1.66 + echo "/dev/cdrom | - | CD/DVD | iso9660 | - | - | - | - | - | - | -" 1.67 for i in /sys/devices/platform/floppy.*/block:*; do 1.68 [ -e $i ] && echo "/dev/${i#*block:} | - | - | - | floppy | - | - | - | - | -" 1.69 done 1.70 @@ -148,9 +178,13 @@ 1.71 umounted-fs-infos) 1.72 # Mounted fs info and actions, rootfs or other fs. 1.73 # 1.74 - UUID=`blkid | grep ^$MOUNTED | grep UUID= | sed 's/.*UUID=\"\([^\"]*\)\".*/\1/'` 1.75 - TYPE=`blkid | grep ^$MOUNTED | grep TYPE= | sed 's/.*TYPE=\"\([^\"]*\)\".*/\1/'` 1.76 - LABEL=`blkid | grep ^$MOUNTED | grep LABEL= | sed 's/.*LABEL=\"\([^\"]*\)\".*/\1/'` 1.77 + case "$DEVICE" in 1.78 + /dev/mapper/*) mdev=/dev/dm-$(ls -l $DEVICE | awk '{ print $6 }');; 1.79 + *) mdev=$DEVICE;; 1.80 + esac 1.81 + UUID=`blkid | grep ^$mdev | grep UUID= | sed 's/.*UUID=\"\([^\"]*\)\".*/\1/'` 1.82 + TYPE=`blkid | grep ^$mdev | grep TYPE= | sed 's/.*TYPE=\"\([^\"]*\)\".*/\1/'` 1.83 + LABEL=`blkid | grep ^$mdev | grep LABEL= | sed 's/.*LABEL=\"\([^\"]*\)\".*/\1/'` 1.84 export UMOUNTED_DEVICE=" 1.85 <window title=\"Device: $DEVICE\" icon-name=\"media-flash\"> 1.86 <vbox> 1.87 @@ -172,19 +206,31 @@ 1.88 <action>mkdir -p $MOUNT_POINT</action> 1.89 <action>mount $DEVICE $MOUNT_POINT</action> 1.90 <action type=\"closewindow\">MOUNTED_DEVICE</action> 1.91 - </button> 1.92 - 1.93 + </button>" 1.94 +while read type fsck args; do 1.95 + [ "$TYPE" == "$type" ] || continue 1.96 + which $fsck > /dev/null || continue 1.97 +UMOUNTED_DEVICE="$UMOUNTED_DEVICE 1.98 <button> 1.99 - <label>e2fsck check</label> 1.100 + <label>$fsck check</label> 1.101 <input file icon=\"drive-harddisk\"></input> 1.102 - <action>xterm -T \"e2fsck -p $DEVICE\" \ 1.103 + <action>xterm -T \"$fsck $args $DEVICE\" \ 1.104 --geomery 80x12 \ 1.105 - -e \"echo; e2fsck -p $DEVICE; \ 1.106 + -e \"echo; $fsck $args $DEVICE; \ 1.107 echo -e '----\nENTER to close Termianl'; \ 1.108 read i\" &</action> 1.109 <action type=\"closewindow\">MOUNTED_DEVICE</action> 1.110 - </button> 1.111 - 1.112 + </button>" 1.113 +done <<EOT 1.114 +ext3 e2fsck -p 1.115 +ext2 e2fsck -p 1.116 +vfat dosfsck -a 1.117 +msdos dosfsck -a 1.118 +xfs fsck.xfs -s 1.119 +reiserfs reiserfsck --fix-fixable 1.120 +jfs jfs_fsck -a 1.121 +EOT 1.122 +UMOUNTED_DEVICE="$UMOUNTED_DEVICE 1.123 <button> 1.124 <input file icon=\"gtk-close\"></input> 1.125 <action type=\"closewindow\">UMOUNTED_DEVICE</action>
2.1 --- a/tinyutils/mountbox Wed Jul 22 13:30:04 2009 +0000 2.2 +++ b/tinyutils/mountbox Sun Aug 02 15:15:19 2009 +0200 2.3 @@ -3,10 +3,9 @@ 2.4 # Gtkdialog box for the mount/umount commands. Part of SliTaz tools. 2.5 # libmountbox: /usr/lib/slitaz/libmountbox 2.6 # 2.7 -# (C) 2008 - SliTaz GNU/Linux project. 2.8 +# (C) 2009 - SliTaz GNU/Linux project. 2.9 # 2.10 -VERSION=20080719 2.11 - 2.12 +VERSION=20090802 2.13 # Mountbox is only for root. 2.14 if test $(id -u) != 0 ; then 2.15 exec subox mountbox 2.16 @@ -90,7 +89,7 @@ 2.17 <tree> 2.18 <width>500</width><height>120</height> 2.19 <variable>DEVICE</variable> 2.20 - <label>Umounted dev|Boot|Start|End|Blocks|Id|System|Type|Label|UUID</label> 2.21 + <label>Umounted dev|Size|System|Type|Label|Boot|Start|End|Blocks|Id|UUID</label> 2.22 <input>/usr/lib/slitaz/libmountbox list-umounted</input> 2.23 <action>/usr/lib/slitaz/libmountbox umounted-fs-infos</action> 2.24 <action>refresh:MOUNTED</action> 2.25 @@ -146,6 +145,11 @@ 2.26 <input file icon="media-cdrom"></input> 2.27 <action>eject</action> 2.28 </button> 2.29 + <button> 2.30 + <label>Crypt</label> 2.31 + <input file icon="passwd"></input> 2.32 + <action>cryptobox &</action> 2.33 + </button> 2.34 <button help> 2.35 <input file icon="help"></input> 2.36 <action type="launch">HELP</action>