2005-11-03 Jeff Johnston <jjohnstn@redhat.com>

* libc/unix/getcwd.c: Don't use non-reentrant syscall names.
        * libc/unix/getlogin.c: Ditto.
        * libc/unix/getpass.c: Ditto.
        * libc/unix/getut.c: Ditto.
        * libc/unix/ttyname.c: Ditto.
This commit is contained in:
Jeff Johnston 2005-11-03 20:47:50 +00:00
parent d31a862312
commit 15eaca1c3f
6 changed files with 29 additions and 21 deletions

View File

@ -1,3 +1,11 @@
2005-11-03 Jeff Johnston <jjohnstn@redhat.com>
* libc/unix/getcwd.c: Don't use non-reentrant syscall names.
* libc/unix/getlogin.c: Ditto.
* libc/unix/getpass.c: Ditto.
* libc/unix/getut.c: Ditto.
* libc/unix/ttyname.c: Ditto.
2005-11-03 Shaun Jackman <sjackman@gmail.com>
* libc/include/sys/unistd.h (readlink, symlink): Provide these

View File

@ -124,7 +124,7 @@ getcwd (pt, size)
for (first = 1;; first = 0)
{
/* Stat the current level. */
if (_stat (up, &s))
if (stat (up, &s))
goto err;
/* Save current node values. */
@ -165,7 +165,7 @@ getcwd (pt, size)
*bup = '\0';
/* Open and stat parent directory. */
if (!(dir = _opendir (up)) || _fstat (__dirfd (dir), &s))
if (!(dir = opendir (up)) || fstat (__dirfd (dir), &s))
goto err;
/* Add trailing slash for next directory. */
@ -182,7 +182,7 @@ getcwd (pt, size)
{
for (;;)
{
if (!(dp = _readdir (dir)))
if (!(dp = readdir (dir)))
goto notfound;
if (dp->d_ino == ino)
break;
@ -191,7 +191,7 @@ getcwd (pt, size)
else
for (;;)
{
if (!(dp = _readdir (dir)))
if (!(dp = readdir (dir)))
goto notfound;
if (ISDOT (dp))
continue;
@ -238,7 +238,7 @@ getcwd (pt, size)
*--bpt = '/';
bpt -= strlen (dp->d_name);
bcopy (dp->d_name, bpt, strlen (dp->d_name));
(void) _closedir (dir);
(void) closedir (dir);
/* Truncate any file name. */
*bup = '\0';

View File

@ -19,24 +19,24 @@ getlogin ()
|| ((tty = ttyname (2)) == 0))
return 0;
if ((utmp_fd = _open (UTMP_FILE, O_RDONLY)) == -1)
if ((utmp_fd = open (UTMP_FILE, O_RDONLY)) == -1)
return 0;
if (!strncmp (tty, "/dev/", 5))
tty += 5;
while (_read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf))
while (read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf))
{
if (!strncmp (tty, utmp_buf.ut_line, sizeof (utmp_buf.ut_line))
&& utmp_buf.ut_type == USER_PROCESS)
{
_close (utmp_fd);
close (utmp_fd);
memset (buf, 0, sizeof (buf));
strncpy (buf, utmp_buf.ut_user, sizeof (utmp_buf.ut_user));
return buf;
}
}
_close (utmp_fd);
close (utmp_fd);
return 0;
}

View File

@ -90,7 +90,7 @@ getpass (prompt)
if (p < buf + _PASSWORD_LEN)
*p++ = ch;
*p = '\0';
(void) _write (fileno (outfp), "\n", 1);
(void) write (fileno (outfp), "\n", 1);
if (echo)
{
term.c_lflag |= ECHO;

View File

@ -16,15 +16,15 @@ setutent ()
{
if (utmp_fd == -2)
{
utmp_fd = _open (utmp_file, O_RDONLY);
utmp_fd = open (utmp_file, O_RDONLY);
}
_lseek (utmp_fd, 0, SEEK_SET);
lseek (utmp_fd, 0, SEEK_SET);
}
void
endutent ()
{
_close (utmp_fd);
close (utmp_fd);
utmp_fd = -2;
}
@ -39,7 +39,7 @@ getutent ()
{
if (utmp_fd == -2)
setutent ();
if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data))
if (read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data))
return 0;
return &utmp_data;
}
@ -47,7 +47,7 @@ getutent ()
struct utmp *
getutid (struct utmp *id)
{
while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
{
switch (id->ut_type)
{
@ -73,7 +73,7 @@ getutid (struct utmp *id)
struct utmp *
getutline (struct utmp *line)
{
while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
{
if ((utmp_data.ut_type == LOGIN_PROCESS ||
utmp_data.ut_type == USER_PROCESS) &&

View File

@ -62,13 +62,13 @@ ttyname (fd)
return NULL;
/* Must be a character device. */
if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
if (fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
return NULL;
if ((dp = _opendir (_PATH_DEV)) == NULL)
if ((dp = opendir (_PATH_DEV)) == NULL)
return NULL;
while ((dirp = _readdir (dp)) != NULL)
while ((dirp = readdir (dp)) != NULL)
{
if (dirp->d_ino != sb.st_ino)
continue;
@ -76,9 +76,9 @@ ttyname (fd)
if (stat (buf, &dsb) || sb.st_dev != dsb.st_dev ||
sb.st_ino != dsb.st_ino)
continue;
(void) _closedir (dp);
(void) closedir (dp);
return buf;
}
(void) _closedir (dp);
(void) closedir (dp);
return NULL;
}