mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
@@ -9,6 +9,7 @@ typedef struct FFBtrfsDiskUsage
|
||||
uint64_t used;
|
||||
const char* type;
|
||||
bool dup;
|
||||
uint8_t copies; // 1=single/raid0/raid5/raid6, 2=dup/raid1/raid10, 3=raid1c3, 4=raid1c4
|
||||
} FFBtrfsDiskUsage;
|
||||
|
||||
typedef struct FFBtrfsResult
|
||||
|
||||
@@ -81,6 +81,15 @@ static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buff
|
||||
item->allocation[index].used = ffStrbufToUInt(buffer, 0); \
|
||||
\
|
||||
item->allocation[index].dup = faccessat(subfd, #_type "/dup/", F_OK, 0) == 0; \
|
||||
do { \
|
||||
uint8_t _copies = 1; \
|
||||
if (faccessat(subfd, #_type "/raid1c4/", F_OK, 0) == 0) _copies = 4; \
|
||||
else if (faccessat(subfd, #_type "/raid1c3/", F_OK, 0) == 0) _copies = 3; \
|
||||
else if (faccessat(subfd, #_type "/raid1/", F_OK, 0) == 0) _copies = 2; \
|
||||
else if (faccessat(subfd, #_type "/raid10/", F_OK, 0) == 0) _copies = 2; \
|
||||
else if (item->allocation[index].dup) _copies = 2; /* DUP on single device */ \
|
||||
item->allocation[index].copies = _copies; \
|
||||
} while(0); \
|
||||
\
|
||||
item->allocation[index].type = #_type;
|
||||
|
||||
@@ -90,6 +99,9 @@ static const char* detectAllocation(FFBtrfsResult* item, int dfd, FFstrbuf* buff
|
||||
|
||||
#undef FF_BTRFS_DETECT_TYPE
|
||||
|
||||
if (item->allocation[0].copies > 1) // index 0 = data
|
||||
item->totalSize /= item->allocation[0].copies;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ bool ffGenerateBtrfsJsonResult(FF_MAYBE_UNUSED FFBtrfsOptions* options, yyjson_m
|
||||
yyjson_mut_val* item = yyjson_mut_arr_add_obj(doc, allocation);
|
||||
yyjson_mut_obj_add_str(doc, item, "type", btrfs->allocation[i].type);
|
||||
yyjson_mut_obj_add_bool(doc, item, "dup", btrfs->allocation[i].dup);
|
||||
yyjson_mut_obj_add_uint(doc, item, "copies", btrfs->allocation[i].copies);
|
||||
yyjson_mut_obj_add_uint(doc, item, "used", btrfs->allocation[i].used);
|
||||
yyjson_mut_obj_add_uint(doc, item, "total", btrfs->allocation[i].total);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user