view _lxcstats.h @ 4:50215911acb3

Add a strsplit() function and stop to build probes into a separate library
author Louis Opter <louis@dotcloud.com>
date Sat, 01 Jan 2011 16:01:19 +0100
parents 2cb8a6cbe468
children e2b88f50e136
line wrap: on
line source

#ifndef _LXC_STATS_PRIV_H_
# define _LXC_STATS_PRIV_H_

# include "compat/compat.h"
# include "probes/probes.h"

# define NSEC_PER_SEC 1000000000L

struct      dirent;

/**
 * Store all informations needed to get statistics from a cgroup
 * hierarchy.
 */
struct      _lxcst_controller {
    char    *cgroup_dir; /**< Mount point of the cgroup hierarchy. */
};

/**
 * Allocate a new lxcst structure for the given container.
 */
struct lxcst    *_lxcst_container_new(struct _lxcst_controller *, const char *);

/**
 * Free a lxcst structure.
 */
void            _lxcst_container_delete(struct lxcst *);

/**
 * Get statistics on a container.
 */
int             _lxcst_container_read_infos(struct lxcst *);

char            *_lxcst_join_path(char *, size_t , const char *, const char *);

/**
 * Used to select only directories with scandir. We can't directly use it with
 * scandir because we need the cgroup_dir.
 *
 * @return true if the given directory entry is a directory.
 */
int             _lxcst_isdir(const struct _lxcst_controller *, const struct dirent *);

/**
 * Allocate a buffer and read an entire file in it.
 *
 * @param [in] path Path to the file to read
 * @param [out] content A pointer to a pointer which will hold the allocated
 * buffer.
 *
 * @return The size of the buffer on sucess, -1 with errno set otherwise.
 */
ssize_t         _lxcst_read_file(const char *path, char **content);

/**
 * Split a string around spaces (defined by isspace()).
 *
 * @param [in] str The string to split, spaces are erased with '\0'.
 * @param [out] fields An array of string, each entry will point to a word of
 * the string.
 * @param [in] nfields Number of entries into the fields array.
 *
 * @return The number of fields found.
 */
int             _lxcst_strsplit(char *str, char **fields, size_t nfields);

#endif