aboutsummaryrefslogtreecommitdiff
path: root/login/getutid_r.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-07-18 08:43:26 +0000
committerRoland McGrath <roland@gnu.org>1996-07-18 08:43:26 +0000
commit49b986270035c7f86c3dc85383fd1da2e413fef9 (patch)
tree5b1236203c804457e180793a67e3e0e4b489a3d8 /login/getutid_r.c
parentd7bca0d30b5d3c8ae8421a1994ba24b1b56370d7 (diff)
downloadglibc-49b986270035c7f86c3dc85383fd1da2e413fef9.zip
glibc-49b986270035c7f86c3dc85383fd1da2e413fef9.tar.gz
glibc-49b986270035c7f86c3dc85383fd1da2e413fef9.tar.bz2
Thu Jul 18 04:33:21 1996 Roland McGrath <roland@baalperazim.frob.com>cvs/libc-960718
* sysdeps/mach/hurd/errnos.awk: Move EWOULDBLOCK check before errno==0 check. mib's clueless hacking broke it. Thu Jul 18 04:27:21 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * Makerules ($(libdir)/libc.so): Add missing / after $(cryptobjdir). Wed Jul 17 10:54:20 1996 David Mosberger-Tang <davidm@azstarnet.com> * sysdeps/unix/sysv/linux/alpha/start.S: Move to ... * sysdeps/alpha/elf/start.S: here. * misc/sys/ustat.h: New file. * misc/ustat.h: Ditto. * sysdeps/generic/ustatbits.h: Ditto. * libc-orig/sysdeps/stub/ustat.c: Ditto. * sysdeps/unix/sysv/linux/ustatbits.h: Ditto. * misc/Makefile (headers): Mention ustat.h, sys/ustat.h, and ustatbits.h. (routines): Mention ustat. * sysdeps/unix/sysv/linux/syscalls.list: Mention klogctl in alphabetically correct place. Mention ustat. * sysdeps/unix/alpha/sysdep.S: Make errno a bss symbol, not a common symbol (makes errno accessible from gdb). * login/pututline_r.c (pututline_r): Test ut_id in repositioning test, not ut_type. * login/logwtmp.c (logwtmp): Reimplemented. Must ensure that a record always gets appended at end of file (wtmp is a log file, after all). Set ut_type to DEAD_PROCESS if name is empty. * login/getutid_r.c (getutid_r): Handle search for UT_TYPE in separate loop from search for UT_ID. Fix code so it is in sync with Unix man page. * login/getutline_r.c (getutline_r): Stop searching only if ut_line matches and type is either USER_PROCESS or LOGIN_PROCESS. Tue Jul 16 15:06:18 1996 David Mosberger-Tang <davidm@azstarnet.com> * sysdeps/unix/sysv/linux/netinet/in.h: Base on <linux/in.h> to avoid duplicate declarations. Sun Jul 14 19:08:55 1996 David Mosberger-Tang <davidm@azstarnet.com> * manual/maint.texi (Supported Configurations): Add alpha-gnu-linux and alpha-gnu-linuxecoff targets. Fri Jul 12 16:58:44 1996 David Mosberger-Tang <davidm@azstarnet.com> * sysdeps/unix/sysv/linux/netinet/in.h: Declare bindresvport(). Sat Jun 22 23:30:07 1996 David Mosberger-Tang <davidm@azstarnet.com> * resolv/res_send.c (res_send): Declare FROMLEN as size_t instead of int. * resolv/res_comp.c (res_hnok): Use empty statement in place of NULL (which generates a "useless expression" warning in gcc).
Diffstat (limited to 'login/getutid_r.c')
-rw-r--r--login/getutid_r.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/login/getutid_r.c b/login/getutid_r.c
index 02013c2..347bbf3 100644
--- a/login/getutid_r.c
+++ b/login/getutid_r.c
@@ -53,32 +53,55 @@ getutid_r (const struct utmp *id, struct utmp **utmp,
if (lseek (utmp_data->ut_fd, utmp_data->loc_utmp, SEEK_SET) == -1)
return -1;
- while (1)
+ if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME
+ || id->ut_type == OLD_TIME || id->ut_type == NEW_TIME)
{
- /* Read the next entry. */
- if (read (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
- != sizeof (struct utmp))
+ /* Search for next entry with type RUN_LVL, BOOT_TIME,
+ OLD_TIME, or NEW_TIME. */
+
+ while (1)
{
- errno = ESRCH;
- return -1;
+ /* Read the next entry. */
+ if (read (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
+ != sizeof (struct utmp))
+ {
+ errno = ESRCH;
+ return -1;
+ }
+
+ /* Update position pointer. */
+ utmp_data->loc_utmp += sizeof (struct utmp);
+
+ if (id->ut_type == utmp_data->ubuf.ut_type)
+ break;
}
+ }
+ else
+ {
+ /* Search for the next entry with the specified ID and with type
+ INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS. */
- /* Update position pointer. */
- utmp_data->loc_utmp += sizeof (struct utmp);
-
- if ((id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME
- || id->ut_type == OLD_TIME || id->ut_type == NEW_TIME)
- && id->ut_type != utmp_data->ubuf.ut_type)
- /* Stop at the next entry with type RUN_LVL, BOOT_TIME,
- OLD_TIME, or NEW_TIME. */
- break;
-
- if ((id->ut_type == INIT_PROCESS || id->ut_type == LOGIN_PROCESS
- || id->ut_type == USER_PROCESS || id->ut_type == DEAD_PROCESS)
- && strncmp (id->ut_id, utmp_data->ubuf.ut_id, sizeof id->ut_id) == 0)
- /* Stop at the next entry with the specified ID and with type
- INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS. */
- break;
+ while (1)
+ {
+ /* Read the next entry. */
+ if (read (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
+ != sizeof (struct utmp))
+ {
+ errno = ESRCH;
+ return -1;
+ }
+
+ /* Update position pointer. */
+ utmp_data->loc_utmp += sizeof (struct utmp);
+
+ if (( utmp_data->ubuf.ut_type == INIT_PROCESS
+ || utmp_data->ubuf.ut_type == LOGIN_PROCESS
+ || utmp_data->ubuf.ut_type == USER_PROCESS
+ || utmp_data->ubuf.ut_type == DEAD_PROCESS)
+ && (strncmp (utmp_data->ubuf.ut_id, id->ut_id, sizeof id->ut_id)
+ == 0))
+ break;
+ }
}
*utmp = &utmp_data->ubuf;