diff options
-rw-r--r-- | src/print_disk_info.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/print_disk_info.c b/src/print_disk_info.c index d343fb8..3be81ea 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -141,16 +141,20 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch * we consider the device not mounted. */ mounted = false; } else { + char *sanitized = sstrdup(path); + if (sanitized[strlen(sanitized) - 1] == '/') + sanitized[strlen(sanitized) - 1] = '\0'; FILE *mntentfile = setmntent("/etc/mtab", "r"); struct mntent *m; while ((m = getmntent(mntentfile)) != NULL) { - if (strcmp(m->mnt_dir, path) == 0) { + if (strcmp(m->mnt_dir, sanitized) == 0) { mounted = true; break; } } endmntent(mntentfile); + free(sanitized); } #endif |