e2fsprogs

repository·master·Indexed 19 days ago

https://github.com/tytso/e2fsprogs

A suite of filesystem management programs for extended filesystems (ext2, ext3, ext4). Includes resize2fs for expanding or shrinking filesystems, the uuidd daemon for UUID generation, and ext2ed, a terminal-based ncurses editor used to selectively corrupt or modify filesystems for test case generation.

Tokens
2.4K
Snippets
7
Records
15
Agent score
67%

What's inside tytso-e2fsprogs

  1. Overview of e2fsprogs

    master
    e2fsprogs is a suite of filesystem management programs for the extended filesystem (ext2, ext3, ext4). It provides utilities for creating, managing, and checking filesystems to ensure they are robust and error-free.
  2. How command dispatching and overriding works in ext2ed

    master

    The ext2ed editor uses a hierarchical command dispatch system. When you enter a command, the dispatch() function searches for a matching handler using a specific priority order. This allows the editor to provide context-sensitive commands that override general ones.

    Dispatch Priority (Highest to Lowest):

    1. Type-specific commands: Commands associated with the current_type (the specific filesystem object currently being inspected, e.g., an inode or a block group). These always take precedence.
    2. Ext2-specific commands: Commands available when an ext2 filesystem is actively being edited.
    3. General commands: Commands that are always available regardless of the current context.

    If a command is found in a higher-priority tier, the lower-tier command with the same name is ignored. If no match is found in any tier, an Error: Unknown command message is displayed.

  3. Run ext2ed with write privileges and a specific device

    master

    You can launch the ext2ed editor and immediately target a specific filesystem device. If you provide the -w flag, the editor will enable write privileges (calling enable_write) upon startup. If a device path is provided as a positional argument, the editor will automatically execute the set_device command for that path.

    Command Syntax:

    # Open a device in read-only mode
    ext2ed /dev/sdb1
    
    # Open a device with write privileges enabled
    ext2ed -w /dev/sdb1
    ext2ed -w /dev/sdb1
  4. Regenerate lib/ext2fs/utf8data.h using Unicode Character Database (UCD) files

    master

    The files in util/ucd/ are part of the Unicode Character Database (UCD) for Unicode version 11.0.0. These files are not distributed with the full e2fsprogs package because of their size. They are only required when performing a Unicode version update to regenerate the lib/ext2fs/utf8data.h header file.

    To regenerate the header, you must obtain the full set of UCD files from the official Unicode website or the Linux kernel source tree and place them in the appropriate directory. The files in this repository are renamed with a suffix indicating the Unicode version (e.g., UnicodeData-11.0.0.txt).

  5. Configure ext2ed for ncurses

    master

    ext2ed relies on the ncurses library for terminal output. Ensure your environment is configured correctly to avoid display issues:

    • Old ncurses versions: If using ncurses around version 1.8.5, you must enable the OLD_NCURSES compile-time option in the Makefile. For versions 1.9.2c and newer, do not use this flag.
    • Terminfo Database: Ensure the ncurses terminfo database is accessible. If you see references to /etc/termcap on startup, the terminfo database is not being found correctly.
    • Linux Console: If running in a Linux console, set your TERM environment variable to linux.
    • Custom Terminfo Path: If using the precompiled binary (linked with ncurses 1.9.4) and your terminfo database is not in /usr/local/lib/terminfo, use the TERMINFO environment variable to specify the correct path.
  6. Install ext2ed

    master

    To install ext2ed, you must have the kernel sources, readline, and ncurses packages installed on your system.

    1. Compile the program using make.
    2. Install the program using make install.

    Note: If you are using an older version of ncurses or if gcc cannot locate specific header files or libraries, you may need to manually edit the Makefile before compiling.

    make
    make install
  7. Run and use ext2ed

    master

    Follow these guidelines when using ext2ed:

    • Configuration: Edit /var/lib/ext2ed/ext2ed.conf to configure the tool before running it. Options include AllowMountedRead and ForceExt2.
    • Opening a Filesystem: Use the setdevice command to open a specific ext2 filesystem.
    • Write Access: Filesystems are opened in read-only mode by default. Use the enablewrite command to enable write access. Use caution when performing write operations.
    • Mounted Filesystems: Do not use ext2ed to change a mounted filesystem. While you can use AllowMountedRead on in the configuration to view a mounted filesystem in read-only mode, the displayed data may be unreliable.

    Critical Limitations:

    • ext2ed cannot handle filesystems larger than 2 GB.
    • It assumes an Intel (little-endian) byte order.
    # Example: Opening a device within the ext2ed interface
    setdevice /dev/hda1
  8. Build and install e2fsprogs

    master
    To build and install e2fsprogs from source, refer to the INSTALL file included in the repository. The project provides specific provisions for building Red Hat RPMs and Debian dpkg packages.
  9. ext2ed configuration options

    master

    The following configuration options are available in /var/lib/ext2ed/ext2ed.conf:

    • AllowMountedRead <on|off>: Allows the tool to open a filesystem that is currently mounted in read-only mode. Note that data displayed may be unreliable.
    • ForceExt2 <on|off>: Forces ext2ed to treat the device as an ext2 filesystem if autodetect fails.
  10. Reference: ext2ed Global Configuration Variables

    master

    The following global variables control the behavior of the ext2ed editor. These are typically initialized by init.c based on a user configuration file but have logical defaults:

    VariableDefault ValueDescription
    Ext2Descriptors"ext2.descriptors"Location of the ext2 filesystem object definition
    AlternateDescriptors""Path to additional user-defined structures
    LogFile"ext2ed.log"Location where each write operation is logged
    LogChanges1Enables (1) or disables (0) logging
    AllowChanges0If set (1), the enable_write command will fail
    AllowMountedRead0Behavior when opening a mounted filesystem read-only
    ForceExt20Overrides ext2 autodetection if set
    DefaultBlockSize1024Default block size used if filesystem detection fails
    DefaultTotalBlocks2097151Default total blocks used if filesystem detection fails
    DefaultBlocksInGroup8192Default blocks per group used if filesystem detection fails
    ForceDefault0Forces use of default values if detection fails