X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fprint_disk_info.c;h=fb7348019b33f1de40a83f7a576d7c8c8193f4fb;hb=b850f5852d0e455c246827a603ac28577a70428d;hp=d343fb89c1b94abe09271feb02a87da78c3235c1;hpb=9375959b68d7c80dbad53a6eb0df1035bb33c6ce;p=i3%2Fi3status diff --git a/src/print_disk_info.c b/src/print_disk_info.c index d343fb8..fb73480 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 (strlen(sanitized) > 1 && 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