Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin Working version of aborted dump{,_lfs} join.



details:   https://anonhg.NetBSD.org/src/rev/d3e115fb97b0
branches:  trunk
changeset: 476894:d3e115fb97b0
user:      perseant <perseant%NetBSD.org@localhost>
date:      Fri Oct 01 04:35:21 1999 +0000

description:
Working version of aborted dump{,_lfs} join.

diffstat:

 sbin/Makefile             |    4 +-
 sbin/dump/Makefile        |    8 +-
 sbin/dump/dump.h          |   40 +++++++++-
 sbin/dump/ffs_inode.c     |  176 ++++++++++++++++++++++++++++++++++++++++++++++
 sbin/dump/main.c          |   39 +--------
 sbin/dump/rcache.c        |    7 +-
 sbin/dump/tape.c          |    7 +-
 sbin/dump/traverse.c      |   81 +++++++-------------
 sbin/dump_lfs/lfs_inode.c |   13 ++-
 9 files changed, 271 insertions(+), 104 deletions(-)

diffs (truncated from 700 to 300 lines):

diff -r 3ad825d5aa0a -r d3e115fb97b0 sbin/Makefile
--- a/sbin/Makefile     Fri Oct 01 04:06:47 1999 +0000
+++ b/sbin/Makefile     Fri Oct 01 04:35:21 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.61 1999/09/30 21:06:57 perseant Exp $
+#      $NetBSD: Makefile,v 1.62 1999/10/01 04:35:21 perseant Exp $
 #      @(#)Makefile    8.5 (Berkeley) 3/31/94
 
 # Not ported: XNSrouted enpload scsiformat startslip
@@ -17,7 +17,7 @@
 SUBDIR+= mount_filecore
 SUBDIR+= mount_ffs     newfs fsck_ffs fsdb dump restore clri tunefs
 SUBDIR+= mount_kernfs
-SUBDIR+= mount_lfs     newfs_lfs fsck_lfs # dump_lfs
+SUBDIR+= mount_lfs     newfs_lfs fsck_lfs dump_lfs
 # mount_mfs -> newfs
 SUBDIR+= mount_msdos   newfs_msdos fsck_msdos
 SUBDIR+= mount_nfs
diff -r 3ad825d5aa0a -r d3e115fb97b0 sbin/dump/Makefile
--- a/sbin/dump/Makefile        Fri Oct 01 04:06:47 1999 +0000
+++ b/sbin/dump/Makefile        Fri Oct 01 04:35:21 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.24 1999/09/30 20:39:58 perseant Exp $
+#      $NetBSD: Makefile,v 1.25 1999/10/01 04:35:22 perseant Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/5/93
 
 #      dump.h                  header file
@@ -9,16 +9,18 @@
 #      tape.c                  handles the mag tape and opening/closing
 #      traverse.c              traverses the file system
 #      unctime.c               undo ctime
+#      ffs_inode.c             FFS-specific filestore routines
+#      ffs_bswap.c             FFS byte-swapping
 #
 #      DEBUG                   use local directory to find ddate and dumpdates
 #      TDEBUG                  trace out the process forking
 
 PROG=  dump
 LINKS= ${BINDIR}/dump ${BINDIR}/rdump
-CPPFLAGS+=-DRDUMP
+CPPFLAGS+=-DRDUMP -I${.CURDIR}
 # CPPFLAGS+= -DDEBUG -DTDEBUG -DFDEBUG -DWRITEDEBUG -DSTATS -DDIAGNOSTICS
 SRCS=  itime.c main.c optr.c dumprmt.c rcache.c tape.c traverse.c unctime.c \
-       ffs_bswap.c
+       ffs_inode.c ffs_bswap.c
 BINGRP=        tty
 BINMODE=2555
 MAN=   dump.8
diff -r 3ad825d5aa0a -r d3e115fb97b0 sbin/dump/dump.h
--- a/sbin/dump/dump.h  Fri Oct 01 04:06:47 1999 +0000
+++ b/sbin/dump/dump.h  Fri Oct 01 04:35:21 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dump.h,v 1.18 1999/09/30 20:39:58 perseant Exp $       */
+/*     $NetBSD: dump.h,v 1.19 1999/10/01 04:35:22 perseant Exp $       */
 
 /*-
  * Copyright (c) 1980, 1993
@@ -41,6 +41,36 @@
 #define MAXNINDIR      (MAXBSIZE / sizeof(daddr_t))
 
 /*
+ * Filestore-independent UFS data, so code can be more easily shared
+ * between ffs, lfs, and maybe ext2fs and others as well.
+ */
+struct ufsi {
+       int64_t ufs_dsize;      /* filesystem size, in sectors */
+       int32_t ufs_bsize;      /* block size */
+       int32_t ufs_bshift;     /* log2(ufs_bsize) */
+       int32_t ufs_fsize;      /* fragment size */
+       int32_t ufs_frag;       /* block size / frag size */
+       int32_t ufs_fsatoda;    /* disk address conversion constant */
+       int32_t ufs_nindir;     /* disk addresses per indirect block */
+       int32_t ufs_inopb;      /* inodes per block */
+       int32_t ufs_maxsymlinklen; /* max symlink length */
+       int32_t ufs_bmask;      /* block mask */
+       int32_t ufs_fmask;      /* frag mask */
+       int64_t ufs_qbmask;     /* ~ufs_bmask */
+       int64_t ufs_qfmask;     /* ~ufs_fmask */
+};
+#define fsatoda(u,a) ((a) << (u)->ufs_fsatoda)
+#define ufs_fragroundup(u,size) /* calculates roundup(size, ufs_fsize) */ \
+        (((size) + (u)->ufs_qfmask) & (u)->ufs_fmask)
+#define ufs_blkoff(u,loc)   /* calculates (loc % u->ufs_bsize) */ \
+        ((loc) & (u)->ufs_qbmask)
+#define ufs_dblksize(u,d,b) \
+       ((((b) >= NDADDR || (d)->di_size >= ((b)+1) << (u)->ufs_bshift \
+               ? (u)->ufs_bsize \
+               : (ufs_fragroundup((u), ufs_blkoff(u, (d)->di_size))))))
+struct ufsi *ufsib;
+
+/*
  * Dump maps used to describe what is to be dumped.
  */
 int    mapsize;        /* size of the state maps */
@@ -84,8 +114,7 @@
 int    tapeno;         /* current tape number */
 time_t tstart_writing; /* when started writing the first tape block */
 int    xferrate;       /* averaged transfer rate of all volumes */
-struct fs *sblock;     /* the file system super block */
-char   sblock_buf[MAXBSIZE];
+char   sblock_buf[MAXBSIZE]; /* buffer to hold the superblock */
 long   dev_bsize;      /* block size of underlying disk device */
 int    dev_bshift;     /* log2(dev_bsize) */
 int    tp_bshift;      /* log2(TP_BSIZE) */
@@ -123,6 +152,11 @@
 #include <sys/cdefs.h>
 #endif
 
+/* filestore-specific hooks */
+int    fs_read_sblock __P((char *));
+struct ufsi *fs_parametrize __P((void));
+ino_t  fs_maxino __P((void));
+
 /* operator interface functions */
 void   broadcast __P((char *message));
 void   lastdump __P((int arg));        /* int should be char */
diff -r 3ad825d5aa0a -r d3e115fb97b0 sbin/dump/ffs_inode.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/dump/ffs_inode.c     Fri Oct 01 04:35:21 1999 +0000
@@ -0,0 +1,176 @@
+/*      $NetBSD: ffs_inode.c,v 1.3 1999/10/01 04:35:22 perseant Exp $ */
+
+/*-
+ * Copyright (c) 1980, 1991, 1993, 1994
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\n\
+        The Regents of the University of California.  All rights reserved.\n");
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)main.c      8.6 (Berkeley) 5/1/95";
+#else
+__RCSID("$NetBSD: ffs_inode.c,v 1.3 1999/10/01 04:35:22 perseant Exp $");
+#endif
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#ifdef sunos
+#include <sys/vnode.h>
+
+#include <ufs/fs.h>
+#include <ufs/fsdir.h>
+#include <ufs/inode.h>
+#else
+#include <ufs/ufs/dir.h>
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
+#include <ufs/ffs/ffs_extern.h>
+#endif
+
+#include <protocols/dumprestore.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fts.h>
+#include <stdio.h>
+#ifdef __STDC__
+#include <string.h>
+#include <unistd.h>
+#endif
+
+#include "dump.h"
+
+#ifndef SBOFF
+#define SBOFF (SBLOCK * DEV_BSIZE)
+#endif
+
+struct fs *sblock;
+
+/*
+ * Read the superblock from disk, and check its magic number.
+ * Determine whether byte-swapping needs to be done on this filesystem.
+ */
+int
+fs_read_sblock(char *sblock_buf)
+{
+       int needswap = 0;
+
+       sblock = (struct fs *)sblock_buf;
+       rawread(SBOFF, (char *) sblock, SBSIZE);
+       if (sblock->fs_magic != FS_MAGIC) {
+               if (sblock->fs_magic == bswap32(FS_MAGIC)) {
+                       ffs_sb_swap(sblock, sblock, 0);
+                       needswap = 1;
+               } else
+                       quit("bad sblock magic number\n");
+       }
+       return needswap;
+}
+
+/*
+ * Fill in the ufsi struct, as well as the maxino and dev_bsize global
+ * variables.
+ */
+struct ufsi *
+fs_parametrize(void)
+{
+       static struct ufsi ufsi;
+
+#ifdef FS_44INODEFMT
+       if (sblock->fs_inodefmt >= FS_44INODEFMT) {
+               spcl.c_flags = iswap32(iswap32(spcl.c_flags) | DR_NEWINODEFMT);
+       } else {
+               /*
+                * Determine parameters for older filesystems. From
+                *      /sys/ufs/ffs/ffs_vfsops.c::ffs_oldfscompat()
+                *
+                * XXX: not sure if other variables (fs_npsect, fs_interleave,
+                * fs_nrpos, fs_maxfilesize) need to be fudged too.
+                */
+               sblock->fs_qbmask = ~sblock->fs_bmask;
+               sblock->fs_qfmask = ~sblock->fs_fmask;
+       }
+#endif
+
+       /* Fill out ufsi struct */
+       ufsi.ufs_dsize = fsbtodb(sblock,sblock->fs_size);
+       ufsi.ufs_bsize = sblock->fs_bsize;
+       ufsi.ufs_bshift = sblock->fs_bshift;
+       ufsi.ufs_fsize = sblock->fs_fsize;
+       ufsi.ufs_frag = sblock->fs_frag;
+       ufsi.ufs_fsatoda = sblock->fs_fsbtodb;
+       ufsi.ufs_nindir = sblock->fs_nindir;
+       ufsi.ufs_inopb = sblock->fs_inopb;
+       ufsi.ufs_maxsymlinklen = sblock->fs_maxsymlinklen;
+       ufsi.ufs_bmask = sblock->fs_bmask;
+       ufsi.ufs_fmask = sblock->fs_fmask;
+       ufsi.ufs_qbmask = sblock->fs_qbmask;
+       ufsi.ufs_qfmask = sblock->fs_qfmask;
+
+       dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1);
+
+       return &ufsi;
+}
+
+ino_t
+fs_maxino(void)
+{
+       return sblock->fs_ipg * sblock->fs_ncg;
+}
+
+struct dinode *
+getino(inum)
+       ino_t inum;
+{
+       static daddr_t minino, maxino;
+       static struct dinode inoblock[MAXINOPB];
+       int i;
+
+       curino = inum;
+       if (inum >= minino && inum < maxino)
+               return (&inoblock[inum - minino]);
+       bread(fsatoda(ufsib, ino_to_fsba(sblock, inum)), (char *)inoblock,
+           (int)ufsib->ufs_bsize);
+       if (needswap)
+               for (i = 0; i < MAXINOPB; i++)
+                       ffs_dinode_swap(&inoblock[i], &inoblock[i]);
+       minino = inum - (inum % INOPB(sblock));
+       maxino = minino + INOPB(sblock);
+       return (&inoblock[inum - minino]);
+}
diff -r 3ad825d5aa0a -r d3e115fb97b0 sbin/dump/main.c
--- a/sbin/dump/main.c  Fri Oct 01 04:06:47 1999 +0000
+++ b/sbin/dump/main.c  Fri Oct 01 04:35:21 1999 +0000
@@ -1,4 +1,4 @@



Home | Main Index | Thread Index | Old Index