op_file.h File Reference

#include <sys/types.h>
Include dependency graph for op_file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* get_pathname_callback )(char const *pathname, void *name_list)

Enumerations

enum  recursion_type { NO_RECURSION = 2, MATCH_ANY_ENTRY_RECURSION = 4, MATCH_DIR_ONLY_RECURSION = 8 }

Functions

int op_file_readable (char const *file)
time_t op_get_mtime (char const *file)
int create_dir (char const *dir)
int create_path (char const *path)
int get_matching_pathnames (void *name_list, get_pathname_callback, char const *base_dir, char const *filter, enum recursion_type recursion)

Detailed Description

Useful file management helpers

Remarks:
Copyright 2002 OProfile authors
Read the file COPYING
Author:
John Levon
Philippe Elie

Definition in file op_file.h.


Typedef Documentation

typedef void(* get_pathname_callback)(char const *pathname, void *name_list)

Clients of get_matching_pathnames must provide their own implementation of get_pathname_callback.

Definition at line 64 of file op_file.h.


Enumeration Type Documentation

Enumerator:
NO_RECURSION 
MATCH_ANY_ENTRY_RECURSION 
MATCH_DIR_ONLY_RECURSION 

Definition at line 68 of file op_file.h.


Function Documentation

int create_dir ( char const *  dir  ) 

create_dir - create a directory

Parameters:
dir the directory name to create

Returns 0 on success.

Definition at line 44 of file op_file.c.

Referenced by check_and_create_config_dir(), and create_path().

Here is the caller graph for this function:

int create_path ( char const *  path  ) 

create_path - create a path

Parameters:
path the path to create

create directory for each dir components in path the last path component is not considered as a directory but as a filename

Returns 0 on success.

Definition at line 57 of file op_file.c.

References create_dir().

Referenced by opd_open_24_sample_file(), opd_open_sample_file(), and operf_open_sample_file().

Here is the call graph for this function:

Here is the caller graph for this function:

int get_matching_pathnames ( void *  name_list,
get_pathname_callback  ,
char const *  base_dir,
char const *  filter,
enum recursion_type  recursion 
)
Parameters:
name_list where to store result
get_pathname_callback client-provided callback function
base_dir directory from where lookup starts
filter a pathname filter
recursion recursion_type -- see above enum and following description: NO_RECURSION: Find matching files from passed base_dir and call get_pathname_callback to add entry to name_list to be returned. MATCH_ANY_ENTRY_RECURSION: Starting at base_dir, for each entry in the dir that matches the filter: if entry is of type 'dir', recurse; else call get_pathname_callback to add entry to name_list to be returned. MATCH_DIR_ONLY_RECURSION: Starting at base_dir, if an entry in the dir is of type 'dir' and its complete pathname contains a match to the filter, call get_pathname_callback to add entry to name_list to be returned; else recurse.

Returns 0 on success.

Return a list of pathnames under base_dir, filtered by filter and optionally looking in sub-directory. See description above of the recursion_type parameter for more details. NOTE: For C clients: Your implementation of the get_pathname_callback function will probably dynamically allocate storage for elements added to name_list. If so, remember to free that memory when it's no longer needed.

Definition at line 115 of file op_file.c.

References get_matching_pathnames(), is_dot_or_dotdot(), make_pathname_from_dirent(), MATCH, MATCH_ANY_ENTRY_RECURSION, MATCH_DIR_ONLY_RECURSION, NO_MATCH, and NO_RECURSION.

Referenced by create_file_list(), get_matching_pathnames(), and op_process_jit_dumpfiles().

Here is the call graph for this function:

Here is the caller graph for this function:

int op_file_readable ( char const *  file  ) 

op_file_readable - is a file readable

Parameters:
file file name

Return true if the given file is readable and regular.

Beware of race conditions !

Definition at line 26 of file op_file.c.

Referenced by copy_file(), op_file_readable(), op_file_readable_tests(), op_get_interface(), op_write_lock_file(), oprof_start::oprof_start(), and oprof_start::save_config().

Here is the caller graph for this function:

time_t op_get_mtime ( char const *  file  ) 

op_get_mtime - get mtime of file

Parameters:
file file name

Returns the mtime of the given file or 0 on failure

Definition at line 33 of file op_file.c.

Referenced by check_mtime(), opd_new_image(), opd_open_sample_file(), and operf_open_sample_file().

Here is the caller graph for this function:


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1