svn commit: r357075 - in head/sys: compat/linux kern sys

Edward Tomasz Napierala trasz at FreeBSD.org
Fri Jan 24 11:57:56 UTC 2020


Author: trasz
Date: Fri Jan 24 11:57:55 2020
New Revision: 357075
URL: https://svnweb.freebsd.org/changeset/base/357075

Log:
  Add kern_unmount() and use in Linuxulator.  No functional changes.
  
  Reviewed by:	kib
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D22646

Modified:
  head/sys/compat/linux/linux_file.c
  head/sys/kern/vfs_mount.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/compat/linux/linux_file.c
==============================================================================
--- head/sys/compat/linux/linux_file.c	Fri Jan 24 11:22:33 2020	(r357074)
+++ head/sys/compat/linux/linux_file.c	Fri Jan 24 11:57:55 2020	(r357075)
@@ -1107,11 +1107,8 @@ out:
 int
 linux_oldumount(struct thread *td, struct linux_oldumount_args *args)
 {
-	struct linux_umount_args args2;
 
-	args2.path = args->path;
-	args2.flags = 0;
-	return (linux_umount(td, &args2));
+	return (kern_unmount(td, args->path, 0));
 }
 #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
 
@@ -1119,16 +1116,19 @@ linux_oldumount(struct thread *td, struct linux_oldumo
 int
 linux_umount(struct thread *td, struct linux_umount_args *args)
 {
-	struct unmount_args bsd;
 	int flags;
 
 	flags = 0;
-	if ((args->flags & LINUX_MNT_FORCE) != 0)
+	if ((args->flags & LINUX_MNT_FORCE) != 0) {
+		args->flags &= ~LINUX_MNT_FORCE;
 		flags |= MNT_FORCE;
+	}
+	if (args->flags != 0) {
+		linux_msg(td, "unsupported umount2 flags %#x", args->flags);
+		return (EINVAL);
+	}
 
-	bsd.path = args->path;
-	bsd.flags = flags;
-	return (sys_unmount(td, &bsd));
+	return (kern_unmount(td, args->path, flags));
 }
 #endif
 

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Fri Jan 24 11:22:33 2020	(r357074)
+++ head/sys/kern/vfs_mount.c	Fri Jan 24 11:57:55 2020	(r357075)
@@ -1294,12 +1294,19 @@ struct unmount_args {
 int
 sys_unmount(struct thread *td, struct unmount_args *uap)
 {
+
+	return (kern_unmount(td, uap->path, uap->flags));
+}
+
+int
+kern_unmount(struct thread *td, const char *path, int flags)
+{
 	struct nameidata nd;
 	struct mount *mp;
 	char *pathbuf;
 	int error, id0, id1;
 
-	AUDIT_ARG_VALUE(uap->flags);
+	AUDIT_ARG_VALUE(flags);
 	if (jailed(td->td_ucred) || usermount == 0) {
 		error = priv_check(td, PRIV_VFS_UNMOUNT);
 		if (error)
@@ -1307,12 +1314,12 @@ sys_unmount(struct thread *td, struct unmount_args *ua
 	}
 
 	pathbuf = malloc(MNAMELEN, M_TEMP, M_WAITOK);
-	error = copyinstr(uap->path, pathbuf, MNAMELEN, NULL);
+	error = copyinstr(path, pathbuf, MNAMELEN, NULL);
 	if (error) {
 		free(pathbuf, M_TEMP);
 		return (error);
 	}
-	if (uap->flags & MNT_BYFSID) {
+	if (flags & MNT_BYFSID) {
 		AUDIT_ARG_TEXT(pathbuf);
 		/* Decode the filesystem ID. */
 		if (sscanf(pathbuf, "FSID:%d:%d", &id0, &id1) != 2) {
@@ -1359,7 +1366,7 @@ sys_unmount(struct thread *td, struct unmount_args *ua
 		 * now, so in the !MNT_BYFSID case return the more likely
 		 * EINVAL for compatibility.
 		 */
-		return ((uap->flags & MNT_BYFSID) ? ENOENT : EINVAL);
+		return ((flags & MNT_BYFSID) ? ENOENT : EINVAL);
 	}
 
 	/*
@@ -1369,7 +1376,7 @@ sys_unmount(struct thread *td, struct unmount_args *ua
 		vfs_rel(mp);
 		return (EINVAL);
 	}
-	error = dounmount(mp, uap->flags, td);
+	error = dounmount(mp, flags, td);
 	return (error);
 }
 

Modified: head/sys/sys/syscallsubr.h
==============================================================================
--- head/sys/sys/syscallsubr.h	Fri Jan 24 11:22:33 2020	(r357074)
+++ head/sys/sys/syscallsubr.h	Fri Jan 24 11:57:55 2020	(r357075)
@@ -315,6 +315,7 @@ int	kern_wait6(struct thread *td, enum idtype idtype, 
 int	kern_writev(struct thread *td, int fd, struct uio *auio);
 int	kern_socketpair(struct thread *td, int domain, int type, int protocol,
 	    int *rsv);
+int	kern_unmount(struct thread *td, const char *path, int flags);
 
 /* flags for kern_sigaction */
 #define	KSA_OSIGSET	0x0001	/* uses osigact_t */


More information about the svn-src-all mailing list