Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Thu Jul 18 04:33:21 1996 Roland McGrath <roland@baalperazim.frob.com>
	* 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).
  • Loading branch information
Roland McGrath committed Jul 18, 1996
1 parent d7bca0d commit 49b9862
Show file tree
Hide file tree
Showing 19 changed files with 275 additions and 175 deletions.
66 changes: 66 additions & 0 deletions ChangeLog
@@ -1,3 +1,69 @@
Thu Jul 18 04:33:21 1996 Roland McGrath <roland@baalperazim.frob.com>

* 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).

Wed Jul 17 23:56:35 1996 Roland McGrath <roland@baalperazim.frob.com>

* sysdeps/mach/hurd/Makefile ($(common-objpfx)errnos.d): Replace ../
Expand Down
2 changes: 1 addition & 1 deletion Makerules
Expand Up @@ -588,7 +588,7 @@ cryptobjdir := $(firstword $(objdir) $(patsubst ../$(subdir),.,$(..)crypt))
$(libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \
$(elfobjdir)/$(rtld-installed-name) \
$(common-objpfx)libc.a \
$(cryptobjdir)libcrypt.so$(libcrypt.so-version)
$(cryptobjdir)/libcrypt.so$(libcrypt.so-version)
(echo '/* Use the shared library, but some functions are only in';\
echo ' the static library, so try that secondarily.'; \
echo ' The dynamic linker defines some functions used by $(<F),';\
Expand Down
67 changes: 45 additions & 22 deletions login/getutid_r.c
Expand Up @@ -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;
Expand Down
22 changes: 8 additions & 14 deletions login/getutline_r.c
Expand Up @@ -55,22 +55,16 @@ getutline_r (const struct utmp *line, struct utmp **utmp,
/* Update position pointer. */
utmp_data->loc_utmp += sizeof (struct utmp);

if (
#if _HAVE_UT_TYPE - 0
if (utmp_data->ubuf.ut_type == USER_PROCESS
&& strncmp (line->ut_line, utmp_data->ubuf.ut_line,
sizeof line->ut_line) == 0)
/* Stop if we found an user entry. */
break;

if (utmp_data->ubuf.ut_type == LOGIN_PROCESS)
/* Stop if we found a login entry. */
break;
#else /* !_HAVE_UT_TYPE */
if (strncmp (line->ut_line, utmp_data->ubuf.ut_line,
sizeof line->ut_line) == 0)
/* Stop if the line match. */
break;
(utmp_data->ubuf.ut_type == USER_PROCESS
|| utmp_data->ubuf.ut_type == LOGIN_PROCESS)
&&
#endif
! strncmp (line->ut_line, utmp_data->ubuf.ut_line,
sizeof line->ut_line))
/* Stop if we found a user or login entry. */
break;
}

*utmp = &utmp_data->ubuf;
Expand Down
62 changes: 41 additions & 21 deletions login/logwtmp.c
Expand Up @@ -17,33 +17,31 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */

#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <utmp.h>

#include <sys/file.h>
#include <sys/stat.h>

void
logwtmp (const char *line, const char *name, const char *host)
{
struct utmp_data data;
struct utmp ut;
struct stat st;
size_t written;
int fd;

/* Tell that we want to use the UTMP file. */
if (utmpname (_PATH_WTMP) == 0)
return;

/* Open UTMP file. */
setutent_r (&data);

/* Position at end of file. */
data.loc_utmp = lseek (data.ut_fd, 0, SEEK_END);
if (data.loc_utmp == -1)
return;
/* Open WTMP file. */
fd = __open (_PATH_WTMP, O_WRONLY | O_APPEND);
if (fd < 0)
return;

/* Set information in new entry. */
bzero (&ut, sizeof (ut));
memset (&ut, 0, sizeof (ut));
ut.ut_pid = getpid ();
#if _HAVE_UT_TYPE - 0
ut.ut_type = USER_PROCESS;
ut.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS;
#endif
strncpy (ut.ut_line, line, sizeof ut.ut_line);
strncpy (ut.ut_name, name, sizeof ut.ut_name);
Expand All @@ -52,14 +50,36 @@ logwtmp (const char *line, const char *name, const char *host)
#endif

#if _HAVE_UT_TV - 0
gettimeofday (&ut.ut_tv, NULL);
__gettimeofday (&ut.ut_tv, NULL);
#else
time (&ut.ut_time);
__time (&ut.ut_time);
#endif

/* Write the entry. */
pututline_r (&ut, &data);
/* Try to lock the file. */
if (__flock (fd, LOCK_EX | LOCK_NB) < 0 && errno != ENOSYS)
{
/* Oh, oh. The file is already locked. Wait a bit and try again. */
sleep (1);

/* This time we ignore the error. */
__flock (fd, LOCK_EX | LOCK_NB);
}

/* Remeber original size of log file: */
if (__fstat (fd, &st) < 0)
goto done;

/* Write the entry. If we can't write all the bytes, reset the file
size back to the original size. That way, no partial entries
will remain. */
written = __write (fd, &ut, sizeof (ut));
if (written > 0 && written != sizeof (ut))
ftruncate (fd, st.st_size);

done:
/* And unlock the file. */
__flock (fd, LOCK_UN);

/* Close UTMP file. */
endutent_r (&data);
/* Close WTMP file. */
__close (fd);
}
17 changes: 10 additions & 7 deletions login/pututline_r.c
Expand Up @@ -58,12 +58,15 @@ pututline_r (const struct utmp *id, struct utmp_data *utmp_data)
return -1;
}

#if _HAVE_UT_TYPE - 0
/* Seek position to write. */
if (utmp_data->loc_utmp >= sizeof (struct utmp)
&& utmp_data->ubuf.ut_type != id->ut_type)
#if _HAVE_UT_ID - 0
/* Check whether we need to reposition. Repositioning is necessary
either if the data in UTMP_DATA is not valid or if the ids don't
match: */
if (utmp_data->loc_utmp < (off_t) sizeof (struct utmp)
|| strncmp(utmp_data->ubuf.ut_id, id->ut_id, sizeof (id->ut_id)) != 0)
{
/* We must not overwrite the data in UTMP_DATA. */
/* We must not overwrite the data in UTMP_DATA since ID may be
aliasing it. */
struct utmp_data *data_tmp = alloca (sizeof (*data_tmp));
struct utmp *dummy;

Expand All @@ -77,7 +80,7 @@ pututline_r (const struct utmp *id, struct utmp_data *utmp_data)
pointer now is at the end of the file. */
return -1;

/* Set position pointer to position after adding of the record. */
/* Set position pointer to position behind the record. */
utmp_data->loc_utmp += sizeof (struct utmp);
}
}
Expand All @@ -98,7 +101,7 @@ pututline_r (const struct utmp *id, struct utmp_data *utmp_data)

if (result >= 0)
/* Position file correctly. */
if (utmp_data->loc_utmp < sizeof (struct utmp))
if (utmp_data->loc_utmp < (off_t) sizeof (struct utmp))
/* Not located at any valid entry. Add at the end. */
{
result = lseek (utmp_data->ut_fd, 0L, SEEK_END);
Expand Down
2 changes: 2 additions & 0 deletions manual/maint.texi
Expand Up @@ -223,6 +223,8 @@ following patterns:

@smallexample
alpha-dec-osf1
alpha-gnu-linux
alpha-gnu-linuxecoff
i@var{x}86-@var{anything}-bsd4.3
i@var{x}86-@var{anything}-gnu
i@var{x}86-@var{anything}-isc2.2
Expand Down
35 changes: 35 additions & 0 deletions misc/sys/ustat.h
@@ -0,0 +1,35 @@
/* Header describing obsolete `ustat' interface.
Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */

/* This interface is obsolete. Use <sys/statfs.h> instead. */

#ifndef _SYS_USTAT_H
#define _SYS_USTAT_H 1

#include <sys/types.h>
#include <ustatbits.h>

__BEGIN_DECLS

extern int __ustat __P ((dev_t, struct ustat *));
extern int ustat __P ((dev_t, struct ustat *));

__END_DECLS

#endif /* _SYS_USTAT_H */
1 change: 1 addition & 0 deletions misc/ustat.h
@@ -0,0 +1 @@
#include <sys/ustat.h>
2 changes: 1 addition & 1 deletion resolv/res_comp.c
Expand Up @@ -397,7 +397,7 @@ res_hnok(dn)
int nch = *dn++;

if (periodchar(ch)) {
NULL;
/* NULL */;
} else if (periodchar(pch)) {
if (!borderchar(ch))
return (0);
Expand Down
2 changes: 1 addition & 1 deletion resolv/res_send.c
Expand Up @@ -499,7 +499,7 @@ res_send(buf, buflen, ans, anssiz)
struct timeval timeout;
fd_set dsmask;
struct sockaddr_in from;
int fromlen;
size_t fromlen;

if ((s < 0) || vc) {
if (vc)
Expand Down
@@ -1,5 +1,6 @@
/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@tamu.edu>
/* Startup code for Alpha/ELF.
Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@tamu.edu>
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
Expand Down

0 comments on commit 49b9862

Please sign in to comment.