#include <sys/types.h>#include <sys/stat.h>#include <stdlib.h>#include <fcntl.h>#include <string.h>#include <unistd.h>#include <stdio.h>#include <assert.h>Include dependency graph for swapfs.c:

Go to the source code of this file.
Data Structures | |
| struct | super_t |
| struct | inode_t |
Defines | |
| #define | _POSIX_SOURCE 1 |
| #define | _PROTOTYPE(function, params) function() |
| #define | BLOCK_SIZE 1024 |
| #define | BOOT_BLOCK_OFF (blockn_t) 0 |
| #define | SUPER_BLOCK_OFF (blockn_t) 1 |
| #define | V1_MAGIC 0x137F |
| #define | V2_MAGIC 0x2468 |
| #define | NINODES_OFFSET 0 |
| #define | V1_ZONES_OFFSET 2 |
| #define | IMAP_BLOCKS_OFFSET 4 |
| #define | ZMAP_BLOCKS_OFFSET 6 |
| #define | FIRSTDATAZONE_OFFSET 8 |
| #define | LOG_ZONE_SIZE_OFFSET 10 |
| #define | MAGIC_OFFSET 16 |
| #define | V2_ZONES_OFFSET 20 |
| #define | NR_DIRECT_ZONES 7 |
| #define | V1_NR_TZONES 9 |
| #define | V2_NR_TZONES 10 |
| #define | V1_INODE_SIZE 32 |
| #define | V2_INODE_SIZE 64 |
| #define | INODE1_MODE_OFF 0 |
| #define | INODE1_SIZE_OFF 4 |
| #define | INODE1_DIRECT_OFF 14 |
| #define | INODE1_IND1_OFF 28 |
| #define | INODE1_IND2_OFF 30 |
| #define | INODE2_MODE_OFF 0 |
| #define | INODE2_SIZE_OFF 8 |
| #define | INODE2_DIRECT_OFF 24 |
| #define | INODE2_IND1_OFF 52 |
| #define | INODE2_IND2_OFF 56 |
| #define | INODE2_IND3_OFF 60 |
| #define | INODE_MODE_MASK 0xf000 |
| #define | INODE_DIR_MODE 0x4000 |
| #define | INODE_BLK_SPECIAL_MODE 0x6000 |
| #define | INODE_CHR_SPECIAL_MODE 0x2000 |
| #define | T_MASK 0x1c |
| #define | T_UNKNOWN 0x00 |
| #define | T_MAYBE_OLD_DIR 0x04 |
| #define | T_OLD_NON_DIR 0x08 |
| #define | T_DIR 0x0c |
| #define | T_NON_DIR 0x10 |
| #define | INDIRECT_MASK 0x03 |
| #define | IND_PROCESSED_BIT 0x20 |
| #define | IND_CONFLICT_BIT 0x40 |
| #define | TYPE_CONFLICT_BIT 0x80 |
| #define | DIR_ENTRY_SIZE 16 |
Typedefs | |
| typedef unsigned long | blockn_t |
| typedef unsigned int | inodesn_t |
| typedef unsigned char * | dzmap_t |
Enumerations | |
| enum | class_t { Unused_zone, Old_zone, In_use_zone } |
Functions | |
| int | _PROTOTYPE (main,(int argc, char *argv[])) |
| static void | _PROTOTYPE (parse_args_init_io,(int argc, char *argv[])) |
| static void | _PROTOTYPE (rw_boot,(void)) |
| static void | _PROTOTYPE (rw_init_super,(super_t *sp)) |
| static void | _PROTOTYPE (init_dzmap,(dzmap_t *dzmap_ptr, size_t dzmap_size)) |
| static void | _PROTOTYPE (rw_ibmap,(super_t super)) |
| static void | _PROTOTYPE (rw_zbmap,(super_t super)) |
| static void | _PROTOTYPE (print_stat,(dzmap_t dzmap, super_t super)) |
| static void | _PROTOTYPE (p1_rw_inodes,(dzmap_t dzmap, super_t super)) |
| static void | _PROTOTYPE (rd_indirects,(dzmap_t dzmap, super_t super, int ind, class_t required_class)) |
| static void | _PROTOTYPE (rw_data_zones,(dzmap_t dzmap, super_t super)) |
| static int | _PROTOTYPE (read_block,(char *buf, blockn_t offset)) |
| static void | _PROTOTYPE (write_block,(char *buf)) |
| static int | _PROTOTYPE (convcpy,(char *dst, char *src, int *format)) |
| static void | _PROTOTYPE (conv2_blkcpy,(char *dst, char *src)) |
| static void | _PROTOTYPE (conv4_blkcpy,(char *dst, char *src)) |
| static void | _PROTOTYPE (conv2cpy,(char *dst, char *src)) |
| static int | _PROTOTYPE (inode_size,(int version)) |
| static void | _PROTOTYPE (init_super,(super_t *sp, char *buf)) |
| static void | _PROTOTYPE (get_inode,(inode_t *ip, char *buf, int version)) |
| static int | _PROTOTYPE (check_inode,(inode_t inode, super_t super)) |
| static int | _PROTOTYPE (was_blk_special,(inode_t inode)) |
| static int | _PROTOTYPE (check_blk_number,(blockn_t num, super_t super)) |
| static void | _PROTOTYPE (cw_inode_block,(char *buf, inodesn_t ninodes, int version)) |
| static void | _PROTOTYPE (proc_ind,(dzmap_t dzmap, size_t curr_ind, char *buf, super_t super)) |
| static void | _PROTOTYPE (cw_dir_block,(char *buf)) |
| static void | _PROTOTYPE (dzmap_add_inode,(dzmap_t dzmap, inode_t inode, super_t super)) |
| static void | _PROTOTYPE (dz_update,(dzmap_t dzmap, blockn_t blknum, int new_indnum, int new_ztype, super_t super)) |
| static class_t | _PROTOTYPE (ztype_class,(int ztype)) |
| static unsigned int | _PROTOTYPE (two_bytes,(char buf[2])) |
| static long | _PROTOTYPE (four_bytes,(char buf[4])) |
| static void | _PROTOTYPE (fail,(char *string)) |
| static void | _PROTOTYPE (usage,(char *arg0)) |
| int | main (int argc, argv) |
| static void | parse_args_init_io (int argc, argv) |
| static void | rw_boot () |
| static void | rw_init_super (super_t *sp) |
| static void | init_dzmap (dzmap_t *dzmap_ptr, size_t dzmap_size) |
| static void | rw_ibmap (super_t super) |
| static void | rw_zbmap (super_t super) |
| static void | p1_rw_inodes (dzmap_t dzmap, super_t super) |
| static void | print_stat (dzmap_t dzmap, super_t super) |
| static void | rd_indirects (dzmap_t dzmap, super_t super, int ind, class_t required_class) |
| static void | rw_data_zones (dzmap_t dzmap, super_t super) |
| static int | read_block (char *buf, blockn_t offset) |
| static void | write_block (char *buf) |
| static int | convcpy (char *dst, char *src, int *format) |
| static void | conv2_blkcpy (char *dst, char *src) |
| static void | conv4_blkcpy (char *dst, char *src) |
| static void | conv2cpy (char *dst, char *src) |
| static int | inode_size (int version) |
| static void | init_super (super_t *sp, char *buf) |
| static void | get_inode (inode_t *ip, char *buf, int version) |
| static int | check_inode (inode_t inode, super_t super) |
| static int | check_blk_number (blockn_t num, super_t super) |
| static int | was_blk_special (inode_t inode) |
| static void | cw_inode_block (char *buf, inodesn_t ninodes, int version) |
| static void | proc_ind (dzmap_t dzmap, size_t curr_ind, char *buf, super_t super) |
| static void | cw_dir_block (char *buf) |
| static void | dzmap_add_inode (dzmap_t dzmap, inode_t inode, super_t super) |
| static void | dz_update (dzmap_t dzmap, blockn_t blknum, int new_indnum, int new_ztype, super_t super) |
| static class_t | ztype_class (int ztype) |
| static void | fail (char *str) |
| static unsigned int | two_bytes (buf) |
| static long | four_bytes (buf) |
| static void | usage (char *arg0) |
Variables | |
| static char | rcsid [] = "$Id: swapfs.c,v 1.1.1.1 2005/04/21 14:55:33 beng Exp $" |
| static int | super_format [] = {2, 2, 2, 2, 2, 2, 4, 2, 2, 4, 0} |
| static int | inode1_format [] = {2, 2, 4, 4, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0} |
| static int | inode2_format [] |
| static char * | ind_str [4] |
| static int | big_endian_fs |
| static int | verbose_flag |
| static int | debug_flag |
| static int | test_flag |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 58 of file swapfs.c. Referenced by rw_boot(). |
|
|
Definition at line 111 of file swapfs.c. Referenced by chkdirzone(), chkdots(), cw_dir_block(), get_inode(), r_readdir(), and search_dir(). |
|
|
Definition at line 67 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 65 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 108 of file swapfs.c. Referenced by dz_update(), and print_stat(). |
|
|
Definition at line 106 of file swapfs.c. Referenced by rd_indirects(). |
|
|
Definition at line 104 of file swapfs.c. Referenced by dz_update(), proc_ind(), rd_indirects(), and rw_data_zones(). |
|
|
Definition at line 81 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 82 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 83 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 79 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 80 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 87 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 88 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 89 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 90 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 85 of file swapfs.c. Referenced by get_inode(). |
|
|
Definition at line 86 of file swapfs.c. Referenced by get_inode(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 68 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 69 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 63 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 73 of file swapfs.c. Referenced by check_inode(), dzmap_add_inode(), get_inode(), and was_blk_special(). |
|
|
Definition at line 59 of file swapfs.c. Referenced by init_super(), and rw_init_super(). |
|
|
Definition at line 101 of file swapfs.c. Referenced by rw_data_zones(), and ztype_class(). |
|
|
Definition at line 97 of file swapfs.c. Referenced by print_stat(), proc_ind(), rd_indirects(), and rw_data_zones(). |
|
|
Definition at line 99 of file swapfs.c. Referenced by dz_update(), get_inode(), and ztype_class(). |
|
|
Definition at line 102 of file swapfs.c. Referenced by ztype_class(). |
|
|
Definition at line 100 of file swapfs.c. Referenced by get_inode(), and ztype_class(). |
|
|
|
|
|
Definition at line 109 of file swapfs.c. Referenced by dz_update(), and print_stat(). |
|
|
Definition at line 76 of file swapfs.c. Referenced by fs_init(), inode_size(), main(), read_super(), and Read_Super_Block(). |
|
|
Definition at line 61 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 74 of file swapfs.c. Referenced by get_inode(), old_icopy(), and r_stat(). |
|
|
Definition at line 64 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 77 of file swapfs.c. Referenced by fs_init(), inode_size(), main(), read_super(), Read_Super_Block(), and Recover_Blocks(). |
|
|
Definition at line 62 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 75 of file swapfs.c. Referenced by get_inode(), new_icopy(), r_stat(), and wipe_inode(). |
|
|
Definition at line 70 of file swapfs.c. Referenced by init_super(). |
|
|
Definition at line 66 of file swapfs.c. Referenced by init_super(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 736 of file swapfs.c. References fprintf(), stderr, and super. Referenced by check_inode(). |
|
||||||||||||
|
Definition at line 721 of file swapfs.c. References check_blk_number(), i, NR_DIRECT_ZONES, and super. Referenced by dzmap_add_inode(). |
|
||||||||||||
|
Definition at line 567 of file swapfs.c. References BLOCK_SIZE, i, and tmp. Referenced by rw_ibmap(), and rw_zbmap(). |
|
||||||||||||
|
Definition at line 604 of file swapfs.c. References tmp. Referenced by cw_dir_block(). |
|
||||||||||||
|
Definition at line 582 of file swapfs.c. References BLOCK_SIZE, i, and tmp. |
|
||||||||||||||||
|
Definition at line 532 of file swapfs.c. Referenced by cw_inode_block(), and rw_init_super(). |
|
|
Definition at line 892 of file swapfs.c. References conv2cpy(), DIR_ENTRY_SIZE, i, memcpy(), and two_bytes(). Referenced by rw_data_zones(). |
|
||||||||||||||||
|
Definition at line 769 of file swapfs.c. References BLOCK_SIZE, cnt, convcpy(), format, i, inode1_format, and inode2_format. Referenced by p1_rw_inodes(). |
|
||||||||||||||||||||||||
|
Definition at line 930 of file swapfs.c. References assert, fail, fprintf(), In_use_zone, IND_CONFLICT_BIT, INDIRECT_MASK, Old_zone, stderr, super, T_MAYBE_OLD_DIR, TYPE_CONFLICT_BIT, and ztype_class(). Referenced by dzmap_add_inode(). |
|
||||||||||||||||
|
Definition at line 912 of file swapfs.c. References check_inode(), inode_t::direct, dz_update(), i, inode_t::ind1, inode_t::ind2, inode_t::ind3, NR_DIRECT_ZONES, inode_t::size, super, and inode_t::ztype. |
|
|
|
|
|
Definition at line 1026 of file swapfs.c. References big_endian_fs. Referenced by get_inode(), init_super(), and proc_ind(). |
|
||||||||||||||||
|
Definition at line 680 of file swapfs.c. References DIR_ENTRY_SIZE, four_bytes(), i, if(), INODE1_DIRECT_OFF, INODE1_IND1_OFF, INODE1_IND2_OFF, INODE1_MODE_OFF, INODE1_SIZE_OFF, INODE2_DIRECT_OFF, INODE2_IND1_OFF, INODE2_IND2_OFF, INODE2_IND3_OFF, INODE2_MODE_OFF, INODE2_SIZE_OFF, NR_DIRECT_ZONES, T_MAYBE_OLD_DIR, T_OLD_NON_DIR, two_bytes(), and was_blk_special(). |
|
||||||||||||
|
Definition at line 321 of file swapfs.c. References fail, malloc(), memset(), and NULL. Referenced by main(). |
|
||||||||||||
|
Definition at line 622 of file swapfs.c. References big_endian_fs, BLOCK_SIZE, fail, FIRSTDATAZONE_OFFSET, four_bytes(), fprintf(), IMAP_BLOCKS_OFFSET, inode_size, LOG_ZONE_SIZE_OFFSET, magic, MAGIC_OFFSET, NINODES_OFFSET, stderr, SUPER_BLOCK_OFF, two_bytes(), V1_MAGIC, V1_ZONES_OFFSET, V2_MAGIC, V2_ZONES_OFFSET, verbose_flag, and ZMAP_BLOCKS_OFFSET. Referenced by rw_init_super(). |
|
|
Definition at line 615 of file swapfs.c. References V1_INODE_SIZE, and V2_INODE_SIZE. |
|
||||||||||||
|
Definition at line 210 of file swapfs.c. References In_use_zone, init_dzmap(), p1_rw_inodes(), parse_args_init_io(), print_stat(), putc, rd_indirects(), rw_boot(), rw_data_zones(), rw_ibmap(), rw_init_super(), rw_zbmap(), stderr, super, and verbose_flag. |
|
||||||||||||
|
Definition at line 361 of file swapfs.c. References BLOCK_SIZE, buf_ptr, cw_inode_block(), fail, i, if(), read_block(), and super. Referenced by main(). |
|
||||||||||||
|
Definition at line 236 of file swapfs.c. References buf, debug_flag, i, test_flag, usage, and verbose_flag. Referenced by main(). |
|
||||||||||||
|
Definition at line 391 of file swapfs.c. References i, In_use_zone, IND_CONFLICT_BIT, super, T_MASK, TYPE_CONFLICT_BIT, verbose_flag, and ztype_class(). Referenced by main(). |
|
||||||||||||||||||||
|
Definition at line 806 of file swapfs.c. References assert, blk, BLOCK_SIZE, expired(), four_bytes(), i, In_use_zone, INDIRECT_MASK, super, T_MASK, two_bytes(), ztype, and ztype_class(). |
|
||||||||||||||||||||
|
Definition at line 429 of file swapfs.c. References BLOCK_SIZE, fail, fprintf(), i, IND_PROCESSED_BIT, ind_str, INDIRECT_MASK, read_block(), stderr, super, T_MASK, and ztype_class(). Referenced by main(). |
|
||||||||||||
|
Definition at line 501 of file swapfs.c. References BLOCK_SIZE, bytes, fail, lseek, and read. Referenced by p1_rw_inodes(), rd_indirects(), rw_boot(), rw_data_zones(), rw_ibmap(), rw_init_super(), and rw_zbmap(). |
|
|
Definition at line 294 of file swapfs.c. References BLOCK_SIZE, BOOT_BLOCK_OFF, fail, read_block(), and write_block(). Referenced by main(). |
|
||||||||||||
|
Definition at line 460 of file swapfs.c. References BLOCK_SIZE, cw_dir_block(), i, ibuf, INDIRECT_MASK, obuf, read_block(), super, T_DIR, T_MASK, write_block(), and ztype. Referenced by main(). |
|
|
Definition at line 331 of file swapfs.c. References BLOCK_SIZE, conv2_blkcpy(), fail, ibuf, obuf, read_block(), and write_block(). Referenced by main(). |
|
|
Definition at line 304 of file swapfs.c. References BLOCK_SIZE, convcpy(), fail, ibuf, init_super(), memcpy(), obuf, read_block(), SUPER_BLOCK_OFF, super_format, and write_block(). Referenced by main(). |
|
|
Definition at line 346 of file swapfs.c. References BLOCK_SIZE, conv2_blkcpy(), fail, ibuf, obuf, read_block(), and write_block(). Referenced by main(). |
|
|
Definition at line 1014 of file swapfs.c. References big_endian_fs. Referenced by cw_dir_block(), dp_pio16_nic2user(), dp_pio16_user2nic(), get_inode(), init_super(), and proc_ind(). |
|
|
|
|
|
Definition at line 748 of file swapfs.c. References BLOCK_SIZE, block_size, debug_flag, fprintf(), i, if(), NR_DIRECT_ZONES, result, and stderr. Referenced by get_inode(). |
|
|
Definition at line 522 of file swapfs.c. References BLOCK_SIZE, fail, test_flag, and write. Referenced by rw_boot(), rw_data_zones(), rw_ibmap(), rw_init_super(), and rw_zbmap(). |
|
|
Definition at line 990 of file swapfs.c. References In_use_zone, Old_zone, T_DIR, T_MAYBE_OLD_DIR, T_NON_DIR, T_OLD_NON_DIR, and Unused_zone. Referenced by dz_update(), print_stat(), proc_ind(), and rd_indirects(). |
|
|
Definition at line 157 of file swapfs.c. Referenced by four_bytes(), init_super(), and two_bytes(). |
|
|
Definition at line 160 of file swapfs.c. Referenced by parse_args_init_io(), and was_blk_special(). |
|
|
Initial value: {"direct", "single indirect",
"double indirect", "triple indirect"}
Definition at line 154 of file swapfs.c. Referenced by rd_indirects(). |
|
|
Definition at line 150 of file swapfs.c. Referenced by cw_inode_block(). |
|
|
Initial value: {2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 0}
Definition at line 151 of file swapfs.c. Referenced by cw_inode_block(). |
|
|
|
|
|
Definition at line 149 of file swapfs.c. Referenced by rw_init_super(). |
|
|
Definition at line 161 of file swapfs.c. Referenced by parse_args_init_io(), and write_block(). |
|
|
Definition at line 159 of file swapfs.c. Referenced by add_file(), copy(), extract(), init_super(), main(), parse_args_init_io(), print_stat(), tarfile(), and verb_print(). |
1.4.6