On 11/20/19 1:35 PM, Petr Vorel wrote: > From: Joey Hess <joeyh@xxxxxxxxxx> > > Some systems have /etc/mtab symlink to /proc/mounts. In that case > mount.nfs complains: > Can't set permissions on mtab: Operation not permitted > > See https://bugs.debian.org/476577 > > This change makes mount.nfs handle symlinked /etc/mtab the way > umount.nfs and util- linux handle it. > > Cc: Chuck Lever <chuck.lever@xxxxxxxxxx> > Signed-off-by: Joey Hess <joeyh@xxxxxxxxxx> > [ pvorel: took patch from Debian, rebased for 2.4.3-rc1 and created commit > message. Patch is also used in Gentoo. ] > Signed-off-by: Petr Vorel <petr.vorel@xxxxxxxxx> Committed... (tag: nfs-utils-2-4-3-rc2) steved. > --- > Hi, > > if you merge, please keep Joey as the author in git :). > > Kind regards, > Petr > > utils/mount/fstab.c | 2 +- > utils/mount/fstab.h | 1 + > utils/mount/mount.c | 7 +++++++ > 3 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/utils/mount/fstab.c b/utils/mount/fstab.c > index 8b0aaf1a..146d8f40 100644 > --- a/utils/mount/fstab.c > +++ b/utils/mount/fstab.c > @@ -61,7 +61,7 @@ mtab_does_not_exist(void) { > return var_mtab_does_not_exist; > } > > -static int > +int > mtab_is_a_symlink(void) { > get_mtab_info(); > return var_mtab_is_a_symlink; > diff --git a/utils/mount/fstab.h b/utils/mount/fstab.h > index 313bf9b3..8676c8c2 100644 > --- a/utils/mount/fstab.h > +++ b/utils/mount/fstab.h > @@ -7,6 +7,7 @@ > #define _PATH_FSTAB "/etc/fstab" > #endif > > +int mtab_is_a_symlink(void); > int mtab_is_writable(void); > int mtab_does_not_exist(void); > void reset_mtab_info(void); > diff --git a/utils/mount/mount.c b/utils/mount/mount.c > index 91f10877..92a0dfe4 100644 > --- a/utils/mount/mount.c > +++ b/utils/mount/mount.c > @@ -204,6 +204,13 @@ create_mtab (void) { > int flags; > mntFILE *mfp; > > + /* Avoid writing if the mtab is a symlink to /proc/mounts, since > + that would create a file /proc/mounts in case the proc filesystem > + is not mounted, and the fchmod below would also fail. */ > + if (mtab_is_a_symlink()) { > + return EX_SUCCESS; > + } > + > lock_mtab(); > > mfp = nfs_setmntent (MOUNTED, "a+"); >