-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.
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;
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)
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);
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;
#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)
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
case 'm':
fp->_flags2 |= _IO_FLAGS2_MMAP;
continue;
+ case 'c':
+ fp->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+ break;
default:
/* Ignore. */
continue;
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)
_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;
#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
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. */
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
__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
/* 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;
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);
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);
/* 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
/* 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. */
/* 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
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. */
size_t len;
/* Open the configuration file. */
- fp = fopen (fname, "r");
+ fp = fopen (fname, "rc");
if (fp == NULL)
return NULL;
-/* 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).
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;
(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 */
/* 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. */
{
__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. */
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. */
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. */
/* 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.
return 2;
/* Open the template file. */
- fp = fopen (datemsk, "r");
+ fp = fopen (datemsk, "rc");
if (fp == NULL)
return 2;
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;