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

9pfs: root device #7

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

KarlK90
Copy link
Contributor

@KarlK90 KarlK90 commented Jan 31, 2025

For @a3f ;-)

This was done using the unstable rustfmt option[1] group_imports that
requires a nightly toolchain, thus it was run manually.

[1]: https://rust-lang.github.io/rustfmt/?version=v1.8.0&search=import#group_imports

Signed-off-by: Stefan Kerkmann <[email protected]>
mkdir, read_file write_file augment the error case with the path in the
error case. This is useful as we otherwise don't know which location
failed. This commit refactors the functions to take any argument that
coerces into a Path - which is implemented by many types.

mkdir now uses create_dir_all as it is not meant to fail if the
directory already exists.

Signed-off-by: Stefan Kerkmann <[email protected]>
@KarlK90 KarlK90 force-pushed the feature/9pfs-root-device branch from eadc41b to 592fac3 Compare January 31, 2025 13:29
}
.as_bytes()
.escape_ascii()
.to_string();
Copy link
Owner

Choose a reason for hiding this comment

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

This looks wrong. In the else case, the string is converted multiple times.

let function = format!("/sys/kernel/config/usb_gadget/9pfs/functions/usb9pfs.{device}");
let link = format!("/sys/kernel/config/usb_gadget/9pfs/configs/c.1/usb9pfs.{device}");
let function = format!("/sys/kernel/config/usb_gadget/9pfs/functions/usb9pfs.{udc}");
let link = format!("/sys/kernel/config/usb_gadget/9pfs/configs/c.1/usb9pfs.{udc}");
Copy link
Owner

Choose a reason for hiding this comment

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

I think @a3f said, that this name does not really matter, so maybe just use a fixed name.
@a3f, what do you think?

udc.as_encoded_bytes(),
)?;
debug!("Attaching 9pfs gatget to UDC {udc}",);
write_file("/sys/kernel/config/usb_gadget/9pfs/UDC", &udc)?;
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, the file name read above is not necessarily UTF-8, so converting it into a String is technically not correct.


let d = time::Duration::new(1, 0);
thread::sleep(d);
Copy link
Owner

Choose a reason for hiding this comment

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

Unrelated, this should be a separate commit.

@KarlK90
Copy link
Contributor Author

KarlK90 commented Feb 1, 2025

@michaelolbrich Thanks for having a look, the PR is still in draft and only a quick "hack job" at this point.

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