Merge pull request #319 from eplanet/fix-etc-mtab
Read /proc/mounts if /etc/mtab can't be read
This commit is contained in:
commit
2d38178063
@ -145,15 +145,22 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
|
|||||||
if (strlen(sanitized) > 1 && sanitized[strlen(sanitized) - 1] == '/')
|
if (strlen(sanitized) > 1 && sanitized[strlen(sanitized) - 1] == '/')
|
||||||
sanitized[strlen(sanitized) - 1] = '\0';
|
sanitized[strlen(sanitized) - 1] = '\0';
|
||||||
FILE *mntentfile = setmntent("/etc/mtab", "r");
|
FILE *mntentfile = setmntent("/etc/mtab", "r");
|
||||||
struct mntent *m;
|
if (mntentfile == NULL) {
|
||||||
|
mntentfile = setmntent("/proc/mounts", "r");
|
||||||
while ((m = getmntent(mntentfile)) != NULL) {
|
}
|
||||||
if (strcmp(m->mnt_dir, sanitized) == 0) {
|
if (mntentfile == NULL) {
|
||||||
mounted = true;
|
fprintf(stderr, "i3status: files /etc/mtab and /proc/mounts aren't accessible\n");
|
||||||
break;
|
} else {
|
||||||
}
|
struct mntent *m;
|
||||||
|
|
||||||
|
while ((m = getmntent(mntentfile)) != NULL) {
|
||||||
|
if (strcmp(m->mnt_dir, sanitized) == 0) {
|
||||||
|
mounted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endmntent(mntentfile);
|
||||||
}
|
}
|
||||||
endmntent(mntentfile);
|
|
||||||
free(sanitized);
|
free(sanitized);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user