Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dissect.disc #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Add dissect.disc #1

wants to merge 9 commits into from

Conversation

MaxGroot
Copy link

@MaxGroot MaxGroot commented Mar 9, 2024

This PR adds support for filesystems typically encountered on optical discs. It currently supports ISO 9660 and its extensions 'Rock Ridge' and 'Joliet'. It currently does not support UDF and Apple extensions to ISO9660.

For example, the following usage:

# First insert the best game ever in your CD drive
from dissect.disc import DISC

with open("/dev/sr0", "rb") as best_game_ever:
    disc = DISC(best_game_ever)
    print(disc.volume_name)
    best_day_ever = disc.primary_volume.creation_date
    print(best_day_ever)
    for best_file_ever in disc.get_entry("/").scandir():
        print(best_file_ever.name)

Would yield:

LEGOISLAND
<dec_datetime year=b'1997', month=b'08', day=b'11', hour=b'22', minute=b'24', second=b'32', centiseconds=b'00', offset=0x30>
.
..
ATTSETUP.EXE
AUTORUN.INF
CONNECT.EX_
DATA
INSTALL.EXE
LEGO

Copy link
Member

@Schamper Schamper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial few comments, let's first discuss these before I go more in depth and you have to go grab the.. well you know. miss you buddy

Two overall comments to think about:

  • dissect.disc makes sense to support different disc formats in the long run. Currently you support ISO, but call it DISC. Maybe just put all the ISO stuff in dissect.disc.iso to make the separation clear.
  • Maybe think of a way to separate the extensions into different files. Circular dependency will be an issue though, so you may have to introduce a base file for the base directory record implementation.

dissect/disc/c_iso_9660.py Outdated Show resolved Hide resolved
dissect/disc/c_iso_9660.py Outdated Show resolved Hide resolved
dissect/disc/c_iso_9660.py Outdated Show resolved Hide resolved
dissect/disc/c_iso_9660.py Outdated Show resolved Hide resolved
dissect/disc/disc.py Outdated Show resolved Hide resolved
dissect/disc/disc.py Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
dissect/disc/disc.py Outdated Show resolved Hide resolved
dissect/disc/disc.py Outdated Show resolved Hide resolved
dissect/disc/disc.py Outdated Show resolved Hide resolved
@Schamper
Copy link
Member

Can you also include these two changes?
fox-it/dissect@72b2495
fox-it/dissect@7228e49

@MaxGroot
Copy link
Author

MaxGroot commented Apr 1, 2024

I've addressed your initial few comments in the first three commits, and the broader remarks in the last one.

Locally, I've started working on UDF, also to further understand what might be a nice structuring for this PR that keeps future extension in mind. I ended up implementing some 'base' logic in dissect.disc.base, which can then be extended by different 'disc formats', such as RockRidge, Joliet, 'plain' ISO9660 or UDF later down the line. The DISC class is then only responsible for selecting the right format (with user preference in mind), and providing access to the underlying available disc formats and their APIs. The abstract classes DiscBase and DiscBaseEntry implement an almost identical API as dissect.target. This also removes the complicated 'stateful' initialization that the DISC class had.

I do have some reservations about the new module structure, but am curious to hear what you think. Perhaps it's acceptable enough that we go more in depth, no holding back. like we always used to do

MaxGroot added 4 commits July 23, 2024 15:20
- Throw the project-specific exceptions rather than the base python ones
- Handle non-ISO9660 input files correctly
- Move file finding logic to base.py
- Bugfix current/parent directory for Joliet
- Bugfix filesize
- New tests to test the bugfixes
@MaxGroot
Copy link
Author

Hi @Schamper,

I know you're upset with me for missing your birthday, but I hope this small present makes up for it. I know your favourite activity is to do code review, so I extended this PR with UDF support so there are more lines in this PR for you to play around with. To make it even more challenging, I only briefly looked at consistent spacing and that stuff, because I know how excited you get clicking that sweet 'add suggestion' button.

I think this more than makes up for all those "How could you miss my birthday", "It was really important to me" and "Why are you so obsessed with an optical medium of the 90s" comments/jokes you were making. You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants