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

Function process_file

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

Source from the content-addressed store, hash-verified

52}
53
54static void
55process_file(struct dirent *dent, struct dt_dir *parent)
56{
57 int fd;
58 struct dt_file *f = malloc(sizeof(*f));
59
60 if (!f) {
61 DPAAX_LOG(DEBUG, "Unable to allocate memory for file node");
62 return;
63 }
64 f->node.is_file = 1;
65 strlcpy(f->node.node.name, dent->d_name, NAME_MAX);
66 snprintf(f->node.node.full_name, PATH_MAX, "%s/%s",
67 parent->node.node.full_name, dent->d_name);
68 f->parent = parent;
69 fd = of_open_file(f->node.node.full_name);
70 if (fd < 0) {
71 DPAAX_LOG(DEBUG, "Unable to open file node");
72 free(f);
73 return;
74 }
75 f->len = read(fd, f->buf, OF_FILE_BUF_MAX);
76 close(fd);
77 if (f->len < 0) {
78 DPAAX_LOG(DEBUG, "Unable to read file node");
79 free(f);
80 return;
81 }
82 list_add_tail(&f->node.list, &parent->files);
83}
84
85static const struct dt_dir *
86node2dir(const struct device_node *n)

Callers 1

iterate_dirFunction · 0.70

Calls 8

mallocFunction · 0.85
snprintfFunction · 0.85
of_open_fileFunction · 0.85
strlcpyFunction · 0.50
freeFunction · 0.50
readFunction · 0.50
closeFunction · 0.50
list_add_tailFunction · 0.50

Tested by

no test coverage detected