style(9).
This commit is contained in:
parent
099894cc96
commit
ecb90dcc75
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=142533
@ -88,9 +88,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
/* The size of the buffer used for I/O. */
|
/* The size of the buffer used for I/O. */
|
||||||
#define BUFFERSIZE (1024*1024)
|
#define BUFFERSIZE (1024*1024)
|
||||||
|
|
||||||
#define STATUS_BAD 0
|
#define STATUS_BAD 0
|
||||||
#define STATUS_GOOD 1
|
#define STATUS_GOOD 1
|
||||||
#define STATUS_UNKNOWN 2
|
#define STATUS_UNKNOWN 2
|
||||||
|
|
||||||
static int checkfor, compress, clear, force, keep, verbose; /* flags */
|
static int checkfor, compress, clear, force, keep, verbose; /* flags */
|
||||||
static int nfound, nsaved, nerr; /* statistics */
|
static int nfound, nsaved, nerr; /* statistics */
|
||||||
@ -123,13 +123,13 @@ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
|
|||||||
|
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case STATUS_BAD:
|
case STATUS_BAD:
|
||||||
stat_str = "bad";
|
stat_str = "bad";
|
||||||
break;
|
break;
|
||||||
case STATUS_GOOD:
|
case STATUS_GOOD:
|
||||||
stat_str = "good";
|
stat_str = "good";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stat_str = "unknown";
|
stat_str = "unknown";
|
||||||
}
|
}
|
||||||
fprintf(f, " Dump Status: %s\n", stat_str);
|
fprintf(f, " Dump Status: %s\n", stat_str);
|
||||||
fflush(f);
|
fflush(f);
|
||||||
@ -230,11 +230,11 @@ DoFile(char *savedir, const char *device)
|
|||||||
struct kerneldumpheader kdhf, kdhl;
|
struct kerneldumpheader kdhf, kdhl;
|
||||||
off_t mediasize, dumpsize, firsthd, lasthd, dmpcnt;
|
off_t mediasize, dumpsize, firsthd, lasthd, dmpcnt;
|
||||||
FILE *info, *fp;
|
FILE *info, *fp;
|
||||||
|
mode_t oumask;
|
||||||
int fd, fdinfo, error, wl;
|
int fd, fdinfo, error, wl;
|
||||||
int nr, nw, hs, he = 0;
|
int nr, nw, hs, he = 0;
|
||||||
int bounds, status;
|
int bounds, status;
|
||||||
u_int sectorsize;
|
u_int sectorsize;
|
||||||
mode_t oumask;
|
|
||||||
|
|
||||||
bounds = getbounds();
|
bounds = getbounds();
|
||||||
dmpcnt = 0;
|
dmpcnt = 0;
|
||||||
@ -429,39 +429,41 @@ DoFile(char *savedir, const char *device)
|
|||||||
nw = fwrite(buf, 1, wl, fp);
|
nw = fwrite(buf, 1, wl, fp);
|
||||||
} else {
|
} else {
|
||||||
for (nw = 0; nw < nr; nw = he) {
|
for (nw = 0; nw < nr; nw = he) {
|
||||||
/* find a contiguous block of zeroes */
|
/* find a contiguous block of zeroes */
|
||||||
for (hs = nw; hs < nr; hs += BLOCKSIZE) {
|
for (hs = nw; hs < nr; hs += BLOCKSIZE) {
|
||||||
for (he = hs; he < nr && buf[he] == 0; ++he)
|
for (he = hs; he < nr && buf[he] == 0;
|
||||||
/* nothing */ ;
|
++he)
|
||||||
/* is the hole long enough to matter? */
|
/* nothing */ ;
|
||||||
if (he >= hs + BLOCKSIZE)
|
/* is the hole long enough to matter? */
|
||||||
break;
|
if (he >= hs + BLOCKSIZE)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* back down to a block boundary */
|
/* back down to a block boundary */
|
||||||
he &= BLOCKMASK;
|
he &= BLOCKMASK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1) Don't go beyond the end of the buffer.
|
* 1) Don't go beyond the end of the buffer.
|
||||||
* 2) If the end of the buffer is less than
|
* 2) If the end of the buffer is less than
|
||||||
* BLOCKSIZE bytes away, we're at the end
|
* BLOCKSIZE bytes away, we're at the end
|
||||||
* of the file, so just grab what's left.
|
* of the file, so just grab what's left.
|
||||||
*/
|
*/
|
||||||
if (hs + BLOCKSIZE > nr)
|
if (hs + BLOCKSIZE > nr)
|
||||||
hs = he = nr;
|
hs = he = nr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point, we have a partial ordering:
|
* At this point, we have a partial ordering:
|
||||||
* nw <= hs <= he <= nr
|
* nw <= hs <= he <= nr
|
||||||
* If hs > nw, buf[nw..hs] contains non-zero data.
|
* If hs > nw, buf[nw..hs] contains non-zero data.
|
||||||
* If he > hs, buf[hs..he] is all zeroes.
|
* If he > hs, buf[hs..he] is all zeroes.
|
||||||
*/
|
*/
|
||||||
if (hs > nw)
|
if (hs > nw)
|
||||||
if (fwrite(buf + nw, hs - nw, 1, fp) != 1)
|
if (fwrite(buf + nw, hs - nw, 1, fp)
|
||||||
break;
|
!= 1)
|
||||||
if (he > hs)
|
break;
|
||||||
if (fseeko(fp, he - hs, SEEK_CUR) == -1)
|
if (he > hs)
|
||||||
break;
|
if (fseeko(fp, he - hs, SEEK_CUR) == -1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nw != wl) {
|
if (nw != wl) {
|
||||||
@ -526,9 +528,9 @@ usage(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, ch, error;
|
|
||||||
struct fstab *fsp;
|
|
||||||
char *savedir;
|
char *savedir;
|
||||||
|
struct fstab *fsp;
|
||||||
|
int i, ch, error;
|
||||||
|
|
||||||
checkfor = compress = clear = force = keep = verbose = 0;
|
checkfor = compress = clear = force = keep = verbose = 0;
|
||||||
nfound = nsaved = nerr = 0;
|
nfound = nsaved = nerr = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user