summaryrefslogtreecommitdiffstats
path: root/sbin/savecore/savecore.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2005-02-26 01:19:21 +0000
committerobrien <obrien@FreeBSD.org>2005-02-26 01:19:21 +0000
commit0214e187afbaf0828ba5150116108e477bc04222 (patch)
tree06e5fff4d5b41a0a5da4d03430a77f785aa2eb33 /sbin/savecore/savecore.c
parent69bd6acc420d61c80e61507d42259bf03e02e36e (diff)
downloadFreeBSD-src-0214e187afbaf0828ba5150116108e477bc04222.zip
FreeBSD-src-0214e187afbaf0828ba5150116108e477bc04222.tar.gz
style(9).
Diffstat (limited to 'sbin/savecore/savecore.c')
-rw-r--r--sbin/savecore/savecore.c88
1 files changed, 45 insertions, 43 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 03fc162..796fb94 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -88,9 +88,9 @@ __FBSDID("$FreeBSD$");
/* The size of the buffer used for I/O. */
#define BUFFERSIZE (1024*1024)
-#define STATUS_BAD 0
-#define STATUS_GOOD 1
-#define STATUS_UNKNOWN 2
+#define STATUS_BAD 0
+#define STATUS_GOOD 1
+#define STATUS_UNKNOWN 2
static int checkfor, compress, clear, force, keep, verbose; /* flags */
static int nfound, nsaved, nerr; /* statistics */
@@ -123,13 +123,13 @@ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
switch(status) {
case STATUS_BAD:
- stat_str = "bad";
- break;
+ stat_str = "bad";
+ break;
case STATUS_GOOD:
- stat_str = "good";
- break;
+ stat_str = "good";
+ break;
default:
- stat_str = "unknown";
+ stat_str = "unknown";
}
fprintf(f, " Dump Status: %s\n", stat_str);
fflush(f);
@@ -230,11 +230,11 @@ DoFile(char *savedir, const char *device)
struct kerneldumpheader kdhf, kdhl;
off_t mediasize, dumpsize, firsthd, lasthd, dmpcnt;
FILE *info, *fp;
+ mode_t oumask;
int fd, fdinfo, error, wl;
int nr, nw, hs, he = 0;
int bounds, status;
u_int sectorsize;
- mode_t oumask;
bounds = getbounds();
dmpcnt = 0;
@@ -429,39 +429,41 @@ DoFile(char *savedir, const char *device)
nw = fwrite(buf, 1, wl, fp);
} else {
for (nw = 0; nw < nr; nw = he) {
- /* find a contiguous block of zeroes */
- for (hs = nw; hs < nr; hs += BLOCKSIZE) {
- for (he = hs; he < nr && buf[he] == 0; ++he)
- /* nothing */ ;
- /* is the hole long enough to matter? */
- if (he >= hs + BLOCKSIZE)
- break;
- }
+ /* find a contiguous block of zeroes */
+ for (hs = nw; hs < nr; hs += BLOCKSIZE) {
+ for (he = hs; he < nr && buf[he] == 0;
+ ++he)
+ /* nothing */ ;
+ /* is the hole long enough to matter? */
+ if (he >= hs + BLOCKSIZE)
+ break;
+ }
- /* back down to a block boundary */
- he &= BLOCKMASK;
-
- /*
- * 1) Don't go beyond the end of the buffer.
- * 2) If the end of the buffer is less than
- * BLOCKSIZE bytes away, we're at the end
- * of the file, so just grab what's left.
- */
- if (hs + BLOCKSIZE > nr)
- hs = he = nr;
-
- /*
- * At this point, we have a partial ordering:
- * nw <= hs <= he <= nr
- * If hs > nw, buf[nw..hs] contains non-zero data.
- * If he > hs, buf[hs..he] is all zeroes.
- */
- if (hs > nw)
- if (fwrite(buf + nw, hs - nw, 1, fp) != 1)
- break;
- if (he > hs)
- if (fseeko(fp, he - hs, SEEK_CUR) == -1)
- break;
+ /* back down to a block boundary */
+ he &= BLOCKMASK;
+
+ /*
+ * 1) Don't go beyond the end of the buffer.
+ * 2) If the end of the buffer is less than
+ * BLOCKSIZE bytes away, we're at the end
+ * of the file, so just grab what's left.
+ */
+ if (hs + BLOCKSIZE > nr)
+ hs = he = nr;
+
+ /*
+ * At this point, we have a partial ordering:
+ * nw <= hs <= he <= nr
+ * If hs > nw, buf[nw..hs] contains non-zero data.
+ * If he > hs, buf[hs..he] is all zeroes.
+ */
+ if (hs > nw)
+ if (fwrite(buf + nw, hs - nw, 1, fp)
+ != 1)
+ break;
+ if (he > hs)
+ if (fseeko(fp, he - hs, SEEK_CUR) == -1)
+ break;
}
}
if (nw != wl) {
@@ -526,9 +528,9 @@ usage(void)
int
main(int argc, char **argv)
{
- int i, ch, error;
- struct fstab *fsp;
char *savedir;
+ struct fstab *fsp;
+ int i, ch, error;
checkfor = compress = clear = force = keep = verbose = 0;
nfound = nsaved = nerr = 0;
OpenPOWER on IntegriCloud