dumptraverse.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 1996, 1998, 2001-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "dump.h"
#ifdef __STDC__
static void lf_dumpinode(struct dinode *);
#else
static void lf_dmpindir();
static void indir();
static void lf_blksout();
static void dsrch();
void lf_dump();
#endif
static char msgbuf[256];
void
{
int bits;
/*
* Handle pass restarts. We don't check for UFSROOTINO just in
* case we need to restart on the root inode.
*/
if (ino != 0) {
bits = ~0;
/* LINTED: lint seems to think map is signed */
}
goto restart;
}
bits = ~0;
}
ino++;
/*
* Ignore any inode less than UFSROOTINO and inodes that
* we have already done on a previous pass.
*/
/*
* The following test is merely an optimization
* for common case where "add" will just return.
*/
}
bits >>= 1;
}
}
void
{
int f;
/* LINTED: 32-bit to 8-bit assignment ok */
return;
}
/* LINTED: 32-bit to 8-bit assignment ok */
/* LINTED: 32-bit to 8-bit assignment ok */
}
if (f == IFSHAD)
return;
/* LINTED: 32-bit to 8-bit assignment ok */
/* attribute changes impact the root */
if (f == IFATTRDIR)
o_esize += 1;
return;
}
}
}
void
{
int f;
/* LINTED: 32-bit to 8-bit assignment ok */
return;
}
/* LINTED: 32-bit to 8-bit assignment ok */
/* LINTED: 32-bit to 8-bit assignment ok */
}
/* LINTED: 32-bit to 8-bit assignment ok */
/* attribute changes impact the root */
if (f == IFATTRDIR)
o_esize += 1;
return;
}
}
}
static struct shcount {
unsigned long count;
} shcounts = {
0,
0
};
void
{
return;
}
/* LINTED: 32-bit to 8-bit assignment ok */
}
void
{
return;
return; /* xxx panic? complain? */
f_esize += esizeprime;
}
void
freeshad()
{
return;
}
/*
* This should be unnecessary, but do it just to be safe.
* Note that shc might be malloc'd or static, so can't free().
*/
}
void
{
int i;
return;
"Warning - directory at inode `%lu' vanished!\n"), ino);
/* LINTED: 32-bit to 8-bit assignment ok */
return;
}
nsubdir = 0;
dadded = 0;
for (i = 0; i < NDADDR; i++) {
filesize);
}
for (i = 0; i < NIADDR; i++) {
}
if (dadded) {
nadded++;
/* LINTED: 32-bit to 8-bit assignment ok */
/* attribute changes "auto-percolate" to root */
}
}
}
if (nsubdir == 0) {
/* LINTED: 32-bit to 8-bit assignment ok */
}
}
}
static void
daddr32_t d;
int n;
{
int i;
"Inconsistency detected: filesystem block size larger than valid maximum.\n"));
dumpabort();
/*NOTREACHED*/
}
/*CSTYLED*/
"Inconsistency detected: inode has more indirect \
blocks than valid maximum.\n"));
dumpabort();
/*NOTREACHED*/
}
return;
#ifdef lint
idblk[0] = '\0';
#endif /* lint */
/* xxx sanity check sblock contents before trusting them */
if (n <= 0) {
d = idblk[i];
if (d != 0)
*filesize);
}
} else {
n--;
d = idblk[i];
if (d != 0)
}
}
}
void
{
/* watchout for dir inodes deleted and maybe reallocated */
"Warning - directory at inode `%lu' vanished!\n"),
ino);
return;
}
}
static void
{
return;
}
int
{
int rc;
return (0);
return (rc);
}
void
{
int i;
return;
return;
}
if (size > 0) {
for (i = 0; i < NIADDR; i++) {
if (size == 0)
break;
}
}
}
void
{
return;
if (shortmeta) {
/* assume spcl.c_shadow is smaller than 1 block */
} else {
}
loffset = 0;
if (newtape) {
} else if (pos)
else
newtape = 0;
pos = 0;
}
static void
int lvl;
{
int i;
"Inconsistency detected: filesystem block size larger than valid maximum.\n"));
dumpabort();
/*NOTREACHED*/
}
"Inconsistency detected: inode has more indirect \
blocks than valid maximum.\n"));
dumpabort();
/*NOTREACHED*/
}
if (blk != 0)
else
if (lvl <= 0) {
return;
}
lvl--;
if (*size == 0)
return;
}
}
static void
{
u_offset_t i;
u_offset_t j, k, count;
u_offset_t bytecnt = 0;
if (pos) {
/*
* We get here if a slave throws a signal to the
* master indicating a partially dumped file.
* Begin by figuring out what was undone.
*/
/* This stuff was dumped already, forget it. */
/* LINTED: spurious complaint on sign-extending */
return;
}
/*
* Some of this was dumped, some wasn't.
* Figure out what was done and skip it.
*/
/* LINTED: spurious complaint on sign-extending */
/* LINTED room after EOT is only a few MB */
/* LINTED: result fits, due to modulus */
/* LINTED: spurious complaint on sign-extending */
(u_offset_t)(unsigned)tp_bsize);
/* LINTED: result fits, due to modulus */
}
}
while (bytes > 0) {
/* LINTED: spurious complaint on sign-extending */
else
if (tpblkskip) {
tpblkskip = 0;
} else {
continue;
}
} else
skip = 0;
tpblkoff = 0;
}
/* LINTED (count - skip) will always fit into an int32_t */
j = 0;
if (*blkp != 0) {
/* LINTED: fragoff fits into 32 bits */
/* LINTED: bytecnt fits into 32 bits */
}
blkp++;
/* LINTED: spurious complaint on sign-extending */
byteoff = 0;
fragoff = 0;
}
bytecnt = 0;
}
pos = 0;
}
void
int typ;
{
int i;
if (!newtape)
else
newtape = 0;
for (i = 0; i < TP_NINDIR; i++)
/* LINTED: spurious complaint on sign-extending */
if (leftover) {
leftover = 0;
} else {
/* LINTED value always less than INT32_MAX */
}
spclrec();
}
}
static void
daddr32_t d;
{
return;
"Inconsistency detected: filesystem block size larger than valid maximum.\n"));
dumpabort();
/*NOTREACHED*/
}
#ifdef lint
dblk[0] = '\0';
#endif /* lint */
/* LINTED ufs disk addresses always fit into 32 bits */
/* LINTED from sizeof check above, roundup() <= max(size_t) */
loc = 0;
/*LINTED [dblk is char[], loc (dp->d_reclen) % 4 == 0]*/
"Warning - directory at inode `%lu' is corrupted\n"),
ino);
break;
}
continue;
"Warning - directory at inode `%lu' is corrupted:\n\
\t\".\" points to inode `%lu' - run fsck\n"),
}
continue;
}
"Warning - directory at inode `%lu' is corrupted:\n\
\t\"..\" points to non-directory inode `%lu' - run fsck\n"),
}
continue;
}
}
dadded++;
return;
}
nsubdir++;
}
}
#define CACHESIZE 32
struct dinode *
{
static int cacheoff = 0;
int i;
}
/* before we do major i/o, check for a secondary cache hit */
for (i = 0; i < CACHESIZE; i++)
return (icache + i);
/* we need to do major i/o. throw the last inode retrieved into */
/* the cache. note: this copies garbage the first time it is */
/* used, but no harm done. */
cacheoff = 0;
/* LINTED: can't make up for broken system macros here */
/* LINTED: (max - min) * size fits into a size_t */
}
#define BREADEMAX 32
#ifdef NO__LONGLONG__
#else
#endif
breaderrors += 1; \
}
void
{
int saverr;
int n;
static int breaderrors = 0;
/* mechanics for caching small bread requests. these are */
/* often small ACLs that are used over and over. */
static int cacheoff = 0;
int i;
if (pagesize == 0)
pagesize = getpagesize();
/*
* We depend on mmap(2)'s guarantee that mapping a
* partial page will cause the remainder of the page
* to be zero-filled.
*/
/* LINTED offset will fit into 32 bits */
if (maddr != MAP_FAILED) {
return;
}
}
/* Don't know where we are, return the least-harmful data */
return;
}
return;
while (cnt != 0) {
"Warning - block %llu is beyond the end of `%s'\n"),
break;
}
break;
}
/* small read. check for cache hit. */
for (i = 0; i < CACHESIZE; i++)
return;
}
/* no cache hit; throw this one into the cache... */
cacheoff = 0;
} else {
}
if (n != DEV_BSIZE) {
n = MAX(n, 0);
breaderrors += 1;
"Warning - cannot read sector %llu of `%s'\n"),
}
da++;
/* LINTED character pointers aren't signed */
}
if (breaderrors > BREADEMAX) {
"More than %d block read errors from dump device `%s'\n"),
dumpailing();
breaderrors = 0;
}
}