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