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;
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. */
/* 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-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;