mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-03 09:00:21 +00:00
Correct use of .Nm. Add section number to .Xr. Add rcsid, usage(). Use err(3).
This commit is contained in:
parent
f9184dd719
commit
437e1c4474
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36626
@ -10,7 +10,7 @@
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" must display the following acknowledgment:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)badsect.8 8.1 (Berkeley) 6/5/93
|
||||
.\" $Id: badsect.8,v 1.5 1997/06/04 06:40:30 charnier Exp $
|
||||
.\" $Id: badsect.8,v 1.6 1997/10/15 17:33:47 max Exp $
|
||||
.\"
|
||||
.Dd June 5, 1993
|
||||
.Dt BADSECT 8
|
||||
@ -39,7 +39,7 @@
|
||||
.Nm badsect
|
||||
.Nd create files to contain bad sectors
|
||||
.Sh SYNOPSIS
|
||||
.Nm /sbin/badsect
|
||||
.Nm badsect
|
||||
.Ar bbdir sector ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm Badsect
|
||||
@ -54,7 +54,7 @@ makes the pack appear perfect, and such packs can then be copied with
|
||||
.Xr dd 1 .
|
||||
The technique used by this program is also less general than
|
||||
bad block forwarding, as
|
||||
.Nm badsect
|
||||
.Nm
|
||||
can't make amends for
|
||||
bad blocks in the i-list of file systems or in swap areas.
|
||||
.Pp
|
||||
@ -66,7 +66,7 @@ formatter.
|
||||
Thus to deal with a newly bad block
|
||||
or on disks where the drivers
|
||||
do not support the bad-blocking standard
|
||||
.Nm badsect
|
||||
.Nm
|
||||
may be used to good effect.
|
||||
.Pp
|
||||
.Nm Badsect
|
||||
@ -74,8 +74,8 @@ is used on a quiet file system in the following way:
|
||||
First mount the file system, and change to its root directory.
|
||||
Make a directory
|
||||
.Li BAD
|
||||
there. Run
|
||||
.Nm badsect
|
||||
there. Run
|
||||
.Nm
|
||||
giving as argument the
|
||||
.Ar BAD
|
||||
directory followed by
|
||||
@ -105,11 +105,11 @@ system call,
|
||||
creating an illegal file whose first block address is the block containing
|
||||
bad sector and whose name is the bad sector number.
|
||||
When it is discovered by
|
||||
.Xr fsck
|
||||
.Xr fsck 8
|
||||
it will ask
|
||||
.Dq Li "HOLD BAD BLOCK ?"
|
||||
A positive response will cause
|
||||
.Xr fsck
|
||||
.Xr fsck 8
|
||||
to convert the inode to a regular file containing the bad block.
|
||||
.Sh SEE ALSO
|
||||
.Xr bad144 8 ,
|
||||
@ -122,7 +122,7 @@ A warning is issued if the block is already in use.
|
||||
.Sh BUGS
|
||||
If more than one sector which comprise a file system fragment are bad,
|
||||
you should specify only one of them to
|
||||
.Nm badsect ,
|
||||
.Nm Ns ,
|
||||
as the blocks in the bad sector files actually cover all the sectors in a
|
||||
file system fragment.
|
||||
.Sh HISTORY
|
||||
|
@ -38,7 +38,11 @@ static const char copyright[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -57,6 +61,7 @@ static const char sccsid[] = "@(#)badsect.c 8.1 (Berkeley) 6/5/93";
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <ufs/ufs/dinode.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
@ -84,6 +89,13 @@ char buf[MAXBSIZE];
|
||||
void rdfs __P((daddr_t, int, char *));
|
||||
int chkuse __P((daddr_t, int));
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: badsect bbdir blkno ...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
@ -97,26 +109,18 @@ main(argc, argv)
|
||||
char name[2 * MAXPATHLEN];
|
||||
char *name_dir_end;
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "usage: badsect bbdir blkno [ blkno ]\n");
|
||||
exit(1);
|
||||
}
|
||||
if (chdir(argv[1]) < 0 || stat(".", &stbuf) < 0) {
|
||||
perror(argv[1]);
|
||||
exit(2);
|
||||
}
|
||||
if (argc < 3)
|
||||
usage();
|
||||
if (chdir(argv[1]) < 0 || stat(".", &stbuf) < 0)
|
||||
err(2, "%s", argv[1]);
|
||||
strcpy(name, _PATH_DEV);
|
||||
if ((dirp = opendir(name)) == NULL) {
|
||||
perror(name);
|
||||
exit(3);
|
||||
}
|
||||
if ((dirp = opendir(name)) == NULL)
|
||||
err(3, "%s", name);
|
||||
name_dir_end = name + strlen(name);
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
strcpy(name_dir_end, dp->d_name);
|
||||
if (lstat(name, &devstat) < 0) {
|
||||
perror(name);
|
||||
exit(4);
|
||||
}
|
||||
if (lstat(name, &devstat) < 0)
|
||||
err(4, "%s", name);
|
||||
if (stbuf.st_dev == devstat.st_rdev &&
|
||||
(devstat.st_mode & IFMT) == IFBLK)
|
||||
break;
|
||||
@ -133,10 +137,8 @@ main(argc, argv)
|
||||
*/
|
||||
memcpy(name_dir_end + 1, name_dir_end, strlen(name_dir_end) + 1);
|
||||
*name_dir_end = 'r';
|
||||
if ((fsi = open(name, O_RDONLY)) < 0) {
|
||||
perror(name);
|
||||
exit(6);
|
||||
}
|
||||
if ((fsi = open(name, O_RDONLY)) < 0)
|
||||
err(6, "%s", name);
|
||||
fs = &sblock;
|
||||
rdfs(SBOFF, SBSIZE, (char *)fs);
|
||||
dev_bsize = fs->fs_fsize / fsbtodb(fs, 1);
|
||||
@ -157,7 +159,7 @@ main(argc, argv)
|
||||
errs++;
|
||||
}
|
||||
else if (mknod(*argv, IFMT|0600, (dev_t)diskbn) < 0) {
|
||||
perror(*argv);
|
||||
warn("%s", *argv);
|
||||
errs++;
|
||||
}
|
||||
}
|
||||
@ -218,13 +220,11 @@ rdfs(bno, size, bf)
|
||||
|
||||
if (lseek(fsi, (off_t)bno * dev_bsize, SEEK_SET) < 0) {
|
||||
printf("seek error: %ld\n", bno);
|
||||
perror("rdfs");
|
||||
exit(1);
|
||||
err(1, "rdfs");
|
||||
}
|
||||
n = read(fsi, bf, size);
|
||||
if (n != size) {
|
||||
printf("read error: %ld\n", bno);
|
||||
perror("rdfs");
|
||||
exit(1);
|
||||
err(1, "rdfs");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user