Skip to content

Commit 647e50e

Browse files
authored
Add inode number to fdinfo (#552)
Signed-off-by: Cyrill Troxler <[email protected]>
1 parent 9d715e8 commit 647e50e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

proc_fdinfo.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var (
2626
rPos = regexp.MustCompile(`^pos:\s+(\d+)$`)
2727
rFlags = regexp.MustCompile(`^flags:\s+(\d+)$`)
2828
rMntID = regexp.MustCompile(`^mnt_id:\s+(\d+)$`)
29+
rIno = regexp.MustCompile(`^ino:\s+(\d+)$`)
2930
rInotify = regexp.MustCompile(`^inotify`)
3031
rInotifyParts = regexp.MustCompile(`^inotify\s+wd:([0-9a-f]+)\s+ino:([0-9a-f]+)\s+sdev:([0-9a-f]+)(?:\s+mask:([0-9a-f]+))?`)
3132
)
@@ -40,6 +41,8 @@ type ProcFDInfo struct {
4041
Flags string
4142
// Mount point ID
4243
MntID string
44+
// Inode number
45+
Ino string
4346
// List of inotify lines (structured) in the fdinfo file (kernel 3.8+ only)
4447
InotifyInfos []InotifyInfo
4548
}
@@ -51,7 +54,7 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
5154
return nil, err
5255
}
5356

54-
var text, pos, flags, mntid string
57+
var text, pos, flags, mntid, ino string
5558
var inotify []InotifyInfo
5659

5760
scanner := bufio.NewScanner(bytes.NewReader(data))
@@ -63,6 +66,8 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
6366
flags = rFlags.FindStringSubmatch(text)[1]
6467
} else if rMntID.MatchString(text) {
6568
mntid = rMntID.FindStringSubmatch(text)[1]
69+
} else if rIno.MatchString(text) {
70+
ino = rIno.FindStringSubmatch(text)[1]
6671
} else if rInotify.MatchString(text) {
6772
newInotify, err := parseInotifyInfo(text)
6873
if err != nil {
@@ -77,6 +82,7 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
7782
Pos: pos,
7883
Flags: flags,
7984
MntID: mntid,
85+
Ino: ino,
8086
InotifyInfos: inotify,
8187
}
8288

0 commit comments

Comments
 (0)