Date: Tue, 5 Jan 2010 23:01:46 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r201621 - user/ed/utmpx/lib/libc/gen Message-ID: <201001052301.o05N1kIT039540@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Tue Jan 5 23:01:46 2010 New Revision: 201621 URL: http://svn.freebsd.org/changeset/base/201621 Log: Also implement utx_active_add() for now. This means we at least write to all three the database files, which means I can implement and test the reading functions. 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 Tue Jan 5 22:59:59 2010 (r201620) +++ user/ed/utmpx/lib/libc/gen/pututxline.c Tue Jan 5 23:01:46 2010 (r201621) @@ -84,6 +84,33 @@ utx_to_futx(const struct utmpx *ut, stru static void utx_active_add(const struct futx *fu) { + int fd; + struct futx fe; + + /* + * Register user login sessions. Overwrite entries of sessions + * that have already been terminated. + */ + fd = open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644); + if (fd < 0) + return; + if (lockf(fd, F_LOCK, 0) == -1) { + close(fd); + return; + } + while (read(fd, &fe, sizeof fe) == sizeof fe) { + /* + * XXX: This check is invalid. We should perform a + * similar comparison as getutxid(). + */ + if (fe.fu_type != USER_PROCESS) { + lseek(fd, -sizeof fe, SEEK_CUR); + break; + } + } + write(fd, fu, sizeof *fu); + lockf(fd, F_ULOCK, 0); + close(fd); } static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001052301.o05N1kIT039540>