You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							36 lines
						
					
					
						
							730 B
						
					
					
				
			
		
		
	
	
							36 lines
						
					
					
						
							730 B
						
					
					
				package procfs
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"io"
 | 
						|
	"os"
 | 
						|
)
 | 
						|
 | 
						|
const (
 | 
						|
	acpiWakeupDefaultPath = "/proc/acpi/wakeup"
 | 
						|
)
 | 
						|
 | 
						|
type Procfs interface {
 | 
						|
	ACPIWakeup() (io.ReadCloser, error)
 | 
						|
	ACPIWakeupWrite() (io.WriteCloser, error)
 | 
						|
}
 | 
						|
 | 
						|
type ProcfsDefaultPath struct{}
 | 
						|
 | 
						|
func (p *ProcfsDefaultPath) ACPIWakeup() (io.ReadCloser, error) {
 | 
						|
	f, err := os.Open(acpiWakeupDefaultPath)
 | 
						|
	if err != nil {
 | 
						|
		return nil, fmt.Errorf("failed to open %s: %w", acpiWakeupDefaultPath, err)
 | 
						|
	}
 | 
						|
 | 
						|
	return f, nil
 | 
						|
}
 | 
						|
 | 
						|
func (p *ProcfsDefaultPath) ACPIWakeupWrite() (io.WriteCloser, error) {
 | 
						|
	f, err := os.OpenFile(acpiWakeupDefaultPath, os.O_WRONLY, 0)
 | 
						|
	if err != nil {
 | 
						|
		return nil, fmt.Errorf("failed to open for writing %s: %w", acpiWakeupDefaultPath, err)
 | 
						|
	}
 | 
						|
 | 
						|
	return f, nil
 | 
						|
}
 | 
						|
 |