1fsdb_ufs(1M)            System Administration Commands            fsdb_ufs(1M)
2
3
4

NAME

6       fsdb_ufs - ufs file system debugger
7

SYNOPSIS

9       fsdb -F ufs [generic_options] [specific_options] special
10
11

DESCRIPTION

13       The  fsdb_ufs  command is an interactive tool that can be used to patch
14       up a damaged UFS file system. It has conversions to translate block and
15       i-numbers  into  their  corresponding disk addresses. Also included are
16       mnemonic offsets to access different parts of an inode.  These  greatly
17       simplify  the process of correcting control block entries or descending
18       the file system tree.
19
20
21       fsdb contains several error-checking routines to verify inode and block
22       addresses. These can be disabled if necessary by invoking fsdb with the
23       -o option or by the use of the o command.
24
25
26       fsdb reads a block at a time and will therefore work with raw  as  well
27       as  block  I/O  devices.  A buffer management routine is used to retain
28       commonly used blocks of data in order to reduce the number of read sys‐
29       tem  calls.  All  assignment  operations  result in an immediate write-
30       through of the corresponding block. Note that in order  to  modify  any
31       portion of the disk, fsdb must be invoked with the w option.
32
33
34       Wherever  possible,  adb-like  syntax was adopted to promote the use of
35       fsdb through familiarity.
36

OPTIONS

38       The following option is supported:
39
40       -o    Specify UFS file system specific options. These  options  can  be
41             any  combination  of  the  following separated by commas (with no
42             intervening spaces). The options available are:
43
44             ?             Display usage
45
46
47             o             Override some error conditions
48
49
50             p='string'    set prompt to string
51
52
53             w             open for write
54
55
56

USAGE

58       Numbers are considered hexadecimal by default. However,  the  user  has
59       control  over how data is to be displayed or accepted. The base command
60       will display or set the input/output base. Once  set,  all  input  will
61       default  to  this  base  and all output will be shown in this base. The
62       base can be overridden temporarily for input by  preceding  hexadecimal
63       numbers  with  '0x', preceding decimal numbers with '0t', or octal num‐
64       bers with '0'. Hexadecimal numbers beginning with a-f or  A-F  must  be
65       preceded with '0x' to distinguish them from commands.
66
67
68       Disk addressing by fsdb is at the byte level. However, fsdb offers many
69       commands to convert a desired inode, directory entry, block, superblock
70       and  so  forth to a byte address. Once the address has been calculated,
71       fsdb will record the result in dot (.).
72
73
74       Several global values are maintained by fsdb:
75
76           o      the current base (referred to as base),
77
78           o      the current address (referred to as dot),
79
80           o      the current inode (referred to as inode),
81
82           o      the current count (referred to as count),
83
84           o      and the current type (referred to as type).
85
86
87       Most commands use the preset value of dot in their execution. For exam‐
88       ple,
89
90
91       > 2:inode
92
93
94       will  first  set  the value of dot to 2, ':', will alert the start of a
95       command, and the inode command will set inode to 2. A count  is  speci‐
96       fied after a ','. Once set, count will remain at this value until a new
97       command is encountered which will then reset the value back to  1  (the
98       default). So, if
99
100
101       > 2000,400/X
102
103
104       is  typed,  400 hex longs are listed from 2000, and when completed, the
105       value of dot will be 2000 + 400 * sizeof (long). If a  RETURN  is  then
106       typed,  the  output  routine will use the current values of dot, count,
107       and type and display 400 more hex longs. A '*' will  cause  the  entire
108       block to be displayed.
109
110
111       End of fragment, block and file are maintained by fsdb. When displaying
112       data as fragments or blocks, an error message will  be  displayed  when
113       the end of fragment or block is reached. When displaying data using the
114       db, ib, directory, or file commands an error message  is  displayed  if
115       the  end of file is reached. This is mainly needed to avoid passing the
116       end of a directory or file and getting unknown and unwanted results.
117
118
119       An example showing several commands and the use of  RETURN would be:
120
121         > 2:ino; 0:dir?d
122               or
123         > 2:ino; 0:db:block?d
124
125
126
127
128       The two examples are synonymous for  getting  to  the  first  directory
129       entry  of  the  root  of  the  file  system. Once there, any subsequent
130       RETURN (or +, -) will advance to subsequent entries. Note that
131
132         > 2:inode; :ls
133               or
134         > :ls /
135
136
137
138
139       is again synonymous.
140
141   Expressions
142       The symbols recognized by fsdb are:
143
144       RETURN       update the value of dot by the current value of  type  and
145                    display using the current value of count.
146
147
148       #            numeric  expressions  may  be  composed  of +, -, *, and %
149                    operators (evaluated left to right) and may use  parenthe‐
150                    ses. Once evaluated, the value of dot is updated.
151
152
153       , count      count indicator. The global value of count will be updated
154                    to count. The value of count will remain until a new  com‐
155                    mand is run. A count specifier of '*' will attempt to show
156                    a blocks's worth of information. The default for count  is
157                    1.
158
159
160       ? f          display  in  structured style with format specifier f. See
161                    FormattedOutput.
162
163
164       / f          display in unstructured style with format specifier f  See
165                    FormattedOutput.
166
167
168       .            the value of dot.
169
170
171       +e           increment the value of dot by the expression e. The amount
172                    actually incremented is dependent on the size of type:
173
174                    dot = dot + e * sizeof (type)
175
176                    The default for e is 1.
177
178
179       -e           decrement the value of dot by the expression e. See  +.
180
181
182       *e           multiply the value of dot by the expression e. Multiplica‐
183                    tion and division don't use type. In the above calculation
184                    of dot, consider the sizeof(type) to be 1.
185
186
187       %e           divide the value of dot by the expression e. See  *.
188
189
190       < name       restore an address saved in register name. name must be  a
191                    single letter or digit.
192
193
194       > name       save  an  address  in register name. name must be a single
195                    letter or digit.
196
197
198       = f          display indicator. If f is a legitimate format  specifier.
199                    then the value of dot is displayed using the format speci‐
200                    fier f.  See  FormattedOutput.  Otherwise,  assignment  is
201                    assumed See  =.
202
203
204       = [s] [e]    assignment  indicator.  The  address pointed to by dot has
205                    its contents changed to the value of the expression  e  or
206                    to  the  ASCII  representation of the quoted (") string s.
207                    This may be useful for changing directory names  or  ASCII
208                    file information.
209
210
211       =+ e         incremental  assignment. The address pointed to by dot has
212                    its contents incremented by expression e.
213
214
215       =- e         decremental assignment. The address pointed to by dot  has
216                    its contents decremented by expression e.
217
218
219   Commands
220       A  command  must be prefixed by a ':' character. Only enough letters of
221       the command to uniquely distinguish it are  needed.  Multiple  commands
222       may be entered on one line by separating them by a  SPACE, TAB or ';'.
223
224
225       In  order  to view a potentially unmounted disk in a reasonable manner,
226       fsdb offers the cd, pwd, ls and find  commands.  The  functionality  of
227       these  commands  substantially  matches those of its UNIX counterparts.
228       See individual commands for details. The '*', '?', and '[-]' wild  card
229       characters are available.
230
231       base=b
232
233           display  or set base. As stated above, all input and output is gov‐
234           erned by the current base. If the  =b is omitted, the current  base
235           is  displayed.  Otherwise,  the current base is set to b. Note that
236           this is interpreted using the old value of base, so to ensure  cor‐
237           rectness  use the '0', '0t', or '0x' prefix when changing the base.
238           The default for base is hexadecimal.
239
240
241       block
242
243           convert the value of dot to a block address.
244
245
246       cd dir
247
248           change the current directory to directory dir. The  current  values
249           of  inode  and  dot  are also updated. If no dir is specified, then
250           change directories to inode 2 ("/").
251
252
253       cg
254
255           convert the value of dot to a cylinder group.
256
257
258       directory
259
260           If the current inode is a directory, then the value of dot is  con‐
261           verted  to  a  directory  slot offset in that directory and dot now
262           points to this entry.
263
264
265       file
266
267           the value of dot is taken as a relative block count from the begin‐
268           ning  of the file. The value of dot is updated to the first byte of
269           this block.
270
271
272       find dir [ -name n] [-inum i]
273
274           find files by name or i-number. find recursively searches directory
275           dir  and below for filenames whose i-number matches i or whose name
276           matches pattern n. Note that only one of the two options (-name  or
277           -inum)  may  be used at one time. Also, the -print is not needed or
278           accepted.
279
280
281       fill=p
282
283           fill an area of disk with pattern p. The area of disk is  delimited
284           by dot and count.
285
286
287       fragment
288
289           convert the value of dot to a fragment address. The only difference
290           between the fragment command and the block command  is  the  amount
291           that is able to be displayed.
292
293
294       inode
295
296           convert  the  value  of dot to an inode address. If successful, the
297           current value of inode will be updated as well as the value of dot.
298           As  a convenient shorthand, if ':inode' appears at the beginning of
299           the line, the value of dot is set to the  current  inode  and  that
300           inode is displayed in inode format.
301
302
303       log_chk
304
305           run  through the valid log entries without printing any information
306           and verify the layout.
307
308
309       log_delta
310
311           count the number of deltas into the log, using the value of dot  as
312           an  offset into the log. No checking is done to make sure that off‐
313           set is within the head/tail offsets.
314
315
316       log_head
317
318           display the header information about the file system logging.  This
319           shows  the  block allocation for the log and the data structures on
320           the disk.
321
322
323       log_otodb
324
325           return the physical disk block number, using the value of dot as an
326           offset into the log.
327
328
329       log_show
330
331           display  all deltas between  the beginning of the log (BOL) and the
332           end of the log (EOL).
333
334
335       ls
336
337           [ -R ] [ -l ] pat1 pat2... list directories or files. If no file is
338           specified,  the current directory is assumed. Either or both of the
339           options may be used (but, if used, must  be  specified  before  the
340           filename  specifiers).  Also, as stated above, wild card characters
341           are available and multiple arguments may be given. The long listing
342           shows  only  the  i-number and the name; use the inode command with
343           '?i' to get more information.
344
345
346       override
347
348           toggle the value of override. Some error conditions may be  overri‐
349           den if override is toggled on.
350
351
352       prompt p
353
354           change the fsdb prompt to p. p must be surrounded by (")s.
355
356
357       pwd
358
359           display the current working directory.
360
361
362       quit
363
364           quit fsdb.
365
366
367       sb
368
369           the  value of dot is taken as a cylinder group number and then con‐
370           verted to the address of the superblock in that cylinder group.  As
371           a shorthand, ':sb' at the beginning of a line will set the value of
372           dot to the superblock and display it in superblock format.
373
374
375       shadow
376
377           if the current inode is a shadow inode, then the value  of  dot  is
378           set to the beginning of the shadow inode data.
379
380
381       !
382
383           escape to shell
384
385
386   Inode Commands
387       In addition to the above commands, there are several commands that deal
388       with inode fields and operate directly on the current inode (they still
389       require the ':'). They may be used to more easily display or change the
390       particular fields. The value of dot is only used by the ':db' and ':ib'
391       commands.  Upon  completion of the command, the value of dot is changed
392       to point to that particular field. For example,
393
394
395       > :ln=+1
396
397
398       would increment the link count of the current inode and set  the  value
399       of dot to the address of the link count field.
400
401       at     access time.
402
403
404       bs     block size.
405
406
407       ct     creation time.
408
409
410       db     use  the  current  value  of  dot as a direct block index, where
411              direct blocks number from 0 - 11. In order to display the  block
412              itself,  you  need to 'pipe' this result into the block or frag‐
413              ment command. For example,
414
415                     > 1:db:block,20/X
416
417
418              would get the contents of data block field 1 from the inode  and
419              convert  it  to  a block address. 20 longs are then displayed in
420              hexadecimal. See FormattedOutput.
421
422
423       gid    group id.
424
425
426       ib     use the current value of dot as an indirect  block  index  where
427              indirect  blocks number from 0 - 2. This will only get the indi‐
428              rect block itself (the block  containing  the  pointers  to  the
429              actual  blocks).  Use  the file command and start at block 12 to
430              get to the actual blocks.
431
432
433       ln     link count.
434
435
436       mt     modification time.
437
438
439       md     mode.
440
441
442       maj    major device number.
443
444
445       min    minor device number.
446
447
448       nm     although listed here, this  command  actually  operates  on  the
449              directory name field. Once poised at the desired directory entry
450              (using the directory command), this command will  allow  you  to
451              change or display the directory name. For example,
452
453              > 7:dir:nm="foo"
454
455              will get the 7th directory entry of the current inode and change
456              its name to foo. Note that names cannot be made larger than  the
457              field  is set up for. If an attempt is made, the string is trun‐
458              cated to fit and a warning message to this effect is displayed.
459
460
461       si     shadow inode.
462
463
464       sz     file size.
465
466
467       uid    user id.
468
469
470   Formatted Output
471       There are two styles and many format types. The two styles  are  struc‐
472       tured  and  unstructured.  Structured output is used to display inodes,
473       directories, superblocks and the like. Unstructured displays raw  data.
474       The following shows the different ways of displaying:
475
476       ?
477            c    display as cylinder groups
478
479
480            i    display as inodes
481
482
483            d    display as directories
484
485
486            s    display as superblocks
487
488
489            S    display as shadow inode data
490
491
492
493       /
494            b      display as bytes
495
496
497            c      display as characters
498
499
500            o O    display as octal shorts or longs
501
502
503            d D    display as decimal shorts or longs
504
505
506            x X    display as hexadecimal shorts or longs
507
508            The format specifier immediately follows the '/' or '?' character.
509            The values displayed by '/b' and all '?' formats are displayed  in
510            the current base. Also, type is appropriately updated upon comple‐
511            tion.
512
513

EXAMPLES

515       Example 1 Displaying in Decimal
516
517
518       The following command displays 2010 in decimal (use of fsdb as a calcu‐
519       lator for complex arithmetic):
520
521
522         > 2000+400%(20+20)=D
523
524
525
526       Example 2 Displaying an i-number in Inode Format
527
528
529       The  following  command  displays i-number 386 in an inode format. This
530       now becomes the current inode:
531
532
533         > 386:ino?i
534
535
536
537       Example 3 Changing the Link Count
538
539
540       The following command changes the link count for the current  inode  to
541       4:
542
543
544         > :ln=4
545
546
547
548       Example 4 Incrementing the Link Count
549
550
551       The following command increments the link count by 1:
552
553
554         > :ln=+1
555
556
557
558       Example 5 Displaying the Creation Time
559
560
561       The following command displays the creation time as a hexadecimal long:
562
563
564         > :ct=X
565
566
567
568       Example 6 Displaying the Modification Time
569
570
571       The following command displays the modification time in time format:
572
573
574         > :mt=t
575
576
577
578       Example 7 Displaying in ASCII
579
580
581       The following command displays in ASCII, block zero of the file associ‐
582       ated with the current inode:
583
584
585         > 0:file/c
586
587
588
589       Example 8 Displaying the First Block's Worth of Directorty Entries
590
591
592       The following command displays the first  block's  worth  of  directory
593       entries  for  the  root  inode of this file system. It will stop prema‐
594       turely if the EOF is reached:
595
596
597         > 2:ino,*?d
598
599
600
601       Example 9 Displaying Changes to the Current Inode
602
603
604       The following command displays changes the current inode to that  asso‐
605       ciated with the 5th directory entry (numbered from zero) of the current
606       inode. The first logical block of the file is then displayed in ASCII:
607
608
609         > 5:dir:inode; 0:file,*/c
610
611
612
613       Example 10 Displaying the Superblock
614
615
616       The following command displays the superblock of this file system:
617
618
619         > :sb
620
621
622
623       Example 11 Displaying the Cylinder Group
624
625
626       The following command displays cylinder group information  and  summary
627       for cylinder group 1:
628
629
630         > 1:cg?c
631
632
633
634       Example 12 Changing the i-number
635
636
637       The  following  command  changes the i-number for the seventh directory
638       slot in the root directory to 3:
639
640
641         > 2:inode; 7:dir=3
642
643
644
645       Example 13 Displaying as Directory Entries
646
647
648       The following command displays the third block of the current inode  as
649       directory entries:
650
651
652         > 2:db:block,*?d
653
654
655
656       Example 14 Changing the Name Field
657
658
659       The  following  command changes the name field in the directory slot to
660       name:
661
662
663         > 7:dir:nm="name"
664
665
666
667       Example 15 Getting and Filling Elements
668
669
670       The following command gets fragment 3c3 and fill 20 type elements  with
671       0x20:
672
673
674         > 3c3:fragment,20:fill=0x20
675
676
677
678       Example 16 Setting the Contents of an Address
679
680
681       The  following command sets the contents of address 2050 to 0xffffffff.
682       0xffffffff may be truncated depending on the current type:
683
684
685         > 2050=0xffff
686
687
688
689       Example 17 Placing ASCII
690
691
692       The following command places the ASCII for the string at 1c92434:
693
694
695         > 1c92434="this is some text"
696
697
698
699       Example 18 Displaying Shadow Inode Data
700
701
702       The following command displays all of the  shadow  inode  data  in  the
703       shadow inode associated with the root inode of this file system:
704
705
706         > 2:ino:si:ino;0:shadow,*?S
707
708
709

ATTRIBUTES

711       See attributes(5) for descriptions of the following attributes:
712
713
714
715
716       ┌─────────────────────────────┬─────────────────────────────┐
717       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
718       ├─────────────────────────────┼─────────────────────────────┤
719       │Availability                 │SUNWcsu                      │
720       └─────────────────────────────┴─────────────────────────────┘
721

SEE ALSO

723       clri(1M), fsck_ufs(1M), dir_ufs(4), attributes(5), ufs(7FS)
724

WARNINGS

726       Since  fsdb reads the disk raw, extreme caution is advised in determin‐
727       ing its availability of fsdb on the system. Suggested  permissions  are
728       600 and owned by bin.
729

NOTES

731       The old command line syntax for clearing i-nodes using the ufs-specific
732       '-z i-number' option is still supported by the new debugger, though  it
733       is  obsolete  and will be removed in a future release. Use of this flag
734       will result in correct operation, but an error message will be  printed
735       warning of the impending obsolesence of this option to the command. The
736       equivalent functionality is available using the more flexible  clri(1M)
737       command.
738
739
740
741SunOS 5.11                        14 Apr 2003                     fsdb_ufs(1M)
Impressum