Shutdown bug

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Shutdown bug

01micko
Administrator
Musher0 has this persistent bug with shutdown and not saving. See <-- http://murga-linux.com/puppy/viewtopic.php?p=739203#739203

I wonder Karl if you can look at it. It may be a locale thing?
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
Yes, but no fun today .

That bug was about that the savefile size was becoming a negative number ie -1024 KB (minus 1024 kilobytes),

Me myself had also trouble, because though the save file was made in correct size and mountable , it was not populated at shutdown. No files in there, just lost+found directory with no content .

Kernel picknicked .

That means that the init in intrd.gz needs security lines, and if no files in there, unmounts the save file again and reverts to the selection loop or to PUPMODE 5 .

BTW, I compile my kernels with panic=56 parameter instead of video=AxB . Though 56 seconds are long now. But for newbies probably ok .
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by 01micko
# locale
LANG=fr_CA
LC_CTYPE="fr_CA"
LC_NUMERIC="fr_CA"
LC_TIME="fr_CA"
LC_COLLATE="fr_CA"
LC_MONETARY="fr_CA"
LC_MESSAGES="fr_CA"
LC_PAPER="fr_CA"
LC_NAME="fr_CA"
LC_ADDRESS="fr_CA"
LC_TELEPHONE="fr_CA"
LC_MEASUREMENT="fr_CA"
LC_IDENTIFICATION="fr_CA"
LC_ALL=
# shutdownconfig
/usr/sbin/shutdownconfig: line 237: [: -ne: unary operator expected
/usr/sbin/shutdownconfig: line 266: 18877 Terminated              yaf-splash -bg orange -close never -fontsize large -text "$T_waitprobing"
sdb8,ext4,/WoofCEtest/slackosave.2fs
131072+0 records in
131072+0 records out
134217728 bytes (134 MB) copied, 2,85062 s, 47,1 MB/s
/usr/sbin/shutdownconfig: line 343: 29916 Terminated              GTK2_RC_FILES=/tmp/orange_gtkrc${$}:/root/.gtkrc-2.0 gtkdialog --center --class="splashwindow" --program=SHUTDLG > /dev/console
# 

Save file was created at 128MB as ext3 administrator without encryption on ext4 partition sdb8 of 454MB size on the pen-drive .
shutdownconfig did not offer anywhere else ( second µmc-card or internal hdd ) .

The error above seems to be related to reiser4 bug in blkid . Former blkid were detecting reiser4 correctly.
Seems the guys at kernel.org messed up the code for util-linux . Same problem on Precise Puppy .
http://sourceforge.net/projects/reiser4/files/reiser4-for-linux-3.x/
I have made one kernel with it , without Aufs, just for full installation .

# blkid -c /dev/null /dev/sdb10
/dev/sdb10: UUID="bbf7a906-d836-4d12-aa1d-78604c30e244" TYPE="reiserfs"
INCORRECT, disktype is OK :
# disktype /dev/sdb10

--- /dev/sdb10
Block device, size 454.9 MiB (477033984 bytes)
Reiser4 file system (4.0 layout, block size 4 KiB)
  UUID BBF7A906-D836-4D12-AA1D-78604C30E244 (DCE, v4)
  Volume size 454.9 MiB (476971008 bytes, 116448 blocks of 4 KiB)

Older blkid :
# /mnt/sda9/sbin/blkid -c /dev/null /dev/sdb10
/dev/sdb10: UUID="bbf7a906-d836-4d12-aa1d-78604c30e244" TYPE="reiser4" 


For Reiser 3 :
# blkid -c /dev/null /dev/sdb9
/dev/sdb9: UUID="e25ed064-95b1-4eb0-bc7b-6e322160ea0f" TYPE="reiserfs"
# disktype /dev/sdb9

--- /dev/sdb9
Block device, size 462.8 MiB (485259264 bytes)
ReiserFS file system (new 3.6 format, standard journal, starts at 64 KiB)
  UUID E25ED064-95B1-4EB0-BC7B-6E322160EA0F (DCE, v4)
  Volume size 462.8 MiB (485228544 bytes, 118464 blocks of 4 KiB)


Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by 01micko
For that line
SAVEPART="`cat /tmp/tag.txt | head -n 1`" #head is in case of errs in output.
I remember it different as | tail -n1

Encountered such too, at iguleder's http://murga-linux.com/puppy/viewtopic.php?p=480362#480362  Insidious Puppy 001

"
Sid seems to have a promblem with the GTK main libs and executables.

Any app that depends on input 2>File is getting a lot of warning messages into the FILE.

Xdialog is one of them.

Apps that relay on clean FILE to perform `cut -f X -d Y` don't find the needed info in that field anymore. It is not -f 2 anymore but -f 120 or such.
"
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by 01micko
Now ran it as
#!/bin/ash
Worked OK .
# shutdownconfig
ash: 0: unknown operand
sdb8,ext4,/WoofCEtest/slackosave.2fs
131072+0 records in
131072+0 records out
134217728 bytes (134 MB) copied, 3,04519 s, 44,1 MB/s

/tmp/shutdownconfig_results :
PUPMODE=128
SAVEPART='sdb8'
SAVEFS='ext4'
PUPSAVE='sdb8,ext4,/WoofCEtest/slackosave_cryptx-2013_11_26_ii.4fs'
SAVEFILE='/WoofCEtest/slackosave_cryptx-2013_11_26_ii.4fs'
NAMEONLY='slackosave_cryptx-2013_11_26_ii.4fs'
SAVEPATH='/WoofCEtest'
MYPASSWORD='puppy'
SFEXT='4fs'
xPDEV='sdb1'
xDEVFS='vfat'
SMNTPT='/mnt/sdb8'
CRYPTO='-E 1'
expBOOTDRV='/dev/sdb'

Both created save files were mountable by clicking on them ( and entering passwd ) :
/dev/sdb8 on /mnt/sdb8 type ext4 (rw,relatime,data=ordered)
/dev/loop1 on /mnt/+mnt+sdb8+WoofCEtest+slackosave-2013_11_26.3fs type ext3 (rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered)
/dev/loop2 on /mnt/+mnt+sdb8+WoofCEtest+slackosave_cryptx-2013_11_26_ii.4fs type ext4 (rw,relatime)
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by Karl Godt
There is at least one line that does not filter errors in case someone installs crappy libg[dt]k  as subcontent of some .pets :
${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} "$T_sizetitle" --no-collapse --no-cancel --default-item "5" --menu "$T_sitemenu" 0 0 0 $SIZELIST >/dev/console 2>/tmp/sizetag.txt
 NUM=`cat /tmp/sizetag.txt`
ACHOICE=`echo -n "$CHOICES" | cut -f $NUM -d ' '`
#return $ACHOICE
SIZEPFILE=$ACHOICE #global variable.

As a coder if head -n1 would be right, would
read NUM </tmp/sizetag.txt
because that would also strip leading :space:
instead of
NUM=`cat /tmp/sizetag.txt | head -n1`
but somehow I remember that these gtk  WARNING messages flood into these /tmp/choice.txt files before the CHOICE gets written into that file - so it would be
NUM=`cat /tmp/sizetag.txt | tail -n1`
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by 01micko
Now even made a crypta save file and everything's OK .

# diff -up /initrd/pup_ro2/usr/sbin/shutdownconfig /usr/sbin/shutdownconfig
--- /initrd/pup_ro2/usr/sbin/shutdownconfig	2013-11-12 20:17:13.000000000 -0100
+++ /usr/sbin/shutdownconfig	2013-11-26 05:25:45.707757471 -0100
@@ -225,7 +225,7 @@ $(gettext "Instead, you should first run
    if [ $RETMNTVAL -eq 0 ];then
     if [ "$ATAG" = "fd0" ];then
      FFREE=`df -k | grep "/dev/$ATAG" | tr -s " " | cut -f 4 -d " "`
-     AFREE=`dc $FFREE 1000 \/ p` #not 1024
+     AFREE=`LC_ALL=C dc $FFREE 1000 \/ p` #not 1024
     else
      #for ntfs cannot use /dev/$ATAG, use mnt point in grep...
      AFREE=`df -m | grep "/mnt/data" | tr -s " " | cut -f 4 -d " "`
@@ -274,6 +274,7 @@ $(gettext 'Highlight desired choice, the
   echo -n "${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} \"${T_partitiontitle}\" --no-collapse --no-cancel ${DEFTAG} --menu \"${T_menu}\" 0 0 0 " >> /tmp/savedlg
   echo -n "$xSCHOICES"  >> /tmp/savedlg
   echo ' 2>/tmp/tag.txt' >> /tmp/savedlg
+  echo ' echo $? >>/tmp/savedlg.exitcode' >> /tmp/savedlg
   chmod 755 /tmp/savedlg
  
   #seems some people have problem, do not select anything...
@@ -306,18 +307,21 @@ $(eval_gettext 'Or, \Zb${T_abort}\ZB to
 
 choosesizefunc(){
  local KFREE SIZELIST NUM CHOICES FLABEL SLABEL ACHOICE KSIZE VALUES VALIDS val
+ while [ ! "$SIZEPFILE" ]
+ do
  KFREE=$1 ; SIZELIST="" ; NUM=1 ; CHOICES=""
  FLABEL="`expr $KFREE \/ 1024`MB"
- [ $KFREE -ge 1048576 ] && FLABEL="`dc $KFREE 1048576 \/ p`GB"
+ [ $KFREE -ge 1048576 ] && FLABEL="`LC_ALL=C dc $KFREE 1048576 \/ p`GB"
  VALUES='32 64 128 256 512 768 1024 1280 2048 4096'
  for val in $VALUES;do
  [ "$val" -gt "$DU_INITRD_PUP_RW" ] && VALIDS="$VALIDS $val"
  done
+ [ "$VALIDS" ] || : # Todo what now
  for ACHOICE in $VALIDS
  do
   KSIZE=`expr $ACHOICE \* 1024`
   SLABEL="${ACHOICE}MB"
-  [ $ACHOICE -ge 1024 ] && SLABEL="`dc $ACHOICE 1024 \/ p`GB"
+  [ $ACHOICE -ge 1024 ] && SLABEL="`LC_ALL=C dc $ACHOICE 1024 \/ p`GB"
   if [ $KSIZE -lt $KFREE ];then
    SIZELIST="$SIZELIST$NUM $SLABEL "
    CHOICES="$CHOICES$KSIZE "
@@ -328,16 +332,22 @@ choosesizefunc(){
   fi
   NUM=`expr $NUM + 1`
  done
+ rm -f /tmp/sizetag.txt
  
  T_sizetitle="$(gettext 'First shutdown: size save-file')"
  T_sitemenu="$(gettext 'Please choose the size you would like for the personal save file.')
 $(gettext 'Note, 512M is a good choice, or highest if that not available.')
 $(gettext 'Select choice, then click OK button...')"
  ${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} "$T_sizetitle" --no-collapse --no-cancel --default-item "5" --menu "$T_sitemenu" 0 0 0 $SIZELIST >/dev/console 2>/tmp/sizetag.txt
+ if [ -s /tmp/sizetag.txt ]; then
  NUM=`cat /tmp/sizetag.txt`
  ACHOICE=`echo -n "$CHOICES" | cut -f $NUM -d ' '`
  #return $ACHOICE
  SIZEPFILE=$ACHOICE #global variable.
+ else
+ : #Todo try again OR break out
+ fi
+ done
 } # end of choosesizefunc()
 
 pupsavefunc() {
@@ -711,13 +721,14 @@ Select <\\\${T_notsave}> to shutdown wit
  ;;
 esac
 case $SAVECHOICE in
- 0)
-  choosepartfunc && pupsavefunc && PUPMODE=128 #yes, save it.
+ 0) #yes, save it
+  choosepartfunc && { pupsavefunc && 
+	  PUPMODE=128 || exit 234; } || exit 233
  ;;
- 3)
-  echo #case already handled above.
+ 3) #case already handled above.
+  echo 
  ;;
- 255)
+ -1|254|255|256)
   exit 255 #wmreboot and wmpoweroff can cancel shutdown. 130221
  ;;
  *)
# 
Most is scribble .

dc might be a culprit :
# locale
LANG=fr_CA
LC_CTYPE="fr_CA"
LC_NUMERIC="fr_CA"
LC_TIME="fr_CA"
LC_COLLATE="fr_CA"
LC_MONETARY="fr_CA"
LC_MESSAGES="fr_CA"
LC_PAPER="fr_CA"
LC_NAME="fr_CA"
LC_ADDRESS="fr_CA"
LC_TELEPHONE="fr_CA"
LC_MEASUREMENT="fr_CA"
LC_IDENTIFICATION="fr_CA"
LC_ALL=fr_CA
# dc 123.123 12 \/ p
dc: syntax error at '123.123'

# LC_NUMERIC=C dc 123.123 12 \/ p
dc: syntax error at '123.123'

# LC_ALL=C dc 123.123 12 \/ p
10.2603

# LANG=C dc 123.123 12 \/ p
dc: syntax error at '123.123'


Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
The other diff has a bug because it uses the  [ ! "$SIZEPFILE" ] test and PSAVEFILE got already a defaultvalue computed . Changed to use a dummy VAR named  [ ! "$SIZEPFILE_LOOP" ] .
FUN_NAME is to replace 'john' .
Also made a similar loop for the savefile name if 'any character' would suggest to type :punct:s like astrix or obelix thus screwing everything further down.
Some code cleanups and echo $LINENO included.
Removed a few >/dev/null since they land in xerrs.log anyway.
The pupmessage binary lacks a ESC feature like dialog has IMHO .
# diff -up /initrd/pup_ro2/usr/sbin/shutdownconfig /usr/sbin/shutdownconfig
--- /initrd/pup_ro2/usr/sbin/shutdownconfig	2013-11-12 20:17:13.000000000 -0100
+++ /usr/sbin/shutdownconfig	2012-11-26 09:28:01.152560041 -0100
@@ -33,12 +33,15 @@
 #130712 fix 130522, 130525 dlgs showing in tray.
 #130721 improve some translations.
 
+FUN_NAME=MinnyMouse
+
+echo $LINENO
 if [ ! $DISPLAY ];then
  export LANG=C #110928 console shutdown using 'dialog', disable i18n.
 else
  export OUTPUT_CHARSET=UTF-8
 fi
-
+echo $LINENO
 . /usr/bin/gettext.sh # enables use of eval_gettext (several named variables) and ngettext (plurals)
 export TEXTDOMAIN=shutdownconfig
 T_title="$(gettext 'First shutdown: save session')" # used 8 times
@@ -47,13 +50,13 @@ T_continue="$(gettext 'Continue')"
 T_abort="$(gettext 'Abort')"
 T_no="$(gettext 'No')"
 T_notsave="$(gettext 'DO NOT SAVE')"
-
+echo $LINENO
 #/etc/rc.d/rc.shutdown will call shutdownconfig if this file does not exist, then will read its contents...
 echo -n "" > /tmp/shutdownconfig_results
 
 . /etc/rc.d/PUPSTATE
 . /etc/DISTRO_SPECS
-
+echo $LINENO
 #puppy.sfs is in a subdirectory, default to saving in it...
 PUPSFSFILE="`echo "$PUPSFS" | cut -f 3 -d ','`"
 PSUBDIR="`dirname "$PUPSFSFILE"`"
@@ -78,10 +81,10 @@ else
  BACKGROUNDPINK=''
  BACKGROUNDORANGE=''
 fi
-
+echo $LINENO
 #120514 Karl Godt: precaution, save-file must be at least this big...
 DU_INITRD_PUP_RW=0
-[ "`mount | grep ' /initrd/pup_rw '`" != "" ] && DU_INITRD_PUP_RW=`du -B 1M -c /initrd/pup_rw |tail -n1 |awk '{print $1}'` #M=1024,MB=1000
+[ "`grep ' /initrd/pup_rw ' /proc/mounts`" = "" ] || DU_INITRD_PUP_RW=`du -B 1M -c /initrd/pup_rw |tail -n1 |awk '{print $1}'` #M=1024,MB=1000
 
 #130525 introduced 130522. moved up.
 ORANGEGTKRC="style \"windowstuff\"
@@ -92,7 +95,7 @@ ORANGEGTKRC="style \"windowstuff\"
 class \"*\" style \"windowstuff\"
 "
 echo "$ORANGEGTKRC" > /tmp/orange_gtkrc${$}
-
+echo $LINENO
 choosepartfunc() { 
  #dialog to choose what partition to create ${DISTRO_FILE_PREFIX}save.2fs on...
  T_admin="$(gettext 'administrator')"
@@ -193,17 +196,22 @@ ${FIDOMSG2}"
  echo "$PARTSLIST" |
  while read APART
  do
-  ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
-  ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
-  AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
+  ATAG=`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`
+  ASIZE=`echo -n "$APART" | cut -f 3 -d '|'`
+  AFS=`echo -n "$APART" | cut -f 2 -d '|'`
   AFREE=`df -m | grep "/dev/${ATAG} " | tr -s " " | cut -f 4 -d " "`
+  echo $LINENO $APART AFREE=$AFREE
+  
+  
+##*********** mounting to check free space
+  RETMNTVAL=0
   if [ ! $AFREE ];then
-   mount -t $AFS /dev/$ATAG /mnt/data > /dev/null 2>&1
+   mount -t $AFS /dev/$ATAG /mnt/data
+   RETMNTVAL=$?
    #need to put in a check that it is not mounted ro. the
    #mount script will fallback to ro for ntfs if rw mnt fails...
-   RETMNTVAL=$?
    if [ $RETMNTVAL -eq 0 ];then
-    if [ "`mount | grep '(rw' | grep '/mnt/data'`" = "" ];then
+    if [ "`grep ' /mnt/data ' /proc/mounts | grep -w 'rw'`" = "" ];then
      umount /mnt/data
      RETMNTVAL=1
     else
@@ -222,18 +230,25 @@ $(gettext "Instead, you should first run
     fi
    fi
    [ -f /tmp/ntfsmnterr.txt ] && rm -f /tmp/ntfsmnterr.txt
+   echo $LINENO RETMNTVAL=$RETMNTVAL
    if [ $RETMNTVAL -eq 0 ];then
     if [ "$ATAG" = "fd0" ];then
-     FFREE=`df -k | grep "/dev/$ATAG" | tr -s " " | cut -f 4 -d " "`
-     AFREE=`dc $FFREE 1000 \/ p` #not 1024
+     FFREE=`df -k | grep -w "/dev/$ATAG" | tr -s " " | cut -f 4 -d " "`
+     AFREE=`LC_ALL=C dc $FFREE 1000 \/ p` #not 1024
     else
      #for ntfs cannot use /dev/$ATAG, use mnt point in grep...
-     AFREE=`df -m | grep "/mnt/data" | tr -s " " | cut -f 4 -d " "`
+     AFREE=`df -m | grep " /mnt/data" | tr -s " " | cut -f 4 -d " "`
     fi
     #umount /dev/$ATAG  v2.02 must use mnt point for ntfs...
     umount /mnt/data
    fi
   fi
+##** mounting to check free space
+  
+  [ "$RETMNTVAL" = 0 ] || continue
+  echo $LINENO AFREE=$AFREE
+  [ "$AFREE" ] || continue
+  
   if [ $AFREE -ne 0 ];then
    if [ "$ATAG" = "$PDEV1" -a $AFREE -gt 256 ];then #120327
     echo -n " --default-item ${ATAG}" > /tmp/shutdownconfig_deftag
@@ -274,6 +289,7 @@ $(gettext 'Highlight desired choice, the
   echo -n "${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} \"${T_partitiontitle}\" --no-collapse --no-cancel ${DEFTAG} --menu \"${T_menu}\" 0 0 0 " >> /tmp/savedlg
   echo -n "$xSCHOICES"  >> /tmp/savedlg
   echo ' 2>/tmp/tag.txt' >> /tmp/savedlg
+  echo ' echo $? >>/tmp/savedlg.exitcode' >> /tmp/savedlg
   chmod 755 /tmp/savedlg
  
   #seems some people have problem, do not select anything...
@@ -303,51 +319,68 @@ $(eval_gettext 'Or, \Zb${T_abort}\ZB to
  echo "$PUPSAVE" #TEST
  return 0
 } #end choosepartfunc
-
+echo $LINENO
 choosesizefunc(){
- local KFREE SIZELIST NUM CHOICES FLABEL SLABEL ACHOICE KSIZE VALUES VALIDS val
+ local KFREE SIZELIST NUM CHOICES FLABEL SLABEL ACHOICE KSIZE VALUES VALIDS val SIZEPFILE_LOOP
+ SIZEPFILE_LOOP='';
+ while [ ! "$SIZEPFILE_LOOP" ]
+ do
  KFREE=$1 ; SIZELIST="" ; NUM=1 ; CHOICES=""
  FLABEL="`expr $KFREE \/ 1024`MB"
- [ $KFREE -ge 1048576 ] && FLABEL="`dc $KFREE 1048576 \/ p`GB"
+ [ $KFREE -ge 1048576 ] && FLABEL="`LC_ALL=C dc $KFREE 1048576 \/ p`GB"
  VALUES='32 64 128 256 512 768 1024 1280 2048 4096'
  for val in $VALUES;do
  [ "$val" -gt "$DU_INITRD_PUP_RW" ] && VALIDS="$VALIDS $val"
  done
+ [ "$VALIDS" ] || : # Todo what now
  for ACHOICE in $VALIDS
  do
   KSIZE=`expr $ACHOICE \* 1024`
   SLABEL="${ACHOICE}MB"
-  [ $ACHOICE -ge 1024 ] && SLABEL="`dc $ACHOICE 1024 \/ p`GB"
+  [ $ACHOICE -ge 1024 ] && SLABEL="`LC_ALL=C dc $ACHOICE 1024 \/ p`GB"
   if [ $KSIZE -lt $KFREE ];then
-   SIZELIST="$SIZELIST$NUM $SLABEL "
-   CHOICES="$CHOICES$KSIZE "
+   SIZELIST="${SIZELIST} $NUM $SLABEL"
+   CHOICES="${CHOICES} $KSIZE"
   else
-   SIZELIST="$SIZELIST$NUM fill_partition(${FLABEL}) "
-   CHOICES="$CHOICES$KFREE "
+   SIZELIST="${SIZELIST} $NUM fill_partition(${FLABEL})"
+   CHOICES="${CHOICES} $KFREE"
    break
   fi
   NUM=`expr $NUM + 1`
  done
+ rm -f /tmp/sizetag.txt
  
  T_sizetitle="$(gettext 'First shutdown: size save-file')"
  T_sitemenu="$(gettext 'Please choose the size you would like for the personal save file.')
 $(gettext 'Note, 512M is a good choice, or highest if that not available.')
 $(gettext 'Select choice, then click OK button...')"
  ${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} "$T_sizetitle" --no-collapse --no-cancel --default-item "5" --menu "$T_sitemenu" 0 0 0 $SIZELIST >/dev/console 2>/tmp/sizetag.txt
+ if [ -s /tmp/sizetag.txt ]; then
  NUM=`cat /tmp/sizetag.txt`
- ACHOICE=`echo -n "$CHOICES" | cut -f $NUM -d ' '`
+ ACHOICE=`echo -n $CHOICES | cut -f $NUM -d ' '`
  #return $ACHOICE
  SIZEPFILE=$ACHOICE #global variable.
+  if [ "${SIZEPFILE//[[:digit:]]/}" = "" ] ; then
+   SIZEPFILE_LOOP=$SIZEPFILE
+  else
+  : #Todo ...
+  fi
+ else
+ : #Todo try again OR break out
+ fi
+ done
 } # end of choosesizefunc()
-
+echo $LINENO
 pupsavefunc() {
- sPTN="/dev/${SAVEPART} "
- SMNTPT="`mount | grep "$sPTN" | tr -s " " | cut -f 3 -d " "`"
+ #sPTN="/dev/${SAVEPART} "
+ #SMNTPT="`mount | grep "$sPTN" | tr -s " " | cut -f 3 -d " "`"
+ SMNTPT=`grep -w "^/dev/$SAVEPART" /proc/mounts | cut -f 2 -d ' '`
+ SMNTPT=`busybox echo -e "$SMNTPT"`
  #ntfs uses /dev/fuse so '/dev/$SAVEPART' no good for grep... NOTE: this fixed later versions ntfs-3g, so this line actually redundant...
- [ "$SMNTPT" = "" ] && SMNTPT="`ps -e | grep -o 'ntfs\-3g.*' | grep "$sPTN" | tr '\t' ' ' | tr -s ' ' | tr ' ' "\n" | grep '^/mnt/'`"
+ [ "$SMNTPT" = "" ] && SMNTPT="`ps -e | grep -o 'ntfs\-3g.*' | grep -w "/dev/$SAVEPART" | tr '\t' ' ' | tr -s ' ' | tr ' ' "\n" | grep '^/mnt/'`"
 
  if [ "$SMNTPT" = "" ];then
-  mkdir /mnt/$SAVEPART 2>/dev/null
+  mkdir -p /mnt/$SAVEPART
   mount -t $SAVEFS /dev/$SAVEPART /mnt/$SAVEPART
   SMNTPT="/mnt/$SAVEPART"
  fi
@@ -383,16 +416,29 @@ pupsavefunc() {
  T_nametitle="$(gettext 'First shutdown: save-file name')"
  T_nameinput="$(eval_gettext "Would you like to customise the name of the '\${DISTRO_FILE_PREFIX}save.\${SFEXT}' file?")
 $(eval_gettext "This is optional, but it is convenient if you have lots of '\${DISTRO_FILE_PREFIX}save' files and you want to choose the right one at startup.")
-$(eval_gettext "For example, if you enter 'john' here, the file will become '\${DISTRO_FILE_PREFIX}save-john.\${SFEXT}'.")
+$(eval_gettext "For example, if you enter '$FUN_NAME' here, the file will become '\${DISTRO_FILE_PREFIX}save-$FUN_NAME.\${SFEXT}'.")
 
-$(gettext 'Type any characters you wish, then click OK button:')"
- MYUSERNAME="`${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} "$T_nametitle" --stdout --nocancel --inputbox "$T_nameinput" 0 0 ""`"
+$(gettext 'Type any alphanumerical and ._ characters you wish, then click OK button:')"
+ 
+ MYUSERNAME_LOOP='';
+ while [ ! "$MYUSERNAME_LOOP" ]
+ do
+ MYUSERNAME="`${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} "$T_nametitle" --stdout --inputbox "$T_nameinput" 0 0 ""`"
  if [ "$MYUSERNAME" != "" ];then
-  MYUSERNAME="`echo -n "$MYUSERNAME" | tr ' ' '_' | tr '-' '_' | sed -e 's/[^a-zA-Z0-9_.]//g'`"
+  echo "$MYUSERNAME" | grep -E '\!|\^|\$|\%|\&|\/|\(|\)|\?|\{|\}|\[|\]|\"|\°|\§' && continue
+  echo $MYUSERNAME
+  echo "$MYUSERNAME" | grep -E "'|\||\*|\;|\:|<|>|@" && continue
+  echo $MYUSERNAME
+  MYUSERNAME=`echo "$MYUSERNAME" | sed "sV[[:punct:]]V\\\\\&Vg"`
+  echo $MYUSERNAME
+  MYUSERNAME=`echo -n "$MYUSERNAME" | tr ' ' '_' | tr '-' '_' | sed -e 's/[^a-zA-Z0-9_.]//g'`
+  echo $MYUSERNAME
   NAMEONLY="${DISTRO_FILE_PREFIX}save-${MYUSERNAME}.${SFEXT}"
   SAVEFILE="$PSUBDIR/$NAMEONLY"
   PUPSAVE="$SAVEPART,$SAVEFS,$SAVEFILE"
+  MYUSERNAME_LOOP="$MYUSERNAME"
  fi
+ done
  
  CRYPTO=""
  T_cryptotitle="$(gettext 'First shutdown: encryption')"
@@ -425,10 +471,10 @@ entered at every bootup.')"
   if [ $RETVAL -eq 1 ];then
    DENSITY="a" #heavy aes encryption
    CRYPTO='-e aes'
-   modprobe aes_generic 2>/dev/null #builtin my recent kernels.
+   modprobe aes_generic       #builtin my recent kernels.
    #did not explicitly load these two before, but do so in init script...
-   modprobe crypto_blkcipher 2>/dev/null #builtin my recent kernels.
-   modprobe cbc 2>/dev/null #110926 builtin in my 2.6.32-smp-45 kernel.
+   modprobe crypto_blkcipher  #builtin my recent kernels.
+   modprobe cbc               #110926 builtin in my 2.6.32-smp-45 kernel.
   else
    DENSITY="x" #light xor encryption.
    CRYPTO='-E 1' #'-e xor' --bug, loads xor.ko which is something else.
@@ -463,7 +509,7 @@ $(eval_gettext 'To quit without saving,
  fi
  
  #we should check to see that there is enough space on the partition...
- PARTFREE=`df | grep "$SMNTPT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
+ PARTFREE=`df | grep " $SMNTPT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
  [ ! $PARTFREE ] && PARTFREE=0
  [ $PARTFREE -lt 32768 ] && PARTFREE=`expr $PARTFREE - 1024` #leave some slack space.
  [ $PARTFREE -gt 32768 ] && PARTFREE=`expr $PARTFREE - 8192` #leave some slack space.
@@ -594,7 +640,7 @@ If uncertain, just click OK button.')"
  return 0
 } #end pupsavefunc
 
-
+echo $LINENO
 xDEVFS="$DEV1FS"
 xPDEV="$PDEV1"
 if [ "$PSAVEMARK" != "" -a "$PDEV1" != "" ];then #see /etc/rc.d/PUPSTATE
@@ -605,9 +651,9 @@ if [ "$PSAVEMARK" != "" -a "$PDEV1" != "
  xDEVFS="$SAVEFS"
  xPDEV="$SAVEPART"
 fi
-
+echo $LINENO
 [ ! "$DEV1FS" ] && xDEVFS='xxx' #this will enable choice of create a save-file.
-
+echo $LINENO
 SAVECHOICE=255
 
 # some word processing now...
@@ -621,7 +667,7 @@ T_cd="$(gettext 'SAVE TO CD')"
 
 #130221 note, pupdialog will exit with 255 if click window close-box, 254 if timeout.
 # former, want to abort shutdown, latter, shutdown without saving.
-
+echo $LINENO
 case $xDEVFS in
  ext2|ext3|ext4|reiserfs|minix|btrfs|f2fs) #linux f.s.  130216 add f2fs.
   #do not allow save to entire partition if pup installed in a subdirectory...
@@ -711,13 +757,14 @@ Select <\\\${T_notsave}> to shutdown wit
  ;;
 esac
 case $SAVECHOICE in
- 0)
-  choosepartfunc && pupsavefunc && PUPMODE=128 #yes, save it.
+ 0) #yes, save it
+  choosepartfunc && { pupsavefunc && 
+	  PUPMODE=128 || exit 234; } || exit 233
  ;;
- 3)
-  echo #case already handled above.
+ 3) #case already handled above.
+  echo 
  ;;
- 255)
+ -1|254|255|256)
   exit 255 #wmreboot and wmpoweroff can cancel shutdown. 130221
  ;;
  *)
@@ -732,18 +779,19 @@ if [ $PUPMODE -eq 128 ];then #will be sa
    NAMEONLY="`basename $SAVEFILE`"
    T_copytitle="$(gettext 'First shutdown: copy .sfs from CD')"
    T_copy="$(gettext 'COPY')"
-   yesno="`eval_gettext \"The CD has '\\\${DISTRO_PUPPYSFS}' and maybe other .sfs files on it. It will speed startup considerably if these are on the hard drive. 
+   yesno=`eval_gettext "The CD has '\\\${DISTRO_PUPPYSFS}' and maybe other .sfs files on it. It will speed startup considerably if these are on the hard drive.
 Also, for PCs with less than 256MB of RAM, \\\${DISTRO_NAME} does not copy the \\\${DISTRO_PUPPYSFS} file to RAM so the CD drive remains mounted, meaning that the drive cannot be used for other purposes. 
 However, if you reply \Zb\\\${T_copy}\ZB here then it will be copied to the same drive as the '\\\${DISTRO_FILE_PREFIX}save' file and loaded from there at startup, thus freeing the CD drive for other uses.
 Even if you have heaps of RAM, it is still good to answer \Zb\\\${T_copy}\ZB to get the faster startup.
 
 Note: if a CD has extra .sfs files on it, by copying them to the same drive as the '\\\${DISTRO_FILE_PREFIX}save' file, they are then available to be loaded at startup, which is configurable by the BootManager (the BootManager is in the System menu)
 
-If you answer \Zb\\\${T_copy}\ZB here, please \Zb\Z1FIRST, RIGHT NOW\Zn\ZB, put the \\\${DISTRO_NAME} CD into the \\\${PDEV1} drive (the same one that the CD was in at startup), if it isn't already, THEN select the \Zb\\\${T_copy}\ZB button...\"`"
+If you answer \Zb\\\${T_copy}\ZB here, please \Zb\Z1FIRST, RIGHT NOW\Zn\ZB, put the \\\${DISTRO_NAME} CD into the \\\${PDEV1} drive (the same one that the CD was in at startup), if it isn't already, THEN select the \Zb\\\${T_copy}\ZB button..."`
 
 
    ${DIALOGEXE} ${BACKGROUNDYELLOW} ${TITLEPARAM} "$T_copytitle" --colors --yes-label "$T_copy" --yesno "$yesno" 0 0 >/dev/console
-   RETVAL=$?
+   RETVAL=$? 
+   
    clear >/dev/console
    if [ $RETVAL -eq 0 ];then
     #echo "Please wait, accessing CD drive..." >/dev/console
@@ -764,8 +812,10 @@ If you answer \Zb\\\${T_copy}\ZB here, p
      cPID=$!
     fi
 
-    APATTERN="/dev/$PDEV1 "
-    CDMNTPT="`mount | grep "$APATTERN" | cut -f 3 -d ' '`"
+    #APATTERN="/dev/$PDEV1 "
+    #CDMNTPT="`mount | grep "$APATTERN" | cut -f 3 -d ' '`"
+    CDMNTPT=`grep -w "^/dev/$PDEV1" /proc/mounts | cut -f 2 -d ' '`
+    CDMNTPT=`busybox echo -e "$CDMNTPT"`
     mkdir -p /mnt/$PDEV1
     if [ "$CDMNTPT" = "" ];then
      mount -t iso9660 /dev/$PDEV1 /mnt/$PDEV1
# 
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

01micko
Administrator
Ok applied the patch.. but ..

got errors from patch? Seemed not fatal so pushed on...

All looks ok from here. Nice verbose output. Created save file fine on my old celeron 2.4GHz (really the hamstrung P4) 1GB RAM. I'll PM the file to musher0 and see if it helps him, unless of course you have already.

Nice job KRG!
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
I have seen the reports now on murga's forum :

http://murga-linux.com/puppy/viewtopic.php?t=90417&start=15 Pupsave (initial shutdown) bug [SOLVED]

I'll attach a pic of musher's problem :
rc.shutdown from prompt

And it has actually 2 fails :
1) the <--here marked negative pupsave file of only minus 1 MegaByte .
2) the now by me marked missing fs type of the installation partition .

If these depend upon each other or are two different problems, is unknown to me.

Musher posted it that it also occured using the GUI, and not only from the prompt:
http://murga-linux.com/puppy/viewtopic.php?p=737771#737771
- The CE-3 version has the pupsave bug. It creates a pupsave with
"-1 mg" size... That's "-" as in "minus". The latest BK Puppies had it too.
Obviously, you can't save anything in a file that has a negative size. Or
is this Puppy actually an anti-matter version... (hehe) it counts everything
in negative numbers! Smile

Actually, it's not funny. The pupsave routine does not work in CE-3, not
with the GUI, and not even with the CLI.

I have to say that I only focused on the negative number problem, and did not detect the missing fs type entry in that photograph back then.
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by Karl Godt
I didn't recognized that slacko-5.6.1 uses busybox blkid it seems. Will have to check Precise Puppy too, then.

Busybox actually implemented the blkid applet with version 1.19.0 :
http://busybox.net/oldnews.html
blkid: optional support for TYPE="fstype"

Puppy-4.3 had busybox 1.15.0 and Lupu-5 busybox-1.16.2 IIRC .

So the busybox blkid apparently likely is incomplete or still needs fixes in rare corner cases.
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
This post was updated on .
https://github.com/idunham/busybox
(branch enh)
compiled with
musl
https://github.com/idunham/musl
(branch g_hack)

That busybox BusyBox v1.22.0.git (2013-06-22 02:42:56 GMT+1) multi-call binary. also still detects reiser4 as reiserfs .

It's possible to download pre-compiled from my google drive site :
https://docs.google.com/file/d/0B7Meqrmt7a3GbTBDVGtFaEhManc/edit
Edit : Corrected above link.
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by Karl Godt
Now builded blkid from https://www.kernel.org/pub/linux/utils/util-linux/v2.22/util-linux-2.22.2.tar.xz
2.23 and 2.24 wouldn't build mount because of mkostemp function dependencies (Puppy-4.3.1) .

bash-3.2# LD_LIBRARY_PATH=/Downloads/util-linux-2.22.2/.libs/:$LD_LIBRARY_PATH
bash-3.2# ./blkid
/dev/sdc6: UUID="058fd949-fe32-41b4-9084-7c6e39fad09f" TYPE="reiser4"
So there are apparently busybox blkid filesystem shortcommings.

The logfiles of the rdsh from musher were OK though, as far as I could see.


Apparently I did not recognized that busybox blkid is used, because woof still applies swapon and swapoff from util-linux, and swapoff is part of rc.shutdown.

swapoff -av works nice with util-linux but does not work at all with busybox swapoff ( -a does not parse /proc/swaps and -v is not implemented ) .

http://bkhome.org/blog/?viewDetailed=02586
Busybox 1.19.3
I have upgraded to the latest Busybox, PET uploaded to the 'common' repo (394KB):
http://distro.ibiblio.org/quirky/pet_packages-common/busybox-1.19.3-w5c.pet
Posted on 11 Nov 2011, 8:45

Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by Karl Godt
This is the code part of blkid.c of busybox :
#include "libbb.h"
#include "volume_id.h"

int blkid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int blkid_main(int argc UNUSED_PARAM, char **argv)
{
	int scan_devices = 1;

	while (*++argv) {
		/* Note: bogus device names don't cause any error messages */
		add_to_uuid_cache(*argv);
		scan_devices = 0;
	}

	display_uuid_cache(scan_devices);
	return 0;
}
util-linux-2.22.2/misc-utils/blkid.c is 958 lines and has no huge license comment block . NO CHANCE !
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by Karl Godt
Ha, could (accidentally?) reproduce the bug :

negative slackosave

code until now is :
# diff -up /initrd/pup_ro2/usr/sbin/shutdownconfig /usr/sbin/shutdownconfig
--- /initrd/pup_ro2/usr/sbin/shutdownconfig	2013-11-12 20:17:13.000000000 -0100
+++ /usr/sbin/shutdownconfig	2012-11-27 21:11:36.286618589 -0100
@@ -93,6 +93,43 @@ class \"*\" style \"windowstuff\"
 "
 echo "$ORANGEGTKRC" > /tmp/orange_gtkrc${$}
 
+check4content(){ [ "$*" ] && return 0 || return 1; }  # SRTING has content returns 0 , otherwise 1
+  
+check4wanted(){ #params $1=STRING to check, $2=not, $2/$3+ chars to check STRING for
+	  local DEBUGME Q VAR I
+	  echo "$@"
+	  DEBUGME=1
+	  [ "$DEBUGME" = 0 ] && Q='-q';
+	  VAR="$1"
+	  [ "$VAR" ] || return 0;
+	  shift
+	  #echo "$@"
+	  I='';
+	  [ "$1" = not ] && { I='-v';shift; }
+	  #echo "$*"
+	  [ "$*" ] || return 0; 
+	  local IS_UNWANTED=0 count
+	  count(){ 
+		  [ "${1//[[:digit:]]/}" ] && return 1
+		  IS_UNWANTED=$((IS_UNWANTED+$1)); 		}
+	  for param in $@
+	  do
+	    #echo $VAR $I $Q $param
+	    case $param in
+	    space) echo "$VAR" | grep $I $Q '[[:space:]]' && count 0 || count 1;;
+	    blank) echo "$VAR" | grep $I $Q '[[:blank:]]' && count 0 || count 1;;
+	    digit) echo "$VAR" | grep $I $Q '[[:digit:]]' && count 0 || count 1;;
+	    alpha) echo "$VAR" | grep $I $Q '[[:alpha:]]' && count 0 || count 1;;
+	    alnum) echo "$VAR" | grep $I $Q '[[:alnum:]]' && count 0 || count 1;;
+	    punct) echo "$VAR" | grep $I $Q '[[:punct:]]' && count 0 || count 1;;
+	    *)     echo "$VAR" | grep $I $Q -Fw "$param"  && count 0 || count 1;;
+	    esac
+	  done 
+	  echo "IS_UNWANTED=$IS_UNWANTED"
+	  return $IS_UNWANTED;
+		}
+		
+
 choosepartfunc() { 
  #dialog to choose what partition to create ${DISTRO_FILE_PREFIX}save.2fs on...
  T_admin="$(gettext 'administrator')"
@@ -189,14 +226,25 @@ ${FIDOMSG2}"
  ppPID=$!
  SCHOICES=""; DEFTAG=""
  rm -f /tmp/schoices.txt
- rm -f /tmp/shutdownconfig_deftag
+ rm -f /tmp/shutdownconfig_deftag 
  echo "$PARTSLIST" |
  while read APART
  do
+  #echo BLOK
   ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
+  check4content  "$ATAG"  || continue
+  check4wanted "$ATAG" not '/dev/'   || continue
   ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
+  check4content  "$ASIZE" || continue
+  check4wanted "$ASIZE" digit  || continue
   AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
+  check4content  "$AFS"   || continue
+  check4wanted "$AFS" not reiser4 bfs swap none extended || continue
+  #RETVAL=$?; echo RETVAL=$RETVAL
   AFREE=`df -m | grep "/dev/${ATAG} " | tr -s " " | cut -f 4 -d " "`
+  check4content  "$AFREE"     || : #not already mounted
+  check4wanted "$AFREE" digit || : #not already mounted
+  #echo BLOK
   if [ ! $AFREE ];then
    mount -t $AFS /dev/$ATAG /mnt/data > /dev/null 2>&1
    #need to put in a check that it is not mounted ro. the
@@ -235,11 +283,13 @@ $(gettext "Instead, you should first run
    fi
   fi
   if [ $AFREE -ne 0 ];then
-   if [ "$ATAG" = "$PDEV1" -a $AFREE -gt 256 ];then #120327
+   if [ "$ATAG" = "$PDEV1" -a $AFREE -gt $DU_INITRD_PUP_RW ];then #120327
     echo -n " --default-item ${ATAG}" > /tmp/shutdownconfig_deftag
     echo "${ATAG} \"f.s.: $AFS  `gettext 'Size:'` ${ASIZE}M  `gettext 'Free:'` ${AFREE}M `gettext '*RECOMMENDED*'`\" " >> /tmp/schoices.txt
+   elif [ "$ATAG" = "$PDEV1" -a $AFREE -le $DU_INITRD_PUP_RW ];then 
+   : # do nothing, else incomplete files would be copied into the save-file.
    else
-    echo "${ATAG} \"`gettext 'Filesystem:'` $AFS  `gettext 'Size:'` ${ASIZE}M  `gettext 'Free:'` ${AFREE}M\" " >> /tmp/schoices.txt
+    echo -e "${ATAG} \"`gettext 'Filesystem:'` $AFS\t`gettext 'Size:'` ${ASIZE}M \t`gettext 'Free:'` ${AFREE}M\" " >> /tmp/schoices.txt
    fi
   fi
  done
@@ -463,13 +513,21 @@ $(eval_gettext 'To quit without saving,
  fi
  
  #we should check to see that there is enough space on the partition...
- PARTFREE=`df | grep "$SMNTPT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
+ PARTFREE=`df -k | grep "$SMNTPT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
  [ ! $PARTFREE ] && PARTFREE=0
  [ $PARTFREE -lt 32768 ] && PARTFREE=`expr $PARTFREE - 1024` #leave some slack space.
  [ $PARTFREE -gt 32768 ] && PARTFREE=`expr $PARTFREE - 8192` #leave some slack space.
- SIZEPFILE=524288 #512M = 524288K
- [ $SIZEPFILE -gt  $PARTFREE ] && SIZEPFILE=$PARTFREE
+ echo PARTFREE=$PARTFREE
+ #SIZEPFILE=524288 #512M = 524288K
+ echo DU_INITRD_PUP_RW=$DU_INITRD_PUP_RW
+ SIZEPFILE=$((DU_INITRD_PUP_RW*1024))
+ echo SIZEPFILE=$SIZEPFILE
+ [ "$SIZEPFILE" = 0 ] && SIZEPFILE=524288 #512M = 524288K
+ echo SIZEPFILE=$SIZEPFILE
+ [ $SIZEPFILE -gt $PARTFREE ] && SIZEPFILE=$PARTFREE
+ echo SIZEPFILE=$SIZEPFILE
  [ $PARTFREE -gt 32768 ] && choosesizefunc $PARTFREE #sets SIZEPFILE
+ echo SIZEPFILE=$SIZEPFILE
  if [ "`echo -n $SAVEFILE | grep '\.[34]fs$'`" != "" ];then #ext3 f.s. needs minimum size.
   [ $SIZEPFILE -lt 5000 ] && return 1 #precaution. rerwin discovered this.
  fi
# 

I suspect the
+    echo -e "${ATAG} \"`gettext 'Filesystem:'` $AFS\t`gettext 'Size:'` ${ASIZE}M \t`gettext 'Free:'` ${AFREE}M\" " >> /tmp/schoices.txt
screwed things .
console gave these :
sdb6,ext2	Size,/WoofCEtest/slackosave.2fs
Usage: mount -V                 : print version
       mount -h                 : print this help
       mount                    : list mounted filesystems
       mount -l                 : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
       mount -a [-t|-O] ...     : mount all stuff from /etc/fstab
       mount device             : mount device at the known place
       mount directory          : mount known device here
       mount -t type dev dir    : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir
or move a subtree:
       mount --move olddir newdir
One can change the type of mount containing the directory dir:
       mount --make-shared dir
       mount --make-slave dir
       mount --make-private dir
       mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
       mount --make-rshared dir
       mount --make-rslave dir
       mount --make-rprivate dir
       mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using  -L label  or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say  man 8 mount .
PARTFREE=-1024
DU_INITRD_PUP_RW=11
SIZEPFILE=11264
SIZEPFILE=11264
SIZEPFILE=-1024
SIZEPFILE=-1024

I am experimenting with TAB \t to achieve such :
TAB ed shutdownconfig puppylinux
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
Seems that I could fix my TAB\t experiment by
@@ -296,7 +346,10 @@ $(eval_gettext 'Or, \Zb${T_abort}\ZB to
   done
  fi
  
- SAVEFS="`echo "$SCHOICES" | grep "^${SAVEPART} " | tr -s " " | cut -f 2 -d ':' | cut -f 2 -d " "`"
+ echo "SCHOICES=$SCHOICES"
+ echo "SAVEPART=$SAVEPART"
+ SAVEFS="`echo "$SCHOICES" | grep "^${SAVEPART} " | tr '\t' ' ' | tr -s '[[:blank:]]' | cut -f 2 -d ':' | cut -f 2 -d " "`"
+ echo "SAVEFS=$SAVEFS"
  SAVEFILE="$PSUBDIR/${DISTRO_FILE_PREFIX}save.2fs"
  [ "$SAVEPART" = "fd0" ] && SAVEFILE="/${DISTRO_FILE_PREFIX}save.2fs"
  PUPSAVE="$SAVEPART,$SAVEFS,$SAVEFILE"
@@ -348,7 +401,12 @@ pupsavefunc() {
 
  if [ "$SMNTPT" = "" ];then
   mkdir /mnt/$SAVEPART 2>/dev/null
+  echo "SAVEFS=$SAVEFS"
+  if [ "$SAVEFS" ] ;then
   mount -t $SAVEFS /dev/$SAVEPART /mnt/$SAVEPART
+  else
+  mount /dev/$SAVEPART /mnt/$SAVEPART
+  fi
   SMNTPT="/mnt/$SAVEPART"
  fi
Mainly by
  - SAVEFS="`echo "$SCHOICES" | grep "^${SAVEPART} " | tr -s " " | cut -f 2 -d ':' | cut -f 2 -d " "`" 
  + SAVEFS="`echo "$SCHOICES" | grep "^${SAVEPART} " | tr '\t' ' ' | tr -s '[[:blank:]]' | cut -f 2 -d ':' | cut -f 2 -d " "`"
To take care for the new invented TAB \t .

So SAVEFS and SCHOICES might be screwed to lead to minus save-files.
Reply | Threaded
Open this post in threaded view
|

Re: Shutdown bug

Karl Godt
Administrator
In reply to this post by Karl Godt
Diff now against the current Slacko Puppy 5.6.3 .
Must add that there are two functions :

check4content
check4wanted

that I want to implement into my fork into functions4puppy .
They check for content or unwanted content .

I must also add that I changed the SIZEPFILE variable generation to fit to my suggestion about using /initrd/pup_rw  back in
#120514 Karl Godt: precaution, save-file must be bigger than size used in ram.
# diff -up /initrd/pup_ro2/usr/sbin/shutdownconfig /usr/sbin/shutdownconfig
--- /initrd/pup_ro2/usr/sbin/shutdownconfig	2013-11-12 20:17:13.000000000 -0100
+++ /usr/sbin/shutdownconfig	2012-11-27 22:22:18.000000000 -0100
@@ -93,6 +93,43 @@ class \"*\" style \"windowstuff\"
 "
 echo "$ORANGEGTKRC" > /tmp/orange_gtkrc${$}
 
+check4content(){ [ "$*" ] && return 0 || return 1; }  # SRTING has content returns 0 , otherwise 1
+  
+check4wanted(){ #params $1=STRING to check, $2=not, $2/$3+ chars to check STRING for
+	  local DEBUGME Q VAR I
+	  echo "$@"
+	  DEBUGME=1
+	  [ "$DEBUGME" = 0 ] && Q='-q';
+	  VAR="$1"
+	  [ "$VAR" ] || return 0;
+	  shift
+	  #echo "$@"
+	  I='';
+	  [ "$1" = not ] && { I='-v';shift; }
+	  #echo "$*"
+	  [ "$*" ] || return 0; 
+	  local IS_UNWANTED=0 count
+	  count(){ 
+		  [ "${1//[[:digit:]]/}" ] && return 1
+		  IS_UNWANTED=$((IS_UNWANTED+$1)); 		}
+	  for param in $@
+	  do
+	    #echo $VAR $I $Q $param
+	    case $param in
+	    space) echo "$VAR" | grep $I $Q '[[:space:]]' && count 0 || count 1;;
+	    blank) echo "$VAR" | grep $I $Q '[[:blank:]]' && count 0 || count 1;;
+	    digit) echo "$VAR" | grep $I $Q '[[:digit:]]' && count 0 || count 1;;
+	    alpha) echo "$VAR" | grep $I $Q '[[:alpha:]]' && count 0 || count 1;;
+	    alnum) echo "$VAR" | grep $I $Q '[[:alnum:]]' && count 0 || count 1;;
+	    punct) echo "$VAR" | grep $I $Q '[[:punct:]]' && count 0 || count 1;;
+	    *)     echo "$VAR" | grep $I $Q -Fw "$param"  && count 0 || count 1;;
+	    esac
+	  done 
+	  echo "IS_UNWANTED=$IS_UNWANTED"
+	  return $IS_UNWANTED;
+		}
+		
+
 choosepartfunc() { 
  #dialog to choose what partition to create ${DISTRO_FILE_PREFIX}save.2fs on...
  T_admin="$(gettext 'administrator')"
@@ -189,14 +226,25 @@ ${FIDOMSG2}"
  ppPID=$!
  SCHOICES=""; DEFTAG=""
  rm -f /tmp/schoices.txt
- rm -f /tmp/shutdownconfig_deftag
+ rm -f /tmp/shutdownconfig_deftag 
  echo "$PARTSLIST" |
  while read APART
  do
+  #echo BLOK
   ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
+  check4content  "$ATAG"  || continue
+  check4wanted "$ATAG" not '/dev/'   || continue
   ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
+  check4content  "$ASIZE" || continue
+  check4wanted "$ASIZE" digit  || continue
   AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
+  check4content  "$AFS"   || continue
+  check4wanted "$AFS" not reiser4 bfs swap none extended || continue
+  #RETVAL=$?; echo RETVAL=$RETVAL
   AFREE=`df -m | grep "/dev/${ATAG} " | tr -s " " | cut -f 4 -d " "`
+  check4content  "$AFREE"     || : #not already mounted
+  check4wanted "$AFREE" digit || : #not already mounted
+  #echo BLOK
   if [ ! $AFREE ];then
    mount -t $AFS /dev/$ATAG /mnt/data > /dev/null 2>&1
    #need to put in a check that it is not mounted ro. the
@@ -235,11 +283,13 @@ $(gettext "Instead, you should first run
    fi
   fi
   if [ $AFREE -ne 0 ];then
-   if [ "$ATAG" = "$PDEV1" -a $AFREE -gt 256 ];then #120327
+   if [ "$ATAG" = "$PDEV1" -a $AFREE -gt $DU_INITRD_PUP_RW ];then #120327
     echo -n " --default-item ${ATAG}" > /tmp/shutdownconfig_deftag
     echo "${ATAG} \"f.s.: $AFS  `gettext 'Size:'` ${ASIZE}M  `gettext 'Free:'` ${AFREE}M `gettext '*RECOMMENDED*'`\" " >> /tmp/schoices.txt
+   elif [ "$ATAG" = "$PDEV1" -a $AFREE -le $DU_INITRD_PUP_RW ];then 
+   : # do nothing, else incomplete files would be copied into the save-file.
    else
-    echo "${ATAG} \"`gettext 'Filesystem:'` $AFS  `gettext 'Size:'` ${ASIZE}M  `gettext 'Free:'` ${AFREE}M\" " >> /tmp/schoices.txt
+    echo -e "${ATAG} \"`gettext 'Filesystem:'` $AFS\t`gettext 'Size:'` ${ASIZE}M \t`gettext 'Free:'` ${AFREE}M\" " >> /tmp/schoices.txt
    fi
   fi
  done
@@ -296,7 +346,10 @@ $(eval_gettext 'Or, \Zb${T_abort}\ZB to
   done
  fi
  
- SAVEFS="`echo "$SCHOICES" | grep "^${SAVEPART} " | tr -s " " | cut -f 2 -d ':' | cut -f 2 -d " "`"
+ echo "SCHOICES=$SCHOICES"
+ echo "SAVEPART=$SAVEPART"
+ SAVEFS="`echo "$SCHOICES" | grep "^${SAVEPART} " | tr '\t' ' ' | tr -s '[[:blank:]]' | cut -f 2 -d ':' | cut -f 2 -d " "`"
+ echo "SAVEFS=$SAVEFS"
  SAVEFILE="$PSUBDIR/${DISTRO_FILE_PREFIX}save.2fs"
  [ "$SAVEPART" = "fd0" ] && SAVEFILE="/${DISTRO_FILE_PREFIX}save.2fs"
  PUPSAVE="$SAVEPART,$SAVEFS,$SAVEFILE"
@@ -348,7 +401,12 @@ pupsavefunc() {
 
  if [ "$SMNTPT" = "" ];then
   mkdir /mnt/$SAVEPART 2>/dev/null
+  echo "SAVEFS=$SAVEFS"
+  if [ "$SAVEFS" ] ;then
   mount -t $SAVEFS /dev/$SAVEPART /mnt/$SAVEPART
+  else
+  mount /dev/$SAVEPART /mnt/$SAVEPART
+  fi
   SMNTPT="/mnt/$SAVEPART"
  fi
  
@@ -463,13 +521,21 @@ $(eval_gettext 'To quit without saving,
  fi
  
  #we should check to see that there is enough space on the partition...
- PARTFREE=`df | grep "$SMNTPT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
+ PARTFREE=`df -k | grep "$SMNTPT" | tr -s " " | head -n 1 | cut -f 4 -d " "`
  [ ! $PARTFREE ] && PARTFREE=0
  [ $PARTFREE -lt 32768 ] && PARTFREE=`expr $PARTFREE - 1024` #leave some slack space.
  [ $PARTFREE -gt 32768 ] && PARTFREE=`expr $PARTFREE - 8192` #leave some slack space.
- SIZEPFILE=524288 #512M = 524288K
- [ $SIZEPFILE -gt  $PARTFREE ] && SIZEPFILE=$PARTFREE
+ echo PARTFREE=$PARTFREE
+ #SIZEPFILE=524288 #512M = 524288K
+ echo DU_INITRD_PUP_RW=$DU_INITRD_PUP_RW
+ SIZEPFILE=$((DU_INITRD_PUP_RW*1024))
+ echo SIZEPFILE=$SIZEPFILE
+ [ "$SIZEPFILE" = 0 ] && SIZEPFILE=524288 #512M = 524288K
+ echo SIZEPFILE=$SIZEPFILE
+ [ $SIZEPFILE -gt $PARTFREE ] && SIZEPFILE=$PARTFREE
+ echo SIZEPFILE=$SIZEPFILE
  [ $PARTFREE -gt 32768 ] && choosesizefunc $PARTFREE #sets SIZEPFILE
+ echo SIZEPFILE=$SIZEPFILE
  if [ "`echo -n $SAVEFILE | grep '\.[34]fs$'`" != "" ];then #ext3 f.s. needs minimum size.
   [ $SIZEPFILE -lt 5000 ] && return 1 #precaution. rerwin discovered this.
  fi
#