diff options
author | Jan Safranek <jsafrane@redhat.com> | 2010-03-12 16:50:20 +0100 |
---|---|---|
committer | Dhaval Giani <dhaval.giani@gmail.com> | 2010-03-21 22:02:01 +0100 |
commit | ed0881d91408000d6ea5e4f73b49acf2615df9f9 (patch) | |
tree | 86148053ea4208f9299877444283ef89de4a18de /include/libcgroup/groups.h | |
parent | 4f6e409bad2dfa94a4245f7ea612b91a9baed2b7 (diff) | |
download | libcg-ed0881d91408000d6ea5e4f73b49acf2615df9f9.tar.gz libcg-ed0881d91408000d6ea5e4f73b49acf2615df9f9.tar.xz libcg-ed0881d91408000d6ea5e4f73b49acf2615df9f9.zip |
Split header file III
Changelog:
- since there are no global macros, base.h is gone
- since there is no base.h, all headers need to include <features.h> to get
__BEGIN_DECLS
- new init.h with cgroup_init() and cgroup_get_subsys_mount_point()
- new error.h with error handling enum and related stuff
- use #ifndef _LIBCGROUP_*_H instead _LIBCG_*_H in header guards
- fix few checkpatch complaints (long lines, whitespaces, ...)
The patch includes Makefile and .spec changes. I tested it compiles,
make dist produces tarball with all headers, so does also the rpm.
'make' should automatically catch all changes in new headers and
recompile dependent (=all) sources when any header changes.
libcgroup.h
- does not declare anything, it just includes all the other files. In
future, it might contain base of doxygen documentation (some
introduction etc.)
libcgroup/error.h
- the big enum with errors + error related functions
libcgroup/init.h
- libcgroup_init() and cgroup_get_subsys_mount_point()
libcgroup/config.h
- configuration reading/unloading
libcgroup/groups.h
- group manipulation stuff (create/modify/delete/free, incl. controllers and
get/set values) + definition of struct cgroup (=must be included by
libcgroup/tasks.h, which needs it)
libcgroup/iterators.h
- various walks, *_begin/next/end
libcgroup/tasks.h
- task classification, incl. rules cache manipulation
In addition, I probably removed some #includes, which are not needed now when
looking for the minimal #include set to build the project. I also hope I did not
miss any function declaration or macro...
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Diffstat (limited to 'include/libcgroup/groups.h')
-rw-r--r-- | include/libcgroup/groups.h | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/include/libcgroup/groups.h b/include/libcgroup/groups.h new file mode 100644 index 0000000..ba01011 --- /dev/null +++ b/include/libcgroup/groups.h @@ -0,0 +1,109 @@ +#ifndef _LIBCGROUP_GROUPS_H +#define _LIBCGROUP_GROUPS_H + +#include <features.h> +#include <sys/types.h> +#include <stdbool.h> + +__BEGIN_DECLS + +/** + * Flags for cgroup_delete_cgroup_ext + */ +enum cgroup_delete_flag { + /** + * Ignore errors caused by migration of tasks to parent group. + */ + CGFLAG_DELETE_IGNORE_MIGRATION = 1, + + /** + * Recursively delete all child groups. + */ + CGFLAG_DELETE_RECURSIVE = 2, +}; + +struct cgroup; +struct cgroup_controller; + +int cgroup_modify_cgroup(struct cgroup *cgroup); +int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership); +int cgroup_delete_cgroup(struct cgroup *cgroup, int ignore_migration); +int cgroup_get_cgroup(struct cgroup *cgroup); +int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, + int ignore_ownership); +int cgroup_copy_cgroup(struct cgroup *dst, struct cgroup *src); + +/** + * Delete control group. + * All tasks are automatically moved to parent group. + * If CGFLAG_DELETE_IGNORE_MIGRATION flag is used, the errors that occurred + * during the task movement are ignored. + * CGFLAG_DELETE_RECURSIVE flag specifies that all subgroups should be removed + * too. If root group is being removed with this flag specified, all subgroups + * are removed but the root group itself is left undeleted. + * + * @param cgroup Group to delete. + * @param flags Combination of CGFLAG_DELETE_* flags, which indicate what and + * how to delete. + */ +int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags); + +struct cgroup *cgroup_new_cgroup(const char *name); +struct cgroup_controller *cgroup_add_controller(struct cgroup *cgroup, + const char *name); +void cgroup_free(struct cgroup **cgroup); +void cgroup_free_controllers(struct cgroup *cgroup); +int cgroup_compare_cgroup(struct cgroup *cgroup_a, struct cgroup *cgroup_b); +int cgroup_compare_controllers(struct cgroup_controller *cgca, + struct cgroup_controller *cgcb); +struct cgroup_controller *cgroup_get_controller(struct cgroup *cgroup, + const char *name); + +int cgroup_add_value_string(struct cgroup_controller *controller, + const char *name, const char *value); +int cgroup_add_value_int64(struct cgroup_controller *controller, + const char *name, int64_t value); +int cgroup_add_value_uint64(struct cgroup_controller *controller, + const char *name, u_int64_t value); +int cgroup_add_value_bool(struct cgroup_controller *controller, + const char *name, bool value); +int cgroup_set_uid_gid(struct cgroup *cgroup, uid_t tasks_uid, gid_t tasks_gid, + uid_t control_uid, gid_t control_gid); +int cgroup_get_uid_gid(struct cgroup *cgroup, uid_t *tasks_uid, + gid_t *tasks_gid, uid_t *control_uid, gid_t *control_gid); +int cgroup_get_value_string(struct cgroup_controller *controller, + const char *name, char **value); +int cgroup_set_value_string(struct cgroup_controller *controller, + const char *name, const char *value); +int cgroup_get_value_int64(struct cgroup_controller *controller, + const char *name, int64_t *value); +int cgroup_set_value_int64(struct cgroup_controller *controller, + const char *name, int64_t value); +int cgroup_get_value_uint64(struct cgroup_controller *controller, + const char *name, u_int64_t *value); +int cgroup_set_value_uint64(struct cgroup_controller *controller, + const char *name, u_int64_t value); +int cgroup_get_value_bool(struct cgroup_controller *controller, + const char *name, bool *value); +int cgroup_set_value_bool(struct cgroup_controller *controller, + const char *name, bool value); +/** + * Return the number of variables for the specified controller, if the + * structure does not exist -1 is returned + * @param controller Name of the controller for which stats are requested. + */ +int cgroup_get_value_name_count(struct cgroup_controller *controller); + +/** + * Return the "index" variable for the specified controller, + * the return value is the pointer to the internal structure so + * don't dealocate it, or change the content of the memory space. + * @param controller Name of the controller for which stats are requested. + * @param index number of the variable. + */ +char *cgroup_get_value_name(struct cgroup_controller *controller, int index); + + +__END_DECLS + +#endif /* _LIBCGROUP_GROUPS_H */ |