Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ISO9660

License: GPL v3

About

ISO9660 is an ISO 9660 (ECMA-119) filesystem reader and writer library and command-line utility with support for Rock Ridge, Joliet, and El Torito. It is intended for software developers and system administrators working with optical disc images on POSIX systems.

Dependencies

  • C23 standard library
  • POSIX.1-2008 system APIs
  • CMake 3.20 or newer (build dependency)
  • C23-compatible C compiler such as GCC 13+ or Clang 16+ (build dependency)

Optional test dependencies:

  • cdrtools (isoinfo)
  • genisoimage
  • 7-Zip (7z)

Build

Configure and compile the static library, shared library, command-line tool, and test suite:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Run test suite:

ctest --test-dir build --output-on-failure

To build with AddressSanitizer and UndefinedBehaviorSanitizer:

cmake -B build-asan -DCMAKE_C_FLAGS="-fsanitize=address,undefined -g -fno-omit-frame-pointer"
cmake --build build-asan
ctest --test-dir build-asan --output-on-failure

Usage

Command-line Tool

Create an image:

./build/iso9660 create -o image.iso -V "DATA" -J -R /path/to/source

Create a bootable image:

./build/iso9660 create -o boot.iso -V "BOOT" -J -R -b boot.img /path/to/source

Display image metadata:

./build/iso9660 info image.iso

List contents:

./build/iso9660 list image.iso

Extract a single file:

./build/iso9660 extract image.iso /docs/manual.txt ./manual.txt

Extract the entire filesystem:

./build/iso9660 extract-all image.iso ./output_dir

C API

Writing an image:

#include <iso9660/iso9660.h>

int main(void) {
    iso9660_writer_opts_t opts;
    iso9660_writer_opts_default(&opts);
    opts.enable_joliet = true;
    opts.enable_rockridge = true;

    iso9660_writer_t *writer = NULL;
    iso9660_writer_create(&opts, &writer);
    iso9660_writer_add_tree(writer, "/path/to/source", "/");
    iso9660_writer_write_file(writer, "output.iso");
    iso9660_writer_destroy(writer);

    return 0;
}

Reading an image:

#include <iso9660/iso9660.h>
#include <stdio.h>

int main(void) {
    iso9660_reader_t *reader = NULL;
    if (iso9660_reader_open_file("output.iso", &reader) != ISO9660_OK) {
        return 1;
    }

    iso9660_stat_t st;
    if (iso9660_reader_stat(reader, "/file.txt", &st) == ISO9660_OK) {
        printf("Size: %lu bytes\n", (unsigned long)st.size);
    }

    iso9660_dir_t *dir = NULL;
    if (iso9660_reader_opendir(reader, "/", &dir) == ISO9660_OK) {
        iso9660_stat_t entry;
        while (iso9660_reader_readdir(dir, &entry) == ISO9660_OK) {
            printf("%s\n", entry.name);
        }
        iso9660_reader_closedir(dir);
    }

    iso9660_reader_close(reader);
    return 0;
}

Acknowledgments

  • ECMA-119 specification (ISO 9660:1988)
  • IEEE P1282 System Use Sharing Protocol (SUSP) and Rock Ridge Interchange Protocol (RRIP)
  • Microsoft Joliet specification
  • Phoenix Technologies and IBM "El Torito" Bootable CD-ROM Format Specification version 1.0

Links to docs and CONTRIBUTING

License

This project is licensed under the GNU General Public License v3.0 or later. See LICENSE.

About

An ISO 9660 (ECMA-119) filesystem implementation.

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages