-static __inline__ void
-dn_times(devnode_t * dnp, struct timeval t1, struct timeval t2)
-{
- if (dnp->dn_flags & (DN_ACCESS | DN_CHANGE | DN_UPDATE)) {
- if (dnp->dn_flags & DN_ACCESS) {
- dnp->dn_atime.tv_sec = t1.tv_sec;
- dnp->dn_atime.tv_nsec = t1.tv_usec * 1000;
- }
- if (dnp->dn_flags & DN_UPDATE) {
- dnp->dn_mtime.tv_sec = t2.tv_sec;
- dnp->dn_mtime.tv_nsec = t2.tv_usec * 1000;
- }
- if (dnp->dn_flags & DN_CHANGE) {
- dnp->dn_ctime.tv_sec = time.tv_sec;
- dnp->dn_ctime.tv_nsec = time.tv_usec * 1000;
- }
- dnp->dn_flags &= ~(DN_ACCESS | DN_CHANGE | DN_UPDATE);
- }
- return;
-}
+/*
+ * Access, change, and modify times are protected by a separate lock,
+ * which allows tty times to be updated (no more than once per second)
+ * in the I/O path without too much fear of contention.
+ *
+ * For getattr, update times to current time if the last update was recent;
+ * preserve legacy behavior that frequent stats can yield sub-second resolutions.
+ * If the last time is old, however, we know that the event that triggered
+ * the need for an update was no more than 1s after the last update. In that case,
+ * use (last update + 1s) as the time, avoiding the illusion that last update happened
+ * much later than it really did.
+ */
+#define DEVFS_LAZY_UPDATE_SECONDS 1
+
+#define DEVFS_UPDATE_CHANGE 0x1
+#define DEVFS_UPDATE_MOD 0x2
+#define DEVFS_UPDATE_ACCESS 0x4