NAME
	inspect -- hacks NILFS v1 disk

SYNOPSIS

	inspect [-e] [-s sketch_number [-o file]] device

DESCRIPTION

Specify device name as command line argument.  After invocation the
inspect, ``super'' command (see below) is executed first, then it
shows a prompt "nilfs>".  Type command name and some arguments (if
needed).

The following options are available:

-e  Print date in second from epoch in listcp output.

-s  sketch_number
    Pull out the sketch data from checkpoint which specified by sketch_number.
    Do listcp in inspect to get the check point number.
    After output the data, inspect exits immediately.

-o  filename
    With -s option, write out the sketch data to filename.
    If the -o option is not specified, stdout is used.

Interactives:

Argument syntax in this document.

* [arg (0)]   optional argument. In () is used as default value.
* Number means block number in common.
* Number is based of 10, 16 (0x...), 8 (0...). (same as C language syntax)
* Prefix #b means block (default), #s means segment.
* Trailing k means multiple 1024, m 1024^2, g 1024^3
  #s1k means block number of beginning of 1024th segment.
* . (period) means current block. Some command set the current block.

Commands:
    some command has aliases.

    bye, exit, quit, q
	exit inspect.

    set blk#
    number
	set blk# to current block (period)
	number without any command name means "set number"

    print
	print current block number

    super
	dump superblock
	set s_last_segment block number to current

    segment [blk# (.)]
	dump segment summary
	alias: ss

    inodehdr [blk# (.)]
	dump disk inode header
	alias: ih

    inode [blk# (.)] [nth (0)] [count (1)]
	dump disk inode.  There are many inodes in one disk block.
	nth specify the inode in one block.
	set blk# to current

    btree [blk# (.)]
	dump header of btree block
	set blk# to current

    bentry [blk# (.)] [nth (0)] [count (1)]
	print key/ptr pair of btree entry.
	alias: be

    listcp [start (0)] [length (no limit)] [number of checkpoints (no limit)] [a]
	list checkpoint which can use cp= option of nilfs mount.
	checkpoint position range can be specified with start/length option (unit: in full segment).
	options:
	   start:			start full segment number for checkpoint search
	   length:			number of full segments for search
	   number of checkpoints:	number of checkpoint to show
	   a:				print statistics.

    listcp output format without -e option:
    1207049    39 Mon Jan 16 14:58:21 2006 MajorCP|LogiBegin|LogiEnd 1390
							 sketch size ^^^^ (in byte)
					   ^^^^ check point flags
		  ^^^^^^^^^^^^^^^^^^^^^^^^ creation date
	       ^^ length of the partial segment (in block)
    ^^^^^^^ check point block number (aka sketch_number)

     listcp output format with -e option:
     463872  2184 1141636124 MajorCP|LogiEnd 1420
				             ^^^^ sketch size (byte)
			     ^^^^ check point flags
		  ^^^^^^^^^^ creation date in second from epoch
	       ^^ length of the partial segment (in block)
    ^^^^^^^ check point block number (aka sketch_number)

    listpseg [start (0)] [length (no limit)] [number of checkpoints (no limit)] [a]
        print partial segment informations.

    listpseg output
    4096  1024 Tue May 23 11:01:13 2006 -    0 1021     0     0     0
                                      number of inode B-tree blocks ^
                                       number of inode blocks ^
                           number of file B-tree blocks ^
                         number of file blocks ^^^^
				sketch size ^ (in byte)
					^ flags, '-' means no flags
	        ^^^^^^^^^^^^^^^^^^^^^^^^ creation date
	   ^^^^ length of the partial segment (in block)
    ^^^^ start block number

    Control-C (or INT signal)
        restart inspect top-level
        dump or listcp output are interrupted by typing Control-C.

    Line editing, command line history
        GNU readline is linked with inspect to edit command line.

The ``inspect'' reads disk data directly, so inspect cannot read any
data before syncing to disk.

Example:
  Inspect nilfs partition /dev/sdb1. The partition is just newfs-ed.

v1/inspect> ./inspect /dev/sdb1
magic	0x3434 rev 1.0				<<<< super command executed
block_size	4096
s_nsegment	7681	segment chunk 39
s_blocks_per_segment	1024
s_crc_seed	0x2a55f608
s_last_segment [blk#]	1			<<<< blk# of latest segment summary
s_last_seq [seq#]	0
s_ctime Tue Jan 17 11:00:04 2006
s_uuid  a9fba9f3-15b2-491b-ae15-ec1af4be3fed
nilfs> ss 1					<<<< dump the segment summary
block#		1	full segment#	0
sumsum		0xa879ba1d	checksum ok
ss_nblocks	6	(summary size	1 blk, 88 bytes)
segment size (w/o checkpoint)		5 blk
ss_nfinfo	1	ss_nfbinfo	1
ss_nfblk	1	ss_nfbblk	1
ss_niblk	1	ss_nibblk	1
flags		0x0031 MajorCP|LogiBegin|LogiEnd  <<<< this segment has mountable check point
checkpoint checksum ok
inode_root	5				  <<<< blk# of inode btree root
Tue Jan 17 11:20:12 2006
nilfs> btree 5					  <<<< dump the btree root
level 0	nkey 1					  <<<< the btree consists of 1 key/ptr pair
nilfs> be 5 0 1					  <<<< dump btree entry
 0 key 0 (0x0) ptr 4 (0x4)			  <<<< key/ptr is 0/4. 
nilfs> ih 4					  <<<< blk 4 is a leaf node, holds disk inode.
ih_ino		0
ih_flags	0x0
ih_nfree	40
ih_free		11
nilfs> inode 4 0 12				  <<<< dump disk inode entry.
						  <<<< ino == 2 is root directory of this fs
   0  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   1  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   2  blks   1	size  4096  links 2  mode 040755 dir  blk_root [blk#] 3	 flags 0x00000000 ver 1
   3  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   4  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   5  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   6  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   7  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   8  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
   9  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
  10  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
  11  blks   0	size	 0  links 0  mode 00   blk_root [blk#] 0  flags 0x10000000 ver 0
nilfs> btree 3					  <<<< blk 3 holds disk block btree root
level 0	nkey 1
nilfs> be 3 0 1
 0 key 0 (0x0) ptr 2 (0x2)			  <<<< blk 2 is leaf node, data block.
nilfs> dump 2					  <<<< dump block 2.  You can see "." and "..".
block# 2, segment# 0
0x0000	0x00000002  0x00000000	0x02010010  0x0000002e	0x00000002  0x00000000	0x02020ff0  0x00002e2e	
0x0020	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0040	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0060	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0080	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x00a0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x00c0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x00e0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0100	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0120	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0140	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0160	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0180	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x01a0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x01c0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x01e0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0200	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0220	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0240	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0260	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0280	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x02a0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x02c0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x02e0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0300	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0320	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0340	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0360	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x0380	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x03a0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x03c0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
0x03e0	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	0x00000000  0x00000000	
nilfs> q

---
inspect.txt,v 1.9 2006/07/14 10:47:47 amagai Exp
