summaryrefslogtreecommitdiffstats
path: root/src/libcgroup-internal.h
Commit message (Collapse)AuthorAgeFilesLines
* config: don't implicitly import cgroup_config_cleanup_namespace_table(), ↵Lennart Poettering2010-03-261-0/+1
| | | | | | | | this is not K&R C anymore... Signed-off-by: Lennart Poettering <lennart@poettering.net> Acked-by: Dhaval Giani <dhaval.giani@gmail.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* api: don't keep one copy of the mount table per .c fileLennart Poettering2010-03-261-2/+2
| | | | | | | | | | The mount table variables need to be declared in the header file and defined in the .c file. If we don't do that every .o file will end up with its own copy of those variables. Signed-off-by: Lennart Poettering <lennart@poettering.net> Acked-by: Dhaval Giani <dhaval.giani@gmail.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* add const where applicable, drop const where unnecessaryLennart Poettering2010-03-261-1/+1
| | | | | | | | | | | | | | | This patch adds the const qualifier to a number of function arguments (mostly string arguments) so that client libraries can pass their own const strings to the library without having to cast their const'ness away. This also drops a couple of consts where call-by-value is done anyway, and which hence has no effect and just misleads the users and adds unnecessary noise to the signal. After all this is C, not C++. Signed-off-by: Lennart Poettering <lennart@poettering.net> Acked-by: Dhaval Giani <dhaval.giani@gmail.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* Move private definitions to private headerJan Safranek2010-03-211-0/+19
| | | | | | | | | Most of the macro definitions in licgroup.h are internal, let's move them to private header. Applications should not depend on them. The only one really needed is CG_VALUE_MAX, which is used in struct cgroup_stat. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* Remove last_errno from public headerJan Safranek2010-03-081-0/+4
| | | | | | | Remove last_errno from public header, that's why we have cgroup_get_last_errno. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
* libcgroup: Setup the namespace datastructuresDhaval Giani2010-01-071-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch handles the validation of the newer configuration files. Some of the rules to be followed 1. We cannot have more controllers in the namespcae section than already mounted. 2. If more than one controller are mounted at the same point, then they will have the same namespace. In case it is not explicitly mentioned, the subsystems at the mount point will be set to the same namespace. This does not mean that controllers mounted at different points need to have the same namespace. Changes from v4: 1. Changed a variable name from mount to mount_path 2. Added more comments Changes from v3: 1. Removed most of the strdups 2. Fixed return values for errors Changes from v2: 1. mount and namespace keyword cannot come in the same file. Changes from v1: 1. Fix a bug where if a namespace was not defined, we were not exiting 2. Comment the validate namespace function 3. Make some of the variables more descriptive 4. Make namespace thread specific Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Introduce the new namespace keywordDhaval Giani2010-01-071-0/+1
| | | | | | | | | | | | | | | This patch introduces a new keywork NAMESPACE which allow cgroups to be created starting from a certain point as mentioned by the administrator. This is provided via the configuration file. Newer APIs will use this feature. Changes from v1: 1. Attempted to fix the indentation 2. Change a variable name Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* removes copy_name_value_from_rules to wrapperIvana Varekova2009-08-061-0/+2
| | | | | | | | | move copy_name_value_from_rules procedure to wrapper.c file and add the header to libcgroup-internal.h Signed-off-by: Ivana Varekova <varekova@redhat.com> Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add the parser of process name in /etc/cgrules.conf.Ken'ichi Ohmichi2009-06-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * The definations of CGROUP_RULE_MAXKEY and CGROUP_RULE_MAXLINE are moved to libcgroup-internal.h since no one from outside should be using them. Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * Use more safety length of a user name for the buffer "username". * Move the macros min()/max() to src/libcgroup-internal.h for using in src/api.c also. Changelog of v3: ================ * Fix unclear buffer of user by memset(). Changelog of v2: ================ * Remove unnecessary memset(). * Some cleanups. Description: ============ This patch adds the parser of process name in /etc/cgrules.conf. A new rule based on process name is as the following, and the process name is stored into the member "procname" in struct cgroup_rule. <user>:<process name> <controllers> <destination> Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add cgroup_get_procname_from_procfs() for getting a process name.Ken'ichi Ohmichi2009-06-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v6: ================ * Change the returning values of *_get_procname_from_proc*() to integer from charactor pointer. * Clarify the number meaning of string length in cg_get_procname_from_ ~proc_status() Changelog of v5: ================ * Rebase the patch to the latest code. Changelog of v4: ================ * Add the error handling for strdup()'s error. * Reduce strlen() calls. * Make the check code of a process name simple. Changelog of v3: ================ * Move cgroup_get_procname_from_procfs() to libcgroup-internal.h. * Fix unclear buffer of buf_cwd by memset(). * Get a real path of script file by realpath(). Changelog of v2: ================ * It is possible to handle a process, which name length is over than 16 characters, also. Description: ============ This patch adds a new function cgroup_get_procname_from_procfs() for getting a process name. This function allocates the memory for a process name, and writes the name to the memory, and returns the pointer of the memory. So a caller should free the memory if unusing it. The process name, which is wrotten by this function, depends on the specified process: If a command process) the full path of command. If a shell script process) the full path of shell script. If a kernel thread) the process name of kernel thread. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Add flags to the walk_tree handleDhaval Giani2009-06-181-0/+9
| | | | | | | | | | | | | | Introduce a cgroup_tree_handle structure so that we can track flags for the walk_tree operation. In a number of cases we would prefer to walk the tree in postorder as opposed to pre-order which is the current default. This patch does the addition. Changes since V1: 1. Added checks for !handle as suggested by Bharata Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* cgconfigparser: Change mkdir in cgroup_config_mount_fs to mkdir -pDhaval Giani2009-06-181-0/+1
| | | | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=502687 mentioned that the directory was not getting created when a cgconfig start was being run. This is was because we failed the mkdir. The mkdir for directories at depth was not succeeding. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Cleanup: Integrate similar code to cgroup_get_uid_gid_from_procfs().Ken'ichi Ohmichi2009-06-081-0/+2
| | | | | | | | | | | | | | CHANGELOG of v2.1: ================ * Rebase the patch for commit '340feae163c4797a6cb1247b3812c1ccdc52fa41'. There are some similar functions for getting process's data (uid, gid) from /proc/<pid>/status file, so this patch integrates these functions into one cgroup_get_uid_gid_from_procfs(). Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Rename "name" to "username" in struct cgroup_rule.Ken'ichi Ohmichi2009-06-081-1/+1
| | | | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * No change. To add the member "procname" to struct cgroup_rule by later patch, this patch renames the member "name" to "username" for the clarification. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Distribute files to various subdirectoriesJan Safranek2009-03-261-0/+105
Signed-off-by: Jan Safranek <jsafrane@redhat.com>