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:
parent
1b32af1722
commit
b2c92b88cc
@ -178,6 +178,9 @@ int main(int argc, char **argv)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
#endif
|
#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 */
|
/* Ensure that we are only quiet when explicitly told to be */
|
||||||
unsetenv("EINFO_QUIET");
|
unsetenv("EINFO_QUIET");
|
||||||
|
|
||||||
|
@ -297,6 +297,9 @@ getmntfile(const char *file)
|
|||||||
struct mntent *ent = NULL;
|
struct mntent *ent = NULL;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
if (!exists("/etc/fstab"))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
fp = setmntent("/etc/fstab", "r");
|
fp = setmntent("/etc/fstab", "r");
|
||||||
while ((ent = getmntent(fp)))
|
while ((ent = getmntent(fp)))
|
||||||
if (strcmp(file, ent->mnt_dir) == 0)
|
if (strcmp(file, ent->mnt_dir) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user