diff options
Diffstat (limited to 'src/tools/tools-common.h')
-rw-r--r-- | src/tools/tools-common.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h new file mode 100644 index 0000000..3437973 --- /dev/null +++ b/src/tools/tools-common.h @@ -0,0 +1,54 @@ +/* + * Copyright Red Hat, Inc. 2009 + * + * Author: Vivek Goyal <vgoyal@redhat.com> + * Jan Safranek <jsafrane@redhat.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef __TOOLS_COMMON + +#define __TOOLS_COMMON + +#include "config.h" +#include <libcgroup.h> + +#ifdef CGROUP_DEBUG +#define cgroup_dbg(x...) printf(x) +#else +#define cgroup_dbg(x...) do {} while (0) +#endif + +/** + * Auxiliary specifier of group, used to store parsed command line options. + */ +struct cgroup_group_spec { + char path[FILENAME_MAX]; + char *controllers[CG_CONTROLLER_MAX]; +}; + + +/** + * Parse command line option with group specifier into provided data structure. + * The option must have form of 'controller1,controller2,..:group_name'. + * + * The parsed list of controllers and group name is added at the end of + * provided cdptr. + * + * @param cdptr Target data structure to fill. New item is allocated and added + * at the end. + * @param optarg Argument to parse. + * @return 0 on success, != 0 on error. + */ +int parse_cgroup_spec(struct cgroup_group_spec *cdptr[], char *optarg); + + +#endif /* TOOLS_COMMON */ |