-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblk_dev_info.c
63 lines (52 loc) · 1.2 KB
/
blk_dev_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "blk_dev_info.h"
#include <stdio.h>
#include <string.h>
struct blk_dev_info*
blk_dev_info_create(
)
{
struct blk_dev_info* bdi;
if (NULL != (bdi = calloc(1, sizeof(struct blk_dev_info))))
blk_dev_info_init(bdi);
return bdi;
}
void
blk_dev_info_destroy(
struct blk_dev_info* bdi
)
{
blk_dev_info_cleanup(bdi);
free(bdi);
}
void
blk_dev_info_init(
struct blk_dev_info* bdi
)
{
static const struct blk_dev_info template = BLK_DEV_INFO_STATIC_INIT;
memcpy(bdi, &template, sizeof(struct blk_dev_info));
}
void
blk_dev_info_cleanup(
struct blk_dev_info* bdi
)
{
if (bdi)
{
free(bdi->model);
free(bdi->serial);
}
}
void
blk_dev_info_dump(
const struct blk_dev_info* bdi
, int indent
)
{
printf( "%*.*sModel: %s\n", indent, indent, "", bdi->model);
printf( "%*.*sSerial: %s\n", indent, indent, "", bdi->serial);
printf( "%*.*sSize: %lu\n", indent, indent, "", bdi->size_byt);
printf( "%*.*sPwr. on Sec: %ld\n", indent, indent, "", bdi->smt_pwr_on_sec);
printf( "%*.*sTemp: %f\n", indent, indent, "", bdi->smt_temp_kel);
printf( "%*.*sBad Sect.: %ld\n", indent, indent, "", bdi->smt_bad_sect);
}