1 FSDB_UDFS(1M)                Maintenance Commands                FSDB_UDFS(1M)
   2 
   3 
   4 
   5 NAME
   6        fsdb_udfs - udfs file system debugger
   7 
   8 SYNOPSIS
   9        fsdb  [-F] udfs [generic_option] [-o specific_option] special
  10 
  11 
  12 DESCRIPTION
  13        The fsdb_udfs command is an interactive tool that can be used to patch
  14        up a damaged udfs file system. fsdb_udfs has conversions to translate
  15        block and i-numbers into their corresponding disk addresses. Mnemonic
  16        offsets to access different parts of an inode are also included.
  17        Mnemonic offsets greatly simplify the process of correcting control
  18        block entries or descending 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 using the o command.
  24 
  25 
  26        fsdb reads one block at a time, and therefore works with raw as well as
  27        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
  29        system calls. All assignment operations result in an immediate write-
  30        through of the corresponding block. In order to modify any portion of
  31        the disk, fsdb must be invoked with the -w option.
  32 
  33 
  34        Wherever possible, adb-like syntax has been adopted to promote the use
  35        of fsdb through familiarity.
  36 
  37 OPTIONS
  38        The following options are supported:
  39 
  40        -o specific_option
  41                              Specify udfs file system specific options in a
  42                              comma-separated list with no intervening spaces.
  43                              The following specific options are supported:
  44 
  45                              o
  46                                          Override some error conditions.
  47 
  48 
  49                              p=string
  50                                          Set prompt to string.
  51 
  52 
  53                              w
  54                                          Open for write.
  55 
  56 
  57                              ?
  58                                          Display usage.
  59 
  60 
  61 
  62 USAGE
  63        Numbers are considered hexadecimal by default. The user has control
  64        over how data is to be displayed or accepted. The base command displays
  65        or sets the input and output base. Once set, all input defaults to this
  66        base and all output displays in this base. The base can be overridden
  67        temporarily for input by preceding hexadecimal numbers by 0x, preceding
  68        decimal numbers with a 0t, or octal numbers with a 0. Hexadecimal
  69        numbers beginning with a-f or A-F must be preceded with a 0x to
  70        distinguish them from commands.
  71 
  72 
  73        Disk addressing by fsdb is at the byte level. However, fsdb offers many
  74        commands to convert a desired inode, directory entry, block, and so
  75        forth, to a byte address. After the address has been calculated, fsdb
  76        records the result in the current address (dot).
  77 
  78 
  79        Several global values are maintained by fsdb:
  80 
  81            o      Current base (referred to as base)
  82 
  83            o      Current address (referred to as dot)
  84 
  85            o      Current inode (referred to as inode)
  86 
  87            o      Current count (referred to as count)
  88 
  89            o      Current type (referred to as type)
  90 
  91 
  92        Most commands use the preset value of dot in their execution. For
  93        example,
  94 
  95           > 2:inode
  96 
  97 
  98 
  99 
 100        first sets the value of dot (.) to 2, colon (:), signifies the start of
 101        a command, and the inode command sets inode to 2. A count is specified
 102        after a comma (,). Once set, count remains at this value until a new
 103        command is encountered that resets the value back to 1 (the default).
 104 
 105 
 106        So, if
 107 
 108          > 2000,400/X
 109 
 110 
 111 
 112 
 113        is entered, 400 hex longs are listed from 2000, and when completed, the
 114        value of dot is  2000 + 400 * sizeof (long). If a RETURN is then
 115        entered, the output routine uses the current values of dot, count, and
 116        type and displays 400 more hex longs. An asterisk (*) causes the entire
 117        block to be displayed. An example showing several commands and the use
 118        of RETURN would be:
 119 
 120          > 2:ino; 0:dir?d
 121 
 122 
 123 
 124 
 125        or
 126 
 127          > 2:ino; 0:db:block?d
 128 
 129 
 130 
 131 
 132        The two examples are synonymous for getting to the first directory
 133        entry of the root of the file system. Once there, subsequently entering
 134        a RETURN, plus (+), or minus (-)  advances to subsequent entries.
 135        Notice that
 136 
 137          > 2:inode; :ls
 138 
 139 
 140 
 141 
 142        or
 143 
 144          > :ls /
 145 
 146 
 147 
 148 
 149        is again synonymous.
 150 
 151    Expressions
 152        The following symbols are recognized by fsdb:
 153 
 154        RETURN
 155                     Update the value of dot by the current value of type and
 156                     display using the current value of count.
 157 
 158 
 159        #
 160                     Update the value of dot by specifying a numeric
 161                     expression. Specify numeric expressions using addition,
 162                     subtraction, multiplication, and division operators ( +,
 163                     -, *, and %). Numeric expressions are evaluated from left
 164                     to right and can use parentheses. After evaluation, the
 165                     value of dot is updated.
 166 
 167 
 168        , count
 169                     Update the count indicator. The global value of count is
 170                     updated to count. The value of count remains until a new
 171                     command is run. A count specifier of * attempts to show a
 172                     blocks's worth of information. The default for count is 1.
 173 
 174 
 175        ?  f
 176                     Display in structured style with format specifier f. See
 177                     Formatted Output.
 178 
 179 
 180        / f
 181                     Display in unstructured style with format specifier f. See
 182                     Formatted Output.
 183 
 184 
 185        .
 186                     Display the value of dot.
 187 
 188 
 189        +e
 190                     Increment the value of dot by the expression e. The amount
 191                     actually incremented is dependent on the size of type: dot
 192                     = dot + e * sizeof (type) The default for e is 1.
 193 
 194 
 195        -e
 196                     Decrement the value of dot by the expression e . See +.
 197 
 198 
 199        *e
 200                     Multiply the value of dot by the expression e.
 201                     Multiplication and division don't use type. In the above
 202                     calculation of dot, consider the sizeof (type) to be 1.
 203 
 204 
 205        %e
 206                     Divide the value of dot by the expression e. See *.
 207 
 208 
 209        < name
 210                     Restore an address saved in register name. name must be a
 211                     single letter or digit.
 212 
 213 
 214        > name
 215                     Save an address in register name. name must be a single
 216                     letter or digit.
 217 
 218 
 219        = f
 220                     Display indicator. If f is a legitimate format specifier
 221                     (see Formatted Output), then the value of dot is displayed
 222                     using format specifier f. Otherwise, assignment is
 223                     assumed. See = [s] [e].
 224 
 225 
 226        = [s] [e]
 227                     Change the value of dot using an assignment indicator. The
 228                     address pointed to by dot has its contents changed to the
 229                     value of the expression e or to the ASCII representation
 230                     of the quoted (") string s. This can be useful for
 231                     changing directory names or ASCII file information.
 232 
 233 
 234        =+ e
 235                     Change the value of dot using an incremental assignment.
 236                     The address pointed to by dot has its contents incremented
 237                     by expression e.
 238 
 239 
 240        =- e
 241                     Change the value of dot using a decremental assignment.
 242                     Decrement the contents of the address pointed to by dot by
 243                     expression e.
 244 
 245 
 246    Commands
 247        A command must be prefixed by a colon (:). Only enough letters of the
 248        command to uniquely distinguish it are needed. Multiple commands can be
 249        entered on one line by  separating them by a SPACE, TAB, or semicolon
 250        (;).
 251 
 252 
 253        To view a potentially unmounted disk in a reasonable manner, fsdb
 254        supports the cd, pwd, ls, and find commands. The functionality of each
 255        of these commands basically matches that of its UNIX counterpart. See
 256        cd(1), pwd(1), ls(1), and find(1) for details. The *, ,, ?, and -
 257        wildcard characters are also supported.
 258 
 259 
 260        The following commands are supported:
 261 
 262        base[=b]
 263 
 264            Display or set the base. All input and output is governed by the
 265            current base.  Without the = b, displays the current base.
 266            Otherwise, sets the current base to b. Base is interpreted using
 267            the old value of base, so to ensure correctness use the 0, 0t, or
 268            0x prefix when changing the base. The default for base is
 269            hexadecimal.
 270 
 271 
 272        block
 273 
 274            Convert the value of dot to a block address.
 275 
 276 
 277        cd [dir]
 278 
 279            Change the current directory to directory  dir. The current values
 280            of inode and dot are also updated. If dir is not specified, changes
 281            directories to inode 2, root (/).
 282 
 283 
 284        directory
 285 
 286            If the current inode is a directory, converts the value of dot to a
 287            directory slot offset in that directory, and dot now points to this
 288            entry.
 289 
 290 
 291        file
 292 
 293            Set the value of dot as a relative block count from the beginning
 294            of the file.  The value of dot is updated to the first byte of
 295            this block.
 296 
 297 
 298        find dir [-name n] | [-inum i]
 299 
 300            Find files by name or i-number. Recursively searches directory dir
 301            and below for file names whose i-number matches i or whose name
 302            matches pattern n. Only one of the two options (-name or -inum) can
 303            be used at one time. The find -print is not necessary or accepted.
 304 
 305 
 306        fill=p
 307 
 308            Fill an area of disk with pattern p. The area of disk is delimited
 309            by dot and count.
 310 
 311 
 312        inode
 313 
 314            Convert the value of dot to an inode address. If successful, the
 315            current value of inode is updated as well as the value of dot. As a
 316            convenient shorthand, if :inode appears at the beginning of the
 317            line, the value of dot is set to the current inode and that inode
 318            is displayed in inode format.
 319 
 320 
 321        ls [ -R ] [-l ] pat1 pat2...
 322 
 323            List directories or files. If no file is specified, the current
 324            directory is assumed. Either or both of the options can be used
 325            (but, if used, must be specified before the filename specifiers).
 326            Wild card characters are available and multiple arguments are
 327            acceptable. The long listing shows only the i-number and the name;
 328            use the inode command with ?i to get more information.
 329 
 330 
 331        override
 332 
 333            Toggle the value of override. Some error conditions might be
 334            overridden if override is toggled to on.
 335 
 336 
 337        prompt "p"
 338 
 339            Change the fsdb prompt to p. p must be enclosed in quotes.
 340 
 341 
 342        pwd
 343 
 344            Display the current working directory.
 345 
 346 
 347        quit
 348 
 349            Quit fsdb.
 350 
 351 
 352        tag
 353 
 354            Convert the value of dot and if this is a valid tag, print the
 355            volume structure according to the tag.
 356 
 357 
 358        !
 359 
 360            Escape to the shell.
 361 
 362 
 363    Inode Commands
 364        In addition to the above commands, several other commands deal with
 365        inode fields and operate directly on the current inode (they still
 366        require the colon (:). They can be used to more easily display or
 367        change the particular fields. The value of dot is only used by the :db
 368        and :ib commands.  Upon completion of the command, the value of dot is
 369        changed so that it points to that particular field. For example,
 370 
 371          > :ln=+1
 372 
 373 
 374 
 375 
 376        increments the link count of the current inode and sets the value of
 377        dot to the address of the link count field.
 378 
 379 
 380        The following inode commands are supported:
 381 
 382        at
 383                Access time
 384 
 385 
 386        bs
 387                Block size
 388 
 389 
 390        ct
 391                Creation time
 392 
 393 
 394        gid
 395                Group id
 396 
 397 
 398        ln
 399                Link number
 400 
 401 
 402        mt
 403                Modification time
 404 
 405 
 406        md
 407                Mode
 408 
 409 
 410        maj
 411                Major device number
 412 
 413 
 414        min
 415                Minor device number
 416 
 417 
 418        nm
 419                This command actually operates on the directory name field.
 420                Once      poised at the desired directory entry (using the
 421                directory command), this command allows you to change or
 422                display the directory name. For example,
 423 
 424                   > 7:dir:nm="foo"
 425 
 426 
 427                gets the 7th directory entry of the current inode and changes
 428                its name to foo. Directory names cannot be made larger than the
 429                field allows. If an attempt is made to make a directory name
 430                larger than the field allows,, the string is truncated to fit
 431                and a warning message is displayed.
 432 
 433 
 434        sz
 435                File size
 436 
 437 
 438        uid
 439                User ID
 440 
 441 
 442        uniq
 443                Unique ID
 444 
 445 
 446    Formatted Output
 447        Formatted output comes in two styles and many format types. The two
 448        styles of formatted output are: structured and unstructured. Structured
 449        output is used to display inodes, directories, and so forth.
 450        Unstructured output displays raw data.
 451 
 452 
 453        Format specifiers are preceded by the slash (/) or question mark (?)
 454        character. type is updated as necessary upon completion.
 455 
 456 
 457        The following format specifiers are preceded by the ? character:
 458 
 459        i
 460             Display as inodes in the current base.
 461 
 462 
 463        d
 464             Display as directories in the current base.
 465 
 466 
 467 
 468        The following format specifiers are preceded by the / character:
 469 
 470        b
 471                 Display as bytes in the current base.
 472 
 473 
 474        c
 475                 Display as characters.
 476 
 477 
 478        o | O
 479                 Display as octal shorts or longs.
 480 
 481 
 482        d | D
 483                 Display as decimal shorts or longs.
 484 
 485 
 486        x | X
 487                 Display as hexadecimal shorts or longs.
 488 
 489 
 490 EXAMPLES
 491        Example 1 Using fsdb as a calculator for complex arithmetic
 492 
 493 
 494        The following command displays 2010 in decimal format, and is an
 495        example of using fsdb as a calculator for complex arithmetic.
 496 
 497 
 498          > 2000+400%(20+20)=D
 499 
 500 
 501 
 502        Example 2 Using fsdb to display an i-number in inode fomat
 503 
 504 
 505        The following command displays the i-number 386 in inode format.386
 506        becomes the current inode.
 507 
 508 
 509          > 386:ino?i
 510 
 511 
 512 
 513        Example 3 Using fsdb to change the link count
 514 
 515 
 516        The following command changes the link count for the current inode to
 517        4.
 518 
 519 
 520          > :ln=4
 521 
 522 
 523 
 524        Example 4 Using fsdb to increment the link count
 525 
 526 
 527        The following command increments the link count by 1.
 528 
 529 
 530          > :ln=+1
 531 
 532 
 533 
 534        Example 5 Using fsdb to display the creation time as a hexadecimal long
 535 
 536 
 537        The following command displays the creation time as a hexadecimal long.
 538 
 539 
 540          > :ct=X
 541 
 542 
 543 
 544        Example 6 Using fsdb to display the modification time in time format
 545 
 546 
 547        The following command displays the modification time in time format.
 548 
 549 
 550          > :mt=t
 551 
 552 
 553 
 554        Example 7 Using fsdb to display in ASCII
 555 
 556 
 557        The following command displays, in ASCII, block 0 of the file
 558        associated with the current inode.
 559 
 560 
 561          > 0:file/c
 562 
 563 
 564 
 565        Example 8 Using fsdb to display the directory enteries for the root
 566        inode
 567 
 568 
 569        The following command displays the first block's directory entries for
 570        the root inode of this file system. This command stops prematurely if
 571        the EOF is reached.
 572 
 573 
 574          > 2:ino,*?d
 575 
 576 
 577 
 578        Example 9 Using fsdb to change the current inode
 579 
 580 
 581         The following command changes the current inode to that associated
 582        with the 5th directory entry (numbered from 0) of the current inode.
 583        The first logical block of the file is then displayed in ASCII.
 584 
 585 
 586          > 5:dir:inode;      0:file,*/c
 587 
 588 
 589 
 590        Example 10 Using fsdb to change the i-number
 591 
 592 
 593         The following command changes the i-number for the 7th directory slot
 594        in the root directory to 3.
 595 
 596 
 597          > 2:inode; 7:dir=3
 598 
 599 
 600 
 601        Example 11 Using fsdb to change the name field
 602 
 603 
 604        The following command changes the name field in the directory slot to
 605        name.
 606 
 607 
 608           > 7:dir:nm="name"
 609 
 610 
 611 
 612        Example 12 Using fsdb to display the a block
 613 
 614 
 615        The following command displays the 3rd block of the current inode as
 616        directory entries.
 617 
 618 
 619        Example 13 Using fsdb to set the contents of address
 620 
 621 
 622        The following command sets the contents of address 2050 to 0xffffffff.
 623        0xffffffff can be truncated, depending on the current type.
 624 
 625 
 626          > 2050=0xffff
 627 
 628 
 629 
 630        Example 14 Using fsdb to place an ASCII string at an address
 631 
 632 
 633        The following command places the ASCII string this is some text at
 634        address 1c92434.
 635 
 636 
 637          > 1c92434="this is some text"
 638 
 639 
 640 
 641 SEE ALSO
 642        clri(1M), fsck_udfs(1M), dir(4),  attributes(5)
 643 
 644 
 645 
 646                                November 26, 2017                 FSDB_UDFS(1M)