From owner-svn-src-all@freebsd.org Sun Apr 3 20:29:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62292B000FE; Sun, 3 Apr 2016 20:29:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E91B16D1; Sun, 3 Apr 2016 20:29:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u33KTLcv062592; Sun, 3 Apr 2016 20:29:21 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u33KTL8M062590; Sun, 3 Apr 2016 20:29:21 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201604032029.u33KTL8M062590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sun, 3 Apr 2016 20:29:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297529 - head/sbin/devd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Apr 2016 20:29:22 -0000 Author: imp Date: Sun Apr 3 20:29:21 2016 New Revision: 297529 URL: https://svnweb.freebsd.org/changeset/base/297529 Log: Add a timestamp variable to the environment. This is when the event was read from the kernel by devd. Modified: head/sbin/devd/devd.cc head/sbin/devd/devd.conf.5 Modified: head/sbin/devd/devd.cc ============================================================================== --- head/sbin/devd/devd.cc Sun Apr 3 20:29:14 2016 (r297528) +++ head/sbin/devd/devd.cc Sun Apr 3 20:29:21 2016 (r297529) @@ -788,6 +788,8 @@ process_event(char *buffer) { char type; char *sp; + struct timeval tv; + char *timestr; sp = buffer + 1; devdlog(LOG_INFO, "Processing event '%s'\n", buffer); @@ -797,7 +799,15 @@ process_event(char *buffer) cfg.set_variable("*", buffer - 1); // $_ is the entire line without the initial character cfg.set_variable("_", buffer); - // No match doesn't have a device, and the format is a little + + // Save the time this happened (as approximated by when we got + // around to processing it). + gettimeofday(&tv, NULL); + asprintf(×tr, "%jd.%06ld", (uintmax_t)tv.tv_sec, tv.tv_usec); + cfg.set_variable("timestamp", timestr); + free(timestr); + + // Match doesn't have a device, and the format is a little // different, so handle it separately. switch (type) { case notify: Modified: head/sbin/devd/devd.conf.5 ============================================================================== --- head/sbin/devd/devd.conf.5 Sun Apr 3 20:29:14 2016 (r297528) +++ head/sbin/devd/devd.conf.5 Sun Apr 3 20:29:21 2016 (r297529) @@ -245,6 +245,8 @@ Variables for other classes of events ar The entire message from the current event .It Li _ The entire message from the current event, after the initial type character +.It Li timestamp +The time this event was processed, in seconds since 1970 dot fraction .It Li bus Device name of parent bus. .It Li cdev