This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 882
pkg/fileutil: helper function to get major, minor numbers of a device file #3500
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jonboulle
suggested changes
Jan 2, 2017
} | ||
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
@@ -105,3 +106,35 @@ func Lsetxattr(path string, attr string, data []byte, flags int) error { | |||
} | |||
return nil | |||
} | |||
|
|||
// 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
squeed
force-pushed
the
fileutil-device
branch
from
January 4, 2017 13:31
58d2a44
to
a8a42aa
Compare
Ci complains about:
|
squeed
force-pushed
the
fileutil-device
branch
from
January 5, 2017 14:14
a8a42aa
to
b30c557
Compare
squeed
force-pushed
the
fileutil-device
branch
from
January 5, 2017 14:24
b30c557
to
7033fb5
Compare
@jonboulle care to re-review? |
jonboulle
approved these changes
Jan 5, 2017
Seems OK but I'll defer to @lucab for approval |
lucab
approved these changes
Jan 6, 2017
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.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.