-
Notifications
You must be signed in to change notification settings - Fork 242
feat(usb_mass_storage): mount as disk #333
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
internal/usbgadget/config.go:140
- [nitpick] Consider returning (bool, error) rather than (error, bool) to follow Go conventions and improve code readability.
func (u *UsbGadget) OverrideGadgetConfig(itemKey string, itemAttr string, value string) (error, bool) {
jsonrpc.go:488
- [nitpick] Consider specifying the allowed modes (cdrom, disk) in the error message for clearer guidance on valid input values.
return "", fmt.Errorf("invalid mode: %s", mode)
usb_mass_storage.go
Outdated
| virtualMediaStateMutex.Unlock() | ||
| return fmt.Errorf("another virtual media is already mounted") | ||
| } | ||
| setMassStorageMode(mode == CDROM) |
Copilot
AI
Apr 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error returned by setMassStorageMode is not checked, which may lead to silent failures. Consider handling the error appropriately.
| setMassStorageMode(mode == CDROM) | |
| err := setMassStorageMode(mode == CDROM) | |
| if err != nil { | |
| virtualMediaStateMutex.Unlock() | |
| return fmt.Errorf("failed to set mass storage mode: %w", err) | |
| } |
usb_mass_storage.go
Outdated
| Size: size, | ||
| } | ||
| virtualMediaStateMutex.Unlock() | ||
| setMassStorageMode(mode == CDROM) |
Copilot
AI
Apr 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error returned by setMassStorageMode in this call is ignored. Consider checking and handling any potential error.
| setMassStorageMode(mode == CDROM) | |
| err := setMassStorageMode(mode == CDROM) | |
| if err != nil { | |
| logger.Errorf("failed to set mass storage mode: %v", err) | |
| return err | |
| } |
usb_mass_storage.go
Outdated
| setMassStorageMode(mode == CDROM) | ||
|
|
Copilot
AI
Apr 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring the error from setMassStorageMode here can lead to unhandled failure scenarios. Please capture and handle the error as needed.
| setMassStorageMode(mode == CDROM) | |
| err = setMassStorageMode(mode == CDROM) | |
| if err != nil { | |
| return fmt.Errorf("failed to set mass storage mode: %w", err) | |
| } |
fe11c4d to
c80945e
Compare
c80945e to
5ba3315
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for mounting USB mass storage as a disk rather than a CD/DVD by renaming functions and updating the UI and RPC logic accordingly.
- Rename backend function from getMassStorageMode() to getMassStorageCDROMEnabled().
- Update UI components to map .img files to "Disk" mode.
- Introduce a new gadget configuration override function in the usbgadget config.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| usb_mass_storage.go | Rename function for clarity and update mass storage mode handling |
| ui/src/routes/devices.$id.mount.tsx | Adjust UI logic to set USB mode to "Disk" for IMG files and update radio input properties |
| jsonrpc.go | Use switch-case for mode translation and update function call to reflect renaming |
| internal/usbgadget/config.go | Add OverrideGadgetConfig for updating gadget configurations |
Comments suppressed due to low confidence (1)
usb_mass_storage.go:116
- The renaming to 'getMassStorageCDROMEnabled' improves clarity. Please ensure related documentation or comments are updated accordingly.
func getMassStorageCDROMEnabled() (bool, error) {
| setUsbMode("Disk"); | ||
| } |
Copilot
AI
May 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UI now uses 'Disk' mode for IMG files while the backend maps non-CDROM modes to 'file'. Consider aligning these terms or adding documentation to clarify this mapping for API consumers.
| setUsbMode("Disk"); | |
| } | |
| setUsbMode("file"); // Aligning with backend terminology | |
| } | |
| // Note: The UI uses "CDROM" and "file" to match backend expectations. | |
| // "CDROM" is used for ISO files, and "file" is used for IMG files. |
5ba3315 to
3f8b30c
Compare
7dffd13 to
023c6e2
Compare
* feat(usb_mass_storage): mount as disk * chore: try to set initial virtual media state from sysfs * chore(usb-mass-storage): fix inquiry_string
No description provided.