Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Add warn() and die()
[slstatus.git]
/
components
/
disk.c
diff --git
a/components/disk.c
b/components/disk.c
index
1251edb
..
f4031ea
100644
(file)
--- a/
components/disk.c
+++ b/
components/disk.c
@@
-12,12
+12,12
@@
disk_free(const char *mnt)
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
-
fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)
);
+
warn("statvfs '%s':", mnt
);
return NULL;
}
return bprintf("%f",
return NULL;
}
return bprintf("%f",
- (float)fs.f_
bsize * (float)fs.f_bfree
/ 1024 / 1024 / 1024);
+ (float)fs.f_
frsize * (float)fs.f_bavail
/ 1024 / 1024 / 1024);
}
const char *
}
const char *
@@
-26,12
+26,12
@@
disk_perc(const char *mnt)
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
-
fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)
);
+
warn("statvfs '%s':", mnt
);
return NULL;
}
return bprintf("%d", (int)(100 *
return NULL;
}
return bprintf("%d", (int)(100 *
-
(1.0f - ((float)fs.f_bfree
/ (float)fs.f_blocks))));
+
(1.0f - ((float)fs.f_bavail
/ (float)fs.f_blocks))));
}
const char *
}
const char *
@@
-40,12
+40,12
@@
disk_total(const char *mnt)
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
-
fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)
);
+
warn("statvfs '%s':", mnt
);
return NULL;
}
return bprintf("%f",
return NULL;
}
return bprintf("%f",
- (float)fs.f_
b
size * (float)fs.f_blocks / 1024 / 1024 / 1024);
+ (float)fs.f_
fr
size * (float)fs.f_blocks / 1024 / 1024 / 1024);
}
const char *
}
const char *
@@
-54,11
+54,11
@@
disk_used(const char *mnt)
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
struct statvfs fs;
if (statvfs(mnt, &fs) < 0) {
-
fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)
);
+
warn("statvfs '%s':", mnt
);
return NULL;
}
return bprintf("%f",
return NULL;
}
return bprintf("%f",
- (float)fs.f_
b
size * ((float)fs.f_blocks -
+ (float)fs.f_
fr
size * ((float)fs.f_blocks -
(float)fs.f_bfree) / 1024 / 1024 / 1024);
}
(float)fs.f_bfree) / 1024 / 1024 / 1024);
}