KDK_GET_HARD_DISK_SIZE(3)
✨ KDK_GET_HARD_DISK_SIZE(3) ✨
okay bestie, so this is a page from the Library Functions Manual, and today we're getting into kdk_get_hard_disk_size 💖 it's giving "how big is this disk actually" energy, and honestly? obsessed.
🌸 NAME 🌸
kdk_get_hard_disk_size — 获取硬盘大小 (get hard disk size, for the non-Chinese speakers in the chat 🫶)
🎀 SYNOPSIS 🎀
#include <libkydiskinfo.h>
extern char* kdk_get_hard_disk_size(const char *diskname);
and bestie, don't forget the link step, no cap:
Link with -lkydiskinfo.
🦋 Detailed Description 🦋
So here's the tea 💅 you hand it a diskname — that's the specified disk name — like an absolute path such as /dev/sda, or a value that the kdk_get_hard_disk() function returns as an element, and it uses that to go fetch the hard disk size info for you. literally that's the whole vibe. 🔥
👑 RETURN VALUE 👑
- On success — it returns the hard disk size of type
char*, in MIB ✨ and heads up bestie, the returned string needs to be released byfree— like, actually free it, don't just leave it there being mysterious 🙈 - On error — it returns
NULL.
🌈 EXAMPLES 🌈
here's the full lil demo program, copied exactly because we do not touch the code, ever:
#include "libkydiskinfo.h"
#include <stdio.h>
#include <stdlib.h>
static void display_disk_info(kdk_diskinfo *di)
{
printf("---------------%s------------------0, di->name);
printf("Disk Sectors:%llu0, di->sectors_num);
printf("Disk Sector Size:%u0, di->sector_size);
printf("Disk Size:%f MiB0, di->total_size_MiB);
printf("Disk Model:%s0, di->model ? di->model : "None");
printf("Disk Serial:%s0, di->serial ? di->serial : "None");
printf("Disk Partition Number:%u0, di->partition_nums);
printf("Disk Type:%d0, di->disk_type);
printf("Disk fwrev:%s0, di->fwrev);
}
static void display_disk_list(char **disklist)
{
int count = 0;
while (disklist[count])
{
printf("No. %d %s0, count + 1, disklist[count]);
count ++;
}
}
int main()
{
char **disklist = kdk_get_disklist();
// display_disk_list(disklist);
for (int i = 0; disklist[i]; i++)
{
kdk_diskinfo *sdainfo = kdk_get_diskinfo(disklist[i]);
if (!sdainfo)
{
printf("[%s]Get disk info error.0, disklist[i]);
continue;
}
display_disk_info(sdainfo);
kdk_free_diskinfo(sdainfo);
}
kdk_free_disklist(disklist);
char **di = kdk_get_hard_disk();
size_t num = 0;
while (di[num])
{
printf("No. %ld %s0, num + 1, di[num]);
char *res = kdk_get_hard_disk_size(di[num]);
printf("容量 = %s0, res);
free(res);
res = kdk_get_hard_fwrev(di[num]);
printf("固态版本 = %s0, res);
free(res);
res = kdk_get_hard_vendor(di[num]);
printf("厂商 = %s0, res);
free(res);
res = kdk_get_hard_type(di[num]);
printf("类型 = %s0, res);
free(res);
res = kdk_get_hard_model(di[num]);
printf("型号 = %s0, res);
free(res);
res =kdk_get_hard_serial(di[num]);
printf("序列号 = %s0, res);
free(res);
num ++;
}
kdk_free_disklist(di);
return 0;
}
see how every single res gets its free(res)? that's the main character energy we're looking for, periodt 💅
⭐ CONFORMING TO ⭐
These functions are as per the withdrawn POSIX.1e draft specification. (withdrawn!! rip to that draft, but we move 💀)
The following functions are Linux extensions:
kdk_get_hard_disk()kdk_free_disklist()kdk_get_hard_fwrev()kdk_get_hard_type()kdk_get_hard_model()kdk_get_hard_serial()kdk_get_hard_vendor()
💜 SEE ALSO 💜
kdk_free_disklist(3)kdk_get_hard_fwrev(3)kdk_get_hard_type(3)kdk_get_hard_model(3)kdk_get_hard_serial(3)kdk_get_hard_vendor(3)kdk_get_hard_disk(3)
and that's the whole page bestie!! 🎀 this one's from the Linux Programmer's Manual, dated Thu Aug 10 2023 — go forth, read your disk sizes, free your strings, and slay 💖✨🦋
📦 where this page comes from
- arch rolling: libkysdk-system 3.0.1.4-1 · LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 · LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 · LGPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms