-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathsysfs_test.go
69 lines (54 loc) · 1.27 KB
/
sysfs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2017 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package sysfs
import (
"errors"
"io"
"periph.io/x/host/v3/fs"
)
func init() {
fs.Inhibit()
reset()
}
func reset() {
fileIOOpen = fileIOOpenDefault
ioctlOpen = ioctlOpenDefault
// Soon.
//fileIOOpen = fileIOOpenPanic
//ioctlOpen = ioctlOpenPanic
}
func ioctlOpenPanic(path string, flag int) (ioctlCloser, error) {
panic("don't forget to override fileIOOpen")
}
func fileIOOpenPanic(path string, flag int) (fileIO, error) {
panic("don't forget to override fileIOOpen")
}
type ioctlClose struct {
ioctlErr error
closeErr error
}
func (i *ioctlClose) Ioctl(op uint, data uintptr) error {
return i.ioctlErr
}
func (i *ioctlClose) Close() error {
return i.closeErr
}
type file struct {
ioctlClose
}
func (f *file) Fd() uintptr {
return 0xFFFFFFFF
}
func (f *file) Read(p []byte) (int, error) {
return 0, errors.New("not implemented")
}
func (f *file) Seek(offset int64, whence int) (int64, error) {
if offset == 0 && whence == io.SeekStart {
return 0, nil
}
return 0, errors.New("not implemented")
}
func (f *file) Write(p []byte) (int, error) {
return 0, errors.New("not implemented")
}