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