Reconsider file backend implementation. #844
Replies: 4 comments 6 replies
-
I also think this is clearer to any future developers. They might be confused that devices have the type of DTYPE_VNODE even though there's DTYPE_DEV. |
Beta Was this translation helpful? Give feedback.
-
The problems with your solution are:
|
Beta Was this translation helpful? Give feedback.
-
I'm aware of this and still consider it better than dyn 😅. I don't really see 2) as a big problem. Is it really that bad to have ~6-10 imports instead of having to create a separate type for every would-be variant (or perhaps I miseunderstood something)? And tbh 1) is also not really a problem for me. it was already done 'my way' and the world didn't end. Maybe we would've added a couple more enum variants over time. Not a big deal to me, especially when the alternative is using dyn, allowing nonsense-state, having several unwraps in places that don't really make sense and having to create extra wrapper structs. |
Beta Was this translation helpful? Give feedback.
-
i'm open to other solutions. |
Beta Was this translation helpful? Give feedback.
-
So, we already talked about this. I'm now testing AC4 after implementing sys_read. The game creates a socket and tries to call connect on it. I need to implement Filedesc::get_socket for that, Since our file backend is a Box<dyn FileBackend>, it's famously very inconvenient to downcast it to a specific implementation. By using dyn, we also have to create a wrapper struct for every file backend to implement the FileBackend trait on. The alternative I suggest would be returning to the old way this was done and simply correcting my previous oversight by having something like
This would disallow inconsistent state (that we technically allow now) while staying true to FreeBSD.
As a sidenote, I also don't like the is_seekable + vnode field combo. This. once again allows nonsense state like a vnode file backend without a vnode, something that cannot happen. I don't really see the point in allowing this. I liked the seekable_vnode method better. It also allows us to reuse the existing stored vnode in some of the file backends instead of having it as a separate field.
Let me know your thoughts.
Beta Was this translation helpful? Give feedback.
All reactions