Xinqi Bao's Git

Add warn() and die()
[slstatus.git] / components / disk.c
index bf69875..f4031ea 100644 (file)
@@ -12,7 +12,7 @@ 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 NULL;
        }
 
@@ -26,7 +26,7 @@ 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 NULL;
        }
 
@@ -40,7 +40,7 @@ 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 NULL;
        }
 
@@ -54,7 +54,7 @@ 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 NULL;
        }