mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
* sysdeps/unix/sysv/linux/kernel-features.h: Define
__ASSUME_PROC_SELF_FD_SYMLINK. * sysdeps/unix/sysv/linux/ttyname.c: Cleanups. Avoid compatibility code is possible. Move compatibility code in .text.compat section. * sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2006-04-19 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/kernel-features.h: Define
|
||||||
|
__ASSUME_PROC_SELF_FD_SYMLINK.
|
||||||
|
* sysdeps/unix/sysv/linux/ttyname.c: Cleanups. Avoid compatibility
|
||||||
|
code is possible. Move compatibility code in .text.compat section.
|
||||||
|
* sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
|
||||||
|
|
||||||
2006-04-18 Ulrich Drepper <drepper@redhat.com>
|
2006-04-18 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Rewrite to avoid loop
|
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Rewrite to avoid loop
|
||||||
|
@ -85,6 +85,12 @@
|
|||||||
# define __ASSUME_SENDFILE 1
|
# define __ASSUME_SENDFILE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Only very old kernels had no real symlinks for terminal descriptors
|
||||||
|
in /proc/self/fd. */
|
||||||
|
#if __LINUX_KERNEL_VERSION >= 131584
|
||||||
|
# define __ASSUME_PROC_SELF_FD_SYMLINK 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* On x86 another `getrlimit' syscall was added in 2.3.25. */
|
/* On x86 another `getrlimit' syscall was added in 2.3.25. */
|
||||||
#if __LINUX_KERNEL_VERSION >= 131865 && defined __i386__
|
#if __LINUX_KERNEL_VERSION >= 131865 && defined __i386__
|
||||||
# define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
|
# define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991,92,93,1996-2001,2002 Free Software Foundation, Inc.
|
/* Copyright (C) 1991,92,93,1996-2002,2006 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <stdio-common/_itoa.h>
|
#include <stdio-common/_itoa.h>
|
||||||
|
#include <kernel-features.h>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Is this used anywhere? It is not exported. */
|
/* Is this used anywhere? It is not exported. */
|
||||||
@ -41,7 +42,7 @@ static char *getttyname (const char *dev, dev_t mydev,
|
|||||||
libc_freeres_ptr (static char *getttyname_name);
|
libc_freeres_ptr (static char *getttyname_name);
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
internal_function
|
internal_function attribute_compat_text_section
|
||||||
getttyname (const char *dev, dev_t mydev, ino64_t myino, int save, int *dostat)
|
getttyname (const char *dev, dev_t mydev, ino64_t myino, int save, int *dostat)
|
||||||
{
|
{
|
||||||
static size_t namelen;
|
static size_t namelen;
|
||||||
@ -117,10 +118,12 @@ ttyname (int fd)
|
|||||||
int dostat = 0;
|
int dostat = 0;
|
||||||
char *name;
|
char *name;
|
||||||
int save = errno;
|
int save = errno;
|
||||||
int len;
|
|
||||||
|
|
||||||
if (!__isatty (fd))
|
if (__builtin_expect (!__isatty (fd), 0))
|
||||||
return NULL;
|
{
|
||||||
|
__set_errno (ENOTTY);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* We try using the /proc filesystem. */
|
/* We try using the /proc filesystem. */
|
||||||
*_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';
|
*_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';
|
||||||
@ -136,10 +139,19 @@ ttyname (int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len = __readlink (procname, ttyname_buf, buflen);
|
ssize_t len = __readlink (procname, ttyname_buf, buflen);
|
||||||
if (len != -1
|
if (__builtin_expect (len == -1 && errno == ENOENT, 0))
|
||||||
/* This is for Linux 2.0. */
|
{
|
||||||
&& ttyname_buf[0] != '[')
|
__set_errno (EBADF);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__builtin_expect (len != -1
|
||||||
|
#ifndef __ASSUME_PROC_SELF_FD_SYMLINK
|
||||||
|
/* This is for Linux 2.0. */
|
||||||
|
&& ttyname_buf[0] != '['
|
||||||
|
#endif
|
||||||
|
, 1))
|
||||||
{
|
{
|
||||||
if ((size_t) len >= buflen)
|
if ((size_t) len >= buflen)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991,92,93,1995-2001, 2003 Free Software Foundation, Inc.
|
/* Copyright (C) 1991,92,93,1995-2001,2003,2006 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -27,13 +27,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <stdio-common/_itoa.h>
|
#include <stdio-common/_itoa.h>
|
||||||
|
#include <kernel-features.h>
|
||||||
|
|
||||||
static int getttyname_r (char *buf, size_t buflen,
|
static int getttyname_r (char *buf, size_t buflen,
|
||||||
dev_t mydev, ino64_t myino, int save,
|
dev_t mydev, ino64_t myino, int save,
|
||||||
int *dostat) internal_function;
|
int *dostat) internal_function;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
internal_function
|
internal_function attribute_compat_text_section
|
||||||
getttyname_r (char *buf, size_t buflen, dev_t mydev, ino64_t myino,
|
getttyname_r (char *buf, size_t buflen, dev_t mydev, ino64_t myino,
|
||||||
int save, int *dostat)
|
int save, int *dostat)
|
||||||
{
|
{
|
||||||
@ -99,7 +100,6 @@ __ttyname_r (int fd, char *buf, size_t buflen)
|
|||||||
struct stat64 st, st1;
|
struct stat64 st, st1;
|
||||||
int dostat = 0;
|
int dostat = 0;
|
||||||
int save = errno;
|
int save = errno;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Test for the absolute minimal size. This makes life easier inside
|
/* Test for the absolute minimal size. This makes life easier inside
|
||||||
the loop. */
|
the loop. */
|
||||||
@ -115,29 +115,34 @@ __ttyname_r (int fd, char *buf, size_t buflen)
|
|||||||
return ERANGE;
|
return ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We try using the /proc filesystem. */
|
if (__builtin_expect (!__isatty (fd), 0))
|
||||||
*_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';
|
|
||||||
|
|
||||||
ret = __readlink (procname, buf, buflen - 1);
|
|
||||||
if (ret == -1 && errno == ENOENT)
|
|
||||||
{
|
|
||||||
__set_errno (EBADF);
|
|
||||||
return EBADF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!__isatty (fd))
|
|
||||||
{
|
{
|
||||||
__set_errno (ENOTTY);
|
__set_errno (ENOTTY);
|
||||||
return ENOTTY;
|
return ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == -1 && errno == ENAMETOOLONG)
|
/* We try using the /proc filesystem. */
|
||||||
|
*_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';
|
||||||
|
|
||||||
|
ssize_t ret = __readlink (procname, buf, buflen - 1);
|
||||||
|
if (__builtin_expect (ret == -1 && errno == ENOENT, 0))
|
||||||
|
{
|
||||||
|
__set_errno (EBADF);
|
||||||
|
return EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__builtin_expect (ret == -1 && errno == ENAMETOOLONG, 0))
|
||||||
{
|
{
|
||||||
__set_errno (ERANGE);
|
__set_errno (ERANGE);
|
||||||
return ERANGE;
|
return ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != -1 && buf[0] != '[')
|
if (__builtin_expect (ret != -1
|
||||||
|
#ifndef __ASSUME_PROC_SELF_FD_SYMLINK
|
||||||
|
/* This is for Linux 2.0. */
|
||||||
|
&& buf[0] != '['
|
||||||
|
#endif
|
||||||
|
, 1))
|
||||||
{
|
{
|
||||||
buf[ret] = '\0';
|
buf[ret] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user