tools/perf/util/tracepoint.c
Source file repositories/reference/linux-study-clean/tools/perf/util/tracepoint.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/tracepoint.c- Extension
.c- Size
- 1160 bytes
- Lines
- 53
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
tracepoint.herrno.hfcntl.hstdio.hstdlib.hsys/param.hunistd.hapi/fs/tracing_path.hfncache.h
Detected Declarations
function tp_event_has_idfunction is_valid_tracepoint
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include "tracepoint.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/param.h>
#include <unistd.h>
#include <api/fs/tracing_path.h>
#include "fncache.h"
int tp_event_has_id(const char *dir_path, struct dirent *evt_dir)
{
char evt_path[MAXPATHLEN];
int fd;
snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, evt_dir->d_name);
fd = open(evt_path, O_RDONLY);
if (fd < 0)
return -EINVAL;
close(fd);
return 0;
}
/*
* Check whether event is in <debugfs_mount_point>/tracing/events
*/
bool is_valid_tracepoint(const char *event_string)
{
char *dst, *path = malloc(strlen(event_string) + 4); /* Space for "/id\0". */
bool have_file = false; /* Conservatively return false if memory allocation failed. */
const char *src;
if (!path)
return false;
/* Copy event_string replacing the ':' with '/'. */
for (src = event_string, dst = path; *src; src++, dst++)
*dst = (*src == ':') ? '/' : *src;
/* Add "/id\0". */
memcpy(dst, "/id", 4);
dst = get_events_file(path);
if (dst)
have_file = file_available(dst);
free(dst);
free(path);
return have_file;
}
Annotation
- Immediate include surface: `tracepoint.h`, `errno.h`, `fcntl.h`, `stdio.h`, `stdlib.h`, `sys/param.h`, `unistd.h`, `api/fs/tracing_path.h`.
- Detected declarations: `function tp_event_has_id`, `function is_valid_tracepoint`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.