squashfs: expose inode number and type via Sys()#395
Closed
luthermonson wants to merge 1 commit into
Closed
Conversation
Adds Inode() and InodeType() accessors to directoryEntry so callers typing the Sys() result to squashfs.FileStat can read squashfs-specific metadata that fs.FileInfo doesn't carry. Sys() still returns *directoryEntry (no breaking change to existing assertions). Refs diskfs#301.
13e13f2 to
0f6189e
Compare
deitch
approved these changes
May 14, 2026
Collaborator
deitch
left a comment
There was a problem hiding this comment.
This looks good to me. I am not the biggest fan of the issue you raised - StatT everywhere else, just relying on the directoryEntry itself with exposed properties here - but it is good enough. The primary interfaces will work, and we can clean it up later.
If you think it is an issue, we can restructure this to a StatT as well. I am not sure how complicated that would be.
Collaborator
|
Also, this still is draft |
Contributor
Author
|
i think i'd like to see this structured as a |
deitch
pushed a commit
that referenced
this pull request
May 15, 2026
Alternative design to #395, applying the same StatT pattern used by the iso9660 and ext4 siblings of #301. Breaking change: removes the FileStat = *directoryEntry alias and the public UID()/GID()/Xattrs() accessor methods. Sys() now returns *StatT with UID, GID, Inode, InodeType, Xattrs, and LinkTarget fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #301. Sibling of #393 (ext4) — same goal, but adapted to squashfs's existing public surface.
What this does
The other filesystems answering #301 (ext4, iso9660, fat) introduce a per-package
StatTstruct returned bySys(). Squashfs is different:Sys()already returns*directoryEntry(aliased as the publicsquashfs.FileStat), which already exposes filesystem-specific metadata via accessor methods —UID(),GID(),Xattrs(),Readlink().To stay consistent with that existing public surface — and to avoid breaking any caller already doing
sys.(squashfs.FileStat).UID()— this PR adds two more accessors rather than introducing a parallel struct:(*directoryEntry).Inode() uint32— squashfs inode number(*directoryEntry).InodeType() string— human-readable inode type ("basic-file","extended-symlink", etc., one of 14 values)Sys()'s return type is unchanged. Callers use it the same way they already useUID()/GID():Why not a
StatTstruct hereTwo competing public shapes inside one package (
squashfs.FileStataccessor methods +squashfs.StatTstruct fields, both reachable from the sameSys()call) would be worse than mild inconsistency across packages. The existing pattern was set when squashfs first exposed UID/GID/Xattrs; this PR follows it.Tests
New
TestSquashfsInodeMetadataexercisesReadDir(".")+DirEntry.Info()andOpenFile().Stat()on the existing test image, asserts non-zeroInode(), no duplicate inode numbers across entries, and a sensibleInodeType()(with the extra check that directories reportbasic-directoryorextended-directory).