From ba28c366721e13994ec4a170d16683a2fcc13b81 Mon Sep 17 00:00:00 2001 From: Prajwal S N Date: Mon, 26 Jun 2023 23:59:30 +0530 Subject: [PATCH] feat(crit): add type to file descriptor Signed-off-by: Prajwal S N --- crit/explore.go | 2 ++ crit/utils.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crit/explore.go b/crit/explore.go index 4a539c741..3d2b98799 100644 --- a/crit/explore.go +++ b/crit/explore.go @@ -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"` } @@ -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) diff --git a/crit/utils.go b/crit/utils.go index e0e173bbe..f76c3a7df 100644 --- a/crit/utils.go +++ b/crit/utils.go @@ -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