| 52 | } |
| 53 | |
| 54 | static void |
| 55 | process_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 | |
| 85 | static const struct dt_dir * |
| 86 | node2dir(const struct device_node *n) |
no test coverage detected