svn commit: r201621 - user/ed/utmpx/lib/libc/gen
Ed Schouten
ed at FreeBSD.org
Tue Jan 5 23:01:46 UTC 2010
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
More information about the svn-src-user
mailing list