WARNS?=1. RCS ids.
This commit is contained in:
parent
cd359aa2a0
commit
3d8d628a25
|
@ -1,6 +1,7 @@
|
|||
# $NetBSD: Makefile,v 1.4 1997/10/07 13:44:02 mrg Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.3 1994/12/22 10:27:18 cgd Exp $
|
||||
|
||||
WARNS?= 1
|
||||
PROG= lfs_cleanerd
|
||||
CFLAGS+=-I${.CURDIR} -DDIAGNOSTIC
|
||||
MAN= lfs_cleanerd.8
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)clean.h 8.2 (Berkeley) 5/4/95
|
||||
* from: @(#)clean.h 8.1 (Berkeley) 6/4/93
|
||||
* $Id: clean.h,v 1.2 1997/10/07 13:39:56 mrg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -106,8 +107,8 @@ typedef struct fs_info {
|
|||
__BEGIN_DECLS
|
||||
int dump_summary __P((struct lfs *, SEGSUM *, u_long, daddr_t **));
|
||||
void err __P((const int, const char *, ...));
|
||||
int fs_getmntinfo __P((struct statfs **, char *, char *));
|
||||
int get __P((int, off_t, void *, size_t));
|
||||
int fs_getmntinfo __P((struct statfs **, char *, const char *));
|
||||
void get __P((int, off_t, void *, size_t));
|
||||
FS_INFO *get_fs_info __P((struct statfs *, int));
|
||||
int lfs_segmapv __P((FS_INFO *, int, caddr_t, BLOCK_INFO **, int *));
|
||||
int mmap_segment __P((FS_INFO *, int, caddr_t *, int));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: cleanerd.c,v 1.2 1997/10/07 13:39:58 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -31,14 +33,15 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1992, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
|
||||
__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n");
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)cleanerd.c 8.2 (Berkeley) 1/13/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cleanerd.c,v 1.2 1997/10/07 13:39:58 mrg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -57,10 +60,7 @@ static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
|
|||
char *special = "cleanerd";
|
||||
int do_small = 0;
|
||||
int do_mmap = 0;
|
||||
int stat_report = 0;
|
||||
struct cleaner_stats {
|
||||
double util_tot;
|
||||
double util_sos;
|
||||
int blocks_read;
|
||||
int blocks_written;
|
||||
int segs_cleaned;
|
||||
|
@ -71,7 +71,7 @@ struct cleaner_stats {
|
|||
struct seglist {
|
||||
int sl_id; /* segment number */
|
||||
int sl_cost; /* cleaning cost */
|
||||
char sl_bytes; /* bytes in segment */
|
||||
char sl_empty; /* is segment empty */
|
||||
};
|
||||
|
||||
struct tossstruct {
|
||||
|
@ -79,8 +79,6 @@ struct tossstruct {
|
|||
int seg;
|
||||
};
|
||||
|
||||
#define CLEAN_BYTES 0x1
|
||||
|
||||
/* function prototypes for system calls; not sure where they should go */
|
||||
int lfs_segwait __P((fsid_t *, struct timeval *));
|
||||
int lfs_segclean __P((fsid_t *, u_long));
|
||||
|
@ -91,12 +89,13 @@ int lfs_markv __P((fsid_t *, BLOCK_INFO *, int));
|
|||
int bi_tossold __P((const void *, const void *, const void *));
|
||||
int choose_segments __P((FS_INFO *, struct seglist *,
|
||||
int (*)(FS_INFO *, SEGUSE *)));
|
||||
void clean_fs __P((FS_INFO *, int (*)(FS_INFO *, SEGUSE *), int, long));
|
||||
int clean_loop __P((FS_INFO *, int, long));
|
||||
void clean_fs __P((FS_INFO *, int (*)(FS_INFO *, SEGUSE *)));
|
||||
int clean_loop __P((FS_INFO *));
|
||||
int clean_segment __P((FS_INFO *, int));
|
||||
int cost_benefit __P((FS_INFO *, SEGUSE *));
|
||||
int cost_compare __P((const void *, const void *));
|
||||
void sig_report __P((int));
|
||||
int main __P((int, char *[]));
|
||||
|
||||
/*
|
||||
* Cleaning Cost Functions:
|
||||
|
@ -157,38 +156,23 @@ main(argc, argv)
|
|||
struct statfs *lstatfsp; /* file system stats */
|
||||
struct timeval timeout; /* sleep timeout */
|
||||
fsid_t fsid;
|
||||
long clean_opts; /* cleaning options */
|
||||
int i, nodaemon, segs_per_clean;
|
||||
int nodaemon;
|
||||
int opt, cmd_err;
|
||||
char *fs_name; /* name of filesystem to clean */
|
||||
extern int optind;
|
||||
|
||||
cmd_err = nodaemon = 0;
|
||||
clean_opts = 0;
|
||||
segs_per_clean = 1;
|
||||
while ((opt = getopt(argc, argv, "bdmn:r:s")) != EOF) {
|
||||
while ((opt = getopt(argc, argv, "smd")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'b': /*
|
||||
* Use live bytes to determine
|
||||
* how many segs to clean.
|
||||
*/
|
||||
clean_opts |= CLEAN_BYTES;
|
||||
break;
|
||||
case 'd': /* Debug mode. */
|
||||
nodaemon = 1;
|
||||
break;
|
||||
case 'm': /* Use mmap instead of read/write */
|
||||
do_mmap = 1;
|
||||
break;
|
||||
case 'n': /* How many segs to clean at once */
|
||||
segs_per_clean = atoi(optarg);
|
||||
break;
|
||||
case 'r': /* Report every stat_report segments */
|
||||
stat_report = atoi(optarg);
|
||||
break;
|
||||
case 's': /* small writes */
|
||||
do_small = 1;
|
||||
break;
|
||||
case 'm':
|
||||
do_mmap = 1;
|
||||
break;
|
||||
case 'd':
|
||||
nodaemon = 1;
|
||||
break;
|
||||
default:
|
||||
++cmd_err;
|
||||
}
|
||||
|
@ -203,7 +187,7 @@ main(argc, argv)
|
|||
signal(SIGINT, sig_report);
|
||||
signal(SIGUSR1, sig_report);
|
||||
signal(SIGUSR2, sig_report);
|
||||
if (fs_getmntinfo(&lstatfsp, fs_name, "lfs") == 0) {
|
||||
if (fs_getmntinfo(&lstatfsp, fs_name, MOUNT_LFS) == 0) {
|
||||
/* didn't find the filesystem */
|
||||
err(1, "lfs_cleanerd: filesystem %s isn't an LFS!", fs_name);
|
||||
}
|
||||
|
@ -225,7 +209,7 @@ main(argc, argv)
|
|||
* to make sure that some nasty process hasn't just
|
||||
* filled the disk system up.
|
||||
*/
|
||||
if (clean_loop(fsp, segs_per_clean, clean_opts))
|
||||
if (clean_loop(fsp))
|
||||
continue;
|
||||
|
||||
#ifdef VERBOSE
|
||||
|
@ -241,42 +225,30 @@ main(argc, argv)
|
|||
|
||||
/* return the number of segments cleaned */
|
||||
int
|
||||
clean_loop(fsp, nsegs, options)
|
||||
clean_loop(fsp)
|
||||
FS_INFO *fsp; /* file system information */
|
||||
int nsegs;
|
||||
long options;
|
||||
{
|
||||
double loadavg[MAXLOADS];
|
||||
time_t now;
|
||||
u_long max_free_segs;
|
||||
u_long db_per_seg;
|
||||
|
||||
/*
|
||||
* Compute the maximum possible number of free segments, given the
|
||||
* number of free blocks.
|
||||
*/
|
||||
db_per_seg = fsbtodb(&fsp->fi_lfs, fsp->fi_lfs.lfs_ssize);
|
||||
max_free_segs = fsp->fi_lfs.lfs_bfree / db_per_seg;
|
||||
max_free_segs = fsp->fi_statfsp->f_bfree / fsp->fi_lfs.lfs_ssize;
|
||||
|
||||
/*
|
||||
* We will clean if there are not enough free blocks or total clean
|
||||
* space is less than BUSY_LIM % of possible clean space.
|
||||
*/
|
||||
now = time((time_t *)NULL);
|
||||
#ifdef VERBOSE
|
||||
printf("db_er_seg = %d max_free_segs = %d, bfree = %d avail = %d ",
|
||||
db_per_seg, max_free_segs, fsp->fi_lfs.lfs_bfree,
|
||||
fsp->fi_lfs.lfs_avail);
|
||||
printf("clean = %d\n", fsp->fi_cip->clean);
|
||||
#endif
|
||||
if ((fsp->fi_lfs.lfs_bfree - fsp->fi_lfs.lfs_avail > db_per_seg &&
|
||||
fsp->fi_lfs.lfs_avail < db_per_seg) ||
|
||||
(fsp->fi_cip->clean < max_free_segs &&
|
||||
if (fsp->fi_cip->clean < max_free_segs &&
|
||||
(fsp->fi_cip->clean <= MIN_SEGS(&fsp->fi_lfs) ||
|
||||
fsp->fi_cip->clean < max_free_segs * BUSY_LIM))) {
|
||||
printf("Cleaner Running at %s (%d of %d segments available)\n",
|
||||
fsp->fi_cip->clean < max_free_segs * BUSY_LIM)) {
|
||||
printf("Cleaner Running at %s (%d of %ld segments available)\n",
|
||||
ctime(&now), fsp->fi_cip->clean, max_free_segs);
|
||||
clean_fs(fsp, cost_benefit, nsegs, options);
|
||||
clean_fs(fsp, cost_benefit);
|
||||
return (1);
|
||||
} else {
|
||||
/*
|
||||
|
@ -290,7 +262,7 @@ clean_loop(fsp, nsegs, options)
|
|||
}
|
||||
if (loadavg[ONE_MIN] == 0.0 && loadavg[FIVE_MIN] &&
|
||||
fsp->fi_cip->clean < max_free_segs * IDLE_LIM) {
|
||||
clean_fs(fsp, cost_benefit, nsegs, options);
|
||||
clean_fs(fsp, cost_benefit);
|
||||
printf("Cleaner Running at %s (system idle)\n",
|
||||
ctime(&now));
|
||||
return (1);
|
||||
|
@ -302,14 +274,11 @@ clean_loop(fsp, nsegs, options)
|
|||
|
||||
|
||||
void
|
||||
clean_fs(fsp, cost_func, nsegs, options)
|
||||
clean_fs(fsp, cost_func)
|
||||
FS_INFO *fsp; /* file system information */
|
||||
int (*cost_func) __P((FS_INFO *, SEGUSE *));
|
||||
int nsegs;
|
||||
long options;
|
||||
{
|
||||
struct seglist *segs, *sp;
|
||||
int to_clean, cleaned_bytes;
|
||||
int i;
|
||||
|
||||
if ((segs =
|
||||
|
@ -323,33 +292,15 @@ clean_fs(fsp, cost_func, nsegs, options)
|
|||
i, fsp->fi_statfsp->f_mntonname);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
if (i) {
|
||||
/* Check which cleaning algorithm to use. */
|
||||
if (options & CLEAN_BYTES) {
|
||||
cleaned_bytes = 0;
|
||||
to_clean = nsegs <<
|
||||
(fsp->fi_lfs.lfs_segshift + fsp->fi_lfs.lfs_bshift);
|
||||
for (sp = segs; i && cleaned_bytes < to_clean;
|
||||
i--, ++sp) {
|
||||
if (clean_segment(fsp, sp->sl_id) < 0)
|
||||
perror("clean_segment failed");
|
||||
else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
|
||||
sp->sl_id) < 0)
|
||||
perror("lfs_segclean failed");
|
||||
printf("Cleaned segment %d (%d bytes)\n",
|
||||
sp->sl_id, sp->sl_bytes);
|
||||
cleaned_bytes += sp->sl_bytes;
|
||||
}
|
||||
} else
|
||||
for (i = MIN(i, nsegs), sp = segs; i-- ; ++sp) {
|
||||
if (clean_segment(fsp, sp->sl_id) < 0)
|
||||
perror("clean_segment failed");
|
||||
else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
|
||||
sp->sl_id) < 0)
|
||||
perror("lfs_segclean failed");
|
||||
printf("Completed cleaning segment %d\n", sp->sl_id);
|
||||
}
|
||||
}
|
||||
if (i)
|
||||
for (i = MIN(i, NUM_TO_CLEAN(fsp)), sp = segs; i-- ; ++sp) {
|
||||
if (clean_segment(fsp, sp->sl_id) < 0)
|
||||
perror("clean_segment failed");
|
||||
else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
|
||||
sp->sl_id) < 0)
|
||||
perror("lfs_segclean failed");
|
||||
printf("Completed cleaning segment %d\n", sp->sl_id);
|
||||
}
|
||||
free(segs);
|
||||
}
|
||||
|
||||
|
@ -402,7 +353,7 @@ choose_segments(fsp, seglist, cost_func)
|
|||
#endif
|
||||
sp->sl_cost = (*cost_func)(fsp, sup);
|
||||
sp->sl_id = i;
|
||||
sp->sl_bytes = sup->su_nbytes;
|
||||
sp->sl_empty = sup->su_nbytes ? 0 : 1;
|
||||
++sp;
|
||||
}
|
||||
nsegs = sp - seglist;
|
||||
|
@ -424,7 +375,6 @@ clean_segment(fsp, id)
|
|||
struct lfs *lfsp;
|
||||
struct tossstruct t;
|
||||
caddr_t seg_buf;
|
||||
double util;
|
||||
int num_blocks, maxblocks, clean_blocks;
|
||||
|
||||
lfsp = &fsp->fi_lfs;
|
||||
|
@ -491,14 +441,8 @@ clean_segment(fsp, id)
|
|||
lp = (u_long *)_bip->bi_bp;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
++cleaner_stats.segs_cleaned;
|
||||
cleaner_stats.blocks_written += num_blocks;
|
||||
util = ((double)num_blocks / fsp->fi_lfs.lfs_ssize);
|
||||
cleaner_stats.util_tot += util;
|
||||
cleaner_stats.util_sos += util * util;
|
||||
|
||||
if (do_small)
|
||||
maxblocks = MAXPHYS / fsp->fi_lfs.lfs_bsize - 1;
|
||||
else
|
||||
|
@ -517,8 +461,7 @@ clean_segment(fsp, id)
|
|||
|
||||
free(block_array);
|
||||
munmap_segment(fsp, seg_buf, do_mmap);
|
||||
if (stat_report && cleaner_stats.segs_cleaned % stat_report == 0)
|
||||
sig_report(SIGUSR1);
|
||||
++cleaner_stats.segs_cleaned;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -541,30 +484,18 @@ void
|
|||
sig_report(sig)
|
||||
int sig;
|
||||
{
|
||||
double avg;
|
||||
|
||||
printf("lfs_cleanerd:\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n",
|
||||
"blocks_read ", cleaner_stats.blocks_read,
|
||||
"blocks_written ", cleaner_stats.blocks_written,
|
||||
"segs_cleaned ", cleaner_stats.segs_cleaned,
|
||||
"segs_empty ", cleaner_stats.segs_empty,
|
||||
"seg_error ", cleaner_stats.segs_error);
|
||||
printf("\t\t%s%5.2f\n\t\t%s%5.2f\n",
|
||||
"util_tot ", cleaner_stats.util_tot,
|
||||
"util_sos ", cleaner_stats.util_sos);
|
||||
printf("\t\tavg util: %4.2f std dev: %9.6f\n",
|
||||
avg = cleaner_stats.util_tot / cleaner_stats.segs_cleaned,
|
||||
cleaner_stats.util_sos / cleaner_stats.segs_cleaned - avg * avg);
|
||||
|
||||
|
||||
if (sig == SIGUSR2) {
|
||||
cleaner_stats.blocks_read = 0;
|
||||
cleaner_stats.blocks_written = 0;
|
||||
cleaner_stats.segs_cleaned = 0;
|
||||
cleaner_stats.segs_empty = 0;
|
||||
cleaner_stats.segs_error = 0;
|
||||
cleaner_stats.util_tot = 0.0;
|
||||
cleaner_stats.util_sos = 0.0;
|
||||
}
|
||||
if (sig == SIGINT)
|
||||
exit(0);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: library.c,v 1.4 1997/10/07 13:39:59 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -31,9 +33,13 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)library.c 8.1 (Berkeley) 6/4/93";*/
|
||||
static char *rcsid = "$Id: library.c,v 1.3 1997/08/01 06:33:39 mikel Exp $";
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)library.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: library.c,v 1.4 1997/10/07 13:39:59 mrg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -46,6 +52,7 @@ static char *rcsid = "$Id: library.c,v 1.3 1997/08/01 06:33:39 mikel Exp $";
|
|||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/lfs/lfs.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -63,6 +70,9 @@ int bi_toss __P((const void *, const void *, const void *));
|
|||
void get_ifile __P((FS_INFO *, int));
|
||||
int get_superblock __P((FS_INFO *, struct lfs *));
|
||||
int pseg_valid __P((FS_INFO *, SEGSUM *));
|
||||
void print_SEGSUM __P((struct lfs *, SEGSUM *));
|
||||
|
||||
extern u_long cksum __P((void *, size_t)); /* XXX */
|
||||
|
||||
/*
|
||||
* This function will get information on a a filesystem which matches
|
||||
|
@ -108,7 +118,6 @@ get_fs_info (lstatfsp, use_mmap)
|
|||
int use_mmap; /* IN: mmap or read */
|
||||
{
|
||||
FS_INFO *fsp;
|
||||
int i;
|
||||
|
||||
fsp = (FS_INFO *)malloc(sizeof(FS_INFO));
|
||||
if (fsp == NULL)
|
||||
|
@ -134,7 +143,6 @@ reread_fs_info(fsp, use_mmap)
|
|||
FS_INFO *fsp; /* IN: prointer fs_infos to reread */
|
||||
int use_mmap;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (statfs(fsp->fi_statfsp->f_mntonname, fsp->fi_statfsp))
|
||||
err(1, "reread_fs_info: statfs failed");
|
||||
|
@ -238,8 +246,18 @@ redo_read:
|
|||
* and segment usage table multiplied by the number of ifile
|
||||
* entries per page.
|
||||
*/
|
||||
fsp->fi_ifile_count = (fsp->fi_ifile_length >> fsp->fi_lfs.lfs_bshift -
|
||||
fsp->fi_lfs.lfs_cleansz - fsp->fi_lfs.lfs_segtabsz) *
|
||||
/*
|
||||
* XXX this used to read:
|
||||
*
|
||||
* fsp->fi_ifile_count = (fsp->fi_ifile_length >> fsp->fi_lfs.lfs_bshift -
|
||||
* fsp->fi_lfs.lfs_cleansz - fsp->fi_lfs.lfs_segtabsz) *
|
||||
* fsp->fi_lfs.lfs_ifpb;
|
||||
*
|
||||
* but now has ()'s around the -'s to quell a GCC warning. This
|
||||
* may not have been the intended purpose, however!
|
||||
*/
|
||||
fsp->fi_ifile_count = (fsp->fi_ifile_length >> (fsp->fi_lfs.lfs_bshift -
|
||||
fsp->fi_lfs.lfs_cleansz - fsp->fi_lfs.lfs_segtabsz)) *
|
||||
fsp->fi_lfs.lfs_ifpb;
|
||||
|
||||
free (ifile_name);
|
||||
|
@ -267,9 +285,13 @@ lfs_segmapv(fsp, seg, seg_buf, blocks, bcount)
|
|||
struct lfs *lfsp;
|
||||
caddr_t s, segend;
|
||||
daddr_t pseg_addr, seg_addr;
|
||||
int i, nelem, nblocks, sumsize;
|
||||
int nelem, nblocks, sumsize;
|
||||
time_t timestamp;
|
||||
#if defined(VERBOSE) || defined(DIAGNOSTIC)
|
||||
int i = 0; /* XXX gcc */
|
||||
#endif
|
||||
|
||||
i = 0;
|
||||
lfsp = &fsp->fi_lfs;
|
||||
nelem = 2 * lfsp->lfs_ssize;
|
||||
if (!(bip = malloc(nelem * sizeof(BLOCK_INFO))))
|
||||
|
@ -425,7 +447,7 @@ add_inodes (fsp, bip, countp, sp, seg_buf, seg_addr)
|
|||
caddr_t seg_buf; /* the buffer containing the segment's data */
|
||||
daddr_t seg_addr; /* disk address of seg_buf */
|
||||
{
|
||||
struct dinode *di;
|
||||
struct dinode *di = NULL; /* XXX gcc */
|
||||
struct lfs *lfsp;
|
||||
IFILE *ifp;
|
||||
BLOCK_INFO *bp;
|
||||
|
@ -589,7 +611,6 @@ munmap_segment (fsp, seg_buf, use_mmap)
|
|||
free (seg_buf);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* USEFUL DEBUGGING TOOLS:
|
||||
*/
|
||||
|
@ -615,9 +636,9 @@ bi_compare(a, b)
|
|||
ba = a;
|
||||
bb = b;
|
||||
|
||||
if (diff = (int)(ba->bi_inode - bb->bi_inode))
|
||||
if ((diff = (int)(ba->bi_inode - bb->bi_inode)))
|
||||
return (diff);
|
||||
if (diff = (int)(ba->bi_lbn - bb->bi_lbn)) {
|
||||
if ((diff = (int)(ba->bi_lbn - bb->bi_lbn))) {
|
||||
if (ba->bi_lbn == LFS_UNUSED_LBN)
|
||||
return(-1);
|
||||
else if (bb->bi_lbn == LFS_UNUSED_LBN)
|
||||
|
@ -629,7 +650,7 @@ bi_compare(a, b)
|
|||
else
|
||||
return (diff);
|
||||
}
|
||||
if (diff = (int)(ba->bi_segcreate - bb->bi_segcreate))
|
||||
if ((diff = (int)(ba->bi_segcreate - bb->bi_segcreate)))
|
||||
return (diff);
|
||||
diff = (int)(ba->bi_daddr - bb->bi_daddr);
|
||||
return (diff);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: misc.c,v 1.2 1997/10/07 13:39:59 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -31,51 +33,31 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93";
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: misc.c,v 1.2 1997/10/07 13:39:59 mrg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/lfs/lfs.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "clean.h"
|
||||
|
||||
extern char *special;
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(const int fatal, const char *fmt, ...)
|
||||
#else
|
||||
err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "%s: ", special);
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
if (errno)
|
||||
(void)fprintf(stderr, " %s", strerror(errno));
|
||||
(void)fprintf(stderr, "\n");
|
||||
if (fatal)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
get(fd, off, p, len)
|
||||
int fd;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: print.c,v 1.2 1997/10/07 13:40:00 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -31,8 +33,13 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)print.c 8.2 (Berkeley) 5/24/95";
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)print.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: print.c,v 1.2 1997/10/07 13:40:00 mrg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -47,6 +54,8 @@ static char sccsid[] = "@(#)print.c 8.2 (Berkeley) 5/24/95";
|
|||
#include <stdio.h>
|
||||
#include "clean.h"
|
||||
|
||||
extern u_long cksum __P((void *, size_t)); /* XXX */
|
||||
|
||||
/*
|
||||
* Print out a summary block; return number of blocks in segment; 0
|
||||
* for empty segment or corrupt segment.
|
||||
|
@ -65,32 +74,22 @@ dump_summary(lfsp, sp, flags, iaddrp)
|
|||
FINFO *fp;
|
||||
int ck;
|
||||
|
||||
if (sp->ss_magic != SS_MAGIC)
|
||||
return(-1);
|
||||
|
||||
if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum,
|
||||
LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum))))
|
||||
return(-1);
|
||||
|
||||
numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
|
||||
|
||||
/* Do some basic sanity checking. */
|
||||
if (sp->ss_nfinfo > LFS_SUMMARY_SIZE / sizeof(FINFO) ||
|
||||
numblocks > lfsp->lfs_ssize ||
|
||||
numblocks > LFS_SUMMARY_SIZE / sizeof(daddr_t))
|
||||
return(-1);
|
||||
|
||||
if (flags & DUMP_SUM_HEADER) {
|
||||
(void)printf(" %s0x%X\t%s%d\t%s%d\n %s0x%X\t%s0x%X\t%s0x%X\n",
|
||||
(void)printf(" %s0x%X\t%s%d\t%s%d\n %s0x%X\t%s0x%X",
|
||||
"next ", sp->ss_next,
|
||||
"nfinfo ", sp->ss_nfinfo,
|
||||
"ninos ", sp->ss_ninos,
|
||||
"sumsum ", sp->ss_sumsum,
|
||||
"datasum ", sp->ss_datasum,
|
||||
"magic ", sp->ss_magic);
|
||||
(void)printf(" create %s", ctime((time_t *)&sp->ss_create));
|
||||
"datasum ", sp->ss_datasum );
|
||||
(void)printf("\tcreate %s", ctime((time_t *)&sp->ss_create));
|
||||
}
|
||||
|
||||
numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
|
||||
|
||||
/* Dump out inode disk addresses */
|
||||
if (flags & DUMP_INODE_ADDRS)
|
||||
printf(" Inode addresses:");
|
||||
|
@ -98,7 +97,7 @@ dump_summary(lfsp, sp, flags, iaddrp)
|
|||
dp = (daddr_t *)((caddr_t)sp + LFS_SUMMARY_SIZE);
|
||||
for (--dp, i = 0; i < sp->ss_ninos; --dp)
|
||||
if (flags & DUMP_INODE_ADDRS) {
|
||||
(void)printf("\t0x%lx", *dp);
|
||||
(void)printf("\t0x%lx", (u_long)*dp);
|
||||
if (++i % 7 == 0)
|
||||
(void)printf("\n");
|
||||
} else
|
||||
|
@ -171,13 +170,13 @@ dump_super(lfsp)
|
|||
"cleansz ", lfsp->lfs_cleansz,
|
||||
"segtabsz ", lfsp->lfs_segtabsz);
|
||||
|
||||
(void)printf("%s0x%X\t%s%d\t%s0x%qX\t%s%d\n",
|
||||
(void)printf("%s0x%X\t%s%d\t%s0x%X\t%s%d\n",
|
||||
"segmask ", lfsp->lfs_segmask,
|
||||
"segshift ", lfsp->lfs_segshift,
|
||||
"bmask ", lfsp->lfs_bmask,
|
||||
"bshift ", lfsp->lfs_bshift);
|
||||
|
||||
(void)printf("%s0x%qX\t\t%s%d\t%s0x%qX\t%s%d\n",
|
||||
(void)printf("%s0x%X\t\t%s%d\t%s0x%X\t%s%d\n",
|
||||
"ffmask ", lfsp->lfs_ffmask,
|
||||
"ffshift ", lfsp->lfs_ffshift,
|
||||
"fbmask ", lfsp->lfs_fbmask,
|
||||
|
|
Loading…
Reference in New Issue