Module Name:src
Committed By: martin
Date: Fri Aug 4 13:10:35 UTC 2023
Modified Files:
src/usr.bin/find [netbsd-9]: function.c main.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1701):
usr.bin/find/main.c: revision 1.32
usr.bin/find/function.c: revision 1.80
PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD
To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.77.2.1 src/usr.bin/find/function.c
cvs rdiff -u -r1.31 -r1.31.32.1 src/usr.bin/find/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/find/function.c
diff -u src/usr.bin/find/function.c:1.77 src/usr.bin/find/function.c:1.77.2.1
--- src/usr.bin/find/function.c:1.77 Tue Sep 4 15:16:15 2018
+++ src/usr.bin/find/function.c Fri Aug 4 13:10:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: function.c,v 1.77 2018/09/04 15:16:15 kre Exp $ */
+/* $NetBSD: function.c,v 1.77.2.1 2023/08/04 13:10:35 martin Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: function.c,v 1.77 2018/09/04 15:16:15 kre Exp $");
+__RCSID("$NetBSD: function.c,v 1.77.2.1 2023/08/04 13:10:35 martin Exp $");
#endif
#endif /* not lint */
@@ -641,7 +641,8 @@ f_exec(PLAN *plan, FTSENT *entry)
err(1, "vfork");
/* NOTREACHED */
case 0:
- if (fchdir(dotfd)) {
+ /* change dir back from where we started */
+ if (!(ftsoptions & FTS_NOCHDIR) && fchdir(dotfd)) {
warn("chdir");
_exit(1);
}
@@ -673,7 +674,8 @@ run_f_exec(PLAN *plan)
err(1, "vfork");
/* NOTREACHED */
case 0:
- if (fchdir(dotfd)) {
+ /* change dir back from where we started */
+ if (!(ftsoptions & FTS_NOCHDIR) && fchdir(dotfd)) {
warn("chdir");
_exit(1);
}
Index: src/usr.bin/find/main.c
diff -u src/usr.bin/find/main.c:1.31 src/usr.bin/find/main.c:1.31.32.1
--- src/usr.bin/find/main.c:1.31 Thu Jan 24 17:50:08 2013
+++ src/usr.bin/find/main.c Fri Aug 4 13:10:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.31 2013/01/24 17:50:08 christos Exp $ */
+/* $NetBSD: main.c,v 1.31.32.1 2023/08/04 13:10:35 martin Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)main.c 8.4 (
#else
__COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\
The Regents of the University of California. All rights reserved.");
-__RCSID("$NetBSD: main.c,v 1.31 2013/01/24 17:50:08 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.31.32.1 2023/08/04 13:10:35 martin Exp $");
#endif
#endif /* not lint */
@@ -149,9 +149,9 @@ main(int argc, char *argv[])
*p = NULL;
if ((dotfd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1)
- err(1, ".");
+ ftsoptions |= FTS_NOCHDIR;
- exit(find_execute(find_formplan(argv), start));
+ return find_execute(find_formplan(argv), start);
}
static void