summaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/getcwd.c12
-rw-r--r--sysdeps/posix/mk-stdiolim.c26
2 files changed, 38 insertions, 0 deletions
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index d40d8d6822..c7fda3eb2c 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -217,6 +217,7 @@ __getcwd (buf, size)
char *path;
register char *pathp;
struct stat st;
+ int prev_errno = errno;
if (size == 0)
{
@@ -310,6 +311,9 @@ __getcwd (buf, size)
dirstream = __opendir (dotp);
if (dirstream == NULL)
goto lose;
+ /* Clear errno to distinguish EOF from error if readdir returns
+ NULL. */
+ __set_errno (0);
while ((d = __readdir (dirstream)) != NULL)
{
if (d->d_name[0] == '.' &&
@@ -343,6 +347,10 @@ __getcwd (buf, size)
{
int save = errno;
(void) __closedir (dirstream);
+ if (save == 0)
+ /* EOF on dirstream, which means that the current directory
+ has been removed. */
+ save = ENOENT;
__set_errno (save);
goto lose;
}
@@ -393,6 +401,10 @@ __getcwd (buf, size)
free ((__ptr_t) dotlist);
memmove (path, pathp, path + size - pathp);
+
+ /* Restore errno on successful return. */
+ __set_errno (prev_errno);
+
return path;
lose:
diff --git a/sysdeps/posix/mk-stdiolim.c b/sysdeps/posix/mk-stdiolim.c
index 7009c4ef10..c268b642de 100644
--- a/sysdeps/posix/mk-stdiolim.c
+++ b/sysdeps/posix/mk-stdiolim.c
@@ -21,6 +21,32 @@
int
main()
{
+ /* Print copyright message. */
+ printf ("\
+/* Stdio limits for POSIX systems.\n\
+ Copyright (C) 1994, 1997 Free Software Foundation, Inc.\n\
+ This file is part of the GNU C Library.\n\
+\n\
+ The GNU C Library is free software; you can redistribute it and/or\n\
+ modify it under the terms of the GNU Library General Public License as\n\
+ published by the Free Software Foundation; either version 2 of the\n\
+ License, or (at your option) any later version.\n\
+\n\
+ The GNU C Library is distributed in the hope that it will be useful,\n\
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n\
+ Library General Public License for more details.\n\
+\n\
+ You should have received a copy of the GNU Library General Publicn\n\
+ License along with the GNU C Library; see the file COPYING.LIB. If not,\n\
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n\
+ Boston, MA 02111-1307, USA. */\n\
+\n\
+#ifndef _STDIO_H\n\
+# error \"Never include <bits/stdio_lim.h> directly; use <stdio.h> instead.\"\n\
+#endif\n\
+\n");
+
/* These values correspond to the code in sysdeps/posix/tempname.c.
Change the values here if you change that code. */
printf ("#define L_tmpnam %u\n", sizeof ("/usr/tmp/") + 9);