Change /etc/mtab to /proc/self/mounts

Fix misleading error message:

 "The /dev/zfs device is missing and must be created.", if /etc/mtab is missing.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com>
Closes #4680 
Closes #5029
This commit is contained in:
slashdd
2016-09-20 13:07:58 -04:00
committed by Brian Behlendorf
parent 25e2ab16be
commit 792517389f
13 changed files with 53 additions and 43 deletions
+7 -7
View File
@@ -294,11 +294,11 @@ mtab_is_writeable(void)
struct stat st;
int error, fd;
error = lstat(MNTTAB, &st);
error = lstat("/etc/mtab", &st);
if (error || S_ISLNK(st.st_mode))
return (0);
fd = open(MNTTAB, O_RDWR | O_CREAT, 0644);
fd = open("/etc/mtab", O_RDWR | O_CREAT, 0644);
if (fd < 0)
return (0);
@@ -320,21 +320,21 @@ mtab_update(char *dataset, char *mntpoint, char *type, char *mntopts)
mnt.mnt_freq = 0;
mnt.mnt_passno = 0;
fp = setmntent(MNTTAB, "a+");
fp = setmntent("/etc/mtab", "a+");
if (!fp) {
(void) fprintf(stderr, gettext(
"filesystem '%s' was mounted, but %s "
"filesystem '%s' was mounted, but /etc/mtab "
"could not be opened due to error %d\n"),
dataset, MNTTAB, errno);
dataset, errno);
return (MOUNT_FILEIO);
}
error = addmntent(fp, &mnt);
if (error) {
(void) fprintf(stderr, gettext(
"filesystem '%s' was mounted, but %s "
"filesystem '%s' was mounted, but /etc/mtab "
"could not be updated due to error %d\n"),
dataset, MNTTAB, errno);
dataset, errno);
return (MOUNT_FILEIO);
}