Skip to content

Commit

Permalink
Merge pull request #134 from snprajwal/add-fd-type
Browse files Browse the repository at this point in the history
feat(crit): add type to file descriptor
  • Loading branch information
rst0git committed Jul 5, 2023
2 parents 4c639ba + ba28c36 commit f8745d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crit/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Fd struct {
// File represents a single opened file
type File struct {
Fd string `json:"fd"`
Type string `json:"type,omitempty"`
Path string `json:"path"`
}

Expand Down Expand Up @@ -114,6 +115,7 @@ func (c *crit) ExploreFds() ([]*Fd, error) {
}
file := File{
Fd: strconv.FormatUint(uint64(fdInfo.GetFd()), 10),
Type: fdInfo.GetType().String(),
Path: filePath,
}
fdEntry.Files = append(fdEntry.Files, &file)
Expand Down
2 changes: 1 addition & 1 deletion crit/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func getFilePath(dir string, fID uint32, fType fdinfo.FdTypes) (string, error) {
case fdinfo.FdTypes_UNIXSK:
filePath, err = getUnixSkFilePath(dir, file, fID)
default:
filePath = fmt.Sprintf("%s.%d", fdinfo.FdTypes_name[int32(fType)], fID)
filePath = fmt.Sprintf("%s.%d", fType.String(), fID)
}

return filePath, err
Expand Down

0 comments on commit f8745d1

Please sign in to comment.