mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 03:28:19 +01:00
Update App version to 0.0.3
This commit is contained in:
@@ -80,7 +80,15 @@ func (u *UsbGadget) IsUDCBound() (bool, error) {
|
||||
|
||||
// BindUDC binds the gadget to the UDC.
|
||||
func (u *UsbGadget) BindUDC() error {
|
||||
err := os.WriteFile(path.Join(udcPath, "bind"), []byte(u.udc), 0644)
|
||||
err := os.WriteFile(udcPath, []byte(u.udc), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error binding UDC: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *UsbGadget) BindUDCToDWC3() error {
|
||||
err := os.WriteFile(path.Join(dwc3Path, "bind"), []byte(u.udc), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error binding UDC: %w", err)
|
||||
}
|
||||
@@ -89,7 +97,15 @@ func (u *UsbGadget) BindUDC() error {
|
||||
|
||||
// UnbindUDC unbinds the gadget from the UDC.
|
||||
func (u *UsbGadget) UnbindUDC() error {
|
||||
err := os.WriteFile(path.Join(udcPath, " "), []byte(u.udc), 0644)
|
||||
err := os.WriteFile(udcPath, []byte("none"), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error unbinding UDC: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *UsbGadget) UnbindUDCToDWC3() error {
|
||||
err := os.WriteFile(path.Join(dwc3Path, "unbind"), []byte(u.udc), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error unbinding UDC: %w", err)
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ type UsbGadget struct {
|
||||
log *zerolog.Logger
|
||||
|
||||
logSuppressionCounter map[string]int
|
||||
logLock sync.Mutex
|
||||
}
|
||||
|
||||
const configFSPath = "/sys/kernel/config"
|
||||
|
||||
@@ -82,6 +82,9 @@ func compareFileContent(oldContent []byte, newContent []byte, looserMatch bool)
|
||||
}
|
||||
|
||||
func (u *UsbGadget) logWithSupression(counterName string, every int, logger *zerolog.Logger, err error, msg string, args ...interface{}) {
|
||||
u.logLock.Lock()
|
||||
defer u.logLock.Unlock()
|
||||
|
||||
if _, ok := u.logSuppressionCounter[counterName]; !ok {
|
||||
u.logSuppressionCounter[counterName] = 0
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user