- #include <parted/parted.h>
- #include <stdio.h>
- int main(int argc, char* argv[])
- {
- ped_device_probe_all();
- PedDevice *dev = 0;
- while((dev = ped_device_get_next(dev)))
- {
- printf("\\n ==============================================\\n");
- printf("device model: %s\\n", dev->model);
- printf("path: %s\\n",dev->path);
- long long size = (dev->sector_size * dev->length)/(1024*1024*1024);
- printf("size: %lld G\\n", size);
- }
- return 0;
- }
- //该片段来自于http://www.codesnippet.cn/detail/240120131907.html
来源: http://www.codesnippet.cn/detail/240120131907.html