| 182 | } |
| 183 | |
| 184 | static void |
| 185 | walktree(struct walk_context *ctx, const char *path, void (*callback)(struct walk_context *ctx)) |
| 186 | { |
| 187 | ctx->callback = callback; |
| 188 | ctx->dir_fd = AT_FDCWD; |
| 189 | ctx->name = path; |
| 190 | |
| 191 | struct walk_context top = *ctx; |
| 192 | top.dir_fd = open(path, O_RDONLY | O_DIRECTORY); |
| 193 | if (top.dir_fd < 0) |
| 194 | die("Cannot open directory %s: %m", path); |
| 195 | |
| 196 | if (fstat(top.dir_fd, &ctx->st) < 0) |
| 197 | die("Cannot stat %s: %m", path); |
| 198 | assert(S_ISDIR(ctx->st.st_mode)); |
| 199 | top.root_dev = ctx->st.st_dev; |
| 200 | |
| 201 | walktree_ctx(&top); |
| 202 | |
| 203 | ctx->is_dir = true; |
| 204 | ctx->callback(ctx); |
| 205 | } |
| 206 | |
| 207 | static void |
| 208 | rmtree_helper(struct walk_context *ctx) |
no test coverage detected
searching dependent graphs…