dtrace_provider_modules - Retrieve the list of DTrace provider modules
cc [ flag... ] file... -ldtrace [ library... ] #include <dtrace.h> int dtrace_provider_modules(dtrace_hdl_t *dtp, const char **mods, int nmods)
The dtrace_provider_modules() function retrieves the list of kernel modules functioning as DTrace providers. The function writes at most nmods module names into the array, mods.
On successful completion, the dtrace_provider_modules() function returns the number of DTrace provider modules. Otherwise the function returns -1, and sets an error number to indicate the error. The error number can be retrieved with the dtrace_errno(3DTRACE)) function.
The dtrace_provider_modules() function will fail if:
The dtp or the mods argument is NULL.
The following example shows how the dtrace_provider_modules() function prints the list of loaded kernel modules functioning as DTrace providers:
#include <dtrace.h> #include <stdio.h> #include <stdlib.h> static dtrace_hdl_t *g_dtp; static void fatal(const char *fmt, ...) { va_list ap; va_start(ap, fmt); (void) vfprintf(stderr, fmt, ap); if (fmt[strlen(fmt) - 1] != '\n') (void) fprintf(stderr, ": %s\n", dtrace_errmsg(g_dtp, dtrace_errno(g_dtp))); exit(EXIT_FAILURE); } int main(int argc, char **argv) { int err, i; const char *mods[20]; int nmods; if ((g_dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) fatal("cannot open dtrace library: %s\n", dtrace_errmsg(NULL, err)); if ((nmods = dtrace_provider_modules(g_dtp, mods, sizeof (mods) / sizeof (char *))) < 0) fatal("dtrace_provider_modules()"); printf("nmods == %d\n", nmods); for (i = 0; i < nmods; i++) printf("Module: %s\n", mods[i]); dtrace_close(g_dtp); return (0); }
See attributes(7) for descriptions of the following attributes:
|