Date: Fri, 8 Jan 2010 07:29:51 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r201771 - user/ed/utmpx/lib/libc/gen Message-ID: <201001080729.o087TpnS003654@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001080729.o087TpnS003654>