Compare commits

...

33 Commits
v8.0 ... next

Author SHA1 Message Date
Eric Blake
6c935a0554 Merge remote branch 'origin/next' into next 2009-10-10 09:28:19 -06:00
Jim Meyering
3b7dc2b522 rm: record timing data
* README-rm-timing-compare: new file
* README-rm-timing-2: New file.
2009-10-10 09:21:36 -06:00
Eric Blake
aeaa6bf7ae touch: optimize use of utimens
* src/touch.c (main): Use UTIME_NOW rather than calling gettime.
(touch): Use UTIME_OMIT rather than stat.
2009-10-10 09:14:39 -06:00
Eric Blake
82e344ca09 copy: allow symlink timestamp preservation on more systems
* src/copy.c (utimens_symlink): Simplify by using lutimens.
* m4/jm-macros.m4 (coreutils_MACROS): Drop utimensat; gnulib does
this for us.
* tests/cp/preserve-slink-time: Recognize lutimes support.
2009-10-10 09:14:35 -06:00
Eric Blake
2cd1577554 build: update gnulib submodule to latest, for utimens improvements 2009-10-10 09:14:17 -06:00
Eric Blake
c2bebf63ed maint: touch up previous LDADD patch
* src/Makefile.am (dir_LDADD): Delete; the ls_LDADD line covers this.
2009-10-10 06:28:40 -06:00
Jim Meyering
d74a1b005c build: build uname(1) unconditionally
Before, on a system without the uname function, the build
system would detect that and not build/install a uname program.
Now that gnulib guarantees a uname function, ...
* configure.ac: Don't check for the uname function.
* src/Makefile.am (build_if_possible__progs): Move uname...
(EXTRA_PROGRAMS): ...to this list.
2009-10-10 09:03:15 +02:00
Jim Meyering
4f1a3eda10 maint: list program names one per line
* src/Makefile.am (EXTRA_PROGRAMS): List them one per line.
(build_if_possible__progs): Likewise.
2009-10-10 08:58:43 +02:00
Jim Meyering
c9e7b8844b build: ls: fix link failure due to missing -lacl
* src/Makefile.am (ls_LDADD): Re-add $(LIB_ACL).
Inadvertently-removed by commit 78c93601.
2009-10-10 08:24:02 +02:00
Eric Blake
219f2f0538 maint: touch up previous LDADD patch
* src/Makefile.am (stdbuf_LDADD): Add missing primer.
(hostname_LDADD, uname_LDADD): Add GETHOSTNAME_LIB.
* bootstrap.conf (gnulib_modules): Add uname.
2009-10-09 20:08:03 -06:00
Eric Blake
78c9360178 maint: improve additional library tracking
* src/Makefile.am (LDADD): Refactor, to make per-library additions
to individual programs easier to maintain.
2009-10-09 19:28:07 -06:00
Jim Meyering
0023f65fd7 chcon: don't disable just because SELinux is disabled
* src/chcon.c (main): Now that gnulib provides getfilecon wrappers,
we can revert most of the 2009-10-05 commit 3a97d664, "chcon: exit
immediately if SELinux is disabled", since chcon is still useful as
long as the file system provides handlers for the security.*
name space.  gnulib's getfilecon wrappers ensure that an offending
context now evokes a return value of -1.
Prompted by comments from Stephen Smalley in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18378/focus=18394
* NEWS (Bug fixes): Mention it.
2009-10-09 14:33:10 +02:00
Jim Meyering
57d9263ca5 ls: remove explicit getfilecon work-around
* src/ls.c (gobble_file): Remove l?getfilecon work-around,
now that the gnulib wrappers handle it for us.
2009-10-09 14:33:10 +02:00
Jim Meyering
e11a0319b3 build: update gnulib submodule to latest, for getfilecon wrappers 2009-10-09 14:33:10 +02:00
Eric Blake
c039c96449 maint: use X2NREALLOC in more places
* src/chroot.c (set_additional_groups): Use X2NREALLOC rather than
x2nrealloc.
* src/factor.c (emit_factor): Likewise.
* src/setuidgid.c (main): Likewise.
2009-10-08 20:30:08 -06:00
Eric Blake
aa092ccf6a maint: remove unused macros and declarations
* src/system.h (EDQUOT, EISDIR, ENOSYS, EOVERFLOW, F_OK, X_OK)
(W_OK, R_OK): Delete; macros provided by gnulib.
(includes): Gnulib guarantees both <time.h> and <sys/time.h>, in
either order.
(free, malloc, memchr, realloc, getenv, lseek): Delete, gnulib
guarantees these declarations.
* m4/check-decl.m4 (gl_CHECK_DECLS): Delete checks now done by
gnulib.
2009-10-08 20:30:06 -06:00
Eric Blake
2a876d901d maint: move timeout exit statuses
* src/timeout.c (EXIT_TIMEDOUT, EXIT_CANCELED): Remove as
macros...
* src/system.h (EXIT_TIMEDOUT, EXIT_CANCELED): ...and provide as
enum values instead.
* src/stdbuf.c (EXIT_CANCELED): Delete.
2009-10-08 20:30:03 -06:00
Eric Blake
a797c4d7d3 stat: test recent patch
* tests/misc/stat-slash: New test.
* tests/Makefile.am (TESTS): Run it.
2009-10-08 20:30:00 -06:00
Eric Blake
7a3bc1bf27 stdbuf: improve path search
* src/stdbuf.c (set_program_path): Use gnulib methods for better
file name handling.
* bootstrap.conf (gnulib_modules): Add xreadlink.
2009-10-08 06:52:18 -06:00
Eric Blake
00674c7475 stat: work with recent gnulib changes
* src/stat.c (do_stat): Don't mask function-like stat macro.
2009-10-08 06:52:15 -06:00
Jim Meyering
eb5f06f2a6 stat: add support for many more file system types
* src/stat.c (human_fstype): Add the following FS types,
from <linux/magic.h>: afs, anon-inode FS, btrfs, cgroupfs,
cramfs-wend, debugfs, futexfs, inotifyfs, minux3, securityfs,
selinux, xenfs.
Also add "nilfs".
* src/Makefile.am (fs-kernel-magic): New rule.
* NEWS (Bug fixes): Mention this.
2009-10-08 10:18:28 +02:00
Jim Meyering
8e32390716 stat: recognize CIFS and HFS file system types
* src/stat.c (human_fstype) [CIFS, HFS]: Add new file system types.
Prompted by a report from Stuart Kemp.
Normalize the form of a few hexadecimal magic numbers.
Alphabetize on S_MAGIC_ case names.
* src/Makefile.am (fs-magic-compare, fs-def, fs-magic): New rules, to
automate comparison of our list with that in the Linux statfs man page.
* NEWS (Bug fixes): Mention it.
2009-10-08 09:07:12 +02:00
Guenter Knauf
b95be30e3f md5sum, sha*sum: also accept openssl checksum syntax
* src/md5sum.c (split_3): Accept openssl checksum syntax, which
differs only by two spaces from that of the bsd checksum tools:
openssl: MD5(f)= d41d8cd98f00b204e9800998ecf8427e
bsd:     MD5 (f) = d41d8cd98f00b204e9800998ecf8427e
2009-10-07 09:31:27 +02:00
Jim Meyering
d183a15cbb maint: make release-making instructions more generic
* README-release: Make instructions more generic.
2009-10-06 16:49:36 +02:00
Jim Meyering
96829a9ff0 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2009-10-06 13:20:18 +02:00
Eric Blake
41c9e064a6 rm: avoid compiler warning
* src/remove.c (rm_fts): Don't allow fall-through when assertions
are disabled.
2009-09-05 16:28:46 +02:00
Eric Blake
5f303a1293 euidaccess-stat: remove unnecessary macros
* lib/euidaccess-stat.c (F_OK, R_OK, W_OK, X_OK): Delete; now
guaranteed by gnulib.
2009-09-05 16:28:46 +02:00
Eric Blake
2df272914b rm: use gnulib faccessat
* bootstrap.conf (gnulib_modules): Add faccessat.  Replace strdup
with strdup-posix.
* m4/jm-macros.m4 (coreutils_MACROS): Revert previous change, now
that gnulib does it for us.
* src/remove.c (write_protected_non_symlink): Use faccessat in
more situations.
2009-09-05 16:28:46 +02:00
Jim Meyering
278109b9f4 NEWS: mention recent improvements in rm 2009-09-05 16:28:46 +02:00
Jim Meyering
0f3f7d495c rm: improve efficiency of rm -r (without -f) from O(N^2) to O(N)
where N is the depth of the deepest hierarchy rm is processing.
* src/remove.c (write_protected_non_symlink): Use faccessat to
avoid O(N)-per-entry cost of calling euidaccess.
* m4/jm-macros.m4 (coreutils_MACROS): Check for faccessat.
2009-09-05 16:28:46 +02:00
Jim Meyering
4f87cc0364 build: placate gcc's new -Wskip-jump-init
* remove.c (rm_fts): Put braces around each of the two offending blocks.
* configure.ac: Don't turn off -Wjump-misses-init.
With the rewrite of remove.c, it is no longer needed.
2009-09-05 16:28:46 +02:00
Jim Meyering
18c5fbd5dc rm: rewrite to use fts
* remove.c: Don't include "unlinkdir.h"; no longer used.
Do not include <setjmp.h> or "cycle-check.h".  Likewise.
Include "xfts.h".
(dir_name, dir_len): Remove definitions.
(CONSECUTIVE_READDIR_UNLINK_THRESHOLD): Likewise.
(INODE_SORT_DIR_ENTRIES_THRESHOLD, NEED_REWIND, D_TYPE): Likewise.
(struct dirstack_state, Dirstack_state): Likewise.
(g_buf, g_n_allocated): Remove declarations.
(hash_freer, hash_compare_strings, rm_malloc): Remove functions.
(rm_free, push_dir, top_dir, pop_dir, right_justify): Likewise.
(full_filename0, xfull_filename, full_filename_): Likewise.
(AD_stack_height, AD_stack_top, AD_stack_pop, AD_stack_clear): Likewise.
(obstack_init_minimal, ds_init, ds_clear, ds_free): Likewise.
(AD_pop_and_chdir, AD_ensure_initialized, AD_mark_helper): Likewise.
(AD_mark_as_unremovable, AD_mark_current_as_unremovable): Likewise.
(AD_push_initial, AD_push, AD_push, AD_is_removable): Likewise.
(write_protected_non_symlink): Change 3rd parameter from
dirstack_state "ds" to full_name.
(prompt): Adjust parameters.  Now, state comes from FTS/FTSENT pair.
Those replace fd_cwd and "ds".  Remove "filename".  Remove pdirent_type
in favor of new "is_dir" parameter.  Rename is_empty to is_empty_p.
(DO_RMDIR, DO_UNLINK): Remove definitions.
(remove_entry, fd_to_subdirp, compare_ino): Remove functions.
(dirent_count, dirent_inode_sort_may_be_useful): Likewise.
(preprocess_dir): Likewise.
(fts_skip_tree, mark_ancestor_dirs, excise, rm_fts): New functions.
(remove_cwd_entries, remove_dir, rm_1): Remove functions.
(rm): Rewrite as a simple loop calling fts_read and dispatching
each entry via rm_fts.
* src/rm.c (main): Adapt to new signature of rm().
* bootstrap.conf (gnulib_modules): Remove unlinkdir, no longer used.
* src/Makefile.am (sc_tight_scope): Also recognize an extern "enum"
declaration.
* tests/rm/empty-name: Adjust expected output to match new diagnostic.
2009-09-05 16:28:46 +02:00
Jim Meyering
cf963e5a54 rm: record timing data
* README-rm-timing-compare: new file
* README-rm-timing-2: New file.
2009-09-05 16:28:46 +02:00
29 changed files with 1075 additions and 272 deletions

View File

@@ -1 +1 @@
7.6
8.0

18
NEWS
View File

@@ -1,5 +1,23 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
** Bug fixes
chcon no longer exits immediately just because SELinux is disabled.
Even then, chcon may still be useful.
[bug introduced in coreutils-8.0]
stat -f recognizes more file system types: afs, cifs, anon-inode FS,
btrfs, cgroupfs, cramfs-wend, debugfs, futexfs, hfs, inotifyfs, minux3,
nilfs, securityfs, selinux, xenfs
** New features
md5sum --check now also accepts openssl-style checksums.
So do sha1sum, sha224sum, sha384sum and sha512sum.
* Noteworthy changes in release 8.0 (2009-10-06) [beta]
** Bug fixes

View File

@@ -7,18 +7,18 @@ Here are most of the steps we (maintainers) follow when making a release.
* Run ./configure && make maintainer-clean
* Ensure that the desired versions of autoconf, automake, bison, etc.
are in your PATH. See HACKING for the complete list.
are in your PATH. See the buildreq list in bootstrap.conf for
the complete list.
* Ensure that you're on "master" with no uncommitted diffs.
This should produce no output: git checkout master; git diff
* Make sure your local gnulib directory is up to date.
* Run bootstrap: ./bootstrap
FIXME: enable excluded programs like arch? to get their manual pages?
* Pre-release testing:
Ensure that make check syntax-check succeeds.
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
run all tests, both root-only and regular.
Run *all* non-root tests, including expensive and very expensive ones i.e.,
@@ -32,16 +32,17 @@ FIXME: enable excluded programs like arch? to get their manual pages?
* Manually set the date, version number, and [stable/alpha/beta] on
line 3 of NEWS, then do e.g.,:
v=7.3
v=8.0
pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' Makefile)
git commit -F <(printf 'version '$v'\n\n* NEWS: Record release date.\n') -a
git tag -s -m "coreutils $v" v$v HEAD
git tag -s -m "$pkg $v" v$v HEAD
* Run the following to create release tarballs. Your choice selects the
corresponding upload-to destination in the emitted gnupload command.
The different destinations are specified in cfg.mk. See the definitions
of gnu_ftp_host-{alpha,beta,major}.
of gnu_ftp_host-{alpha,beta,stable}.
# "TYPE" must be major, beta or alpha
# "TYPE" must be stable, beta or alpha
make TYPE
* Test the tarball. copy it to a few odd-ball systems and ensure that
@@ -59,12 +60,15 @@ Once all the builds and tests have passed,
that they're all valid.
* Push the new tag:
git push origin tag v<JUST_RELEASED_VERSION_NUMBER>
v=$(cat .prev-version)
git push origin tag v$v
* Send the gpg-signed announcement mail, e.g.,
To: info-gnu@gnu.org, coreutils-announce@gnu.org
Cc: coordinator@translationproject.org, bug-coreutils@gnu.org
Subject: coreutils-7.1 released [stable]
Subject: coreutils-8.0 released [beta]
* Approve the announcement here:
http://lists.gnu.org/mailman/admindb/coreutils-announce
@@ -73,10 +77,13 @@ Once all the builds and tests have passed,
From here:
https://savannah.gnu.org/projects/coreutils/
click on the "submit news", then write something like the following:
(If there is no such button, then enable "News" for the project via
the Main -> "Select Features" menu item, or via this link:
https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=gzip)
Subject: coreutils-7.2 released [stable]
Subject: coreutils-0.0 released [beta]
The announcement is here:
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/49
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/54
Then go here to approve it:
https://savannah.gnu.org/news/approve.php?group=coreutils
@@ -85,4 +92,6 @@ Once all the builds and tests have passed,
http://www.gnu.org/software/coreutils/manual/
by running the gnu-web-doc-update script.
by running this:
build-aux/gnu-web-doc-update

View File

@@ -210,6 +210,7 @@ gnulib_modules="
sys_stat
timespec
tzset
uname
unicodeio
unistd-safer
unlink-busy
@@ -238,6 +239,7 @@ gnulib_modules="
xnanosleep
xprintf
xprintf-posix
xreadlink
xstrtod
xstrtoimax
xstrtol

2
cfg.mk
View File

@@ -39,7 +39,7 @@ bootstrap-tools = autoconf,automake,gnulib,bison
# Now that we have better tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = 0d22ab4ad3fedd9cf283b256b61e8080
old_NEWS_hash = 785e51bc9af87e7eb004f9ba24a0ca27
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c

View File

@@ -118,8 +118,6 @@ fi
AC_FUNC_FORK
optional_bin_progs=
AC_CHECK_FUNCS([uname],
gl_ADD_PROG([optional_bin_progs], [uname]))
AC_CHECK_FUNCS([chroot],
gl_ADD_PROG([optional_bin_progs], [chroot]))
AC_CHECK_FUNCS([gethostid],

2
gnulib

Submodule gnulib updated: 6f6420cc97...959d9cb463

View File

@@ -1,4 +1,4 @@
#serial 24
#serial 25
# Check declarations for this package.
dnl Copyright (C) 1997-2001, 2003-2006, 2008-2009 Free Software
@@ -37,13 +37,7 @@ AC_DEFUN([gl_CHECK_DECLS],
AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
AC_CHECK_DECLS_ONCE([free])
AC_CHECK_DECLS_ONCE([getenv])
AC_CHECK_DECLS_ONCE([geteuid])
AC_CHECK_DECLS_ONCE([getlogin])
AC_CHECK_DECLS_ONCE([getuid])
AC_CHECK_DECLS_ONCE([lseek])
AC_CHECK_DECLS_ONCE([malloc])
AC_CHECK_DECLS_ONCE([memchr])
AC_CHECK_DECLS_ONCE([realloc])
])

View File

@@ -89,9 +89,6 @@ AC_DEFUN([coreutils_MACROS],
tcgetpgrp \
)
# for cp.c
AC_CHECK_FUNCS_ONCE([utimensat])
dnl This can't use AC_REQUIRE; I'm not quite sure why.
cu_PREREQ_STAT_PROG

View File

@@ -24,25 +24,114 @@ no_install__progs = \
arch hostname su
build_if_possible__progs = \
chroot df hostid nice pinky stdbuf libstdbuf.so stty su uname uptime users who
chroot \
df \
hostid \
libstdbuf.so \
nice \
pinky \
stdbuf \
stty \
su \
uptime \
users \
who
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
EXTRA_PROGRAMS = \
$(no_install__progs) \
$(build_if_possible__progs) \
[ chcon chgrp chown chmod cp dd dircolors du \
ginstall link ln dir vdir ls mkdir \
mkfifo mknod mktemp \
mv nohup readlink rm rmdir shred stat sync touch unlink \
cat cksum comm csplit cut expand fmt fold head join groups md5sum \
nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
shuf sort split sum tac tail tr tsort unexpand uniq wc \
basename date dirname echo env expr factor false \
id kill logname pathchk printenv printf pwd \
runcon seq sleep tee \
test timeout true truncate tty whoami yes \
base64
[ \
base64 \
basename \
cat \
chcon \
chgrp \
chmod \
chown \
cksum \
comm \
cp \
csplit \
cut \
date \
dd \
dir \
dircolors \
dirname \
du \
echo \
env \
expand \
expr \
factor \
false \
fmt \
fold \
ginstall \
groups \
head \
id \
join \
kill \
link \
ln \
logname \
ls \
md5sum \
mkdir \
mkfifo \
mknod \
mktemp \
mv \
nl \
nohup \
od \
paste \
pathchk \
pr \
printenv \
printf \
ptx \
pwd \
readlink \
rm \
rmdir \
runcon \
seq \
sha1sum \
sha224sum \
sha256sum \
sha384sum \
sha512sum \
shred \
shuf \
sleep \
sort \
split \
stat \
sum \
sync \
tac \
tail \
tee \
test \
timeout \
touch \
tr \
true \
truncate \
tsort \
tty \
uname \
unexpand \
uniq \
unlink \
vdir \
wc \
whoami \
yes
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
@@ -50,20 +139,20 @@ noinst_PROGRAMS = setuidgid getlimits
pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
noinst_HEADERS = \
chown-core.h \
copy.h \
cp-hash.h \
dircolors.h \
fs.h \
group-list.h \
ls.h \
operand2sig.h \
prog-fprintf.h \
remove.h \
system.h \
wheel-size.h \
wheel.h \
noinst_HEADERS = \
chown-core.h \
copy.h \
cp-hash.h \
dircolors.h \
fs.h \
group-list.h \
ls.h \
operand2sig.h \
prog-fprintf.h \
remove.h \
system.h \
wheel-size.h \
wheel.h \
uname.h
EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
@@ -87,99 +176,216 @@ nodist_libver_a_SOURCES = version.c version.h
# replacement functions defined in libcoreutils.a.
LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
# First, list all programs, to make listing per-program libraries easier.
# See [ below.
arch_LDADD = $(LDADD)
base64_LDADD = $(LDADD)
basename_LDADD = $(LDADD)
cat_LDADD = $(LDADD)
chcon_LDADD = $(LDADD)
chgrp_LDADD = $(LDADD)
chmod_LDADD = $(LDADD)
chown_LDADD = $(LDADD)
chroot_LDADD = $(LDADD)
cksum_LDADD = $(LDADD)
comm_LDADD = $(LDADD)
cp_LDADD = $(LDADD)
csplit_LDADD = $(LDADD)
cut_LDADD = $(LDADD)
date_LDADD = $(LDADD)
dd_LDADD = $(LDADD)
df_LDADD = $(LDADD)
# See dir_LDADD below
dircolors_LDADD = $(LDADD)
dirname_LDADD = $(LDADD)
du_LDADD = $(LDADD)
echo_LDADD = $(LDADD)
env_LDADD = $(LDADD)
expand_LDADD = $(LDADD)
expr_LDADD = $(LDADD)
factor_LDADD = $(LDADD)
false_LDADD = $(LDADD)
fmt_LDADD = $(LDADD)
fold_LDADD = $(LDADD)
getlimits_LDADD = $(LDADD)
ginstall_LDADD = $(LDADD)
groups_LDADD = $(LDADD)
head_LDADD = $(LDADD)
hostid_LDADD = $(LDADD)
hostname_LDADD = $(LDADD)
id_LDADD = $(LDADD)
join_LDADD = $(LDADD)
kill_LDADD = $(LDADD)
link_LDADD = $(LDADD)
ln_LDADD = $(LDADD)
logname_LDADD = $(LDADD)
ls_LDADD = $(LDADD)
md5sum_LDADD = $(LDADD)
mkdir_LDADD = $(LDADD)
mkfifo_LDADD = $(LDADD)
mknod_LDADD = $(LDADD)
mktemp_LDADD = $(LDADD)
mv_LDADD = $(LDADD)
nice_LDADD = $(LDADD)
nl_LDADD = $(LDADD)
nohup_LDADD = $(LDADD)
od_LDADD = $(LDADD)
paste_LDADD = $(LDADD)
pathchk_LDADD = $(LDADD)
pinky_LDADD = $(LDADD)
pr_LDADD = $(LDADD)
printenv_LDADD = $(LDADD)
printf_LDADD = $(LDADD)
ptx_LDADD = $(LDADD)
pwd_LDADD = $(LDADD)
readlink_LDADD = $(LDADD)
rm_LDADD = $(LDADD)
rmdir_LDADD = $(LDADD)
runcon_LDADD = $(LDADD)
seq_LDADD = $(LDADD)
setuidgid_LDADD = $(LDADD)
sha1sum_LDADD = $(LDADD)
sha224sum_LDADD = $(LDADD)
sha256sum_LDADD = $(LDADD)
sha384sum_LDADD = $(LDADD)
sha512sum_LDADD = $(LDADD)
shred_LDADD = $(LDADD)
shuf_LDADD = $(LDADD)
sleep_LDADD = $(LDADD)
sort_LDADD = $(LDADD)
split_LDADD = $(LDADD)
stat_LDADD = $(LDADD)
stdbuf_LDADD = $(LDADD)
stty_LDADD = $(LDADD)
su_LDADD = $(LDADD)
sum_LDADD = $(LDADD)
sync_LDADD = $(LDADD)
tac_LDADD = $(LDADD)
tail_LDADD = $(LDADD)
tee_LDADD = $(LDADD)
test_LDADD = $(LDADD)
timeout_LDADD = $(LDADD)
touch_LDADD = $(LDADD)
tr_LDADD = $(LDADD)
true_LDADD = $(LDADD)
truncate_LDADD = $(LDADD)
tsort_LDADD = $(LDADD)
tty_LDADD = $(LDADD)
uname_LDADD = $(LDADD)
unexpand_LDADD = $(LDADD)
uniq_LDADD = $(LDADD)
unlink_LDADD = $(LDADD)
uptime_LDADD = $(LDADD)
users_LDADD = $(LDADD)
# See vdir_LDADD below
wc_LDADD = $(LDADD)
who_LDADD = $(LDADD)
whoami_LDADD = $(LDADD)
yes_LDADD = $(LDADD)
# for eaccess in lib/euidaccess.c.
chcon_LDADD = $(LDADD) $(LIB_SELINUX)
cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
mknod_LDADD = $(LDADD) $(LIB_SELINUX)
mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
runcon_LDADD = $(LDADD) $(LIB_SELINUX)
pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
rm_LDADD = $(LDADD) $(LIB_EACCESS)
test_LDADD = $(LDADD) $(LIB_EACCESS)
# This is for the '[' program. Automake transliterates '[' to '_'.
__LDADD = $(LDADD) $(LIB_EACCESS)
# Synonyms. Recall that Automake transliterates '[' to '_'.
__LDADD = $(test_LDADD)
dir_LDADD = $(ls_LDADD)
vdir_LDADD = $(ls_LDADD)
# for clock_gettime and fdatasync
dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
id_LDADD = $(LDADD) $(LIB_SELINUX)
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
# Shared files
copy_LDADD =
cp_LDADD += $(copy_LDADD)
ginstall_LDADD += $(copy_LDADD)
mv_LDADD += $(copy_LDADD)
## If necessary, add -lm to resolve use of pow in lib/strtod.c.
sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
remove_LDADD =
mv_LDADD += $(remove_LDADD)
rm_LDADD += $(remove_LDADD)
# for get_date and gettime
date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
# for eaccess, euidaccess
copy_LDADD += $(LIB_EACCESS)
remove_LDADD += $(LIB_EACCESS)
test_LDADD += $(LIB_EACCESS)
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
# If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
# for selinux use
chcon_LDADD += $(LIB_SELINUX)
copy_LDADD += $(LIB_SELINUX)
ginstall_LDADD += $(LIB_SELINUX)
id_LDADD += $(LIB_SELINUX)
ls_LDADD += $(LIB_SELINUX)
mkdir_LDADD += $(LIB_SELINUX)
mkfifo_LDADD += $(LIB_SELINUX)
mknod_LDADD += $(LIB_SELINUX)
runcon_LDADD += $(LIB_SELINUX)
stat_LDADD += $(LIB_SELINUX)
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
seq_LDADD = $(LDADD) $(POW_LIB)
# for gettime, settime, utimecmp, utimens
copy_LDADD += $(LIB_CLOCK_GETTIME)
date_LDADD += $(LIB_CLOCK_GETTIME)
ginstall_LDADD += $(LIB_CLOCK_GETTIME)
ls_LDADD += $(LIB_CLOCK_GETTIME)
pr_LDADD += $(LIB_CLOCK_GETTIME)
touch_LDADD += $(LIB_CLOCK_GETTIME)
# If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
# and the `nanosleep' reference in lib/xnanosleep.c.
nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
# for gethrxtime, randint, randread, gen_tempname
dd_LDADD += $(LIB_GETHRXTIME)
mktemp_LDADD += $(LIB_GETHRXTIME)
shred_LDADD += $(LIB_GETHRXTIME)
shuf_LDADD += $(LIB_GETHRXTIME)
sort_LDADD += $(LIB_GETHRXTIME)
# for cap_get_file
ls_LDADD += $(LIB_CAP)
# for fdatasync
dd_LDADD += $(LIB_FDATASYNC)
shred_LDADD += $(LIB_FDATASYNC)
# for strtod, strtold
printf_LDADD += $(POW_LIB)
seq_LDADD += $(POW_LIB)
sleep_LDADD += $(POW_LIB)
sort_LDADD += $(POW_LIB)
tail_LDADD += $(POW_LIB)
uptime_LDADD += $(POW_LIB)
# for xnanosleep
sleep_LDADD += $(LIB_NANOSLEEP)
tail_LDADD += $(LIB_NANOSLEEP)
# for various GMP functions
expr_LDADD = $(LDADD) $(LIB_GMP)
expr_LDADD += $(LIB_GMP)
factor_LDADD += $(LIB_GMP)
# for various GMP functions
factor_LDADD = $(LDADD) $(LIB_GMP)
# for getloadavg
uptime_LDADD += $(GETLOADAVG_LIBS)
sleep_LDADD = $(nanosec_libs)
tail_LDADD = $(nanosec_libs)
# for crypt
su_LDADD += $(LIB_CRYPT)
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
su_LDADD = $(LDADD) $(LIB_CRYPT)
dir_LDADD += $(LIB_ACL)
# for various ACL functions
copy_LDADD += $(LIB_ACL)
ls_LDADD += $(LIB_ACL)
vdir_LDADD += $(LIB_ACL)
cp_LDADD += $(LIB_ACL) $(LIB_XATTR)
mv_LDADD += $(LIB_ACL) $(LIB_XATTR)
ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR)
stat_LDADD = $(LDADD) $(LIB_SELINUX)
# for various xattr functions
copy_LDADD += $(LIB_XATTR)
# Append $(LIBICONV) to each program that uses proper_name_utf8.
# for print_unicode_char, proper_name_utf8
cat_LDADD += $(LIBICONV)
cp_LDADD += $(LIBICONV)
df_LDADD += $(LIBICONV)
du_LDADD += $(LIBICONV)
getlimits_LDADD += $(LIBICONV)
printf_LDADD += $(LIBICONV)
ptx_LDADD += $(LIBICONV)
split_LDADD += $(LIBICONV)
stdbuf_LDADD += $(LIBICONV)
timeout_LDADD += $(LIBICONV)
truncate_LDADD += $(LIBICONV)
# programs that use getaddrinfo (e.g., via canon_host)
pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB)
who_LDADD = $(LDADD) $(GETADDRINFO_LIB)
# for canon_host
pinky_LDADD += $(GETADDRINFO_LIB)
who_LDADD += $(GETADDRINFO_LIB)
# for gethostname, uname
hostname_LDADD += $(GETHOSTNAME_LIB)
uname_LDADD += $(GETHOSTNAME_LIB)
$(PROGRAMS): ../lib/libcoreutils.a
@@ -330,6 +536,61 @@ wheel.h: wheel-gen.pl Makefile.am
# Tell automake to exempt then from that installcheck test.
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
# Compare fs.h with the list of file system names/magic-numbers in the
# Linux statfs man page. This target prints any new name/number pairs.
.PHONY: fs-magic-compare
fs-magic-compare: fs-magic fs-kernel-magic fs-def
join -v1 -t@ fs-magic fs-def
join -v1 -t@ fs-kernel-magic fs-def
CLEANFILES += fs-def
fs-def: fs.h
grep '^# *define ' $< > $@-t && mv $@-t $@
CLEANFILES += fs-magic
fs-magic: Makefile
man statfs \
|perl -ne '/File system types:/.../Nobody kno/ and print' \
|grep 0x | perl -p \
-e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
-e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
-e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
-e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
-e 's/CIFS_MAGIC_NUMBER/CIFS/;' \
-e 's/(_SUPER)?_MAGIC//;' \
-e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
-e 's/^\s+//;' \
-e 's/^_(XIAFS)/$$1/;' \
-e 's/^USBDEVICE/USBDEVFS/;' \
-e 's/NTFS_SB/NTFS/;' \
-e 's/^/# define S_MAGIC_/;' \
-e 's,\s*/\* .*? \*/,,;' \
| grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
| LC_ALL=C sort \
> $@-t && mv $@-t $@
CLEANFILES += fs-kernel-magic
fs-kernel-magic: Makefile
perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \
| perl -p \
-e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
-e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
-e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
-e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
-e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
-e 's/(_SUPER)?_MAGIC//;' \
-e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
-e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
-e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
-e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
-e 's/^#define\s+//;' \
-e 's/^USBDEVICE/USBDEVFS/;' \
-e 's/^/# define S_MAGIC_/;' \
-e 's,\s*/\* .*? \*/,,;' \
| grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
| LC_ALL=C sort \
> $@-t && mv $@-t $@
BUILT_SOURCES += fs.h
fs.h: stat.c extract-magic
$(AM_V_GEN)rm -f $@

231
src/README-rm-timing-2 Normal file
View File

@@ -0,0 +1,231 @@
#!/bin/bash
# Demonstrate >5X speed-up in using fts-based rm on ext4
# Demonstrate 1.5X speed-up in using fts-based rm on reiserfs
set -x
a=$(printf %031d 0)
b=$(printf %031d 1)
(mkdir $a \
&& cd $a \
&& seq --format=%031g 10000 |xargs touch \
&& seq --format=d%030g 10000 |xargs mkdir ) || framework_failure
cp -al $a $b || framework_failure
mkdir e || framework_failure
mv $a $b e || framework_failure
cp -a e 1
cp -a e 2
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
env time /p/bin/rm -rf 1
env time /cu/src/rm -rf 2
cp -a e 1
cp -a e 2
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
env time cu/src/rm -rf 2
env time /p/bin/rm -rf 1
########################################################################
# on ext4
# + env time /p/bin/rm -rf 1
# 0.19user 12.09system 0:14.42elapsed 85%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+212minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.13user 0.93system 0:01.08elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+1235minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + env time /cu/src/rm -rf 2
# 0.12user 0.94system 0:01.07elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+1236minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.19user 12.08system 0:12.33elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+212minor)pagefaults 0swaps
# on reiserfs:
# + env time /p/bin/rm -rf 1
# 0.30user 4.16system 0:04.49elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+168minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.21user 2.47system 0:02.88elapsed 93%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+80outputs (0major+1199minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + env time /cu/src/rm -rf 2
# 0.19user 2.56system 0:02.76elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+1200minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.29user 4.17system 0:04.55elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
# 0inputs+0outputs (0major+168minor)pagefaults 0swaps
########################################################################
# on xfs, F11, slow-disk laptop: (shows slight improvement)
# iou$ bash /cu/src/README-rm-timing-2 :
# ++ printf %031d 0
# + a=0000000000000000000000000000000
# ++ printf %031d 1
# + b=0000000000000000000000000000001
# + mkdir 0000000000000000000000000000000
# + cd 0000000000000000000000000000000
# + xargs touch
# + seq --format=%031g 10000
# + seq --format=d%030g 10000
# + xargs mkdir
# + cp -al 0000000000000000000000000000000 0000000000000000000000000000001
# + mkdir e
# + mv 0000000000000000000000000000000 0000000000000000000000000000001 e
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /p/bin/rm -rf 1
# 1.06user 12.10system 1:41.96elapsed 12%CPU (0avgtext+0avgdata 0maxresident)k
# 16368inputs+0outputs (1major+175minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.57user 5.47system 1:32.69elapsed 6%CPU (0avgtext+0avgdata 0maxresident)k
# 20112inputs+0outputs (1major+1214minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /cu/src/rm -rf 2
# 0.54user 5.34system 1:28.43elapsed 6%CPU (0avgtext+0avgdata 0maxresident)k
# 19032inputs+0outputs (1major+1198minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.99user 12.36system 1:37.36elapsed 13%CPU (0avgtext+0avgdata 0maxresident)k
# 20256inputs+0outputs (1major+174minor)pagefaults 0swaps
########################################################################
# on btrfs, F11, slow-disk laptop: (shows 7-8X speed-up)
# iou$ env time bash /cu/src/README-rm-timing-2 :
# ++ printf %031d 0
# + a=0000000000000000000000000000000
# ++ printf %031d 1
# + b=0000000000000000000000000000001
# + mkdir 0000000000000000000000000000000
# + cd 0000000000000000000000000000000
# + seq --format=%031g 10000
# + xargs touch
# + seq --format=d%030g 10000
# + xargs mkdir
# + cp -al 0000000000000000000000000000000 0000000000000000000000000000001
# + mkdir e
# + mv 0000000000000000000000000000000 0000000000000000000000000000001 e
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /p/bin/rm -rf 1
# 0.51user 59.42system 1:09.73elapsed 85%CPU (0avgtext+0avgdata 0maxresident)k
# 43536inputs+82536outputs (1major+425minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.26user 8.01system 0:08.50elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
# 808inputs+54984outputs (1major+1199minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# 0.26user 8.31system 0:09.17elapsed 93%CPU (0avgtext+0avgdata 0maxresident)k
# 976inputs+47744outputs (1major+1197minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.48user 57.83system 1:04.81elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
# 27408inputs+75632outputs (1major+423minor)pagefaults 0swaps
# ---
# 5.60user 214.36system 4:14.11elapsed 86%CPU (0avgtext+0avgdata 0maxresident)k
# 131544inputs+551320outputs (83major+15945minor)pagefaults 0swaps
########################################################################
# on reiserfs, F11, slow-disk laptop: (shows ~4X speed-up)
# but notice total test time: just 51s, compared with 4:11 for btrfs above.
# iou$ env time bash /cu/src/README-rm-timing-2 :
# ++ printf %031d 0
# + a=0000000000000000000000000000000
# ++ printf %031d 1
# + b=0000000000000000000000000000001
# + mkdir 0000000000000000000000000000000
# + cd 0000000000000000000000000000000
# + seq --format=%031g 10000
# + xargs touch
# + seq --format=d%030g 10000
# + xargs mkdir
# + cp -al 0000000000000000000000000000000 0000000000000000000000000000001
# + mkdir e
# + mv 0000000000000000000000000000000 0000000000000000000000000000001 e
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /p/bin/rm -rf 1
# 0.48user 9.79system 0:10.33elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
# 256inputs+0outputs (1major+191minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.25user 2.15system 0:02.50elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
# 808inputs+0outputs (1major+1198minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /cu/src/rm -rf 2
# 0.26user 2.10system 0:02.46elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k
# 808inputs+0outputs (1major+1198minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.44user 9.89system 0:10.41elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
# 264inputs+0outputs (1major+176minor)pagefaults 0swaps
# ---
# 4.48user 42.92system 0:51.14elapsed 92%CPU (0avgtext+0avgdata 0maxresident)k
# 21680inputs+54232outputs (86major+16962minor)pagefaults 0swaps
########################################################################
# on ext2, F11, slow-disk laptop: (shows ~4X speed-up)
# iou$ env time bash /cu/src/README-rm-timing-2 :
# ++ printf %031d 0
# + a=0000000000000000000000000000000
# ++ printf %031d 1
# + b=0000000000000000000000000000001
# + mkdir 0000000000000000000000000000000
# + cd 0000000000000000000000000000000
# + seq --format=%031g 10000
# + xargs touch
# + seq --format=d%030g 10000
# + xargs mkdir
# + cp -al 0000000000000000000000000000000 0000000000000000000000000000001
# + mkdir e
# + mv 0000000000000000000000000000000 0000000000000000000000000000001 e
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /p/bin/rm -rf 1
# 1.02user 15.25system 0:30.76elapsed 52%CPU (0avgtext+0avgdata 0maxresident)k
# 178888inputs+19144outputs (1major+423minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.40user 2.30system 0:05.99elapsed 45%CPU (0avgtext+0avgdata 0maxresident)k
# 83088inputs+18480outputs (1major+1199minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /cu/src/rm -rf 2
# 0.38user 2.83system 0:08.18elapsed 39%CPU (0avgtext+0avgdata 0maxresident)k
# 85848inputs+16024outputs (1major+1199minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.84user 15.24system 0:25.28elapsed 63%CPU (0avgtext+0avgdata 0maxresident)k
# 178656inputs+18728outputs (1major+423minor)pagefaults 0swaps
# ---
# 6.73user 263.32system 5:27.69elapsed 82%CPU (0avgtext+0avgdata 0maxresident)k
# 780296inputs+891712outputs (86major+17155minor)pagefaults 0swaps
########################################################################
# on tmpfs, F11, slow-disk laptop: (shows ~4X speed-up)
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /p/bin/rm -rf 1
# 0.37user 2.47system 0:03.10elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
# 256inputs+0outputs (1major+175minor)pagefaults 0swaps
# + env time /cu/src/rm -rf 2
# 0.23user 0.41system 0:00.76elapsed 85%CPU (0avgtext+0avgdata 0maxresident)k
# 520inputs+0outputs (1major+2092minor)pagefaults 0swaps
# + cp -a e 1
# + cp -a e 2
# + sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
# + env time /cu/src/rm -rf 2
# 0.24user 0.41system 0:00.73elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
# 800inputs+0outputs (1major+2090minor)pagefaults 0swaps
# + env time /p/bin/rm -rf 1
# 0.36user 2.47system 0:02.86elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
# 256inputs+0outputs (1major+175minor)pagefaults 0swaps

View File

@@ -0,0 +1,297 @@
==================================================
[SSD: it's a toss-up, when removing a million-file (1000 per dir) tree
on (sdd-ocz-summit-120G, F11, x86_64, lots of RAM)
$ z-mktree --root=z --depth=2 --b=1000;env time /p/bin/rm -rf z
0.50user 13.99system 0:17.83elapsed 81%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+10834minor)pagefaults 0swaps
$ z-mktree --root=z --depth=2 --b=1000;env time src/rm -rf z
0.52user 13.88system 0:17.41elapsed 82%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+8outputs (0major+10835minor)pagefaults 0swaps
==================================================
on (tmpfs, F11, x86_64, lots of RAM)
/t, with very deep, narrow tree, new rm is >20% faster:
$ z-mkdir 1000000
$ env time /p/bin/rm -rf $TMPDIR/z
6.25user 12.88system 0:19.22elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+70976minor)pagefaults 0swaps
$ z-mkdir 1000000
env time /bin/rm -rf $TMPDIR/z
$ env time /bin/rm -rf $TMPDIR/z
11.06user 14.32system 0:25.43elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
56inputs+0outputs (1major+79999minor)pagefaults 0swaps
*** slow*DOWN* of ~4% on a 1-1Kdir-1M-file (1k-files-per-dir) hierarchy
again, this is on tmpfs:
$ z-mktree --root=/t/z --depth=2 --b=1000;strace -c /p/bin/rm -rf /t/z
vv$ z-mktree --root=/t/z --depth=2 --b=1000;env time /cu/src/rm -rf /t/z
0.29user 2.75system 0:03.06elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+10834minor)pagefaults 0swaps
$ z-mktree --root=/t/z --depth=2 --b=1000;env time /p/p/coreutils-7.5/bin/rm -rf /t/z
0.14user 2.76system 0:02.92elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+184minor)pagefaults 0swaps
==================================================
[old rm]
iou$ z-mktree --root=/t/z --depth=2 --b=1000;strace -c /p/bin/rm -rf /t/z
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
90.66 0.086370 0 1001002 1 unlinkat
8.72 0.008310 1 10002 getdents64
0.22 0.000214 0 2001 openat
0.20 0.000188 0 2021 close
0.09 0.000089 0 6019 fstat64
0.08 0.000073 0 6003 fcntl64
0.03 0.000028 1 29 12 open
0.00 0.000000 0 4 read
0.00 0.000000 0 1 execve
0.00 0.000000 0 1000 lseek
0.00 0.000000 0 3 3 access
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 2 munmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 19 mmap2
0.00 0.000000 0 1 lstat64
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 fstatat64
------ ----------- ----------- --------- --------- ----------------
100.00 0.095272 1028117 16 total
[new, fts-based rm]
iou$ z-mktree --root=/t/z --depth=2 --b=1000;strace -c ./rm -rf /t/z
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
95.88 0.122730 0 1001001 unlinkat
3.95 0.005058 1 7007 getdents64
0.10 0.000126 0 2022 close
0.05 0.000064 0 1001 openat
0.02 0.000020 0 1017 fstat64
0.00 0.000000 0 4 read
0.00 0.000000 0 29 12 open
0.00 0.000000 0 1 execve
0.00 0.000000 0 3 3 access
0.00 0.000000 0 510 brk
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 2 munmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 19 mmap2
0.00 0.000000 0 1 lstat64
0.00 0.000000 0 3003 fcntl64
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1001 fstatat64
------ ----------- ----------- --------- --------- ----------------
100.00 0.127998 1016627 15 total
iou$ export LC_ALL=C cu:198-rm-fts
iou$ z-mktree --root=/t/z --depth=2 --b=1000;strace -c ./rm -rf /t/z
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
93.49 0.110607 0 1001001 unlinkat
6.32 0.007475 1 7007 getdents64
0.10 0.000124 0 1001 fstatat64
0.06 0.000068 0 479 brk
0.02 0.000018 0 2008 close
0.01 0.000015 0 3003 fcntl64
0.00 0.000000 0 2 read
0.00 0.000000 0 3 open
0.00 0.000000 0 1 execve
0.00 0.000000 0 3 3 access
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 1 munmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 6 mmap2
0.00 0.000000 0 1 lstat64
0.00 0.000000 0 1003 fstat64
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1001 openat
------ ----------- ----------- --------- --------- ----------------
100.00 0.118307 1016526 3 total
iou$ z-mktree --root=/t/z --depth=2 --b=1000;strace -c /p/bin/rm -rf /t/z
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
92.87 0.107659 0 1001002 1 unlinkat
6.59 0.007641 1 10002 getdents64
0.22 0.000252 0 2001 openat
0.15 0.000179 0 6005 fstat64
0.10 0.000113 0 6003 fcntl64
0.05 0.000054 0 1000 lseek
0.02 0.000027 0 2007 close
0.00 0.000000 0 2 read
0.00 0.000000 0 3 open
0.00 0.000000 0 1 execve
0.00 0.000000 0 3 3 access
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 1 munmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 6 mmap2
0.00 0.000000 0 1 lstat64
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 fstatat64
------ ----------- ----------- --------- --------- ----------------
100.00 0.115925 1028047 4 total
**********************************************************************
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time /p/bin/rm -rf /t/z
0.16user 3.35system 0:03.68elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+166minor)pagefaults 0swaps
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time /p/bin/rm -rf /t/z
0.16user 3.12system 0:03.34elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+166minor)pagefaults 0swaps
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time /p/bin/rm -rf /t/z
0.14user 3.12system 0:03.26elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+167minor)pagefaults 0swaps
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time /p/bin/rm -rf /t/z
0.12user 2.98system 0:03.17elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+167minor)pagefaults 0swaps
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time ./rm -rf /t/z
0.68user 3.08system 0:03.76elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1566minor)pagefaults 0swaps
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time ./rm -rf /t/z
0.64user 3.12system 0:03.79elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1565minor)pagefaults 0swaps
iou$ z-mktree --root=/t/z --depth=2 --b=1000;env time ./rm -rf /t/z
0.60user 3.09system 0:03.78elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1566minor)pagefaults 0swaps
************************************************************************
************************************************************************
The above are relatively normal hierarchies.
Here is one that is extreme (/t is a tmpfs file system):
[shows that fts-based rm takes 20-25% more time than the old one]
iou$ mkdir .j && (cd .j && seq 1000000|xargs touch)
iou$ env time ./rm -rf /t/.j cu:198-rm-fts
0.10user 0.41system 0:00.59elapsed 87%CPU (0avgtext+0avgdata 0maxresident)k
256inputs+0outputs (1major+4459minor)pagefaults 0swaps
iou$ env time ./rm -rf /t/.j cu:198-rm-fts
0.82user 3.48system 0:04.35elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
256inputs+0outputs (1major+43130minor)pagefaults 0swaps
iou$ env time /p/bin/rm -rf /t/.j cu:198-rm-fts
0.14user 3.02system 0:03.25elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
256inputs+0outputs (1major+164minor)pagefaults 0swaps
iou$ env time strace -c /p/bin/rm -rf /t/.j cu:198-rm-fts
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
95.49 0.122568 0 1000002 1 unlinkat
4.51 0.005785 1 7797 getdents64
0.00 0.000000 0 2 read
0.00 0.000000 0 3 open
0.00 0.000000 0 7 close
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 lseek
0.00 0.000000 0 3 3 access
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 1 munmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 6 mmap2
0.00 0.000000 0 1 lstat64
0.00 0.000000 0 5 fstat64
0.00 0.000000 0 3 fcntl64
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 fstatfs64
0.00 0.000000 0 1 openat
0.00 0.000000 0 1 fstatat64
------ ----------- ----------- --------- --------- ----------------
100.00 0.128353 1007844 4 total
2.96user 21.57system 0:24.80elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
8inputs+0outputs (0major+406minor)pagefaults 0swaps
iou$ env time strace -c ./rm -rf /t/.j cu:198-rm-fts
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
83.46 0.160976 0 1000001 unlinkat
14.54 0.028036 21 1306 brk
2.01 0.003873 0 7795 getdents64
0.00 0.000000 0 2 read
0.00 0.000000 0 3 open
0.00 0.000000 0 8 close
0.00 0.000000 0 1 execve
0.00 0.000000 0 3 3 access
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 1 munmap
0.00 0.000000 0 4 mprotect
0.00 0.000000 0 6 mmap2
0.00 0.000000 0 1 lstat64
0.00 0.000000 0 3 fstat64
0.00 0.000000 0 3 fcntl64
0.00 0.000000 0 1 set_thread_area
0.00 0.000000 0 1 fstatfs64
0.00 0.000000 0 1 openat
0.00 0.000000 0 1 fstatat64
------ ----------- ----------- --------- --------- ----------------
100.00 0.192885 1009142 3 total
3.86user 22.06system 0:26.30elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+43371minor)pagefaults 0swaps
======================================================
# On a faster system, the new fts-based rm still takes a 20% perf. hit,
# probably due to malloc (ab)use, just like above. Yep, sure looks like it.
# in /tmpfs, /t
mkdir .j && (cd .j && seq 1000000|xargs touch)
vv$ env time /p/p/coreutils-7.5/bin/rm -rf .j
0.14user 2.81system 0:02.98elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
264inputs+0outputs (1major+174minor)pagefaults 0swaps
vv$ cd /t; env time /cu/src/rm -rf .j
0.38user 3.17system 0:03.57elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+70489minor)pagefaults 0swaps
vv$ strace -c /p/p/coreutils-7.5/bin/rm -rf .j
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
66.41 0.081223 0 1000002 1 unlinkat
33.43 0.040887 42 978 getdents
0.16 0.000199 199 1 execve
0.00 0.000000 0 1 read
0.00 0.000000 0 3 open
0.00 0.000000 0 7 close
0.00 0.000000 0 6 fstat
0.00 0.000000 0 1 lstat
0.00 0.000000 0 1 lseek
0.00 0.000000 0 9 mmap
0.00 0.000000 0 3 mprotect
0.00 0.000000 0 1 munmap
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 1 1 access
0.00 0.000000 0 3 fcntl
0.00 0.000000 0 1 fstatfs
0.00 0.000000 0 1 arch_prctl
0.00 0.000000 0 1 openat
0.00 0.000000 0 1 newfstatat
------ ----------- ----------- --------- --------- ----------------
100.00 0.122309 1001025 2 total
vv$ cd /t; strace -c /cu/src/rm -rf .j
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
51.26 0.087638 0 1000001 unlinkat
26.49 0.045291 46 976 getdents
22.24 0.038024 18 2134 brk
0.00 0.000000 0 1 read
0.00 0.000000 0 3 open
0.00 0.000000 0 8 close
0.00 0.000000 0 4 fstat
0.00 0.000000 0 1 lstat
0.00 0.000000 0 9 mmap
0.00 0.000000 0 3 mprotect
0.00 0.000000 0 1 munmap
0.00 0.000000 0 1 ioctl
0.00 0.000000 0 1 1 access
0.00 0.000000 0 1 execve
0.00 0.000000 0 3 fcntl
0.00 0.000000 0 1 fstatfs
0.00 0.000000 0 1 arch_prctl
0.00 0.000000 0 1 openat
0.00 0.000000 0 1 newfstatat
------ ----------- ----------- --------- --------- ----------------
100.00 0.170953 1003151 1 total

View File

@@ -519,10 +519,6 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
if (is_selinux_enabled () != 1)
error (EXIT_FAILURE, 0,
_("%s may be used only on a SELinux kernel"), program_name);
if (reference_file)
{
if (getfilecon (reference_file, &ref_context) < 0)

View File

@@ -91,7 +91,7 @@ set_additional_groups (char const *groups)
}
if (n_gids == n_gids_allocated)
gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids);
gids = X2NREALLOC (gids, &n_gids_allocated);
gids[n_gids++] = value;
}

View File

@@ -123,20 +123,12 @@ static char const *top_level_dst_name;
static inline int
utimens_symlink (char const *file, struct timespec const *timespec)
{
int err = 0;
#if HAVE_UTIMENSAT
err = utimensat (AT_FDCWD, file, timespec, AT_SYMLINK_NOFOLLOW);
int err = lutimens (file, timespec);
/* When configuring on a system with new headers and libraries, and
running on one with a kernel that is old enough to lack the syscall,
utimensat fails with ENOSYS. Ignore that. */
if (err && errno == ENOSYS)
err = 0;
#else
(void) file;
(void) timespec;
#endif
return err;
}

View File

@@ -67,7 +67,7 @@ static void
emit_factor (mpz_t n)
{
if (nfactors_found == nfactors_allocated)
factor = x2nrealloc (factor, &nfactors_allocated, sizeof *factor);
factor = X2NREALLOC (factor, &nfactors_allocated);
mpz_init (factor[nfactors_found]);
mpz_set (factor[nfactors_found], n);
++nfactors_found;

View File

@@ -2802,17 +2802,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
: lgetfilecon (absolute_name, &f->scontext));
err = (attr_len < 0);
/* Contrary to its documented API, getfilecon may return 0,
yet set f->scontext to NULL (on at least Debian's libselinux1
2.0.15-2+b1), so work around that bug.
FIXME: remove this work-around in 2011, or whenever affected
versions of libselinux are long gone. */
if (attr_len == 0)
{
err = 0;
f->scontext = xstrdup ("unlabeled");
}
if (err == 0)
have_selinux = ! STREQ ("unlabeled", f->scontext);
else

View File

@@ -251,11 +251,10 @@ static bool
split_3 (char *s, size_t s_len,
unsigned char **hex_digest, int *binary, char **file_name)
{
size_t i;
bool escaped_filename = false;
size_t algo_name_len;
i = 0;
size_t i = 0;
while (ISWHITE (s[i]))
++i;
@@ -263,11 +262,13 @@ split_3 (char *s, size_t s_len,
algo_name_len = strlen (DIGEST_TYPE_STRING);
if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
{
if (strncmp (s + i + algo_name_len, " (", 2) == 0)
if (s[i + algo_name_len] == ' ')
++i;
if (s[i + algo_name_len] == '(')
{
*binary = 0;
return bsd_split_3 (s + i + algo_name_len + 2,
s_len - (i + algo_name_len + 2),
return bsd_split_3 (s + i + algo_name_len + 1,
s_len - (i + algo_name_len + 1),
hex_digest, file_name);
}
}

View File

@@ -110,7 +110,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, 0, _("invalid group %s"),
quote (gr));
if (n_gids == n_gids_allocated)
gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids);
gids = X2NREALLOC (gids, &n_gids_allocated);
gids[n_gids++] = tmp_ul;
if (*ptr == '\0')

View File

@@ -219,25 +219,39 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "adfs";
case S_MAGIC_AFFS: /* 0xADFF */
return "affs";
case S_MAGIC_AUTOFS: /* 0x187 */
case S_MAGIC_AFS: /* 0x5346414F */
return "afs";
case S_MAGIC_ANON_INODE_FS: /* 0x09041934 */
return "anon-inode FS";
case S_MAGIC_AUTOFS: /* 0x0187 */
return "autofs";
case S_MAGIC_BEFS: /* 0x42465331 */
return "befs";
case S_MAGIC_BFS: /* 0x1BADFACE */
return "bfs";
case S_MAGIC_BINFMT_MISC: /* 0x42494e4d */
case S_MAGIC_BINFMT_MISC: /* 0x42494E4D */
return "binfmt_misc";
case S_MAGIC_BTRFS: /* 0x9123683E */
return "btrfs";
case S_MAGIC_CGROUP: /* 0x0027E0EB */
return "cgroupfs";
case S_MAGIC_CIFS: /* 0xFF534D42 */
return "cifs";
case S_MAGIC_CODA: /* 0x73757245 */
return "coda";
case S_MAGIC_COH: /* 0x012FF7B7 */
return "coh";
case S_MAGIC_CRAMFS: /* 0x28CD3D45 */
return "cramfs";
case S_MAGIC_CRAMFS_WEND: /* 0x453DCD28 */
return "cramfs-wend";
case S_MAGIC_DEBUGFS: /* 0x64626720 */
return "debugfs";
case S_MAGIC_DEVFS: /* 0x1373 */
return "devfs";
case S_MAGIC_DEVPTS: /* 0x1CD1 */
return "devpts";
case S_MAGIC_EFS: /* 0x414A53 */
case S_MAGIC_EFS: /* 0x00414A53 */
return "efs";
case S_MAGIC_EXT: /* 0x137D */
return "ext";
@@ -249,20 +263,26 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "fat";
case S_MAGIC_FUSECTL: /* 0x65735543 */
return "fusectl";
case S_MAGIC_FUTEXFS: /* 0x0BAD1DEA */
return "futexfs";
case S_MAGIC_HFS: /* 0x4244 */
return "hfs";
case S_MAGIC_HPFS: /* 0xF995E849 */
return "hpfs";
case S_MAGIC_HUGETLBFS: /* 0x958458f6 */
case S_MAGIC_HUGETLBFS: /* 0x958458F6 */
return "hugetlbfs";
case S_MAGIC_INOTIFYFS: /* 0x2BAD1DEA */
return "inotifyfs";
case S_MAGIC_ISOFS: /* 0x9660 */
return "isofs";
case S_MAGIC_ISOFS_R_WIN: /* 0x4004 */
return "isofs";
case S_MAGIC_ISOFS_WIN: /* 0x4000 */
return "isofs";
case S_MAGIC_JFFS2: /* 0x72B6 */
return "jffs2";
case S_MAGIC_JFFS: /* 0x07C0 */
return "jffs";
case S_MAGIC_JFFS2: /* 0x72B6 */
return "jffs2";
case S_MAGIC_JFS: /* 0x3153464A */
return "jfs";
case S_MAGIC_LUSTRE: /* 0x0BD00BD0 */
@@ -275,6 +295,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "minix v2";
case S_MAGIC_MINIX_V2_30: /* 0x2478 */
return "minix v2 (30 char.)";
case S_MAGIC_MINIX_V3: /* 0x4D5A */
return "minux3";
case S_MAGIC_MSDOS: /* 0x4D44 */
return "msdos";
case S_MAGIC_NCP: /* 0x564C */
@@ -283,9 +305,11 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "nfs";
case S_MAGIC_NFSD: /* 0x6E667364 */
return "nfsd";
case S_MAGIC_NILFS: /* 0x3434 */
return "nilfs";
case S_MAGIC_NTFS: /* 0x5346544E */
return "ntfs";
case S_MAGIC_OPENPROM: /* 0x9fa1 */
case S_MAGIC_OPENPROM: /* 0x9FA1 */
return "openprom";
case S_MAGIC_PROC: /* 0x9FA0 */
return "proc";
@@ -297,6 +321,10 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "reiserfs";
case S_MAGIC_ROMFS: /* 0x7275 */
return "romfs";
case S_MAGIC_SECURITYFS: /* 0x73636673 */
return "securityfs";
case S_MAGIC_SELINUX: /* 0xF97CFF8C */
return "selinux";
case S_MAGIC_SMB: /* 0x517B */
return "smb";
case S_MAGIC_SQUASHFS: /* 0x73717368 */
@@ -307,7 +335,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "sysv2";
case S_MAGIC_SYSV4: /* 0x012FF7B5 */
return "sysv4";
case S_MAGIC_TMPFS: /* 0x1021994 */
case S_MAGIC_TMPFS: /* 0x01021994 */
return "tmpfs";
case S_MAGIC_UDF: /* 0x15013346 */
return "udf";
@@ -319,6 +347,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "usbdevfs";
case S_MAGIC_VXFS: /* 0xA501FCF5 */
return "vxfs";
case S_MAGIC_XENFS: /* 0xABBA1974 */
return "xenfs";
case S_MAGIC_XENIX: /* 0x012FF7B4 */
return "xenix";
case S_MAGIC_XFS: /* 0x58465342 */
@@ -872,7 +902,12 @@ do_stat (char const *filename, bool terse, char const *format)
return false;
}
}
else if ((follow_links ? stat : lstat) (filename, &statbuf) != 0)
/* We can't use the shorter
(follow_links ? stat : lstat) (filename, &statbug)
since stat might be a function-like macro. */
else if ((follow_links
? stat (filename, &statbuf)
: lstat (filename, &statbuf)) != 0)
{
error (0, errno, _("cannot stat %s"), quote (filename));
return false;

View File

@@ -24,8 +24,10 @@
#include "system.h"
#include "error.h"
#include "filenamecat.h"
#include "posixver.h"
#include "quote.h"
#include "xreadlink.h"
#include "xstrtol.h"
#include "c-ctype.h"
@@ -35,9 +37,6 @@
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
/* Internal error */
enum { EXIT_CANCELED = 125 };
static char *program_path;
extern char **environ;
@@ -145,34 +144,26 @@ set_program_path (const char *arg)
}
else
{
char *path;
char tmppath[PATH_MAX + 1];
ssize_t len = readlink ("/proc/self/exe", tmppath, sizeof (tmppath) - 1);
if (len > 0)
{
tmppath[len] = '\0';
program_path = dir_name (tmppath);
}
char *path = xreadlink ("/proc/self/exe");
if (path)
program_path = dir_name (path);
else if ((path = getenv ("PATH")))
{
char *dir;
path = xstrdup (path);
for (dir = strtok (path, ":"); dir != NULL; dir = strtok (NULL, ":"))
{
int req = snprintf (tmppath, sizeof (tmppath), "%s/%s", dir, arg);
if (req >= sizeof (tmppath))
char *candidate = file_name_concat (dir, arg, NULL);
if (access (candidate, X_OK) == 0)
{
error (0, 0, _("path truncated when looking for %s"),
quote (arg));
}
else if (access (tmppath, X_OK) == 0)
{
program_path = dir_name (tmppath);
program_path = dir_name (candidate);
free (candidate);
break;
}
free (candidate);
}
free (path);
}
free (path);
}
}

View File

@@ -44,16 +44,8 @@ you must include <sys/types.h> before including this file
#include "configmake.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <sys/time.h>
#include <time.h>
/* Since major is a function on SVR4, we can't use `ifndef major'. */
#if MAJOR_IN_MKDEV
@@ -86,16 +78,8 @@ you must include <sys/types.h> before including this file
#include <errno.h>
/* Some systems don't define the following symbols. */
#ifndef EDQUOT
# define EDQUOT (-1)
#endif
#ifndef EISDIR
# define EISDIR (-1)
#endif
#ifndef ENOSYS
# define ENOSYS (-1)
#endif
/* Some systems don't define this; POSIX mentions it but says it is
obsolete, so gnulib does not provide it either. */
#ifndef ENODATA
# define ENODATA (-1)
#endif
@@ -107,8 +91,10 @@ you must include <sys/types.h> before including this file
/* Exit statuses for programs like 'env' that exec other programs. */
enum
{
EXIT_CANNOT_INVOKE = 126,
EXIT_ENOENT = 127
EXIT_TIMEDOUT = 124, /* Time expired before child completed. */
EXIT_CANCELED = 125, /* Internal error prior to exec attempt. */
EXIT_CANNOT_INVOKE = 126, /* Program located, but not usable. */
EXIT_ENOENT = 127 /* Could not find program to exec. */
};
#include "exitfail.h"
@@ -123,13 +109,6 @@ initialize_exit_failure (int status)
#include <fcntl.h>
#ifndef F_OK
# define F_OK 0
# define X_OK 1
# define W_OK 2
# define R_OK 4
#endif
#include <dirent.h>
#ifndef _D_EXACT_NAMLEN
# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
@@ -279,30 +258,6 @@ select_plural (uintmax_t n)
#define STREQ(a, b) (strcmp (a, b) == 0)
#if !HAVE_DECL_FREE
void free ();
#endif
#if !HAVE_DECL_MALLOC
char *malloc ();
#endif
#if !HAVE_DECL_MEMCHR
char *memchr ();
#endif
#if !HAVE_DECL_REALLOC
char *realloc ();
#endif
#if !HAVE_DECL_GETENV
char *getenv ();
#endif
#if !HAVE_DECL_LSEEK
off_t lseek ();
#endif
#if !HAVE_DECL_GETLOGIN
char *getlogin ();
#endif
@@ -547,10 +502,6 @@ enum
while (0)
#endif
#ifndef EOVERFLOW
# define EOVERFLOW EINVAL
#endif
#if ! HAVE_SYNC
# define sync() /* empty */
#endif

View File

@@ -73,12 +73,6 @@
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
/* Note ETIMEDOUT is 110 on GNU/Linux systems but this is non standard */
#define EXIT_TIMEDOUT 124
/* Internal failure. */
#define EXIT_CANCELED 125
static int timed_out;
static int term_signal = SIGTERM; /* same default as kill command. */
static int monitored_pid;

View File

@@ -22,6 +22,7 @@
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <assert.h>
#include "system.h"
#include "argmatch.h"
@@ -119,11 +120,9 @@ static bool
touch (const char *file)
{
bool ok;
struct stat sbuf;
int fd = -1;
int open_errno = 0;
struct timespec timespec[2];
struct timespec const *t;
struct timespec const *t = newtime;
if (STREQ (file, "-"))
fd = STDOUT_FILENO;
@@ -144,24 +143,13 @@ touch (const char *file)
if (change_times != (CH_ATIME | CH_MTIME))
{
/* We're setting only one of the time values. stat the target to get
the other one. If we have the file descriptor already, use fstat.
Otherwise, either we're in no-create mode (and hence didn't call open)
or FILE is inaccessible or a directory, so we have to use stat. */
if (fd != -1 ? fstat (fd, &sbuf) : stat (file, &sbuf))
/* We're setting only one of the time values. */
if (change_times == CH_MTIME)
newtime[0].tv_nsec = UTIME_OMIT;
else
{
if (open_errno)
error (0, open_errno, _("creating %s"), quote (file));
else
{
if (no_create && (errno == ENOENT || errno == EBADF))
return true;
error (0, errno, _("failed to get attributes of %s"),
quote (file));
}
if (fd == STDIN_FILENO)
close (fd);
return false;
assert (change_times == CH_ATIME);
newtime[1].tv_nsec = UTIME_OMIT;
}
}
@@ -171,16 +159,6 @@ touch (const char *file)
write access to the file, but don't own it. */
t = NULL;
}
else
{
timespec[0] = (change_times & CH_ATIME
? newtime[0]
: get_stat_atime (&sbuf));
timespec[1] = (change_times & CH_MTIME
? newtime[1]
: get_stat_mtime (&sbuf));
t = timespec;
}
ok = (gl_futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
@@ -195,8 +173,7 @@ touch (const char *file)
else if (fd == STDOUT_FILENO)
{
/* Do not diagnose "touch -c - >&-". */
if (!ok && errno == EBADF && no_create
&& change_times == (CH_ATIME | CH_MTIME))
if (!ok && errno == EBADF && no_create)
return true;
}
@@ -429,10 +406,7 @@ main (int argc, char **argv)
if (change_times == (CH_ATIME | CH_MTIME))
amtime_now = true;
else
{
gettime (&newtime[0]);
newtime[1] = newtime[0];
}
newtime[1].tv_nsec = newtime[0].tv_nsec = UTIME_NOW;
}
if (optind == argc)

View File

@@ -218,6 +218,7 @@ TESTS = \
misc/stat-fmt \
misc/stat-hyphen \
misc/stat-printf \
misc/stat-slash \
misc/stdbuf \
misc/stty \
misc/stty-invalid \

View File

@@ -24,6 +24,7 @@ fi
. $srcdir/test-lib.sh
grep '^#define HAVE_UTIMENSAT' "$CONFIG_HEADER" > /dev/null ||
grep '^#define HAVE_LUTIMES' "$CONFIG_HEADER" > /dev/null ||
skip_test_ 'this system lacks the utimensat function'
ln -s no-such dangle || framework_failure
@@ -34,6 +35,7 @@ case $(stat --format=%y dangle) in
??:??:??.000000000) sleep 2;;
esac
# Can't use --format=%x, as lstat() modifies atime on some platforms.
cp -Pp dangle d2 || framework_failure
stat --format=%y dangle > t1 || framework_failure
stat --format=%y d2 > t2 || framework_failure

View File

@@ -67,6 +67,16 @@ my @Tests =
['check-bsd3', '--check', '--status',
{IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['check-openssl', '--check', {IN=> {'f.sha1' => "SHA1(f)= $degenerate\n"}},
{AUX=> {f=> ''}},
{ERR=>"md5sum: f.sha1: no properly formatted "
. "MD5 checksum lines found\n"},
{EXIT=> 1}],
['check-openssl2', '--check', {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}},
{AUX=> {f=> ''}}, {OUT=>"f: OK\n"}],
['check-openssl3', '--check', '--status',
{IN=> {'f.md5' => "MD5(f)= $degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1},
{ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}],

View File

@@ -60,6 +60,17 @@ my @Tests =
['check-bsd3', '--check', '--status',
{IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['check-openssl', '--check', {IN=> {'f.md5' => "MD5(f)= $sha_degenerate\n"}},
{AUX=> {f=> ''}},
{ERR=>"sha1sum: f.md5: no properly formatted "
. "SHA1 checksum lines found\n"},
{EXIT=> 1}],
['check-openssl2', '--check',
{IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}},
{AUX=> {f=> ''}}, {OUT=>"f: OK\n"}],
['check-openssl3', '--check', '--status',
{IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}},
{AUX=> {f=> 'bar'}}, {EXIT=> 1}],
['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1},
{ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}],
);

49
tests/misc/stat-slash Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/sh
# demonstrate that stat handles trailing slashes correctly
# Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
stat --version
fi
. $srcdir/test-lib.sh
touch file || framework_failure
mkdir dir || framework_failure
ln -s file link1 || framework_failure
ln -s dir link2 || framework_failure
cat <<EOF > exp || framework_failure
link1
symbolic link
directory
directory
EOF
fail=0
# This failed on Solaris 9 for coreutils 8.0.
stat --format=%n link1 > out || fail=1
stat --format=%n link1/ >> out && fail=1
stat --format=%F link2 >> out || fail=1
stat -L --format=%F link2 >> out || fail=1
stat --format=%F link2/ >> out || fail=1
compare out exp || fail=1
Exit $fail