Skip to content

Use as_any to downcast inodes for updating in ext4#271

Merged
hexagonal-sun merged 1 commit intohexagonal-sun:masterfrom
arihant2math:ext4plus-bump
Apr 3, 2026
Merged

Use as_any to downcast inodes for updating in ext4#271
hexagonal-sun merged 1 commit intohexagonal-sun:masterfrom
arihant2math:ext4plus-bump

Conversation

@arihant2math
Copy link
Copy Markdown
Collaborator

Solves the problem of input inodes not being updated by ext4 functions with as_any. Since inodes on the same filesystem are equivalent we can guarantee that the downcast will not fail (if it does, the cross device error will be caught first)

I'll probably do the same to FileOps later.

Ok(())
}

fn as_any(&self) -> &dyn Any;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is there a way we could provide a default implementation for this so all the trait implementations don't have to provide a boilerplate impl?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For weird trait-bounding reasons that fails to compile. I could make it a proc macro, but that feels a little redundant.

@hexagonal-sun
Copy link
Copy Markdown
Owner

I'm a bit unsure exactly what this is trying to solve. Could you expand further?

@arihant2math
Copy link
Copy Markdown
Collaborator Author

I'm a bit unsure exactly what this is trying to solve. Could you expand further?

I'm trying to mutate the inputs to various inode methods.

For example: link takes inode: Arc<dyn Inode> as a parameter, however I can't modify it without downcasting. I would prefer to keep it up to date because there probably would possible data loss if nlinks is out of date and the inode is accidentally deleted.

Copy link
Copy Markdown
Owner

@hexagonal-sun hexagonal-sun left a comment

Choose a reason for hiding this comment

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

LGTM

@hexagonal-sun hexagonal-sun merged commit 7984272 into hexagonal-sun:master Apr 3, 2026
4 checks passed
@arihant2math arihant2math deleted the ext4plus-bump branch April 3, 2026 20:12
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