master ohmu/fastfetch-openbsd / src / modules / disk / disk.c
ohmu  ·  2026-10-15
  1#include "common/printing.h"
  2#include "common/jsonconfig.h"
  3#include "common/percent.h"
  4#include "common/size.h"
  5#include "common/time.h"
  6#include "detection/disk/disk.h"
  7#include "modules/disk/disk.h"
  8
  9#ifndef _WIN32
 10    #include <fnmatch.h>
 11#endif
 12
 13#pragma GCC diagnostic ignored "-Wsign-conversion"
 14
 15static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index) {
 16    FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
 17
 18    uint64_t bytesUsed = disk->bytesTotal - disk->bytesFree;
 19
 20    if (options->moduleArgs.key.length == 0) {
 21        ffStrbufSetF(&key, "%s (%s)", FF_MODULE_GET_DISPLAY_NAME(Disk), disk->mountpoint.chars);
 22    } else {
 23        FF_STRBUF_AUTO_DESTROY mountpointLink = ffStrbufCreate();
 24        FF_STRBUF_AUTO_DESTROY nameLink = ffStrbufCreate();
 25#ifdef __linux__
 26        if (getenv("WSL_DISTRO_NAME") != nullptr && getenv("WT_SESSION") != nullptr) {
 27            if (ffStrbufEqualS(&disk->filesystem, "9p") && ffStrbufStartsWithS(&disk->mountpoint, "/mnt/")) {
 28                ffStrbufSetF(&mountpointLink, "\e]8;;file:///%c:/\e\\%s\e]8;;\e\\", disk->mountpoint.chars[5], disk->mountpoint.chars);
 29                ffStrbufSetF(&nameLink, "\e]8;;file:///%c:/\e\\%s\e]8;;\e\\", disk->mountpoint.chars[5], disk->name.chars);
 30            } else {
 31                ffStrbufSetF(&mountpointLink, "\e]8;;file:////wsl.localhost/%s%s\e\\%s\e]8;;\e\\", getenv("WSL_DISTRO_NAME"), disk->mountpoint.chars, disk->mountpoint.chars);
 32                ffStrbufSetF(&nameLink, "\e]8;;file:////wsl.localhost/%s%s\e\\%s\e]8;;\e\\", getenv("WSL_DISTRO_NAME"), disk->mountpoint.chars, disk->name.chars);
 33            }
 34        } else
 35#endif
 36        {
 37            ffStrbufSetF(&mountpointLink, "\e]8;;file://%s\e\\%s\e]8;;\e\\", disk->mountpoint.chars, disk->mountpoint.chars);
 38            ffStrbufSetF(&nameLink, "\e]8;;file://%s\e\\%s\e]8;;\e\\", disk->mountpoint.chars, disk->name.chars);
 39        }
 40
 41        FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
 42                                                                           FF_ARG(disk->mountpoint, "mountpoint"),
 43                                                                           FF_ARG(disk->name, "name"),
 44                                                                           FF_ARG(disk->mountFrom, "mount-from"),
 45                                                                           FF_ARG(options->moduleArgs.keyIcon, "icon"),
 46                                                                           FF_ARG(index, "index"),
 47                                                                           FF_ARG(disk->filesystem, "filesystem"),
 48                                                                           FF_ARG(mountpointLink, "mountpoint-link"),
 49                                                                           FF_ARG(nameLink, "name-link"),
 50                                                                           FF_ARG(FF_MODULE_GET_DISPLAY_NAME(Disk), "module-name"),
 51                                                                       }));
 52    }
 53
 54    FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
 55    ffSizeAppendNum(bytesUsed, &usedPretty);
 56
 57    FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
 58    ffSizeAppendNum(disk->bytesTotal, &totalPretty);
 59
 60    double bytesPercentage = disk->bytesTotal > 0 ? (double) bytesUsed / (double) disk->bytesTotal * 100.0 : 0;
 61    FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
 62
 63    if (options->moduleArgs.outputFormat.length == 0) {
 64        ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
 65
 66        FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
 67
 68        if (disk->bytesTotal > 0) {
 69            if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) {
 70                ffPercentAppendBar(&str, bytesPercentage, options->percent, &options->moduleArgs);
 71                ffStrbufAppendC(&str, ' ');
 72            }
 73
 74            if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) {
 75                ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
 76            }
 77
 78            if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) {
 79                ffPercentAppendNum(&str, bytesPercentage, options->percent, str.length > 0, &options->moduleArgs);
 80                ffStrbufAppendC(&str, ' ');
 81            }
 82        } else {
 83            ffStrbufAppendS(&str, "Unknown ");
 84        }
 85
 86        if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) {
 87            if (disk->filesystem.length) {
 88                ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars);
 89            }
 90
 91            ffStrbufAppendC(&str, '[');
 92            if (disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT) {
 93                ffStrbufAppendS(&str, "External, ");
 94            }
 95            if (disk->type & FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT) {
 96                ffStrbufAppendS(&str, "Subvolume, ");
 97            }
 98            if (disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT) {
 99                ffStrbufAppendS(&str, "Hidden, ");
100            }
101            if (disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT) {
102                ffStrbufAppendS(&str, "Read-only, ");
103            }
104            if (str.chars[str.length - 1] == '[') {
105                ffStrbufSubstrBefore(&str, str.length - 1);
106            } else {
107                ffStrbufTrimRight(&str, ' ');
108                str.chars[str.length - 1] = ']';
109            }
110        }
111
112        ffStrbufTrimRight(&str, ' ');
113        ffStrbufPutTo(&str, stdout);
114    } else {
115        FF_STRBUF_AUTO_DESTROY bytesPercentageNum = ffStrbufCreate();
116        if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) {
117            ffPercentAppendNum(&bytesPercentageNum, bytesPercentage, options->percent, false, &options->moduleArgs);
118        }
119        FF_STRBUF_AUTO_DESTROY bytesPercentageBar = ffStrbufCreate();
120        if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) {
121            ffPercentAppendBar(&bytesPercentageBar, bytesPercentage, options->percent, &options->moduleArgs);
122        }
123
124        double filesPercentage = disk->filesTotal > 0 ? ((double) disk->filesUsed / (double) disk->filesTotal) * 100.0 : 0;
125        FF_STRBUF_AUTO_DESTROY filesPercentageNum = ffStrbufCreate();
126        if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) {
127            ffPercentAppendNum(&filesPercentageNum, filesPercentage, options->percent, false, &options->moduleArgs);
128        }
129        FF_STRBUF_AUTO_DESTROY filesPercentageBar = ffStrbufCreate();
130        if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) {
131            ffPercentAppendBar(&filesPercentageBar, filesPercentage, options->percent, &options->moduleArgs);
132        }
133
134        bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
135        bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
136        bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
137
138        FF_STRBUF_AUTO_DESTROY freePretty = ffStrbufCreate();
139        ffSizeAppendNum(disk->bytesFree, &freePretty);
140
141        uint64_t now = ffTimeGetNow();
142        uint64_t duration = now - disk->createTime;
143        uint32_t milliseconds = (uint32_t) (duration % 1000);
144        duration /= 1000;
145        uint32_t seconds = (uint32_t) (duration % 60);
146        duration /= 60;
147        uint32_t minutes = (uint32_t) (duration % 60);
148        duration /= 60;
149        uint32_t hours = (uint32_t) (duration % 24);
150        duration /= 24;
151        uint32_t days = (uint32_t) duration;
152
153        FFTimeGetAgeResult age = ffTimeGetAge(disk->createTime, now);
154        FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
155                                                                                                     FF_ARG(usedPretty, "size-used"),
156                                                                                                     FF_ARG(totalPretty, "size-total"),
157                                                                                                     FF_ARG(bytesPercentageNum, "size-percentage"),
158                                                                                                     FF_ARG(disk->filesUsed, "files-used"),
159                                                                                                     FF_ARG(disk->filesTotal, "files-total"),
160                                                                                                     FF_ARG(filesPercentageNum, "files-percentage"),
161                                                                                                     FF_ARG(isExternal, "is-external"),
162                                                                                                     FF_ARG(isHidden, "is-hidden"),
163                                                                                                     FF_ARG(disk->filesystem, "filesystem"),
164                                                                                                     FF_ARG(disk->name, "name"),
165                                                                                                     FF_ARG(isReadOnly, "is-readonly"),
166                                                                                                     { FF_ARG_TYPE_STRING, ffTimeToShortStr(disk->createTime), "create-time" },
167                                                                                                     FF_ARG(bytesPercentageBar, "size-percentage-bar"),
168                                                                                                     FF_ARG(filesPercentageBar, "files-percentage-bar"),
169                                                                                                     FF_ARG(days, "days"),
170                                                                                                     FF_ARG(hours, "hours"),
171                                                                                                     FF_ARG(minutes, "minutes"),
172                                                                                                     FF_ARG(seconds, "seconds"),
173                                                                                                     FF_ARG(milliseconds, "milliseconds"),
174                                                                                                     FF_ARG(disk->mountpoint, "mountpoint"),
175                                                                                                     FF_ARG(disk->mountFrom, "mount-from"),
176                                                                                                     FF_ARG(age.years, "years"),
177                                                                                                     FF_ARG(age.daysOfYear, "days-of-year"),
178                                                                                                     FF_ARG(age.yearsFraction, "years-fraction"),
179                                                                                                     FF_ARG(freePretty, "size-free"),
180                                                                                                     FF_ARG(bytesUsed, "bytes-used"),
181                                                                                                     FF_ARG(disk->bytesTotal, "bytes-total"),
182                                                                                                 }));
183    }
184}
185
186bool ffPrintDisk(FFDiskOptions* options) {
187    FF_LIST_AUTO_DESTROY disks = ffListCreate();
188    const char* error = ffDetectDisks(options, &disks);
189
190    if (error) {
191        ffPrintError(FF_MODULE_GET_DISPLAY_NAME(Disk), 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
192        return false;
193    }
194
195    if (disks.length == 0) {
196        ffPrintError(FF_MODULE_GET_DISPLAY_NAME(Disk), 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No disks found");
197        return false;
198    }
199
200    uint32_t index = 0;
201    FF_LIST_FOR_EACH (FFDisk, disk, disks) {
202        if (__builtin_expect(options->folders.length == 0, 1) && (disk->type & ~options->showTypes)) {
203            continue;
204        }
205
206        printDisk(options, disk, ++index);
207    }
208
209    FF_LIST_FOR_EACH (FFDisk, disk, disks) {
210        ffStrbufDestroy(&disk->mountFrom);
211        ffStrbufDestroy(&disk->mountpoint);
212        ffStrbufDestroy(&disk->filesystem);
213        ffStrbufDestroy(&disk->name);
214    }
215
216    return true;
217}
218
219static bool setSeparatedList(FFstrbuf* strbuf, yyjson_val* val, char separator) {
220    if (yyjson_is_str(val)) {
221        ffStrbufSetJsonVal(strbuf, val);
222        return true;
223    }
224    if (yyjson_is_arr(val)) {
225        ffStrbufClear(strbuf);
226        yyjson_val* elem;
227        size_t eidx, emax;
228        yyjson_arr_foreach (val, eidx, emax, elem) {
229            if (yyjson_is_str(elem)) {
230                if (strbuf->length > 0) {
231                    ffStrbufAppendC(strbuf, separator);
232                }
233                ffStrbufAppendJsonVal(strbuf, elem);
234            }
235        }
236        return true;
237    }
238    return false;
239}
240
241void ffParseDiskJsonObject(FFDiskOptions* options, yyjson_val* module) {
242    yyjson_val *key, *val;
243    size_t idx, max;
244    yyjson_obj_foreach (module, idx, max, key, val) {
245        if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
246            continue;
247        }
248
249        if (unsafe_yyjson_equals_str(key, "folders")) {
250            setSeparatedList(&options->folders, val, FF_DISK_FOLDER_SEPARATOR);
251            continue;
252        }
253
254        if (unsafe_yyjson_equals_str(key, "hideFolders")) {
255            setSeparatedList(&options->hideFolders, val, FF_DISK_FOLDER_SEPARATOR);
256            continue;
257        }
258
259        if (unsafe_yyjson_equals_str(key, "hideFS")) {
260            setSeparatedList(&options->hideFS, val, ':');
261            continue;
262        }
263
264        if (unsafe_yyjson_equals_str(key, "showRegular")) {
265            if (yyjson_get_bool(val)) {
266                options->showTypes |= FF_DISK_VOLUME_TYPE_REGULAR_BIT;
267            } else {
268                options->showTypes &= ~FF_DISK_VOLUME_TYPE_REGULAR_BIT;
269            }
270            continue;
271        }
272
273        if (unsafe_yyjson_equals_str(key, "showExternal")) {
274            if (yyjson_get_bool(val)) {
275                options->showTypes |= FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
276            } else {
277                options->showTypes &= ~FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
278            }
279            continue;
280        }
281
282        if (unsafe_yyjson_equals_str(key, "showHidden")) {
283            if (yyjson_get_bool(val)) {
284                options->showTypes |= FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
285            } else {
286                options->showTypes &= ~FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
287            }
288            continue;
289        }
290
291        if (unsafe_yyjson_equals_str(key, "showSubvolumes")) {
292            if (yyjson_get_bool(val)) {
293                options->showTypes |= FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
294            } else {
295                options->showTypes &= ~FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT;
296            }
297            continue;
298        }
299
300        if (unsafe_yyjson_equals_str(key, "showReadOnly")) {
301            if (yyjson_get_bool(val)) {
302                options->showTypes |= FF_DISK_VOLUME_TYPE_READONLY_BIT;
303            } else {
304                options->showTypes &= ~FF_DISK_VOLUME_TYPE_READONLY_BIT;
305            }
306            continue;
307        }
308
309        if (unsafe_yyjson_equals_str(key, "showUnknown")) {
310            if (yyjson_get_bool(val)) {
311                options->showTypes |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
312            } else {
313                options->showTypes &= ~FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
314            }
315            continue;
316        }
317
318        if (unsafe_yyjson_equals_str(key, "useAvailable")) {
319            if (yyjson_get_bool(val)) {
320                options->calcType = FF_DISK_CALC_TYPE_AVAILABLE;
321            } else {
322                options->calcType = FF_DISK_CALC_TYPE_FREE;
323            }
324            continue;
325        }
326
327        if (ffPercentParseJsonObject(key, val, &options->percent)) {
328            continue;
329        }
330
331        ffPrintError(FF_MODULE_GET_DISPLAY_NAME(Disk), 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
332    }
333}
334
335[[gnu::cold]]
336void ffGenerateDiskJsonConfig(FFDiskOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
337    ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
338
339    yyjson_mut_obj_add_bool(doc, module, "showRegular", !!(options->showTypes & FF_DISK_VOLUME_TYPE_REGULAR_BIT));
340
341    yyjson_mut_obj_add_bool(doc, module, "showExternal", !!(options->showTypes & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT));
342
343    yyjson_mut_obj_add_bool(doc, module, "showHidden", !!(options->showTypes & FF_DISK_VOLUME_TYPE_HIDDEN_BIT));
344
345    yyjson_mut_obj_add_bool(doc, module, "showSubvolumes", !!(options->showTypes & FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT));
346
347    yyjson_mut_obj_add_bool(doc, module, "showReadOnly", !!(options->showTypes & FF_DISK_VOLUME_TYPE_READONLY_BIT));
348
349    yyjson_mut_obj_add_bool(doc, module, "showUnknown", !!(options->showTypes & FF_DISK_VOLUME_TYPE_UNKNOWN_BIT));
350
351    yyjson_mut_obj_add_strbuf(doc, module, "folders", &options->folders);
352
353    yyjson_mut_obj_add_strbuf(doc, module, "hideFolders", &options->hideFolders);
354
355    yyjson_mut_obj_add_strbuf(doc, module, "hideFS", &options->hideFS);
356
357    yyjson_mut_obj_add_bool(doc, module, "useAvailable", options->calcType == FF_DISK_CALC_TYPE_AVAILABLE);
358
359    ffPercentGenerateJsonConfig(doc, module, options->percent);
360}
361
362bool ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
363    FF_LIST_AUTO_DESTROY disks = ffListCreate();
364    const char* error = ffDetectDisks(options, &disks);
365
366    if (error) {
367        yyjson_mut_obj_add_str(doc, module, "error", error);
368        return false;
369    }
370
371    yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
372
373    FF_LIST_FOR_EACH (FFDisk, item, disks) {
374        yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
375
376        yyjson_mut_val* bytes = yyjson_mut_obj_add_obj(doc, obj, "bytes");
377        yyjson_mut_obj_add_uint(doc, bytes, "free", item->bytesFree);
378        yyjson_mut_obj_add_uint(doc, bytes, "total", item->bytesTotal);
379
380        yyjson_mut_val* files = yyjson_mut_obj_add_obj(doc, obj, "files");
381        if (item->filesTotal == 0 && item->filesUsed == 0) {
382            yyjson_mut_obj_add_null(doc, files, "total");
383            yyjson_mut_obj_add_null(doc, files, "used");
384        } else {
385            yyjson_mut_obj_add_uint(doc, files, "total", item->filesTotal);
386            yyjson_mut_obj_add_uint(doc, files, "used", item->filesUsed);
387        }
388
389        yyjson_mut_obj_add_strbuf(doc, obj, "filesystem", &item->filesystem);
390        yyjson_mut_obj_add_strbuf(doc, obj, "mountpoint", &item->mountpoint);
391        yyjson_mut_obj_add_strbuf(doc, obj, "mountFrom", &item->mountFrom);
392        yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name);
393        yyjson_mut_val* typeArr = yyjson_mut_obj_add_arr(doc, obj, "volumeType");
394        if (item->type & FF_DISK_VOLUME_TYPE_REGULAR_BIT) {
395            yyjson_mut_arr_add_str(doc, typeArr, "Regular");
396        }
397        if (item->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT) {
398            yyjson_mut_arr_add_str(doc, typeArr, "External");
399        }
400        if (item->type & FF_DISK_VOLUME_TYPE_SUBVOLUME_BIT) {
401            yyjson_mut_arr_add_str(doc, typeArr, "Subvolume");
402        }
403        if (item->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT) {
404            yyjson_mut_arr_add_str(doc, typeArr, "Hidden");
405        }
406        if (item->type & FF_DISK_VOLUME_TYPE_READONLY_BIT) {
407            yyjson_mut_arr_add_str(doc, typeArr, "Read-only");
408        }
409        if (item->type & FF_DISK_VOLUME_TYPE_UNKNOWN_BIT) {
410            yyjson_mut_arr_add_str(doc, typeArr, "Unknown");
411        }
412
413        const char* pstr = ffTimeToFullStr(item->createTime);
414        if (*pstr) {
415            yyjson_mut_obj_add_strcpy(doc, obj, "createTime", pstr);
416        } else {
417            yyjson_mut_obj_add_null(doc, obj, "createTime");
418        }
419    }
420
421    FF_LIST_FOR_EACH (FFDisk, item, disks) {
422        ffStrbufDestroy(&item->mountpoint);
423        ffStrbufDestroy(&item->mountFrom);
424        ffStrbufDestroy(&item->filesystem);
425        ffStrbufDestroy(&item->name);
426    }
427
428    return true;
429}
430
431void ffInitDiskOptions(FFDiskOptions* options) {
432    ffOptionInitModuleArg(&options->moduleArgs, "");
433
434    ffStrbufInit(&options->folders);
435#if _WIN32 || __APPLE__ || __ANDROID__
436    ffStrbufInit(&options->hideFolders);
437#elif __HAIKU__
438    ffStrbufInitS(&options->hideFolders, "/esp"); // /boot on haiku is the system volume
439#else
440    ffStrbufInitS(&options->hideFolders, "/efi:/boot:/boot/*");
441#endif
442    ffStrbufInit(&options->hideFS);
443    options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT | FF_DISK_VOLUME_TYPE_READONLY_BIT;
444    options->calcType = FF_DISK_CALC_TYPE_FREE;
445    options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
446}
447
448void ffDestroyDiskOptions(FFDiskOptions* options) {
449    ffOptionDestroyModuleArg(&options->moduleArgs);
450    ffStrbufDestroy(&options->folders);
451    ffStrbufDestroy(&options->hideFolders);
452    ffStrbufDestroy(&options->hideFS);
453}
454
455FFModuleBaseInfo ffDiskModuleInfo = {
456    .name = "Disk",
457    .description = "Print partitions, space usage, file system, etc",
458    .displayName = {
459        .en = "Disk",
460        .ar = "القرص",
461        .cs = "Disk",
462        .de = "Festplatte",
463        .es = "Disco",
464        .fi = "Levy",
465        .fr = "Disque",
466        .gl = "Disco",
467        .he = "דיסק",
468        .id = "Disk",
469        .it = "Disco",
470        .ja = "ディスク",
471        .ko = "디스크",
472        .pl = "Dysk",
473        .pt = "Disco",
474        .ru = "Диск",
475        .tr = "Disk",
476        .uk = "Диск",
477        .vi = "Ổ đĩa",
478        .zh_CN = "磁盘分区",
479        .zh_TW = "硬碟分割",
480    },
481    .initOptions = (void*) ffInitDiskOptions,
482    .destroyOptions = (void*) ffDestroyDiskOptions,
483    .parseJsonObject = (void*) ffParseDiskJsonObject,
484    .printModule = (void*) ffPrintDisk,
485    .generateJsonResult = (void*) ffGenerateDiskJsonResult,
486    .generateJsonConfig = (void*) ffGenerateDiskJsonConfig,
487    .formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
488        { "Size used (formatted)", "size-used" },
489        { "Size total (formatted)", "size-total" },
490        { "Size percentage num", "size-percentage" },
491        { "Files used", "files-used" },
492        { "Files total", "files-total" },
493        { "Files percentage num", "files-percentage" },
494        { "True if external volume", "is-external" },
495        { "True if hidden volume", "is-hidden" },
496        { "Filesystem *", "filesystem" },
497        { "Label / name *", "name" },
498        { "True if read-only", "is-readonly" },
499        { "Create time in local timezone", "create-time" },
500        { "Size percentage bar", "size-percentage-bar" },
501        { "Files percentage bar", "files-percentage-bar" },
502        { "Days after creation", "days" },
503        { "Hours after creation", "hours" },
504        { "Minutes after creation", "minutes" },
505        { "Seconds after creation", "seconds" },
506        { "Milliseconds after creation", "milliseconds" },
507        { "Mount point / drive letter *", "mountpoint" },
508        { "Mount from (device path) *", "mount-from" },
509        { "Years integer after creation", "years" },
510        { "Days of year after creation", "days-of-year" },
511        { "Years fraction after creation", "years-fraction" },
512        { "Size free (formatted)", "size-free" },
513        { "Size used (in bytes)", "bytes-used" },
514        { "Size total (in bytes)", "bytes-total" },
515    })),
516    .defaultOrder = 42,
517};