Merge pull request #207 from stapelberg/disk_info
disk: sanitize trailing slashes
This commit is contained in:
commit
554db9fcc1
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user