Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 31 Oct 2014, 09:48
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
/bin/umount
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Mon 08 Jul 2013, 22:13    Post subject:  /bin/umount  

Style in bash using arrays
as here : http://murga-linux.com/puppy/viewtopic.php?t=86617
for that remark in the original
/bin/umount :
Quote:
FULLCMD="`echo -n " $*" | sed -e 's/ \-n / /g'`" #unsatisfactory!


Code:
#!/bin/bash
# Karl Reimer Godt July 2013

[ "$*" ] || exec busybox umount

sync

USE_FULL='';

ARGS=`set | grep -E 'ARGV|ARGC'`
ARGSV=`echo "$ARGS" | grep -m1 ARGV | grep -o '(.*)$' | sed 's|^(||;s|)$||' `
ARGSC=`echo "$ARGS" | grep -m1 ARGC | cut -f2 -d'"'`
c=$ARGSC

while read p
do
p="${p#*=}"
p="${p/#\"/}"
p="${p/%\"/}"
P[$c]="$p"
(( c-- ))
done<<EOI
$(echo "$ARGSV" | sed 's|" \[|"\n\[|g')
EOI

function_rox_n_fuser(){
 [ -e "${*}" ] || return 0
 (pidof ROX-Filer || pidof rox) && rox -D "${*}"
 sleep 0.02 #change if req
 busybox fuser -m "${*}"
 sleep 0.02 #change if req
}

for k in `seq 1 1 $ARGSC`
do
case "${P[$k]}"
in
/*)
if [ -d "${P[$k]}" ] ; then
 MNTPTS_ALL=`awk '{print $1"+++"$2}' /proc/mounts`
 MNTPTS_ALL=`busybox echo -e "$MNTPTS_ALL"`
 DEVNAMEP=`echo "$MNTPTS_ALL" | grep -m1 -w "${P[$k]}"`
 DEVNAMEP="${DEVNAMEP%%+++*}"
 MNTPT_M="${P[$k]}"
 function_rox_n_fuser "$DEVNAMEP"
elif [ -b "${P[$k]}" ] ; then
 function_rox_n_fuser "${P[$k]}"
 MNTPTS_ALL=`awk '{print $1"+++"$2}' /proc/mounts`
 MNTPTS_ALL=`busybox echo -e "$MNTPTS_ALL"`
 MNTPT_D=`echo "$MNTPTS_ALL" | grep -m1 -w "${P[$k]}"`
 MNTPT_D="${MNTPT_D#*+++}"
 DEVNAMEP="${P[$k]}"
fi
;;
--version)
echo "$0 : Puppy Linux Wrapper bash shell script:"
busybox umount --help
echo "$0 : defaults using -dr"
echo "$0 : OR /bin/umount-FULL:"
USE_FULL=YES
;;
--*) #exec umount-FULL ${P[@]} ;;
USE_FULL=YES
;;
esac
done

[ "$MNTPT_M" -o "$MNTPT_D" ] || MOUNTEDSB=`tac /proc/mounts`

[ "$USE_FULL" ] && {
umount-FULL "${P[@]}"
RETVAL=$?
} || {
busybox umount -dr "${P[@]}"
RETVAL=$?
}

sleep 0.02s #change if req
IFS='. ' read UPtime restU RUNtime restR </proc/uptime
dmesg | tail | grep -w "$UPtime"

[ $RETVAL = 0 ] || exit $RETVAL

  if [ "$MNTPT_M" ] ; then OLDMOUNTPT="$MNTPT_M"
elif [ "$MNTPT_D" ] ; then OLDMOUNTPT="$MNTPT_D"
else
sleep 0.02s #change if req
[ -f /proc/mounts ] || { echo "No /proc/mounts ." ; exit $RETVAL ; } ##+++2013-08-10 in case of umount -a
MOUNTEDSA=`tac /proc/mounts`
OLDMOUNTS=`echo "$MOUNTEDSB" | grep -v "$MOUNTEDSA"`
OLDMOUNTPT=`echo "$OLDMOUNTS" | awk '{print $2}'`
OLDMOUNTPT=`echo -e "$OLDMOUNTPT" | head -n1`
  fi

[ "$MNTPT_M" -o "$MNTPT_D" ] || {
[ "$MOUNTEDSB" -a "$MOUNTEDSA" -a "$MOUNTEDSB" = "$MOUNTEDSA" ] && {
echo "NO CHANGES.";exit $RETVAL; } || {
[ "$MOUNTEDSB" -a "$MOUNTEDSA" -a "$MOUNTEDSB" != "$MOUNTEDSA" ] || {
echo "NO CHANGES.";exit $RETVAL; }; }; }

[ "$OLDMOUNTPT" -a -d "$OLDMOUNTPT" -a ! "`ls -A "$OLDMOUNTPT"`" ] && rmdir "$OLDMOUNTPT"

[ "$DISPLAY" ] || { echo "NO DISPLAY.";exit $RETVAL; }

#. /etc/eventmanager
#[ "$ICONDESK" = true ] || exit $RETVAL
#[ "$ICONPARTITIONS" = true ] || exit $RETVAL

[ "$DEVNAMEP" ] || {
DEVNAMEP=`echo "$OLDMOUNT" | awk '{print $1}'`
DEVNAMEP=`echo -e "$DEVNAMEP"`
}
echo "${DEVNAMEP##*/}"
[ -d /root/.pup_event/drive_"${DEVNAMEP##*/}" ] || { echo "NO drive_${DEVNAMEP##*/} Directory.";exit $RETVAL ; }

( pidof ROX-Filer || pidof rox ) || { echo "ROX-Filer or rox not running.";exit $RETVAL ; }
pidof pup_event_frontend_d || { echo "pup_event_frontend_d not running.";exit $RETVAL ; }

case ${DEVNAMEP##*/} in
fd*)      CATEGORY=floppy  ;;
scd*|sr*) CATEGORY=optical ;;
mmc*|sd*|hd*)
DEVNAME=`echo "$DEVNAMEP" | sed 's%p[0-9]*$%%;s%[0-9]*$%%'`
PROBEDISK2=`probedisk2`
CATEGORY=`echo "$PROBEDISK2" | grep -m1 -w "$DEVNAME" | cut -f2 -d'|'`
;;
*) echo "Not a block device for pup_event* ICONDESK.";exit $RETVAL ;;
esac

DISK_FREE=`df`

. /etc/rc.d/functions4puppy4
echo "$DISK_FREE" | grep -w "^$DEVNAMEP" | grep -E ' /initrd/| /$' &&
{
      icon_mounted_func "${DEVNAMEP##*/}" $CATEGORY; } || {  #see functions4puppy4
      icon_unmounted_func "${DEVNAMEP##*/}" $CATEGORY;
}

exit $RETVAL

edit 2013-08-10 : Added test if /proc/mounts exists in case of umount -a

Last edited by Karl Godt on Sat 10 Aug 2013, 15:24; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
musher0


Joined: 04 Jan 2009
Posts: 4278
Location: Gatineau (Qc), Canada

PostPosted: Tue 09 Jul 2013, 16:00    Post subject:  

Hello, Karl.

I tried your script and nothing happened.
I probably misunderstood something.
(See attached picture.)

Best regards.

musher0
umount-krg_sh-2013-07-09.jpg
 Description   
 Filesize   74.96 KB
 Viewed   172 Time(s)

umount-krg_sh-2013-07-09.jpg


_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Wed 10 Jul 2013, 16:13    Post subject:  

Hey, Christian . Sorry, if you misunderstood something .

It is a re-written /bin/umount .

Code:
umount &

does it do something extra ( eg unmounting of all drives ? ) in your OS ?

If so , you probably may run fatdog , lighthouse , saluki or igu's roar-ng .
These derivates tend to have several until lots of code changes .

bash-3.00# filemnt /JUMP-2/pup-430.sfs
- /usr/sbin/filemnt as an example that calls /bin/umount, if the .sfs is mounted -
should give some output like
Quote:
----------------------------------------------------------------------
IMGBASE='pup-430.sfs' imgFileBASE='pup-430.sfs'
Warning: Input Method Open Failed
Warning: Unable to load any usable fontset
1 /mnt/pup\-430\.sfs\.18022
2 /dev/loop0
3
4
------------
9544
13 305 308 518 520 522 772 6702 6719 6727 6741 6744 6746 6749 6758 6759 6776 8018 8050 8053 8096 8098 8099 8276 9382 9484 9485 9489 9515 9521 9529 9530 9531 9535 9537 9539 9544 9623 9624 9626 10958 11103 11106 11107 12723 13113 13320 13507 13570 16489 19434
loop0
NO drive_loop0 Directory.
------------
/usr/sbin/filemnt UnMount: /JUMP-2/pup-430.sfs
bash-3.00#

- though my filemnt is also hacked a bit to give some more verbosity -
.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0623s ][ Queries: 12 (0.0034s) ][ GZIP on ]