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

Function iterate_dir

dpdk/drivers/common/dpaax/dpaa_of.c:101–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99static int process_dir(const char *relative_path, struct dt_dir *dt);
100
101static int
102iterate_dir(struct dirent **d, int num, struct dt_dir *dt)
103{
104 int loop;
105 /* Iterate the directory contents */
106 for (loop = 0; loop < num; loop++) {
107 struct dt_dir *subdir;
108 int ret;
109 /* Ignore dot files of all types (especially "..") */
110 if (d[loop]->d_name[0] == '.')
111 continue;
112 switch (d[loop]->d_type) {
113 case DT_REG:
114 process_file(d[loop], dt);
115 break;
116 case DT_DIR:
117 subdir = malloc(sizeof(*subdir));
118 if (!subdir) {
119 perror("malloc");
120 return -ENOMEM;
121 }
122 strlcpy(subdir->node.node.name, d[loop]->d_name,
123 NAME_MAX);
124 snprintf(subdir->node.node.full_name, PATH_MAX,
125 "%s/%s", dt->node.node.full_name,
126 d[loop]->d_name);
127 subdir->parent = dt;
128 ret = process_dir(subdir->node.node.full_name, subdir);
129 if (ret)
130 return ret;
131 list_add_tail(&subdir->node.list, &dt->subdirs);
132 break;
133 default:
134 DPAAX_LOG(DEBUG, "Ignoring invalid dt entry %s/%s",
135 dt->node.node.full_name, d[loop]->d_name);
136 }
137 }
138 return 0;
139}
140
141static int
142process_dir(const char *relative_path, struct dt_dir *dt)

Callers 1

process_dirFunction · 0.85

Calls 6

mallocFunction · 0.85
snprintfFunction · 0.85
process_dirFunction · 0.85
process_fileFunction · 0.70
strlcpyFunction · 0.50
list_add_tailFunction · 0.50

Tested by

no test coverage detected