-static
-void delete_trace(const char *trace_path)
-{
- /* Remove all trace files and delete temporary trace directory */
- struct dirent *entry;
- DIR *trace_dir = opendir(trace_path);
-
- if (!trace_dir) {
- perror("# opendir");
- return;
- }
-
- while ((entry = readdir(trace_dir))) {
- struct stat st;
- char filename[PATH_MAX];
-
- if (snprintf(filename, sizeof(filename), "%s/%s",
- trace_path, entry->d_name) <= 0) {
- continue;
- }
-
- if (stat(filename, &st)) {
- continue;
- }
-
- if (S_ISREG(st.st_mode)) {
- unlinkat(bt_dirfd(trace_dir), entry->d_name, 0);
- }
- }
-
- rmdir(trace_path);
- closedir(trace_dir);
-}
-