* lib/fdleak.c: Include <stdarg.h> and "cloexec.h".
(open_cloexec): Support O_CREAT. Use O_CLOEXEC if it is available.
(O_CLOEXEC): #define to 0 if not already #defined.
* import-gnulib.config (modules): Import modules open (for
PROMOTED_MODE_T) and stdbool (for 'true').
* lib/fdleak.h: Update prototype of open_cloexec to allow mode to
be passed.
Signed-off-by: James Youngman <jay@gnu.org>
* configure.ac: Check for <sys/resource.h> and the getrusage
function.
* lib/fdleak.c: Don't #include <sys/resource.h> if we don't have it.
(get_max_fd): If neither /proc/self/fd not getrusage is available,
return _POSIX_OPEN_MAX.
(remember_non_cloexec_fds): Also check for leaks in file
descriptors 0, 1, 2, just in case the caller closed them.
(find_first_leaked_fd): Likewise.
(open_cloexec): Make sure we are not creating a file (for some odd
system where O_CREAT is 0).
Signed-off-by: James Youngman <jay@gnu.org>
* find/pred.c (do_fprintf): If getfilecon fails, print the
relevant segment anyway, with the file context expanding to an
empty string.
* find/parser.c (make_segment): For %Z, set the cost to
NeedsAccessInfo.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (gnulib_version): Update to more recent
version of gnulib. Import the cloexec module too.
* lib/fdleak.c: New file; a module for detecting file descriptor
leaks. Also define an open_cloexec() function.
* lib/fdleak.h: Declare the global functions defined in fdleak.c.
* lib/Makefile.am (libfind_a_SOURCES): Add fdleak.c and fdleak.h.
* find/find.c (main): Call remember_non_cloexec_fds in order to
detect file descriptor leaks.
(main): set FD_CLOEXEC on starting_desc.
(safely_chdir_lstat): Likewise for dotfd.
(safely_chdir_nofollow): Likewise for fd.
* find/ftsfind.c (inside_dir): set FD_CLOEXEC on curr_fd.
(main): Call remember_non_cloexec_fds in order to detect file
descriptor leaks.
(main): set FD_CLOEXEC on starting_desc.
* find/pred.c (launch): before we exec the child, call
complain_about_leaky_fds in order to complain about non-FD_CLOEXEC
file descriptors that weren't open when the program was run.
* find/sharefile.c (sharefile_fopen): Set FD_CLOEXEC on the files
we open.
* gnulib-local/lib/save-cwd.c.diff: Patch gnulib to set FD_CLOEXEC
on the file descriptors opened by save_cwd.
* gnulib-local/modules/save-cwd.diff: Hence the save-cwd module
depends on the cloexec module.
* import-gnulib.sh (run_gnulib_tool): Pass the --local-dir option
in order to apply these patches.
Signed-off-by: James Youngman <jay@gnu.org>
* find/find.1 (-iname): We already refer to -name, so duplicate
less text.
(-name): Explain that -name a/b will never match anything.
* doc/find.texi (Base Name Patterns): Explain that -name a/b will
never match anything.
(Full Name Patterns): Fix typo.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (gnulib_version): Update $gnulib_version.
* build-aux/.cvsignore: Ignore new files built by gnulib.
* build-aux/.gitignore: Likewise.
Signed-off-by: James Youngman <jay@gnu.org>
* xargs/xargs.c (smaller_of): New function, returns the smaller of
its two size_t arguments.
(main): Instead of asserting that the value of bc_ctl.arg_max is
smaller than some value, simply adjust the value if necessary.
Signed-off-by: James Youngman <jay@gnu.org>
* doc/find.texi (Problems with -exec and filenames): Add missing
$0 argument in example for sh -c 'something "$@" sh ...
* NEWS: Mention this change.
Signed-off-by: James Youngman <jay@gnu.org>
* find/parser.c (parse_fls): If the argument is invalid, reverse
the change that collect_arg() made to *arg_ptr (that is, don't
consume the argument).
(parse_fprint0): Likewise.
(parse_gid): Likewise.
(parse_group): Likewise.
(parse_inum): Likewise.
(parse_links): Likewise.
(do_parse_xmin): Likewise.
(parse_name): Likewise.
(parse_printf): Likewise.
(parse_uid): Likewise.
(parse_used): Likewise.
(parse_time): Likewise.
* NEWS: mention this change.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (modules): Include gnulib's math module, to
avoid a compilation error for "-HUGE_VAL" on Solaris x86_64.
* NEWS: Mention this change.
Signed-off-by: James Youngman <jay@gnu.org>
* find/testsuite/find.posix/exec-nogaps.exp: New test for find
-exec ... {} ; and find -exec ... {} +, both of which simply
ensure that all exec arguments are processed exactly once each.
* find/testsuite/find.posix/exec-nogaps.xo: Expected output file
for the test in exec-nogaps.exp.
Signed-off-by: James Youngman <jay@gnu.org>
2009-11-29 James Youngman <jay@gnu.org>
Fix Savannah bug#27328, segfault if the initial exec for "find
-exec" fails. Also bug #27975: Infinite loop for -exec [..] {} +.
* lib/buildcmd.h (struct buildcmd_state): Introduce
largest_successful_arg_count and smallest_failed_arg_count in
order to avoid an assumption that we understand how the operatingn
system interprets ARG_MAX and the assumption that the compile-time
ARG_MAX value (or the equivalent from sysconf()) is avtually
correct.
(struct buildcmd_control): Change the calling convention of the
exec callback to allow us to pass the argument list separately.
(bc_args_exceed_testing_limit): declare this new funciton.
* lib/buildcmd.c (bc_args_complete): New function, NULL-terminates
the argv list. We use this instead of passing NULL to
bc_push_arg().
(update_limit): New function. Decides how many arguments to
pass to the invoked command on the next attempt.
(copy_args): Build an argument list containing all the initial
arguments plus some of the other args (the number to be used is
decided by update_limit).
(bc_do_exec): Avoid special-casing the first call to exec. Use
update_limit to decide how many arguments to pass and copy_args to
build the argument list. The new form of the loop should fix
Savannah bug #27328.
(bc_push_arg): Drop support for passing NULL as an argument (to
terminate the arg list we just pass in a special argument instead).
(bc_args_exceed_testing_limit): New function, returns nonzero if
the argument list exceeds a testing limit (used for failure
injection by tests).
(exceeds): New support function, implementing part of
bc_args_exceed_testing_limit.
(bc_init_state): Initialise largest_successful_arg_count and
smallest_failed_arg_count.
* find/defs.h (struct exec_val): New member last_child_status.
This stores the status of the most recently completed child.
* find/pred.c (new_impl_pred_exec): Use last_child_status.
(launch): Use the new calling convention for the exec callback.
Set last_child_status. Call bc_args_exceed_testing_limit() to do
failure injection for unit tests.
* find/util.c (do_complete_pending_execdirs): Call bc_do_exec
rather than calling launch directly in order to allow for breaking
the argument list up if it's too long.
* xargs/xargs.c (xargs_do_exec): Update to use the new caling
convention for the exec callback.
Signed-off-by: James Youngman <jay@gnu.org>
James Youngman wrote:
> On Fri, Oct 23, 2009 at 6:09 PM, Jorma Karvonen
> <karvonen.jorma@gmail.com> wrote:
>> Hello,
>>
>> here are some messages that probably need to be localized. I have
>> shown them in localized form:
>
> Thanks, I'm not sure which version of findutils you started with, but
> since you gave the strings too, I had no problems finding the messages
> you were referring to. A couple of them were obsolete, but thanks for
> finding the ones that were still in there!
>
> I have left a few of the messages un-translated as they're just debug
> messages. I attach the patch I just pushed.
>
> Thanks again!
> James.
...
> - const char *errmsg = "arithmetic overflow while converting %s "
> - "days to a number of seconds";
> + const char *errmsg = _("arithmetic overflow while converting %s "
> + "days to a number of seconds");
> struct timespec origin;
>
> if (!collect_arg(argv, arg_ptr, &timearg))
Hi James,
I spotted at least one more with this:
$ grep -nE '\<error \([^"]*"[^"]*[a-z]{3}' $(g ls-files) | grep -v '_('
xargs/xargs.c:1009: error (1, errno, "/dev/tty");
xargs/xargs.c:1093: error (1, errno, "could not create pipe before fork");
Regarding this one,
xargs/xargs.c:1009: error (1, errno, "/dev/tty");
it's better for those on the receiving end of such a diagnostic
to say what operation was being attempted, so...
[btw, the above check for unmarked-yet-translatable diagnostics is automated
in gnulib's maint.mk. If you're interested, running "make syntax-check"
can detect problems like this; to enable, use gnulib's maintainer-makefile
module. ]
From 333b90e420200f8c083264ba1781dc01221d2807 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Mon, 9 Nov 2009 10:39:35 +0100
Subject: [PATCH] Adjust two xargs diagnostics.
* xargs/xargs.c (print_args): Give a better diagnostic when
failing to open /dev/tty.
(xargs_do_exec): Mark a diagnostic for translation.
* lib/check-regexprops.sh: Portability fixes for FreeBSD (mktemp
requires an argument, dialect differences in sed regexes).
Signed-off-by: James Youngman <jay@gnu.org>
Fix up some problems introduced in a manual conflict resolution.
* find/parser.c (insert_path_check): Add missing third argument to
insert_primary_withpred.
(parse_iwholename): Remove redundant extra definition.
(parse_ipath): Likewise.
Fix Savannah bug #27017: find -D opt / -fstype ext3 -print , -quit
coredumps.
* find/tree.c (set_new_parent): Initialise struct
predicate->arg_text to NULL (instead of leaving it uninitialised).
(get_new_pred_noarg): Likewise.
(get_new_pred): Initialise predicate->arg_text to
"ThisShouldBeSetToSomethingElse" to make it easier to notice
bugs.
(get_new_pred_chk_op): Use get_new_pred_noarg.
(print_predicate): Use an if statement instead of
two ternary operators.
* find/util.c (insert_primary_withpred): Accept new argument, arg,
being the argument (if any) of this predicate. Pass it to
get_new_pred_chk_op.
(insert_primary): Likewise (pass arg to insert_primary_withpred).
(insert_primary_noarg): New function; calls insert_primary with
arg=NULL.
* find/parser.c (collect_arg_stat_info): Add an output parameter;
the filename from which we collected the stat information.
(parse_closeparen, parse_delete, parse_and, parse_or,
parse_comma): Use get_new_pred_noarg.
(parse_cnewer, parse_newer, parse_anewer): Use new
collect_arg_stat_info and insert_primary interface.
(parse_print, parse_prune, parse_nouser, parse_empty): Use
insert_primary_noarg.
(parse_accesscheck, parse_false): Use insert_primary_noarg.
(parse_used, parse_iname, parse_fprint, insert_fprint,
parse_fstype, parse_ilname): Use new collect_arg and
insert_primary interfaces.
(parse_ipath, parse_lname, do_parse_xmin, parse_name, parse_path,
parse_perm, parse_size, parse_user, parse_time): Use new
collect_arg and insert_primary_withpred interface.
(parse_negate, parse_openparen): Use new get_new_pred_chk_op interface.
(parse_newerXY, parse_nogroup): Use new insert_primary interface.
(insert_regex, parse_samefile): Use new insert_primary_withpred
interface.
(insert_type, insert_fprintf, new_insert_exec_ok, insert_num): Use
new insert_primary_withpred interface.
* find/defs.h (struct predicate.arg_text): make const.
Add declarations for new function get_new_pred_noarg and
insert_primary_noarg. Add 'arg' parameter to get_new_pred_chk_op
and insert_primary_withpred.
Savannah bug #23920: warn about -path arguments ending in /.
* find/parser.c (insert_path_check): new function; abstracts the
common functionality of parse_path, parse_ipath, parse_wholename,
parse_iwholename. Also check for a trailing slash and warn about
it (unless $POSIXLY_CORRECT is set). Don't warn if the pattern
also happens to be a start_point, because those could be matched.
(parse_path, parse_ipath, parse_wholename, parse_iwholename): Use
insert_path_check.
* find/tree.c (is_start_point): new function; returns true if the
indidated string matches a start point.
(num_start_points, start_points): new variables, storing the
starting points listed on the command line.
(build_expression_tree): Set num_start_points and start_points.
* find/defs.h: Declare is_start_point.
* doc/find.texi (Full Name Patterns): Explain that candidate names
for -path, -regex etc. will never end in a slash, so "-path /tmp/"
will never match anything.
* find/find.1: Likewise.
Fix Savannah bug #26327: xargs man page is vague about the number
of times command is executed.
* xargs/xargs.1 (DESCRIPTION): Explain more clearly that the
command will be executed many times. Indicate that -L can also be
useful with -P.
* NEWS: Mention this change.
* import-gnulib.sh (gnulib_changed): New variable.
(do_checkout): set gnulib_changed=true if the gnulib code didn't
already correspond to our configured version. Don't use a large
subshell, because we need to set $gnulib_changed and don't want
the value to be discarded.
(main): Run gnulib-tool if gnulib was not at the correct version
or the import-gnulib.config file has changed.
Signed-off-by: James Youngman <jay@gnu.org>
* find/find.1: Use ` instead of ' at the start of quoted text. Use
\(aq instead of ' or \' in commands to get a literal straight quote.
Use ` and ' instead of `` and '' (for consistency).
Signed-off-by: James Youngman <jay@gnu.org>
Fix Savannah bug #24873, Duplicate fprint option corrupts output
by opening each output file only once.
* find/sharefile.c: New file; keeps a mapping from dev/inode to
FILE*, allowing us to determine when the file we just opened is
the same as something else we already opened.
* import-gnulib.config (modules): Import the hash module, used by
sharefile.c.
* find/sharefile.h: Function declarations for same.
* find/find.c (main): Call sharefile_init().
* find/ftsfind.c (main): Likewise.
* find/parser.c (open_output_file): Call sharfile_fopen to open an
output file, instead of fopen_safer.
* find/util.c (cleanup): Close any shared output files that are
open. Also fflush stdout.
(undangle_file_pointers): Set the relevant FILE* pointers to
NULL.
(flush_and_close_output_files): Remove (since sharefile_destroy
has the desired effect).
* find/Makefile.am (libfindtools_a_SOURCES): Add sharefile.c.
(EXTRA_DIST): Add sharefile.h.
* find/defs.h: #include sharefile.h.
(struct state): Add member shared_files, holding a handle to the
shared-file hash table implemented in sharefile.[ch].
* find/testsuite/find.gnu/fprintf-samefile.exp: New test,
exercising -fprintf (though it is not able to detect bug #24873).
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add
find.gnu/fprintf-samefile.exp.
Signed-off-by: James Youngman <jay@gnu.org>