Annotation of 43BSDReno/sbin/restore/restore.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that: (1) source distributions retain this entire copyright
                      7:  * notice and comment, and (2) distributions including binaries display
                      8:  * the following acknowledgement:  ``This product includes software
                      9:  * developed by the University of California, Berkeley and its contributors''
                     10:  * in the documentation or other materials provided with the distribution
                     11:  * and in all advertising materials mentioning features or use of this
                     12:  * software. Neither the name of the University nor the names of its
                     13:  * contributors may be used to endorse or promote products derived
                     14:  * from this software without specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  *
                     19:  *     @(#)restore.h   5.8 (Berkeley) 6/1/90
                     20:  */
                     21: 
                     22: #include <stdio.h>
                     23: #include <sys/param.h>
                     24: #include <sys/time.h>
                     25: #include <ufs/dinode.h>
                     26: #include <ufs/fs.h>
                     27: 
                     28: /*
                     29:  * Flags
                     30:  */
                     31: extern int     cvtflag;        /* convert from old to new tape format */
                     32: extern int     bflag;          /* set input block size */
                     33: extern int     dflag;          /* print out debugging info */
                     34: extern int     hflag;          /* restore heirarchies */
                     35: extern int     mflag;          /* restore by name instead of inode number */
                     36: extern int     Nflag;          /* do not write the disk */
                     37: extern int     vflag;          /* print out actions taken */
                     38: extern int     yflag;          /* always try to recover from tape errors */
                     39: /*
                     40:  * Global variables
                     41:  */
                     42: extern char    *dumpmap;       /* map of inodes on this dump tape */
                     43: extern char    *clrimap;       /* map of inodes to be deleted */
                     44: extern ino_t   maxino;         /* highest numbered inode in this file system */
                     45: extern long    dumpnum;        /* location of the dump on this tape */
                     46: extern long    volno;          /* current volume being read */
                     47: extern long    ntrec;          /* number of TP_BSIZE records per tape block */
                     48: extern time_t  dumptime;       /* time that this dump begins */
                     49: extern time_t  dumpdate;       /* time that this dump was made */
                     50: extern char    command;        /* opration being performed */
                     51: extern FILE    *terminal;      /* file descriptor for the terminal input */
                     52: 
                     53: /*
                     54:  * Each file in the file system is described by one of these entries
                     55:  */
                     56: struct entry {
                     57:        char    *e_name;                /* the current name of this entry */
                     58:        u_char  e_namlen;               /* length of this name */
                     59:        char    e_type;                 /* type of this entry, see below */
                     60:        short   e_flags;                /* status flags, see below */
                     61:        ino_t   e_ino;                  /* inode number in previous file sys */
                     62:        long    e_index;                /* unique index (for dumpped table) */
                     63:        struct  entry *e_parent;        /* pointer to parent directory (..) */
                     64:        struct  entry *e_sibling;       /* next element in this directory (.) */
                     65:        struct  entry *e_links;         /* hard links to this inode */
                     66:        struct  entry *e_entries;       /* for directories, their entries */
                     67:        struct  entry *e_next;          /* hash chain list */
                     68: };
                     69: /* types */
                     70: #define        LEAF 1                  /* non-directory entry */
                     71: #define NODE 2                 /* directory entry */
                     72: #define LINK 4                 /* synthesized type, stripped by addentry */
                     73: /* flags */
                     74: #define EXTRACT                0x0001  /* entry is to be replaced from the tape */
                     75: #define NEW            0x0002  /* a new entry to be extracted */
                     76: #define KEEP           0x0004  /* entry is not to change */
                     77: #define REMOVED                0x0010  /* entry has been removed */
                     78: #define TMPNAME                0x0020  /* entry has been given a temporary name */
                     79: #define EXISTED                0x0040  /* directory already existed during extract */
                     80: /*
                     81:  * functions defined on entry structs
                     82:  */
                     83: extern struct entry *lookupino();
                     84: extern struct entry *lookupname();
                     85: extern struct entry *lookupparent();
                     86: extern struct entry *addentry();
                     87: extern char *myname();
                     88: extern char *savename();
                     89: extern char *gentempname();
                     90: extern char *flagvalues();
                     91: extern ino_t lowerbnd();
                     92: extern ino_t upperbnd();
                     93: #define NIL ((struct entry *)(0))
                     94: /*
                     95:  * Constants associated with entry structs
                     96:  */
                     97: #define HARDLINK       1
                     98: #define SYMLINK                2
                     99: #define TMPHDR         "RSTTMP"
                    100: 
                    101: /*
                    102:  * The entry describes the next file available on the tape
                    103:  */
                    104: struct context {
                    105:        char    *name;          /* name of file */
                    106:        ino_t   ino;            /* inumber of file */
                    107:        struct  dinode *dip;    /* pointer to inode */
                    108:        char    action;         /* action being taken on this file */
                    109: } curfile;
                    110: /* actions */
                    111: #define        USING   1       /* extracting from the tape */
                    112: #define        SKIP    2       /* skipping */
                    113: #define UNKNOWN 3      /* disposition or starting point is unknown */
                    114: 
                    115: /*
                    116:  * Definitions for library routines operating on directories.
                    117:  */
                    118: typedef struct dirdesc DIR;
                    119: extern DIR *rst_opendir();
                    120: extern struct direct *rst_readdir();
                    121: 
                    122: /*
                    123:  * Other exported routines
                    124:  */
                    125: extern ino_t psearch();
                    126: extern ino_t dirlookup();
                    127: extern long listfile();
                    128: extern long deletefile();
                    129: extern long addfile();
                    130: extern long nodeupdates();
                    131: extern long verifyfile();
                    132: extern char *rindex();
                    133: extern char *index();
                    134: extern char *strcat();
                    135: extern char *strncat();
                    136: extern char *strcpy();
                    137: extern char *strncpy();
                    138: extern char *fgets();
                    139: extern char *mktemp();
                    140: extern char *malloc();
                    141: extern char *calloc();
                    142: extern char *realloc();
                    143: extern long lseek();
                    144: 
                    145: /*
                    146:  * Useful macros
                    147:  */
                    148: #define        MWORD(m,i) (m[(unsigned)(i-1)/NBBY])
                    149: #define        MBIT(i) (1<<((unsigned)(i-1)%NBBY))
                    150: #define        BIS(i,w)        (MWORD(w,i) |=  MBIT(i))
                    151: #define        BIC(i,w)        (MWORD(w,i) &= ~MBIT(i))
                    152: #define        BIT(i,w)        (MWORD(w,i) & MBIT(i))
                    153: 
                    154: #define dprintf                if (dflag) fprintf
                    155: #define vprintf                if (vflag) fprintf
                    156: 
                    157: #define GOOD 1
                    158: #define FAIL 0

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.