summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2007-02-03 18:12:11 +0100
committerJim Meyering <jim@meyering.net>2007-02-03 18:12:11 +0100
commit1c73876f5f7973ca41caaf0ce326254b1081713a (patch)
tree168710b53277fa888fc53d184d00bb088338192a /src
parent251f774621735e208e3800022ad4acd0b785784e (diff)
downloadcoreutils-1c73876f5f7973ca41caaf0ce326254b1081713a.tar.xz
* NEWS: Document fix for cp --parents.
* src/cp.c (make_dir_parents_private): Report the error sooner with "cp --parents DIR/FILE DEST" when DIR is a non-directory, thus not creating the directory, DEST/DIR. * tests/cp/cp-parents: Test for the non-race-condition bug fixed by the above change.
Diffstat (limited to 'src')
-rw-r--r--src/cp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cp.c b/src/cp.c
index 8fe11a1e7..aea63dce7 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -1,5 +1,5 @@
/* cp.c -- file copying (main routines)
- Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation.
+ Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -415,6 +415,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
mode_t src_mode;
mode_t omitted_permissions;
mode_t mkdir_mode;
+ int src_errno;
/* This component does not exist. We must set
*new_dst and new->mode inside this loop because,
@@ -422,9 +423,14 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
make_dir_parents_private creates only e_dir/../a if
./b already exists. */
*new_dst = true;
- if (XSTAT (x, src, &stats))
+ src_errno = (XSTAT (x, src, &stats) != 0
+ ? errno
+ : S_ISDIR (stats.st_mode)
+ ? 0
+ : ENOTDIR);
+ if (src_errno)
{
- error (0, errno, _("failed to get attributes of %s"),
+ error (0, src_errno, _("failed to get attributes of %s"),
quote (src));
return false;
}