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

Feature Request: File-Folder Hybrid #1135

Open
amab8901 opened this issue Dec 17, 2024 · 6 comments
Open

Feature Request: File-Folder Hybrid #1135

amab8901 opened this issue Dec 17, 2024 · 6 comments

Comments

@amab8901
Copy link

amab8901 commented Dec 17, 2024

The way Rust currently organizes modules seems unnecessarily verbose: creating a directory and then creating a file with the same name as the directory, in which you manually need to specify the children. Would be really convenient for a Rust developer if a file-folder hybrid was introduced into Linux Kernel, so that Rust compiler can capitalize on it to eliminate the redundancy.

Benefits:

  • no need to duplicate the same file/folder name => cleaner/simpler/streamlined file tree
  • No need to write "pub mod X", because compiler would be able to figure it out automatically

This idea is inspired by Notion, which supports file-folder hybrids.

Here's how the filesystem works today:

apple
├──pear
│   ├──kiwi.rs
│   ├──potato.rs
│   └──cucumber.rs
├──guava
│   ├──tomato.rs
│   ├──orange.rs
│   └──banana.rs
├──pineapple
│   ├──blueberry.rs
│   ├──strawberry.rs
│   └──lemon.rs
├──pear.rs
├──guava.rs
└──pineapple.rs

The following files can have child files but cannot directly be written to or read from:

  • pear
  • guava
  • pineapple

The following files can be directly written to and read from but cannot have child files:

  • pear.rs
  • guava.rs
  • pineapple.rs
  • kiwi.rs
  • potato.rs
  • cucumber.rs
  • tomato.rs
  • orange.rs
  • banana.rs
  • blueberry.rs
  • strawberry.rs
  • lemon.rs

Here's what I'd like the filesystem to be capable of:

apple
├──pear.rs
│   ├──kiwi.rs
│   ├──potato.rs
│   └──cucumber.rs
├──guava.rs
│   ├──tomato.rs
│   ├──orange.rs
│   └──banana.rs
└──pineapple.rs
    ├──blueberry.rs
    ├──strawberry.rs
    └──lemon.rs

The following can be read from, written to, and have child files:

  • [every single file above]

The following are read from, written to and have child files all simultaneously:

  • pear.rs
  • guava.rs
  • pineapple.rs

The following have all 3 abilities but are using only the abilities to be written to and be read from (but aren't using their ability to have child files):

  • kiwi.rs
  • potato.rs
  • cucumber.rs
  • tomato.rs
  • orange.rs
  • banana.rs
  • blueberry.rs
  • strawberry.rs
  • lemon.rs
@bjorn3
Copy link
Member

bjorn3 commented Dec 17, 2024

This is not something rust-for-linux has control over.

@tgross35
Copy link
Collaborator

I am not sure what is meant by a file/folder hybrid, but in Rust you can also do module_name/mod.rs. And if you don't have submodules, you can just create module_name.rs without creating a directory.

@ojeda
Copy link
Member

ojeda commented Dec 17, 2024

Yeah, @amab8901 please clarify -- do you have an example? Thanks!

@amab8901
Copy link
Author

I updated the original post to elaborate what it looks like

@bjorn3
Copy link
Member

bjorn3 commented Dec 18, 2024

What you seem to want is fundamentally impossible on any common OS. And even if Linux itself added support for it, it will take decades before everyone in the Linux userspace and all git tooling has caught up to it and even once that happens, using it in the Linux source code would make it impossible to cross-compile Linux from a non-Linux OS that likely don't (yet) support it.

@ojeda
Copy link
Member

ojeda commented Dec 18, 2024

@amab8901 Thanks for detailing the original message!

From your expanded example, I agree that it seems unrelated to Rust for Linux: if I understand correctly, your motivation is to improve how Rust works in userspace (and likely other use cases); however, Rust for Linux is about supporting Rust as a language for kernel development (e.g. writing a driver in Rust), not about adding features to the kernel that could improve Rust when used in Linux.

If you want to pursue the idea, then I would suggest raising this in the LKML Cc'ing the right experts, such as FS people, ideally with some prototype code to show how it would look like.

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

No branches or pull requests

4 participants