Merge commit 'b31ca922c7346747131aed07c0c171ec2f573aac' into merges
[unleashed.git] / share / man / man8 / fsdb_udfs.8
blobd29811ccd3e5283283c61ff79ef8b928119927e0
1 '\" te
2 .\"  Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH FSDB_UDFS 8 "Jun 11, 1999"
7 .SH NAME
8 fsdb_udfs \- udfs file system debugger
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBfsdb \fR [\fB-F\fR] udfs [\fIgeneric_option\fR] [\fB-o \fR\fIspecific_option\fR] \fIspecial\fR
13 .fi
15 .SH DESCRIPTION
16 .sp
17 .LP
18 The \fBfsdb_udfs\fR command is an interactive tool that can be used to patch up
19 a damaged \fBudfs\fR file system. \fBfsdb_udfs\fR has conversions to translate
20 block and i-numbers into their corresponding disk addresses. Mnemonic offsets
21 to access different parts of an inode are also included. Mnemonic offsets
22 greatly simplify the process of correcting control block entries or descending
23 the file system tree.
24 .sp
25 .LP
26 \fBfsdb\fR contains several error-checking routines to verify inode and block
27 addresses. These can be disabled if necessary by invoking \fBfsdb\fR with the
28 \fB-o\fR option or by using the \fBo\fR command.
29 .sp
30 .LP
31 \fBfsdb\fR reads one block at a time, and therefore works with raw as well as
32 block \fBI/O\fR devices. A buffer management routine is used to retain commonly
33 used blocks of data in order to reduce the number of read system calls. All
34 assignment operations result in an immediate write-through of the corresponding
35 block. In order to modify any portion of the disk, \fBfsdb\fR must be invoked
36 with the \fB-w\fR option.
37 .sp
38 .LP
39 Wherever possible, \fBadb\fR-like syntax has been adopted to promote the use of
40 \fBfsdb\fR through familiarity.
41 .SH OPTIONS
42 .sp
43 .LP
44 The following options are supported:
45 .sp
46 .ne 2
47 .na
48 \fB\fB-o\fR \fIspecific_option\fR\fR
49 .ad
50 .RS 22n
51 Specify \fBudfs\fR file system specific options in a comma-separated list with
52 no intervening spaces. The following specific options are supported:
53 .sp
54 .ne 2
55 .na
56 \fBo\fR
57 .ad
58 .RS 12n
59 Override some error conditions.
60 .RE
62 .sp
63 .ne 2
64 .na
65 \fBp=\fIstring\fR\fR
66 .ad
67 .RS 12n
68 Set prompt to \fIstring\fR.
69 .RE
71 .sp
72 .ne 2
73 .na
74 \fBw\fR
75 .ad
76 .RS 12n
77 Open for write.
78 .RE
80 .sp
81 .ne 2
82 .na
83 \fB?\fR
84 .ad
85 .RS 12n
86 Display usage.
87 .RE
89 .RE
91 .SH USAGE
92 .sp
93 .LP
94 Numbers are considered hexadecimal by default. The user has control over how
95 data is to be displayed or accepted. The \fBbase\fR command displays or sets
96 the input and output base. Once set, all input defaults to this base and all
97 output displays in this base. The base can be overriden temporarily for input
98 by preceding hexadecimal numbers by \fB0x\fR, preceding decimal numbers with a
99 \fB0t\fR, or octal numbers with a \fB0\fR. Hexadecimal numbers beginning with
100 \fBa\fR-\fBf\fR or \fBA\fR -\fBF\fR must be preceded with a \fB0x\fR to
101 distinguish them from commands.
104 Disk addressing by \fBfsdb\fR is at the byte level. However, \fBfsdb\fR offers
105 many commands to convert a desired inode, directory entry, block, and so forth,
106 to a byte address. After the address has been calculated, \fBfsdb\fR records
107 the result in the current address (\fBdot\fR).
110 Several global values are maintained by \fBfsdb\fR\fB\fR:
111 .RS +4
113 .ie t \(bu
114 .el o
115 Current base (referred to as \fBbase\fR)
117 .RS +4
119 .ie t \(bu
120 .el o
121 Current address (referred to as \fBdot\fR)
123 .RS +4
125 .ie t \(bu
126 .el o
127 Current inode (referred to as \fBinode\fR)
129 .RS +4
131 .ie t \(bu
132 .el o
133 Current count (referred to as \fBcount\fR)
135 .RS +4
137 .ie t \(bu
138 .el o
139 Current type (referred to as \fBtype\fR)
143 Most commands use the preset value of \fBdot\fR in their execution. For
144 example,
146 .in +2
148  > 2:inode
150 .in -2
155 first sets the value of dot (\fB\&.\fR) to \fB2\fR, colon (\fB:\fR), signifies
156 the start of a command, and the \fBinode\fR command sets \fBinode\fR to
157 \fB2\fR. A count is specified after a comma (\fB,\fR). Once set, count remains
158 at this value until a new command is encountered that resets the value back to
159 \fB1\fR (the default).
162 So, if
164 .in +2
166 > 2000,400/X
168 .in -2
173 is entered, \fB400\fR hex longs are listed from \fB2000\fR, and when completed,
174 the value of dot is \fB 2000 + 400 * sizeof\fR (long). If a RETURN is then
175 entered, the output routine uses the current values of \fBdot\fR, \fBcount\fR,
176 and \fBtype\fR and displays \fB400 \fRmore hex longs. An asterisk (\fB*\fR)
177 causes the entire block to be displayed. An example showing several commands
178 and the use of RETURN would be:
180 .in +2
182 > 2:ino; 0:dir?d
184 .in -2
191 .in +2
193 > 2:ino; 0:db:block?d
195 .in -2
200 The two examples are synonymous for getting to the first directory entry of the
201 root of the file system. Once there, subsequently entering a RETURN, plus
202 (\fB+\fR), or minus (\fB-\fR)  advances to subsequent entries. Notice that
204 .in +2
206 > 2:inode; :ls
208 .in -2
215 .in +2
217 > :ls /
219 .in -2
224 is again synonymous.
225 .SS "Expressions"
228 The following symbols are recognized by \fBfsdb\fR:
230 .ne 2
232 \fBRETURN\fR
234 .RS 13n
235 Update the value of dot by the current value of \fItype\fR and \fIdisplay\fR
236 using the current value of \fIcount\fR.
240 .ne 2
242 \fB\fI#\fR\fR
244 .RS 13n
245 Update the value of dot by specifying a numeric expression. Specify numeric
246 expressions using addition, subtraction, mulitiplication, and division
247 operators ( \fB+\fR, \fB-\fR, \fB*\fR, and \fB%\fR). Numeric expressions are
248 evaluated from left to right and can use parentheses. After evaluation, the
249 value of dot is updated.
253 .ne 2
255 \fB, \fIcount\fR\fR
257 .RS 13n
258 Update the count indicator. The global value of \fIcount\fR is updated to
259 \fIcount\fR. The value of \fIcount\fR remains until a new command is run. A
260 \fIcount\fR specifier of \fB*\fR attempts to show a blocks's worth of
261 information. The default for \fIcount\fR is \fB1\fR.
265 .ne 2
267 \fB? \fI f\fR\fR
269 .RS 13n
270 Display in structured style with format specifier \fBf\fR. See \fBFormatted
271 Output\fR.
275 .ne 2
277 \fB/ \fIf\fR\fR
279 .RS 13n
280 Display in unstructured style with format specifier \fBf\fR. See \fBFormatted
281 Output\fR.
285 .ne 2
287 \fB\&.\fR
289 .RS 13n
290 Display the value of dot.
294 .ne 2
296 \fB+\fIe\fR\fR
298 .RS 13n
299 Increment the value of dot by the expression \fIe\fR. The amount actually
300 incremented is dependent on the size of type: \fBdot = dot + \fR\fIe \fR\fB*
301 \fR\fBsizeof\fR (\fItype\fR) The default for \fIe\fR is \fB1\fR.
305 .ne 2
307 \fB\(mi\fIe\fR\fR
309 .RS 13n
310 Decrement the value of dot by the expression \fIe \fR. See \fB+\fR.
314 .ne 2
316 \fB*\fIe\fR\fR
318 .RS 13n
319 Multiply the value of dot by the expression \fIe\fR. Multiplication and
320 division don't use \fItype\fR. In the above calculation of dot, consider the
321 \fBsizeof\fR (\fItype\fR) to be \fB1\fR.
325 .ne 2
327 \fB%\fIe\fR\fR
329 .RS 13n
330 Divide the value of dot by the expression \fIe\fR. See \fB*\fR.
334 .ne 2
336 \fB< \fIname\fR\fR
338 .RS 13n
339 Restore an address saved in register \fIname\fR. \fIname\fR must be a single
340 letter or digit.
344 .ne 2
346 \fB> \fIname\fR\fR
348 .RS 13n
349 Save an address in register \fIname\fR. \fIname\fR must be a single letter or
350 digit.
354 .ne 2
356 \fB= \fIf\fR\fR
358 .RS 13n
359 Display indicator. If \fIf\fR is a legitimate format specifier (see
360 \fBFormatted Output\fR), then the value of dot is displayed using format
361 specifier \fIf\fR. Otherwise, assignment is assumed. See \fB= [s] [e]\fR.
365 .ne 2
367 \fB= [\fIs\fR] [\fIe\fR]\fR
369 .RS 13n
370 Change the value of dot using an assignment indicator. The address pointed to
371 by dot has its contents changed to the value of the expression \fIe\fR or to
372 the \fBASCII\fR representation of the quoted (\fB"\fR) string \fIs\fR. This can
373 be useful for changing directory names or \fBASCII\fR file information.
377 .ne 2
379 \fB=+ \fIe\fR\fR
381 .RS 13n
382 Change the value of dot using an incremental assignment. The address pointed to
383 by dot has its contents incremented by expression \fIe\fR.
387 .ne 2
389 \fB=- e\fR
391 .RS 13n
392 Change the value of dot using a decremental assignment. Decrement the contents
393 of the address pointed to by dot by expression \fIe\fR.
396 .SS "Commands"
399 A command must be prefixed by a colon (\fB:\fR). Only enough letters of the
400 command to uniquely distinguish it are needed. Multiple commands can be entered
401 on one line by  separating them by a SPACE, TAB, or semicolon (\fB;\fR).
404 To view a potentially unmounted disk in a reasonable manner, \fBfsdb\fR
405 supports the \fBcd\fR, \fBpwd\fR, \fBls\fR, and \fBfind\fR commands. The
406 functionality of each of these commands basically matches that of its UNIX
407 counterpart. See \fBcd\fR(1), \fBpwd\fR(1), \fBls\fR(1), and \fBfind\fR(1) for
408 details. The \fB*\fR, \fB,\fR, \fB?\fR, and \fB-\fR wildcard characters are
409 also supported.
412 The following commands are supported:
414 .ne 2
416 \fBbase[=\fIb\fR]\fR
418 .sp .6
419 .RS 4n
420 Display or set the base. All input and output is governed by the current base.
421 Without the \fB=\fR \fIb\fR, displays the current base. Otherwise, sets the
422 current base to \fIb\fR. Base is interpreted using the old value of base, so to
423 ensure correctness use the \fB0\fR, \fB0t\fR, or \fB0x\fR prefix when changing
424 the base. The default for base is hexadecimal.
428 .ne 2
430 \fBblock\fR
432 .sp .6
433 .RS 4n
434 Convert the value of dot to a block address.
438 .ne 2
440 \fBcd [\fIdir\fR]\fR
442 .sp .6
443 .RS 4n
444 Change the current directory to directory  \fIdir\fR. The current values of
445 inode and dot are also updated. If \fBdir\fR is not specified, changes
446 directories to inode 2, root (\fB/\fR).
450 .ne 2
452 \fBdirectory\fR
454 .sp .6
455 .RS 4n
456 If the current inode is a directory, converts the value of dot to a directory
457 slot offset in that directory, and dot now points to this entry.
461 .ne 2
463 \fBfile\fR
465 .sp .6
466 .RS 4n
467 Set the value of dot as a relative block count from the beginning of the file.
468 The value of dot is updated to the first byte of  this block.
472 .ne 2
474 \fBfind \fIdir\fR [\fB-name\fR \fIn\fR] | [\fB-inum\fR\fI i\fR]\fR
476 .sp .6
477 .RS 4n
478 Find files by name or i-number. Recursively searches directory \fIdir\fR and
479 below for file names whose i-number matches\fB i\fR or whose name matches
480 pattern \fIn\fR. Only one of the two options (\fB-name\fR or \fB-inum\fR) can
481 be used at one time. The find \fB-print\fR is not necessary or accepted.
485 .ne 2
487 \fBfill=\fIp\fR\fR
489 .sp .6
490 .RS 4n
491 Fill an area of disk with pattern \fIp\fR. The area of disk is delimited by dot
492 and count.
496 .ne 2
498 \fBinode\fR
500 .sp .6
501 .RS 4n
502 Convert the value of dot to an inode address. If successful, the current value
503 of inode is updated as well as the value of dot. As a convenient shorthand, if
504 \fB:inode\fR appears at the beginning of the line, the value of dot is set to
505 the current inode and that inode is displayed in inode format.
509 .ne 2
511 \fBls [ \fB-R\fR ] [\fB-l\fR ] \fIpat1\fR \fIpat2\fR...\fR
513 .sp .6
514 .RS 4n
515 List directories or files. If no file is specified, the current directory is
516 assumed. Either or both of the options can be used (but, if used, must be
517 specified before the filename specifiers). Wild card characters are available
518 and multiple arguments are acceptable. The long listing shows only the i-number
519 and the name; use the inode command with \fB?i\fR to get more information.
523 .ne 2
525 \fBoverride\fR
527 .sp .6
528 .RS 4n
529 Toggle the value of override. Some error conditions might be overridden if
530 override is toggled to \fBon\fR.
534 .ne 2
536 \fBprompt "\fIp\fR"\fR
538 .sp .6
539 .RS 4n
540 Change the \fBfsdb\fR prompt to \fIp\fR. \fIp\fR must be enclosed in quotes.
544 .ne 2
546 \fBpwd\fR
548 .sp .6
549 .RS 4n
550 Display the current working directory.
554 .ne 2
556 \fBquit\fR
558 .sp .6
559 .RS 4n
560 Quit \fBfsdb\fR.
564 .ne 2
566 \fBtag\fR
568 .sp .6
569 .RS 4n
570 Convert the value of dot and if this is a valid tag, print the volume structure
571 according to the tag.
575 .ne 2
577 \fB!\fR
579 .sp .6
580 .RS 4n
581 Escape to the shell.
584 .SS "Inode Commands"
587 In addition to the above commands, several other commands deal with inode
588 fields and operate directly on the current inode (they still require the colon
589 (\fB:\fR). They can be used to more easily display or change the particular
590 fields. The value of dot is only used by the \fB:db\fR and \fB:ib\fR commands.
591 Upon completion of the command, the value of dot is changed so that it points
592 to that particular field. For example,
594 .in +2
596 > :ln=+1
598 .in -2
603 increments the link count of the current inode and sets the value of dot to the
604 address of the link count field.
607 The following inode commands are supported:
609 .ne 2
611 \fBat\fR
613 .RS 8n
614 Access time
618 .ne 2
620 \fBbs\fR
622 .RS 8n
623 Block size
627 .ne 2
629 \fBct\fR
631 .RS 8n
632 Creation time
636 .ne 2
638 \fBgid\fR
640 .RS 8n
641 Group id
645 .ne 2
647 \fBln\fR
649 .RS 8n
650 Link number
654 .ne 2
656 \fBmt\fR
658 .RS 8n
659 Modification time
663 .ne 2
665 \fBmd\fR
667 .RS 8n
668 Mode
672 .ne 2
674 \fBmaj\fR
676 .RS 8n
677 Major device number
681 .ne 2
683 \fBmin\fR
685 .RS 8n
686 Minor device number
690 .ne 2
692 \fBnm\fR
694 .RS 8n
695 This command actually operates on the directory name field. Once      poised at
696 the desired directory entry (using the \fBdirectory\fR command), this command
697 allows you to change or display the directory name. For example,
699 .in +2
701  > 7:dir:nm="foo"
703 .in -2
706 gets the \fB7\fRth directory entry of the current inode and changes its name to
707 \fBfoo\fR. Directory names cannot be made larger than the field allows. If an
708 attempt is made to make a directory name larger than the field allows,, the
709 string is truncated to fit and a warning message is displayed.
713 .ne 2
715 \fBsz\fR
717 .RS 8n
718 File size
722 .ne 2
724 \fBuid\fR
726 .RS 8n
727 User \fBID\fR
731 .ne 2
733 \fBuniq\fR
735 .RS 8n
736 Unique \fBID\fR
739 .SS "Formatted Output"
742 Formatted output comes in two styles and many format types. The two styles of
743 formatted output are: structured and unstructured. Structured output is used to
744 display inodes, directories, and so forth. Unstructured output displays raw
745 data.
748 Format specifiers are preceded by the slash (\fB/\fR) or question mark
749 (\fB?\fR) character. \fItype\fR is updated as necessary upon completion.
752 The following format specifiers are preceded by the \fB?\fR character:
754 .ne 2
756 \fBi\fR
758 .RS 5n
759 Display as inodes in the current base.
763 .ne 2
765 \fBd\fR
767 .RS 5n
768 Display as directories in the current base.
773 The following format specifiers are preceded by the \fB/\fR character:
775 .ne 2
777 \fBb\fR
779 .RS 9n
780 Display as bytes in the current base.
784 .ne 2
786 \fBc\fR
788 .RS 9n
789 Display as characters.
793 .ne 2
795 \fBo | O\fR
797 .RS 9n
798 Display as octal shorts or longs.
802 .ne 2
804 \fBd | D\fR
806 .RS 9n
807 Display as decimal shorts or longs.
811 .ne 2
813 \fBx | X\fR
815 .RS 9n
816 Display as hexadecimal shorts or longs.
819 .SH EXAMPLES
821 \fBExample 1 \fRUsing fsdb as a calculator for complex arithmetic
824 The following command displays \fB2010\fR in decimal format, and is an example
825 of using \fBfsdb\fR as a calculator for complex arithmetic.
828 .in +2
830 > 2000+400%(20+20)=D
832 .in -2
836 \fBExample 2 \fRUsing fsdb to display an i-number in idode fomat
839 The following command displays the i-number \fB386\fR in inode format.\fB386\fR
840 becomes the current inode.
843 .in +2
845 > 386:ino?i
847 .in -2
851 \fBExample 3 \fRUsing fsdb to change the link count
854 The following command changes the link count for the current inode to \fB4\fR.
857 .in +2
859 > :ln=4
861 .in -2
865 \fBExample 4 \fRUsing fsdb to increment the link count
868 The following command increments the link count by \fB1\fR.
871 .in +2
873 > :ln=+1
875 .in -2
879 \fBExample 5 \fRUsing fsdb to display the creation time as a hexadecimal long
882 The following command displays the creation time as a hexadecimal long.
885 .in +2
887 > :ct=X
889 .in -2
893 \fBExample 6 \fRUsing fsdb to display the modification time in time format
896 The following command displays the modification time in time format.
899 .in +2
901 > :mt=t
903 .in -2
907 \fBExample 7 \fRUsing fsdb to display in ASCII
910 The following command displays, in \fBASCII\fR, block \fB0\fR of the file
911 associated with the current inode.
914 .in +2
916 > 0:file/c
918 .in -2
922 \fBExample 8 \fRUsing fsdb to display the directory enteries for the root inode
925 The following command displays the first block's directory entries for the root
926 inode of this file system. This command stops prematurely if the \fBEOF\fR is
927 reached.
930 .in +2
932 > 2:ino,*?d
934 .in -2
938 \fBExample 9 \fRUsing fsdb to change the current inode
941  The following command changes the current inode to that associated with the
942 \fB5\fRth directory entry (numbered from \fB0\fR) of the current inode. The
943 first logical block of the file is then displayed in \fBASCII\fR.
946 .in +2
948 > 5:dir:inode; 0:file,*/c
950 .in -2
954 \fBExample 10 \fRUsing fsdb to change the i-number
957  The following command changes the i-number for the \fB7\fRth directory slot in
958 the root directory to \fB3\fR.
961 .in +2
963 > 2:inode; 7:dir=3
965 .in -2
969 \fBExample 11 \fRUsing fsdb to change the name field
972 The following command changes the \fIname\fR field in the directory slot to
973 \fBname\fR.
976 .in +2
978  > 7:dir:nm="name"
980 .in -2
984 \fBExample 12 \fRUsing fsdb to display the a block
987 The following command displays the \fB3\fRrd block of the current inode as
988 directory entries.
991 \fBExample 13 \fRUsing fsdb to set the contents of address
994 The following command sets the contents of address \fB2050\fR to
995 \fB0xffffffff\fR. \fB0xffffffff\fR can be truncated, depending on the current
996 type.
999 .in +2
1001 > 2050=0xffff
1003 .in -2
1007 \fBExample 14 \fRUsing fsdb to place an ASCII string at an address
1010 The following command places the \fBASCII\fR string \fBthis is some text\fR at
1011 address \fB1c92434\fR.
1014 .in +2
1016 > 1c92434="this is some text"
1018 .in -2
1021 .SH SEE ALSO
1024 \fBclri\fR(8), \fBfsck_udfs\fR(8), \fBdir\fR(4),  \fBattributes\fR(5)