summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-11-17 18:09:18 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-11-17 18:09:18 +0000
commit9c0e10a770f855888c3ceea3772815c5883c36bd (patch)
tree2b1ec53ac51fd995d14d9483aa5d304014f8fc06
parent7966ad142b7387b44eb0f860f8444c98e8ff8f73 (diff)
kleink: When fstat(2)ing a file descriptor of a local communications domain
socket, fill the socket's creation time into the stat structure's st_[acm]time fields: POSIX requires this behavior for pipe(2). N.B.: updating the st_[am]time fields when reading/writing the pipe is neither required nor implemented, though.
-rw-r--r--sys/kern/uipc_usrreq.c8
-rw-r--r--sys/sys/unpcb.h3
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 0eb02ec99d5..bb6bfbd7098 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.7 1997/11/06 05:58:25 csapuntz Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.8 1997/11/17 18:09:15 deraadt Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -259,6 +259,9 @@ uipc_usrreq(so, req, m, nam, control)
((struct stat *) m)->st_dev = NODEV;
if (unp->unp_ino == 0)
unp->unp_ino = unp_ino++;
+ ((struct stat *) m)->st_atimespec =
+ ((struct stat *) m)->st_mtimespec =
+ ((struct stat *) m)->st_ctimespec = unp->unp_ctime;
((struct stat *) m)->st_ino = unp->unp_ino;
return (0);
@@ -322,6 +325,7 @@ unp_attach(so)
struct socket *so;
{
register struct unpcb *unp;
+ struct timeval tv;
int error;
if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
@@ -347,6 +351,8 @@ unp_attach(so)
bzero((caddr_t)unp, sizeof(*unp));
unp->unp_socket = so;
so->so_pcb = unp;
+ microtime(&tv);
+ TIMEVAL_TO_TIMESPEC(&tv, &unp->unp_ctime);
return (0);
}
diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h
index 17606345cd0..ce69eadae55 100644
--- a/sys/sys/unpcb.h
+++ b/sys/sys/unpcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: unpcb.h,v 1.2 1996/03/03 12:12:41 niklas Exp $ */
+/* $OpenBSD: unpcb.h,v 1.3 1997/11/17 18:09:17 deraadt Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
@@ -71,6 +71,7 @@ struct unpcb {
struct mbuf *unp_addr; /* bound address of socket */
int unp_cc; /* copy of rcv.sb_cc */
int unp_mbcnt; /* copy of rcv.sb_mbcnt */
+ struct timeval unp_ctime; /* holds creation time */
};
#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))