Tiny Core Base > TCB Bugs

printf in /init, it has missing "f"

(1/4) > >>

nick65go:

--- Code: ---tc@box:~$ grep Mem /proc/meminfo
MemTotal:        7078652 kB
MemFree:         5904004 kB
MemAvailable:    6046176 kB
tc@box:~$ grep MemFree /proc/meminfo
MemFree:         5904036 kB
tc@box:~$ grep MemFree /proc/meminfo | awk '{print $2/3}'
1.96799e+06
tc@box:~$ grep MemFree /proc/meminfo | awk '{print $2/3}' | cut -d. -f1
1
tc@box:~$ grep MemTotal /proc/meminfo | awk '{print $2/3}' | cut -d. -f1
2
--- End code ---

the result value (1 or 2) is useless for nr_inodes
--- Code: ---mount / -o remount,size=90%,nr_inodes=$inodes
--- End code ---


so is a missing "f", should be printf (not print) in awk '{print $2/3}'

--- Code: ---tc@box:~$ awk '/MemFree/ {printf "%d",$2/3}' /proc/meminfo
1920377
tc@box:~$ grep MemFree /proc/meminfo | awk '{printf $2/3}' | cut -d. -f1
1920360
--- End code ---

EDIT: What is know-how in dividing FreeMem by 3? Why not 4, or 3.14 etc?

nick65go:
BTW, this mistake started in the past, beginning with TinyCore version 5.4 (kernel 3.8.13) on 32 bits, if somebody has the curiosity to check it.

Paul_123:
Interesting,

Seems awk is doing that based on how much memory is free.......call it 3 times and get a different result (obviously free memory is changing all the time).  This is on my rpi4 with 8GB of ram.


--- Code: ---tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{print $2/3}' | cut -d. -f1
2616180
tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{print $2/3}' | cut -d. -f1
2616096
tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{print $2/3}' | cut -d. -f1
2

--- End code ---


However, so does printf


--- Code: ---tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{printf $2/3}' | cut -d. -f1
2616124
tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{printf $2/3}' | cut -d. -f1
2
tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{printf $2/3}' | cut -d. -f1
2

--- End code ---

Probably need to format the print output


--- Code: ---tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{printf "%d" ,$2/3}' | cut -d. -f1
2616321
tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{printf "%d" ,$2/3}' | cut -d. -f1
2616332
tc@piCore64_Devel:/$ grep MemFree /proc/meminfo | awk '{printf "%d" ,$2/3}' | cut -d. -f1
2616321

--- End code ---

As for the correct inode ratio, I'm sure there is some logic somewhere.

nick65go:
I think it is not calling awk for 3 times in a loop, but it is FreeMem divided by 3. AWK has nothing to do with memory, it about mount parameters pre-calculated.So maybe inode number has a size 1/4 of mem-tmp-filesize, so ratio is 1/3 etc. And maybe is specific to temp_filesys only to gain some speed?
I wish to undestand the logic also. Plus before kernel 3.8 it was not necesary for mount in RAM with parameter nr_inode. I tested on TC 11.1 x64 with 8GB RAM. Maybe it is (again) a bug in busybox 1.31.1 syntax. FYI: [bysybox] mount seems to ignore the unsuitable parameters, so no harm; just curios about the logic for current kernel 5.x.

Greg Erskine:
On my RPi4B - Linux pCPJustBoom 4.19.122-pcpCore_v8 #1 SMP PREEMPT Tue May 26 20:10:39 EDT 2020 aarch64 GNU/Linux

I am getting a proper result 100% of the time. No weird results!

Navigation

[0] Message Index

[#] Next page

Go to full version