Module Name:    src
Committed By:   christos
Date:           Sun Jan 14 22:43:18 UTC 2018

Modified Files:
        src/sys/fs/autofs: autofs_mount.h autofs_vfsops.c

Log Message:
support getargs, fix flush, fix mutex_destroy


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/autofs/autofs_mount.h
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/autofs/autofs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/autofs/autofs_mount.h
diff -u src/sys/fs/autofs/autofs_mount.h:1.1 src/sys/fs/autofs/autofs_mount.h:1.2
--- src/sys/fs/autofs/autofs_mount.h:1.1	Mon Jan  8 22:31:14 2018
+++ src/sys/fs/autofs/autofs_mount.h	Sun Jan 14 17:43:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: autofs_mount.h,v 1.1 2018/01/09 03:31:14 christos Exp $	*/
+/*	$NetBSD: autofs_mount.h,v 1.2 2018/01/14 22:43:18 christos Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -39,9 +39,9 @@
  * This structure should only be used by automount(8).
  */
 struct autofs_args {
-	const char	*from;
-	const char	*master_options;
-	const char	*master_prefix;
+	char	*from;
+	char	*master_options;
+	char	*master_prefix;
 };
 
 #endif /* !_SYS_FS_AUTOFS_AUTOFS_MOUNT_H_ */

Index: src/sys/fs/autofs/autofs_vfsops.c
diff -u src/sys/fs/autofs/autofs_vfsops.c:1.3 src/sys/fs/autofs/autofs_vfsops.c:1.4
--- src/sys/fs/autofs/autofs_vfsops.c:1.3	Sat Jan 13 17:06:21 2018
+++ src/sys/fs/autofs/autofs_vfsops.c	Sun Jan 14 17:43:18 2018
@@ -33,7 +33,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.3 2018/01/13 22:06:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.4 2018/01/14 22:43:18 christos Exp $");
 
 
 #include "autofs.h"
@@ -95,26 +95,39 @@ static int
 autofs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
 {
 	struct autofs_args *args = data;
-	struct autofs_mount *amp;
+	struct autofs_mount *amp = VFSTOAUTOFS(mp);
 	struct statvfs *sbp = &mp->mnt_stat;
 	int error;
 
+	if (mp->mnt_flag & MNT_UPDATE) {
+		if (amp == NULL)
+			return EIO;
+		autofs_flush(amp);
+		return 0;
+	}
+
 	if (!args)
 		return EINVAL;
 
-	/*
-	 * MNT_GETARGS is unsupported.  Autofs is mounted via automount(8) by
-	 * parsing /etc/auto_master instead of regular mount(8) variants with
-	 * -o getargs support, thus not really needed either.
-	 */
-	if (mp->mnt_flag & MNT_GETARGS)
-		return EOPNOTSUPP;
-
-	if (mp->mnt_flag & MNT_UPDATE) {
-		autofs_flush(VFSTOAUTOFS(mp));
-		return 0;
+	if (mp->mnt_flag & MNT_GETARGS) {
+		if (amp == NULL)
+			return EIO;
+		error = copyoutstr(amp->am_from, args->from,
+		    sizeof(amp->am_from), NULL);
+		if (error)
+			return error;
+		error = copyoutstr(amp->am_options, args->master_options,
+		    sizeof(amp->am_options), NULL);
+		if (error)
+			return error;
+		error = copyoutstr(amp->am_prefix, args->master_prefix,
+		    sizeof(amp->am_prefix), NULL);
+		return error;
 	}
 
+	if (amp != NULL)
+		return EBUSY;
+
 	/*
 	 * Allocate the autofs mount.
 	 */
@@ -146,11 +159,9 @@ autofs_mount(struct mount *mp, const cha
 
 	mutex_enter(&amp->am_lock);
 	error = autofs_node_new(NULL, amp, ".", -1, &amp->am_root);
-	if (error) {
-		mutex_exit(&amp->am_lock);
-		goto fail;
-	}
 	mutex_exit(&amp->am_lock);
+	if (error)
+		goto fail1;
 	KASSERT(amp->am_root->an_ino == AUTOFS_ROOTINO);
 
 	autofs_statvfs(mp, sbp);
@@ -159,13 +170,16 @@ autofs_mount(struct mount *mp, const cha
 	error = set_statvfs_info(path, UIO_USERSPACE, args->from, UIO_USERSPACE,
 	    mp->mnt_op->vfs_name, mp, curlwp);
 	if (error)
-		goto fail;
+		goto fail1;
 	strlcpy(amp->am_from, sbp->f_mntfromname, sizeof(amp->am_from));
 	strlcpy(amp->am_on, sbp->f_mntonname, sizeof(amp->am_on));
 
 	return 0;
 
+fail1:
+	mutex_destroy(&amp->am_lock);
 fail:
+	mp->mnt_data = NULL;
 	kmem_free(amp, sizeof(*amp));
 	return error;
 }

Reply via email to