Mercurial > archived > louis > perso > liblxcstats
view open.c @ 12:dbf24a82f625 default tip
Fix doxygen comments and add a Doxyfile
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Fri, 07 Jan 2011 21:49:31 +0100 |
parents | 8339ab15527d |
children |
line wrap: on
line source
#include <errno.h> #include <stdbool.h> #include <stdio.h> #include <mntent.h> #include <stdlib.h> #include <string.h> #include "_lxcstats.h" #include "lxcstats.h" static char * lxcst_cgroup_mount_point(void) { FILE *mtab; struct mntent mntbuf; char strbuf[1024]; bool found = false; mtab = fopen("/etc/mtab", "r"); if (!mtab) return (NULL); while (getmntent_r(mtab, &mntbuf, strbuf, sizeof(strbuf))) { if (!strcmp(mntbuf.mnt_type, "cgroup")) { found = true; break ; } } fclose(mtab); if (found) return (strdup(mntbuf.mnt_dir)); errno = ENOENT; return (NULL); } lxcst_handle *lxcst_open(void) { struct _lxcst_controller *c; c = calloc(1, sizeof(*c)); if (!c) return (NULL); c->cgroup_dir = lxcst_cgroup_mount_point(); if (!c->cgroup_dir) goto free_controller; c->lxc_dir = LXC_DIR; return (c); free_controller: free(c); return (NULL); }