add fasthalt
[unix-history] / usr / src / sbin / fsdb / fsdb.8
CommitLineData
ba8cfc9e
KM
1.\" Copyright (c) 1988 Regents of the University of California.
2.\" All rights reserved.
3.\"
57a981eb 4.\" This code is derived from software contributed to Berkeley by
ba8cfc9e 5.\" Computer Consoles Inc.
57a981eb 6.\"
ba8cfc9e 7.\" Redistribution and use in source and binary forms are permitted
57a981eb
KB
8.\" provided that the above copyright notice and this paragraph are
9.\" duplicated in all such forms and that any documentation,
10.\" advertising materials, and other materials related to such
11.\" distribution and use acknowledge that the software was developed
12.\" by the University of California, Berkeley. The name of the
13.\" University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
ba8cfc9e 18.\"
57a981eb 19.\" @(#)fsdb.8 6.2 (Berkeley) %G%
ba8cfc9e
KM
20.\"
21.TH FSDB 8 ""
22.UC 7
23.SH NAME
24fsdb \- file system debugger
25.SH SYNOPSIS
26.B /etc/fsdb
27.RB [ options ]
28special
29.SH OPTIONS
30The options available to
31.I fsdb\^
32are:
33.RS
34.PD 0
35.TP 13
36.B -?
37display usage
38.TP 13
39.B -o
40override some error conditions
41.TP 13
42.B "-p'string'\^"
43set prompt to string
44.TP 13
45.B -w
46open for write
47.PD
48.RE
49.SH DESCRIPTION
50Since
51.I fsdb
52reads the disk raw,
53it is able to circumvent normal
54file system security.
55Extreme caution is advised
56in determining its availability
57on the system.
58Suggested permissions are 600
59and owned by bin.
60.PP
61.I Fsdb\^
62can be used
63to patch up
64a damaged file system
65after a crash.
66It has conversions
67to translate block and i-numbers
68into their corresponding disk addresses.
69Also included are mnemonic offsets
70to access different parts
71of an inode.
72These greatly simplify the process
73of correcting control block entries
74or descending the file system tree.
75.PP
76.I Fsdb\^
77contains several error-checking routines
78to verify inode and block addresses.
79These can be disabled if necessary
80by invoking
81.I fsdb\^
82with the
83.IR \-o
84option
85or by the use of the
86.IR o
87command.
88.PP
89.I Fsdb\^
90reads a block at a time
91and will therefore work with raw as well as block
92I/O.
93A buffer management routine
94is used to retain commonly used
95blocks of data
96in order to reduce the number of read system calls.
97All assignment operations result
98in an immediate write-through
99of the corresponding block.
100Note that in order to modify
101any portion of the disk,
102.IR fsdb
103must be invoked with the
104.IR -w
105option.
106.PP
107Wherever possible,
108.IR adb- like
109syntax was adopted
110to promote the use
111of
112.IR fsdb
113through familiarity.
114.PP
115Numbers are considered hexadecimal by default.
116However, the user has control over how data is
117to be displayed
118or accepted.
119The
120.IR base
121command will display
122or set the input/output base.
123Once set,
124all input will default to this base
125and all output will be shown in this base.
126The base can be overriden temporarily for input by
127preceding hexadecimal numbers with '0x', preceding
128decimal numbers with '0t', or
129octal numbers with '0'.
130Hexadecimal numbers beginning with a-f or A-F must
131be preceded with '0x'
132to distinguish them from commands.
133.PP
134Disk addressing by
135.IR fsdb
136is at the byte level.
137However,
138.IR fsdb
139offers many commands to convert
140a desired inode, directory entry,
141block, superblock etc. to a
142byte address.
143Once the address has been calculated,
144.IR fsdb
145will record the result in
146.IR dot
147(see next paragraph).
148.PP
149Several global values are maintained by
150.IR fsdb :
151the current base (referred to as
152.IR base ),
153the current address (referred to as
154.IR dot ),
155the current inode (referred to as
156.IR inode ),
157the current count (referred to as
158.IR count ),
159and the current type (referred to as
160.IR type ).
161Most commands use the preset value of
162.IR dot
163in
164their execution.
165For example,
166.RS
167.PD 0
168.TP 7.2n
169> 2:inode
170.PD
171.RE
172will first set the value of
173.IR dot
174to 2, ':' will alert the start of a command,
175and the
176.IR inode
177command will set
178.IR inode
179to 2.
180A count is specified after a ','.
181Once set,
182.IR count
183will remain at this value
184until a new command is encountered
185which will then reset the value back to 1 (the default).
186So, if
187.RS
188.PD 0
189.TP 7.2n
190> 2000,400/X
191.PD
192.RE
193is typed,
194400 hex longs are listed
195from 2000,
196and when completed,
197the value of
198.IR dot
199will be 2000 + 400 * sizeof (long).
200If a carriage-return is then typed,
201the output routine will use the
202current values of
203.IR dot ,
204.IR count ,
205and
206.IR type
207and display 400 more hex longs.
208A '*' will cause the entire block to
209be displayed.
210.PP
211End of fragment, block and file are maintained by
212.IR fsdb.
213When displaying data as fragments or blocks,
214an error message will be displayed when the end of fragment
215or block is reached.
216When displaying data using the
217.IR db,
218.IR ib,
219.IR directory,
220or
221.IR file
222commands an error message is displayed if the
223end of file is reached.
224This is mainly needed
225to avoid passing the
226end of a directory or file
227and getting unknown and unwanted results.
228.PP
229An example showing several commands and
230the use of carriage-return would be:
231.RS
232.PD 0
233.TP 7.2n
234> 2:ino; 0:dir?d
235.br
236or
237.PD
238.RE
239.RS
240.PD 0
241.TP 7.2n
242> 2:ino; 0:db:block?d
243.PD
244.RE
245The two examples are synonymous for getting to the first
246directory entry of the root of the file system.
247Once there,
248subsequent carriage-returns (or +, -) will advance to subsequent
249entries.
250Note that
251.RS
252.PD 0
253.TP 7.2n
254> 2:inode; :ls
255.br
256or
257.PD
258.RE
259.RS
260.PD 0
261.TP 7.2n
262> :ls /
263.PD
264.RE
265is again synonymous.
266.SH EXPRESSIONS
267.PP
268The symbols recognized by
269.I fsdb\^
270are:
271.TP 7.2n
272.B carriage-return
273update the value of
274.IR dot
275by the current value of
276.IR type
277and display using the current value of
278.IR count .
279.TP 7.2n
280.B #
281numeric expressions may be composed of +, -, *, and % operators
282(evaluated left to right) and may use parentheses. Once evaluated,
283the value of
284.IR dot
285is updated.
286.TP 7.2n
287.BI , " count"\^
288count indicator. The global value of
289.IR count
290will be updated to
291.IR count .
292The value of
293.IR count
294will remain until a new command is run.
295A count specifier of '*' will attempt to show a
296.IR blocks's
297worth of information.
298The default for
299.IR count
300is 1.
301.TP 7.2n
302.BI ? " f\^"
303display in structured style with format
304specifier
305.IR f
306(see FORMATTED OUTPUT section).
307.TP 7.2n
308.BI / " f\^"
309display in unstructured style with format
310specifier
311.IR f
312(see FORMATTED OUTPUT section).
313.TP 7.2n
314.B .
315the value of
316.IR dot .
317.TP 7.2n
318.BI + "e\^"
319increment the value of
320.IR dot
321by the expression
322.IR e.
323The amount actually incremented is dependent
324on the size of
325.IR type :
326.br
327.nf
328 dot = dot + e * sizeof (type)
329.fi
330The default for
331.IR e
332is 1.
333.TP 7.2n
334.BI - "e\^"
335decrement the value of
336.IR dot
337by the expression
338.IR e
339(see +).
340.TP 7.2n
341.BI * "e\^"
342multiply the value of
343.IR dot
344by the expression
345.IR e.
346Multiplication and division don't
347use
348.IR type.
349In the above calculation of
350.IR dot ,
351consider the
352sizeof (
353.IR type )
354to be 1.
355.TP 7.2n
356.BI % "e\^"
357divide the value of
358.IR dot
359by the expression
360.IR e
361(see *).
362.TP 7.2n
363.BI < " name\^"
364restore an address saved in register
365.IR name .
366.IR name
367must be a single letter or digit.
368.TP 7.2n
369.BI > " name\^"
370save an address in register
371.IR name .
372.IR name
373must be a single letter or digit.
374.TP 7.2n
375.BI = " f"
376display indicator.
377If
378.IR f
379is a legitimate format specifier
380(see FORMATTED OUTPUT
381section),
382then the value of
383.IR dot
384is displayed using
385format specifier
386.IR f .
387Otherwise,
388assignment is assumed
389(see next item).
390.TP 7.2n
391.BI = " [s] [e]\^"
392assignment indicator.
393The address pointed to by
394.IR dot
395has its contents changed to the value of the
396expression
397.IR e
398or to the
399.IR ASCII
400representation of the
401quoted (") string
402.IR s.
403This may be useful for changing
404directory names or
405.IR ASCII
406file information.
407.TP 7.2n
408.BI =+ " e\^"
409incremental assignment.
410The address pointed to by
411.IR dot
412has its contents incremented by expression
413.IR e .
414.TP 7.2n
415.BI =- " e\^"
416decremental assignment.
417The address pointed to by
418.IR dot
419has its contents decremented by expression
420.IR e .
421.SH COMMANDS
422.PP
423A command must be prefixed by a ':' character.
424Only enough letters of the command
425to uniquely
426distinguish it are needed.
427Multiple commands may be entered
428on one line by separating
429them by a space, tab or ';'.
430.PP
431In order to view a potentially
432unmounted disk in a reasonable
433manner,
434.I fsdb\^
435offers the
436.IR cd ,
437.IR pwd ,
438.IR ls
439and
440.IR find
441commands.
442The functionality of these
443commands substantially matches those of
444its
445.IR UNIX
446counterparts
447(see individual command for details).
448The '*', '?', and '[-]' wild card
449characters are available.
450.TP 7.2n
451.BI base=b
452display or set base. As stated above,
453all input and output is governed by
454the current
455.IR base .
456If the '=b' is left off,
457the current
458.IR base
459is displayed.
460Otherwise, the current
461.IR base
462is set
463to
464.IR b.
465Note that this is interpreted
466using the old value of
467.IR base ,
468so to ensure correctness use the '0', '0t', or '0x'
469prefix when changing the
470.IR base.
471The default for
472.IR base
473is hexadecimal.
474.TP 7.2n
475.B block
476convert the value of
477.IR dot
478to a block address.
479.TP 7.2n
480.B cd dir
481change the current directory
482to directory
483.IR dir.
484The current values of
485.IR inode
486and
487.IR dot
488are also updated.
489If no
490.IR dir
491is specified,
492then change directories to
493inode 2 ("/").
494.TP 7.2n
495.B cg
496convert the value of
497.IR dot
498to a cylinder group.
499.TP 7.2n
500.B directory
501If the current
502.IR inode
503is a directory,
504then the value of
505.IR dot
506is converted to a directory
507slot offset in that directory
508and
509.IR dot
510now points to
511this entry.
512.TP 7.2n
513.B file
514the value of
515.IR dot
516is taken as
517a relative block count from the
518beginning of the file.
519The value of
520.IR dot
521is updated to the first byte
522of this block.
523.IR
524.TP 7.2n
525.BI find " dir [-name n] [-inum i]\^"
526find files by name or i-number.
527.IR find
528recursively searches
529directory
530.IR dir
531and below for filenames whose
532i-number matches
533.IR i
534or whose name
535matches pattern
536.IR n .
537Note that only one of the two options
538(-name or -inum)
539may be used at one time.
540Also, the -print is not needed or
541accepted.
542.TP 7.2n
543.BI fill "=p\^"
544fill an area of disk with pattern
545.IR p.
546The area of disk
547is delimited by
548.IR dot
549and
550.IR count .
551.TP 7.2n
552.B fragment
553convert the value of
554.IR dot
555to
556a fragment address.
557The only difference between the
558.IR fragment
559command and the
560.IR block
561command is the amount that
562is able to be displayed.
563.TP 7.2n
564.B inode
565convert the value of
566.IR dot
567to an inode address.
568If successful,
569the current value of
570.IR inode
571will be updated as well as
572the value of
573.IR dot.
574As a convenient shorthand,
575if ':inode' appears at the
576beginning of the line,
577the value of
578.IR dot
579is set to the current
580.IR inode
581and that inode is displayed
582in inode format.
583.TP 7.2n
584.BI ls " [-R] [-l] pat1 pat2 ...\^"
585list directories or files.
586If no file is specified,
587the current directory is assumed.
588Either or both of the
589options may be used (but, if used,
590.IR must
591be specified before the
592filename specifiers).
593Also, as stated above,
594wild card characters are
595available and multiple
596arguments may be given.
597The long listing shows only
598the i-number and the name;
599use the
600.IR inode
601command with '?i'
602to get more information.
603.TP 7.2n
604.B override
605toggle the value of override.
606Some error conditions may be
607overriden
608if override is toggled on.
609.TP 7.2n
610.BI prompt " p\^"
611change the fsdb prompt to
612.IR p.
613.IR p
614must be surrounded by (")s.
615.TP 7.2n
616.B pwd
617display the current working directory.
618.TP 7.2n
619.B quit
620quit
621.IR fsdb .
622.TP 7.2n
623.B sb
624the value of
625.IR dot
626is taken as a cylinder group
627number and then converted to
628the address of the superblock
629in that cylinder group.
630As a shorthand, ':sb' at
631the beginning of a line
632will set the value of
633.IR dot
634to
635.IR the
636superblock and display it
637in superblock format.
638.TP 7.2n
639.B !
640escape to shell
641.SH INODE COMMANDS
642In addition to the above commands,
643there are several commands that deal with inode
644fields and operate directly on the current
645.IR inode
646(they still require the ':').
647They may be used to more easily display
648or change the particular fields.
649The value of
650.IR dot
651is only used by the ':db'
652and ':ib' commands.
653Upon completion of the command,
654the value of
655.IR dot
656is changed to point to
657that particular field.
658For example,
659.RS
660.PD 0
661.TP 7.2n
662> :ln=+1
663.PD
664.RE
665would
666increment the link count of the current
667.IR inode
668and set the value of
669.IR dot
670to the address of the link
671count field.
672.TP 7.2n
673.B at
674access time.
675.TP 7.2n
676.B bs
677block size.
678.TP 7.2n
679.B ct
680creation time.
681.TP 7.2n
682.B db
683use the current value of
684.IR dot
685as a direct block index,
686where direct blocks number from
6870 - 11.
688In order to display the block
689itself, you need to 'pipe' this
690result into the
691.IR block
692or
693.IR fragment
694command.
695For example,
696.br
697.nf
698 > 1:db:block,20/X
699.fi
700would get the contents of
701data block field 1 from the inode and
702convert it to a block address.
70320 longs are then displayed in hexadecimal
704(see FORMATTED OUTPUT section).
705.TP 7.2n
706.B gid
707group id.
708.TP 7.2n
709.B ib
710use the current value of
711.IR dot
712as an indirect block index
713where indirect blocks number from
7140 - 2.
715This will only get the indirect block itself
716(the block containing the pointers to the actual blocks).
717Use the
718.IR file
719command and start at block 12 to get to the actual
720blocks.
721.TP 7.2n
722.B ln
723link count.
724.TP 7.2n
725.B mt
726modification time.
727.TP 7.2n
728.B md
729mode.
730.TP 7.2n
731.B maj
732major device number.
733.TP 7.2n
734.B min
735minor device number.
736.TP 7.2n
737.B nm
738although listed here,
739this command actually
740operates on the directory
741name field.
742Once poised at the desired
743directory entry (using the
744.IR directory
745command),
746this command will allow
747you to change or display
748the directory name.
749For example,
750.br
751.nf
752 > 7:dir:nm="foo"
753.fi
754will get the 7th directory
755entry of the current
756.IR inode
757and change its name to foo.
758Note that names
759cannot be made larger than the
760field is set up for.
761If an attempt is made,
762the string is truncated to fit
763and a warning message to this
764effect is displayed.
765.TP 7.2n
766.B sz
767file size.
768.TP 7.2n
769.B uid
770user id.
771.SH FORMATTED OUTPUT
772.PP
773There are two styles
774and many format types.
775The two styles are structured and
776unstructured.
777Structured output is used to display
778inodes, directories, superblocks and the
779like.
780Unstructured just displays
781raw data.
782The following table shows the
783different ways of displaying:
784.TP 7.2n
785.B ?
786.RS
787.PD 0
788.TP 13
789.B c
790display as cylinder groups
791.TP 13
792.B i
793display as inodes
794.TP 13
795.B d
796display as directories
797.TP 13
798.B s
799display as superblocks
800.PD
801.RE
802.TP 7.2n
803.B /
804.RS
805.PD 0
806.TP 13
807.B b
808display as bytes
809.TP 13
810.B c
811display as characters
812.TP 13
813.B o O
814display as octal shorts or longs
815.TP 13
816.B d D
817display as decimal shorts or longs
818.TP 13
819.B x X
820display as hexadecimal shorts or longs
821.PD
822.RE
823.PP
824The format specifier immediately follows
825the '/' or '?' character.
826The values displayed by '/b' and all '?'
827formats are displayed in the current
828.IR base .
829Also,
830.IR type
831is appropriately updated
832upon completion.
833.SH EXAMPLES
834.TP 16
835> 2000+400%(20+20)=D
836will display 2010 in decimal (use of
837.IR fsdb
838as a calculator
839for complex arithmetic).
840.TP 16
841> 386:ino?i
842display i-number 386 in an inode format.
843This now becomes the current
844.IR inode .
845.TP 16
846> :ln=4
847changes the link count for the
848current
849.IR inode
850to 4.
851.TP 16
852> :ln=+1
853increments the link count by 1.
854.TP 16
855> :ct=X
856display the creation time as a hexadecimal long.
857.TP 16
858> :mt=t
859display the modification time in time format.
860.TP 16
861> 0:file/c
862displays, in
863.IR ASCII ,
864block zero of the file associated
865with the
866current
867.IR inode .
868.TP 16
869> 2:ino,*?d
870displays the first blocks worth of directory entries for
871the root inode of this file system.
872It will stop prematurely if the eof is reached.
873.TP 16
874> 5:dir:inode; 0:file,*/c
875changes the current inode to that
876associated with the 5th directory entry
877(numbered from zero)
878of the current
879.IR inode.
880The first logical block of the file
881is then displayed in
882.IR ASCII .
883.TP 16
884> :sb
885displays the superblock of this file system.
886.TP 16
887> 1:cg?c
888displays cylinder group information and summary
889for cylinder group 1.
890.TP 16
891> 2:inode; 7:dir=3
892changes the i-number for the
893seventh directory slot in the root directory to 3.
894.TP 16
895> 7:dir:nm="name"
896changes the name field
897in the directory slot to
898.IR name .
899.TP 16
900> 2:db:block,*?d
901displays the third block of the current
902.IR inode
903as directory entries.
904.TP 16
905> 3c3:fragment,20:fill=0x20
906get fragment 3c3 and fill 20
907.IR type
908elements
909with 0x20.
910.TP 16
911> 2050=0xffff
912set the contents of address 2050 to 0xffffffff.
9130xffffffff may be truncated depending on the current
914.IR type.
915.TP 16
916> 1c92434="this is some text"
917will place the
918.IR ASCII
919for the string at
9201c92434.
921.SH SEE ALSO
922fsck(8), dir(4), fs(5).
923.SH BUGS
924.PP
925Extreme caution is advised in
926determining the availability
927of
928.IR fsdb
929on the system.
930Suggested permissions are 600 and
931owned by bin.