MCPcopy Create free account
hub / github.com/F-Stack/f-stack / graph_pcap_default_path_get

Function graph_pcap_default_path_get

dpdk/lib/graph/graph_pcap.c:56–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static int
57graph_pcap_default_path_get(char **dir_path)
58{
59 struct passwd *pwd;
60 char *home_dir;
61
62 /* First check for shell environment variable */
63 home_dir = getenv("HOME");
64 if (home_dir == NULL) {
65 graph_warn("Home env not preset.");
66 /* Fallback to password file entry */
67 pwd = getpwuid(getuid());
68 if (pwd == NULL)
69 return -EINVAL;
70
71 home_dir = pwd->pw_dir;
72 }
73
74 /* Append default pcap file to directory */
75 if (asprintf(dir_path, "%s/%s", home_dir, GRAPH_PCAP_FILE_NAME) == -1)
76 return -ENOMEM;
77
78 return 0;
79}
80
81int
82graph_pcap_file_open(const char *filename)

Callers 1

graph_pcap_file_openFunction · 0.85

Calls 1

asprintfFunction · 0.85

Tested by

no test coverage detected