-
Couldn't load subscription status.
- Fork 881
pkg/fileutil: helper function to get major, minor numbers of a device file #3500
Conversation
pkg/fileutil/fileutil_linux.go
Outdated
| } | ||
| stat_t, ok := d.Sys().(*syscall.Stat_t) | ||
| if !ok { | ||
| err = fmt.Errorf("Cannot determine device number") |
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.
lowercase error
| } | ||
|
|
||
| // GetDeviceInfo returns the type, major, and minor numbers of a device | ||
| func GetDeviceInfo(path string) (kind rune, major uint64, minor uint64, err error) { |
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.
Change this to
func GetDeviceInfo(path string) (kind rune, major uint64, minor uint64, err error) {
d, err := os.Lstat(path)
if err != nil {
return ' ', 0, 0, err
}
return getDeviceInfo(d)
}
func getDeviceInfo(d *os.FileInfo) (kind rune, major uint64, minor uint64, err error) {
...
}
Then you can test the inner function to your heart's content
58d2a44 to
a8a42aa
Compare
|
Ci complains about: |
a8a42aa to
b30c557
Compare
b30c557 to
7033fb5
Compare
|
@jonboulle care to re-review? |
|
Seems OK but I'll defer to @lucab for approval |
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.
LGTM. Depending on who will be the consumers of this, it could make sense to later introduce a custom enum for the kind instead of a char.
No description provided.