2003-09-04  Ulrich Drepper  <drepper@redhat.com>

	* libio/libio.h: Define _IO_FLAGS2_NOTCANCEL.
	* libio/fileops.c [_LIBC]: Remove close macro.
	(_IO_file_open): If _IO_FLAGS2_NOTCANCEL is set, use open_not_cancel.
	(_IO_new_file_open): Recognize 'c' flag in mode string.
	(_IO_file_read): If _IO_FLAGS2_NOTCANCEL is set use read_not_cancel.
	(_IO_new_file_write): If _IO_FLAGS2_NOTCANCEL is set use
	write_not_cancel.
	* iconv/gconv_conf.c: Use fopen with 'c' mode flag.
	* inet/rcmd.c: Likewise.
	* inet/ruserpass.c: Likewise.
	* intl/localealias.c: Likewise.
	* malloc/mtrace.c: Likewise.
	* misc/getpass.c: Likewise.
	* misc/getttyent.c: Likewise.
	* misc/mntent_r.c: Likewise.
	* misc/getusershell.c: Likewise.
	* nss/nsswitch.c: Likewise.
	* resolv/res_hconf.c: Likewise.
	* resolv/res_init.c: Likewise.
	* sysdeps/unix/sysv/linux/getsysstats.c: Likewise.
	* time/getdate.c: Likewise.
	* time/tzfile.c: Likewise.
	* misc/fstab.h: Undo last change.
	* misc/mntent.h: Likewise.
	* misc/Makefile: Remove CFLAGS-mntent_r.c, CFLAGS-mntent.c, and
	CFLAGS-fstab.c definition.

2003-09-04  Jakub Jelinek  <jakub@redhat.com>
2003-09-03  Ulrich Drepper  <drepper@redhat.com>
This commit is contained in:
Ulrich Drepper 2003-09-04 08:27:37 +00:00
parent 58e8ec84f4
commit ee8449f729
21 changed files with 90 additions and 44 deletions

View file

@ -1,8 +1,37 @@
22003-09-04 Jakub Jelinek <jakub@redhat.com>
2003-09-04 Ulrich Drepper <drepper@redhat.com>
* libio/libio.h: Define _IO_FLAGS2_NOTCANCEL.
* libio/fileops.c [_LIBC]: Remove close macro.
(_IO_file_open): If _IO_FLAGS2_NOTCANCEL is set, use open_not_cancel.
(_IO_new_file_open): Recognize 'c' flag in mode string.
(_IO_file_read): If _IO_FLAGS2_NOTCANCEL is set use read_not_cancel.
(_IO_new_file_write): If _IO_FLAGS2_NOTCANCEL is set use
write_not_cancel.
* iconv/gconv_conf.c: Use fopen with 'c' mode flag.
* inet/rcmd.c: Likewise.
* inet/ruserpass.c: Likewise.
* intl/localealias.c: Likewise.
* malloc/mtrace.c: Likewise.
* misc/getpass.c: Likewise.
* misc/getttyent.c: Likewise.
* misc/mntent_r.c: Likewise.
* misc/getusershell.c: Likewise.
* nss/nsswitch.c: Likewise.
* resolv/res_hconf.c: Likewise.
* resolv/res_init.c: Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c: Likewise.
* time/getdate.c: Likewise.
* time/tzfile.c: Likewise.
* misc/fstab.h: Undo last change.
* misc/mntent.h: Likewise.
* misc/Makefile: Remove CFLAGS-mntent_r.c, CFLAGS-mntent.c, and
CFLAGS-fstab.c definition.
2003-09-04 Jakub Jelinek <jakub@redhat.com>
* sysdeps/generic/unwind.h (_Unwind_GetBSP): Add prototype.
003-09-03 Ulrich Drepper <drepper@redhat.com>
2003-09-03 Ulrich Drepper <drepper@redhat.com>
* nss/getXXbyYY_r.c (INTERNAL): Explicitly set errno and avoid
returning ERANGE if this wasn't intended.

View file

@ -357,7 +357,9 @@ internal_function
read_conf_file (const char *filename, const char *directory, size_t dir_len,
void **modules, size_t *nmodules)
{
FILE *fp = fopen (filename, "r");
/* Note the file is opened with cancellation in the I/O functions
disabled. */
FILE *fp = fopen (filename, "rc");
char *line = NULL;
size_t line_len = 0;
static int modcounter;

View file

@ -551,7 +551,7 @@ iruserfopen (const char *file, uid_t okuser)
cp = _("not regular file");
else
{
res = fopen (file, "r");
res = fopen (file, "rc");
if (!res)
cp = _("cannot open");
else if (__fxstat64 (_STAT_VER, fileno (res), &st) < 0)

View file

@ -114,7 +114,7 @@ ruserpass(host, aname, apass)
buf = alloca (strlen (hdir) + 8);
__stpcpy (__stpcpy (buf, hdir), "/.netrc");
cfile = fopen(buf, "r");
cfile = fopen(buf, "rc");
if (cfile == NULL) {
if (errno != ENOENT)
warn("%s", buf);

View file

@ -219,7 +219,9 @@ read_alias_file (fname, fname_len)
memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
#endif
fp = fopen (full_fname, "r");
/* Note the file is opened with cancellation in the I/O functions
disabled. */
fp = fopen (full_fname, "rc");
freea (full_fname);
if (fp == NULL)
return 0;

View file

@ -59,7 +59,6 @@ extern int errno;
#ifdef _LIBC
# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
# define close(FD) __close (FD)
# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
@ -226,10 +225,12 @@ _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64)
int is32not64;
{
int fdesc;
#ifdef _G_OPEN64
fdesc = (is32not64
? open (filename, posix_mode, prot)
: _G_OPEN64 (filename, posix_mode, prot));
#ifdef _LIBC
if (fp->_flags2 & _IO_FLAGS2_NOTCANCEL)
fdesc = open_not_cancel (filename,
posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
#else
fdesc = open (filename, posix_mode, prot);
#endif
@ -318,6 +319,9 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
case 'm':
fp->_flags2 |= _IO_FLAGS2_MMAP;
continue;
case 'c':
fp->_flags2 |= _IO_FLAGS2_NOTCANCEL;
break;
default:
/* Ignore. */
continue;
@ -1200,7 +1204,9 @@ _IO_file_read (fp, buf, size)
void *buf;
_IO_ssize_t size;
{
return read (fp->_fileno, buf, size);
return ((fp->_flags2 & _IO_FLAGS2_NOTCANCEL)
? read_not_cancel (fp->_fileno, buf, size)
: read (fp->_fileno, buf, size));
}
INTDEF(_IO_file_read)
@ -1262,7 +1268,9 @@ _IO_new_file_write (f, data, n)
_IO_ssize_t to_do = n;
while (to_do > 0)
{
_IO_ssize_t count = write (f->_fileno, data, to_do);
_IO_ssize_t count = ((f->_flags2 & _IO_FLAGS2_NOTCANCEL)
? write_not_cancel (f->_fileno, data, to_do)
: write (f->_fileno, data, to_do));
if (count < 0)
{
f->_flags |= _IO_ERR_SEEN;

View file

@ -138,6 +138,7 @@
#define _IO_USER_LOCK 0x8000
#define _IO_FLAGS2_MMAP 1
#define _IO_FLAGS2_NOTCANCEL 2
/* These are "formatting flags" matching the iostream fmtflags enum values. */
#define _IO_SKIPWS 01

View file

@ -280,7 +280,7 @@ mtrace ()
if (mtb == NULL)
return;
mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "w");
mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "wc");
if (mallstream != NULL)
{
/* Make sure we close the file descriptor on exec. */

View file

@ -86,9 +86,6 @@ CFLAGS-error.c = -fexceptions
CFLAGS-getpass.c = -fexceptions
CFLAGS-mkstemp.c = -fexceptions
CFLAGS-mkstemp64.c = -fexceptions
CFLAGS-mntent_r.c = -fexceptions
CFLAGS-mntent.c = -fexceptions
CFLAGS-fstab.c = -fexceptions
CFLAGS-getsysstats.c = -fexceptions
CFLAGS-getusershell.c = -fexceptions

View file

@ -68,11 +68,11 @@ struct fstab
__BEGIN_DECLS
extern struct fstab *getfsent (void);
extern struct fstab *getfsspec (__const char *__name);
extern struct fstab *getfsfile (__const char *__name);
extern int setfsent (void);
extern void endfsent (void);
extern struct fstab *getfsent (void) __THROW;
extern struct fstab *getfsspec (__const char *__name) __THROW;
extern struct fstab *getfsfile (__const char *__name) __THROW;
extern int setfsent (void) __THROW;
extern void endfsent (void) __THROW;
__END_DECLS

View file

@ -56,7 +56,7 @@ getpass (prompt)
/* Try to write to and read from the terminal if we can.
If we can't open the terminal, use stderr and stdin. */
in = fopen ("/dev/tty", "w+");
in = fopen ("/dev/tty", "w+c");
if (in == NULL)
{
in = stdin;

View file

@ -192,7 +192,7 @@ setttyent()
if (tf) {
(void)rewind(tf);
return (1);
} else if ((tf = fopen(_PATH_TTYS, "r"))) {
} else if ((tf = fopen(_PATH_TTYS, "rc"))) {
/* We do the locking ourselves. */
__fsetlocking (tf, FSETLOCKING_BYCALLER);
return (1);

View file

@ -100,7 +100,7 @@ initshells()
if (strings != NULL)
free(strings);
strings = NULL;
if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
if ((fp = fopen(_PATH_SHELLS, "rc")) == NULL)
return (char **) okshells;
if (fstat64(fileno(fp), &statb) == -1) {
(void)fclose(fp);

View file

@ -1,5 +1,5 @@
/* Utilities for reading/writing fstab, mtab, etc.
Copyright (C) 1995-1999, 2003 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999 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
@ -64,28 +64,28 @@ struct mntent
/* Prepare to begin reading and/or writing mount table entries from the
beginning of FILE. MODE is as for `fopen'. */
extern FILE *setmntent (__const char *__file, __const char *__mode);
extern FILE *setmntent (__const char *__file, __const char *__mode) __THROW;
/* Read one mount table entry from STREAM. Returns a pointer to storage
reused on the next call, or null for EOF or error (use feof/ferror to
check). */
extern struct mntent *getmntent (FILE *__stream);
extern struct mntent *getmntent (FILE *__stream) __THROW;
#ifdef __USE_MISC
/* Reentrant version of the above function. */
extern struct mntent *getmntent_r (FILE *__restrict __stream,
struct mntent *__restrict __result,
char *__restrict __buffer,
int __bufsize);
int __bufsize) __THROW;
#endif
/* Write the mount table entry described by MNT to STREAM.
Return zero on success, nonzero on failure. */
extern int addmntent (FILE *__restrict __stream,
__const struct mntent *__restrict __mnt);
__const struct mntent *__restrict __mnt) __THROW;
/* Close a stream opened with `setmntent'. */
extern int endmntent (FILE *__stream);
extern int endmntent (FILE *__stream) __THROW;
/* Search MNT->mnt_opts for an option matching OPT.
Returns the address of the substring, or null if none found. */

View file

@ -1,5 +1,5 @@
/* Utilities for reading/writing fstab, mtab, etc.
Copyright (C) 1995-2000, 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1995-2000, 2001, 2002, 2003 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
@ -38,7 +38,12 @@
FILE *
__setmntent (const char *file, const char *mode)
{
FILE *result = fopen (file, mode);
/* Extend the mode parameter with "c" to disable cancellation in the
I/O functions. */
size_t modelen = strlen (mode);
char newmode[modelen + 2];
memcpy (mempcpy (newmode, mode, modelen), "c", 2);
FILE *result = fopen (file, newmode);
if (result != NULL)
/* We do the locking ourselves. */

View file

@ -428,7 +428,7 @@ nss_parse_file (const char *fname)
size_t len;
/* Open the configuration file. */
fp = fopen (fname, "r");
fp = fopen (fname, "rc");
if (fp == NULL)
return NULL;

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1993, 1995-2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 1993, 1995-2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David Mosberger (davidm@azstarnet.com).
@ -425,7 +425,7 @@ do_init (void)
if (hconf_name == NULL)
hconf_name = _PATH_HOSTCONF;
fp = fopen (hconf_name, "r");
fp = fopen (hconf_name, "rc");
if (!fp)
/* make up something reasonable: */
_res_hconf.service[_res_hconf.num_services++] = SERVICE_BIND;

View file

@ -231,7 +231,7 @@ __res_vinit(res_state statp, int preinit) {
(line[sizeof(name) - 1] == ' ' || \
line[sizeof(name) - 1] == '\t'))
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
if ((fp = fopen(_PATH_RESCONF, "rc")) != NULL) {
/* No threads use this stream. */
__fsetlocking (fp, FSETLOCKING_BYCALLER);
/* read the config file */

View file

@ -154,7 +154,7 @@ __get_nprocs ()
/* The /proc/stat format is more uniform, use it by default. */
__stpcpy (__stpcpy (proc_fname, proc_path), "/stat");
fp = fopen (proc_fname, "r");
fp = fopen (proc_fname, "rc");
if (fp != NULL)
{
/* No threads use this stream. */
@ -171,7 +171,7 @@ __get_nprocs ()
{
__stpcpy (__stpcpy (proc_fname, proc_path), "/cpuinfo");
fp = fopen (proc_fname, "r");
fp = fopen (proc_fname, "rc");
if (fp != NULL)
{
/* No threads use this stream. */
@ -209,7 +209,7 @@ __get_nprocs_conf ()
char *proc_cpuinfo = alloca (strlen (proc_path) + sizeof ("/cpuinfo"));
__stpcpy (__stpcpy (proc_cpuinfo, proc_path), "/cpuinfo");
fp = fopen (proc_cpuinfo, "r");
fp = fopen (proc_cpuinfo, "rc");
if (fp != NULL)
{
/* No threads use this stream. */
@ -249,7 +249,7 @@ phys_pages_info (const char *format)
char *proc_meminfo = alloca (strlen (proc_path) + sizeof ("/meminfo"));
__stpcpy (__stpcpy (proc_meminfo, proc_path), "/meminfo");
fp = fopen (proc_meminfo, "r");
fp = fopen (proc_meminfo, "rc");
if (fp != NULL)
{
/* No threads use this stream. */

View file

@ -1,5 +1,5 @@
/* Convert a string representation of time to a time value.
Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1997,1998,1999,2000,2001,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
@ -129,7 +129,7 @@ __getdate_r (const char *string, struct tm *tp)
return 2;
/* Open the template file. */
fp = fopen (datemsk, "r");
fp = fopen (datemsk, "rc");
if (fp == NULL)
return 2;

View file

@ -148,7 +148,9 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
file = new;
}
f = fopen (file, "r");
/* Note the file is opened with cancellation in the I/O functions
disabled. */
f = fopen (file, "rc");
if (f == NULL)
return;