From owner-svn-src-user@FreeBSD.ORG Fri Jan 8 07:29:52 2010 Return-Path: <owner-svn-src-user@FreeBSD.ORG> Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D27B1065692; Fri, 8 Jan 2010 07:29:52 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F15488FC0A; Fri, 8 Jan 2010 07:29:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o087TpXK003656; Fri, 8 Jan 2010 07:29:51 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o087TpnS003654; Fri, 8 Jan 2010 07:29:51 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201001080729.o087TpnS003654@svn.freebsd.org> From: Ed Schouten <ed@FreeBSD.org> Date: Fri, 8 Jan 2010 07:29:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201771 - user/ed/utmpx/lib/libc/gen X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" <svn-src-user.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>, <mailto:svn-src-user-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user> List-Post: <mailto:svn-src-user@freebsd.org> List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>, <mailto:svn-src-user-request@freebsd.org?subject=subscribe> X-List-Received-Date: Fri, 08 Jan 2010 07:29:52 -0000 Author: ed Date: Fri Jan 8 07:29:51 2010 New Revision: 201771 URL: http://svn.freebsd.org/changeset/base/201771 Log: Also add an upgrade path for lastlogin. Right now we only have one version of the file format, so there's nothing to do here, except truncating it. Future versions of the implementation should have some conversion routines. Modified: user/ed/utmpx/lib/libc/gen/pututxline.c Modified: user/ed/utmpx/lib/libc/gen/pututxline.c ============================================================================== --- user/ed/utmpx/lib/libc/gen/pututxline.c Fri Jan 8 05:53:11 2010 (r201770) +++ user/ed/utmpx/lib/libc/gen/pututxline.c Fri Jan 8 07:29:51 2010 (r201771) @@ -181,6 +181,26 @@ done: } static void +utx_lastlogin_upgrade(void) +{ + int fd; + struct stat sb; + + fd = _open(_PATH_UTX_LASTLOGIN, O_RDWR, 0644); + if (fd < 0) + return; + + /* + * Truncate broken lastlogin files. In the future we should + * check for older versions of the file format here and try to + * upgrade it. + */ + if (_fstat(fd, &sb) != -1 && sb.st_size % sizeof(struct futx) != 0) + ftruncate(fd, 0); + _close(fd); +} + +static void utx_log_add(const struct futx *fu) { struct { @@ -219,6 +239,7 @@ pututxline(const struct utmpx *utmpx) case BOOT_TIME: case SHUTDOWN_TIME: utx_active_purge(); + utx_lastlogin_upgrade(); break; case OLD_TIME: case NEW_TIME: