Date: Tue, 5 Jan 2010 23:26:45 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r201624 - user/ed/utmpx/lib/libc/gen Message-ID: <201001052326.o05NQj7s045718@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Tue Jan 5 23:26:45 2010 New Revision: 201624 URL: http://svn.freebsd.org/changeset/base/201624 Log: Last commit for today. Don't forget the un-namespacing. Modified: user/ed/utmpx/lib/libc/gen/getutxent.c user/ed/utmpx/lib/libc/gen/pututxline.c Modified: user/ed/utmpx/lib/libc/gen/getutxent.c ============================================================================== --- user/ed/utmpx/lib/libc/gen/getutxent.c Tue Jan 5 23:09:34 2010 (r201623) +++ user/ed/utmpx/lib/libc/gen/getutxent.c Tue Jan 5 23:26:45 2010 (r201624) @@ -29,8 +29,10 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "namespace.h" #include <stdio.h> #include <utmpx.h> +#include "un-namespace.h" void endutxent(void) Modified: user/ed/utmpx/lib/libc/gen/pututxline.c ============================================================================== --- user/ed/utmpx/lib/libc/gen/pututxline.c Tue Jan 5 23:09:34 2010 (r201623) +++ user/ed/utmpx/lib/libc/gen/pututxline.c Tue Jan 5 23:26:45 2010 (r201624) @@ -29,11 +29,13 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "namespace.h" #include <fcntl.h> #include <string.h> #include <unistd.h> #include <utmpx.h> #include "utxdb.h" +#include "un-namespace.h" static int utx_to_futx(const struct utmpx *ut, struct futx *fu) @@ -91,14 +93,14 @@ utx_active_add(const struct futx *fu) * Register user login sessions. Overwrite entries of sessions * that have already been terminated. */ - fd = open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644); + fd = _open(_PATH_UTX_ACTIVE, O_CREAT|O_RDWR, 0644); if (fd < 0) return; if (lockf(fd, F_LOCK, 0) == -1) { - close(fd); + _close(fd); return; } - while (read(fd, &fe, sizeof fe) == sizeof fe) { + while (_read(fd, &fe, sizeof fe) == sizeof fe) { /* * XXX: This check is invalid. We should perform a * similar comparison as getutxid(). @@ -108,9 +110,9 @@ utx_active_add(const struct futx *fu) break; } } - write(fd, fu, sizeof *fu); + _write(fd, fu, sizeof *fu); lockf(fd, F_ULOCK, 0); - close(fd); + _close(fd); } static int @@ -131,22 +133,22 @@ utx_lastlogin_add(const struct futx *fu) * current user already has an entry. If not, append a new * entry. */ - fd = open(_PATH_UTX_LASTLOGIN, O_CREAT|O_RDWR, 0644); + fd = _open(_PATH_UTX_LASTLOGIN, O_CREAT|O_RDWR, 0644); if (fd < 0) return; if (lockf(fd, F_LOCK, 0) == -1) { - close(fd); + _close(fd); return; } - while (read(fd, &fe, sizeof fe) == sizeof fe) { + while (_read(fd, &fe, sizeof fe) == sizeof fe) { if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) == 0) { lseek(fd, -sizeof fe, SEEK_CUR); break; } } - write(fd, fu, sizeof *fu); + _write(fd, fu, sizeof *fu); lockf(fd, F_ULOCK, 0); - close(fd); + _close(fd); } static void @@ -169,11 +171,11 @@ utx_log_add(const struct futx *fu) r.len = htobe16(l); memcpy(&r.data, fu, l); - f = open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644); + f = _open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644); if (f < 0) return; - write(f, &r, sizeof r.len + l); - close(f); + _write(f, &r, sizeof r.len + l); + _close(f); } struct utmpx * @@ -189,12 +191,10 @@ pututxline(const struct utmpx *utmpx) case OLD_TIME: case NEW_TIME: case SHUTDOWN_TIME: - utx_log_add(&fu); break; case USER_PROCESS: utx_active_add(&fu); utx_lastlogin_add(&fu); - utx_log_add(&fu); break; #if 0 case INIT_PROCESS: @@ -203,8 +203,10 @@ pututxline(const struct utmpx *utmpx) case DEAD_PROCESS: if (utx_active_remove(&fu) != 0) return (NULL); - utx_log_add(&fu); + default: + return (NULL); } + utx_log_add(&fu); return (NULL); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001052326.o05NQj7s045718>