libtracefs(3)

# libtracefs(3) Manual Page

## NAME

tracefs_event_get_file, tracefs_event_file_read, tracefs_event_file_write, tracefs_event_file_append, tracefs_event_file_clear, tracefs_event_file_exists - Work with trace event files.

## SYNOPSIS

    #include <tracefs.h>

    char *tracefs_event_get_file(struct tracefs_instance *instance, const char *system, const char *event,
                                 const char *file);
    char *tracefs_event_file_read(struct tracefs_instance *instance, const char *system, const char *event,
                                  const char *file, int *psize);
    int tracefs_event_file_write(struct tracefs_instance *instance, const char *system, const char *event,
                                 const char *file, const char *str);
    int tracefs_event_file_append(struct tracefs_instance *instance, const char *system, const char *event,
                                  const char *file, const char *str);
    int tracefs_event_file_clear(struct tracefs_instance *instance, const char *system, const char *event,
                                 const char *file);
    bool tracefs_event_file_exists(struct tracefs_instance *instance, const char *system, const char *event,
                                   const char *file)

## DESCRIPTION

These are functions for accessing tracefs event specific files. These functions act similar to the tracefs instance file functions but are easier to get to if the system and events are known before hand.

The tracefs_event_get_file() returns the full path of the file for the given system and event that is within the given instance. If instance is NULL, then the file for the event for the top level instance is returned. Note, there is no check to see if the file actually exists or even if the system and event exist. It only creates the path name for such an event if it did exist. This acts similar to the tracefs_instance_get_file(3), but is to be used to get to event files if the system and event are already known.

The tracefs_event_file_read() reads the content for the event file for the given instance or the top level instance if instance is NULL. The content of the file is returned and psize is set to the amount of data that was read. The returned content must be freed with free(3). This acts similar to the tracefs_instance_file_read(3), but is to be used to read the event file if the system and event are already known.

The tracefs_event_file_write() writes str to the event file. It will truncate anything that is already in that file. This acts similar to the tracefs_instance_file_write(3), but is to be used to read the event file if the system and event are already known.

The tracefs_event_file_append() appends str to the event file. It will not clear out the file as it writes sting. This acts similar to the tracefs_instance_file_append(3), but is to be used to read the event file if the system and event are already known.

The tracefs_event_file_clear() clears the content of the event file. This acts similar to the tracefs_instance_file_clear(3), but is to be used to read the event file if the system and event are already known.

The tracefs_event_file_exists() returns true if the event file exists, and false otherwise. This acts similar to the tracefs_instance_file_exists(3), but is to be used to read the event file if the system and event are already known.

## RETURN VALUE

tracefs_event_get_file() returns the path of the given system/event file on success and NULL on error. The return value must be freed with tracefs_put_tracing_file(3).

tracefs_event_file_read() reads the content of the system/event file or NULL on error. The return pointer must be freed with free(3).

tracefs_event_file_write() and tracefs_event_file_append() returns the number of bytes written to the system/event file or negative on error.

tracefs_event_file_clear() returns zero on success and -1 on error.

tracefs_event_file_exists() returns true if the system/event file exists for the given instance (or top level if instance is NULL) or false otherwise.

## EXAMPLE

## FILES

    tracefs.h
            Header file to include in order to have access to the library APIs.
    -ltracefs
            Linker switch to add when building a program that uses the library.

## SEE ALSO

libtracefs(3), libtraceevent(3), trace-cmd(1)

## AUTHOR

    Steven Rostedt <rostedt@goodmis.org>

## REPORTING BUGS

Report bugs to <linux-trace-devel@vger.kernel.org>

## LICENSE

libtracefs is Free Software licensed under the GNU LGPL 2.1

## RESOURCES

https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/

## COPYING

Copyright (C) 2022 Google, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).