1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-13 11:15:27 +00:00

fs.cc, linux.cc Use /proc/mounts for list of currently mounted fs (#357)

Per manpage of mount(1) in newer util-linux:

    The programs mount and umount traditionally maintained a list of
    currently mounted filesystems in the file /etc/mtab.  This real mtab
    file is still supported, but on current Linux systems it is better
    to make it a symlink to /proc/mounts instead, because a regular mtab
    file maintained in userspace cannot reliably work with namespaces,
    containers and other advanced Linux features.

In most new Linux (e.g. Debian) /etc/mtab is already symlinked to
/proc/mounts.

See
e778642a9e
for the gory details.
This commit is contained in:
Zak B. Elep 2017-01-31 09:31:35 +08:00 committed by Brenden Matthews
parent 2600d01373
commit c6ef3ba5e7
2 changed files with 3 additions and 3 deletions

View File

@ -151,13 +151,13 @@ void get_fs_type(const char *path, char *result)
#else /* HAVE_STRUCT_STATFS_F_FSTYPENAME */ #else /* HAVE_STRUCT_STATFS_F_FSTYPENAME */
struct mntent *me; struct mntent *me;
FILE *mtab = setmntent("/etc/mtab", "r"); FILE *mtab = setmntent("/proc/mounts", "r");
char *search_path; char *search_path;
int match; int match;
char *slash; char *slash;
if (mtab == NULL) { if (mtab == NULL) {
NORM_ERR("setmntent /etc/mtab: %s", strerror(errno)); NORM_ERR("setmntent /proc/mounts: %s", strerror(errno));
strncpy(result, "unknown", DEFAULT_TEXT_BUFFER_SIZE); strncpy(result, "unknown", DEFAULT_TEXT_BUFFER_SIZE);
return; return;
} }

View File

@ -143,7 +143,7 @@ int check_mount(struct text_object *obj)
if (!obj->data.s) if (!obj->data.s)
return 0; return 0;
if ((mtab = fopen("/etc/mtab", "r"))) { if ((mtab = fopen("/proc/mounts", "r"))) {
char buf1[256], buf2[129]; char buf1[256], buf2[129];
while (fgets(buf1, 256, mtab)) { while (fgets(buf1, 256, mtab)) {