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

[Draft] Improve file to support modern os #86

Conversation

rishadbaniya
Copy link
Contributor

@rishadbaniya rishadbaniya commented May 1, 2024

this is a very early draft

@rishadbaniya rishadbaniya marked this pull request as draft May 1, 2024 16:33
@jgarzik
Copy link
Contributor

jgarzik commented May 1, 2024

Great start. One early file organization comment:
Prefer to follow the ls style of:

  1. toplevel source in $category/src/$utility.rs
  2. secondary sources in $category/src/$utility_util/ directory.,

@rishadbaniya
Copy link
Contributor Author

rishadbaniya commented May 1, 2024

through many research and scouring(the code of linux file utility v5.41) i've come to following high level conclusions

To make a "file" utility means to "abide" by the code of the linux "file" utility of a certain version(not the man page specification of magic)

Let me clarify what i mean:
Let's start with what's a compiled magic file

It's simply nothing but a file that has those lines of of text based magic file laid in a a C struct called struct magic and placed in a binary file

So to parse the binary magic file means to simply parse it to the struct magic, parsing the binary magic file is as simple as that and for each version of "file" utility this struct changes(it's size, it has new fields)...for example for 5.45 and 5.41 the binary magic file isn't compatible with each other. Why? Because the structure of the struct magic has been changed and having a supporting every single version is very painful as we need to be up to date with the "file" utility of as it's responsible for creating those compiled magic files

the complexity however comes in the raw magic file, the specification is not the "man page" itself but rather the code, without the code writing the "file" utility is absolutely impossible i.e parsing the raw magic file.

So, here' some details of this file utility:

It's planning to parse binary magic file and the text based magic file supported by file 5.41 as it's the version currently being used in OS X

@jgarzik
Copy link
Contributor

jgarzik commented Jun 22, 2024

Referenced permanently in issue #144, so closing this PR.

@jgarzik jgarzik closed this Jun 22, 2024
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.

None yet

2 participants