fstabinfo/mountinfo: ensure /etc/fstab exists before calling setmntent

This is based on a patch by A. Wilcox <awilfox.gentoo@foxkit.us>.

X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226

X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226
This commit is contained in:
William Hubbs 2016-06-07 04:31:48 -05:00
parent 1b32af1722
commit b2c92b88cc
2 changed files with 6 additions and 0 deletions

View File

@ -178,6 +178,9 @@ int main(int argc, char **argv)
FILE *fp;
#endif
/* fail if there is no /etc/fstab */
if (!exists("/etc/fstab"))
eerrorx("/etc/fstab does not exist");
/* Ensure that we are only quiet when explicitly told to be */
unsetenv("EINFO_QUIET");

View File

@ -297,6 +297,9 @@ getmntfile(const char *file)
struct mntent *ent = NULL;
FILE *fp;
if (!exists("/etc/fstab"))
return NULL;
fp = setmntent("/etc/fstab", "r");
while ((ent = getmntent(fp)))
if (strcmp(file, ent->mnt_dir) == 0)