More Robust Free Space Checking for ppm
Posted: Wed 26 Feb 2020, 06:32
Puppy use a function called fx_personal_storage_free_mb to determine the free space. This is used in the puppy package manager and if this function fails the ppm will exit:
/woof-code/rootfs-skeleton/usr/local/petget/installmodes.sh#L294
This function (i.e. fx_personal_storage_free_mb), works as follows:
The stat function finds the mount point for the device containing the save file or save file or folder.
Then the df function is used to find the available free space for this mount point:
/woof-code/rootfs-skeleton/etc/rc.d/functions_x#L74
However, there is a weird case where the above function doesn't work but the following does:
I don't completly understand why, but here is some output in my sandbox:
Here's some relevant traced output when building my sandbox:
What I'm doing here is experimenting only binding specific directories from /mnt/home for my sandbox to have access to rather than everything. This is done with a modified version of my sandbox script.
https://pastebin.com/tYfwdvQe
The official project is at:
https://gitlab.com/s243a/psandbox
and some related threads:
SSH/sandbox/chroot folder
woof-CE: sandbox.sh official and modified versions
Remaster a Sandbox
Edit:
Another way to fix it is in the funciton fx_personal_storage_free_mb, use "df -a" rather than "df -a" . The -a option includes "dummy files". I'm not sure what they mean by a dummy file but it seems to include what I want:
Code: Select all
. /etc/rc.d/functions_x
AVAILABLE=$SIZEFREEM
if [ ! "$AVAILABLE" ]; then
echo "Free space estimation error. Exiting" > /tmp/petget_proc/petget/install_status
. /usr/lib/gtkdialog/box_ok "$(gettext 'Free space error')" error "$(gettext 'This is a rare error that fails to report the available free space. It should be OK after a restart')"
clean_up
exit 1
fi
This function (i.e. fx_personal_storage_free_mb), works as follows:
The stat function finds the mount point for the device containing the save file or save file or folder.
Code: Select all
PTN=" $(stat -Lc %m /initrd/${SAVE_LAYER})" ;; #Except for pupmode=2
Code: Select all
while read F1 F2 F3 F4 F5plus ; do
case "$F5plus" in *"$PTN")
SIZEFREEM=${F4} ; break ;;
esac
done <<EOF
However, there is a weird case where the above function doesn't work but the following does:
Code: Select all
df /initrd/pup_rw | sed -n -e'2 {s/ */ /g;p}' | cut -d ' ' -f4
Code: Select all
sandbox# . /etc/rc.d/PUPSTATE
sandbox# echo $PUPMODE
12
sandbox# readlink /initrd/pup_rw
/initrd/mnt/dev_save/arch/32/20.02+7/a32pupsave
sandbox# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
aufs 176493 117494 49966 71% /
unionfs 176493 117494 49966 71% /initrd/mnt/dev_save
/dev/sda2 176493 117494 49966 71% /initrd/mnt/dev_save/git_madness
devtmpfs 1813 0 1813 0% /dev
shmfs 724 105 619 15% /dev/shm
tmpfs 5182 373 4809 8% /initrd/mnt/tmpfs
sandbox# cat /proc/mounts
aufs / aufs rw,relatime,si=cbc5bc9311362e28 0 0
unionfs /initrd/mnt/dev_save aufs rw,relatime,si=cbc5bc920a2bb628 0 0
/dev/sda2 /initrd/mnt/dev_save/arch/32/20.02+7 ext4 rw,noatime 0 0
/dev/sda2 /initrd/mnt/dev_save/git_madness ext4 rw,noatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=1855516k,nr_inodes=463879,mode=755 0 0
none /dev/pts devpts rw,relatime,gid=2,mode=620,ptmxmode=000 0 0
shmfs /dev/shm tmpfs rw,relatime,size=740528k 0 0
none /sys sysfs rw,relatime 0 0
none /proc proc rw,relatime 0 0
tmpfs /initrd/mnt/tmpfs tmpfs rw,relatime,size=5305536k 0 0
Code: Select all
+ mkdir -p /mnt/sb/dev_save/arch/32/20.02+7
+ mount -o bind /mnt/home/arch/32/20.02+7 /mnt/sb/dev_save/arch/32/20.02+7
+ mkdir -p /mnt/sb/dev_save/git_madness
+ mount -o bind /mnt/home/git_madness /mnt/sb/dev_save/git_madness
+ mount -o rbind /mnt/sb/dev_save /mnt/sb/fakeroot/initrd/mnt/dev_save
https://pastebin.com/tYfwdvQe
The official project is at:
https://gitlab.com/s243a/psandbox
and some related threads:
SSH/sandbox/chroot folder
woof-CE: sandbox.sh official and modified versions
Remaster a Sandbox
Edit:
Another way to fix it is in the funciton fx_personal_storage_free_mb, use "df -a" rather than "df -a" . The -a option includes "dummy files". I'm not sure what they mean by a dummy file but it seems to include what I want:
Code: Select all
sandbox# df -a
Filesystem 1K-blocks Used Available Use% Mounted on
aufs 180728044 120318180 51159768 71% /
unionfs 180728044 120318180 51159768 71% /initrd/mnt/dev_save
/dev/sda2 180728044 120318180 51159768 71% /initrd/mnt/dev_save/arch/32/20.02+7
/dev/sda2 180728044 120318180 51159768 71% /initrd/mnt/dev_save/git_madness
devtmpfs 1855516 0 1855516 0% /dev
none 0 0 0 - /dev/pts
shmfs 740528 131108 609420 18% /dev/shm
none 0 0 0 - /sys
none 0 0 0 - /proc
tmpfs 5305536 381172 4924364 8% /initrd/mnt/tmpfs