2007-04-14 21:41:59 +00:00
|
|
|
/* listfile.h -- display a long listing of a file
|
2025-01-04 11:43:53 +01:00
|
|
|
Copyright (C) 2007-2025 Free Software Foundation, Inc.
|
2007-04-14 21:41:59 +00:00
|
|
|
|
2007-07-02 08:25:45 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
2007-04-14 21:41:59 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-02 08:25:45 +00:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
Removed trailing whitespace.
Removed trailing whitespace.
* Makefile.am: Removed trailing white space.
* NEWS, build-aux/check-testfiles.sh, build-aux/src-sniff.py,
doc/Makefile.am, doc/find-maint.texi, doc/find.texi, find/Makefile.am,
find/defs.h, find/find.1, find/find.c, find/finddata.c, find/fstype.c,
find/ftsfind.c, find/parser.c, find/pred.c, find/tree.c, find/util.c,
import-gnulib.sh, lib/Makefile.am, lib/buildcmd.c, lib/buildcmd.h,
lib/dircallback.c, lib/dircallback.h, lib/extendbuf.c,
lib/extendbuf.h, lib/findutils-version.c, lib/findutils-version.h,
lib/forcefindlib.c, lib/gnulib-version.h, lib/listfile.c,
lib/modetype.h, lib/nextelem.c, lib/nextelem.h, lib/printquoted.c,
lib/printquoted.h, lib/qmark.c, lib/regexprops.c, lib/regextype.c,
lib/savedirinfo.c, lib/savedirinfo.h, lib/strspn.c, lib/wait.h,
lib/waitpid.c, locate/bigram.c, locate/code.c, locate/locate.1,
locate/locate.c, locate/locatedb.5, locate/locatedb.h,
locate/updatedb.1, locate/updatedb.sh, locate/word_io.c,
m4/findlib.m4, m4/nullsort.m4, m4/withfts.m4, xargs/xargs.1: Likewise.
Signed-off-by: James Youngman <jay@gnu.org>
2009-03-04 10:49:59 +00:00
|
|
|
|
2007-04-14 21:41:59 +00:00
|
|
|
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.
|
Removed trailing whitespace.
Removed trailing whitespace.
* Makefile.am: Removed trailing white space.
* NEWS, build-aux/check-testfiles.sh, build-aux/src-sniff.py,
doc/Makefile.am, doc/find-maint.texi, doc/find.texi, find/Makefile.am,
find/defs.h, find/find.1, find/find.c, find/finddata.c, find/fstype.c,
find/ftsfind.c, find/parser.c, find/pred.c, find/tree.c, find/util.c,
import-gnulib.sh, lib/Makefile.am, lib/buildcmd.c, lib/buildcmd.h,
lib/dircallback.c, lib/dircallback.h, lib/extendbuf.c,
lib/extendbuf.h, lib/findutils-version.c, lib/findutils-version.h,
lib/forcefindlib.c, lib/gnulib-version.h, lib/listfile.c,
lib/modetype.h, lib/nextelem.c, lib/nextelem.h, lib/printquoted.c,
lib/printquoted.h, lib/qmark.c, lib/regexprops.c, lib/regextype.c,
lib/savedirinfo.c, lib/savedirinfo.h, lib/strspn.c, lib/wait.h,
lib/waitpid.c, locate/bigram.c, locate/code.c, locate/locate.1,
locate/locate.c, locate/locatedb.5, locate/locatedb.h,
locate/updatedb.1, locate/updatedb.sh, locate/word_io.c,
m4/findlib.m4, m4/nullsort.m4, m4/withfts.m4, xargs/xargs.1: Likewise.
Signed-off-by: James Youngman <jay@gnu.org>
2009-03-04 10:49:59 +00:00
|
|
|
|
2007-04-14 21:41:59 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
all: prefer https:// URLs where possible
Change from http:// to https:// URLs for the following:
www.gnu.org, gnu.org, savannah.gnu.org, git.sv.gnu.org, lists.gnu.org,
translationproject.org, cve.mitre.org, cwe.mitre.org, xkcd.com,
standards.ieee.org, and gcc.gnu.org.
* COPYING: Do the above replacement.
* ChangeLog-2013: Likewise.
* NEWS: Likewise.
* README: Likewise.
* README-hacking: Likewise.
* build-aux/Makefile.am: Likewise.
* build-aux/check-testfiles.sh: Likewise.
* build-aux/gen-changelog.sh: Likewise.
* build-aux/man-lint.sh: Likewise.
* build-aux/src-sniff.py: Likewise.
* cfg.mk: Likewise.
* configure.ac: Likewise.
* doc/Makefile.am: Likewise.
* doc/find-maint.texi: Likewise.
* doc/find.texi: Likewise.
* find/defs.h: Likewise.
* find/exec.c: Likewise.
* find/find.1: Likewise.
* find/finddata.c: Likewise.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/oldfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/print.c: Likewise.
* find/print.h: Likewise.
* find/sharefile.c: Likewise.
* find/sharefile.h: Likewise.
* find/testsuite/Makefile.am: Likewise.
* find/testsuite/binary_locations.sh: Likewise.
* find/testsuite/checklists.py: Likewise.
* find/testsuite/config/unix.exp: Likewise.
* find/testsuite/find.gnu/name-period.exp: Likewise.
* find/testsuite/find.posix/depth1.exp: Likewise.
* find/testsuite/sv-34079.sh: Likewise.
* find/testsuite/sv-34976-execdir-fd-leak.sh: Likewise.
* find/testsuite/sv-48030-exec-plus-bug.sh: Likewise.
* find/testsuite/sv-48180-refuse-noop.sh: Likewise.
* find/testsuite/sv-52220.sh: Likewise.
* find/testsuite/sv-bug-32043.sh: Likewise.
* find/testsuite/test_escape_c.sh: Likewise.
* find/testsuite/test_escapechars.sh: Likewise.
* find/testsuite/test_inode.sh: Likewise.
* find/testsuite/test_type-list.sh: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* gnulib-local/lib/gcc-function-attributes.h: Likewise.
* lib/bugreports.c: Likewise.
* lib/bugreports.h: Likewise.
* lib/buildcmd.c: Likewise.
* lib/buildcmd.h: Likewise.
* lib/check-regexprops.sh: Likewise.
* lib/dircallback.c: Likewise.
* lib/dircallback.h: Likewise.
* lib/extendbuf.c: Likewise.
* lib/extendbuf.h: Likewise.
* lib/fdleak.c: Likewise.
* lib/fdleak.h: Likewise.
* lib/findutils-version.c: Likewise.
* lib/findutils-version.h: Likewise.
* lib/listfile.c: Likewise.
* lib/listfile.h: Likewise.
* lib/printquoted.c: Likewise.
* lib/printquoted.h: Likewise.
* lib/qmark.c: Likewise.
* lib/regexprops.c: Likewise.
* lib/regextype.c: Likewise.
* lib/regextype.h: Likewise.
* lib/safe-atoi.c: Likewise.
* lib/safe-atoi.h: Likewise.
* lib/splitstring.c: Likewise.
* lib/splitstring.h: Likewise.
* lib/test_splitstring.c: Likewise.
* lib/unused-result.h: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.1: Likewise.
* locate/locate.c: Likewise.
* locate/locatedb.5: Likewise.
* locate/locatedb.h: Likewise.
* locate/testsuite/Makefile.am: Likewise.
* locate/testsuite/config/unix.exp: Likewise.
* locate/updatedb.1: Likewise.
* locate/updatedb.sh: Likewise.
* locate/word_io.c: Likewise.
* po/fetch-po-files: Likewise.
* xargs/testsuite/Makefile.am: Likewise.
* xargs/testsuite/config/unix.exp: Likewise.
* xargs/xargs.1: Likewise.
* xargs/xargs.c: Likewise.
2017-10-23 00:19:34 +02:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2007-04-14 21:41:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined DIRCALLBACK_H
|
|
|
|
# define DIRCALLBACK_H
|
|
|
|
|
Exec predicates now store which directory they want to run in.
* lib/dircallback.c (run_in_dirfd): New name for old run_in_dir
function.
(run_in_dir): Like the old funciton of the same name, but now
takes an argument const struct saved_cwd *.
* lib/dircallback.h: Update declarations of run_in_dirfd and
run_in_dir.
* find/util.c: Include dircallback.h, xalloc.h, save-cwd.h.
(do_complete_pending_execdirs): Remove dir_fd parameter, since the
per-predicate data structures now indicate what directory they
need to be run in. Instead of calling bc_do_exec directly, use a
callback 'exec_cb' that uses run_in_dir (which now takes a
saved_cwd* parameter instead of a file descriptor).
(do_exec): Called by do_complete_pending_execdirs, and simply uses
run_in_dir to call exec_cb, restoring the working directory
afterward.
(record_initial_cwd): New function, initialises the global
variable initial_wd.
(cleanup_initial_cwd): New function, cleans up the global variable
initial_wd.
(cleanup): Call cleanup_initial_cwd.
(get_start_dirfd): Remove.
(is_exec_in_local_dir): New funciton; true for predicates -execdir
and -okdir.
* find/pred.c: Include cloexec.h and save-cwd.h.
(record_exec_dir): New function, sets the value of
execp->wd_for_exec if needed.
(new_impl_pred_exec): Remove the obsolete dir_fd parameter. Call
record_exec_dir.
(pred_exec): Don't pass the dir_fd parameter.
(pred_execdir): Likewise.
(pred_ok): Likewise.
(pred_okdir): Likewise.
(can_access): Call run_in_dirfd rather than run_in_dir (the
function was renamed).
(prep_child_for_exec): Remove dir_fd parameter; don't fchdir to
that. Call restore_cwd instead (passing a saved_cwd* parameter
which replaced dir_fd).
(launch): Remove references to execp->use_current_dir.
(launch): Change references to execp->dir_fd to execp->wd_for_exec.
* find/parser.c: Correct indentiation of declaration of
insert_exec_ok and remove the obsolete dir_fd parameter.
(parse_exec): Don't pass the dir_fd parameter to insert_exec_ok.
(parse_execdir): Likewise.
(parse_ok): Likewise.
(parse_okdir): Likewise.
(insert_exec_ok): Remove obsolete dir_fd paramter. Initialise
execp->wd_for_exec, either to NULL (for -*dir) or to the
initial_wd.
* find/ftsfind.c: Remove get_current_dirfd. Remove
complete_execdirs_cb.
(consider_visiting): Call complete_pending_execdirs directly.
(main): Call record_initial_cwd to record the initial working
directory, early on. Don't initialise starting_dir or
starting_desc, they have been removed.
* find/finddata.c: Include save-cwd.h. Remove starting_dir and
starting_desc. Add new global variable initial_wd. It is a struct
saved_wd* and represents find's initial working directory.
* find/find.c: Include save-cwd.h.
(main): Call record_initial_cwd in order to initialise the
global variable initial_wd Don't set starting_desc and
starting_dir, since those variables have been removed.
(safely_chdir): Don't pass an fd to complete_pending_execdirs.
(chdir_back): Remove the safety check (since we are using fchdir
and in any case no longer have all the data that the existing
wd_sanity_check function wants).
(do_process_top_dir): Don't pass an fd to
complete_pending_execdirs.
(process_dir): Likewise.
* find/defs.h (struct exec_val): Remove use_current_dir and
dir_fd. Replace with wd_for_exec, which is a struct saved_wd*.
(get_start_dirfd): Remove prototype.
(get_current_dirfd): Remove prototype.
(complete_pending_execdirs): No longer takes dir_fd parameter.
(record_initial_cwd): Add prototype.
(is_exec_in_local_dir): Add prototype.
(options): Declare.
(initial_wd): Add declaration. It is a struct saved_wd* and
represents find's initial working directory.
(starting_dir): Remove devlaration of global variable.
(starting_desc): Remove devlaration of global variable.
* import-gnulib.config (modules): Import module save-cwd.
Signed-off-by: James Youngman <jay@gnu.org>
2010-04-10 17:15:01 +01:00
|
|
|
struct saved_cwd;
|
|
|
|
|
|
|
|
int run_in_dirfd (int fd, int (*callback)(void*), void *usercontext);
|
2011-06-03 01:08:34 +01:00
|
|
|
int run_in_dir (const struct saved_cwd*, int (*callback)(void*), void *usercontext);
|
2007-04-14 21:41:59 +00:00
|
|
|
|
|
|
|
#endif
|