mount: do not guess mount as NFS if "hostname:" contains slashes

function                                             old     new   delta
singlemount                                         1273    1295     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2020-12-05 14:14:11 +01:00
parent 758c2bd58e
commit b1eedfcfa1

View File

@ -2064,15 +2064,19 @@ static int singlemount(struct mntent *mp, int ignore_busy)
} }
// Might this be an NFS filesystem? // Might this be an NFS filesystem?
if ((!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs")) if (!(vfsflags & (MS_BIND | MS_MOVE))
&& strchr(mp->mnt_fsname, ':') != NULL && (!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs"))
&& !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)) ) {
char *colon = strchr(mp->mnt_fsname, ':');
if (colon /* looks like "hostname:..." */
&& strchrnul(mp->mnt_fsname, '/') > colon /* "hostname:" has no slashes */
) { ) {
if (!mp->mnt_type) if (!mp->mnt_type)
mp->mnt_type = (char*)"nfs"; mp->mnt_type = (char*)"nfs";
rc = nfsmount(mp, vfsflags, filteropts); rc = nfsmount(mp, vfsflags, filteropts);
goto report_error; goto report_error;
} }
}
// Look at the file. (Not found isn't a failure for remount, or for // Look at the file. (Not found isn't a failure for remount, or for
// a synthetic filesystem like proc or sysfs.) // a synthetic filesystem like proc or sysfs.)