coreutils: Add various bug fixes
Add a number of bug fixes, mostly imported from Fedora and Wind River Linux. cp-i-u: fix unnecessary prompting fix-install: Fix installing to a dangling symlink i18n: li18nux/lsb compliance ls-x: Fix incorrect output overflow: Fix potential overflow in who command Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
This commit is contained in:
parent
427472e980
commit
522d16a70f
|
@ -0,0 +1,118 @@
|
|||
This patch was imported from the Fedora Core 8 coreutils-6.9-9 package.
|
||||
|
||||
The package is stated as being Licensed as GPLv2+.
|
||||
|
||||
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
||||
|
||||
----
|
||||
|
||||
When "cp -i --update old new" would do nothing because "new" is
|
||||
newer than "old", cp would nonetheless prompt for whether it is
|
||||
ok to overwrite "new". Then, regardless of the response (because
|
||||
of the --update option), cp would do nothing.
|
||||
|
||||
The following patch eliminates the unnecessary prompt in that case.
|
||||
|
||||
diff --git a/src/copy.c b/src/copy.c
|
||||
index b7bf73b..0e549d2 100644
|
||||
--- a/src/copy.c
|
||||
+++ b/src/copy.c
|
||||
@@ -1210,6 +1210,30 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
+ if (!S_ISDIR (src_mode) && x->update)
|
||||
+ {
|
||||
+ /* When preserving time stamps (but not moving within a file
|
||||
+ system), don't worry if the destination time stamp is
|
||||
+ less than the source merely because of time stamp
|
||||
+ truncation. */
|
||||
+ int options = ((x->preserve_timestamps
|
||||
+ && ! (x->move_mode
|
||||
+ && dst_sb.st_dev == src_sb.st_dev))
|
||||
+ ? UTIMECMP_TRUNCATE_SOURCE
|
||||
+ : 0);
|
||||
+
|
||||
+ if (0 <= utimecmp (dst_name, &dst_sb, &src_sb, options))
|
||||
+ {
|
||||
+ /* We're using --update and the destination is not older
|
||||
+ than the source, so do not copy or move. Pretend the
|
||||
+ rename succeeded, so the caller (if it's mv) doesn't
|
||||
+ end up removing the source file. */
|
||||
+ if (rename_succeeded)
|
||||
+ *rename_succeeded = true;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* When there is an existing destination file, we may end up
|
||||
returning early, and hence not copying/moving the file.
|
||||
This may be due to an interactive `negative' reply to the
|
||||
@@ -1302,30 +1326,6 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-
|
||||
- if (x->update)
|
||||
- {
|
||||
- /* When preserving time stamps (but not moving within a file
|
||||
- system), don't worry if the destination time stamp is
|
||||
- less than the source merely because of time stamp
|
||||
- truncation. */
|
||||
- int options = ((x->preserve_timestamps
|
||||
- && ! (x->move_mode
|
||||
- && dst_sb.st_dev == src_sb.st_dev))
|
||||
- ? UTIMECMP_TRUNCATE_SOURCE
|
||||
- : 0);
|
||||
-
|
||||
- if (0 <= utimecmp (dst_name, &dst_sb, &src_sb, options))
|
||||
- {
|
||||
- /* We're using --update and the destination is not older
|
||||
- than the source, so do not copy or move. Pretend the
|
||||
- rename succeeded, so the caller (if it's mv) doesn't
|
||||
- end up removing the source file. */
|
||||
- if (rename_succeeded)
|
||||
- *rename_succeeded = true;
|
||||
- return true;
|
||||
- }
|
||||
- }
|
||||
}
|
||||
|
||||
if (x->move_mode)
|
||||
diff --git a/tests/mv/update b/tests/mv/update
|
||||
index 0c06024..6c3d149 100755
|
||||
--- a/tests/mv/update
|
||||
+++ b/tests/mv/update
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# make sure --update works as advertised
|
||||
|
||||
-# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
|
||||
+# Copyright (C) 2001, 2004, 2006-2007 Free Software Foundation, Inc.
|
||||
|
||||
# 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
|
||||
@@ -46,11 +46,16 @@ fi
|
||||
|
||||
fail=0
|
||||
|
||||
-for cp_or_mv in cp mv; do
|
||||
- # This is a no-op.
|
||||
- $cp_or_mv --update old new || fail=1
|
||||
- case "`cat new`" in new) ;; *) fail=1 ;; esac
|
||||
- case "`cat old`" in old) ;; *) fail=1 ;; esac
|
||||
+for interactive in '' -i; do
|
||||
+ for cp_or_mv in cp mv; do
|
||||
+ # This is a no-op, with no prompt.
|
||||
+ # With coreutils-6.9 and earlier, using --update with -i would
|
||||
+ # mistakenly elicit a prompt.
|
||||
+ $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1
|
||||
+ test -s out && fail=1
|
||||
+ case "`cat new`" in new) ;; *) fail=1 ;; esac
|
||||
+ case "`cat old`" in old) ;; *) fail=1 ;; esac
|
||||
+ done
|
||||
done
|
||||
|
||||
# This will actually perform the rename.
|
||||
--
|
||||
1.5.3.rc1.16.g9d6f
|
|
@ -0,0 +1,99 @@
|
|||
The install command doesn't over write the dangling symlink, for
|
||||
example:
|
||||
|
||||
$ install fileA /tmp/fileA
|
||||
|
||||
If /tmp/fileA is a dangling symlink, there would be an error:
|
||||
|
||||
install: cannot create regular file '/tmp/fileA': File exists
|
||||
|
||||
This is because of the following code in copy.c:
|
||||
|
||||
if (!new_dst)
|
||||
{
|
||||
if (XSTAT (x, dst_name, &dst_sb) != 0)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, _("cannot stat %s"), quote (dst_name));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_dst = true;
|
||||
}
|
||||
}
|
||||
|
||||
XSTAT() use stat() for dst_name(the dangling symlink /tmp/fileA) when
|
||||
install.c invokes it, and stat will set errno to ENOENT, and then
|
||||
new_dst will be set to true which means that /tmp/fileA doesn't exist,
|
||||
then we will create /tmp/fileA without remove it first, so the error
|
||||
comes.
|
||||
|
||||
This is fixed in a way which adds the member cmd_install in
|
||||
struct cp_options to make sure my change only affected to the install
|
||||
command and use lstat to fix the problem.
|
||||
|
||||
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
|
||||
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
||||
|
||||
---
|
||||
src/copy.c | 10 +++++++++-
|
||||
src/copy.h | 3 +++
|
||||
src/install.c | 1 +
|
||||
3 files changed, 13 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/src/copy.c b/src/copy.c
|
||||
--- a/src/copy.c
|
||||
+++ b/src/copy.c
|
||||
@@ -1029,6 +1029,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
bool delayed_ok;
|
||||
bool copied_as_regular = false;
|
||||
bool preserve_metadata;
|
||||
+ int dst_stat_result;
|
||||
|
||||
if (x->move_mode && rename_succeeded)
|
||||
*rename_succeeded = false;
|
||||
@@ -1069,7 +1070,14 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|
||||
if (!new_dst)
|
||||
{
|
||||
- if (XSTAT (x, dst_name, &dst_sb) != 0)
|
||||
+ if ( x->cmd_install && ( x->backup_type == no_backups))
|
||||
+ dst_stat_result = lstat (dst_name, &dst_sb);
|
||||
+ else
|
||||
+ {
|
||||
+ dst_stat_result = XSTAT (x, dst_name, &dst_sb);
|
||||
+ }
|
||||
+
|
||||
+ if (dst_stat_result != 0)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
diff --git a/src/copy.h b/src/copy.h
|
||||
--- a/src/copy.h
|
||||
+++ b/src/copy.h
|
||||
@@ -114,6 +114,9 @@ struct cp_options
|
||||
If that fails, then resort to copying. */
|
||||
bool move_mode;
|
||||
|
||||
+ /* For the install command */
|
||||
+ bool cmd_install;
|
||||
+
|
||||
/* Whether this process has appropriate privileges to chown a file
|
||||
whose owner is not the effective user ID. */
|
||||
bool chown_privileges;
|
||||
diff --git a/src/install.c b/src/install.c
|
||||
--- a/src/install.c
|
||||
+++ b/src/install.c
|
||||
@@ -149,6 +149,7 @@ cp_option_init (struct cp_options *x)
|
||||
x->hard_link = false;
|
||||
x->interactive = I_UNSPECIFIED;
|
||||
x->move_mode = false;
|
||||
+ x->cmd_install = true;
|
||||
x->chown_privileges = chown_privileges ();
|
||||
x->one_file_system = false;
|
||||
x->preserve_ownership = false;
|
||||
--
|
||||
1.7.0.1
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,115 @@
|
|||
This patch was imported from the Fedora Core 8 coreutils-6.9-9 package.
|
||||
|
||||
The package is stated as being Licensed as GPLv2+.
|
||||
|
||||
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
||||
|
||||
--- coreutils-6.9/src/ls.c.ls-x 2007-06-13 14:27:36.000000000 +0100
|
||||
+++ coreutils-6.9/src/ls.c 2007-06-13 14:28:42.000000000 +0100
|
||||
@@ -4151,16 +4151,16 @@
|
||||
size_t pos = 0;
|
||||
size_t cols = calculate_columns (false);
|
||||
struct column_info const *line_fmt = &column_info[cols - 1];
|
||||
- size_t name_length = length_of_file_name_and_frills (cwd_file);
|
||||
+ struct fileinfo const *f = sorted_file[0];
|
||||
+ size_t name_length = length_of_file_name_and_frills (f);
|
||||
size_t max_name_length = line_fmt->col_arr[0];
|
||||
|
||||
/* Print first entry. */
|
||||
- print_file_name_and_frills (cwd_file);
|
||||
+ print_file_name_and_frills (f);
|
||||
|
||||
/* Now the rest. */
|
||||
for (filesno = 1; filesno < cwd_n_used; ++filesno)
|
||||
{
|
||||
- struct fileinfo const *f;
|
||||
size_t col = filesno % cols;
|
||||
|
||||
if (col == 0)
|
||||
--- coreutils-6.9/tests/ls/Makefile.am.ls-x 2007-03-18 21:36:43.000000000 +0000
|
||||
+++ coreutils-6.9/tests/ls/Makefile.am 2007-06-13 14:28:42.000000000 +0100
|
||||
@@ -24,7 +24,7 @@
|
||||
stat-dtype \
|
||||
inode dangle file-type recursive dired infloop \
|
||||
rt-1 time-1 symlink-slash follow-slink no-arg m-option \
|
||||
- stat-vs-dirent
|
||||
+ stat-vs-dirent x-option
|
||||
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
--- /dev/null 2007-06-13 08:43:51.993263382 +0100
|
||||
+++ coreutils-6.9/tests/ls/x-option 2007-06-13 14:28:42.000000000 +0100
|
||||
@@ -0,0 +1,59 @@
|
||||
+#!/bin/sh
|
||||
+# Exercise the -x option.
|
||||
+
|
||||
+# Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+# 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
|
||||
+# the Free Software Foundation; either version 2 of the License, or
|
||||
+# (at your option) any later version.
|
||||
+
|
||||
+# This program is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+# GNU General Public License for more details.
|
||||
+
|
||||
+# You should have received a copy of the GNU General Public License
|
||||
+# along with this program; if not, write to the Free Software
|
||||
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
+# 02110-1301, USA.
|
||||
+
|
||||
+if test "$VERBOSE" = yes; then
|
||||
+ set -x
|
||||
+ ls --version
|
||||
+fi
|
||||
+
|
||||
+. $srcdir/../envvar-check
|
||||
+. $srcdir/../lang-default
|
||||
+
|
||||
+pwd=`pwd`
|
||||
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
|
||||
+trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
|
||||
+trap '(exit $?); exit $?' 1 2 13 15
|
||||
+
|
||||
+framework_failure=0
|
||||
+mkdir -p $tmp || framework_failure=1
|
||||
+cd $tmp || framework_failure=1
|
||||
+mkdir subdir || framework_failure=1
|
||||
+touch subdir/b || framework_failure=1
|
||||
+touch subdir/a || framework_failure=1
|
||||
+
|
||||
+if test $framework_failure = 1; then
|
||||
+ echo "$0: failure in testing framework" 1>&2
|
||||
+ (exit 1); exit 1
|
||||
+fi
|
||||
+
|
||||
+fail=0
|
||||
+
|
||||
+# Coreutils 6.8 and 6.9 would output this in the wrong order.
|
||||
+ls -x subdir > out || fail=1
|
||||
+ls -rx subdir >> out || fail=1
|
||||
+cat <<\EOF > exp || fail=1
|
||||
+a b
|
||||
+b a
|
||||
+EOF
|
||||
+
|
||||
+cmp out exp || fail=1
|
||||
+test $fail = 1 && diff out exp 2> /dev/null
|
||||
+
|
||||
+(exit $fail); exit $fail
|
||||
--- coreutils-6.9/NEWS.ls-x 2007-03-22 21:19:45.000000000 +0000
|
||||
+++ coreutils-6.9/NEWS 2007-06-13 14:28:42.000000000 +0100
|
||||
@@ -13,6 +13,11 @@
|
||||
Using pr -m -s (i.e. merging files, with TAB as the output separator)
|
||||
no longer inserts extraneous spaces between output columns.
|
||||
|
||||
+** Bug fixes
|
||||
+
|
||||
+ ls -x DIR would sometimes output the wrong string in place of the
|
||||
+ first entry. [introduced in coreutils-6.8]
|
||||
+
|
||||
|
||||
* Noteworthy changes in release 6.8 (2007-02-24) [not-unstable]
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
This patch was imported from the Fedora Core 8 coreutils-6.9-9 package.
|
||||
|
||||
The package is stated as being Licensed as GPLv2+.
|
||||
|
||||
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
||||
|
||||
--- coreutils-5.2.1/src/who.c.overflow 2005-05-25 09:59:06.000000000 +0100
|
||||
+++ coreutils-5.2.1/src/who.c 2005-05-25 10:00:31.000000000 +0100
|
||||
@@ -75,7 +75,7 @@
|
||||
# define NEW_TIME 0
|
||||
#endif
|
||||
|
||||
-#define IDLESTR_LEN 6
|
||||
+#define IDLESTR_LEN 10
|
||||
|
||||
#if HAVE_STRUCT_XTMP_UT_PID
|
||||
# define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \
|
|
@ -16,6 +16,11 @@ inherit autotools gettext
|
|||
SRC_URI = "http://ftp.gnu.org/gnu/coreutils/${BP}.tar.bz2 \
|
||||
file://gnulib_m4.patch \
|
||||
file://futimens.patch \
|
||||
file://coreutils-ls-x.patch \
|
||||
file://coreutils-6.9-cp-i-u.patch \
|
||||
file://coreutils-i18n.patch \
|
||||
file://coreutils-overflow.patch \
|
||||
file://coreutils-fix-install.patch \
|
||||
file://man-touch.patch"
|
||||
|
||||
# [ gets a special treatment and is not included in this
|
||||
|
|
Loading…
Reference in New Issue