Module Name: src
Committed By: christos
Date: Sat Apr 11 15:47:34 UTC 2009
Modified Files:
src/sys/dev/dmover: dmover_io.c
src/sys/dev/putter: putter.c
src/sys/kern: kern_drvctl.c sys_mqueue.c
src/sys/net: bpf.c bpfdesc.h if_tap.c
src/sys/opencrypto: cryptodev.c
src/sys/sys: mqueue.h
Log Message:
Fix PR/37878 and PR/37550: Provide stat(2) for all devices and don't use
fbadop_stat.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/dmover/dmover_io.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/putter/putter.c
cvs rdiff -u -r1.24 -r1.25 src/sys/kern/kern_drvctl.c
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/sys_mqueue.c
cvs rdiff -u -r1.144 -r1.145 src/sys/net/bpf.c
cvs rdiff -u -r1.29 -r1.30 src/sys/net/bpfdesc.h
cvs rdiff -u -r1.55 -r1.56 src/sys/net/if_tap.c
cvs rdiff -u -r1.47 -r1.48 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.6 -r1.7 src/sys/sys/mqueue.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/dmover/dmover_io.c
diff -u src/sys/dev/dmover/dmover_io.c:1.32 src/sys/dev/dmover/dmover_io.c:1.33
--- src/sys/dev/dmover/dmover_io.c:1.32 Sat Apr 4 06:12:51 2009
+++ src/sys/dev/dmover/dmover_io.c Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: dmover_io.c,v 1.32 2009/04/04 10:12:51 ad Exp $ */
+/* $NetBSD: dmover_io.c,v 1.33 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.32 2009/04/04 10:12:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.33 2009/04/11 15:47:33 christos Exp $");
#include <sys/param.h>
#include <sys/queue.h>
@@ -100,6 +100,9 @@
volatile int ds_flags;
u_int ds_nreqs;
struct simplelock ds_slock;
+ struct timespec ds_atime;
+ struct timespec ds_mtime;
+ struct timespec ds_btime;
};
static ONCE_DECL(dmio_cleaner_control);
@@ -358,6 +361,7 @@
if (ds->ds_session == NULL)
return (ENXIO);
+ getnanotime(&ds->ds_atime);
s = splsoftclock();
simple_lock(&ds->ds_slock);
@@ -487,6 +491,7 @@
if (ds->ds_session == NULL)
return (ENXIO);
+ getnanotime(&ds->ds_mtime);
s = splsoftclock();
simple_lock(&ds->ds_slock);
@@ -569,6 +574,21 @@
return (error);
}
+static int
+dmio_stat(struct file *fp, struct stat *st)
+{
+ struct dmio_state *ds = fp->f_data;
+
+ (void)memset(st, 0, sizeof(st));
+ KERNEL_LOCK(1, NULL);
+ st->st_dev = makedev(cdevsw_lookup_major(&dmoverio_cdevsw), 0);
+ st->st_atime = ds->ds_atime;
+ st->st_mtime = ds->ds_mtime;
+ st->st_ctime = st->st_birthtime = ds->ds_btime;
+ KERNEL_UNLOCK(NULL);
+ return 0;
+}
+
/*
* dmio_ioctl:
*
@@ -734,7 +754,7 @@
.fo_ioctl = dmio_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = dmio_poll,
- .fo_stat = fbadop_stat,
+ .fo_stat = dmio_stat,
.fo_close = dmio_close,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
@@ -759,6 +779,8 @@
s = splsoftclock();
ds = pool_get(&dmio_state_pool, PR_WAITOK);
splx(s);
+ getnanotime(&ds->ds_btime);
+ ds->ds_atime = ds->ds_mtime = ds->ds_btime;
memset(ds, 0, sizeof(*ds));
simple_lock_init(&ds->ds_slock);
Index: src/sys/dev/putter/putter.c
diff -u src/sys/dev/putter/putter.c:1.21 src/sys/dev/putter/putter.c:1.22
--- src/sys/dev/putter/putter.c:1.21 Sat Apr 4 06:12:51 2009
+++ src/sys/dev/putter/putter.c Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: putter.c,v 1.21 2009/04/04 10:12:51 ad Exp $ */
+/* $NetBSD: putter.c,v 1.22 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.21 2009/04/04 10:12:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.22 2009/04/11 15:47:33 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -44,12 +44,29 @@
#include <sys/filedesc.h>
#include <sys/kmem.h>
#include <sys/poll.h>
+#include <sys/stat.h>
#include <sys/socketvar.h>
#include <sys/module.h>
#include <dev/putter/putter_sys.h>
/*
+ * Device routines. These are for when /dev/puffs is initially
+ * opened before it has been cloned.
+ */
+
+dev_type_open(puttercdopen);
+dev_type_close(puttercdclose);
+dev_type_ioctl(puttercdioctl);
+
+/* dev */
+const struct cdevsw putter_cdevsw = {
+ puttercdopen, puttercdclose, noread, nowrite,
+ noioctl, nostop, notty, nopoll,
+ nommap, nokqfilter, D_OTHER
+};
+
+/*
* Configuration data.
*
* This is static-size for now. Will be redone for devfs.
@@ -111,6 +128,9 @@
uint8_t *pi_curput;
size_t pi_curres;
void *pi_curopaq;
+ struct timespec pi_atime;
+ struct timespec pi_mtime;
+ struct timespec pi_btime;
TAILQ_ENTRY(putter_instance) pi_entries;
};
@@ -171,6 +191,7 @@
kauth_cred_t, int);
static int putter_fop_ioctl(file_t*, u_long, void *);
static int putter_fop_poll(file_t *, int);
+static int putter_fop_stat(file_t *, struct stat *);
static int putter_fop_close(file_t *);
static int putter_fop_kqfilter(file_t *, struct knote *);
@@ -181,7 +202,7 @@
.fo_ioctl = putter_fop_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = putter_fop_poll,
- .fo_stat = fbadop_stat,
+ .fo_stat = putter_fop_stat,
.fo_close = putter_fop_close,
.fo_kqfilter = putter_fop_kqfilter,
.fo_drain = fnullop_drain,
@@ -195,6 +216,7 @@
size_t origres, moved;
int error;
+ getnanotime(&pi->pi_atime);
KERNEL_LOCK(1, NULL);
if (pi->pi_private == PUTTER_EMBRYO || pi->pi_private == PUTTER_DEAD) {
@@ -243,6 +265,7 @@
size_t frsize;
int error;
+ getnanotime(&pi->pi_mtime);
KERNEL_LOCK(1, NULL);
DPRINTF(("putter_fop_write (%p): writing response, resid %zu\n",
@@ -383,6 +406,21 @@
}
static int
+putter_fop_stat(file_t *fp, struct stat *st)
+{
+ struct putter_instance *pi = fp->f_data;
+
+ (void)memset(st, 0, sizeof(*st));
+ KERNEL_LOCK(1, NULL);
+ st->st_dev = makedev(cdevsw_lookup_major(&putter_cdevsw), pi->pi_idx);
+ st->st_atimespec = pi->pi_atime;
+ st->st_mtimespec = pi->pi_mtime;
+ st->st_ctimespec = st->st_birthtimespec = pi->pi_btime;
+ KERNEL_UNLOCK_ONE(NULL);
+ return 0;
+}
+
+static int
putter_fop_ioctl(file_t *fp, u_long cmd, void *data)
{
@@ -467,21 +505,6 @@
return 0;
}
-/*
- * Device routines. These are for when /dev/puffs is initially
- * opened before it has been cloned.
- */
-
-dev_type_open(puttercdopen);
-dev_type_close(puttercdclose);
-dev_type_ioctl(puttercdioctl);
-
-/* dev */
-const struct cdevsw putter_cdevsw = {
- puttercdopen, puttercdclose, noread, nowrite,
- noioctl, nostop, notty, nopoll,
- nommap, nokqfilter, D_OTHER
-};
int
puttercdopen(dev_t dev, int flags, int fmt, struct lwp *l)
{
@@ -500,6 +523,8 @@
pi->pi_curput = NULL;
pi->pi_curres = 0;
pi->pi_curopaq = NULL;
+ getnanotime(&pi->pi_btime);
+ pi->pi_atime = pi->pi_mtime = pi->pi_btime;
selinit(&pi->pi_sel);
mutex_exit(&pi_mtx);
Index: src/sys/kern/kern_drvctl.c
diff -u src/sys/kern/kern_drvctl.c:1.24 src/sys/kern/kern_drvctl.c:1.25
--- src/sys/kern/kern_drvctl.c:1.24 Sat Apr 4 17:49:05 2009
+++ src/sys/kern/kern_drvctl.c Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_drvctl.c,v 1.24 2009/04/04 21:49:05 joerg Exp $ */
+/* $NetBSD: kern_drvctl.c,v 1.25 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 2004
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.24 2009/04/04 21:49:05 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.25 2009/04/11 15:47:33 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -44,6 +44,7 @@
#include <sys/poll.h>
#include <sys/drvctlio.h>
#include <sys/devmon.h>
+#include <sys/stat.h>
struct drvctl_event {
TAILQ_ENTRY(drvctl_event) dce_link;
@@ -75,6 +76,7 @@
kauth_cred_t, int);
static int drvctl_ioctl(struct file *, u_long, void *);
static int drvctl_poll(struct file *, int);
+static int drvctl_stat(struct file *, struct stat *);
static int drvctl_close(struct file *);
static const struct fileops drvctl_fileops = {
@@ -83,7 +85,7 @@
.fo_ioctl = drvctl_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = drvctl_poll,
- .fo_stat = fbadop_stat,
+ .fo_stat = drvctl_stat,
.fo_close = drvctl_close,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
@@ -370,6 +372,13 @@
}
static int
+drvctl_stat(struct file *fp, struct stat *st)
+{
+ (void)memset(st, 0, sizeof(*st));
+ return 0;
+}
+
+static int
drvctl_poll(struct file *fp, int events)
{
int revents = 0;
Index: src/sys/kern/sys_mqueue.c
diff -u src/sys/kern/sys_mqueue.c:1.14 src/sys/kern/sys_mqueue.c:1.15
--- src/sys/kern/sys_mqueue.c:1.14 Sat Apr 4 06:12:51 2009
+++ src/sys/kern/sys_mqueue.c Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_mqueue.c,v 1.14 2009/04/04 10:12:51 ad Exp $ */
+/* $NetBSD: sys_mqueue.c,v 1.15 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.14 2009/04/04 10:12:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.15 2009/04/11 15:47:33 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -84,6 +84,7 @@
LIST_HEAD_INITIALIZER(mqueue_head);
static int mq_poll_fop(file_t *, int);
+static int mq_stat_fop(file_t *, struct stat *);
static int mq_close_fop(file_t *);
#define FNOVAL -1
@@ -94,7 +95,7 @@
.fo_ioctl = fbadop_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = mq_poll_fop,
- .fo_stat = fbadop_stat,
+ .fo_stat = mq_stat_fop,
.fo_close = mq_close_fop,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
@@ -240,6 +241,23 @@
}
static int
+mq_stat_fop(file_t *fp, struct stat *st)
+{
+ struct mqueue *mq = fp->f_data;
+
+ (void)memset(st, 0, sizeof(*st));
+ KERNEL_LOCK(1, NULL);
+ st->st_mode = mq->mq_mode;
+ st->st_uid = mq->mq_euid;
+ st->st_gid = mq->mq_egid;
+ st->st_atimespec = mq->mq_atime;
+ st->st_mtimespec = mq->mq_mtime;
+ st->st_ctimespec = st->st_birthtimespec = mq->mq_btime;
+ KERNEL_UNLOCK_ONE(NULL);
+ return 0;
+}
+
+static int
mq_poll_fop(file_t *fp, int events)
{
struct mqueue *mq = fp->f_data;
@@ -444,6 +462,8 @@
mutex_enter(&mq->mq_mtx);
LIST_INSERT_HEAD(&mqueue_head, mq, mq_list);
mq_new = NULL;
+ getnanotime(&mq->mq_btime);
+ mq->mq_atime = mq->mq_mtime = mq->mq_btime;
}
/* Increase the counters, and make descriptor ready */
@@ -493,6 +513,7 @@
return error;
mq = fp->f_data;
+ getnanotime(&mq->mq_atime);
/* Check the message size limits */
if (msg_len < mq->mq_attrib.mq_msgsize) {
error = EMSGSIZE;
@@ -655,6 +676,8 @@
}
mq = fp->f_data;
+ getnanotime(&mq->mq_mtime);
+
/* Check the message size limit */
if (msg_len <= 0 || msg_len > mq->mq_attrib.mq_msgsize) {
error = EMSGSIZE;
Index: src/sys/net/bpf.c
diff -u src/sys/net/bpf.c:1.144 src/sys/net/bpf.c:1.145
--- src/sys/net/bpf.c:1.144 Sat Apr 4 06:12:51 2009
+++ src/sys/net/bpf.c Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf.c,v 1.144 2009/04/04 10:12:51 ad Exp $ */
+/* $NetBSD: bpf.c,v 1.145 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.144 2009/04/04 10:12:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.145 2009/04/11 15:47:33 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_bpf.h"
@@ -58,6 +58,7 @@
#include <sys/conf.h>
#include <sys/vnode.h>
#include <sys/queue.h>
+#include <sys/stat.h>
#include <sys/file.h>
#include <sys/filedesc.h>
@@ -151,6 +152,7 @@
int);
static int bpf_ioctl(struct file *, u_long, void *);
static int bpf_poll(struct file *, int);
+static int bpf_stat(struct file *, struct stat *);
static int bpf_close(struct file *);
static int bpf_kqfilter(struct file *, struct knote *);
static void bpf_softintr(void *);
@@ -161,7 +163,7 @@
.fo_ioctl = bpf_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = bpf_poll,
- .fo_stat = fbadop_stat,
+ .fo_stat = bpf_stat,
.fo_close = bpf_close,
.fo_kqfilter = bpf_kqfilter,
.fo_drain = fnullop_drain,
@@ -402,6 +404,8 @@
d->bd_bufsize = bpf_bufsize;
d->bd_seesent = 1;
d->bd_pid = l->l_proc->p_pid;
+ getnanotime(&d->bd_btime);
+ d->bd_atime = d->bd_mtime = d->bd_btime;
callout_init(&d->bd_callout, 0);
selinit(&d->bd_sel);
d->bd_sih = softint_establish(SOFTINT_CLOCK, bpf_softintr, d);
@@ -476,6 +480,7 @@
int error;
int s;
+ getnanotime(&d->bd_atime);
/*
* Restrict application to use a buffer the same size as
* the kernel buffers.
@@ -625,6 +630,7 @@
KERNEL_UNLOCK_ONE(NULL);
return (ENXIO);
}
+ getnanotime(&d->bd_mtime);
ifp = d->bd_bif->bif_ifp;
@@ -1120,6 +1126,21 @@
memcpy(ifr->ifr_name, ifp->if_xname, IFNAMSIZ);
}
+static int
+bpf_stat(struct file *fp, struct stat *st)
+{
+ struct bpf_d *d = fp->f_data;
+
+ (void)memset(st, 0, sizeof(*st));
+ KERNEL_LOCK(1, NULL);
+ st->st_dev = makedev(cdevsw_lookup_major(&bpf_cdevsw), d->bd_pid);
+ st->st_atimespec = d->bd_atime;
+ st->st_mtimespec = d->bd_mtime;
+ st->st_ctimespec = st->st_birthtimespec = d->bd_btime;
+ KERNEL_UNLOCK_ONE(NULL);
+ return 0;
+}
+
/*
* Support for poll() system call
*
Index: src/sys/net/bpfdesc.h
diff -u src/sys/net/bpfdesc.h:1.29 src/sys/net/bpfdesc.h:1.30
--- src/sys/net/bpfdesc.h:1.29 Sat Mar 14 10:46:10 2009
+++ src/sys/net/bpfdesc.h Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: bpfdesc.h,v 1.29 2009/03/14 14:46:10 dsl Exp $ */
+/* $NetBSD: bpfdesc.h,v 1.30 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@@ -93,6 +93,9 @@
pid_t bd_pid; /* corresponding PID */
LIST_ENTRY(bpf_d) bd_list; /* list of all BPF's */
void *bd_sih; /* soft interrupt handle */
+ struct timespec bd_atime; /* access time */
+ struct timespec bd_mtime; /* modification time */
+ struct timespec bd_btime; /* birth time */
};
Index: src/sys/net/if_tap.c
diff -u src/sys/net/if_tap.c:1.55 src/sys/net/if_tap.c:1.56
--- src/sys/net/if_tap.c:1.55 Sat Apr 4 06:12:51 2009
+++ src/sys/net/if_tap.c Sat Apr 11 11:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tap.c,v 1.55 2009/04/04 10:12:51 ad Exp $ */
+/* $NetBSD: if_tap.c,v 1.56 2009/04/11 15:47:33 christos Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.55 2009/04/04 10:12:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.56 2009/04/11 15:47:33 christos Exp $");
#if defined(_KERNEL_OPT)
#include "bpfilter.h"
@@ -61,6 +61,7 @@
#include <sys/mutex.h>
#include <sys/simplelock.h>
#include <sys/intr.h>
+#include <sys/stat.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -115,6 +116,9 @@
kmutex_t sc_rdlock;
struct simplelock sc_kqlock;
void *sc_sih;
+ struct timespec sc_atime;
+ struct timespec sc_mtime;
+ struct timespec sc_btime;
};
/* autoconf(9) glue */
@@ -135,6 +139,7 @@
static int tap_dev_write(int, struct uio *, int);
static int tap_dev_ioctl(int, u_long, void *, struct lwp *);
static int tap_dev_poll(int, int, struct lwp *);
+static int tap_dev_stat(int , struct stat *);
static int tap_dev_kqfilter(int, struct knote *);
/* Fileops access routines */
@@ -145,6 +150,7 @@
kauth_cred_t, int);
static int tap_fops_ioctl(file_t *, u_long, void *);
static int tap_fops_poll(file_t *, int);
+static int tap_fops_stat(file_t *, struct stat *);
static int tap_fops_kqfilter(file_t *, struct knote *);
static const struct fileops tap_fileops = {
@@ -153,7 +159,7 @@
.fo_ioctl = tap_fops_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = tap_fops_poll,
- .fo_stat = fbadop_stat,
+ .fo_stat = tap_fops_stat,
.fo_close = tap_fops_close,
.fo_kqfilter = tap_fops_kqfilter,
.fo_drain = fnullop_drain,
@@ -268,6 +274,8 @@
sc->sc_dev = self;
sc->sc_sih = softint_establish(SOFTINT_CLOCK, tap_softintr, sc);
+ getnanotime(&sc->sc_btime);
+ sc->sc_atime = sc->sc_mtime = sc->sc_btime;
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
@@ -891,6 +899,8 @@
if (sc == NULL)
return (ENXIO);
+ getnanotime(&sc->sc_atime);
+
ifp = &sc->sc_ec.ec_if;
if ((ifp->if_flags & IFF_UP) == 0)
return (EHOSTDOWN);
@@ -966,6 +976,33 @@
}
static int
+tap_fops_stat(file_t *fp, struct stat *st)
+{
+ int error;
+ KERNEL_LOCK(1, NULL);
+ error = tap_dev_stat((intptr_t)fp->f_data, st);
+ KERNEL_UNLOCK_ONE(NULL);
+ return error;
+}
+
+static int
+tap_dev_stat(int unit, struct stat *st)
+{
+ struct tap_softc *sc =
+ device_lookup_private(&tap_cd, unit);
+
+ if (sc == NULL)
+ return ENXIO;
+
+ (void)memset(st, 0, sizeof(*st));
+ st->st_dev = makedev(cdevsw_lookup_major(&tap_cdevsw), unit);
+ st->st_atimespec = sc->sc_atime;
+ st->st_mtimespec = sc->sc_mtime;
+ st->st_ctimespec = st->st_birthtimespec = sc->sc_btime;
+ return 0;
+}
+
+static int
tap_cdev_write(dev_t dev, struct uio *uio, int flags)
{
return tap_dev_write(minor(dev), uio, flags);
@@ -996,6 +1033,7 @@
if (sc == NULL)
return (ENXIO);
+ getnanotime(&sc->sc_mtime);
ifp = &sc->sc_ec.ec_if;
/* One write, one packet, that's the rule */
Index: src/sys/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.47 src/sys/opencrypto/cryptodev.c:1.48
--- src/sys/opencrypto/cryptodev.c:1.47 Sat Apr 4 06:12:52 2009
+++ src/sys/opencrypto/cryptodev.c Sat Apr 11 11:47:34 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: cryptodev.c,v 1.47 2009/04/04 10:12:52 ad Exp $ */
+/* $NetBSD: cryptodev.c,v 1.48 2009/04/11 15:47:34 christos Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.47 2009/04/04 10:12:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.48 2009/04/11 15:47:34 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -84,6 +84,7 @@
#include <sys/select.h>
#include <sys/poll.h>
#include <sys/atomic.h>
+#include <sys/stat.h>
#include "opt_ocf.h"
#include <opencrypto/cryptodev.h>
@@ -122,6 +123,9 @@
int sesn;
struct selinfo sinfo;
u_int32_t requestid;
+ struct timespec atime;
+ struct timespec mtime;
+ struct timespec btime;
};
/* For our fixed-size allocations */
@@ -142,6 +146,7 @@
static int cryptof_ioctl(struct file *, u_long, void *);
static int cryptof_close(struct file *);
static int cryptof_poll(struct file *, int);
+static int cryptof_stat(struct file *, struct stat *);
static const struct fileops cryptofops = {
.fo_read = cryptof_read,
@@ -149,7 +154,7 @@
.fo_ioctl = cryptof_ioctl,
.fo_fcntl = fnullop_fcntl,
.fo_poll = cryptof_poll,
- .fo_stat = fbadop_stat,
+ .fo_stat = cryptof_stat,
.fo_close = cryptof_close,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
@@ -228,6 +233,8 @@
struct fcrypt *criofcr;
int criofd;
+ getnanotime(&fcr->atime);
+
switch (cmd) {
case CRIOGET: /* XXX deprecated, remove after 5.0 */
if ((error = fd_allocfile(&criofp, &criofd)) != 0)
@@ -265,6 +272,7 @@
goto mbail;
}
+ fcr->mtime = fcr->atime;
error = cryptodev_msession(fcr, snop, sgop->count);
if (error) {
goto mbail;
@@ -276,6 +284,7 @@
kmem_free(snop, sgop->count * sizeof(struct session_n_op));
break;
case CIOCFSESSION:
+ fcr->mtime = fcr->atime;
mutex_spin_enter(&crypto_mtx);
ses = *(u_int32_t *)data;
cse = csefind(fcr, ses);
@@ -286,6 +295,7 @@
mutex_spin_exit(&crypto_mtx);
break;
case CIOCNFSESSION:
+ fcr->mtime = fcr->atime;
sfop = (struct crypt_sfop *)data;
sesid = kmem_alloc((sfop->count * sizeof(u_int32_t)),
KM_SLEEP);
@@ -297,6 +307,7 @@
kmem_free(sesid, (sfop->count * sizeof(u_int32_t)));
break;
case CIOCCRYPT:
+ fcr->mtime = fcr->atime;
mutex_spin_enter(&crypto_mtx);
cop = (struct crypt_op *)data;
cse = csefind(fcr, cop->ses);
@@ -309,6 +320,7 @@
DPRINTF(("cryptodev_op error = %d\n", error));
break;
case CIOCNCRYPTM:
+ fcr->mtime = fcr->atime;
mop = (struct crypt_mop *)data;
cnop = kmem_alloc((mop->count * sizeof(struct crypt_n_op)),
KM_SLEEP);
@@ -328,6 +340,7 @@
DPRINTF(("cryptodev_key error = %d\n", error));
break;
case CIOCNFKEYM:
+ fcr->mtime = fcr->atime;
mkop = (struct crypt_mkop *)data;
knop = kmem_alloc((mkop->count * sizeof(struct crypt_n_kop)),
KM_SLEEP);
@@ -345,6 +358,7 @@
error = crypto_getfeat((int *)data);
break;
case CIOCNCRYPTRETM:
+ fcr->mtime = fcr->atime;
crypt_ret = (struct cryptret *)data;
count = crypt_ret->count;
crypt_res = kmem_alloc((count * sizeof(struct crypt_result)),
@@ -1010,6 +1024,8 @@
return error;
fcr = pool_get(&fcrpl, PR_WAITOK);
+ getnanotime(&fcr->btime);
+ fcr->atime = fcr->mtime = fcr->btime;
mutex_spin_enter(&crypto_mtx);
TAILQ_INIT(&fcr->csessions);
TAILQ_INIT(&fcr->crp_ret_mq);
@@ -1939,6 +1955,21 @@
}
static int
+cryptof_stat(struct file *fp, struct stat *st)
+{
+ struct fcrypt *fcr = fp->f_data;
+
+ (void)memset(st, 0, sizeof(st));
+ KERNEL_LOCK(1, NULL);
+ st->st_dev = makedev(cdevsw_lookup_major(&crypto_cdevsw), fcr->sesn);
+ st->st_atimespec = fcr->atime;
+ st->st_mtimespec = fcr->mtime;
+ st->st_ctimespec = st->st_birthtimespec = fcr->btime;
+ KERNEL_UNLOCK_ONE(NULL);
+ return 0;
+}
+
+static int
cryptof_poll(struct file *fp, int events)
{
struct fcrypt *fcr = (struct fcrypt *)fp->f_data;
Index: src/sys/sys/mqueue.h
diff -u src/sys/sys/mqueue.h:1.6 src/sys/sys/mqueue.h:1.7
--- src/sys/sys/mqueue.h:1.6 Mon Jan 19 21:15:32 2009
+++ src/sys/sys/mqueue.h Sat Apr 11 11:47:34 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: mqueue.h,v 1.6 2009/01/20 02:15:32 rmind Exp $ */
+/* $NetBSD: mqueue.h,v 1.7 2009/04/11 15:47:34 christos Exp $ */
/*
* Copyright (c) 2007, Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -88,6 +88,9 @@
TAILQ_HEAD(, mq_msg) mq_head;
/* Entry of the global list */
LIST_ENTRY(mqueue) mq_list;
+ struct timespec mq_atime;
+ struct timespec mq_mtime;
+ struct timespec mq_btime;
};
/* Structure of the message */