s243a

initrd/init:load_sfs_file (tahrpup)

Apr 15th, 2018
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.81 KB | None | 0 0
  1. load_sfs_file() { #Line 315 of initrd/init
  2.  [ "$LOADMSG" ] && echo -n "$(printf "${L_LOADING_FILE}" "$ONE_BASENAME" "$LOADMSG")" > /dev/console
  3.  if [ "$COPY2RAM" = "" ];then
  4.   COPY2RAM="no"
  5.   #if there's heaps of ram, copy puppy.sfs to a tmpfs...
  6.   #v405 fast media plus more than 256MB ram then definitely worth copying to ram...
  7.   SIZESFSK=$(du -k $ONE_FN | cut -f 1)
  8.   SIZESFSK=$(($SIZESFSK + 1000)) #some slack.
  9.   MINRAM2CPY=$(($SIZESFSK * 2)) #100222 technosaurus: in case of very big puppies.
  10.   #decide whether to copy .sfs's to ram
  11.   [ "$PNOCOPY" = "yes" ] || COPYCONTENDER='yes'
  12.   [ "$PCOPY" = "yes" ] && COPYCONTENDER='yes'
  13.   [ "$PRAMONLY" = "yes" ] && COPYCONTENDER='yes'
  14.   [ "$COPYCONTENDER" = "yes" ] && [ $RAMSIZE -gt 400000 ] && [ $RAMSIZE -gt $MINRAM2CPY ] && COPY2RAM="yes"
  15.  fi
  16.  if [ "$COPY2RAM" = "yes" ];then
  17.   SIZEZK=$(du -k $ONE_FN | cut -f 1)
  18.   TFREEK=$(df | grep -m1 ' /mnt/tmpfs' | tr -s ' ' | cut -f 4 -d ' ')
  19.   if [ $TFREEK -gt $SIZEZK ];then
  20.    if [ "$ONE_MP" = "" ];then #101101 humongous initrd.
  21.     mv -af $ONE_FN /mnt/tmpfs/
  22.    else
  23.     [ "$LOADMSG" ] && [ "$COPYMSG" ] && echo -en " \\033[1;35m${COPYMSG}\\033[0;39m" > /dev/console #purple.
  24.     TOTAL_SIZEK_SFS_RAM=$(($TOTAL_SIZEK_SFS_RAM + $SIZEZK))
  25.     cp -af $ONE_FN /mnt/tmpfs/
  26.    fi
  27.    sync
  28.    setup_loop_sfs /mnt/tmpfs/$ONE_BASENAME
  29.   else
  30.    setup_loop_sfs $ONE_FN
  31.    [ "$ONE_PART" != "rootfs" ] && KEEPMOUNTED="${KEEPMOUNTED}${ONE_PART} "
  32.   fi
  33.  else
  34.   setup_loop_sfs $ONE_FN
  35.   [ "$ONE_PART" != "rootfs" ] && KEEPMOUNTED="${KEEPMOUNTED}${ONE_PART} "
  36.  fi
  37.  SFS_MP="/pup_${ONE_SFX}"
  38.  [ "$ONE_SFX" = "p" ] && SFS_MP="/pup_ro2"
  39.  [ -d "$SFS_MP" ] || mkdir $SFS_MP
  40.  mount -r -t squashfs -o noatime $ONE_LOOP $SFS_MP > /dev/console 2>&1
  41.  STATUS=$?
  42.  [ $STATUS -eq 0 ] && ONE_LAYER="$SFS_MP=rr"
  43.  [ "$LOADMSG" ] && check_status $STATUS
  44. }
Advertisement
Add Comment
Please, Sign In to add comment