fsck.c File Reference

#include <sys/types.h>
#include <sys/dir.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/type.h>
#include "../../servers/fs/const.h"
#include "../../servers/fs/inode.h"
#include "../../servers/fs/type.h"
#include <minix/fslib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <a.out.h>
#include <tools.h>
#include <dirent.h>
#include "../../servers/fs/super.h"

Include dependency graph for fsck.c:

Go to the source code of this file.

Data Structures

struct  stack

Defines

#define INODES_PER_BLOCK   V2_INODES_PER_BLOCK(block_size)
#define INODE_SIZE   ((int) V2_INODE_SIZE)
#define WORDS_PER_BLOCK   (block_size / (int) sizeof(bitchunk_t))
#define MAX_ZONES   (V2_NR_DZONES+V2_INDIRECTS(block_size)+(long)V2_INDIRECTS(block_size)*V2_INDIRECTS(block_size))
#define NR_DZONE_NUM   V2_NR_DZONES
#define NR_INDIRECTS   V2_INDIRECTS(block_size)
#define NR_ZONE_NUMS   V2_NR_TZONES
#define ZONE_NUM_SIZE   V2_ZONE_NUM_SIZE
#define bit_nr   bit_t
#define block_nr   block_t
#define d_inode   d2_inode
#define d_inum   d_ino
#define dir_struct   struct direct
#define i_mode   d2_mode
#define i_nlinks   d2_nlinks
#define i_size   d2_size
#define i_zone   d2_zone
#define zone_nr   zone_t
#define BITSHIFT   4
#define MAXPRINT   80
#define CINDIR   128
#define CDIRECT   1
#define BITMASK   ((1 << BITSHIFT) - 1)
#define WORDOFBIT(b)   ((b) >> BITSHIFT)
#define POWEROFBIT(b)   (1 << ((int) (b) & BITMASK))
#define setbit(w, b)   (w[WORDOFBIT(b)] |= POWEROFBIT(b))
#define clrbit(w, b)   (w[WORDOFBIT(b)] &= ~POWEROFBIT(b))
#define bitset(w, b)   (w[WORDOFBIT(b)] & POWEROFBIT(b))
#define ZONE_CT   360
#define INODE_CT   95
#define STICKY_BIT   01000
#define ztob(z)   ((block_nr) (z) << sb.s_log_zone_size)
#define btoa(b)   ((long) (b) * block_size)
#define SCALE   ((int) ztob(1))
#define FIRST   ((zone_nr) sb.s_firstdatazone)
#define N_IMAP   (sb.s_imap_blocks)
#define N_ZMAP   (sb.s_zmap_blocks)
#define N_ILIST   ((sb.s_ninodes+INODES_PER_BLOCK-1) / INODES_PER_BLOCK)
#define N_DATA   (sb.s_zones - FIRST)
#define OFFSET_SUPER_BLOCK   SUPER_BLOCK_BYTES
#define BLK_IMAP   2
#define BLK_ZMAP   (BLK_IMAP + N_IMAP)
#define BLK_ILIST   (BLK_ZMAP + N_ZMAP)
#define BLK_FIRST   ztob(FIRST)
#define ZONE_SIZE   ((int) ztob(block_size))
#define NLEVEL   (NR_ZONE_NUMS - NR_DZONE_NUM + 1)
#define zaddr(z)   btoa(ztob(z))
#define cinoaddr(i)   ((long) (i - 1) * INODE_SIZE + (long) btoa(BLK_ILIST))
#define INDCHUNK   ((int) (CINDIR * ZONE_NUM_SIZE))
#define DIRCHUNK   ((int) (CDIRECT * DIR_ENTRY_SIZE))
#define DOT   1
#define DOTDOT   2

Functions

 _PROTOTYPE (int main,(int argc, char **argv))
 _PROTOTYPE (void initvars,(void))
 _PROTOTYPE (void fatal,(char *s))
 _PROTOTYPE (int eoln,(int c))
 _PROTOTYPE (int yes,(char *question))
 _PROTOTYPE (int atoo,(char *s))
 _PROTOTYPE (int input,(char *buf, int size))
 _PROTOTYPE (char *alloc,(unsigned nelem, unsigned elsize))
 _PROTOTYPE (void printrec,(struct stack *sp))
 _PROTOTYPE (void printpath,(int mode, int nlcr))
 _PROTOTYPE (void devio,(block_nr bno, int dir))
 _PROTOTYPE (void devread,(long offset, char *buf, int size))
 _PROTOTYPE (void pr,(char *fmt, int cnt, char *s, char *p))
 _PROTOTYPE (void lpr,(char *fmt, long cnt, char *s, char *p))
 _PROTOTYPE (bit_nr getnumber,(char *s))
 _PROTOTYPE (char **getlist,(char ***argv, char *type))
 _PROTOTYPE (void lsi,(char **clist))
 _PROTOTYPE (bitchunk_t *allocbitmap,(int nblk))
 _PROTOTYPE (void loadbitmap,(bitchunk_t *bitmap, block_nr bno, int nblk))
 _PROTOTYPE (void fillbitmap,(bitchunk_t *bitmap, bit_nr lwb, bit_nr upb, char **list))
 _PROTOTYPE (void freebitmap,(bitchunk_t *p))
 _PROTOTYPE (void chkword,(unsigned w1, unsigned w2, bit_nr bit, char *type, int *n, int *report, bit_t))
 _PROTOTYPE (void chkmap,(bitchunk_t *cmap, bitchunk_t *dmap, bit_nr bit, block_nr blkno, int nblk, char *type))
 _PROTOTYPE (void counterror,(Ino_t ino))
 _PROTOTYPE (void printperm,(mode_t mode, int shift, int special, int overlay))
 _PROTOTYPE (void list,(Ino_t ino, d_inode *ip))
 _PROTOTYPE (int Remove,(dir_struct *dp))
 _PROTOTYPE (void make_printable_name,(char *dst, char *src, int n))
 _PROTOTYPE (int chkdots,(Ino_t ino, off_t pos, dir_struct *dp, Ino_t exp))
 _PROTOTYPE (int chkname,(Ino_t ino, dir_struct *dp))
 _PROTOTYPE (int chkentry,(Ino_t ino, off_t pos, dir_struct *dp))
 _PROTOTYPE (int chkdirzone,(Ino_t ino, d_inode *ip, off_t pos, zone_nr zno))
 _PROTOTYPE (void errzone,(char *mess, zone_nr zno, int level, off_t pos))
 _PROTOTYPE (int markzone,(zone_nr zno, int level, off_t pos))
 _PROTOTYPE (int chkindzone,(Ino_t ino, d_inode *ip, off_t *pos, zone_nr zno, int level))
 _PROTOTYPE (off_t jump,(int level))
 _PROTOTYPE (int chkzones,(Ino_t ino, d_inode *ip, off_t *pos, zone_nr *zlist, int len, int level))
 _PROTOTYPE (int chkfile,(Ino_t ino, d_inode *ip))
 _PROTOTYPE (void chkdev,(char *f, char **clist, char **ilist, char **zlist))
void initvars ()
void fatal (char *s)
int eoln (int c)
int yes (char *question)
int atoo (char *s)
int input (char *buf, int size)
char * alloc (unsigned nelem, unsigned elsize)
void printname (char *s)
void printrec (struct stack *sp)
void printpath (int mode, int nlcr)
void devopen ()
void devclose ()
void devio (block_nr bno, int dir)
void devread (long offset, char *buf, int size)
void devwrite (long offset, char *buf, int size)
void pr (char *fmt, int cnt, char *s, char *p)
void lpr (char *fmt, long cnt, char *s, char *p)
bit_nr getnumber (char *s)
char ** getlist (char ***argv, char *type)
void lsuper ()
void getsuper ()
void chksuper ()
int inoaddr (int inn)
void lsi (char **clist)
bitchunk_tallocbitmap (int nblk)
void loadbitmap (bitchunk_t *bitmap, block_nr bno, int nblk)
void dumpbitmap (bitchunk_t *bitmap, block_nr bno, int nblk)
void fillbitmap (bitchunk_t *bitmap, bit_nr lwb, bit_nr upb, char **list)
void freebitmap (bitchunk_t *p)
void getbitmaps ()
void putbitmaps ()
void chkword (unsigned w1, unsigned w2, bit_nr bit, char *type, int *n, int *report, bit_nr phys)
void chkmap (bitchunk_t *cmap, bitchunk_t *dmap, bit_nr bit, block_nr blkno, int nblk, char *type)
void chkilist ()
void getcount ()
void counterror (ino_t ino)
void chkcount ()
void freecount ()
void printperm (mode_t mode, int shift, int special, int overlay)
void list (ino_t ino, d_inode *ip)
int Remove (dir_struct *dp)
void make_printable_name (char *dst, char *src, int n)
int chkdots (ino_t ino, off_t pos, dir_struct *dp, ino_t exp)
int chkname (ino_t ino, dir_struct *dp)
int chkentry (ino_t ino, off_t pos, dir_struct *dp)
int chkdirzone (ino_t ino, d_inode *ip, off_t pos, zone_nr zno)
int chksymlinkzone (ino_t ino, d_inode *ip, off_t pos, zone_nr zno)
void errzone (char *mess, zone_nr zno, int level, off_t pos)
int markzone (zone_nr zno, int level, off_t pos)
int chkindzone (ino_t ino, d_inode *ip, off_t *pos, zone_nr zno, int level)
off_t jump (int level)
int zonechk (ino_t ino, d_inode *ip, off_t *pos, zone_nr zno, int level)
int chkzones (ino_t ino, d_inode *ip, off_t *pos, zone_nr *zlist, int len, int level)
int chkfile (ino_t ino, d_inode *ip)
int chkdirectory (ino_t ino, d_inode *ip)
int chkspecial (ino_t ino, d_inode *ip)
int chkmode (ino_t ino, d_inode *ip)
int chkinode (ino_t ino, d_inode *ip)
int descendtree (dir_struct *dp)
void chktree ()
void printtotal ()
void chkdev (char *f, char **clist, char **ilist, char **zlist)
int main (int argc, char **argv)

Variables

unsigned int fs_version = 2
unsigned int block_size = 0
static struct super_block sb
char * prog
char * fsck_device
int firstcnterr
bitchunk_timap
bitchunk_tspec_imap
bitchunk_tzmap
bitchunk_tspec_zmap
bitchunk_tdirmap
char * rwbuf
block_nr thisblk
char * nullbuf
nlink_tcount
int changed
stackftop
int dev
int nfreeinode
int nregular
int ndirectory
int nblkspec
int ncharspec
int nbadinode
int npipe
int nsyml
int ztype [NLEVEL]
long nfreezone
int repair
int automatic
int listing
int listsuper
int firstlist
unsigned part_offset
char answer [] = "Answer questions with y or n. Then hit RETURN"


Define Documentation

#define bit_nr   bit_t
 

Definition at line 11 of file fsck.c.

Referenced by chkdev(), chkdirectory(), chkdots(), chkentry(), chkilist(), chkinode(), chkmap(), chkname(), chksymlinkzone(), counterror(), descendtree(), fillbitmap(), getnumber(), lsi(), markzone(), mini_receive(), and Remove().

#define BITMASK   ((1 << BITSHIFT) - 1)
 

Definition at line 80 of file fsck.c.

#define bitset w,
b   )     (w[WORDOFBIT(b)] & POWEROFBIT(b))
 

Definition at line 85 of file fsck.c.

Referenced by ajar(), chkentry(), chkilist(), dead(), descendtree(), edible(), hinged(), living(), locked(), locks(), markzone(), opaque(), outside(), plural(), portal(), printed(), small(), treasr(), vessel(), wearng(), and worn().

#define BITSHIFT   4
 

Definition at line 64 of file fsck.c.

Referenced by main().

#define BLK_FIRST   ztob(FIRST)
 

Definition at line 114 of file fsck.c.

#define BLK_ILIST   (BLK_ZMAP + N_ZMAP)
 

Definition at line 113 of file fsck.c.

Referenced by chksuper().

#define BLK_IMAP   2
 

Definition at line 111 of file fsck.c.

Referenced by chkdev().

#define BLK_ZMAP   (BLK_IMAP + N_IMAP)
 

Definition at line 112 of file fsck.c.

Referenced by chkdev().

#define block_nr   block_t
 

Definition at line 12 of file fsck.c.

Referenced by chksuper(), devread(), and devwrite().

#define btoa b   )     ((long) (b) * block_size)
 

Definition at line 99 of file fsck.c.

Referenced by devio(), dumpbitmap(), getsuper(), loadbitmap(), and lsuper().

#define CDIRECT   1
 

Definition at line 68 of file fsck.c.

Referenced by chkdirzone().

#define CINDIR   128
 

Definition at line 67 of file fsck.c.

Referenced by chkindzone().

#define cinoaddr i   )     ((long) (i - 1) * INODE_SIZE + (long) btoa(BLK_ILIST))
 

Definition at line 120 of file fsck.c.

Referenced by inoaddr().

#define clrbit w,
b   )     (w[WORDOFBIT(b)] &= ~POWEROFBIT(b))
 

Definition at line 84 of file fsck.c.

Referenced by counterror(), and descendtree().

#define d_inode   d2_inode
 

Definition at line 13 of file fsck.c.

Referenced by counterror(), descendtree(), and lsi().

#define d_inum   d_ino
 

Definition at line 14 of file fsck.c.

#define dir_struct   struct direct
 

Definition at line 15 of file fsck.c.

Referenced by chkdirzone(), chkentry(), chktree(), descendtree(), and Remove().

#define DIRCHUNK   ((int) (CDIRECT * DIR_ENTRY_SIZE))
 

Definition at line 122 of file fsck.c.

Referenced by chkdirzone().

#define DOT   1
 

Definition at line 142 of file fsck.c.

#define DOTDOT   2
 

Definition at line 143 of file fsck.c.

Referenced by chkdirectory(), and chkentry().

#define FIRST   ((zone_nr) sb.s_firstdatazone)
 

Definition at line 101 of file fsck.c.

#define i_mode   d2_mode
 

Definition at line 16 of file fsck.c.

#define i_nlinks   d2_nlinks
 

Definition at line 17 of file fsck.c.

#define i_size   d2_size
 

Definition at line 18 of file fsck.c.

Referenced by chkindzone(), freesp_inode(), plan_a(), rahead(), re_input(), and truncate_inode().

#define i_zone   d2_zone
 

Definition at line 19 of file fsck.c.

#define INDCHUNK   ((int) (CINDIR * ZONE_NUM_SIZE))
 

Definition at line 121 of file fsck.c.

Referenced by chkindzone().

#define INODE_CT   95
 

Definition at line 88 of file fsck.c.

#define INODE_SIZE   ((int) V2_INODE_SIZE)
 

Definition at line 4 of file fsck.c.

Referenced by chkilist(), chksymlinkzone(), counterror(), descendtree(), and lsi().

#define INODES_PER_BLOCK   V2_INODES_PER_BLOCK(block_size)
 

Definition at line 3 of file fsck.c.

#define MAX_ZONES   (V2_NR_DZONES+V2_INDIRECTS(block_size)+(long)V2_INDIRECTS(block_size)*V2_INDIRECTS(block_size))
 

Definition at line 6 of file fsck.c.

Referenced by chksuper().

#define MAXPRINT   80
 

Definition at line 66 of file fsck.c.

Referenced by chkmap(), and chkword().

#define N_DATA   (sb.s_zones - FIRST)
 

Definition at line 107 of file fsck.c.

#define N_ILIST   ((sb.s_ninodes+INODES_PER_BLOCK-1) / INODES_PER_BLOCK)
 

Definition at line 106 of file fsck.c.

Referenced by chksuper().

#define N_IMAP   (sb.s_imap_blocks)
 

Definition at line 104 of file fsck.c.

Referenced by chkdev(), and getbitmaps().

#define N_ZMAP   (sb.s_zmap_blocks)
 

Definition at line 105 of file fsck.c.

Referenced by chkdev(), and getbitmaps().

#define NLEVEL   (NR_ZONE_NUMS - NR_DZONE_NUM + 1)
 

Definition at line 116 of file fsck.c.

Referenced by initvars().

#define NR_DZONE_NUM   V2_NR_DZONES
 

Definition at line 7 of file fsck.c.

Referenced by chkfile().

#define NR_INDIRECTS   V2_INDIRECTS(block_size)
 

Definition at line 8 of file fsck.c.

Referenced by chkindzone(), and jump().

#define NR_ZONE_NUMS   V2_NR_TZONES
 

Definition at line 9 of file fsck.c.

Referenced by chkfile(), and chkspecial().

#define OFFSET_SUPER_BLOCK   SUPER_BLOCK_BYTES
 

Definition at line 110 of file fsck.c.

Referenced by getsuper(), and lsuper().

#define POWEROFBIT b   )     (1 << ((int) (b) & BITMASK))
 

Definition at line 82 of file fsck.c.

#define SCALE   ((int) ztob(1))
 

Definition at line 100 of file fsck.c.

Referenced by chkdirzone(), and chksuper().

#define setbit w,
b   )     (w[WORDOFBIT(b)] |= POWEROFBIT(b))
 

Definition at line 83 of file fsck.c.

Referenced by chkdirectory(), chkdots(), chkinode(), chkname(), chksymlinkzone(), descendtree(), dodash(), fillbitmap(), lsi(), markzone(), and Remove().

#define STICKY_BIT   01000
 

Definition at line 93 of file fsck.c.

Referenced by list().

#define WORDOFBIT b   )     ((b) >> BITSHIFT)
 

Definition at line 81 of file fsck.c.

#define WORDS_PER_BLOCK   (block_size / (int) sizeof(bitchunk_t))
 

Definition at line 5 of file fsck.c.

Referenced by chkmap(), dumpbitmap(), and loadbitmap().

#define zaddr z   )     btoa(ztob(z))
 

Definition at line 119 of file fsck.c.

Referenced by chkdirzone(), chkindzone(), and chksymlinkzone().

#define ZONE_CT   360
 

Definition at line 87 of file fsck.c.

#define zone_nr   zone_t
 

Definition at line 20 of file fsck.c.

Referenced by chkfile(), and chkindzone().

#define ZONE_NUM_SIZE   V2_ZONE_NUM_SIZE
 

Definition at line 10 of file fsck.c.

#define ZONE_SIZE   ((int) ztob(block_size))
 

Definition at line 115 of file fsck.c.

Referenced by jump(), printtotal(), and zonechk().

#define ztob z   )     ((block_nr) (z) << sb.s_log_zone_size)
 

Definition at line 98 of file fsck.c.


Function Documentation

_PROTOTYPE void  chkdev,
(char *f, char **clist, char **ilist, char **zlist) 
 

_PROTOTYPE int  chkfile,
(Ino_t ino, d_inode *ip) 
 

_PROTOTYPE int  chkzones,
(Ino_t ino, d_inode *ip, off_t *pos, zone_nr *zlist, int len, int level
 

_PROTOTYPE off_t  jump,
(int level
 

_PROTOTYPE int  chkindzone,
(Ino_t ino, d_inode *ip, off_t *pos, zone_nr zno, int level
 

_PROTOTYPE int  markzone,
(zone_nr zno, int level, off_t pos
 

_PROTOTYPE void  errzone,
(char *mess, zone_nr zno, int level, off_t pos
 

_PROTOTYPE int  chkdirzone,
(Ino_t ino, d_inode *ip, off_t pos, zone_nr zno) 
 

_PROTOTYPE int  chkentry,
(Ino_t ino, off_t pos, dir_struct *dp) 
 

_PROTOTYPE int  chkname,
(Ino_t ino, dir_struct *dp) 
 

_PROTOTYPE int  chkdots,
(Ino_t ino, off_t pos, dir_struct *dp, Ino_t exp) 
 

_PROTOTYPE void  make_printable_name,
(char *dst, char *src, int n
 

_PROTOTYPE int  Remove,
(dir_struct *dp) 
 

_PROTOTYPE void  list,
(Ino_t ino, d_inode *ip) 
 

_PROTOTYPE void  printperm,
(mode_t mode, int shift, int special, int overlay) 
 

_PROTOTYPE void  counterror,
(Ino_t ino) 
 

_PROTOTYPE void  chkmap,
(bitchunk_t *cmap, bitchunk_t *dmap, bit_nr bit, block_nr blkno, int nblk, char *type
 

_PROTOTYPE void  chkword,
(unsigned w1, unsigned w2, bit_nr bit, char *type, int *n, int *report, bit_t
 

_PROTOTYPE void  freebitmap,
(bitchunk_t *p
 

_PROTOTYPE void  fillbitmap,
(bitchunk_t *bitmap, bit_nr lwb, bit_nr upb, char **list) 
 

_PROTOTYPE void  loadbitmap,
(bitchunk_t *bitmap, block_nr bno, int nblk) 
 

_PROTOTYPE bitchunk_t allocbitmap,
(int nblk) 
 

_PROTOTYPE void  lsi,
(char **clist) 
 

_PROTOTYPE char **  getlist,
(char ***argv, char *type
 

_PROTOTYPE bit_nr  getnumber,
(char *s
 

_PROTOTYPE void  lpr,
(char *fmt, long cnt, char *s, char *p
 

_PROTOTYPE void  pr,
(char *fmt, int cnt, char *s, char *p
 

_PROTOTYPE void  devread,
(long offset, char *buf, int size) 
 

_PROTOTYPE void  devio,
(block_nr bno, int dir
 

_PROTOTYPE void  printpath,
(int mode, int nlcr) 
 

_PROTOTYPE void  printrec,
(struct stack *sp
 

_PROTOTYPE char *  alloc,
(unsigned nelem, unsigned elsize) 
 

_PROTOTYPE int  input,
(char *buf, int size) 
 

_PROTOTYPE int  atoo,
(char *s
 

_PROTOTYPE int  yes,
(char *question) 
 

_PROTOTYPE int  eoln,
(int c
 

_PROTOTYPE void  fatal,
(char *s
 

_PROTOTYPE void  initvars,
(void) 
 

_PROTOTYPE int  main,
(int argc, char **argv) 
 

char* alloc unsigned  nelem,
unsigned  elsize
 

Definition at line 312 of file fsck.c.

References fatal(), fprintf(), malloc(), memset(), p, and stderr.

bitchunk_t* allocbitmap int  nblk  ) 
 

Definition at line 644 of file fsck.c.

References alloc(), bitmap, and block_size.

Referenced by getbitmaps().

int atoo char *  s  ) 
 

Definition at line 273 of file fsck.c.

References n.

Referenced by lsi().

void chkcount  ) 
 

Definition at line 837 of file fsck.c.

References count, counterror(), firstcnterr, printf, super_block::s_ninodes, and sb.

Referenced by chkdev().

void chkdev char *  f,
char **  clist,
char **  ilist,
char **  zlist
 

Definition at line 1504 of file fsck.c.

References _MAX_BLOCK_SIZE, automatic, bit_nr, BLK_IMAP, BLK_ZMAP, block_size, changed, chkcount(), chkilist(), chkmap(), chksuper(), chktree(), devclose(), devopen(), fatal(), fillbitmap(), FIRST, freecount(), fsck_device, getbitmaps(), getcount(), getsuper(), imap, initvars(), lsi(), malloc(), memset(), N_IMAP, N_ZMAP, nullbuf, printf, printtotal(), putbitmaps(), repair, rwbuf, super_block::s_ninodes, super_block::s_zones, sb, spec_imap, spec_zmap, and zmap.

Referenced by main().

int chkdirectory ino_t  ino,
d_inode *  ip
 

Definition at line 1292 of file fsck.c.

References bit_nr, chkfile(), dirmap, DOT, DOTDOT, ftop, ok(), printf, printpath(), setbit, and stack::st_presence.

Referenced by chkmode().

int chkdirzone ino_t  ino,
d_inode *  ip,
off_t  pos,
zone_nr  zno
 

Definition at line 1077 of file fsck.c.

References block_size, CDIRECT, devread(), devwrite(), DIR_ENTRY_SIZE, dir_struct, DIRCHUNK, dirty, n, NO_ENTRY, NR_DIR_ENTRIES, offset, SCALE, size, and zaddr.

int chkdots ino_t  ino,
off_t  pos,
dir_struct *  dp,
ino_t  exp
 

Definition at line 961 of file fsck.c.

References bit_nr, count, DIR_ENTRY_SIZE, make_printable_name(), printf, printpath(), setbit, spec_imap, and yes().

Referenced by chkentry().

int chkentry ino_t  ino,
off_t  pos,
dir_struct *  dp
 

Definition at line 1026 of file fsck.c.

References bit_nr, bitset, chkdots(), chkname(), count, descendtree(), dir_struct, dirmap, DOT, DOTDOT, ftop, memset(), printf, printname(), printpath(), Remove(), ROOT_INODE, super_block::s_ninodes, sb, SHRT_MAX, stack::st_dir, stack::st_next, stack::st_presence, strcmp, and yes().

int chkfile ino_t  ino,
d_inode *  ip
 

Definition at line 1278 of file fsck.c.

References chkzones(), NR_DZONE_NUM, NR_ZONE_NUMS, ok(), and pos.

Referenced by chkdirectory(), and chkmode().

void chkilist  ) 
 

Definition at line 782 of file fsck.c.

References bit_nr, bitset, devread(), devwrite(), I_NOT_ALLOC, imap, inoaddr, INODE_SIZE, nullbuf, printf, super_block::s_ninodes, sb, and yes().

Referenced by chkdev().

int chkindzone ino_t  ino,
d_inode *  ip,
off_t pos,
zone_nr  zno,
int  level
 

Definition at line 1195 of file fsck.c.

References chkzones(), CINDIR, devread(), i_size, INDCHUNK, n, NR_INDIRECTS, offset, zaddr, and zone_nr.

Referenced by zonechk().

int chkinode ino_t  ino,
d_inode *  ip
 

Definition at line 1399 of file fsck.c.

References bit_nr, chkmode(), count, fatal(), I_DIRECTORY, I_TYPE, imap, nfreeinode, printf, printpath(), ROOT_INODE, setbit, SHRT_MAX, and spec_imap.

Referenced by descendtree().

void chkmap bitchunk_t cmap,
bitchunk_t dmap,
bit_nr  bit,
block_nr  blkno,
int  nblk,
char *  type
 

Definition at line 753 of file fsck.c.

References automatic, bit_nr, chkword(), dumpbitmap(), loadbitmap(), MAXPRINT, p, printf, repair, report(), WORDS_PER_BLOCK, and yes().

Referenced by chkdev().

int chkmode ino_t  ino,
d_inode *  ip
 

Definition at line 1364 of file fsck.c.

References chkdirectory(), chkfile(), chkspecial(), I_BLOCK_SPECIAL, I_CHAR_SPECIAL, I_DIRECTORY, I_NAMED_PIPE, I_REGULAR, I_SYMBOLIC_LINK, I_TYPE, nbadinode, nblkspec, ncharspec, ndirectory, npipe, nregular, nsyml, printf, and printpath().

Referenced by chkinode().

int chkname ino_t  ino,
dir_struct *  dp
 

Definition at line 996 of file fsck.c.

References bit_nr, n, p, printf, printname(), printpath(), Remove(), setbit, and spec_imap.

Referenced by chkentry().

int chkspecial ino_t  ino,
d_inode *  ip
 

Definition at line 1337 of file fsck.c.

References NO_DEV, NO_ZONE, NR_ZONE_NUMS, printf, and printpath().

Referenced by chkmode().

void chksuper  ) 
 

Definition at line 560 of file fsck.c.

References bitmapsize(), BLK_ILIST, block_nr, block_size, fatal(), if(), long(), MAX_FILE_POS, MAX_ZONES, maxsize, n, N_ILIST, pr(), printf, super_block::s_firstdatazone, super_block::s_imap_blocks, super_block::s_log_zone_size, super_block::s_magic, super_block::s_max_size, super_block::s_ninodes, super_block::s_zmap_blocks, super_block::s_zones, sb, SCALE, SUPER_V2, and SUPER_V3.

Referenced by chkdev().

int chksymlinkzone ino_t  ino,
d_inode *  ip,
off_t  pos,
zone_nr  zno
 

Definition at line 1117 of file fsck.c.

References bit_nr, devread(), devwrite(), fatal(), inoaddr, INODE_SIZE, offset, PATH_MAX, printf, printpath(), setbit, spec_imap, strlen(), target, yes(), and zaddr.

void chktree  ) 
 

Definition at line 1464 of file fsck.c.

References descendtree(), dir_struct, fatal(), N_DATA, nfreeinode, nfreezone, putchar, ROOT_INODE, super_block::s_ninodes, and sb.

Referenced by chkdev().

void chkword unsigned  w1,
unsigned  w2,
bit_nr  bit,
char *  type,
int *  n,
int *  report,
bit_nr  phys
 

Definition at line 732 of file fsck.c.

References automatic, MAXPRINT, printf, repair, and yes().

Referenced by chkmap().

int chkzones ino_t  ino,
d_inode *  ip,
off_t pos,
zone_nr *  zlist,
int  len,
int  level
 

Definition at line 1252 of file fsck.c.

References i, jump, markzone(), NO_ZONE, and ok().

Referenced by chkfile(), and chkindzone().

void counterror ino_t  ino  ) 
 

Definition at line 808 of file fsck.c.

References bit_nr, clrbit, count, d_inode, devread(), devwrite(), fatal(), firstcnterr, I_NOT_ALLOC, imap, inoaddr, INODE_SIZE, printf, and yes().

Referenced by chkcount().

int descendtree dir_struct *  dp  ) 
 

Definition at line 1428 of file fsck.c.

References bit_nr, bitset, chkinode(), clrbit, count, d_inode, devread(), devwrite(), dir_struct, ftop, imap, inoaddr, INODE_SIZE, list, listing, memset(), nullbuf, printf, printpath(), setbit, spec_imap, stack::st_dir, stack::st_next, and yes().

Referenced by chkentry(), and chktree().

void devclose  ) 
 

Definition at line 384 of file fsck.c.

References close, dev, fatal(), and perror().

Referenced by chkdev().

void devio block_nr  bno,
int  dir
 

Definition at line 393 of file fsck.c.

References block_size, btoa, dev, errno, fatal(), lseek, memset(), printf, prog, read, READING, rwbuf, SEEK_SET, thisblk, and write.

Referenced by devread(), and devwrite().

void devopen  ) 
 

Definition at line 375 of file fsck.c.

References dev, fatal(), fsck_device, O_RDONLY, O_RDWR, open, perror(), and repair.

Referenced by chkdev().

void devread long  offset,
char *  buf,
int  size
 

Definition at line 424 of file fsck.c.

References block_nr, block_size, devio(), fatal(), memmove(), READING, and rwbuf.

Referenced by chkdirzone(), chkilist(), chkindzone(), chksymlinkzone(), counterror(), descendtree(), getsuper(), loadbitmap(), and lsi().

void devwrite long  offset,
char *  buf,
int  size
 

Definition at line 435 of file fsck.c.

References block_nr, block_size, changed, devio(), fatal(), memmove(), READING, repair, rwbuf, and WRITING.

Referenced by chkdirzone(), chkilist(), chksymlinkzone(), counterror(), descendtree(), dumpbitmap(), lsi(), and lsuper().

void dumpbitmap bitchunk_t bitmap,
block_nr  bno,
int  nblk
 

Definition at line 670 of file fsck.c.

References block_size, btoa, devwrite(), i, p, and WORDS_PER_BLOCK.

Referenced by chkmap().

int eoln int  c  ) 
 

Definition at line 242 of file fsck.c.

References EOF.

Referenced by input(), and yes().

void errzone char *  mess,
zone_nr  zno,
int  level,
off_t  pos
 

Definition at line 1148 of file fsck.c.

References printf, and printpath().

Referenced by markzone().

void fatal char *  s  ) 
 

Definition at line 234 of file fsck.c.

References exit(), and printf.

void fillbitmap bitchunk_t bitmap,
bit_nr  lwb,
bit_nr  upb,
char **  list
 

Definition at line 683 of file fsck.c.

References bit_nr, getnumber(), NO_BIT, printf, setbit, and spec_imap.

Referenced by chkdev().

void freebitmap bitchunk_t p  ) 
 

Definition at line 703 of file fsck.c.

References free.

Referenced by putbitmaps().

void freecount  ) 
 

Definition at line 847 of file fsck.c.

References count, and free.

Referenced by chkdev().

void getbitmaps  ) 
 

Definition at line 710 of file fsck.c.

References allocbitmap(), dirmap, imap, N_IMAP, N_ZMAP, spec_imap, spec_zmap, and zmap.

Referenced by chkdev().

void getcount  ) 
 

Definition at line 802 of file fsck.c.

References alloc(), count, super_block::s_ninodes, and sb.

Referenced by chkdev().

char** getlist char ***  argv,
char *  type
 

Definition at line 478 of file fsck.c.

References getnumber(), NO_BIT, NULL, and printf.

Referenced by main().

bit_nr getnumber char *  s  ) 
 

Definition at line 465 of file fsck.c.

References bit_nr, isdigit, n, NO_BIT, and NULL.

Referenced by fillbitmap(), getlist(), and lsi().

void getsuper  ) 
 

Definition at line 529 of file fsck.c.

References block_size, dev, fatal(), fs_version, listsuper, lseek, lsuper(), OFFSET_SUPER_BLOCK, perror(), read, sb, SEEK_SET, SUPER_MAGIC, SUPER_V2, and SUPER_V3.

Referenced by chkdev().

void initvars  ) 
 

Definition at line 221 of file fsck.c.

References changed, firstcnterr, firstlist, nbadinode, nblkspec, ncharspec, ndirectory, NLEVEL, NO_BLOCK, npipe, nregular, nsyml, thisblk, and ztype.

Referenced by chkdev().

int inoaddr int  inn  ) 
 

Definition at line 604 of file fsck.c.

References a, and cinoaddr.

int input char *  buf,
int  size
 

Definition at line 286 of file fsck.c.

References eoln(), fflush(), getchar, p, printf, repair, and stdout.

off_t jump int  level  ) 
 

Definition at line 1217 of file fsck.c.

References NR_INDIRECTS, and ZONE_SIZE.

void list ino_t  ino,
d_inode *  ip
 

Definition at line 873 of file fsck.c.

References firstlist, I_BLOCK_SPECIAL, I_CHAR_SPECIAL, I_DIRECTORY, I_NAMED_PIPE, I_REGULAR, I_SET_GID_BIT, I_SET_UID_BIT, I_SYMBOLIC_LINK, I_TYPE, MAJOR, MINOR, printf, printpath(), printperm(), putchar, and STICKY_BIT.

void loadbitmap bitchunk_t bitmap,
block_nr  bno,
int  nblk
 

Definition at line 655 of file fsck.c.

References block_size, btoa, devread(), i, p, and WORDS_PER_BLOCK.

Referenced by chkmap().

void lpr char *  fmt,
long  cnt,
char *  s,
char *  p
 

Definition at line 457 of file fsck.c.

References printf.

Referenced by printtotal().

void lsi char **  clist  ) 
 

Definition at line 614 of file fsck.c.

References atol(), atoo(), bit_nr, d_inode, devread(), devwrite(), getnumber(), inoaddr, INODE_SIZE, input, NO_BIT, printf, setbit, spec_imap, and yes().

Referenced by chkdev().

void lsuper  ) 
 

Definition at line 498 of file fsck.c.

References atol(), devwrite(), exit(), input, OFFSET_SUPER_BLOCK, printf, repair, super_block::s_block_size, super_block::s_firstdatazone, super_block::s_imap_blocks, super_block::s_log_zone_size, super_block::s_max_size, super_block::s_ninodes, super_block::s_zmap_blocks, super_block::s_zones, sb, and yes().

Referenced by getsuper().

int main int  argc,
char **  argv
 

Definition at line 1546 of file fsck.c.

References arg, automatic, BITSHIFT, chkdev(), exit(), getlist(), listing, listsuper, printf, prog, repair, and sync.

void make_printable_name char *  dst,
char *  src,
int  n
 

Definition at line 925 of file fsck.c.

References c, and isprint.

Referenced by chkdots().

int markzone zone_nr  zno,
int  level,
off_t  pos
 

Definition at line 1169 of file fsck.c.

References bit_nr, bitset, errzone(), FIRST, nfreezone, super_block::s_zones, sb, setbit, spec_zmap, zmap, and ztype.

Referenced by chkzones().

void pr char *  fmt,
int  cnt,
char *  s,
char *  p
 

Definition at line 449 of file fsck.c.

References printf.

Referenced by chksuper(), evaluate(), explode(), newrule(), printtotal(), and splitenv().

void printname char *  s  ) 
 

Definition at line 327 of file fsck.c.

References c, isprint, n, and putchar.

Referenced by chkentry(), chkname(), print1(), and printrec().

void printpath int  mode,
int  nlcr
 

Definition at line 355 of file fsck.c.

References ftop, printf, printrec(), putchar, stack::st_dir, and stack::st_next.

Referenced by chkdirectory(), chkdots(), chkentry(), chkinode(), chkmode(), chkname(), chkspecial(), chksymlinkzone(), descendtree(), errzone(), and list().

void printperm mode_t  mode,
int  shift,
int  special,
int  overlay
 

Definition at line 853 of file fsck.c.

References putchar, R_BIT, W_BIT, and X_BIT.

Referenced by list().

void printrec struct stack sp  ) 
 

Definition at line 344 of file fsck.c.

References printname(), and putchar.

Referenced by printpath(), and printrec().

void printtotal  ) 
 

Definition at line 1477 of file fsck.c.

References block_size, lpr(), nbadinode, nblkspec, ncharspec, ndirectory, nfreeinode, nfreezone, npipe, nregular, nsyml, pr(), printf, and ZONE_SIZE.

Referenced by chkdev().

void putbitmaps  ) 
 

Definition at line 720 of file fsck.c.

References dirmap, freebitmap(), imap, spec_imap, spec_zmap, and zmap.

Referenced by chkdev().

int Remove dir_struct *  dp  ) 
 

Definition at line 912 of file fsck.c.

References bit_nr, count, dir_struct, memset(), setbit, spec_imap, and yes().

Referenced by chkentry(), chkname(), test03(), test04(), and test10().

int yes char *  question  ) 
 

Definition at line 249 of file fsck.c.

References automatic, c, eoln(), exit(), fflush(), getchar, printf, repair, and stdout.

int zonechk ino_t  ino,
d_inode *  ip,
off_t pos,
zone_nr  zno,
int  level
 

Definition at line 1231 of file fsck.c.

References chkindzone(), I_DIRECTORY, I_SYMBOLIC_LINK, I_TYPE, and ZONE_SIZE.


Variable Documentation

char answer[] = "Answer questions with y or n. Then hit RETURN"
 

Definition at line 153 of file fsck.c.

Referenced by add(), ask(), do_extract_currentfile(), execute(), getinfo(), ListHosts(), master(), and yes().

int automatic
 

Definition at line 150 of file fsck.c.

Referenced by chkdev(), chkmap(), chkword(), main(), and yes().

unsigned int block_size = 0
 

Definition at line 62 of file fsck.c.

int changed
 

Definition at line 133 of file fsck.c.

nlink_t* count
 

Definition at line 132 of file fsck.c.

int dev
 

Definition at line 140 of file fsck.c.

bitchunk_t* dirmap
 

Definition at line 128 of file fsck.c.

Referenced by chkdirectory(), chkentry(), getbitmaps(), and putbitmaps().

int firstcnterr
 

Definition at line 125 of file fsck.c.

Referenced by chkcount(), counterror(), and initvars().

int firstlist
 

Definition at line 151 of file fsck.c.

Referenced by initvars(), and list().

unsigned int fs_version = 2
 

Definition at line 62 of file fsck.c.

Referenced by add_zone(), alloc_inode(), enter_dir(), getsuper(), incr_link(), incr_size(), main(), print_fs(), and super().

char * fsck_device
 

Definition at line 124 of file fsck.c.

Referenced by chkdev(), and devopen().

struct stack * ftop
 

Referenced by chkdirectory(), chkentry(), descendtree(), and printpath().

bitchunk_t* imap
 

Definition at line 126 of file fsck.c.

Referenced by chkdev(), chkilist(), chkinode(), counterror(), descendtree(), getbitmaps(), and putbitmaps().

int listing
 

Definition at line 150 of file fsck.c.

Referenced by descendtree(), and main().

int listsuper
 

Definition at line 150 of file fsck.c.

Referenced by getsuper(), and main().

int nbadinode
 

Definition at line 146 of file fsck.c.

Referenced by chkmode(), initvars(), and printtotal().

int nblkspec
 

Definition at line 146 of file fsck.c.

Referenced by chkmode(), initvars(), and printtotal().

int ncharspec
 

Definition at line 146 of file fsck.c.

Referenced by chkmode(), initvars(), and printtotal().

int ndirectory
 

Definition at line 146 of file fsck.c.

Referenced by chkmode(), initvars(), and printtotal().

int nfreeinode
 

Definition at line 146 of file fsck.c.

Referenced by chkinode(), chktree(), and printtotal().

long nfreezone
 

Definition at line 148 of file fsck.c.

Referenced by chktree(), markzone(), and printtotal().

int npipe
 

Definition at line 147 of file fsck.c.

Referenced by chkmode(), initvars(), pipeline(), and printtotal().

int nregular
 

Definition at line 146 of file fsck.c.

Referenced by chkmode(), initvars(), and printtotal().

int nsyml
 

Definition at line 147 of file fsck.c.

Referenced by chkmode(), initvars(), and printtotal().

char* nullbuf
 

Definition at line 131 of file fsck.c.

Referenced by chkdev(), chkilist(), and descendtree().

unsigned part_offset
 

Definition at line 152 of file fsck.c.

char* prog
 

Definition at line 124 of file fsck.c.

int repair
 

Definition at line 150 of file fsck.c.

Referenced by chkdev(), chkmap(), chkword(), devopen(), devwrite(), input(), lsuper(), main(), and yes().

char* rwbuf
 

Definition at line 129 of file fsck.c.

Referenced by chkdev(), devio(), devread(), and devwrite().

struct super_block sb [static]
 

Definition at line 91 of file fsck.c.

Referenced by check_mtab(), chk_path(), chk_same(), chkcount(), chkdev(), chkentry(), chkilist(), chksuper(), chktree(), copy(), cp_file(), d_ncols(), dev_up(), doit(), e_backc(), e_getc(), e_peekc(), e_putc(), e_search(), e_sputz(), ed_insert(), empty_indir(), ex_alldot(), ex_gobol(), ex_goeol(), ex_gonl(), ex_gopl(), execvp(), extract(), f_twords(), fts_safe_changedir(), fts_stat(), geometry(), get_inode(), getcount(), getsuper(), kbd_send(), lnk_creat(), lsuper(), main(), mainSort(), markzone(), mk_link(), mkpath(), mode(), node_creat(), printit(), rd_wrfile(), readfs(), sb_close(), sb_clrovw(), sb_cpyn(), sb_killn(), sb_rdelc(), sb_rewind(), sb_seek(), sb_setovw(), sb_sins(), sb_tell(), sb_ztell(), sbe_sbs(), sbx_next(), sbx_norm(), sbx_ready(), sbx_sbrdy(), sbx_smdisc(), sbx_xcis(), scan_keyboard(), sctrin(), set_crc(), set_ftime(), unlnk_exist(), and wr_rdfile().

bitchunk_t * spec_imap
 

Definition at line 126 of file fsck.c.

Referenced by chkdev(), chkdots(), chkinode(), chkname(), chksymlinkzone(), descendtree(), fillbitmap(), getbitmaps(), lsi(), putbitmaps(), and Remove().

bitchunk_t * spec_zmap
 

Definition at line 127 of file fsck.c.

Referenced by chkdev(), getbitmaps(), markzone(), and putbitmaps().

block_nr thisblk
 

Definition at line 130 of file fsck.c.

Referenced by devio(), and initvars().

bitchunk_t* zmap
 

Definition at line 127 of file fsck.c.

Referenced by chkdev(), getbitmaps(), markzone(), and putbitmaps().

int ztype[NLEVEL]
 

Definition at line 147 of file fsck.c.

Referenced by initvars(), markzone(), proc_ind(), and rw_data_zones().


Generated on Fri Apr 14 23:06:36 2006 for minix by  doxygen 1.4.6