Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/dev Pull up revision 1.15 (requested by hannken in ti...



details:   https://anonhg.NetBSD.org/src/rev/82e98f3faa44
branches:  netbsd-3
changeset: 575521:82e98f3faa44
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Apr 21 19:01:40 2005 +0000

description:
Pull up revision 1.15 (requested by hannken in ticket #184):
Support user controllable flags for the snapshot driver:
- Add FSSIOFSET and FSSIOFGET ioctl() to set/get the flags.
- Add FSS_UNCONFIG_ON_CLOSE flag to unconfigure the snapshot device
  on the last close.
Reviewed by: Jason R. Thorpe <thorpej%netbsd.org@localhost>

diffstat:

 sys/dev/fss.c |  50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 46 insertions(+), 4 deletions(-)

diffs (101 lines):

diff -r 95e1502e5efd -r 82e98f3faa44 sys/dev/fss.c
--- a/sys/dev/fss.c     Thu Apr 21 19:01:32 2005 +0000
+++ b/sys/dev/fss.c     Thu Apr 21 19:01:40 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fss.c,v 1.13.2.1 2005/04/21 19:00:24 tron Exp $        */
+/*     $NetBSD: fss.c,v 1.13.2.2 2005/04/21 19:01:40 tron Exp $        */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.13.2.1 2005/04/21 19:00:24 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.13.2.2 2005/04/21 19:01:40 tron Exp $");
 
 #include "fss.h"
 
@@ -172,22 +172,52 @@
 int
 fss_open(dev_t dev, int flags, int mode, struct proc *p)
 {
+       int s, mflag;
        struct fss_softc *sc;
 
+       mflag = (mode == S_IFCHR ? FSS_CDEV_OPEN : FSS_BDEV_OPEN);
+
        if ((sc = FSS_DEV_TO_SOFTC(dev)) == NULL)
                return ENODEV;
 
+       FSS_LOCK(sc, s);
+
+       sc->sc_flags |= mflag;
+
+       FSS_UNLOCK(sc, s);
+
        return 0;
 }
 
 int
 fss_close(dev_t dev, int flags, int mode, struct proc *p)
 {
+       int s, mflag, error;
        struct fss_softc *sc;
 
+       mflag = (mode == S_IFCHR ? FSS_CDEV_OPEN : FSS_BDEV_OPEN);
+
        if ((sc = FSS_DEV_TO_SOFTC(dev)) == NULL)
                return ENODEV;
 
+       FSS_LOCK(sc, s); 
+
+       if ((sc->sc_flags & (FSS_CDEV_OPEN|FSS_BDEV_OPEN)) == mflag) {
+               if ((sc->sc_uflags & FSS_UNCONFIG_ON_CLOSE) != 0 &&
+                   (sc->sc_flags & FSS_ACTIVE) != 0) {
+                       FSS_UNLOCK(sc, s);
+                       error = fss_ioctl(dev, FSSIOCCLR, NULL, FWRITE, p);
+                       if (error)
+                               return error;
+                       FSS_LOCK(sc, s);
+               }
+               sc->sc_uflags &= ~FSS_UNCONFIG_ON_CLOSE;
+       }
+
+       sc->sc_flags &= ~mflag;
+
+       FSS_UNLOCK(sc, s);
+
        return 0;
 }
 
@@ -254,8 +284,6 @@
        sc->sc_flags |= FSS_EXCL;
        FSS_UNLOCK(sc, s);
 
-       error = EINVAL;
-
        switch (cmd) {
        case FSSIOCSET:
                if ((flag & FWRITE) == 0)
@@ -298,6 +326,20 @@
                        break;
                }
                break;
+
+       case FSSIOFSET:
+               sc->sc_uflags = *(int *)data;
+               error = 0;
+               break;
+
+       case FSSIOFGET:
+               *(int *)data = sc->sc_uflags;
+               error = 0;
+               break;
+
+       default:
+               error = EINVAL;
+               break;
        }
 
        FSS_LOCK(sc, s);



Home | Main Index | Thread Index | Old Index