summaryrefslogtreecommitdiff
path: root/lib/mkdir-p.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-06-13 10:15:19 +0000
committerJim Meyering <jim@meyering.net>2005-06-13 10:15:19 +0000
commitecd375b64aeb3805261916ee3408fadcacd0c448 (patch)
tree6120abfe5a5ec3826e6b45391299e735b15dc0f2 /lib/mkdir-p.c
parent26438e44cd2770c9bdbe444dafee120404ac3f55 (diff)
downloadcoreutils-ecd375b64aeb3805261916ee3408fadcacd0c448.tar.xz
(make_dir_parents): New parameter: different_working_dir,
to tell caller if/when we change the working directory and are unable to return to the initial one.
Diffstat (limited to 'lib/mkdir-p.c')
-rw-r--r--lib/mkdir-p.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/mkdir-p.c b/lib/mkdir-p.c
index 839b33842..bcda8d482 100644
--- a/lib/mkdir-p.c
+++ b/lib/mkdir-p.c
@@ -63,6 +63,7 @@
_("failed to return to initial working directory")); \
free_cwd (&cwd); \
errno = _saved_errno; \
+ *different_working_dir = true; \
return false; \
} \
free_cwd (&cwd); \
@@ -144,6 +145,9 @@ make_dir (char const *dir, char const *fulldir, mode_t mode,
with the name of the directory that was just made as an argument.
If PRESERVE_EXISTING is true and ARG is an existing directory,
then do not attempt to set its permissions and ownership.
+ Upon return, set *DIFFERENT_WORKING_DIR to true if this function
+ has changed the current working directory and is unable to restore
+ it to its initial state.
Return true iff ARG exists as a directory with the proper
ownership and permissions when done. */
@@ -155,10 +159,12 @@ make_dir_parents (char const *arg,
uid_t owner,
gid_t group,
bool preserve_existing,
- char const *verbose_fmt_string)
+ char const *verbose_fmt_string,
+ bool *different_working_dir)
{
struct stat stats;
bool retval = true;
+ *different_working_dir = false;
if (stat (arg, &stats) != 0)
{