From: Jim Meyering Date: Mon, 13 Jun 2005 10:19:18 +0000 (+0000) Subject: (main): When make_dir_parents changes the current working X-Git-Tag: CPPI-1_12~640 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=736dfd391dbcdba2340ded3066a186ec6c7be1b4;p=thirdparty%2Fcoreutils.git (main): When make_dir_parents changes the current working directory, give a diagnostic about each subsequent failure to create a dot-relative directory. (install_file_in_file_parents): Update make_dir_parents caller. --- diff --git a/src/install.c b/src/install.c index 027d201d98..b885fae864 100644 --- a/src/install.c +++ b/src/install.c @@ -357,11 +357,25 @@ main (int argc, char **argv) if (dir_arg) { int i; + bool cwd_not_restored = false; for (i = 0; i < n_files; i++) { + bool different_cwd; + if (cwd_not_restored && IS_RELATIVE_FILE_NAME (argv[optind])) + { + error (0, 0, + _("unable to create relative-named directory, %s," + " due to prior failure to restore working directory"), + quote (argv[optind])); + ok = false;; + continue; + } + ok &= make_dir_parents (file[i], mode, mode, owner_id, group_id, false, - (x.verbose ? _("creating directory %s") : NULL)); + (x.verbose ? _("creating directory %s") : NULL), + &different_cwd); + cwd_not_restored |= different_cwd; } } else @@ -409,9 +423,12 @@ install_file_in_file_parents (char const *from, char const *to, that this option is intended mainly to help installers when the distribution doesn't provide proper install rules. */ mode_t dir_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + bool different_cwd; /* FIXME: use this */ ok = make_dir_parents (dest_dir, dir_mode, dir_mode, owner_id, group_id, true, - (x->verbose ? _("creating directory %s") : NULL)); + (x->verbose ? _("creating directory %s") : NULL), + &different_cwd); + /* Ignore different_cwd, since this function is called at most once. */ } free (dest_dir);