| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: badsect.c,v 1.31 2008/12/29 16:03:57 christos Exp $ */ | | 1 | /* $NetBSD: badsect.c,v 1.32 2009/03/16 12:53:30 lukem Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1981, 1983, 1993 | | 4 | * Copyright (c) 1981, 1983, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | __COPYRIGHT("@(#) Copyright (c) 1981, 1983, 1993\ | | 34 | __COPYRIGHT("@(#) Copyright (c) 1981, 1983, 1993\ |
35 | The Regents of the University of California. All rights reserved."); | | 35 | The Regents of the University of California. All rights reserved."); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)badsect.c 8.2 (Berkeley) 5/4/95"; | | 40 | static char sccsid[] = "@(#)badsect.c 8.2 (Berkeley) 5/4/95"; |
41 | #else | | 41 | #else |
42 | __RCSID("$NetBSD: badsect.c,v 1.31 2008/12/29 16:03:57 christos Exp $"); | | 42 | __RCSID("$NetBSD: badsect.c,v 1.32 2009/03/16 12:53:30 lukem Exp $"); |
43 | #endif | | 43 | #endif |
44 | #endif /* not lint */ | | 44 | #endif /* not lint */ |
45 | | | 45 | |
46 | /* | | 46 | /* |
47 | * badsect | | 47 | * badsect |
48 | * | | 48 | * |
49 | * Badsect takes a list of file-system relative sector numbers | | 49 | * Badsect takes a list of file-system relative sector numbers |
50 | * and makes files containing the blocks of which these sectors are a part. | | 50 | * and makes files containing the blocks of which these sectors are a part. |
51 | * It can be used to contain sectors which have problems if these sectors | | 51 | * It can be used to contain sectors which have problems if these sectors |
52 | * are not part of the bad file for the pack (see bad144). For instance, | | 52 | * are not part of the bad file for the pack (see bad144). For instance, |
53 | * this program can be used if the driver for the file system in question | | 53 | * this program can be used if the driver for the file system in question |
54 | * does not support bad block forwarding. | | 54 | * does not support bad block forwarding. |
55 | */ | | 55 | */ |
| @@ -240,29 +240,29 @@ chkuse(off_t blkno, int cnt) | | | @@ -240,29 +240,29 @@ chkuse(off_t blkno, int cnt) |
240 | bn = dtogd(fs, fsbn); | | 240 | bn = dtogd(fs, fsbn); |
241 | if (isclr(cg_blksfree(&acg, needswap), bn)) | | 241 | if (isclr(cg_blksfree(&acg, needswap), bn)) |
242 | warnx("Warning: sector %lld is in use", (long long)blkno); | | 242 | warnx("Warning: sector %lld is in use", (long long)blkno); |
243 | | | 243 | |
244 | return 0; | | 244 | return 0; |
245 | } | | 245 | } |
246 | | | 246 | |
247 | /* | | 247 | /* |
248 | * read a block from the file system | | 248 | * read a block from the file system |
249 | */ | | 249 | */ |
250 | static void | | 250 | static void |
251 | rdfs(off_t bno, size_t size, void *bf) | | 251 | rdfs(off_t bno, size_t size, void *bf) |
252 | { | | 252 | { |
253 | int n; | | 253 | ssize_t n; |
254 | | | 254 | |
255 | if (lseek(fsi, bno * dev_bsize, SEEK_SET) == -1) | | 255 | if (lseek(fsi, bno * dev_bsize, SEEK_SET) == -1) |
256 | err(1, "seek error at block %lld", (long long)bno); | | 256 | err(1, "seek error at block %lld", (long long)bno); |
257 | | | 257 | |
258 | switch (n = read(fsi, bf, size)) { | | 258 | switch (n = read(fsi, bf, size)) { |
259 | case -1: | | 259 | case -1: |
260 | err(1, "read error at block %lld", (long long)bno); | | 260 | err(1, "read error at block %lld", (long long)bno); |
261 | break; | | 261 | break; |
262 | | | 262 | |
263 | default: | | 263 | default: |
264 | if (n == size) | | 264 | if ((size_t)n == size) |
265 | return; | | 265 | return; |
266 | errx(1, "incomplete read at block %lld", (long long)bno); | | 266 | errx(1, "incomplete read at block %lld", (long long)bno); |
267 | } | | 267 | } |
268 | } | | 268 | } |