@@ -2,6 +2,7 @@ package crit
22
33import (
44 "fmt"
5+ "path/filepath"
56 "strconv"
67
78 "github.com/checkpoint-restore/go-criu/v6/crit/images"
@@ -20,7 +21,7 @@ type PsTree struct {
2021
2122// ExplorePs constructs the process tree and returns the root process
2223func (c * crit ) ExplorePs () (* PsTree , error ) {
23- psTreeImg , err := getImg (fmt . Sprintf ( "%s/ pstree.img", c . inputDirPath ))
24+ psTreeImg , err := getImg (filepath . Join ( c . inputDirPath , " pstree.img" ))
2425 if err != nil {
2526 return nil , err
2627 }
@@ -31,7 +32,7 @@ func (c *crit) ExplorePs() (*PsTree, error) {
3132 process := entry .Message .(* images.PstreeEntry )
3233 pId := process .GetPid ()
3334
34- coreImg , err := getImg (fmt .Sprintf ("%s/ core-%d.img" , c . inputDirPath , pId ))
35+ coreImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("core-%d.img" , pId ) ))
3536 if err != nil {
3637 return nil , err
3738 }
@@ -77,7 +78,7 @@ type File struct {
7778// ExploreFds searches the process tree for open files
7879// and returns a list of PIDs with the corresponding files
7980func (c * crit ) ExploreFds () ([]* Fd , error ) {
80- psTreeImg , err := getImg (fmt . Sprintf ( "%s/ pstree.img", c . inputDirPath ))
81+ psTreeImg , err := getImg (filepath . Join ( c . inputDirPath , " pstree.img" ))
8182 if err != nil {
8283 return nil , err
8384 }
@@ -87,13 +88,13 @@ func (c *crit) ExploreFds() ([]*Fd, error) {
8788 process := entry .Message .(* images.PstreeEntry )
8889 pId := process .GetPid ()
8990 // Get file with object IDs
90- idsImg , err := getImg (fmt .Sprintf ("%s/ ids-%d.img" , c . inputDirPath , pId ))
91+ idsImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("ids-%d.img" , pId ) ))
9192 if err != nil {
9293 return nil , err
9394 }
9495 filesId := idsImg .Entries [0 ].Message .(* images.TaskKobjIdsEntry ).GetFilesId ()
9596 // Get open file descriptors
96- fdInfoImg , err := getImg (fmt .Sprintf ("%s/ fdinfo-%d.img" , c . inputDirPath , filesId ))
97+ fdInfoImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("fdinfo-%d.img" , filesId ) ))
9798 if err != nil {
9899 return nil , err
99100 }
@@ -113,7 +114,7 @@ func (c *crit) ExploreFds() ([]*Fd, error) {
113114 fdEntry .Files = append (fdEntry .Files , & file )
114115 }
115116 // Get chroot and chdir info
116- fsImg , err := getImg (fmt .Sprintf ("%s/ fs-%d.img" , c . inputDirPath , pId ))
117+ fsImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("fs-%d.img" , pId ) ))
117118 if err != nil {
118119 return nil , err
119120 }
@@ -161,7 +162,7 @@ type Mem struct {
161162// ExploreMems traverses the process tree and returns a
162163// list of processes with the corresponding memory mapping
163164func (c * crit ) ExploreMems () ([]* MemMap , error ) {
164- psTreeImg , err := getImg (fmt . Sprintf ( "%s/ pstree.img", c . inputDirPath ))
165+ psTreeImg , err := getImg (filepath . Join ( c . inputDirPath , " pstree.img" ))
165166 if err != nil {
166167 return nil , err
167168 }
@@ -181,7 +182,7 @@ func (c *crit) ExploreMems() ([]*MemMap, error) {
181182 process := entry .Message .(* images.PstreeEntry )
182183 pId := process .GetPid ()
183184 // Get memory mappings
184- mmImg , err := getImg (fmt .Sprintf ("%s/ mm-%d.img" , c . inputDirPath , pId ))
185+ mmImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("mm-%d.img" , pId ) ))
185186 if err != nil {
186187 return nil , err
187188 }
@@ -288,7 +289,7 @@ type Vma struct {
288289// ExploreRss traverses the process tree and returns
289290// a list of processes with their RSS mappings
290291func (c * crit ) ExploreRss () ([]* RssMap , error ) {
291- psTreeImg , err := getImg (fmt . Sprintf ( "%s/ pstree.img", c . inputDirPath ))
292+ psTreeImg , err := getImg (filepath . Join ( c . inputDirPath , " pstree.img" ))
292293 if err != nil {
293294 return nil , err
294295 }
@@ -298,13 +299,13 @@ func (c *crit) ExploreRss() ([]*RssMap, error) {
298299 process := entry .Message .(* images.PstreeEntry )
299300 pId := process .GetPid ()
300301 // Get virtual memory addresses
301- mmImg , err := getImg (fmt .Sprintf ("%s/ mm-%d.img" , c . inputDirPath , pId ))
302+ mmImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("mm-%d.img" , pId ) ))
302303 if err != nil {
303304 return nil , err
304305 }
305306 vmas := mmImg .Entries [0 ].Message .(* images.MmEntry ).GetVmas ()
306307 // Get physical memory addresses
307- pagemapImg , err := getImg (fmt .Sprintf ("%s/ pagemap-%d.img" , c . inputDirPath , pId ))
308+ pagemapImg , err := getImg (filepath . Join ( c . inputDirPath , fmt .Sprintf ("pagemap-%d.img" , pId ) ))
308309 if err != nil {
309310 return nil , err
310311 }
0 commit comments