-
-
Notifications
You must be signed in to change notification settings - Fork 600
Description
General description of bug:
I have compiled and installed fastfech on my Raspberry Pi 2 and everything works fine except disk sizes when disk is more than 4GiB capacity.
Instead of 14GiB for / capacity, fastfetch shows 16777216 TiB !
Output of df -h on the Raspberry:
Filesystem Size Used Avail Use% Mounted on
/dev/root 14G 3.0G 11G 23% /
devtmpfs 355M 0 355M 0% /dev
tmpfs 483M 2.4M 481M 1% /dev/shm
tmpfs 194M 1.1M 193M 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/mmcblk0p1 255M 50M 206M 20% /boot
/dev/zram0 226M 66M 144M 32% /var/log
tmpfs 97M 0 97M 0% /run/user/1001
tmpfs 97M 0 97M 0% /run/user/999
Often helpful questions:
- Does the issue occur across multiple terminal emulators? Y
- Does the issue occur across multiple shells? (bash, zsh, fish, etc) Y
Output of fastfetch --version:
fastfetch 1.7.5-171
Output of fastfetch --load-config devinfo:
_,met$$$$$gg. jef@pi2
,g$$$$$$$$$$$$$$$P. -------
,g$$P" """Y$$.". OS: Raspbian GNU/Linux 11 armv7l
,$$P' `$$$. Host: Raspberry Pi 2 Model B Rev 1.1
',$$P ,ggs. `$$b:Kernel: 5.15.76-v7+
`d$$' ,$P"' . $$$ CPU: ARMv7 rev 5 (v7l) (4) @ 0.9 GHz
$$P d$' , $$$PUptime: 3 days, 12 hours, 53 mins
$$: $. - ,d$$' Processes: 214
$$; Y$b._ _,d$P' Memory: 127.37 MiB / 965.76 MiB (13%)
Y$$. `.`"Y$$$$P"' Swap: 29.25 MiB / 405.62 MiB (7%)
`$$b "-.__ Disk (/): 16777216 TiB / 1.95 GiB (255%)
`Y$$ Disk (/var/hdd.log): 16777216 TiB / 1.95 GiB (255%)
`Y$$. Disk (/var/log): 82.60 MiB / 225.91 MiB (36%) [Removable]
`$$b. Local IP (eth0): 192.168.70.35
`Y$$b. Local IP (docker0): 172.17.0.1
`"Y$b._ Local IP (veth33cf668): 169.254.123.105
`""" Battery: batteryDir doesn't contain any battery folder
Power Adapter: Not supported on this platform
Shell: fish 3.5.1
Terminal: /dev/pts/1
Locale: en_GB.UTF-8
Date & Time: 2022-11-17 14:54:18
████████████████████████
████████████████████████
Output of fastfetch --load-config devinfo-verbose:
_,met$$$$$gg. jef@pi2
,g$$$$$$$$$$$$$$$P. -------
,g$$P" """Y$$.". OS: System: Linux; Name: Raspbian GNU/Linux; Pretty name: Raspbian GNU/Linux 11 (bullseye); ID: raspbian; ID like: debian; Variant: ; Variant ID: ; Version: 11 (bullseye); Version ID: 11; Version codename: bullseye; Build ID: ; Architecture: armv7l
`d$$' ,$P"' . $$$ Host: Family: product_family: ; product_name: Raspberry Pi 2 Model B Rev 1.1
$$P d$' , $$$PKernel: Sysname: Linux; Release: 5.15.76-v7+; Version: #1597 SMP Fri Nov 4 12:13:17 GMT 2022
$$: $. - ,d$$' Uptime: Days: 3; Hours: 12; Minutes: 56; Seconds: 11
$$; Y$b._ _,d$P' Processes: Count: 216
Y$$. `.`"Y$$$$P"' Packages: All: 765; pacman: 0; pacman branch: ; dpkg: 765; rpm: 0; emerge: 0; xbps: 0; apk: 0; flatpak: 0; snap: 0; brew: 0
`Y$$ Shell: Process name: fish; Process path: fish; Process exe: fish; Process version: 3.5.1; User path: /usr/bin/fish; User exe: fish; User version: 3.5.1
`$$b. Resolution: Couldn't detect resolution
`Y$$b. DE: No DE found
`"Y$b._ WM: No WM found
`""" WM Theme: WM Theme needs sucessfull WM detection
Theme: Theme isn't supported in TTY
Icons: Icons aren't supported in TTY
Font: Font isn't supported in TTY
Cursor: Cursor isn't supported in TTY
Terminal: Name: /dev/pts/1, Vendor: /dev/pts/1, CoresPhysical: 1, CoresLogical: fish, CoresOnline: fish, FrequencyMin: fish, FrequencyMax: 3.5.1, Temperature: /usr/bin/fish
Terminal Font: Unknown terminal: /dev/pts/1
CPU: ARMv7 rev 5 (v7l) (4) @ 0.9 GHz
CPU Usage: Percentage: 2.51256
pcilib: Cannot open /proc/bus/pci
pcilib: Cannot find any working access method.
Output of fastfetch --list-features:
libpci
gio
chafa
zlib
sqlite3
Possible solution
After a little research, I found that the culprit was located in disk_linux.c :
statvfs on 32 bits systems returns values with 32 bits integers. Changing use of statvfs to statvsf64 did the job.
diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c
index 2ff4395..8d92288 100644
--- a/src/detection/disk/disk_linux.c
+++ b/src/detection/disk/disk_linux.c
@@ -63,9 +63,9 @@ void ffDetectDisksImpl(FFDiskResult* disks)
disk->type = FF_DISK_TYPE_REGULAR;
//Detects stats
- struct statvfs fs;
- if(statvfs(disk->mountpoint.chars, &fs) != 0)
- memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too
+ struct statvfs64 fs;
+ if(statvfs64(disk->mountpoint.chars, &fs) != 0)
+ memset(&fs, 0, sizeof(struct statvfs64)); //Set all values to 0, so our values get initialized to 0 too
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
disk->bytesUsed = disk->bytesTotal - (fs.f_bavail * fs.f_frsize);
This change should not impact 64 bits Linux, since statvfs and statvfs64 are the same on these systems.
Here is an output of fastfetch --load-config devinfo after the change :
_,met$$$$$gg. jef@pi2
,g$$$$$$$$$$$$$$$P. -------
,g$$P" """Y$$.". OS: Raspbian GNU/Linux 11 armv7l
,$$P' `$$$. Host: Raspberry Pi 2 Model B Rev 1.1
',$$P ,ggs. `$$b:Kernel: 5.15.76-v7+
`d$$' ,$P"' . $$$ CPU: ARMv7 rev 5 (v7l) (4) @ 0.9 GHz
$$P d$' , $$$PUptime: 3 days, 13 hours, 36 mins
$$: $. - ,d$$' Processes: 212
$$; Y$b._ _,d$P' Memory: 126.32 MiB / 965.76 MiB (13%)
Y$$. `.`"Y$$$$P"' Swap: 29.00 MiB / 405.62 MiB (7%)
`$$b "-.__ Disk (/): 3.56 GiB / 13.95 GiB (25%)
`Y$$ Disk (/var/hdd.log): 3.56 GiB / 13.95 GiB (25%)
`Y$$. Disk (/var/log): 82.77 MiB / 225.91 MiB (36%) [Removable]
`$$b. Local IP (eth0): 192.168.70.35
`Y$$b. Local IP (docker0): 172.17.0.1
`"Y$b._ Local IP (veth33cf668): 169.254.123.105
`""" Battery: batteryDir doesn't contain any battery folder
Power Adapter: Not supported on this platform
Shell: fish 3.5.1
Terminal: /dev/pts/1
Locale: en_GB.UTF-8
Date & Time: 2022-11-17 15:37:02
████████████████████████
████████████████████████
There may be other detections (swap, memory) that suffers the same issue on 32 bits Linux.