NetBSD Problem Report #994
From gnats Tue Apr 25 15:02:36 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id PAA27262 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Tue, 25 Apr 1995 15:02:35 -0700
Message-Id: <199504252203.WAA01073@lola-granola.MIT.EDU>
Date: Tue, 25 Apr 1995 22:03:10 GMT
From: jhawk@MIT.EDU
Reply-To: jhawk@MIT.EDU
To: gnats-bugs@NetBSD.ORG
Subject: badsect tries to use block device
X-Send-Pr-Version: 3.2
>Number: 994
>Category: bin
>Synopsis: badsect tries to use block device
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 25 15:05:13 +0000 1995
>Closed-Date: Fri Sep 20 21:52:02 +0000 1996
>Last-Modified: Fri Sep 20 21:52:18 +0000 1996
>Originator: John Hawkinson
>Release: Tue Apr 25 18:03:03 EDT 1995
>Organization:
MIT SIPB
>Environment:
System: NetBSD lola-granola 1.0A NetBSD 1.0A (LOLA) #46: Thu Apr 20 21:45:36 EDT 1995 mycroft@lola-granola:/afs/sipb.mit.edu/project/netbsd/dev/current-source/src/sys/arch/i386/compile/LOLA i386
>Description:
badsect(8) tries to open the block device (eg: /dev/wd0f)
instead of the raw device (/dev/rwdof) and thus fails to
work entirely.
>How-To-Repeat:
mount /u1
cd /u1; mkdir BAD
badsect BAD 59828
/dev/wd0f: Device busy
>Fix:
I'm at a loss as to the Right Way (tm) to obtain the raw device.
I decided to use fsck's method of prepending "r"...
*** badsect.c 1995/04/25 18:25:40 1.1
--- badsect.c 1995/04/25 21:53:14 1.2
***************
*** 100,106 ****
struct stat stbuf, devstat;
register struct direct *dp;
DIR *dirp;
! char name[BUFSIZ];
if (argc < 3) {
fprintf(stderr, "usage: badsect bbdir blkno [ blkno ]\n");
--- 100,106 ----
struct stat stbuf, devstat;
register struct direct *dp;
DIR *dirp;
! char name[BUFSIZ], rname[BUFSIZ];
if (argc < 3) {
fprintf(stderr, "usage: badsect bbdir blkno [ blkno ]\n");
***************
*** 131,139 ****
stbuf.st_rdev, argv[1]);
exit(5);
}
! if ((fsi = open(name, 0)) < 0) {
! perror(name);
! exit(6);
}
fs = &sblock;
rdfs(SBOFF, SBSIZE, (char *)fs);
--- 131,151 ----
stbuf.st_rdev, argv[1]);
exit(5);
}
! strncpy(rname, name, 5);
! strcat(rname,"r");
! strcat(rname, &name[5]);
! if (stat(rname, &devstat) < 0) {
! perror(rname);
! fprintf(stderr, "Can't find raw device %s\n", rname);
! exit(6);
! }
! if (!S_ISCHR(devstat.st_mode)) {
! fprintf(stderr,"%s is not a character device\n", rname);
! exit(7);
! }
! if ((fsi = open(rname, 0)) < 0) {
! perror(rname);
! exit(8);
}
fs = &sblock;
rdfs(SBOFF, SBSIZE, (char *)fs);
***************
*** 148,154 ****
errs++;
}
}
! printf("Don't forget to run ``fsck %s''\n", name);
exit(errs);
}
--- 160,166 ----
errs++;
}
}
! printf("Don't forget to run ``fsck %s''\n", rname);
exit(errs);
}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: scottr
State-Changed-When: Fri Sep 20 14:52:02 PDT 1996
State-Changed-Why:
Took the idea, but not the code; but it's finally done. :-)
>Unformatted:
(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.