badblocks.c File Reference

#include <sys/types.h>
#include <sys/stat.h>
#include <minix/config.h>
#include <minix/type.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
#include "../../servers/fs/const.h"
#include "../../servers/fs/type.h"
#include <string.h>
#include <stdio.h>
#include "../../servers/fs/super.h"

Include dependency graph for badblocks.c:

Go to the source code of this file.

Defines

#define EXTERN   extern
#define OK   0
#define NOT_OK   1
#define QUIT   2
#define READ   0
#define WRITE   1
#define HARMLESS   0
#define DIR_CREATED   1
#define DEV_MOUNTED   2
#define FILE_EXISTS   3
#define SUCCESS   4
#define BYTE   0377
#define BLOCK_SIZE   1024
#define SIZE_OF_INT   (sizeof (int) )
#define V_NR_DZONES   V2_NR_DZONES
#define V_SMALLER   V1_NR_DZONES
#define BIT_MAP_SHIFT   13
#define INT_BITS   (SIZE_OF_INT << 3)

Functions

 _PROTOTYPE (int main,(int argc, char **argv))
 _PROTOTYPE (void rw_super,(int flag))
 _PROTOTYPE (void get_super,(void))
 _PROTOTYPE (void rw_inode,(struct stat *stat_ptr, int rw_mode))
 _PROTOTYPE (void get_inode,(struct stat *stat_ptr))
 _PROTOTYPE (long rd_cmdline,(int argc, char *argv[]))
 _PROTOTYPE (void modify,(int nr_blocks))
 _PROTOTYPE (void save_blk,(block_t blk_num))
 _PROTOTYPE (int blk_is_used,(block_t blk_num))
 _PROTOTYPE (int blk_ok,(block_t num))
 _PROTOTYPE (void set_bit,(zone_t num))
 _PROTOTYPE (long rd_num,(void))
 _PROTOTYPE (int ok,(char *str))
 _PROTOTYPE (void done,(int nr))
void rw_super (int flag)
void get_super ()
void put_super ()
void rw_inode (struct stat *stat_ptr, int rw_mode)
void get_inode (struct stat *stat_ptr)
void put_inode (struct stat *stat_ptr)
int main (int argc, argv)
long rd_cmdline (int argc, argv)
void modify (int nr_blocks)
void save_blk (block_t blk_num)
void reset_blks ()
void show_blks ()
int blk_is_used (block_t blk_num)
int blk_ok (block_t num)
void set_bit (zone_t num)
long rd_num ()
int ok (char *str)
void done (int nr)

Variables

char * dev_name
char f_name [] = ".Bad_XXXXXX"
char file_name [50]
char dir_name [] = "/tmpXXXXXX"
block_t block [V_NR_DZONES+1]
int interactive
int position = 2
FILEf
int fd
int eofseen
stat stat_buf
super_blocksp
super_block sbs
int inodes_per_block
size_t inode_size
int v1fs = 0
int v2fs = 0
d1_inode d1inode
d1_inodeip1
d2_inode d2inode
d2_inodeip2
static blk_cnt = 0


Define Documentation

#define BIT_MAP_SHIFT   13
 

Definition at line 492 of file badblocks.c.

Referenced by blk_ok(), and set_bit().

#define BLOCK_SIZE   1024
 

Definition at line 89 of file badblocks.c.

#define BYTE   0377
 

Definition at line 88 of file badblocks.c.

Referenced by ack_emit_instruction(), add_string(), alloc_inode(), alloc_zone(), bas_get_operand(), beep(), beep_x(), clone_opcl(), cons_write(), conv2(), ctty_io(), decode_ioctl(), dev_close(), dev_io(), dev_open(), dev_up(), do_exec(), do_ioctl(), do_svrctl(), do_transfer(), do_unpause(), fproc_dmp(), gen_opcl(), get_work(), gnu_put_expression(), in_process(), main(), out_char(), read_header(), rw_block(), search_str(), select_major_match(), select_unsuspend_by_endpt(), and set_6845().

#define DEV_MOUNTED   2
 

Definition at line 84 of file badblocks.c.

Referenced by done(), main(), and set_bit().

#define DIR_CREATED   1
 

Definition at line 83 of file badblocks.c.

Referenced by blk_ok(), done(), get_super(), main(), rw_inode(), rw_super(), and set_bit().

#define EXTERN   extern
 

Definition at line 38 of file badblocks.c.

#define FILE_EXISTS   3
 

Definition at line 85 of file badblocks.c.

Referenced by done(), and main().

#define HARMLESS   0
 

Definition at line 82 of file badblocks.c.

Referenced by done(), and main().

#define INT_BITS   (SIZE_OF_INT << 3)
 

Definition at line 493 of file badblocks.c.

Referenced by blk_ok(), and set_bit().

#define NOT_OK   1
 

Definition at line 76 of file badblocks.c.

Referenced by blk_ok(), main(), and ok().

#define OK   0
 

Definition at line 75 of file badblocks.c.

#define QUIT   2
 

Definition at line 77 of file badblocks.c.

#define READ   0
 

Definition at line 79 of file badblocks.c.

#define SIZE_OF_INT   (sizeof (int) )
 

Definition at line 90 of file badblocks.c.

Referenced by blk_ok(), and set_bit().

#define SUCCESS   4
 

Definition at line 86 of file badblocks.c.

Referenced by announce(), done(), find_user(), main(), processrequest(), tail(), TalkChk(), and TalkInit().

#define V_NR_DZONES   V2_NR_DZONES
 

Definition at line 97 of file badblocks.c.

Referenced by reset_blks().

#define V_SMALLER   V1_NR_DZONES
 

Definition at line 98 of file badblocks.c.

Referenced by main().

#define WRITE   1
 

Definition at line 80 of file badblocks.c.


Function Documentation

_PROTOTYPE void  done,
(int nr) 
 

_PROTOTYPE int  ok,
(char *str
 

_PROTOTYPE long  rd_num,
(void) 
 

_PROTOTYPE void  set_bit,
(zone_t num) 
 

_PROTOTYPE int  blk_ok,
(block_t num) 
 

_PROTOTYPE int  blk_is_used,
(block_t blk_num) 
 

_PROTOTYPE void  save_blk,
(block_t blk_num) 
 

_PROTOTYPE void  modify,
(int nr_blocks) 
 

_PROTOTYPE long  rd_cmdline,
(int argc, char *argv[]) 
 

_PROTOTYPE void  get_inode,
(struct stat *stat_ptr) 
 

_PROTOTYPE void  rw_inode,
(struct stat *stat_ptr, int rw_mode) 
 

_PROTOTYPE void  get_super,
(void) 
 

_PROTOTYPE void  rw_super,
(int flag
 

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

int blk_is_used block_t  blk_num  ) 
 

Definition at line 480 of file badblocks.c.

References i.

Referenced by blk_ok().

int blk_ok block_t  num  ) 
 

Definition at line 495 of file badblocks.c.

References BIT_MAP_SHIFT, blk, blk_is_used(), BLOCK_SIZE, DIR_CREATED, done, INT_BITS, lseek, NOT_OK, offset, OK, printf, read, SEEK_SET, SIZE_OF_INT, sp, and words.

Referenced by main().

void done int  nr  ) 
 

Definition at line 642 of file badblocks.c.

References DEV_MOUNTED, dev_name, DIR_CREATED, dir_name, exit(), FILE_EXISTS, file_name, HARMLESS, rmdir, SUCCESS, sync, umount, and unlink.

void get_inode struct stat stat_ptr  ) 
 

Definition at line 238 of file badblocks.c.

References cnt, d1_inode::d1_zone, d2_inode::d2_zone, ip1, ip2, READ, rw_inode(), V1_NR_TZONES, and V2_NR_TZONES.

Referenced by advance(), alloc_inode(), forbidden(), fs_init(), init_root(), main(), readfs(), and unlink_file().

void get_super  ) 
 

Definition at line 164 of file badblocks.c.

References DIR_CREATED, done, printf, READ, rw_super(), sp, SUPER_MAGIC, SUPER_V2, SUPER_V3, and v2fs.

Referenced by alloc_inode(), alloc_zone(), free_inode(), free_zone(), main(), rd_indir(), rw_inode(), and wr_indir().

int main int  argc,
argv 
 

Definition at line 263 of file badblocks.c.

References blk_ok(), block_size, chmod, cnt, d1inode, d2inode, DEV_MOUNTED, DIR_CREATED, done, fclose(), FILE_EXISTS, finished(), fopen(), fp, fprintf(), fstat, get_inode(), get_super(), geteuid, HARMLESS, ip1, ip2, mkdir, mktemp(), mount, NOT_OK, NULL, O_RDWR, ok(), OK, open, printf, QUIT, rd_cmdline(), rd_num(), reset_blks(), S_IFBLK, S_IFMT, save_blk(), sbs, show_blks(), sp, stat::st_mode, stat, stat_buf, stderr, strcat(), umount, V1_INODE_SIZE, V1_INODES_PER_BLOCK, V2_INODE_SIZE, V2_INODES_PER_BLOCK, v2fs, and V_SMALLER.

void modify int  nr_blocks  ) 
 

Definition at line 423 of file badblocks.c.

References d1_inode::d1_zone, i, ip1, and set_bit().

int ok char *  str  ) 
 

Definition at line 618 of file badblocks.c.

References c, EOF, getchar, NOT_OK, OK, printf, and QUIT.

Referenced by affirmative(), chkdirectory(), chkfile(), chkzones(), cidr_aton(), doiobj(), get_name(), isokendpt_f(), lrstr(), main(), matchs(), pack_vector(), parse_cidr(), range_match(), and tab_parse().

void put_inode struct stat stat_ptr  ) 
 

Definition at line 255 of file badblocks.c.

References rw_inode(), and WRITE.

Referenced by advance(), change_into(), clone_opcl(), common_open(), do_access(), do_chdir(), do_chmod(), do_chown(), do_close(), do_link(), do_lstat(), do_mkdir(), do_mknod(), do_rdlink(), do_reboot(), do_rename(), do_slink(), do_stat(), do_truncate(), do_unlink(), do_utime(), ltraverse(), name_to_dev(), new_node(), parse_path(), and unlink_file().

void put_super  ) 
 

Definition at line 186 of file badblocks.c.

References rw_super(), and WRITE.

long rd_cmdline int  argc,
argv 
 

Definition at line 414 of file badblocks.c.

References atol().

Referenced by main().

long rd_num  ) 
 

Definition at line 591 of file badblocks.c.

References c, EOF, exit(), getchar, num(), and printf.

Referenced by main().

void reset_blks  ) 
 

Definition at line 463 of file badblocks.c.

References blk_cnt, i, and V_NR_DZONES.

Referenced by main().

void rw_inode struct stat stat_ptr,
int  rw_mode
 

Definition at line 193 of file badblocks.c.

References blk, BLOCK_SIZE, DIR_CREATED, done, ip1, ip2, lseek, offset, printf, read, READ, SEEK_SET, sp, and write.

Referenced by common_open(), do_pipe(), do_sync(), get_inode(), new_node(), and put_inode().

void rw_super int  flag  ) 
 

Definition at line 144 of file badblocks.c.

References BLOCK_SIZE, DIR_CREATED, done, L, lseek, printf, read, READ, SEEK_SET, sp, SUPER_SIZE, and write.

Referenced by get_super(), and put_super().

void save_blk block_t  blk_num  ) 
 

Definition at line 457 of file badblocks.c.

References blk_cnt.

Referenced by main().

void set_bit zone_t  num  ) 
 

Definition at line 543 of file badblocks.c.

References BIT_MAP_SHIFT, blk, BLOCK_SIZE, DEV_MOUNTED, DIR_CREATED, done, INT_BITS, L, long(), lseek, offset, printf, read, SEEK_SET, SIZE_OF_INT, sp, words, and write.

Referenced by modify().

void show_blks  ) 
 

Definition at line 472 of file badblocks.c.

References blk_cnt, i, and printf.

Referenced by main().


Variable Documentation

blk_cnt = 0 [static]
 

Definition at line 455 of file badblocks.c.

Referenced by reset_blks(), save_blk(), and show_blks().

block_t block[V_NR_DZONES+1]
 

Definition at line 123 of file badblocks.c.

Referenced by andor(), c_list(), do_select(), list(), namelist(), nested(), and pipeline().

d1_inode d1inode
 

Definition at line 136 of file badblocks.c.

Referenced by main().

d2_inode d2inode
 

Definition at line 138 of file badblocks.c.

Referenced by main().

char* dev_name
 

Definition at line 118 of file badblocks.c.

Referenced by done(), and fill_iftab().

char dir_name[] = "/tmpXXXXXX"
 

Definition at line 121 of file badblocks.c.

Referenced by done(), Find_Deleted_Entry(), main(), and remove_dir().

int eofseen
 

Definition at line 129 of file badblocks.c.

FILE* f
 

Definition at line 127 of file badblocks.c.

Referenced by _cre(), _fprintPwd(), _ini(), _opn(), _wrb(), _wrc(), _wrf(), _wri(), _wrl(), _wrr(), _wrs(), _wrz(), _wsb(), _wsc(), _wsi(), _wsl(), _wsr(), _wss(), _wstrin(), _wsz(), basefind(), bread(), bwrite(), clear_func(), copy_action(), copy_ident(), copy_text(), countem(), cxsize(), die(), do_dup(), do_fcntl(), do_file(), do_ioctl(), do_unpause(), domark(), fill_buffer(), find_filp(), fprintPwd(), get_line(), getline(), getsym(), getzrxinit(), initfl(), library(), logmsg(), look(), main(), mark(), myfeof(), ne_probe(), netfinger(), openredirect(), permissions(), popfile(), print(), print1(), print_grammar(), printit(), procentry(), procexit(), raw_install(), read_write(), readword(), release(), select_match_pipe(), select_request_general(), select_request_pipe(), set_profile(), setstat(), skipit(), Still_Logged_On(), timestamp(), wcs(), wctxpn(), work(), and write_section().

char f_name[] = ".Bad_XXXXXX"
 

Definition at line 119 of file badblocks.c.

int fd
 

Definition at line 128 of file badblocks.c.

char file_name[50]
 

Definition at line 120 of file badblocks.c.

size_t inode_size
 

Definition at line 133 of file badblocks.c.

Referenced by init_super().

int inodes_per_block
 

Definition at line 132 of file badblocks.c.

int interactive
 

Definition at line 124 of file badblocks.c.

d1_inode* ip1
 

Definition at line 137 of file badblocks.c.

Referenced by get_inode(), main(), modify(), and rw_inode().

d2_inode* ip2
 

Definition at line 139 of file badblocks.c.

Referenced by get_inode(), main(), and rw_inode().

int position = 2
 

Definition at line 125 of file badblocks.c.

Referenced by get_part_table(), read_write(), and test_read().

struct super_block sbs
 

Definition at line 131 of file badblocks.c.

Referenced by main().

struct super_block* sp
 

Definition at line 131 of file badblocks.c.

Referenced by add_lookback_edge(), addfname(), advance(), alloc_inode(), alloc_zone(), asciisetsize(), backref(), blank(), blk_ok(), bltinlookup(), build_relations(), compute_lookaheads(), connect(), df(), dissect(), dn_comp(), dn_find(), do_exec(), do_mount(), do_privctl(), do_reboot(), dodot(), dowait(), dump_stack(), dyndep(), enlarge(), evalcommand(), evalfor(), execve(), expandarg(), expandmeta(), expr_operator(), expsort(), fallbackQSort3(), finds_data(), finds_pc(), findsname(), findstr(), findsval(), forbidden(), free_inode(), free_shifts(), free_zone(), fsversion(), fts_get_clientptr(), fts_open(), fts_set_clientptr(), fts_ufslinks(), get_args(), get_block_size(), get_priv(), get_shifts(), get_state(), get_super(), getopt(), gnu_finds_data(), gnu_finds_pc(), gnu_listsym(), gnu_sname(), gnu_sval(), gnu_symbolic(), gnu_symbolvalue(), gnu_symeq(), gnu_symprefix(), gnu_text_symbol(), growstackblock(), ifsbreakup(), init_root(), initialize(), initialize_F(), listsym(), long2speed(), ltraverse(), macro(), main(), mainQSort3(), mounted(), netfinger(), new_block(), newname(), outfunc(), output(), p_b_cclass(), p_b_coll_elem(), parsenode(), Pass2(), Pass3(), patch_stack(), popstackmark(), print_actions(), print_core(), print_gotos(), privileges_dmp(), process(), rd_indir(), read_only(), recomp(), recvfile(), regtry(), rexecve(), rw_inode(), rw_seg(), rw_super(), save_column(), sayhello(), search(), search_dir(), sendfile(), set_accessing_symbol(), set_bit(), set_EFF(), set_goto_map(), set_shift_table(), set_state_table(), speed2long(), stalloc(), swapon(), symbolic(), symbolvalue(), symeq(), symprefix(), text_symbol(), transpose(), trymandir(), unmount(), update_times(), and wr_indir().

struct stat stat_buf
 

Definition at line 130 of file badblocks.c.

Referenced by main(), and parse_arguments().

int v1fs = 0
 

Definition at line 134 of file badblocks.c.

int v2fs = 0
 

Definition at line 134 of file badblocks.c.

Referenced by get_super(), and main().


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