Module Name:    src
Committed By:   mlelstv
Date:           Mon Nov 28 08:42:20 UTC 2016

Modified Files:
        src/sys/dev: dksubr.c
        src/sys/sys: disk.h param.h

Log Message:
Extend dkdriver interface with a d_firstopen function. This is called
by dk_open() for the first opener and mirrors the use of the d_lastclose
callback.

Bump kernel version for the interface change.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/dksubr.c
cvs rdiff -u -r1.67 -r1.68 src/sys/sys/disk.h
cvs rdiff -u -r1.509 -r1.510 src/sys/sys/param.h

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

Modified files:

Index: src/sys/dev/dksubr.c
diff -u src/sys/dev/dksubr.c:1.91 src/sys/dev/dksubr.c:1.92
--- src/sys/dev/dksubr.c:1.91	Mon Oct 24 17:14:27 2016
+++ src/sys/dev/dksubr.c	Mon Nov 28 08:42:20 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.91 2016/10/24 17:14:27 jdolecek Exp $ */
+/* $NetBSD: dksubr.c,v 1.92 2016/11/28 08:42:20 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.91 2016/10/24 17:14:27 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.92 2016/11/28 08:42:20 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -122,6 +122,7 @@ int
 dk_open(struct dk_softc *dksc, dev_t dev,
     int flags, int fmt, struct lwp *l)
 {
+	const struct dkdriver *dkd = dksc->sc_dkdev.dk_driver;
 	struct	disklabel *lp = dksc->sc_dkdev.dk_label;
 	int	part = DISKPART(dev);
 	int	pmask = 1 << part;
@@ -143,6 +144,15 @@ dk_open(struct dk_softc *dksc, dev_t dev
 	}
 
 	/*
+	 * initialize driver for the first opener
+	 */
+	if (dk->dk_openmask == 0 && dkd->d_firstopen != NULL) {
+		ret = (*dkd->d_firstopen)(dksc->sc_dev, dev, flags, fmt);
+		if (ret)
+			goto done;
+	}
+
+	/*
 	 * If we're init'ed and there are no other open partitions then
 	 * update the in-core disklabel.
 	 */

Index: src/sys/sys/disk.h
diff -u src/sys/sys/disk.h:1.67 src/sys/sys/disk.h:1.68
--- src/sys/sys/disk.h:1.67	Wed Apr 27 02:19:12 2016
+++ src/sys/sys/disk.h	Mon Nov 28 08:42:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: disk.h,v 1.67 2016/04/27 02:19:12 christos Exp $	*/
+/*	$NetBSD: disk.h,v 1.68 2016/11/28 08:42:20 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
@@ -481,6 +481,7 @@ struct dkdriver {
 	int	(*d_dumpblocks)(device_t, void *, daddr_t, int);
 	int	(*d_lastclose)(device_t);
 	int	(*d_discard)(device_t, off_t, off_t);
+	int	(*d_firstopen)(device_t, dev_t, int, int);
 };
 #endif
 

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.509 src/sys/sys/param.h:1.510
--- src/sys/sys/param.h:1.509	Wed Nov  2 03:06:19 2016
+++ src/sys/sys/param.h	Mon Nov 28 08:42:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.509 2016/11/02 03:06:19 pgoyette Exp $	*/
+/*	$NetBSD: param.h,v 1.510 2016/11/28 08:42:20 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799004200	/* NetBSD 7.99.42 */
+#define	__NetBSD_Version__	799004300	/* NetBSD 7.99.43 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)

Reply via email to