Fix the following warnings:
pkg/mount/mountinfo.go:5:6: type name will be used as mount.MountInfo by other packages, and that stutters; consider calling this Info
pkg/mount/mountinfo.go:7:2: struct field Id should be ID
Signed-off-by: Antonio Murdaca <runcom@linux.com>
| ... | ... |
@@ -1,10 +1,10 @@ |
| 1 | 1 |
package mount |
| 2 | 2 |
|
| 3 |
-// MountInfo reveals information about a particular mounted filesystem. This |
|
| 3 |
+// Info reveals information about a particular mounted filesystem. This |
|
| 4 | 4 |
// struct is populated from the content in the /proc/<pid>/mountinfo file. |
| 5 |
-type MountInfo struct {
|
|
| 6 |
- // Id is a unique identifier of the mount (may be reused after umount). |
|
| 7 |
- Id int |
|
| 5 |
+type Info struct {
|
|
| 6 |
+ // ID is a unique identifier of the mount (may be reused after umount). |
|
| 7 |
+ ID int |
|
| 8 | 8 |
|
| 9 | 9 |
// Parent indicates the ID of the mount parent (or of self for the top of the |
| 10 | 10 |
// mount tree). |
| ... | ... |
@@ -15,7 +15,7 @@ import ( |
| 15 | 15 |
|
| 16 | 16 |
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from |
| 17 | 17 |
// bind mounts. |
| 18 |
-func parseMountTable() ([]*MountInfo, error) {
|
|
| 18 |
+func parseMountTable() ([]*Info, error) {
|
|
| 19 | 19 |
var rawEntries *C.struct_statfs |
| 20 | 20 |
|
| 21 | 21 |
count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT)) |
| ... | ... |
@@ -29,9 +29,9 @@ func parseMountTable() ([]*MountInfo, error) {
|
| 29 | 29 |
header.Len = count |
| 30 | 30 |
header.Data = uintptr(unsafe.Pointer(rawEntries)) |
| 31 | 31 |
|
| 32 |
- var out []*MountInfo |
|
| 32 |
+ var out []*Info |
|
| 33 | 33 |
for _, entry := range entries {
|
| 34 |
- var mountinfo MountInfo |
|
| 34 |
+ var mountinfo Info |
|
| 35 | 35 |
mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0]) |
| 36 | 36 |
mountinfo.Source = C.GoString(&entry.f_mntfromname[0]) |
| 37 | 37 |
mountinfo.Fstype = C.GoString(&entry.f_fstypename[0]) |
| ... | ... |
@@ -30,7 +30,7 @@ const ( |
| 30 | 30 |
|
| 31 | 31 |
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from |
| 32 | 32 |
// bind mounts |
| 33 |
-func parseMountTable() ([]*MountInfo, error) {
|
|
| 33 |
+func parseMountTable() ([]*Info, error) {
|
|
| 34 | 34 |
f, err := os.Open("/proc/self/mountinfo")
|
| 35 | 35 |
if err != nil {
|
| 36 | 36 |
return nil, err |
| ... | ... |
@@ -40,10 +40,10 @@ func parseMountTable() ([]*MountInfo, error) {
|
| 40 | 40 |
return parseInfoFile(f) |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
-func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
|
| 43 |
+func parseInfoFile(r io.Reader) ([]*Info, error) {
|
|
| 44 | 44 |
var ( |
| 45 | 45 |
s = bufio.NewScanner(r) |
| 46 |
- out = []*MountInfo{}
|
|
| 46 |
+ out = []*Info{}
|
|
| 47 | 47 |
) |
| 48 | 48 |
|
| 49 | 49 |
for s.Scan() {
|
| ... | ... |
@@ -52,13 +52,13 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 | 54 |
var ( |
| 55 |
- p = &MountInfo{}
|
|
| 55 |
+ p = &Info{}
|
|
| 56 | 56 |
text = s.Text() |
| 57 | 57 |
optionalFields string |
| 58 | 58 |
) |
| 59 | 59 |
|
| 60 | 60 |
if _, err := fmt.Sscanf(text, mountinfoFormat, |
| 61 |
- &p.Id, &p.Parent, &p.Major, &p.Minor, |
|
| 61 |
+ &p.ID, &p.Parent, &p.Major, &p.Minor, |
|
| 62 | 62 |
&p.Root, &p.Mountpoint, &p.Opts, &optionalFields); err != nil {
|
| 63 | 63 |
return nil, fmt.Errorf("Scanning '%s' failed: %s", text, err)
|
| 64 | 64 |
} |
| ... | ... |
@@ -84,7 +84,7 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
| 84 | 84 |
// PidMountInfo collects the mounts for a specific process ID. If the process |
| 85 | 85 |
// ID is unknown, it is better to use `GetMounts` which will inspect |
| 86 | 86 |
// "/proc/self/mountinfo" instead. |
| 87 |
-func PidMountInfo(pid int) ([]*MountInfo, error) {
|
|
| 87 |
+func PidMountInfo(pid int) ([]*Info, error) {
|
|
| 88 | 88 |
f, err := os.Open(fmt.Sprintf("/proc/%d/mountinfo", pid))
|
| 89 | 89 |
if err != nil {
|
| 90 | 90 |
return nil, err |
| ... | ... |
@@ -457,8 +457,8 @@ func TestParseFedoraMountinfoFields(t *testing.T) {
|
| 457 | 457 |
if len(infos) != expectedLength {
|
| 458 | 458 |
t.Fatalf("Expected %d entries, got %d", expectedLength, len(infos))
|
| 459 | 459 |
} |
| 460 |
- mi := MountInfo{
|
|
| 461 |
- Id: 15, |
|
| 460 |
+ mi := Info{
|
|
| 461 |
+ ID: 15, |
|
| 462 | 462 |
Parent: 35, |
| 463 | 463 |
Major: 0, |
| 464 | 464 |
Minor: 3, |