From 75a835742e60311f7f27bf44af862caad67e3a23 Mon Sep 17 00:00:00 2001 From: Ingo Bürk Date: Fri, 29 May 2015 08:41:11 +0200 Subject: Use format_not_mounted if the directory for a disk_info block does not exist. This is useful for dynamically mounted devices like thumb drives that get mounted into a directory such as '/media/$UID/$NAME'. fixes #33 --- src/print_disk_info.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/print_disk_info.c') diff --git a/src/print_disk_info.c b/src/print_disk_info.c index 69d7b8c..7fd47b9 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -124,10 +124,11 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch #else struct statvfs buf; - if (statvfs(path, &buf) == -1) - return; - - if (format_not_mounted != NULL) { + if (statvfs(path, &buf) == -1) { + /* If statvfs errors, e.g., due to the path not existing, + * we use the format for a not mounted device. */ + format = format_not_mounted; + } else if (format_not_mounted != NULL) { FILE *mntentfile = setmntent("/etc/mtab", "r"); struct mntent *m; bool found = false; -- cgit v1.2.3