CVS commit: src/sys/fs/autofs

2020-04-26 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sun Apr 26 17:00:31 UTC 2020

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

Log Message:
autofs: Silence down a warning which should really be a debug message

taken-from: FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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_vfsops.c
diff -u src/sys/fs/autofs/autofs_vfsops.c:1.10 src/sys/fs/autofs/autofs_vfsops.c:1.11
--- src/sys/fs/autofs/autofs_vfsops.c:1.10	Mon Mar 16 21:20:09 2020
+++ src/sys/fs/autofs/autofs_vfsops.c	Sun Apr 26 17:00:31 2020
@@ -33,7 +33,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.10 2020/03/16 21:20:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.11 2020/04/26 17:00:31 tkusumi Exp $");
 
 
 #include "autofs.h"
@@ -194,7 +194,7 @@ autofs_unmount(struct mount *mp, int mnt
 		flags |= FORCECLOSE;
 	error = vflush(mp, NULL, flags);
 	if (error) {
-		AUTOFS_WARN("vflush failed with error %d", error);
+		AUTOFS_DEBUG("vflush failed with error %d", error);
 		return error;
 	}
 



CVS commit: src/sys/fs/autofs

2020-03-28 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sat Mar 28 17:29:57 UTC 2020

Modified Files:
src/sys/fs/autofs: autofs.c

Log Message:
autofs: Make autofs(5) timeout messages include affected process name and PID

Sync warning message with FreeBSD and DragonFlyBSD.
taken-from: FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/autofs/autofs.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.c
diff -u src/sys/fs/autofs/autofs.c:1.4 src/sys/fs/autofs/autofs.c:1.5
--- src/sys/fs/autofs/autofs.c:1.4	Sat Dec 14 12:01:13 2019
+++ src/sys/fs/autofs/autofs.c	Sat Mar 28 17:29:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $	*/
+/*	$NetBSD: autofs.c,v 1.5 2020/03/28 17:29:56 tkusumi Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.5 2020/03/28 17:29:56 tkusumi Exp $");
 
 #include "autofs.h"
 
@@ -376,8 +376,9 @@ autofs_trigger_one(struct autofs_node *a
 
 	request_error = ar->ar_error;
 	if (request_error)
-		AUTOFS_WARN("request for %s completed with error %d",
-		ar->ar_path, request_error);
+		AUTOFS_WARN("request for %s completed with error %d, "
+		"pid %d (%s)", ar->ar_path, request_error,
+		curproc->p_pid, curproc->p_comm);
 
 	wildcards = ar->ar_wildcards;
 



CVS commit: src/sys/fs/autofs

2019-12-14 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sat Dec 14 12:01:13 UTC 2019

Modified Files:
src/sys/fs/autofs: autofs.c

Log Message:
autofs: Make /dev/autofs cdevsw functions static

Also less confusing since autofs vnops also has autofs_{open,close} in NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/autofs/autofs.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.c
diff -u src/sys/fs/autofs/autofs.c:1.3 src/sys/fs/autofs/autofs.c:1.4
--- src/sys/fs/autofs/autofs.c:1.3	Tue Jan  9 16:19:39 2018
+++ src/sys/fs/autofs/autofs.c	Sat Dec 14 12:01:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $	*/
+/*	$NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.4 2019/12/14 12:01:13 tkusumi Exp $");
 
 #include "autofs.h"
 
@@ -78,9 +78,9 @@ __KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1
 #include 
 #include 
 
-dev_type_open(autofs_open);
-dev_type_close(autofs_close);
-dev_type_ioctl(autofs_ioctl);
+static dev_type_open(autofs_open);
+static dev_type_close(autofs_close);
+static dev_type_ioctl(autofs_ioctl);
 
 const struct cdevsw autofs_cdevsw = {
 	.d_open = autofs_open,
@@ -519,7 +519,7 @@ autofs_ioctl_done(struct autofs_daemon_d
 	return 0;
 }
 
-int
+static int
 autofs_open(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -543,7 +543,7 @@ autofs_open(dev_t dev, int flags, int mo
 	return 0;
 }
 
-int
+static int
 autofs_close(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -555,7 +555,7 @@ autofs_close(dev_t dev, int flags, int m
 	return 0;
 }
 
-int
+static int
 autofs_ioctl(dev_t dev, const u_long cmd, void *data, int flag, struct lwp *l)
 {
 



CVS commit: src/sys/fs/autofs

2018-01-14 Thread Christos Zoulas
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 
-__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 = >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(>am_lock);
 	error = autofs_node_new(NULL, amp, ".", -1, >am_root);
-	if (error) {
-		mutex_exit(>am_lock);
-		goto fail;
-	}
 	mutex_exit(>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(>am_lock);
 fail:
+	mp->mnt_data = NULL;
 	kmem_free(amp, sizeof(*amp));
 	return error;
 }



CVS commit: src/sys/fs/autofs

2018-01-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 13 22:06:21 UTC 2018

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

Log Message:
prevent assert on unmount.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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_vfsops.c
diff -u src/sys/fs/autofs/autofs_vfsops.c:1.2 src/sys/fs/autofs/autofs_vfsops.c:1.3
--- src/sys/fs/autofs/autofs_vfsops.c:1.2	Tue Jan  9 11:19:39 2018
+++ src/sys/fs/autofs/autofs_vfsops.c	Sat Jan 13 17:06:21 2018
@@ -33,7 +33,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.2 2018/01/09 16:19:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.3 2018/01/13 22:06:21 christos Exp $");
 
 
 #include "autofs.h"
@@ -219,6 +219,13 @@ autofs_unmount(struct mount *mp, int mnt
 	while (!RB_EMPTY(>am_root->an_children)) {
 		struct autofs_node *anp;
 		anp = RB_MIN(autofs_node_tree, >am_root->an_children);
+		if (!RB_EMPTY(>an_children)) {
+			AUTOFS_DEBUG("%s: %s has children", __func__,
+			anp->an_name);
+			mutex_exit(>am_lock);
+			return EBUSY;
+		}
+			
 		autofs_node_delete(anp);
 	}
 	autofs_node_delete(amp->am_root);



CVS commit: src/sys/fs/autofs

2018-01-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan  9 16:19:39 UTC 2018

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

Log Message:
fix module attachment and cdevsw


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/autofs/autofs.c
cvs rdiff -u -r1.1 -r1.2 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.c
diff -u src/sys/fs/autofs/autofs.c:1.2 src/sys/fs/autofs/autofs.c:1.3
--- src/sys/fs/autofs/autofs.c:1.2	Tue Jan  9 08:56:00 2018
+++ src/sys/fs/autofs/autofs.c	Tue Jan  9 11:19:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: autofs.c,v 1.2 2018/01/09 13:56:00 martin Exp $	*/
+/*	$NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -68,23 +68,33 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.2 2018/01/09 13:56:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.3 2018/01/09 16:19:39 christos Exp $");
 
 #include "autofs.h"
 
+#include "ioconf.h"
+
 #include 
 #include 
 #include 
 
-static int	autofs_open(dev_t dev, int flags, int mode, struct lwp *l);
-static int	autofs_close(dev_t dev, int flags, int mode, struct lwp *l);
-static int	autofs_ioctl(dev_t dev, const u_long cmd, void *data, int flag,
-struct lwp *l);
-
-struct cdevsw autofs_ops = {
-	.d_open		= autofs_open,
-	.d_close	= autofs_close,
-	.d_ioctl	= autofs_ioctl,
+dev_type_open(autofs_open);
+dev_type_close(autofs_close);
+dev_type_ioctl(autofs_ioctl);
+
+const struct cdevsw autofs_cdevsw = {
+	.d_open = autofs_open,
+	.d_close = autofs_close,
+	.d_read = noread,
+	.d_write = nowrite,
+	.d_ioctl = autofs_ioctl,
+	.d_stop = nostop,
+	.d_tty = notty,
+	.d_poll = nopoll,
+	.d_mmap = nommap,
+	.d_kqfilter = nokqfilter,
+	.d_discard = nodiscard,
+	.d_flag = D_OTHER,
 };
 
 /*
@@ -111,6 +121,11 @@ int autofs_retry_attempts = 3;
 int autofs_retry_delay = 1;
 int autofs_interruptible = 1;
 
+void
+autofsattach(int n)
+{
+}
+
 static int
 autofs_node_cmp(const struct autofs_node *a, const struct autofs_node *b)
 {
@@ -504,7 +519,7 @@ autofs_ioctl_done(struct autofs_daemon_d
 	return 0;
 }
 
-static int
+int
 autofs_open(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -528,7 +543,7 @@ autofs_open(dev_t dev, int flags, int mo
 	return 0;
 }
 
-static int
+int
 autofs_close(dev_t dev, int flags, int mode, struct lwp *l)
 {
 
@@ -540,7 +555,7 @@ autofs_close(dev_t dev, int flags, int m
 	return 0;
 }
 
-static int
+int
 autofs_ioctl(dev_t dev, const u_long cmd, void *data, int flag, struct lwp *l)
 {
 

Index: src/sys/fs/autofs/autofs_vfsops.c
diff -u src/sys/fs/autofs/autofs_vfsops.c:1.1 src/sys/fs/autofs/autofs_vfsops.c:1.2
--- src/sys/fs/autofs/autofs_vfsops.c:1.1	Mon Jan  8 22:31:14 2018
+++ src/sys/fs/autofs/autofs_vfsops.c	Tue Jan  9 11:19:39 2018
@@ -33,7 +33,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.1 2018/01/09 03:31:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.2 2018/01/09 16:19:39 christos Exp $");
 
 
 #include "autofs.h"
@@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: autofs_vfsop
 MODULE(MODULE_CLASS_VFS, autofs, NULL);
 
 static int	autofs_statvfs(struct mount *, struct statvfs *);
+static int	autofs_sysctl_create(void);
 
 static void
 autofs_init(void)
@@ -64,6 +65,10 @@ autofs_init(void)
 	cv_init(_softc->sc_cv, "autofscv");
 	mutex_init(_softc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
 	autofs_softc->sc_dev_opened = false;
+
+	autofs_sysctl_create();
+	workqueue_create(_tmo_wq, "autofstmo",
+	autofs_timeout_wq, NULL, 0, 0, WQ_MPSAFE);
 }
 
 static void
@@ -72,6 +77,8 @@ autofs_done(void)
 	KASSERT(autofs_softc);
 	KASSERT(!autofs_softc->sc_dev_opened);
 
+	workqueue_destroy(autofs_tmo_wq);
+
 	struct autofs_softc *sc = autofs_softc;
 	autofs_softc = NULL;
 
@@ -437,6 +444,8 @@ fail:
 	return error;
 }
 
+extern const struct cdevsw autofs_cdevsw;
+
 static int
 autofs_modcmd(modcmd_t cmd, void *arg)
 {
@@ -451,30 +460,16 @@ autofs_modcmd(modcmd_t cmd, void *arg)
 		if (error)
 			break;
 #ifdef _MODULE
-		error = devsw_attach("autofs", NULL, , _ops,
+		error = devsw_attach("autofs", NULL, , _cdevsw,
 		);
 		if (error) {
 			vfs_detach(_vfsops);
 			break;
 		}
 #endif
-		error = workqueue_create(_tmo_wq, "autofstmo",
-		autofs_timeout_wq, NULL, 0, 0, WQ_MPSAFE);
-		if (error) {
-			devsw_detach(NULL, _ops);
-			vfs_detach(_vfsops);
-			break;
-		}
-
-		error = autofs_sysctl_create();
-		if (error) {
-			workqueue_destroy(autofs_tmo_wq);
-			devsw_detach(NULL, _ops);
-			vfs_detach(_vfsops);
-			break;
-		}
 		break;
 	case MODULE_CMD_FINI:
+#ifdef _MODULE
 		KASSERT(autofs_softc);
 		mutex_enter(_softc->sc_lock);
 		if (autofs_softc->sc_dev_opened) {
@@ -484,9 +479,7 @@ autofs_modcmd(modcmd_t cmd, void *arg)
 		}
 		mutex_exit(_softc->sc_lock);
 
-		

CVS commit: src/sys/fs/autofs

2018-01-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan  9 13:56:00 UTC 2018

Modified Files:
src/sys/fs/autofs: autofs.c

Log Message:
Include  for the atomic funtions used in here.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/autofs/autofs.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.c
diff -u src/sys/fs/autofs/autofs.c:1.1 src/sys/fs/autofs/autofs.c:1.2
--- src/sys/fs/autofs/autofs.c:1.1	Tue Jan  9 03:31:14 2018
+++ src/sys/fs/autofs/autofs.c	Tue Jan  9 13:56:00 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: autofs.c,v 1.1 2018/01/09 03:31:14 christos Exp $	*/
+/*	$NetBSD: autofs.c,v 1.2 2018/01/09 13:56:00 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -68,10 +68,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.1 2018/01/09 03:31:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autofs.c,v 1.2 2018/01/09 13:56:00 martin Exp $");
 
 #include "autofs.h"
 
+#include 
 #include 
 #include