NetBSD Problem Report #504

From gnats  Sat Oct  1 15:24:33 1994
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.9/8.6.9) with ESMTP id PAA29908 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Sat, 1 Oct 1994 15:24:32 -0700
Message-Id: <199410012106.RAA00946@kolvir.blrc.ma.us>
Date: Sat, 1 Oct 1994 17:06:37 -0400
From: John Kohl <jtk@kolvir.blrc.ma.us>
Reply-To: jtk@kolvir.blrc.ma.us
To: gnats-bugs@netbsd.org
Subject: find(1) chokes on fdesc file system
X-Send-Pr-Version: 3.2

>Number:         504
>Category:       misc
>Synopsis:       find(1) chokes on fdesc file system
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 01 15:35:02 +0000 1994
>Closed-Date:    Tue Oct 18 13:57:55 +0000 1994
>Last-Modified:  
>Originator:     John Kohl
>Release:        1.0_BETA
>Organization:
>Environment:
System: NetBSD kolvir 1.0_BETA NetBSD 1.0_BETA (KOLVIR) #25: Thu Sep 29 23:31:17 EDT 1994 jtk@kolvir:/u1/NetBSD-1.0/src/sys/arch/i386/compile/KOLVIR i386


>Description:
find(1), as called from /usr/libexec/locate.updatedb, doesn't properly
prune its descents into the fdesc file system if said filesystem is
union mounted.


>How-To-Repeat:
1) mount /dev/fd with an fstab line like so:
	fdesc /dev fdesc rw,union 1 2
2) run find like so, and watch it choke:
# find /dev \( \! -fstype local -o -fstype fdesc -o -fstype kernfs \) -a -prune -o -print
/dev
/dev/fd
/dev/fd/0
/dev/fd/1
/dev/fd/2
/dev/fd/3
/dev/fd/4
find: 5: Bad file descriptor
Exit 1

>Fix:

The problem is that find doesn't record all the state needed when
crossing a mountpoint.  Here's a patch:

*** 1.1	1994/10/01 21:02:18
--- usr.bin/find/function.c	1994/10/01 21:03:55
***************
*** 381,389 ****
  		first = 0;
  		switch (plan->flags) {
  		case F_MTFLAG:
- 			val = sb.f_flags;
- 			break;
  		case F_MTTYPE:
  			strncpy(fstype, sb.f_fstypename, MFSNAMELEN);
  			fstype[MFSNAMELEN] = '\0';
  			break;
--- 381,392 ----
  		first = 0;
  		switch (plan->flags) {
  		case F_MTFLAG:
  		case F_MTTYPE:
+ 			/* copy both flags & type, so that if future
+ 			 * tests look at this same device crossing,
+ 			 * they'll have valid data for comparison
+ 			 */
+ 			val = sb.f_flags;
  			strncpy(fstype, sb.f_fstypename, MFSNAMELEN);
  			fstype[MFSNAMELEN] = '\0';
  			break;



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mycroft 
State-Changed-When: Tue Oct 18 06:57:55 PDT 1994 
State-Changed-Why:  
Fixed. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.