Compare commits

...

139 Commits

Author SHA1 Message Date
Jim Meyering
c0d85f7e45 . 2000-09-09 08:58:58 +00:00
Jim Meyering
fdd7f15c6e *** empty log message *** 2000-09-09 08:58:42 +00:00
Jim Meyering
88fec8763a . 2000-09-09 08:56:38 +00:00
Jim Meyering
80fe6fbd20 *** empty log message *** 2000-09-09 08:55:48 +00:00
Jim Meyering
ca10098c93 *** empty log message *** 2000-09-09 08:53:37 +00:00
Jim Meyering
e336878a5b *** empty log message *** 2000-09-09 08:42:34 +00:00
Jim Meyering
6f98f91fad *** empty log message *** 2000-09-09 08:27:52 +00:00
Jim Meyering
a2e3399aa2 *** empty log message *** 2000-09-09 08:25:33 +00:00
Jim Meyering
f3643f7edd (TESTS_ENVIRONMENT): Propagate $MAKE into environment, for special-bits. 2000-09-09 08:24:41 +00:00
Jim Meyering
108783401d *** empty log message *** 2000-09-09 08:22:54 +00:00
Jim Meyering
88cd90df1e *** empty log message *** 2000-09-09 08:22:19 +00:00
Jim Meyering
f6c0c0ee16 *** empty log message *** 2000-09-09 08:18:10 +00:00
Jim Meyering
bb4904c751 (TESTS): Add special-bits. 2000-09-09 08:17:33 +00:00
Jim Meyering
6fdcba1097 *** empty log message *** 2000-09-09 07:32:43 +00:00
Jim Meyering
7ce4ee180b (copy_internal): Call chmod also if we've made the
preceding chown call and we're supposed to preserve some special
permission bit(s) that would have been reset by chown.
Reported by Greg Louis.
2000-09-09 07:32:36 +00:00
Jim Meyering
84d9e6f35b (SAME_OWNER, SAME_GROUP, SAME_OWNER_AND_GROUP): Define.
(copy_internal): Avoid calling chown if we know it's not necessary.
2000-09-09 07:29:38 +00:00
Jim Meyering
5e333bb8b8 *** empty log message *** 2000-09-09 07:20:54 +00:00
Jim Meyering
7d5c9847aa Don't use atoi.
Include sys/param.h and limits.h.
Include xstrtol.h.
(CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Define.
(UID_T_MAX, GID_T_MAX, MAXUID, MAXGID): Define.
(parse_user_spec): Use xstrtoul, not atoi when converting numeric
UID, GID.  Check range.
2000-09-09 07:20:46 +00:00
Jim Meyering
116698bb24 *** empty log message *** 2000-09-08 09:03:05 +00:00
Jim Meyering
93fe4a3b72 (S_IRWXUGO): Define here, instead. 2000-09-08 09:01:32 +00:00
Jim Meyering
3a66ad8dcd (S_IRWXUGO): Remove definition. 2000-09-08 09:01:02 +00:00
Jim Meyering
b12b63eced *** empty log message *** 2000-09-07 13:23:52 +00:00
Jim Meyering
5f44c5626b . 2000-09-07 13:22:26 +00:00
Jim Meyering
829258e77c Update from master repository. 2000-09-07 13:22:14 +00:00
Jim Meyering
d9a1527093 *** empty log message *** 2000-09-07 07:08:50 +00:00
Jim Meyering
bd5a2dc9e1 (cut invocation): Note that when using -f, lines with no delimiters are
also printed.
2000-09-07 07:08:39 +00:00
Jim Meyering
95ed06eb09 (usage): Note that when using -f, lines with no delimiters are also printed. 2000-09-07 07:08:17 +00:00
Jim Meyering
19ee58e090 Remove obsolete comment block. 2000-09-07 07:01:11 +00:00
Jim Meyering
b61f6618aa *** empty log message *** 2000-09-06 20:04:17 +00:00
Jim Meyering
7ed190837a (_getopt_internal): Update from glibc. 2000-09-06 20:04:06 +00:00
Jim Meyering
812dc8da17 *** empty log message *** 2000-09-05 12:15:38 +00:00
Jim Meyering
b150de0a99 Redirect stdout to stderr before trying to
remove the temp directory.  Otherwise, the `rm -rf' would get an
error because the output file wouldn't be closed and the directory
wouldn't be `empty'.
2000-09-05 12:15:30 +00:00
Jim Meyering
2757680bbf . 2000-09-05 12:04:29 +00:00
Jim Meyering
9fecbb3105 Remove the `cp -bdl symlink foo' case.
since it's no longer portable (hard link to a symlink).
2000-09-05 12:02:40 +00:00
Jim Meyering
b0126126d2 Remove the `cp -dl sl1 sl2' case,
since it's no longer portable (hard link to a symlink).
2000-09-05 11:53:03 +00:00
Jim Meyering
3260d507f5 *** empty log message *** 2000-09-05 10:41:18 +00:00
Jim Meyering
537879ee7d . 2000-09-05 10:22:35 +00:00
Jim Meyering
0c483136cf . 2000-09-04 20:51:43 +00:00
Jim Meyering
106eedf2a8 Remove declaration of lstat, now that it's in copy.h. 2000-09-04 20:51:29 +00:00
Jim Meyering
cec4418796 Move declaractions of lstat, stat, and rpl_lstat
as well as the definition of lstat from cp.c to this file.
2000-09-04 20:51:12 +00:00
Jim Meyering
25e0824d28 Move declaractions of lstat, stat, and rpl_lstat
as well as the definition of lstat from here to copy.h.
2000-09-04 20:50:45 +00:00
Jim Meyering
739a268735 *** empty log message *** 2000-09-04 17:01:23 +00:00
Jim Meyering
7c5d2581a0 . 2000-09-04 16:58:38 +00:00
Jim Meyering
9f99fca934 mv's --force (-f) option is no longer needed for
this test, now that all it does is cancel --interactive (-i).
2000-09-04 16:58:25 +00:00
Jim Meyering
d7dfef329f *** empty log message *** 2000-09-04 16:56:17 +00:00
Jim Meyering
daaa56f985 Add new tests using cp's --rem option.
Reflect the fact that cp's -f option no longer causes cp to remove the
destination file before trying to open it.
Reflect the fact that `cp -bdl' now makes a backup when copying a
symlink onto the file it points to (FIXME: look into this, and why
cp -bl does *not* do so).
2000-09-04 16:56:09 +00:00
Jim Meyering
143be7ea2d *** empty log message *** 2000-09-04 15:22:08 +00:00
Jim Meyering
4cb0cadf96 (do_link): Tweak diagnostics. 2000-09-04 15:22:00 +00:00
Jim Meyering
b5545e03db (same_file_ok): Hoist a test. 2000-09-04 14:49:30 +00:00
Jim Meyering
4dfe280c99 *** empty log message *** 2000-09-04 14:46:18 +00:00
Jim Meyering
616d9920c0 factor out backup/same test, put it after if-else. 2000-09-04 14:45:42 +00:00
Jim Meyering
65a185d754 (same_file_ok): factor some more. improve -- now passes all tests.
checkpoint
2000-09-04 14:42:32 +00:00
Jim Meyering
5dcb9b11aa *** empty log message *** 2000-09-04 08:16:16 +00:00
Jim Meyering
fbc1b0b06f *** empty log message *** 2000-09-04 08:03:56 +00:00
Jim Meyering
1f64389cd5 *** empty log message *** 2000-09-04 07:27:49 +00:00
Jim Meyering
e2017655a1 *** empty log message *** 2000-09-04 07:25:10 +00:00
Jim Meyering
09af7ed5f7 *** empty log message *** 2000-09-04 07:09:08 +00:00
Jim Meyering
2c663e070c *** empty log message *** 2000-09-03 18:50:55 +00:00
Jim Meyering
799114aa8c (cp_option_init): Initialize new members. 2000-09-03 18:50:49 +00:00
Jim Meyering
8ed20d830e . 2000-09-03 18:50:14 +00:00
Jim Meyering
a513c6c10e . 2000-09-03 18:49:37 +00:00
Jim Meyering
35640da77d tweak comment 2000-09-03 15:25:11 +00:00
Jim Meyering
b8fbc41536 Remove obsolete comment block.
(cp_option_init): Initialize new members.
(usage): Reflect the fact that --force (-f) relates only to whether
mv prompts.
(main): Remove uses of old `force' option member.
2000-09-03 14:36:50 +00:00
Jim Meyering
475fb2e732 (enum): Add UNLINK_DEST_BEFORE_OPENING.
[long_options]: Add an entry for --remove-destination.
(usage): Describe --remove-destination.
(do_copy): Use unlink_dest_after_failed_open member, not `force.'
(cp_option_init): Initialize new members.
(main): Handle UNLINK_DEST_BEFORE_OPENING (aka --remove-destination).
2000-09-03 14:09:23 +00:00
Jim Meyering
b1bf91b67d correct description of unlink_dest_after_failed_open 2000-09-03 13:56:15 +00:00
Jim Meyering
e2a422b8ef comment 2000-09-03 13:18:22 +00:00
Jim Meyering
81ab1beb52 Use strcoll (not strcmp) when comparing file names. 2000-09-03 13:06:41 +00:00
Jim Meyering
c199939348 (struct cp_options) [force]: Remove member.
[unlink_dest_before_opening]: Add member.
[unlink_dest_after_failed_open]: Add member.
2000-09-03 13:04:44 +00:00
Jim Meyering
76685fb1e9 (same_file_ok): New function, extracted from copy_internal,
and partially rewritten.
(copy_internal): Unlink destination file when unlink_dest_before_opening
option is set, and when the source is neither a regular file nor a directory.
2000-09-03 13:01:49 +00:00
Jim Meyering
3e8dff57b2 *** empty log message *** 2000-09-02 09:44:47 +00:00
Jim Meyering
1207fe6788 *** empty log message *** 2000-09-02 09:32:01 +00:00
Jim Meyering
24946d8604 *** empty log message *** 2000-09-02 09:30:03 +00:00
Jim Meyering
aa8f9f7e67 *** empty log message *** 2000-09-02 09:28:31 +00:00
Jim Meyering
9136c97143 *** empty log message *** 2000-09-02 09:08:31 +00:00
Jim Meyering
976d5c8a3f add basic test 2000-09-02 07:55:32 +00:00
Jim Meyering
3b023926b1 *** empty log message *** 2000-08-30 07:58:05 +00:00
Jim Meyering
048aa98ba8 Merge in changes from GNU libc. 2000-08-30 07:58:01 +00:00
Jim Meyering
3c5e612fce declare __fpending only if necessary 2000-08-28 14:55:18 +00:00
Jim Meyering
92452ed0a0 check for __fpending declaration 2000-08-28 14:53:10 +00:00
Jim Meyering
edc1ebe9e7 include stdio_ext.h 2000-08-28 14:50:37 +00:00
Jim Meyering
96719d7999 *** empty log message *** 2000-08-27 09:50:08 +00:00
Jim Meyering
739185ba74 . 2000-08-27 09:30:11 +00:00
Jim Meyering
6bf3479c9f (copy_reg): New parameters: X and NEW_DST.
Remove the SPARSE_MODE parameter.  Update caller.
Perform POSIX-mandated (for cp) open-with-O_WRONLY|O_TRUNC when
the regular destination file exists;  upon failure, unlink
that existing file, then open again, but with O_WRONLY|O_CREAT.
(copy_internal): `force' in not related to interactive; remove
the conjunct.
Remove the entire `else if (x->force)' block;  justifying
removal of the non-directory part is easy:  POSIX requires we try
to open an existing regular file, so we can't unlink it beforehand.
The part that changes the mode on a directory to allow overwriting
isn't necessary.
2000-08-27 09:30:00 +00:00
Jim Meyering
2c8881fa4e (copy_internal): Set `new_dst' when the move_mode rename fails,
since we then unlink the destination file.
2000-08-27 08:46:21 +00:00
Jim Meyering
a246888987 (copy_reg): Rename two goto labels. 2000-08-27 08:33:35 +00:00
Jim Meyering
5f4e35a42a . 2000-08-26 22:24:50 +00:00
Jim Meyering
004fa32b78 (usage): --force is independent of --interactive. 2000-08-26 22:24:31 +00:00
Jim Meyering
b679f078af . 2000-08-26 15:40:01 +00:00
Jim Meyering
64c38128cb . 2000-08-26 15:39:39 +00:00
Jim Meyering
47ffae51d2 *** empty log message *** 2000-08-26 12:05:55 +00:00
Jim Meyering
dc93e67305 Include "__fpending.h".
(close_stdout_status): Return right away if there's nothing to flush.
2000-08-26 12:05:50 +00:00
Jim Meyering
04b3f8c73f *** empty log message *** 2000-08-26 12:04:46 +00:00
Jim Meyering
15da58e940 *** empty log message *** 2000-08-26 12:04:13 +00:00
Jim Meyering
2c45ec8870 (noinst_HEADERS): Add __fpending.h. 2000-08-26 12:04:01 +00:00
Jim Meyering
b0a76138e8 *** empty log message *** 2000-08-26 11:59:55 +00:00
Jim Meyering
f48d309e1f *** empty log message *** 2000-08-26 11:58:08 +00:00
Jim Meyering
9f29c127ad Use jm_FUNC_FPENDING. 2000-08-26 11:56:54 +00:00
Jim Meyering
4edc4fdd20 *** empty log message *** 2000-08-26 11:56:20 +00:00
Jim Meyering
bf25ff5686 *** empty log message *** 2000-08-26 11:55:12 +00:00
Jim Meyering
5dee541de5 *** empty log message *** 2000-08-26 11:46:21 +00:00
Jim Meyering
9ca4b0ce4c *** empty log message *** 2000-08-26 11:44:00 +00:00
Jim Meyering
86d77d28f6 *** empty log message *** 2000-08-26 11:26:11 +00:00
Jim Meyering
5fec9dcd63 *** empty log message *** 2000-08-26 11:25:48 +00:00
Jim Meyering
5cd332146d *** empty log message *** 2000-08-25 07:43:45 +00:00
Jim Meyering
f35a629b10 *** empty log message *** 2000-08-25 07:39:22 +00:00
Jim Meyering
2115d8b251 *** empty log message *** 2000-08-24 11:39:14 +00:00
Jim Meyering
44256afd61 Put back the kluge. It's necessary after all.
(buggy_lseek_support): New function.
(skip): Use it.
Frank Adler reported that although _llseek returns 0, lseek
erroneously returns an offset suggesting the operation succeeded
even though it fails.
2000-08-24 11:39:08 +00:00
Jim Meyering
078fb9958e *** empty log message *** 2000-08-24 11:36:28 +00:00
Jim Meyering
10d2bd9fe1 . 2000-08-24 08:40:47 +00:00
Jim Meyering
d5f68c636f . 2000-08-24 08:40:08 +00:00
Jim Meyering
fc5b8b497f *** empty log message *** 2000-08-24 08:37:06 +00:00
Jim Meyering
399ca3007b *** empty log message *** 2000-08-24 08:36:47 +00:00
Jim Meyering
69450c7b8e (skip): Assume lseek failed if it returned zero, since a zero return is
impossible and some buggy drivers return zero.

Use SEEK_CUR rather than SEEK_SET; this fixes a bug when the
file descriptor is not currently rewound.
2000-08-24 08:34:33 +00:00
Jim Meyering
2abb1fd55d *** empty log message *** 2000-08-23 16:26:55 +00:00
Jim Meyering
5679351226 Include <config.h> unconditionally, to be consistent
with all the other programs in this directory.
2000-08-23 16:26:39 +00:00
Jim Meyering
52d06428c4 *** empty log message *** 2000-08-23 07:54:41 +00:00
Jim Meyering
9fa18193a8 *** empty log message *** 2000-08-23 07:54:23 +00:00
Jim Meyering
c5a36496a9 longer input 2000-08-23 07:54:06 +00:00
Jim Meyering
89f0eb153f redir dd's stderr 2000-08-23 07:49:05 +00:00
Jim Meyering
0816398823 change PROG from ls to dd 2000-08-23 07:48:11 +00:00
Jim Meyering
2ca0198ba4 (TESTS): Add not-rewound. 2000-08-23 07:47:52 +00:00
Jim Meyering
441d42d262 *** empty log message *** 2000-08-23 07:45:59 +00:00
Jim Meyering
47635579b0 use better trap 2000-08-23 07:38:21 +00:00
Jim Meyering
ed034dc2fb *** empty log message *** 2000-08-23 07:35:22 +00:00
Jim Meyering
d704481d1f back out last change 2000-08-23 07:33:28 +00:00
Jim Meyering
9445f3be05 *** empty log message *** 2000-08-22 11:12:06 +00:00
Jim Meyering
ba9af72e94 Don't even try to use lseek on character devices.
(buggy_lseek_support): New function.
(skip): Use it.
Reported by Martin Gallant via Michael Stone.
2000-08-22 11:12:01 +00:00
Jim Meyering
f2f8c736c9 *** empty log message *** 2000-08-22 11:05:47 +00:00
Jim Meyering
3ee1d2075c Clean up traps. Create files in a subdir. 2000-08-21 09:45:52 +00:00
Jim Meyering
4ff47b028e remove `dir' in trap, too 2000-08-21 09:41:56 +00:00
Jim Meyering
6d622fcb6b use better trap 2000-08-21 09:39:59 +00:00
Jim Meyering
dfdd08e943 *** empty log message *** 2000-08-21 05:29:32 +00:00
Jim Meyering
bcb31e6df5 *** empty log message *** 2000-08-21 05:15:55 +00:00
Jim Meyering
e37426d44c *** empty log message *** 2000-08-20 22:48:42 +00:00
Jim Meyering
5344a40bc2 remove blank line 2000-08-20 22:46:16 +00:00
Jim Meyering
f79086fbd3 *** empty log message *** 2000-08-20 22:46:05 +00:00
Jim Meyering
3944f9acc9 *** empty log message *** 2000-08-20 22:35:52 +00:00
Jim Meyering
5f69a51188 . 2000-08-20 21:16:36 +00:00
Jim Meyering
fc27421c82 New file. From J. David Anglin. 2000-08-20 21:12:36 +00:00
48 changed files with 1237 additions and 330 deletions

View File

@@ -145,11 +145,13 @@ writable-files:
WGET = wget
ftp-gnu = ftp://ftp.gnu.org/gnu
automake_repo=:pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
.PHONY: wget-update
wget-update:
$(WGET) $(ftp-gnu)/texinfo/texinfo.tex -O $(srcdir)/doc/texinfo.tex
$(WGET) $(ftp-gnu)/config/config.guess -O $(srcdir)/config.guess
$(WGET) $(ftp-gnu)/config/config.sub -O $(srcdir)/config.sub
cvs -d $(automake_repo) co -p automake/depcomp > depcomp
alpha: writable-files po-check
$(MAKE) cvs-dist

3
THANKS
View File

@@ -84,6 +84,7 @@ Erik Corry erik@kroete2.freinet.de
Felix Lee flee@teleport.com
Fletcher Mattox fletcher@cs.utexas.edu
Florin Iucha fiucha@hsys.mic.ro
Frank Adler fadler@allesklar.de
Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU
François Pinard pinard@iro.umontreal.ca
Fred Fish fnf@ninemoons.com
@@ -96,6 +97,7 @@ Geoff Odhner geoff@franklin.com
Gerhard Poul gpoul@gnu.org
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
GOTO Masanori gotom@debian.or.jp
Greg Louis glouis@dynamicro.on.ca
Greg McGary gkm@gnu.org
Greg Troxel gdt@bbn.com
Greg Wooledge gawooledge@sherwin.com
@@ -174,6 +176,7 @@ Mark Kettenis kettenis@phys.uva.nl
Mark W. Eichin eichin@cygnus.com
Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
Martin martin@dresden.nacamar.de
Martin Gallant martyg@goodbit.net
Martin Hippe martin.hippe@schlund.de
Martin Mitchell martin@debian.org
Martin P.J. Zinser zinser@decus.de

View File

@@ -3,9 +3,9 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
\def\texinfoversion{2000-05-28.15}
\def\texinfoversion{2000-09-06.09}
%
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
% Free Software Foundation, Inc.
%
% This texinfo.tex file is free software; you can redistribute it and/or
@@ -3155,7 +3155,6 @@ width0pt\relax} \fi
%
% Double the \vsize as well. (We don't need a separate register here,
% since nobody clobbers \vsize.)
\advance\vsize by -\ht\partialpage
\vsize = 2\vsize
}
@@ -3169,6 +3168,7 @@ width0pt\relax} \fi
% previous page.
\dimen@ = \vsize
\divide\dimen@ by 2
\advance\dimen@ by -\ht\partialpage
%
% box0 will be the left-hand column, box2 the right.
\setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
@@ -3176,15 +3176,18 @@ width0pt\relax} \fi
\unvbox255
\penalty\outputpenalty
}
%
% Re-output the contents of the output page -- any previous material,
% followed by the two boxes we just split, in box0 and box2.
\def\pagesofar{%
% Re-output the contents of the output page -- any previous material,
% followed by the two boxes we just split, in box0 and box2.
\unvbox\partialpage
%
\hsize = \doublecolumnhsize
\wd0=\hsize \wd2=\hsize
\hbox to\pagewidth{\box0\hfil\box2}%
}
%
% All done with double columns.
\def\enddoublecolumns{%
\output = {%
% Split the last of the double-column material. Leave it on the
@@ -3209,8 +3212,9 @@ width0pt\relax} \fi
% \endgroup where \vsize got restored).
\pagegoal = \vsize
}
%
% Called at the end of the double column material.
\def\balancecolumns{%
% Called at the end of the double column material.
\setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
\dimen@ = \ht0
\advance\dimen@ by \topskip

View File

@@ -3165,6 +3165,8 @@ take up 1 character.
@opindex --fields
Print only the fields listed in @var{field-list}. Fields are
separated by a TAB character by default.
Also print any line that contains no delimiter character, unless
the @samp{--only-delimited} (@samp{-s}) option is specified
@item -d @var{input_delim_byte}
@itemx --delimiter=@var{input_delim_byte}

View File

@@ -1,3 +1,30 @@
2000-09-09 Jim Meyering <meyering@lucent.com>
Don't use atoi.
* userspec.c: Include sys/param.h and limits.h.
Include xstrtol.h.
(CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Define.
(UID_T_MAX, GID_T_MAX, MAXUID, MAXGID): Define.
(parse_user_spec): Use xstrtoul, not atoi when converting numeric
UID, GID. Check range.
2000-09-06 Jim Meyering <meyering@lucent.com>
* getopt.c (_getopt_internal): Update from glibc.
2000-08-30 Jim Meyering <meyering@lucent.com>
* strftime.c: Merge in changes from GNU libc.
2000-08-26 Jim Meyering <meyering@lucent.com>
* closeout.c: Include "__fpending.h".
(close_stdout_status): Return right away if there's nothing to flush.
* Makefile.am (noinst_HEADERS): Add __fpending.h.
* __fpending.c: New file.
* __fpending.h: New file.
2000-08-07 Paul Eggert <eggert@twinsun.com>
Standardize on "memory exhausted" instead of "Memory exhausted"

View File

@@ -24,7 +24,8 @@ libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
noinst_HEADERS = \
argmatch.h backupfile.h bumpalloc.h closeout.h diacrit.h dirname.h error.h \
exclude.h filemode.h fnmatch.h fsusage.h getdate.h getline.h getopt.h \
exclude.h filemode.h fnmatch.h __fpending.h fsusage.h \
getdate.h getline.h getopt.h \
getstr.h getpagesize.h group-member.h hard-locale.h hash.h human.h lchown.h \
linebuffer.h long-options.h mbswidth.h md5.h memcasecmp.h memcoll.h \
makepath.h mbswidth.h modechange.h mountlist.h nanosleep.h obstack.h \

View File

@@ -140,7 +140,8 @@ libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
noinst_HEADERS = \
argmatch.h backupfile.h bumpalloc.h closeout.h diacrit.h dirname.h error.h \
exclude.h filemode.h fnmatch.h fsusage.h getdate.h getline.h getopt.h \
exclude.h filemode.h fnmatch.h __fpending.h fsusage.h \
getdate.h getline.h getopt.h \
getstr.h getpagesize.h group-member.h hard-locale.h hash.h human.h lchown.h \
linebuffer.h long-options.h mbswidth.h md5.h memcasecmp.h memcoll.h \
makepath.h mbswidth.h modechange.h mountlist.h nanosleep.h obstack.h \
@@ -193,48 +194,48 @@ DIST_SOURCES = $(libfetish_a_SOURCES)
HEADERS = $(noinst_HEADERS)
depcomp = $(SHELL) $(top_srcdir)/depcomp
DEP_FILES = @AMDEP@ $(DEPDIR)/addext$U.Po $(DEPDIR)/alloca.Po \
$(DEPDIR)/argmatch$U.Po $(DEPDIR)/atexit.Po $(DEPDIR)/backupfile$U.Po \
$(DEPDIR)/basename$U.Po $(DEPDIR)/canon-host$U.Po $(DEPDIR)/chown.Po \
$(DEPDIR)/closeout$U.Po $(DEPDIR)/diacrit$U.Po $(DEPDIR)/dirname$U.Po \
$(DEPDIR)/dup2.Po $(DEPDIR)/error.Po $(DEPDIR)/euidaccess.Po \
$(DEPDIR)/exclude$U.Po $(DEPDIR)/fileblocks.Po $(DEPDIR)/filemode$U.Po \
$(DEPDIR)/fnmatch.Po $(DEPDIR)/fsusage.Po $(DEPDIR)/ftruncate.Po \
$(DEPDIR)/full-write$U.Po $(DEPDIR)/getdate$U.Po $(DEPDIR)/getgroups.Po \
$(DEPDIR)/gethostname.Po $(DEPDIR)/getline.Po $(DEPDIR)/getloadavg.Po \
$(DEPDIR)/getopt$U.Po $(DEPDIR)/getopt1$U.Po $(DEPDIR)/getpass.Po \
$(DEPDIR)/getstr$U.Po $(DEPDIR)/getugroups$U.Po \
$(DEPDIR)/getusershell.Po $(DEPDIR)/group-member.Po \
$(DEPDIR)/hard-locale$U.Po $(DEPDIR)/hash$U.Po $(DEPDIR)/human$U.Po \
$(DEPDIR)/idcache$U.Po $(DEPDIR)/isdir$U.Po $(DEPDIR)/lchown.Po \
$(DEPDIR)/linebuffer$U.Po $(DEPDIR)/localcharset$U.Po \
$(DEPDIR)/long-options$U.Po $(DEPDIR)/lstat.Po $(DEPDIR)/makepath$U.Po \
$(DEPDIR)/malloc.Po $(DEPDIR)/mbswidth$U.Po $(DEPDIR)/md5$U.Po \
$(DEPDIR)/memcasecmp$U.Po $(DEPDIR)/memchr.Po $(DEPDIR)/memcmp.Po \
$(DEPDIR)/memcoll$U.Po $(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po \
$(DEPDIR)/memset.Po $(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po \
$(DEPDIR)/mountlist.Po $(DEPDIR)/nanosleep.Po $(DEPDIR)/obstack.Po \
$(DEPDIR)/path-concat$U.Po $(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po \
$(DEPDIR)/quote$U.Po $(DEPDIR)/quotearg$U.Po $(DEPDIR)/readtokens$U.Po \
$(DEPDIR)/readutmp.Po $(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po \
$(DEPDIR)/rmdir.Po $(DEPDIR)/rpmatch.Po $(DEPDIR)/safe-read$U.Po \
$(DEPDIR)/same$U.Po $(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po \
$(DEPDIR)/stat.Po $(DEPDIR)/stime.Po $(DEPDIR)/stpcpy.Po \
$(DEPDIR)/strcasecmp.Po $(DEPDIR)/strcspn.Po $(DEPDIR)/strdup.Po \
$(DEPDIR)/strftime.Po $(DEPDIR)/stripslash$U.Po \
$(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po $(DEPDIR)/strnlen.Po \
$(DEPDIR)/strpbrk.Po $(DEPDIR)/strstr.Po $(DEPDIR)/strtod.Po \
$(DEPDIR)/strtol.Po $(DEPDIR)/strtoul.Po $(DEPDIR)/strtoull.Po \
$(DEPDIR)/strtoumax.Po $(DEPDIR)/strverscmp.Po $(DEPDIR)/unicodeio$U.Po \
$(DEPDIR)/userspec$U.Po $(DEPDIR)/utime.Po $(DEPDIR)/version-etc$U.Po \
$(DEPDIR)/xgetcwd$U.Po $(DEPDIR)/xgethostname$U.Po \
$(DEPDIR)/xmalloc$U.Po $(DEPDIR)/xstrdup$U.Po $(DEPDIR)/xstrtod$U.Po \
$(DEPDIR)/xstrtol$U.Po $(DEPDIR)/xstrtoul$U.Po \
$(DEPDIR)/xstrtoumax$U.Po $(DEPDIR)/yesno$U.Po
DEP_FILES = @AMDEP@ $(DEPDIR)/__fpending.Po $(DEPDIR)/addext$U.Po \
$(DEPDIR)/alloca.Po $(DEPDIR)/argmatch$U.Po $(DEPDIR)/atexit.Po \
$(DEPDIR)/backupfile$U.Po $(DEPDIR)/basename$U.Po \
$(DEPDIR)/canon-host$U.Po $(DEPDIR)/chown.Po $(DEPDIR)/closeout$U.Po \
$(DEPDIR)/diacrit$U.Po $(DEPDIR)/dirname$U.Po $(DEPDIR)/dup2.Po \
$(DEPDIR)/error.Po $(DEPDIR)/euidaccess.Po $(DEPDIR)/exclude$U.Po \
$(DEPDIR)/fileblocks.Po $(DEPDIR)/filemode$U.Po $(DEPDIR)/fnmatch.Po \
$(DEPDIR)/fsusage.Po $(DEPDIR)/ftruncate.Po $(DEPDIR)/full-write$U.Po \
$(DEPDIR)/getdate$U.Po $(DEPDIR)/getgroups.Po $(DEPDIR)/gethostname.Po \
$(DEPDIR)/getline.Po $(DEPDIR)/getloadavg.Po $(DEPDIR)/getopt$U.Po \
$(DEPDIR)/getopt1$U.Po $(DEPDIR)/getpass.Po $(DEPDIR)/getstr$U.Po \
$(DEPDIR)/getugroups$U.Po $(DEPDIR)/getusershell.Po \
$(DEPDIR)/group-member.Po $(DEPDIR)/hard-locale$U.Po \
$(DEPDIR)/hash$U.Po $(DEPDIR)/human$U.Po $(DEPDIR)/idcache$U.Po \
$(DEPDIR)/isdir$U.Po $(DEPDIR)/lchown.Po $(DEPDIR)/linebuffer$U.Po \
$(DEPDIR)/localcharset$U.Po $(DEPDIR)/long-options$U.Po \
$(DEPDIR)/lstat.Po $(DEPDIR)/makepath$U.Po $(DEPDIR)/malloc.Po \
$(DEPDIR)/mbswidth$U.Po $(DEPDIR)/md5$U.Po $(DEPDIR)/memcasecmp$U.Po \
$(DEPDIR)/memchr.Po $(DEPDIR)/memcmp.Po $(DEPDIR)/memcoll$U.Po \
$(DEPDIR)/memcpy.Po $(DEPDIR)/memmove.Po $(DEPDIR)/memset.Po \
$(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po $(DEPDIR)/mountlist.Po \
$(DEPDIR)/nanosleep.Po $(DEPDIR)/obstack.Po $(DEPDIR)/path-concat$U.Po \
$(DEPDIR)/posixtm$U.Po $(DEPDIR)/putenv.Po $(DEPDIR)/quote$U.Po \
$(DEPDIR)/quotearg$U.Po $(DEPDIR)/readtokens$U.Po $(DEPDIR)/readutmp.Po \
$(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po $(DEPDIR)/rmdir.Po \
$(DEPDIR)/rpmatch.Po $(DEPDIR)/safe-read$U.Po $(DEPDIR)/same$U.Po \
$(DEPDIR)/save-cwd$U.Po $(DEPDIR)/savedir$U.Po $(DEPDIR)/stat.Po \
$(DEPDIR)/stime.Po $(DEPDIR)/stpcpy.Po $(DEPDIR)/strcasecmp.Po \
$(DEPDIR)/strcspn.Po $(DEPDIR)/strdup.Po $(DEPDIR)/strftime.Po \
$(DEPDIR)/stripslash$U.Po $(DEPDIR)/strncasecmp.Po $(DEPDIR)/strndup.Po \
$(DEPDIR)/strnlen.Po $(DEPDIR)/strpbrk.Po $(DEPDIR)/strstr.Po \
$(DEPDIR)/strtod.Po $(DEPDIR)/strtol.Po $(DEPDIR)/strtoul.Po \
$(DEPDIR)/strtoull.Po $(DEPDIR)/strtoumax.Po $(DEPDIR)/strverscmp.Po \
$(DEPDIR)/unicodeio$U.Po $(DEPDIR)/userspec$U.Po $(DEPDIR)/utime.Po \
$(DEPDIR)/version-etc$U.Po $(DEPDIR)/xgetcwd$U.Po \
$(DEPDIR)/xgethostname$U.Po $(DEPDIR)/xmalloc$U.Po \
$(DEPDIR)/xstrdup$U.Po $(DEPDIR)/xstrtod$U.Po $(DEPDIR)/xstrtol$U.Po \
$(DEPDIR)/xstrtoul$U.Po $(DEPDIR)/xstrtoumax$U.Po $(DEPDIR)/yesno$U.Po
DIST_COMMON = README $(noinst_HEADERS) ChangeLog Makefile.am \
Makefile.in TODO alloca.c atexit.c chown.c dup2.c error.c error.h \
euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c getdate.c \
getgroups.c gethostname.c getline.c getloadavg.c getpass.c \
Makefile.in TODO __fpending.c alloca.c atexit.c chown.c dup2.c error.c \
error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
getdate.c getgroups.c gethostname.c getline.c getloadavg.c getpass.c \
getusershell.c group-member.c lchown.c malloc.c memchr.c memcmp.c \
memcpy.c memmove.c memset.c mktime.c mountlist.c nanosleep.c obstack.c \
obstack.h putenv.c readutmp.c realloc.c regex.c rmdir.c rpmatch.c \
@@ -298,6 +299,8 @@ libfetish.a: $(libfetish_a_OBJECTS) $(libfetish_a_DEPENDENCIES)
-rm -f libfetish.a
$(libfetish_a_AR) libfetish.a $(libfetish_a_OBJECTS) $(libfetish_a_LIBADD)
$(RANLIB) libfetish.a
__fpending_.c: __fpending.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/__fpending.c; then echo $(srcdir)/__fpending.c; else echo __fpending.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > __fpending_.c
addext_.c: addext.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/addext.c; then echo $(srcdir)/addext.c; else echo addext.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > addext_.c
alloca_.c: alloca.c $(ANSI2KNR)
@@ -510,25 +513,26 @@ xstrtoumax_.c: xstrtoumax.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoumax.c; then echo $(srcdir)/xstrtoumax.c; else echo xstrtoumax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoumax_.c
yesno_.c: yesno.c $(ANSI2KNR)
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/yesno.c; then echo $(srcdir)/yesno.c; else echo yesno.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > yesno_.c
addext_.o alloca_.o argmatch_.o atexit_.o backupfile_.o basename_.o \
canon-host_.o chown_.o closeout_.o diacrit_.o dirname_.o dup2_.o \
error_.o euidaccess_.o exclude_.o fileblocks_.o filemode_.o fnmatch_.o \
fsusage_.o ftruncate_.o full-write_.o getdate_.o getgroups_.o \
gethostname_.o getline_.o getloadavg_.o getopt_.o getopt1_.o getpass_.o \
getstr_.o getugroups_.o getusershell_.o group-member_.o hard-locale_.o \
hash_.o human_.o idcache_.o isdir_.o lchown_.o linebuffer_.o \
localcharset_.o long-options_.o lstat_.o makepath_.o malloc_.o \
mbswidth_.o md5_.o memcasecmp_.o memchr_.o memcmp_.o memcoll_.o \
memcpy_.o memmove_.o memset_.o mktime_.o modechange_.o mountlist_.o \
nanosleep_.o obstack_.o path-concat_.o posixtm_.o putenv_.o quote_.o \
quotearg_.o readtokens_.o readutmp_.o realloc_.o regex_.o rmdir_.o \
rpmatch_.o safe-read_.o same_.o save-cwd_.o savedir_.o stat_.o stime_.o \
stpcpy_.o strcasecmp_.o strcspn_.o strdup_.o strftime_.o stripslash_.o \
strncasecmp_.o strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o \
strtol_.o strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o \
unicodeio_.o userspec_.o utime_.o version-etc_.o xgetcwd_.o \
xgethostname_.o xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o \
xstrtoumax_.o yesno_.o : $(ANSI2KNR)
__fpending_.o addext_.o alloca_.o argmatch_.o atexit_.o backupfile_.o \
basename_.o canon-host_.o chown_.o closeout_.o diacrit_.o dirname_.o \
dup2_.o error_.o euidaccess_.o exclude_.o fileblocks_.o filemode_.o \
fnmatch_.o fsusage_.o ftruncate_.o full-write_.o getdate_.o \
getgroups_.o gethostname_.o getline_.o getloadavg_.o getopt_.o \
getopt1_.o getpass_.o getstr_.o getugroups_.o getusershell_.o \
group-member_.o hard-locale_.o hash_.o human_.o idcache_.o isdir_.o \
lchown_.o linebuffer_.o localcharset_.o long-options_.o lstat_.o \
makepath_.o malloc_.o mbswidth_.o md5_.o memcasecmp_.o memchr_.o \
memcmp_.o memcoll_.o memcpy_.o memmove_.o memset_.o mktime_.o \
modechange_.o mountlist_.o nanosleep_.o obstack_.o path-concat_.o \
posixtm_.o putenv_.o quote_.o quotearg_.o readtokens_.o readutmp_.o \
realloc_.o regex_.o rmdir_.o rpmatch_.o safe-read_.o same_.o \
save-cwd_.o savedir_.o stat_.o stime_.o stpcpy_.o strcasecmp_.o \
strcspn_.o strdup_.o strftime_.o stripslash_.o strncasecmp_.o \
strndup_.o strnlen_.o strpbrk_.o strstr_.o strtod_.o strtol_.o \
strtoul_.o strtoull_.o strtoumax_.o strverscmp_.o unicodeio_.o \
userspec_.o utime_.o version-etc_.o xgetcwd_.o xgethostname_.o \
xmalloc_.o xstrdup_.o xstrtod_.o xstrtol_.o xstrtoul_.o xstrtoumax_.o \
yesno_.o : $(ANSI2KNR)
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
@@ -569,6 +573,7 @@ distclean-tags:
maintainer-clean-tags:
@AMDEP@include $(DEPDIR)/__fpending.Po
@AMDEP@include $(DEPDIR)/addext$U.Po
@AMDEP@include $(DEPDIR)/alloca.Po
@AMDEP@include $(DEPDIR)/argmatch$U.Po

30
lib/__fpending.c Normal file
View File

@@ -0,0 +1,30 @@
/* __fpending.c -- return the number of pending output bytes on a stream
Copyright (C) 2000 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Jim Meyering. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "__fpending.h"
size_t
__fpending (FILE *fp)
{
return PENDING_OUTPUT_N_BYTES;
}

18
lib/__fpending.h Normal file
View File

@@ -0,0 +1,18 @@
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#if HAVE_STDIO_EXT_H
# include <stdio_ext.h>
#endif
#include <sys/types.h>
#ifndef HAVE_DECL___FPENDING
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL___FPENDING
size_t __fpending (FILE *);
#endif

View File

@@ -43,6 +43,7 @@ extern int errno;
#include "closeout.h"
#include "error.h"
#include "quotearg.h"
#include "__fpending.h"
static int default_exit_status = EXIT_FAILURE;
static const char *file_name;
@@ -86,11 +87,15 @@ close_stdout_set_file_name (const char *file)
It's important to detect such failures and exit nonzero because many
tools (most notably `make' and other build-management systems) depend
on being able to detect failure in other tools via their exit status. */
void
close_stdout_status (int status)
{
int e = ferror (stdout) ? 0 : -1;
if (__fpending (stdout) == 0)
return;
if (fclose (stdout) != 0)
e = errno;

View File

@@ -27,13 +27,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#else
# if !defined __STDC__ || !__STDC__
#endif
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
# ifndef const
# define const
# endif
# ifndef const
# define const
# endif
#endif
@@ -671,7 +671,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
pfound = p;
indfound = option_index;
}
else
else if (pfound->has_arg != p->has_arg
|| pfound->flag != p->flag
|| pfound->val != p->val)
/* Second or later nonexact match found. */
ambig = 1;
}

View File

@@ -98,8 +98,8 @@ extern char *tzname[];
# define L_(Str) L##Str
# define NLW(Sym) _NL_W##Sym
# define MEMCPY(d, s, n) wmemcpy (d, s, n)
# define STRLEN(s) wcslen (s)
# define MEMCPY(d, s, n) __wmemcpy (d, s, n)
# define STRLEN(s) __wcslen (s)
#else
# define CHAR_T char
@@ -752,6 +752,11 @@ my_strftime (s, maxsize, format, tp ut_argument)
case L_('b'):
case L_('h'): /* POSIX.2 extension. */
if (change_case)
{
to_uppcase = 1;
to_lowcase = 0;
}
if (modifier != 0)
goto bad_format;
#if defined _NL_CURRENT || !HAVE_STRFTIME
@@ -848,7 +853,7 @@ my_strftime (s, maxsize, format, tp ut_argument)
if (era)
{
# ifdef COMPILE_WIDE
size_t len = wcslen (era->era_wname);
size_t len = __wcslen (era->era_wname);
cpy (len, era->era_wname);
# else
size_t len = strlen (era->era_name);

View File

@@ -40,6 +40,14 @@ char *alloca ();
#include <pwd.h>
#include <grp.h>
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#if HAVE_LIMITS_H
# include <limits.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#else
@@ -58,6 +66,7 @@ char *alloca ();
#endif
#include "xalloc.h"
#include "xstrtol.h"
#if ENABLE_NLS
# include <libintl.h>
@@ -81,6 +90,34 @@ struct group *getgrgid ();
# define endpwent() ((void) 0)
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
#ifndef GID_T_MAX
# define GID_T_MAX TYPE_MAXIMUM (gid_t)
#endif
/* MAXUID may come from limits.h or sys/params.h. */
#ifndef MAXUID
# define MAXUID UID_T_MAX
#endif
#ifndef MAXGID
# define MAXGID GID_T_MAX
#endif
/* Perform the equivalent of the statement `dest = strdup (src);',
but obtaining storage via alloca instead of from the heap. */
@@ -220,8 +257,12 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
error_msg = E_bad_spec;
else
{
/* FIXME: don't use atoi! */
*uid = atoi (u);
unsigned long int tmp_long;
if (xstrtoul (u, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|| tmp_long > MAXUID)
return _(E_invalid_user);
printf ("MAXUID: %u\n", (uid_t) MAXUID);
*uid = tmp_long;
}
}
}
@@ -263,8 +304,11 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
error_msg = E_invalid_group;
else
{
/* FIXME: don't use atoi! */
*gid = atoi (g);
unsigned long int tmp_long;
if (xstrtoul (u, NULL, 0, &tmp_long, NULL) != LONGINT_OK
|| tmp_long > MAXGID)
return _(E_invalid_group);
*gid = tmp_long;
}
}
else

View File

@@ -1,3 +1,8 @@
2000-08-26 Jim Meyering <meyering@lucent.com>
* jm-macros.m4: Use jm_FUNC_FPENDING.
* fpending.m4: New file.
2000-08-20 Jim Meyering <meyering@lucent.com>
* check-decl.m4: Include utmp.h `#if HAVE_UTMP_H', rather than

View File

@@ -13,6 +13,7 @@ d-ino.m4 \
d-type.m4 \
error.m4 \
fnmatch.m4 \
fpending.m4 \
fstypename.m4 \
fsusage.m4 \
ftruncate.m4 \

View File

@@ -127,6 +127,7 @@ d-ino.m4 \
d-type.m4 \
error.m4 \
fnmatch.m4 \
fpending.m4 \
fstypename.m4 \
fsusage.m4 \
ftruncate.m4 \

75
m4/fpending.m4 Normal file
View File

@@ -0,0 +1,75 @@
#serial 1
dnl From Jim Meyering
dnl Using code from emacs, based on suggestions from Paul Eggert
dnl and Ulrich Drepper.
dnl Find out how to determine the number of pending output bytes on a stream.
dnl glibc (2.1.93 and newer) and Solaris provide __fpending. On other systems,
dnl we have to grub around in the FILE struct.
AC_DEFUN(jm_FUNC_FPENDING,
[
AC_CHECK_HEADERS(stdio_ext.h)
AC_REPLACE_FUNCS([__fpending])
fp_headers='
# if HAVE_STDIO_EXT_H
# include <stdio_ext.h>
# endif
'
AC_CHECK_DECLS([__fpending], , , $fp_headers)
if test $ac_cv_func___fpending = no; then
AC_CACHE_CHECK(
[how to determine the number of pending output bytes on a stream],
ac_cv_sys_pending_output_n_bytes,
[
fp_save_DEFS=$DEFS
for ac_expr in \
\
'# glibc2' \
'fp->_IO_write_ptr - fp->_IO_write_base' \
\
'# traditional Unix' \
'fp->_ptr - fp->_base' \
\
'# BSD' \
'fp->_p - fp->_bf._base' \
\
'# SCO, Unixware' \
'fp->__ptr - fp->__base' \
\
'# old glibc?' \
'fp->__bufp - fp->__buffer' \
\
'# old glibc iostream?' \
'fp->_pptr - fp->_pbase' \
\
'# VMS' \
'(*fp)->_ptr - (*fp)->_base' \
\
'# e.g., DGUX R4.11; the info is not available' \
1 \
; do
# Skip each embedded comment.
case "$ac_expr" in '#'*) continue;; esac
DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
AC_TRY_COMPILE(
[#include <stdio.h>
],
[FILE *fp = stdin; (void) ($ac_expr);],
fp_done=yes
)
DEFS=$fp_save_DEFS
test "$fp_done" = yes && break
done
ac_cv_sys_pending_output_n_bytes=$ac_expr
]
)
AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
$ac_cv_sys_pending_output_n_bytes,
[the number of pending output bytes on stream `fp'])
fi
])

View File

@@ -92,6 +92,7 @@ AC_DEFUN(jm_MACROS,
AC_REQUIRE([AM_FUNC_ERROR_AT_LINE])
AC_REQUIRE([jm_FUNC_GNU_STRFTIME])
AC_REQUIRE([jm_FUNC_MKTIME])
AC_REQUIRE([jm_FUNC_FPENDING])
AC_REQUIRE([jm_FUNC_GETGROUPS])
test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS"

View File

@@ -1,3 +1,170 @@
2000-09-09 Jim Meyering <meyering@lucent.com>
* Version 4.0z.
* tests/cp/special-bits: New file.
* tests/cp/Makefile.am (TESTS): Add special-bits.
(TESTS_ENVIRONMENT): Propagate $MAKE into environment, for special-bits.
* src/copy.c (SAME_OWNER, SAME_GROUP, SAME_OWNER_AND_GROUP): Define.
(copy_internal): Avoid calling chown if we know it's not necessary.
* src/copy.c (copy_internal): Call chmod also if we've made the
preceding chown call and we're supposed to preserve some special
permission bit(s) that would have been reset by chown.
Reported by Greg Louis.
2000-09-08 Jim Meyering <meyering@lucent.com>
* src/mkdir.c (S_IRWXUGO): Remove definition.
* src/sys2.h (S_IRWXUGO): Define here, instead.
2000-09-07 Jim Meyering <meyering@lucent.com>
* doc/texinfo.tex: Update from master repository.
* config.sub: Likewise.
* config.guess: Likewise.
2000-09-05 Jim Meyering <meyering@lucent.com>
* tests/mv/part-symlink: Redirect stdout to stderr before trying to
remove the temp directory. Otherwise, the `rm -rf' would get an
error because the output file wouldn't be closed and the directory
wouldn't be `empty'.
* tests/cp/same-file: Likewise.
* tests/cp/same-file: Remove the `cp -dl sl1 sl2' case,
since it's no longer portable (hard link to a symlink).
Likewise for the `cp -bdl symlink foo' case.
* config.guess: Update from master repository.
2000-09-04 Jim Meyering <meyering@lucent.com>
* src/cp.c: Move declaractions of lstat, stat, and rpl_lstat
as well as the definition of lstat from here...
* src/copy.h: ...to here.
* src/copy.c: Remove declaration of lstat, now that it's in copy.h.
* tests/mv/force: mv's --force (-f) option is no longer needed for
this test, now that all it does is cancel --interactive (-i).
* tests/cp/same-file: Add new tests using cp's --rem option.
Reflect the fact that cp's -f option no longer causes cp to remove the
destination file before trying to open it.
Reflect the fact that `cp -bdl' now makes a backup when copying a
symlink onto the file it points to (FIXME: look into this, and why
cp -bl does *not* do so).
* src/ln.c (do_link): Tweak diagnostics.
2000-09-03 Jim Meyering <meyering@lucent.com>
* src/install.c (cp_option_init): Initialize new members.
* src/cp.c (enum): Add UNLINK_DEST_BEFORE_OPENING.
[long_options]: Add an entry for --remove-destination.
(usage): Describe --remove-destination.
(do_copy): Use unlink_dest_after_failed_open member, not `force.'
(cp_option_init): Initialize new members.
(main): Handle UNLINK_DEST_BEFORE_OPENING (aka --remove-destination).
* src/mv.c: Remove obsolete comment block.
(cp_option_init): Initialize new members.
(usage): Reflect the fact that --force (-f) relates only to whether
mv prompts.
(main): Remove uses of old `force' option member.
* src/install.c (cp_option_init): Reflect
`force' no longer means unlink-dest-before-opening
* src/copy.h (struct cp_options) [force]: Remove member.
[unlink_dest_before_opening]: Add member. `cp -f' and `mv -f' used to
do this. Now, you must use `cp --remove-destination' to get this
behavior. Now, `cp -f' and `mv -f' work as required by POSIX.
[unlink_dest_after_failed_open]: Add member.
* src/copy.c (same_file_ok): New function, extracted from copy_internal,
and rewritten.
(copy_internal): Unlink destination file when unlink_dest_before_opening
option is set, and when the source is neither a regular file nor a
directory.
* tests/mv/Makefile.am (TESTS): Add part-symlink.
* src/ls.c: Use strcoll (not strcmp) when comparing file names.
Suggestion from Ulrich Drepper.
2000-08-27 Jim Meyering <meyering@lucent.com>
* src/copy.c (copy_reg): New parameters: X and NEW_DST.
Remove the SPARSE_MODE parameter. Update caller.
Perform POSIX-mandated (for cp) open-with-O_WRONLY|O_TRUNC when copying
a regular source file and the destination file exists; upon failure,
unlink that existing file, then open again, but with O_WRONLY|O_CREAT.
(copy_internal): `force' in not related to interactive; remove
the conjunct.
Remove the entire `else if (x->force)' block; justifying
removal of the non-directory part is easy: POSIX requires we try
to open an existing regular file, so we can't unlink it beforehand.
The part that changes the mode on a directory to allow overwriting
isn't necessary.
* src/copy.c (copy_reg): Rename two goto labels.
(copy_internal): Set `new_dst' when the move_mode rename fails,
since we then unlink the destination file.
* src/cp.c (usage): --force is independent of --interactive.
2000-08-24 Jim Meyering <meyering@lucent.com>
Put back the kluge. It's necessary after all.
* src/dd.c (buggy_lseek_support): New function.
(skip): Use it.
Frank Adler reported that although _llseek returns 0, lseek
erroneously returns an offset suggesting the operation succeeded
even though it fails.
* install-sh: Double quote as needed, to protect against arguments
containing spaces or shell metacharacters. Reported by Bruno Haible.
2000-08-23 Jim Meyering <meyering@lucent.com>
* tests/dd/not-rewound: New test, for the SEEK_CUR vs. SEEK_SET part
of the last change. Based on Paul's example.
* tests/dd/Makefile.am (TESTS): Add not-rewound.
2000-08-22 Paul Eggert <eggert@twinsun.com>
* src/dd.c (skip):
Assume lseek failed if it returned zero, since a zero return is
impossible and some buggy drivers return zero.
Use SEEK_CUR rather than SEEK_SET; this fixes a bug when the
file descriptor is not currently rewound.
2000-08-23 Jim Meyering <meyering@lucent.com>
* src/dd.c: Back out my last change. Paul's (above) is better.
2000-08-22 Jim Meyering <meyering@lucent.com>
Don't even try to use lseek on character devices.
* src/dd.c (buggy_lseek_support): New function.
(skip): Use it.
Reported by Martin Gallant via Michael Stone.
2000-08-21 Jim Meyering <meyering@lucent.com>
* tests/cp/same-file: Clean up traps. Create files in a subdir.
* install-sh (oIFS): Remove unmatched double quote, left over from
my 2000-08-12 change. From J. David Anglin.
* Makefile.maint (wget-update): Get the latest version of depcomp.
* depcomp: Update from automake.
2000-08-20 Jim Meyering <meyering@lucent.com>
* Version 4.0y.

View File

@@ -1,4 +1,17 @@
Changes in release 4.1:
Changes in release 4.01:
[4.0z]
* `cp -p' once again preserves `special' permission bits (this bug was
introduced in 4.0y)
* mv's --force (-f) option now controls solely whether mv prompts (per POSIX)
* `cp -f' now first attempts to open an existing destination file, and only
if that fails does it resort to unlinking the file and retrying the open.
Before, it would unlink the file before trying to open it.
* cp accepts a new option, --remove-destination, that provides the old behavior
* cp's -f option no longer cancels the effect of --interactive (-i) (per POSIX)
* when ls sorts directory entries, it now honors the current locale settings
* dd's `skip=BLOCKS' operator once again works on systems with a buggy lseek
function (Linux, at least on SCSI tape devices)
* fix a typo in install-sh
[4.0y]
* cp now accepts the POSIX-mandated -H and -L options.
* cp -p and mv now try to preserve uid even if you're not root, as per POSIX.2.

View File

@@ -1,3 +1,16 @@
2000-09-07 Jim Meyering <meyering@lucent.com>
* src/cut.c: Remove obsolete comment block.
(usage): Note that when using -f, lines with no delimiters are
also printed.
* doc/textutils.texi (cut invocation): Likewise.
2000-08-23 Jim Meyering <meyering@lucent.com>
* src/md5sum.c: Include <config.h> unconditionally, to be consistent
with all the other programs in this directory.
* src/tsort.c: Likewise.
2000-08-19 Jim Meyering <meyering@lucent.com>
* src/comm.c (writeline): Correct comments. From Bruno Haible.

View File

@@ -44,6 +44,10 @@
or if the target system doesn't support file ownership. */ \
&& ((errno != EPERM && errno != EINVAL) || x->myeuid == 0))
#define SAME_OWNER(A, B) ((A).st_uid == (B).st_uid)
#define SAME_GROUP(A, B) ((A).st_gid == (B).st_gid)
#define SAME_OWNER_AND_GROUP(A, B) (SAME_OWNER (A, B) && SAME_GROUP (A, B))
struct dir_list
{
struct dir_list *parent;
@@ -55,8 +59,6 @@ int full_write ();
int euidaccess ();
int yesno ();
int lstat ();
static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
int new_dst, dev_t device,
struct dir_list *ancestors,
@@ -167,12 +169,13 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
in the source file as holes in the destination file.
(Holes are read as zeroes by the `read' system call.)
Use DST_MODE as the 3rd argument in the call to open.
X provides many option settings.
Return 0 if successful, -1 if an error occurred.
FIXME: describe sparse_mode. */
*NEW_DST is as in copy_internal. */
static int
copy_reg (const char *src_path, const char *dst_path,
enum Sparse_type sparse_mode, mode_t dst_mode)
const struct cp_options *x, mode_t dst_mode, int *new_dst)
{
char *buf;
int buf_size;
@@ -184,7 +187,7 @@ copy_reg (const char *src_path, const char *dst_path,
int return_val = 0;
off_t n_read_total = 0;
int last_write_made_hole = 0;
int make_holes = (sparse_mode == SPARSE_ALWAYS);
int make_holes = (x->sparse_mode == SPARSE_ALWAYS);
source_desc = open (src_path, O_RDONLY);
if (source_desc < 0)
@@ -202,12 +205,38 @@ copy_reg (const char *src_path, const char *dst_path,
return -1;
}
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, dst_mode);
/* These semantics are required for cp.
The if-block will be taken in move_mode. */
if (*new_dst)
{
dest_desc = open (dst_path, O_WRONLY | O_CREAT, dst_mode);
}
else
{
dest_desc = open (dst_path, O_WRONLY | O_TRUNC, dst_mode);
if (dest_desc < 0 && x->unlink_dest_after_failed_open)
{
if (unlink (dst_path))
{
error (0, errno, _("cannot remove %s"), quote (dst_path));
return_val = -1;
goto close_src_desc;
}
/* Tell caller that the destination file was unlinked. */
*new_dst = 1;
/* Try the open again, but this time with different flags. */
dest_desc = open (dst_path, O_WRONLY | O_CREAT, dst_mode);
}
}
if (dest_desc < 0)
{
error (0, errno, _("cannot create regular file %s"), quote (dst_path));
return_val = -1;
goto ret2;
goto close_src_desc;
}
/* Find out the optimal buffer size. */
@@ -216,13 +245,13 @@ copy_reg (const char *src_path, const char *dst_path,
{
error (0, errno, _("cannot fstat %s"), quote (dst_path));
return_val = -1;
goto ret;
goto close_src_and_dst_desc;
}
buf_size = ST_BLKSIZE (sb);
#if HAVE_STRUCT_STAT_ST_BLOCKS
if (sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
if (x->sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
{
/* Use a heuristic to determine whether SRC_PATH contains any
sparse blocks. */
@@ -231,7 +260,7 @@ copy_reg (const char *src_path, const char *dst_path,
{
error (0, errno, _("cannot fstat %s"), quote (src_path));
return_val = -1;
goto ret;
goto close_src_and_dst_desc;
}
/* If the file has fewer blocks than would normally
@@ -258,7 +287,7 @@ copy_reg (const char *src_path, const char *dst_path,
#endif
error (0, errno, _("reading %s"), quote (src_path));
return_val = -1;
goto ret;
goto close_src_and_dst_desc;
}
if (n_read == 0)
break;
@@ -292,7 +321,7 @@ copy_reg (const char *src_path, const char *dst_path,
{
error (0, errno, _("cannot lseek %s"), quote (dst_path));
return_val = -1;
goto ret;
goto close_src_and_dst_desc;
}
last_write_made_hole = 1;
}
@@ -306,7 +335,7 @@ copy_reg (const char *src_path, const char *dst_path,
{
error (0, errno, _("writing %s"), quote (dst_path));
return_val = -1;
goto ret;
goto close_src_and_dst_desc;
}
last_write_made_hole = 0;
}
@@ -333,13 +362,13 @@ copy_reg (const char *src_path, const char *dst_path,
}
}
ret:
close_src_and_dst_desc:
if (close (dest_desc) < 0)
{
error (0, errno, _("closing %s"), quote (dst_path));
return_val = -1;
}
ret2:
close_src_desc:
if (close (source_desc) < 0)
{
error (0, errno, _("closing %s"), quote (src_path));
@@ -349,6 +378,167 @@ ret2:
return return_val;
}
/* Return nonzero if it's ok that the source and destination
files are the `same' by some measure. The goal is to avoid
making the `copy' operation remove both copies of the file
in that case, while still allowing the user to e.g., move or
copy a regular file onto a symlink that points to it.
Try to minimize the cost of this function in the common case. */
static int
same_file_ok (const char *src_path, const struct stat *src_sb,
const char *dst_path, const struct stat *dst_sb,
const struct cp_options *x, int *return_now)
{
const struct stat *src_sb_link;
const struct stat *dst_sb_link;
const struct stat *src_sb_no_link;
const struct stat *dst_sb_no_link;
int same_link;
int same = (SAME_INODE (*src_sb, *dst_sb));
*return_now = 0;
/* FIXME: this should (at the very least) be moved into the following
if-block. More likely, it should be removed, because it inhibits
making backups. But removing it will result in a change in behavior
that will probably have to be documented -- and tests will have to
be updated. */
if (same && x->hard_link)
{
*return_now = 1;
return 1;
}
if (x->xstat == lstat)
{
same_link = same;
/* If both the source and destination files are symlinks (and we'll
know this here IFF preserving symlinks (aka xstat == lstat),
then it's ok. */
if (S_ISLNK (src_sb->st_mode) && S_ISLNK (dst_sb->st_mode))
return 1;
src_sb_link = src_sb;
dst_sb_link = dst_sb;
}
else
{
static struct stat tmp_dst_sb;
static struct stat tmp_src_sb;
if (!same)
return 1;
if (lstat (dst_path, &tmp_dst_sb)
|| lstat (src_path, &tmp_src_sb))
return 1;
src_sb_link = &tmp_src_sb;
dst_sb_link = &tmp_dst_sb;
same_link = SAME_INODE (*src_sb_link, *dst_sb_link);
/* If both are symlinks, then it's ok, but only if the destination
will be unlinked before being opened. This is like the test
above, but with the addition of the unlink_dest_before_opening
conjunct because otherwise, with two symlinks to the same target,
we'd end up truncating the source file. */
if (S_ISLNK (src_sb_link->st_mode) && S_ISLNK (dst_sb_link->st_mode)
&& x->unlink_dest_before_opening)
return 1;
}
/* The backup code ensures there's a copy, so it's ok to remove
any destination file. But there's one exception: when both
source and destination are the same directory entry. In that
case, moving the destination file aside (in making the backup)
would also rename the source file and result in an error. */
if (x->backup_type != none)
{
if (!same_link)
return 1;
return ! same_name (src_path, dst_path);
}
#if 0
/* FIXME: use or remove */
/* If we're making a backup, we'll detect the problem case in
copy_reg because SRC_PATH will no longer exist. Allowing
the test to be deferred lets cp do some useful things.
But when creating hardlinks and SRC_PATH is a symlink
but DST_PATH is not we must test anyway. */
if (x->hard_link
|| !S_ISLNK (src_sb_link->st_mode)
|| S_ISLNK (dst_sb_link->st_mode))
return 1;
if (x->dereference != DEREF_NEVER)
return 1;
#endif
/* They may refer to the same file if we're in move mode and the
target is a symlink. That is ok, since we remove any existing
destination file before opening it -- via `rename' if they're on
the same file system, via `unlink (DST_PATH)' otherwise.
It's also ok if they're distinct hard links to the same file. */
if ((x->move_mode || x->unlink_dest_before_opening)
&& (S_ISLNK (dst_sb_link->st_mode)
|| (same_link && !same_name (src_path, dst_path))))
return 1;
/* If neither is a symlink, then it's ok as long as they aren't
links to the same file. */
if (!S_ISLNK (src_sb_link->st_mode) && !S_ISLNK (dst_sb_link->st_mode))
{
if (!SAME_INODE (*src_sb_link, *dst_sb_link))
return 1;
/* If they are the same file, it's ok if we're making hard links. */
if (x->hard_link)
{
*return_now = 1;
return 1;
}
}
/* It's ok to remove a destination symlink. But that works only when we
unlink before opening the destination and when they're on the same
partition. */
if (x->unlink_dest_before_opening
&& S_ISLNK (dst_sb_link->st_mode))
return src_sb_link->st_dev == src_sb_link->st_dev;
if (x->xstat == lstat)
{
static struct stat tmp_dst_sb;
static struct stat tmp_src_sb;
if (stat (dst_path, &tmp_dst_sb)
|| stat (src_path, &tmp_src_sb)
|| ! SAME_INODE (tmp_dst_sb, tmp_dst_sb))
return 1;
/* FIXME: shouldn't this be testing whether we're making symlinks? */
if (x->hard_link)
{
*return_now = 1;
return 1;
}
src_sb_no_link = &tmp_src_sb;
dst_sb_no_link = &tmp_dst_sb;
}
else
{
src_sb_no_link = src_sb;
dst_sb_no_link = dst_sb;
}
return 0;
}
/* Copy the file SRC_PATH to the file DST_PATH. The files may be of
any type. NEW_DST should be nonzero if the file DST_PATH cannot
exist because its parent directory was just created; NEW_DST should
@@ -380,6 +570,7 @@ copy_internal (const char *src_path, const char *dst_path,
int rename_errno;
int delayed_fail;
int copied_as_regular = 0;
int ran_chown = 0;
if (move_mode && rename_succeeded)
*rename_succeeded = 0;
@@ -422,64 +613,17 @@ copy_internal (const char *src_path, const char *dst_path,
}
else
{
int same;
int return_now;
int ok = same_file_ok (src_path, &src_sb, dst_path, &dst_sb,
x, &return_now);
if (return_now)
return 0;
/* The destination file exists already. */
same = (SAME_INODE (src_sb, dst_sb));
#ifdef S_ISLNK
/* If we're preserving symlinks (--no-dereference) and either
file is a symlink, use stat (not xstat) to see if they refer
to the same file. */
if (!same
/* If we'll remove DST_PATH first, then this doesn't matter. */
&& ! x->force
/* Allow them to be the same (and don't set `same') if we're
in move mode and the target is a symlink. That is ok, since
we remove any existing destination file before opening it --
via `rename' if they're on the same file system,
via `unlink(DST_PATH)' otherwise. */
&& !(move_mode
&& S_ISLNK (dst_sb.st_mode))
/* If we're making a backup, we'll detect the problem case in
copy_reg because SRC_PATH will no longer exist. Allowing
the test to be deferred lets cp do some useful things.
But when creating hardlinks and SRC_PATH is a symlink
but DST_PATH is not we must test anyway. */
&& (x->backup_type == none
|| (x->hard_link
&& S_ISLNK (src_sb.st_mode)
&& !S_ISLNK (dst_sb.st_mode)))
&& x->dereference == DEREF_NEVER
&& (S_ISLNK (dst_sb.st_mode) ^ S_ISLNK (src_sb.st_mode)))
if (! ok)
{
struct stat dst2_sb;
struct stat src2_sb;
if (stat (dst_path, &dst2_sb) == 0
&& stat (src_path, &src2_sb) == 0
&& SAME_INODE (src2_sb, dst2_sb))
{
same = 1;
}
}
#endif
if (same)
{
if (x->hard_link)
return 0;
if (x->backup_type == none
&& (!x->force || same_name (src_path, dst_path)))
{
error (0, 0, _("%s and %s are the same file"),
quote_n (0, src_path), quote_n (1, dst_path));
return 1;
}
error (0, 0, _("%s and %s are the same file"),
quote_n (0, src_path), quote_n (1, dst_path));
return 1;
}
if (!S_ISDIR (src_type))
@@ -498,7 +642,7 @@ copy_internal (const char *src_path, const char *dst_path,
if (!S_ISDIR (src_type) && x->interactive)
{
if (euidaccess (dst_path, W_OK) != 0 && x->force)
if (euidaccess (dst_path, W_OK) != 0)
{
fprintf (stderr,
_("%s: overwrite %s, overriding mode %04lo? "),
@@ -579,34 +723,17 @@ copy_internal (const char *src_path, const char *dst_path,
}
new_dst = 1;
}
else if (x->force)
else if (x->unlink_dest_before_opening
|| (x->xstat == lstat
&& ! S_ISREG (src_sb.st_mode)
&& ! S_ISDIR (src_sb.st_mode)))
{
if (S_ISDIR (dst_sb.st_mode))
if (unlink (dst_path) && errno != ENOENT)
{
/* Temporarily change mode to allow overwriting. */
if (euidaccess (dst_path, W_OK | X_OK) != 0
&& chmod (dst_path, S_IRWXU))
{
error (0, errno,
_("cannot change permissions for %s"),
quote (dst_path));
return 1;
}
}
else
{
if (unlink (dst_path) && errno != ENOENT)
{
error (0, errno, _("cannot remove old link to %s"),
quote (dst_path));
if (x->failed_unlink_is_fatal)
return 1;
}
else
{
new_dst = 1;
}
error (0, errno, _("cannot remove %s"), quote (dst_path));
return 1;
}
new_dst = 1;
}
}
}
@@ -699,6 +826,8 @@ copy_internal (const char *src_path, const char *dst_path,
quote_n (0, src_path), quote_n (1, dst_path));
return 1;
}
new_dst = 1;
}
delayed_fail = 0;
@@ -825,8 +954,8 @@ copy_internal (const char *src_path, const char *dst_path,
/* POSIX says the permission bits of the source file must be
used as the 3rd argument in the open call, but that's not consistent
with historical practice. */
if (copy_reg (src_path, dst_path, x->sparse_mode,
get_dest_mode (x, src_mode)))
if (copy_reg (src_path, dst_path, x,
get_dest_mode (x, src_mode), &new_dst))
goto un_backup;
}
else
@@ -954,8 +1083,11 @@ copy_internal (const char *src_path, const char *dst_path,
}
}
if (x->preserve_owner_and_group)
/* Avoid calling chown if we know it's not necessary. */
if (x->preserve_owner_and_group
&& (new_dst || !SAME_OWNER_AND_GROUP (src_sb, dst_sb)))
{
ran_chown = 1;
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, _("preserving ownership for %s"), quote (dst_path));
@@ -964,9 +1096,11 @@ copy_internal (const char *src_path, const char *dst_path,
}
}
/* Permissions of newly-created regular files were set upon `open'
in copy_reg. */
if (new_dst && copied_as_regular)
/* Permissions of newly-created regular files were set upon `open' in
copy_reg. But don't return early if there were any special bits and
we had to run chown, because the chown must have reset those bits. */
if ((new_dst && copied_as_regular)
&& !(ran_chown && (src_mode & ~S_IRWXUGO)))
return delayed_fail;
if ((x->preserve_chmod_bits || new_dst)

View File

@@ -46,14 +46,23 @@ struct cp_options
/* If nonzero, dereference symbolic links (copy the files they point to). */
enum Dereference_symlink dereference;
/* If nonzero, remove existing destination nondirectories. */
int force;
/* If nonzero, remove each existing destination nondirectory before
trying to open it. */
int unlink_dest_before_opening;
/* If nonzero, first try to open each existing destination nondirectory,
then, if the open fails, unlink and try again.
This option must be set for `cp -f', in case the destination file
exists when the open is attempted. It is irrelevant to `mv' since
any destination is sure to be removed before the open. */
int unlink_dest_after_failed_open;
/* Setting this member is meaningful only if FORCE is also set.
If nonzero, copy returns nonzero upon failed unlink.
Otherwise, the failure still elicits a diagnostic, but it doesn't
change copy's return value. This is nonzero for cp and mv, and zero
for install. */
/* FIXME: this is now unused. */
int failed_unlink_is_fatal;
/* If nonzero, create hard links instead of copying files.
@@ -121,6 +130,18 @@ struct cp_options
int (*xstat) ();
};
int stat ();
int lstat ();
/* Arrange to make lstat calls go through the wrapper function
on systems with an lstat function that does not dereference symlinks
that are specified with a trailing slash. */
# if ! LSTAT_FOLLOWS_SLASHED_SYMLINK
int rpl_lstat PARAMS((const char *, struct stat *));
# undef lstat
# define lstat rpl_lstat
# endif
int
copy PARAMS ((const char *src_path, const char *dst_path,
int nonexistent_dst, const struct cp_options *options,

View File

@@ -73,21 +73,10 @@ enum
TARGET_DIRECTORY_OPTION = CHAR_MAX + 1,
SPARSE_OPTION,
STRIP_TRAILING_SLASHES_OPTION,
PARENTS_OPTION
PARENTS_OPTION,
UNLINK_DEST_BEFORE_OPENING
};
int stat ();
int lstat ();
/* Arrange to make lstat calls go through the wrapper function
on systems with an lstat function that does not dereference symlinks
that are specified with a trailing slash. */
#if ! LSTAT_FOLLOWS_SLASHED_SYMLINK
int rpl_lstat PARAMS((const char *, struct stat *));
# undef lstat
# define lstat rpl_lstat
#endif
void strip_trailing_slashes ();
/* Initial number of entries in each hash table entry's table of inodes. */
@@ -134,6 +123,7 @@ static struct option const long_opts[] =
{"path", no_argument, NULL, PARENTS_OPTION}, /* Deprecated. */
{"preserve", no_argument, NULL, 'p'},
{"recursive", no_argument, NULL, 'R'},
{"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
{"strip-trailing-slash", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"suffix", required_argument, NULL, 'S'},
{"symbolic-link", no_argument, NULL, 's'},
@@ -167,7 +157,8 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
--backup[=CONTROL] make a backup of each existing destination file\n\
-b like --backup but does not accept an argument\n\
-d, --no-dereference preserve links\n\
-f, --force remove existing destinations, never prompt\n\
-f, --force if a preexisting destination file cannot be\n\
opened, then unlink it and try again\n\
-i, --interactive prompt before overwrite\n\
-H follow symbolic links that are explicitly\n\
specified in the command line, but do not\n\
@@ -182,6 +173,8 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
-r copy recursively, non-directories as files\n\
WARNING: use -R instead when you might copy\n\
special files like FIFOs or /dev/zero\n\
--remove-destination unlink each preexisting destination file before\n\
attempting to open it (contrast with --force)\n\
--sparse=WHEN control creation of sparse files\n\
-R, --recursive copy directories recursively\n\
--strip-trailing-slashes remove any trailing slashes from each SOURCE\n\
@@ -603,7 +596,7 @@ do_copy (int n_files, char **file, const char *target_directory,
`cp --force --backup foo foo' to `cp --force foo fooSUFFIX'
where SUFFIX is determined by any version control options used. */
if (x->force
if (x->unlink_dest_after_failed_open
&& x->backup_type != none
&& STREQ (source, dest)
&& !new_dst && S_ISREG (sb.st_mode))
@@ -658,7 +651,8 @@ cp_option_init (struct cp_options *x)
{
x->copy_as_regular = 1;
x->dereference = DEREF_UNDEFINED;
x->force = 0;
x->unlink_dest_before_opening = 0;
x->unlink_dest_after_failed_open = 0;
x->failed_unlink_is_fatal = 1;
x->hard_link = 0;
x->interactive = 0;
@@ -752,7 +746,7 @@ main (int argc, char **argv)
break;
case 'f':
x.force = 1;
x.unlink_dest_after_failed_open = 1;
break;
case 'H':
@@ -795,6 +789,10 @@ main (int argc, char **argv)
x.copy_as_regular = 0;
break;
case UNLINK_DEST_BEFORE_OPENING:
x.unlink_dest_before_opening = 1;
break;
case STRIP_TRAILING_SLASHES_OPTION:
remove_trailing_slashes = 1;
break;

View File

@@ -20,42 +20,7 @@
/* POSIX changes, bug fixes, long-named options, and cleanup
by David MacKenzie <djm@gnu.ai.mit.edu>.
Rewrite cut_fields and cut_bytes -- Jim Meyering.
Options:
--bytes=byte-list
-b byte-list Print only the bytes in positions listed
in BYTE-LIST.
Tabs and backspaces are treated like any
other character; they take up 1 byte.
--characters=character-list
-c character-list Print only characters in positions listed
in CHARACTER-LIST.
The same as -b for now, but
internationalization will change that.
Tabs and backspaces are treated like any
other character; they take up 1 character.
--fields=field-list
-f field-list Print only the fields listed in FIELD-LIST.
Fields are separated by a TAB by default.
--delimiter=delim
-d delim For -f, fields are separated by the first
character in DELIM instead of TAB.
-n Do not split multibyte chars (no-op for now).
--only-delimited
-s For -f, do not print lines that do not contain
the field separator character.
The BYTE-LIST, CHARACTER-LIST, and FIELD-LIST are one or more numbers
or ranges separated by commas. The first byte, character, and field
are numbered 1.
A FILE of `-' means standard input. */
Rewrite cut_fields and cut_bytes -- Jim Meyering. */
#include <config.h>
@@ -209,7 +174,9 @@ Print selected parts of lines from each FILE to standard output.\n\
-b, --bytes=LIST output only these bytes\n\
-c, --characters=LIST output only these characters\n\
-d, --delimiter=DELIM use DELIM instead of TAB for field delimiter\n\
-f, --fields=LIST output only these fields\n\
-f, --fields=LIST output only these fields; also print any line\n\
that contains no delimiter character, unless\n\
the -s option is specified\n\
-n (ignored)\n\
-s, --only-delimited do not print lines not containing delimiters\n\
--output-delimiter=STRING use STRING as the output delimiter\n\

View File

@@ -718,9 +718,41 @@ swab_buffer (unsigned char *buf, size_t *nread)
return ++bufstart;
}
/* Return nonzero iff the file referenced by FDESC is of a type for
which lseek's return value is known to be invalid on some systems.
Otherwise, return zero.
For example, return nonzero if FDESC references a character device
(on any system) because the lseek on many Linux systems incorrectly
returns an offset implying it succeeds for tape devices, even though
the function fails to perform the requested operation. In that case,
lseek should return nonzero and set errno. */
static int
buggy_lseek_support (int fdesc)
{
/* We have to resort to this because on some systems, lseek doesn't work
on some special files but doesn't return an error, either.
In particular, the Linux tape drivers are a problem.
For example, when I did the following using dd-4.0y or earlier on a
Linux-2.2.17 system with a Exabyte SCSI tape drive:
dev=/dev/nst0
reset='mt -f $dev rewind; mt -f $dev fsf 1'
eval $reset; dd if=$dev bs=32k of=out1
eval $reset; dd if=$dev bs=32k of=out2 skip=1
the resulting files, out1 and out2, would compare equal. */
struct stat stats;
return (fstat (fdesc, &stats) == 0
&& (S_ISCHR (stats.st_mode)));
}
/* Throw away RECORDS blocks of BLOCKSIZE bytes on file descriptor FDESC,
which is open with read permission for FILE. Store up to BLOCKSIZE
bytes of the data at a time in BUF, if necessary. */
bytes of the data at a time in BUF, if necessary. RECORDS must be
nonzero. */
static void
skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
@@ -729,10 +761,13 @@ skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
off_t o;
/* Try lseek and if an error indicates it was an inappropriate
operation, fall back on using read. */
operation, fall back on using read. Some broken versions of
lseek may return zero, so count that as an error too as a valid
zero return is not possible here. */
o = records * blocksize;
if (o / blocksize != records
|| lseek (fdesc, o, SEEK_SET) == -1)
|| buggy_lseek_support (fdesc)
|| lseek (fdesc, o, SEEK_CUR) <= 0)
{
while (records-- > 0)
{

View File

@@ -189,7 +189,8 @@ cp_option_init (struct cp_options *x)
{
x->copy_as_regular = 1;
x->dereference = DEREF_ALWAYS;
x->force = 1;
x->unlink_dest_before_opening = 0;
x->unlink_dest_after_failed_open = 1;
/* If unlink fails, try to proceed anyway. */
x->failed_unlink_is_fatal = 0;

View File

@@ -316,8 +316,8 @@ do_link (const char *source, const char *dest)
error (0, errno,
(symbolic_link
? _("create symbolic link %s to %s")
: _("create hard link %s to %s")),
? _("creating symbolic link %s to %s")
: _("creating hard link %s to %s")),
quote_n (0, dest), quote_n (1, source));
if (dest_backup)

View File

@@ -2109,7 +2109,7 @@ compare_ctime (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = CTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2118,7 +2118,7 @@ rev_cmp_ctime (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = CTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2127,7 +2127,7 @@ compare_mtime (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = MTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2136,7 +2136,7 @@ rev_cmp_mtime (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = MTIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2145,7 +2145,7 @@ compare_atime (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = ATIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2154,7 +2154,7 @@ rev_cmp_atime (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = ATIME_CMP (file2->stat, file1->stat);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2163,7 +2163,7 @@ compare_size (const struct fileinfo *file1, const struct fileinfo *file2)
{
int diff = longdiff (file2->stat.st_size, file1->stat.st_size);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2172,7 +2172,7 @@ rev_cmp_size (const struct fileinfo *file2, const struct fileinfo *file1)
{
int diff = longdiff (file2->stat.st_size, file1->stat.st_size);
if (diff == 0)
diff = strcmp (file1->name, file2->name);
diff = strcoll (file1->name, file2->name);
return diff;
}
@@ -2191,13 +2191,13 @@ rev_cmp_version (const struct fileinfo *file2, const struct fileinfo *file1)
static int
compare_name (const struct fileinfo *file1, const struct fileinfo *file2)
{
return strcmp (file1->name, file2->name);
return strcoll (file1->name, file2->name);
}
static int
rev_cmp_name (const struct fileinfo *file2, const struct fileinfo *file1)
{
return strcmp (file1->name, file2->name);
return strcoll (file1->name, file2->name);
}
/* Compare file extensions. Files with no extension are `smallest'.
@@ -2212,14 +2212,14 @@ compare_extension (const struct fileinfo *file1, const struct fileinfo *file2)
base1 = strrchr (file1->name, '.');
base2 = strrchr (file2->name, '.');
if (base1 == 0 && base2 == 0)
return strcmp (file1->name, file2->name);
return strcoll (file1->name, file2->name);
if (base1 == 0)
return -1;
if (base2 == 0)
return 1;
cmp = strcmp (base1, base2);
cmp = strcoll (base1, base2);
if (cmp == 0)
return strcmp (file1->name, file2->name);
return strcoll (file1->name, file2->name);
return cmp;
}
@@ -2232,14 +2232,14 @@ rev_cmp_extension (const struct fileinfo *file2, const struct fileinfo *file1)
base1 = strrchr (file1->name, '.');
base2 = strrchr (file2->name, '.');
if (base1 == 0 && base2 == 0)
return strcmp (file1->name, file2->name);
return strcoll (file1->name, file2->name);
if (base1 == 0)
return -1;
if (base2 == 0)
return 1;
cmp = strcmp (base1, base2);
cmp = strcoll (base1, base2);
if (cmp == 0)
return strcmp (file1->name, file2->name);
return strcoll (file1->name, file2->name);
return cmp;
}

View File

@@ -18,9 +18,7 @@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <config.h>
#include <getopt.h>
#include <stdio.h>

View File

@@ -28,10 +28,6 @@
#include "modechange.h"
#include "quote.h"
#ifndef S_IRWXUGO
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
#endif
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "mkdir"

View File

@@ -15,27 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Options:
-f, --force Assume a 'y' answer to all questions it would
normally ask, and not ask the questions.
-i, --interactive Require confirmation from the user before
performing any move that would destroy an
existing file.
-u, --update Do not move a nondirectory that has an
existing destination with the same or newer
modification time.
-v, --verbose List the name of each file as it is moved, and
the name it is moved to.
-b, --backup
-S, --suffix
-V, --version-control
Backup file creation.
Written by Mike Parker, David MacKenzie, and Jim Meyering */
/* Written by Mike Parker, David MacKenzie, and Jim Meyering */
#ifdef _AIX
#pragma alloca
@@ -126,7 +106,8 @@ cp_option_init (struct cp_options *x)
{
x->copy_as_regular = 0; /* FIXME: maybe make this an option */
x->dereference = DEREF_NEVER;
x->force = 0;
x->unlink_dest_before_opening = 0;
x->unlink_dest_after_failed_open = 0;
x->failed_unlink_is_fatal = 1;
x->hard_link = 0;
x->interactive = 0;
@@ -357,7 +338,7 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\
\n\
--backup[=CONTROL] make a backup of each existing destination file\n\
-b like --backup but does not accept an argument\n\
-f, --force remove existing destinations, never prompt\n\
-f, --force never prompt before overwriting\n\
-i, --interactive prompt before overwrite\n\
--strip-trailing-slashes remove any trailing slashes from each SOURCE\n\
argument\n\
@@ -435,11 +416,9 @@ main (int argc, char **argv)
break;
case 'f':
x.interactive = 0;
x.force = 1;
break;
case 'i':
x.interactive = 1;
x.force = 0;
break;
case STRIP_TRAILING_SLASHES_OPTION:
remove_trailing_slashes = 1;

View File

@@ -118,6 +118,10 @@
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif
#ifndef S_IRWXUGO
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
#endif
/* All the mode bits that can be affected by chmod. */
#define CHMOD_MODE_BITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)

View File

@@ -21,9 +21,7 @@
sort) in Donald E. Knuth, The Art of Computer Programming, Volume
1/Fundamental Algorithms, page 262. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <config.h>
#include <stdio.h>
#include <assert.h>

View File

@@ -4,7 +4,8 @@ AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file cp-mv-backup symlink-slash slink-2-slink fail-perm dir-slash \
perm cp-HL
perm cp-HL special-bits
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
MAKE=$(MAKE) \
PATH=`pwd`/../../src:$$PATH

View File

@@ -120,10 +120,11 @@ AUTOMAKE_OPTIONS = 1.1 gnits
TESTS = \
backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
same-file cp-mv-backup symlink-slash slink-2-slink fail-perm dir-slash \
perm cp-HL
perm cp-HL special-bits
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
MAKE=$(MAKE) \
PATH=`pwd`/../../src:$$PATH
subdir = tests/cp

View File

@@ -12,7 +12,7 @@ fi
pwd=`pwd`
tmp=perm.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap 'exit $?' 1 2 13 15
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
@@ -39,7 +39,7 @@ for u in 31 37 2; do
for o_perm in r w x rw wx xr rwx; do
touch src || exit 1
chmod u=r,g=rx,o= src || exit 1
set X `ls -l src`
set _ `ls -l src`
shift
expected_perms=$1
rm -f dest
@@ -50,23 +50,23 @@ for u in 31 37 2; do
$cmd $force src dest || exit 1
test "$cmd" = mv && test -f src && exit 1
test "$cmd" = cp && { test -f src || exit 1; }
set X `ls -l dest`
set _ `ls -l dest`
shift
case "$cmd:$force:$existing_dest" in
cp::yes)
cp:*:yes)
_g_perm=`echo rwx|sed 's/[^'$g_perm']/-/g'`
_o_perm=`echo rwx|sed 's/[^'$o_perm']/-/g'`
expected_perms=-rw-$_g_perm$_o_perm
;;
cp::no|cp:-f:*)
cp:*:no)
test $u = 37 &&
expected_perms=`echo $expected_perms|sed 's/.....$/-----/'`
test $u = 31 &&
expected_perms=`echo $expected_perms|sed 's/..\(..\).$/--\1-/'`
;;
esac
test x$1 = x$expected_perms || exit 1
test _$1 = _$expected_perms || exit 1
# Perform only one iteration when there's no existing destination.
test $existing_dest = no && break 3
done

View File

@@ -13,9 +13,21 @@ LANG=C; export LANG
VERSION_CONTROL=numbered; export VERSION_CONTROL
pwd=`pwd`
tmp=same-f-$$
trap 'status=$?; cd $pwd; exec 1>&2; rm -rf $tmp && exit $status' 0
trap 'exit $?' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
actual=actual-$$
expected=expected-$$
trap "cd $pwd; rm -rf $actual $expected dir" 0 1 2 3 15
exec 1> $actual
@@ -23,18 +35,23 @@ exec 1> $actual
contents=XYZ
for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
for options in '' -d -f -df -b -bd -bf -bdf \
for options in '' -d -f -df --rem -b -bd -bf -bdf \
-l -dl -fl -dfl -bl -bdl -bfl -bdfl; do
case $args$options in
# These tests are not portable.
'sl1 sl2'-bd*l)
continue;;
# They all involve making a hard link to a symbolic link.
'symlink foo'-dfl)
continue;;
'symlink foo'-bdl)
continue;;
'symlink foo'-bdfl)
continue;;
'sl1 sl2'-dfl)
continue;;
'sl1 sl2'-bd*l)
continue;;
'sl1 sl2'-dl)
continue;;
esac
rm -rf dir
mkdir dir
@@ -82,8 +99,9 @@ done
cat <<\EOF > $expected
1 [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
1 -d [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
0 -f (foo symlink)
0 -df (foo symlink)
1 -f [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
1 -df [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
0 --rem (foo symlink)
0 -b (foo symlink symlink.~1~ -> foo)
0 -bd (foo symlink symlink.~1~ -> foo)
0 -bf (foo symlink symlink.~1~ -> foo)
@@ -91,7 +109,7 @@ cat <<\EOF > $expected
0 -l (foo symlink -> foo)
0 -dl (foo symlink -> foo)
0 -fl (foo symlink -> foo)
0 -dfl (foo symlink)
0 -dfl (foo symlink -> foo)
0 -bl (foo symlink -> foo)
0 -bdl (foo symlink symlink.~1~ -> foo)
0 -bfl (foo symlink -> foo)
@@ -99,8 +117,9 @@ cat <<\EOF > $expected
1 [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 -d [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 -f [cp: `symlink' and `foo' are the same file] (symlink -> foo) symlink-loop symlink-loop
0 -df (foo -> foo symlink -> foo) symlink-loop symlink-loop
1 -f [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 -df [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 --rem [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
1 -b [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
0 -bd (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop
1 -bf [cp: `symlink' and `foo' are the same file] (foo symlink -> foo)
@@ -109,13 +128,13 @@ cat <<\EOF > $expected
0 -dl (foo symlink -> foo)
0 -fl (foo symlink -> foo)
0 -bl (foo symlink -> foo)
0 -bdl (foo symlink -> foo)
0 -bfl (foo symlink -> foo)
1 [cp: `foo' and `foo' are the same file] (foo)
1 -d [cp: `foo' and `foo' are the same file] (foo)
1 -f [cp: `foo' and `foo' are the same file] (foo)
1 -df [cp: `foo' and `foo' are the same file] (foo)
1 --rem [cp: `foo' and `foo' are the same file] (foo)
1 -b [cp: `foo' and `foo' are the same file] (foo)
1 -bd [cp: `foo' and `foo' are the same file] (foo)
0 -bf (foo foo.~1~)
@@ -130,23 +149,24 @@ cat <<\EOF > $expected
0 -bdfl (foo foo.~1~)
1 [cp: `sl1' and `sl2' are the same file] (foo sl1 -> foo sl2 -> foo)
1 -d [cp: cannot create symbolic link `sl2': File exists] (foo sl1 -> foo sl2 -> foo)
0 -f (foo sl1 -> foo sl2)
0 -d (foo sl1 -> foo sl2 -> foo)
1 -f [cp: `sl1' and `sl2' are the same file] (foo sl1 -> foo sl2 -> foo)
0 -df (foo sl1 -> foo sl2 -> foo)
0 --rem (foo sl1 -> foo sl2)
0 -b (foo sl1 -> foo sl2 sl2.~1~ -> foo)
0 -bd (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo)
0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo)
0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo)
0 -l (foo sl1 -> foo sl2 -> foo)
1 -dl [cp: cannot create link `sl2': File exists] (foo sl1 -> foo sl2 -> foo)
0 -fl (foo sl1 -> foo sl2 -> foo)
0 -bl (foo sl1 -> foo sl2 -> foo)
0 -bfl (foo sl1 -> foo sl2 -> foo)
1 [cp: `foo' and `hardlink' are the same file] (foo hardlink)
1 -d [cp: `foo' and `hardlink' are the same file] (foo hardlink)
0 -f (foo hardlink)
0 -df (foo hardlink)
1 -f [cp: `foo' and `hardlink' are the same file] (foo hardlink)
1 -df [cp: `foo' and `hardlink' are the same file] (foo hardlink)
0 --rem (foo hardlink)
0 -b (foo hardlink hardlink.~1~)
0 -bd (foo hardlink hardlink.~1~)
0 -bf (foo hardlink hardlink.~1~)

59
tests/cp/special-bits Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/sh
# make sure `cp -p' preserves special bits
# This works only when run as root.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
pwd=`pwd`
tmp=spec-bits.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
touch file || framework_failure=1
chmod u-w file || framework_failure=1
(echo foo >> file) >/dev/null 2>&1 || {
echo '********************************************'
echo "$0: NOTICE: This test must be run as root."
echo "You can do the following as \`root' to run just this test:"
echo ""
echo "cd $pwd && $MAKE check TESTS=special-bits"
echo ""
echo "Here's a minimalist version. It outputs nothing when the test"
echo "succeeds, and \`FAIL' if it fails."
echo ""
echo "cd $pwd \\"
echo " && env PATH=../../src:\$PATH MAKE=$MAKE ./special-bits || echo FAIL"
echo ""
echo '********************************************'
exit 77
}
touch a b || framework_failure=1
chmod u+sx,go= a || framework_failure=1
chmod u=rwx,g=sx,o= b || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
cp -p a a2 || fail=1
set _ `ls -l a`; shift; p1=$1
set _ `ls -l a2`; shift; p2=$1
test $p1 = $p2 || fail=1
cp -p b b2 || fail=1
set _ `ls -l b`; shift; p1=$1
set _ `ls -l b2`; shift; p2=$1
test $p1 = $p2 || fail=1
(exit $fail); exit

View File

@@ -7,6 +7,6 @@ TESTS_ENVIRONMENT = \
srcdir=$(srcdir) \
PERL="@PERL@" \
PATH=`pwd`/../../src:$$PATH \
PROG=ls
PROG=dd
TESTS = misc
TESTS = misc not-rewound

View File

@@ -122,10 +122,10 @@ TESTS_ENVIRONMENT = \
srcdir=$(srcdir) \
PERL="@PERL@" \
PATH=`pwd`/../../src:$$PATH \
PROG=ls
PROG=dd
TESTS = misc
TESTS = misc not-rewound
subdir = tests/dd
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h

33
tests/dd/not-rewound Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# Make sure dd does the right thing when the input file descriptor
# is not rewound.
if test "$VERBOSE" = yes; then
set -x
dd --version
fi
pwd=`pwd`
tmp=dd-rw.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
echo abcde > in
(dd skip=1 count=1 bs=1; dd skip=1 bs=1) < in > out 2> /dev/null || fail=1
case `cat out` in
bde) ;;
*) fail=1 ;;
esac
(exit $fail); exit

View File

@@ -2,7 +2,8 @@
AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = i-2 mv-special-1 into-self into-self-2 into-self-3 backup-is-src \
i-1 hard-link-1 force partition-perm to-symlink dir-file diag
i-1 hard-link-1 force partition-perm to-symlink dir-file diag \
part-symlink
EXTRA_DIST = $(TESTS) setup
TESTS_ENVIRONMENT = \

View File

@@ -118,7 +118,8 @@ l = @l@
AUTOMAKE_OPTIONS = 1.3 gnits
TESTS = i-2 mv-special-1 into-self into-self-2 into-self-3 backup-is-src \
i-1 hard-link-1 force partition-perm to-symlink dir-file diag
i-1 hard-link-1 force partition-perm to-symlink dir-file diag \
part-symlink
EXTRA_DIST = $(TESTS) setup

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# move a file onto itself with --force
# move a file onto itself
if test "$VERBOSE" = yes; then
set -x
@@ -28,7 +28,7 @@ LANG=C
export LANG
# This mv command should exit nonzero.
mv --force $ff $ff > out 2>&1 && fail=1
mv $ff $ff > out 2>&1 && fail=1
cat > exp <<EOF
mv: \`$ff' and \`$ff' are the same file
@@ -39,7 +39,7 @@ test `cat $ff` = force-contents || fail=1
# This should succeed, even though the source and destination
# device and inodes are the same.
mv --force $ff $ff2 || fail=1
mv $ff $ff2 || fail=1
rm -fr out exp $ff $ff2

207
tests/mv/part-symlink Executable file
View File

@@ -0,0 +1,207 @@
#!/bin/sh
# make sure cp and mv can handle many combinations of local and
# other-partition regular/symlink'd files.
if test "$VERBOSE" = yes; then
set -x
mv --version
cp --version
fi
pwd=`pwd`
tmp=part-sl.$$
trap 'status=$?; cd $pwd; exec 1>&2; rm -rf $tmp $other_partition_tmpdir && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
pwd_tmp=$pwd/$tmp
. $srcdir/setup
. $srcdir/../envvar-check
if test -z "$other_partition_tmpdir"; then
(exit 77); exit
fi
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
# Four cases:
# local regular file w/symlink on another partition
# (loc_reg, rem_sl)
# (rem_sl, loc_reg)
# local symlink to regular file on another partition
# (loc_sl, rem_reg)
# (rem_reg, loc_sl)
# Exercise those four cases for each of
# cp and mv, with lots of combinations of options.
actual=actual-$$
expected=expected-$$
exec 1> $actual
# FIXME: This should be bigger: like more than 8k
contents=XYZ
loc_reg=loc_reg
loc_sl=loc_sl
rem_reg=$other_partition_tmpdir/rem_reg
rem_sl=$other_partition_tmpdir/rem_sl
for copy in cp mv; do
for args in \
'loc_reg rem_sl' \
'rem_sl loc_reg' \
'loc_sl rem_reg' \
'rem_reg loc_sl' \
; do
for options in '' --rem '--rem -d' '--rem -b' -b -bd -d; do
case "$options" in *d*|*--rem*) test $copy = mv && continue;; esac
rm -rf dir || fail=1
rm -f $other_partition_tmpdir/* || fail=1
mkdir dir || fail=1
cd dir || fail=1
case "$args" in *loc_reg*) reg_abs="`pwd`/$loc_reg" ;; esac
case "$args" in *rem_reg*) reg_abs=$rem_reg ;; esac
case "$args" in *loc_sl*) slink=$loc_sl ;; esac
case "$args" in *rem_sl*) slink=$rem_sl ;; esac
echo $contents > $reg_abs || fail=1
ln -nsf $reg_abs $slink || fail=1
actual_args=`echo $args|sed 's,^,$,;s/ / $/'`
actual_args=`eval echo $actual_args`
(
(
# echo 1>&2 cp $options $args
$copy $options $actual_args 2>.err
copy_status=$?
echo $copy_status $copy $options $args
# Normalize the program name in the error output,
# remove any site-dependent part of other-partition file name,
# and put brackets around the output.
test -s .err && {
echo '[' | tr -d '\012'
sed 's/^[^:][^:]*\(..\):/\1:/;s,'$other_partition_tmpdir/,, .err
echo ']' | tr -d '\012'
}
# Strip off all but the file names.
# Remove any site-dependent part of each file name.
ls="`ls -lG --ignore=.err . \
| sed \
-e '/^total /d' \
-e s,$other_partition_tmpdir/,, \
-e s,$pwd_tmp/,, \
-e 's/^...............................................//'`"
ls2="`cd $other_partition_tmpdir && ls -lG --ignore=.err . \
| sed \
-e '/^total /d' \
-e s,$other_partition_tmpdir/,, \
-e s,$pwd_tmp/,, \
-e 's/^...............................................//'`"
echo "($ls) ($ls2)"
# If the command failed, then it must not have changed the files.
if test $copy_status != 0; then
for f in $actual_args; do
test -f $f ||
{ echo "$copy FAILED but removed $f"; continue; }
case "`cat $f`" in
"$contents") ;;
*) echo "$copy FAILED but modified $f";;
esac
done
fi
if test $copy = cp; then
# Make sure the original is unchanged and that
# the destination is a copy.
for f in $actual_args; do
if test -f $f; then
if test $copy_status != 0; then
test
fi
case "`cat $f`" in
"$contents") ;;
*) echo $copy FAILED;;
esac
else
echo symlink-loop
fi
done
fi
) | tr '\012' ' '
echo
) | sed 's/ *$//'
cd ..
done
echo
done
done
test $fail = 1 &&
{ (exit $?); exit; }
cat <<\EOF > $expected
1 cp loc_reg rem_sl [cp: `loc_reg' and `rem_sl' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
0 cp --rem loc_reg rem_sl (loc_reg) (rem_sl)
0 cp --rem -d loc_reg rem_sl (loc_reg) (rem_sl)
0 cp --rem -b loc_reg rem_sl (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg)
0 cp -b loc_reg rem_sl (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg)
0 cp -bd loc_reg rem_sl (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg)
1 cp -d loc_reg rem_sl [cp: `loc_reg' and `rem_sl' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
1 cp rem_sl loc_reg [cp: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
1 cp --rem rem_sl loc_reg [cp: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
1 cp --rem -d rem_sl loc_reg [cp: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
1 cp --rem -b rem_sl loc_reg [cp: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
1 cp -b rem_sl loc_reg [cp: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
0 cp -bd rem_sl loc_reg (loc_reg -> dir/loc_reg loc_reg~) (rem_sl -> dir/loc_reg) symlink-loop symlink-loop
1 cp -d rem_sl loc_reg [cp: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
1 cp loc_sl rem_reg [cp: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
1 cp --rem loc_sl rem_reg [cp: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
1 cp --rem -d loc_sl rem_reg [cp: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
1 cp --rem -b loc_sl rem_reg [cp: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
1 cp -b loc_sl rem_reg [cp: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
0 cp -bd loc_sl rem_reg (loc_sl -> rem_reg) (rem_reg -> rem_reg rem_reg~) symlink-loop symlink-loop
1 cp -d loc_sl rem_reg [cp: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
1 cp rem_reg loc_sl [cp: `rem_reg' and `loc_sl' are the same file ](loc_sl -> rem_reg) (rem_reg)
0 cp --rem rem_reg loc_sl (loc_sl) (rem_reg)
0 cp --rem -d rem_reg loc_sl (loc_sl) (rem_reg)
0 cp --rem -b rem_reg loc_sl (loc_sl loc_sl~ -> rem_reg) (rem_reg)
0 cp -b rem_reg loc_sl (loc_sl loc_sl~ -> rem_reg) (rem_reg)
0 cp -bd rem_reg loc_sl (loc_sl loc_sl~ -> rem_reg) (rem_reg)
1 cp -d rem_reg loc_sl [cp: `rem_reg' and `loc_sl' are the same file ](loc_sl -> rem_reg) (rem_reg)
0 mv loc_reg rem_sl () (rem_sl)
0 mv -b loc_reg rem_sl () (rem_sl rem_sl~ -> dir/loc_reg)
1 mv rem_sl loc_reg [mv: `rem_sl' and `loc_reg' are the same file ](loc_reg) (rem_sl -> dir/loc_reg)
0 mv -b rem_sl loc_reg (loc_reg -> dir/loc_reg loc_reg~) ()
1 mv loc_sl rem_reg [mv: `loc_sl' and `rem_reg' are the same file ](loc_sl -> rem_reg) (rem_reg)
0 mv -b loc_sl rem_reg () (rem_reg -> rem_reg rem_reg~)
0 mv rem_reg loc_sl (loc_sl) ()
0 mv -b rem_reg loc_sl (loc_sl loc_sl~ -> rem_reg) ()
EOF
# Uncomment this if you see a failure and want to try to diagnose it.
#diff -u $expected $actual 1>&2
cmp $expected $actual
(exit $?); exit

View File

@@ -37,6 +37,9 @@ fi
# before copying.
mv $file $rem_symlink || fail=1
# Make sure $file is gone.
test -f $file && fail=1
# Make sure $rem_file is unmodified.
test `cat $rem_file` = remote || fail=1

26
tests/sample-test Normal file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
# FIXME
if test "$VERBOSE" = yes; then
set -x
FIXME --version
fi
pwd=`pwd`
tmp=FIXME.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
(exit $fail); exit