* NEWS: Mention deprecation of fdsavedir.
* lib/savedir.c (streamsavedir): New extern function, whose name
ends in "savedir" to be consistent with the others. This differs
from savedirstream in that it doesn't close its argument. The
next version of GNU tar will use this instead of fdsavedir, to
avoid some race conditions and conserve file descriptors.
(savedirstream): Reimplement as a wrapper around streamsavedir.
(fdsavedir): Add a comment deprecating this function. As far as
I know, only GNU tar used it, and GNU tar doesn't need it any more.
* lib/savedir.h (streamsavedir): New decl.
(fdsavedir): Add a comment deprecating this.
+2010-09-12 Paul Eggert <eggert@cs.ucla.edu>
+
+ savedir: add streamsavedir, deprecate fdsavedir
+ * NEWS: Mention deprecation of fdsavedir.
+ * lib/savedir.c (streamsavedir): New extern function, whose name
+ ends in "savedir" to be consistent with the others. This differs
+ from savedirstream in that it doesn't close its argument. The
+ next version of GNU tar will use this instead of fdsavedir, to
+ avoid some race conditions and conserve file descriptors.
+ (savedirstream): Reimplement as a wrapper around streamsavedir.
+ (fdsavedir): Add a comment deprecating this function. As far as
+ I know, only GNU tar used it, and GNU tar doesn't need it any more.
+ * lib/savedir.h (streamsavedir): New decl.
+ (fdsavedir): Add a comment deprecating this.
+
2010-09-10 Bruno Haible <bruno@clisp.org>
langinfo: Fix last commit.
Date Modules Changes
+2010-09-12 savedir The fdsavedir function is now deprecated.
+
2010-09-10 fcntl-h This module now defaults O_CLOEXEC to 0, and
it defaults O_EXEC and O_SEARCH to O_RDONLY.
Use "#if O_CLOEXEC" instead of "#ifdef O_CLOEXEC".
/* Return a freshly allocated string containing the file names
in directory DIRP, separated by '\0' characters;
the end is marked by two '\0' characters in a row.
- Return NULL (setting errno) if DIRP cannot be read or closed.
+ Return NULL (setting errno) if DIRP cannot be read.
If DIRP is NULL, return NULL without affecting errno. */
-static char *
-savedirstream (DIR *dirp)
+char *
+streamsavedir (DIR *dirp)
{
char *name_space;
size_t allocated = NAME_SIZE_DEFAULT;
}
name_space[used] = '\0';
save_errno = errno;
- if (closedir (dirp) != 0)
- save_errno = errno;
if (save_errno != 0)
{
free (name_space);
return name_space;
}
+/* Like savedirstreamp (DIRP), except also close DIRP. */
+
+static char *
+savedirstream (DIR *dirp)
+{
+ char *name_space = streamsavedir (dirp);
+ if (dirp && closedir (dirp) != 0)
+ {
+ int save_errno = errno;
+ free (name_space);
+ errno = save_errno;
+ return NULL;
+ }
+ return name_space;
+}
+
/* Return a freshly allocated string containing the file names
in directory DIR, separated by '\0' characters;
the end is marked by two '\0' characters in a row.
the end is marked by two '\0' characters in a row.
Return NULL (setting errno) if FD cannot be read or closed. */
+/* deprecated */
char *
fdsavedir (int fd)
{
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
-#if !defined SAVEDIR_H_
-# define SAVEDIR_H_
+#ifndef _GL_SAVEDIR_H
+#define _GL_SAVEDIR_H
+#include <dirent.h>
+char *streamsavedir (DIR *dirp);
char *savedir (char const *dir);
-char *fdsavedir (int fd);
+char *fdsavedir (int fd); /* deprecated */
#endif