about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--iconv/gconv_conf.c4
-rw-r--r--inet/rcmd.c2
-rw-r--r--inet/ruserpass.c2
-rw-r--r--intl/localealias.c4
-rw-r--r--libio/fileops.c22
-rw-r--r--libio/libio.h1
-rw-r--r--malloc/mtrace.c2
-rw-r--r--misc/Makefile3
-rw-r--r--misc/fstab.h10
-rw-r--r--misc/getpass.c2
-rw-r--r--misc/getttyent.c2
-rw-r--r--misc/getusershell.c2
-rw-r--r--misc/mntent.h12
-rw-r--r--misc/mntent_r.c9
-rw-r--r--nss/nsswitch.c2
-rw-r--r--resolv/res_hconf.c4
-rw-r--r--resolv/res_init.c2
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c8
-rw-r--r--time/getdate.c4
-rw-r--r--time/tzfile.c4
21 files changed, 90 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c0935c0ed..6e1a33c168 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 1fa7d0e9f8..858d40998b 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -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;
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 42871f7950..ad72108b6a 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -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)
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index e0f1a52b0e..e5b2caf4dc 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -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);
diff --git a/intl/localealias.c b/intl/localealias.c
index ed8747d691..32d05ff347 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -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;
diff --git a/libio/fileops.c b/libio/fileops.c
index 4993630efc..8a225ae5a5 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -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;
diff --git a/libio/libio.h b/libio/libio.h
index 11274aebb4..c70a86ae90 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -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
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 6d56cf0b5c..6cdd5f3324 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -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.  */
diff --git a/misc/Makefile b/misc/Makefile
index 406ed0fed9..db04bb9baf 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -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
 
diff --git a/misc/fstab.h b/misc/fstab.h
index 421c65a5c6..24ecad7dbc 100644
--- a/misc/fstab.h
+++ b/misc/fstab.h
@@ -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
 
diff --git a/misc/getpass.c b/misc/getpass.c
index 70562e54af..52dab9439a 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -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;
diff --git a/misc/getttyent.c b/misc/getttyent.c
index 1bc82e6938..2ff0a7b5c2 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -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);
diff --git a/misc/getusershell.c b/misc/getusershell.c
index c15b8f664f..96ab5c8be1 100644
--- a/misc/getusershell.c
+++ b/misc/getusershell.c
@@ -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);
diff --git a/misc/mntent.h b/misc/mntent.h
index 863664c6bf..a82e9539af 100644
--- a/misc/mntent.h
+++ b/misc/mntent.h
@@ -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.  */
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 7a394186d4..9bfe8756f1 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -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.  */
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 08b869854d..b983e3443b 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -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;
 
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index 40afeb0b94..cd622eddb8 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -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;
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 7b9cf43313..61820e6e0b 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -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 */
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 69dabd165b..985a0860cb 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -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.  */
diff --git a/time/getdate.c b/time/getdate.c
index 8c9d16f833..851efacfd2 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -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;
 
diff --git a/time/tzfile.c b/time/tzfile.c
index 2d1775b05b..e2d9f50cd9 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -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;