Skip to content

Commit a3f13bd

Browse files
authored
Merge pull request #545 from fastfetch-cli/dev
Release v2.0.5
2 parents 745a8dd + 55444b9 commit a3f13bd

File tree

14 files changed

+186
-74
lines changed

14 files changed

+186
-74
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 2.0.5
2+
3+
Bugfixes:
4+
* Fix segfault when using libxrandr (#544, Display, Linux)
5+
* Don't print 0px (#544, Cursor)
6+
7+
Features:
8+
* Add option `--disk-use-available` (#543)
9+
* Add option `--disk-show-readonly`
10+
111
# 2.0.4
212

313
Bugfixes:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
22

33
project(fastfetch
4-
VERSION 2.0.4
4+
VERSION 2.0.5
55
LANGUAGES C
66
DESCRIPTION "Fast system information tool"
77
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"

doc/json_schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,21 @@
884884
"title": "Set if subvolumes should be printed",
885885
"default": false
886886
},
887+
"showReadOnly": {
888+
"type": "boolean",
889+
"title": "Set if read only volumes should be printed",
890+
"default": false
891+
},
887892
"showUnknown": {
888893
"type": "boolean",
889894
"title": "Set if unknown (unable to detect sizes) volumes should be printed",
890895
"default": false
891896
},
897+
"useAvailable": {
898+
"type": "boolean",
899+
"title": "Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes",
900+
"default": false
901+
},
892902
"key": {
893903
"$ref": "#/$defs/key"
894904
},

src/data/help.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ Module specific options:
129129
--disk-show-external <?value>: Set if external volume should be printed. Default is true
130130
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
131131
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
132+
--disk-show-readonly <?value>: Set if read only volumes should be printed. Default is false
132133
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
134+
--disk-use-available <?value>: Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes. Default is false
133135
--bluetooth-show-disconnected: <?value>: Set if disconnected bluetooth devices should be printed. Default is false
134136
--display-compact-type: <?string>: Set if all displays should be printed in one line. Default is none
135137
--display-detect-name: <?value>: Set if display name should be detected and printed (if supported). Default is false

src/detection/disk/disk.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static int compareDisks(const void* disk1, const void* disk2)
77
return ffStrbufCompAlphabetically(&((const FFDisk*) disk1)->mountpoint, &((const FFDisk*) disk2)->mountpoint);
88
}
99

10-
const char* ffDetectDisks(FFlist* disks)
10+
const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks)
1111
{
1212
const char* error = ffDetectDisksImpl(disks);
1313

@@ -22,7 +22,13 @@ const char* ffDetectDisks(FFlist* disks)
2222
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
2323
{
2424
if(disk->bytesTotal == 0)
25-
disk->type |= FF_DISK_TYPE_UNKNOWN_BIT;
25+
disk->type |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
26+
else
27+
{
28+
disk->bytesUsed = disk->bytesTotal - (
29+
options->calcType == FF_DISK_CALC_TYPE_FREE ? disk->bytesFree : disk->bytesAvailable
30+
);
31+
}
2632
}
2733

2834
return NULL;

src/detection/disk/disk.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ typedef struct FFDisk
1010
FFstrbuf mountpoint;
1111
FFstrbuf filesystem;
1212
FFstrbuf name;
13-
FFDiskType type;
13+
FFDiskVolumeType type;
1414

1515
uint64_t bytesUsed;
16+
uint64_t bytesFree;
17+
uint64_t bytesAvailable;
1618
uint64_t bytesTotal;
1719

1820
uint32_t filesUsed;
@@ -23,6 +25,6 @@ typedef struct FFDisk
2325
* Returns a List of FFDisk, sorted alphabetically by mountpoint.
2426
* If error is not set, disks contains at least one disk.
2527
*/
26-
const char* ffDetectDisks(FFlist* result /* list of FFDisk */);
28+
const char* ffDetectDisks(FFDiskOptions* options, FFlist* result /* list of FFDisk */);
2729

2830
#endif

src/detection/disk/disk_apple.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
77
{
88
// FreeBSD doesn't support these flags
99
if(fs->f_flags & MNT_DONTBROWSE)
10-
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
10+
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
1111
else if(fs->f_flags & MNT_REMOVABLE)
12-
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
12+
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
1313
else
14-
disk->type = FF_DISK_TYPE_REGULAR_BIT;
14+
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
1515

1616
ffStrbufInitS(&disk->name, [NSFileManager.defaultManager displayNameAtPath:@(fs->f_mntonname)].UTF8String);
1717
}

src/detection/disk/disk_bsd.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
1010
if(ffStrbufEqualS(&disk->filesystem, "zfs"))
1111
{
1212
disk->type = !ffStrStartsWith(fs->f_mntfromname, "zroot/") || ffStrStartsWith(fs->f_mntfromname, "zroot/ROOT/")
13-
? FF_DISK_TYPE_REGULAR_BIT
14-
: FF_DISK_TYPE_SUBVOLUME_BIT;
13+
? FF_DISK_VOLUME_TYPE_REGULAR_BIT
14+
: FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
1515
}
1616
else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/"))
17-
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
17+
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
1818
else if(!(fs->f_flags & MNT_LOCAL))
19-
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
19+
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
2020
else
21-
disk->type = FF_DISK_TYPE_REGULAR_BIT;
21+
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
2222

2323
ffStrbufInit(&disk->name);
2424
}
@@ -45,14 +45,19 @@ const char* ffDetectDisksImpl(FFlist* disks)
4545
#endif
4646

4747
disk->bytesTotal = fs->f_blocks * fs->f_bsize;
48-
disk->bytesUsed = disk->bytesTotal - ((uint64_t)fs->f_bfree * fs->f_bsize);
48+
disk->bytesFree = (uint64_t)fs->f_bfree * fs->f_bsize;
49+
disk->bytesAvailable = (uint64_t)fs->f_bavail * fs->f_bsize;
50+
disk->bytesUsed = 0; // To be filled in ./disk.c
4951

5052
disk->filesTotal = (uint32_t) fs->f_files;
5153
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree);
5254

5355
ffStrbufInitS(&disk->mountpoint, fs->f_mntonname);
5456
ffStrbufInitS(&disk->filesystem, fs->f_fstypename);
5557
detectFsInfo(fs, disk);
58+
59+
if(fs->f_flags & MNT_RDONLY)
60+
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
5661
}
5762

5863
return NULL;

src/detection/disk/disk_linux.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
155155
static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDisk, FF_MAYBE_UNUSED const char* options)
156156
{
157157
if(ffStrbufEqualS(&currentDisk->mountpoint, "/") || ffStrbufEqualS(&currentDisk->mountpoint, "/storage/emulated"))
158-
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
158+
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
159159
else if(ffStrbufStartsWithS(&currentDisk->mountpoint, "/mnt/media_rw/"))
160-
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
160+
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
161161
else
162-
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
162+
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
163163
}
164164

165165
#else
@@ -191,13 +191,13 @@ static bool isSubvolume(const FFlist* devices)
191191
static void detectType(const FFlist* devices, FFDisk* currentDisk, const char* options)
192192
{
193193
if(isSubvolume(devices))
194-
currentDisk->type = FF_DISK_TYPE_SUBVOLUME_BIT;
194+
currentDisk->type = FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
195195
else if(strstr(options, "nosuid") != NULL || strstr(options, "nodev") != NULL)
196-
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
196+
currentDisk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
197197
else if(ffStrbufStartsWithS(&currentDisk->mountpoint, "/boot") || ffStrbufStartsWithS(&currentDisk->mountpoint, "/efi"))
198-
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
198+
currentDisk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
199199
else
200-
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
200+
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
201201
}
202202

203203
#endif
@@ -209,10 +209,15 @@ static void detectStats(FFDisk* disk)
209209
memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too
210210

211211
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
212-
disk->bytesUsed = disk->bytesTotal - (fs.f_bfree * fs.f_frsize);
212+
disk->bytesFree = fs.f_bfree * fs.f_frsize;
213+
disk->bytesAvailable = fs.f_bavail * fs.f_frsize;
214+
disk->bytesUsed = 0; // To be filled in ./disk.c
213215

214216
disk->filesTotal = (uint32_t) fs.f_files;
215217
disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree);
218+
219+
if(fs.f_flag & ST_RDONLY)
220+
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
216221
}
217222

218223
const char* ffDetectDisksImpl(FFlist* disks)

src/detection/disk/disk_windows.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,25 @@ const char* ffDetectDisksImpl(FFlist* disks)
2525
FFDisk* disk = ffListAdd(disks);
2626
ffStrbufInitWS(&disk->mountpoint, mountpoint);
2727

28-
uint64_t bytesFree;
29-
if(!GetDiskFreeSpaceExW(mountpoint, NULL, (PULARGE_INTEGER)&disk->bytesTotal, (PULARGE_INTEGER)&bytesFree))
28+
if(!GetDiskFreeSpaceExW(
29+
mountpoint,
30+
(PULARGE_INTEGER)&disk->bytesAvailable,
31+
(PULARGE_INTEGER)&disk->bytesTotal,
32+
(PULARGE_INTEGER)&disk->bytesFree
33+
))
3034
{
3135
disk->bytesTotal = 0;
32-
bytesFree = 0;
36+
disk->bytesFree = 0;
37+
disk->bytesAvailable = 0;
3338
}
34-
disk->bytesUsed = disk->bytesTotal - bytesFree;
39+
disk->bytesUsed = 0; // To be filled in ./disk.c
3540

3641
if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM)
37-
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
42+
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
3843
else if(driveType == DRIVE_FIXED)
39-
disk->type = FF_DISK_TYPE_REGULAR_BIT;
44+
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
4045
else
41-
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
46+
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
4247

4348
ffStrbufInit(&disk->filesystem);
4449
ffStrbufInit(&disk->name);
@@ -47,11 +52,12 @@ const char* ffDetectDisksImpl(FFlist* disks)
4752
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa#remarks
4853
UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
4954

55+
DWORD diskFlags;
5056
BOOL result = GetVolumeInformationW(mountpoint,
5157
diskName, sizeof(diskName) / sizeof(*diskName), //Volume name
5258
NULL, //Serial number
5359
NULL, //Max component length
54-
NULL, //File system flags
60+
&diskFlags, //File system flags
5561
diskFileSystem, sizeof(diskFileSystem) / sizeof(*diskFileSystem)
5662
);
5763
SetErrorMode(errorMode);
@@ -60,6 +66,8 @@ const char* ffDetectDisksImpl(FFlist* disks)
6066
{
6167
ffStrbufSetWS(&disk->filesystem, diskFileSystem);
6268
ffStrbufSetWS(&disk->name, diskName);
69+
if(diskFlags & FILE_READ_ONLY_VOLUME)
70+
disk->type |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
6371
}
6472

6573
//Unsupported

0 commit comments

Comments
 (0)