Module Name: src Committed By: christos Date: Sat Apr 1 15:57:20 UTC 2023
Modified Files: src/usr.bin/find: function.c main.c Log Message: PR/57313: Timo Buhrmester: Don't bail if "." cannot be opened. From FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/usr.bin/find/function.c cvs rdiff -u -r1.31 -r1.32 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.79 src/usr.bin/find/function.c:1.80 --- src/usr.bin/find/function.c:1.79 Thu Mar 18 14:24:14 2021 +++ src/usr.bin/find/function.c Sat Apr 1 11:57:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: function.c,v 1.79 2021/03/18 18:24:14 cheusov Exp $ */ +/* $NetBSD: function.c,v 1.80 2023/04/01 15:57:20 christos 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.79 2021/03/18 18:24:14 cheusov Exp $"); +__RCSID("$NetBSD: function.c,v 1.80 2023/04/01 15:57:20 christos 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.32 --- src/usr.bin/find/main.c:1.31 Thu Jan 24 12:50:08 2013 +++ src/usr.bin/find/main.c Sat Apr 1 11:57:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.31 2013/01/24 17:50:08 christos Exp $ */ +/* $NetBSD: main.c,v 1.32 2023/04/01 15:57:20 christos 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.32 2023/04/01 15:57:20 christos 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