summaryrefslogtreecommitdiffstats
path: root/api.c
Commit message (Collapse)AuthorAgeFilesLines
* Distribute files to various subdirectoriesJan Safranek2009-03-261-2320/+0
| | | | Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Fix of the return valuesIvana Varekova2009-03-261-5/+10
| | | | | | | This patch fixes a few error values in api.c file. Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Removed unused functions from api.cDhaval Giani2009-03-041-45/+0
| | | | | | | | | | api.c: At top level: api.c:1780: warning: ‘cg_prepare_controller_array’ defined but not used api.c:1805: warning: ‘cg_free_controller_array’ defined but not used Turns out no one is using this functions. Remove them. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Fix unused variable warnings for the walk_tree APIDhaval Giani2009-03-041-2/+0
| | | | | | | | | | | | api.c: In function ‘cg_walk_node’: api.c:2252: warning: unused variable ‘base_level’ api.c: In function ‘cgroup_walk_tree_end’: api.c:2314: warning: unused variable ‘ret’ Fix the above warnings. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
* libcgroup: Check if the data structures have been initialized for walk_treeDhaval Giani2009-03-041-0/+12
| | | | | | | | The test for cgroup_init() was not being done by the walk tree APIs. With this it is possible for it to run without cgroup_init() being called and having mysterious failures. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Feature: Provide new libcgroup walk tree APIDhaval Giani2009-02-281-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From: Balbir Singh <balbir@linux.vnet.ibm.com> Changelog v3..v4 1. Add _end() method for the iterator Changelog v3..v2 1. Move to iterator based design Changelog v2..v1 1. Add base path and depth semantics for walking This patch adds the capability to walk cgroups by providing a new API called cgroup_walk_tree. The API accepts the controller to walk and the order in which the directories and files must be visited. The code is implemented as an iterator, the begin function starts the walk and we have depth control. The next function gets the following node and returns ECGEOF when done. libcgroup.map has been updated to reflect the same change and the prototype is exported in libcgroup.h. I've also added test cases (tests/walk_test.c). Sample output is show root is /cgroup/cpu/// path , parent , relative /, full /cgroup/cpu/// path l3, parent , relative /l3, full /cgroup/cpu///l3 path ll1, parent l3, relative /l3/ll1, full /cgroup/cpu///l3/ll1 path lll1, parent ll1, relative /l3/ll1/lll1, full /cgroup/cpu///l3/ll1/lll1 path l2, parent , relative /l2, full /cgroup/cpu///l2 path ll1, parent l2, relative /l2/ll1, full /cgroup/cpu///l2/ll1 path lll1, parent ll1, relative /l2/ll1/lll1, full /cgroup/cpu///l2/ll1/lll1 path l1, parent , relative /l1, full /cgroup/cpu///l1 path ll1, parent l1, relative /l1/ll1, full /cgroup/cpu///l1/ll1 path lll1, parent ll1, relative /l1/ll1/lll1, full /cgroup/cpu///l1/ll1/lll1 path a, parent , relative /a, full /cgroup/cpu///a path e, parent a, relative /a/e, full /cgroup/cpu///a/e path f, parent e, relative /a/e/f, full /cgroup/cpu///a/e/f path f, parent a, relative /a/f, full /cgroup/cpu///a/f path x, parent a, relative /a/x, full /cgroup/cpu///a/x path b, parent a, relative /a/b, full /cgroup/cpu///a/b path c, parent b, relative /a/b/c, full /cgroup/cpu///a/b/c path d, parent c, relative /a/b/c/d, full /cgroup/cpu///a/b/c/d path default, parent , relative /default, full /cgroup/cpu///default root is /cgroup/cpu//a/ path , parent , relative /, full /cgroup/cpu//a/ path e, parent , relative /e, full /cgroup/cpu//a/e path f, parent e, relative /e/f, full /cgroup/cpu//a/e/f path f, parent , relative /f, full /cgroup/cpu//a/f path x, parent , relative /x, full /cgroup/cpu//a/x path b, parent , relative /b, full /cgroup/cpu//a/b path c, parent b, relative /b/c, full /cgroup/cpu//a/b/c Walking the first 5 nodes root is /cgroup/cpu/// path , parent , relative /, full /cgroup/cpu/// path l3, parent , relative /l3, full /cgroup/cpu///l3 path ll1, parent l3, relative /l3/ll1, full /cgroup/cpu///l3/ll1 path lll1, parent ll1, relative /l3/ll1/lll1, full /cgroup/cpu///l3/ll1/lll1 NOTE: Parent directory is represented by an empty (not NULL) string "". The length of the string is 0. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@356 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Rename dbg() to cgroup_dbg()Dhaval Giani2009-02-251-66/+75
| | | | | | | | | | | | | From: Jan Safranek <jsafrane@redhat.com> Rename dbg() to cgroup_dbg() everywhere. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@345 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgorup: Fix a chown security issueDhaval Giani2009-02-211-7/+9
| | | | | | | | | | | | | | | | | | | | From: Balbir Singh <balbir@linux.vnet.ibm.com> Impact: Bug fix causes incorrect chown This patch fixes a potential security issue, we free path and add reallocate it using asprintf, but that breaks chown, since that relies on fts_path[0] and path to point to the same address location. Please review, comment. [dhaval@linux.vnet.ibm.com: Fixed the return checks] Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@335 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix return valuesDhaval Giani2009-02-211-4/+11
| | | | | | | | | | | | | | | | | From: Balbir Singh <balbir@linux.vnet.ibm.com> Impact: Bug fix, fix incorrect return values This patch fixes incorrect return value of -1 being returned from some call sites. Please review, comment. printf's are ugly, so they've been converted to dbg. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@334 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* This patch store the last errno value to last_errno value and addBalbir Singh2009-02-161-8/+62
| | | | | | | | | | | | cgroup_add_last_errno procedure to show this number. Use this procedure to show the cause of the error when ECGOTHER is returned. [balbir@linux.vnet.ibm.com: fix last_errno in config.c] Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@329 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Rename DEBUG to CGROUP_DEBUGDhaval Giani2009-02-161-1/+1
| | | | | | | | | | | | | | From: Jan Safranek <jsafrane@redhat.com> Using plain DEBUG can be dangerous, it might have side effects on different libraries, there should be something with CGROUP_ prefix. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@325 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix low hanging cleanupsDhaval Giani2009-01-061-38/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the cleanups possible are obvious. 1. Change usage of strcat to strncat 2. Change usage of tge following type char *s = malloc(); strcpy(s, "somestring"); strcat(s, "someotherstring"); to something more easily understandble such as asprintf(&s, "%s%s", somestring, someotherstring); Changes for v2: 1. Fix some memory leaks discovered using valgrind 2. Fix Balbir's comments regarding codingstyle. 3. Move the controllers array memory leak fix into another patch Changes from v1: 1. Correct the error handling of asprintf as pointed out by Dan Smith TODO: 1. Figure out what is the correct value of n for cg_build_path_locked valgrind output, [root@gondor tests]# sh runlibcgrouptest.sh Running first set of testcases ============================== ==5067== Memcheck, a memory error detector. ==5067== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==5067== Using LibVEX rev 1804, a library for dynamic binary translation. ==5067== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==5067== Using valgrind-3.3.0, a dynamic binary instrumentation framework. ==5067== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==5067== For more details, rerun with: -v ==5067== C:DBG: fs_mounted as recieved from script=0 TEST 1:PASS : cgroup_init() Ret Value = 50001 TEST 2:PASS : cgroup_attach_task() Ret Value = 50014 Parameter nullcgroup TEST 3:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 4:PASS : cgroup_create_cgroup() Ret Value = 50014 TEST 5:PASS : cgroup_delete_cgroup() Ret Value = 50014 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 50014 TEST 7:PASS : cgroup_delete_cgroup() Ret Value = 50014 TEST 8:PASS : cgroup_add_controller() Ret Value = 0 TEST 9:PASS : cgroup_add_controller() Ret Value = 0 TEST10:PASS : cgroup_add_controller() Ret Value = 0 ==5067== ==5067== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 1) ==5067== malloc/free: in use at exit: 0 bytes in 0 blocks. ==5067== malloc/free: 18 allocs, 18 frees, 32,293 bytes allocated. ==5067== For counts of detected errors, rerun with: -v ==5067== All heap blocks were freed -- no leaks are possible. Running second set of testcases ============================== ==5083== Memcheck, a memory error detector. ==5083== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==5083== Using LibVEX rev 1804, a library for dynamic binary translation. ==5083== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==5083== Using valgrind-3.3.0, a dynamic binary instrumentation framework. ==5083== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==5083== For more details, rerun with: -v ==5083== C:DBG: fs_mounted as recieved from script=1 C:DBG: mountpoint1 as recieved from script=/dev/cgroup_controllers-1 sanity check pass. cgroup TEST 1:PASS : cgroup_attach_task() Ret Value = 50014 Parameter nullcgroup TEST 2:PASS : cgroup_init() Ret Value = 0 TEST 3:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST 4:PASS : cgroup_attach_task_pid() Ret Value = 50016 TEST 5:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 7:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x40070D8: strncat (mc_replace_strmem.c:214) ==5083== by 0x804BC92: main (libcgrouptest01.c:1271) ==5083== at 0x40070D8: strncat (mc_replace_strmem.c:214) ==5083== by 0x804BC92: main (libcgrouptest01.c:1271) ==5083== ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x8049471: _ZL14group_modifiedPci (libcgrouptest01.c:1076) ==5083== by 0x804C583: main (libcgrouptest01.c:254) ==5083== ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x8049479: _ZL14group_modifiedPci (libcgrouptest01.c:1076) ==5083== by 0x804C583: main (libcgrouptest01.c:254) ==5083== ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x4007470: strncmp (mc_replace_strmem.c:314) ==5083== by 0x804949B: _ZL14group_modifiedPci (libcgrouptest01.c:1076) ==5083== by 0x804C583: main (libcgrouptest01.c:254) ==5083== ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x4007475: strncmp (mc_replace_strmem.c:314) ==5083== by 0x804949B: _ZL14group_modifiedPci (libcgrouptest01.c:1076) ==5083== by 0x804C583: main (libcgrouptest01.c:254) ==5083== ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x4007497: strncmp (mc_replace_strmem.c:314) ==5083== by 0x804949B: _ZL14group_modifiedPci (libcgrouptest01.c:1076) ==5083== by 0x804C583: main (libcgrouptest01.c:254) ==5083== ==5083== Conditional jump or move depends on uninitialised value(s) ==5083== at 0x40074A0: strncmp (mc_replace_strmem.c:314) ==5083== by 0x804949B: _ZL14group_modifiedPci (libcgrouptest01.c:1076) ==5083== by 0x804C583: main (libcgrouptest01.c:254) TEST 8:FAIL : cgroup_modify_cgroup() Ret Value = 0 Parameter same cgroup TEST 9:PASS : cgroup_new_cgroup() Ret Value = 0 TEST10:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST11:PASS : cgroup_modify_cgroup() Ret Value = 50007 TEST12:PASS : cgroup_new_cgroup() Ret Value = 0 TEST13:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST14:PASS : cgroup_get_cgroup() Ret Value = 50007 Parameter nullcgroup TEST15:PASS : cgroup_get_cgroup() Ret Value = 50002 Parameter not created group TEST16:PASS : cgroup_get_cgroup() Ret Value = 0 TEST 0:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 0:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST17:FAIL : cgroup_get_cgroup() Ret Value = 50017 TEST16:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST17:PASS : cgroup_create_cgroup() Ret Value = 50007 TEST18:PASS : cgroup_delete_cgroup() Ret Value = 50007 TEST19:PASS : cgroup_compare_cgroup() Ret Value = 50011 Parameter nullcgroup TEST20:PASS : cgroup_compare_cgroup() Ret Value = 0 TEST21:PASS : cgroup_compare_cgroup() Ret Value = 50017 ==5083== ==5083== ERROR SUMMARY: 9 errors from 7 contexts (suppressed: 18 from 1) ==5083== malloc/free: in use at exit: 0 bytes in 0 blocks. ==5083== malloc/free: 279 allocs, 279 frees, 237,968 bytes allocated. ==5083== For counts of detected errors, rerun with: -v ==5083== All heap blocks were freed -- no leaks are possible. Cleanup done Running third set of testcases ============================== ==5134== Memcheck, a memory error detector. ==5134== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==5134== Using LibVEX rev 1804, a library for dynamic binary translation. ==5134== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==5134== Using valgrind-3.3.0, a dynamic binary instrumentation framework. ==5134== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==5134== For more details, rerun with: -v ==5134== C:DBG: fs_mounted as recieved from script=2 C:DBG: mountpoint1 as recieved from script=/dev/cgroup_controllers-1 C:DBG: mountpoint2 as recieved from script=/dev/cgroup_controllers-2 sanity check pass. cgroup TEST 1:PASS : cgroup_init() Ret Value = 0 TEST 2:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST 3:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 4:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 5:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 5:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 7:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 8:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST 9:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST10:PASS : cgroup_new_cgroup() Ret Value = 0 TEST11:PASS : cgroup_attach_task() Ret Value = 50002 Parameter not created group TEST12:PASS : cgroup_new_cgroup() Ret Value = 0 TEST13:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST14:PASS : cgroup_new_cgroup() Ret Value = 0 TEST15:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST16:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST17:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST18:PASS : cgroup_new_cgroup() Ret Value = 0 TEST19:PASS : cgroup_create_cgroup() Ret Value = 0 group found under both controllers TEST20:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST21:PASS : cgroup_new_cgroup() Ret Value = 0 TEST22:PASS : cgroup_modify_cgroup() Ret Value = 0 group modified under both controllers TEST23:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST 0:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 0:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST24:FAIL : cgroup_get_cgroup() Ret Value = 50018 ==5134== ==5134== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 1) ==5134== malloc/free: in use at exit: 66,044 bytes in 15 blocks. ==5134== malloc/free: 279 allocs, 264 frees, 232,094 bytes allocated. ==5134== For counts of detected errors, rerun with: -v ==5134== searching for pointers to 15 not-freed blocks. ==5134== checked 6,381,388 bytes. ==5134== ==5134== 66,044 (18,064 direct, 47,980 indirect) bytes in 4 blocks are definitely lost in loss record 1 of 3 ==5134== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==5134== by 0x4030DAA: cgroup_new_cgroup (wrapper.c:28) ==5134== by 0x8049656: new_cgroup(char*, char*, char*, int, int) (libcgrouptest01.c:1132) ==5134== by 0x8049917: create_new_cgroup_ds(int, char const*, int, int) (libcgrouptest01.c:744) ==5134== by 0x804C190: main (libcgrouptest01.c:485) ==5134== ==5134== ==5134== 20,980 bytes in 5 blocks are indirectly lost in loss record 2 of 3 ==5134== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==5134== by 0x4030C3C: cgroup_add_value_string (wrapper.c:122) ==5134== by 0x8048FDB: _ZL17add_control_valueP17cgroup_controllerPcS1_i (libcgrouptest01.c:1113) ==5134== by 0x80496C9: new_cgroup(char*, char*, char*, int, int) (libcgrouptest01.c:1147) ==5134== by 0x8049917: create_new_cgroup_ds(int, char const*, int, int) (libcgrouptest01.c:744) ==5134== by 0x804C190: main (libcgrouptest01.c:485) ==5134== ==5134== ==5134== 27,000 bytes in 6 blocks are indirectly lost in loss record 3 of 3 ==5134== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==5134== by 0x4030F5B: cgroup_add_controller (wrapper.c:62) ==5134== by 0x80496AE: new_cgroup(char*, char*, char*, int, int) (libcgrouptest01.c:1144) ==5134== by 0x8049917: create_new_cgroup_ds(int, char const*, int, int) (libcgrouptest01.c:744) ==5134== by 0x804C190: main (libcgrouptest01.c:485) ==5134== ==5134== LEAK SUMMARY: ==5134== definitely lost: 18,064 bytes in 4 blocks. ==5134== indirectly lost: 47,980 bytes in 11 blocks. ==5134== possibly lost: 0 bytes in 0 blocks. ==5134== still reachable: 0 bytes in 0 blocks. ==5134== suppressed: 0 bytes in 0 blocks. Cleanup done [root@gondor tests]# Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@302 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix a few of the valgrind issuesDhaval Giani2009-01-051-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the leaks reported by valgrind in the library. The valgrind output after this patch is applied is, [root@gondor tests]# sh runlibcgrouptest.sh Running first set of testcases ============================== ==14406== Memcheck, a memory error detector. ==14406== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==14406== Using LibVEX rev 1804, a library for dynamic binary translation. ==14406== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==14406== Using valgrind-3.3.0, a dynamic binary instrumentation framework. ==14406== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==14406== For more details, rerun with: -v ==14406== C:DBG: fs_mounted as recieved from script=0 TEST 1:PASS : cgroup_init() Ret Value = 50001 TEST 2:PASS : cgroup_attach_task() Ret Value = 50014 Parameter nullcgroup TEST 3:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 4:PASS : cgroup_create_cgroup() Ret Value = 50014 TEST 5:PASS : cgroup_delete_cgroup() Ret Value = 50014 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 50014 TEST 7:PASS : cgroup_delete_cgroup() Ret Value = 50014 TEST 8:PASS : cgroup_add_controller() Ret Value = 0 TEST 9:PASS : cgroup_add_controller() Ret Value = 0 TEST10:PASS : cgroup_add_controller() Ret Value = 0 ==14406== ==14406== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 1) ==14406== malloc/free: in use at exit: 704 bytes in 2 blocks. ==14406== malloc/free: 18 allocs, 16 frees, 32,293 bytes allocated. ==14406== For counts of detected errors, rerun with: -v ==14406== searching for pointers to 2 not-freed blocks. ==14406== checked 6,389,612 bytes. ==14406== ==14406== 704 bytes in 2 blocks are still reachable in loss record 1 of 1 ==14406== at 0x4006AEE: malloc (vg_replace_malloc.c:207) ==14406== by 0x4C2AC78E: __fopen_internal (in /lib/libc-2.9.so) ==14406== by 0x4C2AC85B: fopen@@GLIBC_2.1 (in /lib/libc-2.9.so) ==14406== by 0x8049155: get_controllers(char const*, int*) (libcgrouptest01.c:979) ==14406== by 0x804B589: main (libcgrouptest01.c:84) ==14406== ==14406== LEAK SUMMARY: ==14406== definitely lost: 0 bytes in 0 blocks. ==14406== possibly lost: 0 bytes in 0 blocks. ==14406== still reachable: 704 bytes in 2 blocks. ==14406== suppressed: 0 bytes in 0 blocks. Running second set of testcases ============================== ==14422== Memcheck, a memory error detector. ==14422== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==14422== Using LibVEX rev 1804, a library for dynamic binary translation. ==14422== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==14422== Using valgrind-3.3.0, a dynamic binary instrumentation framework. ==14422== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==14422== For more details, rerun with: -v ==14422== C:DBG: fs_mounted as recieved from script=1 C:DBG: mountpoint1 as recieved from script=/dev/cgroup_controllers-1 sanity check pass. cgroup TEST 1:PASS : cgroup_attach_task() Ret Value = 50014 Parameter nullcgroup TEST 2:PASS : cgroup_init() Ret Value = 0 TEST 3:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST 4:PASS : cgroup_attach_task_pid() Ret Value = 50016 TEST 5:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 7:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x40070D8: strncat (mc_replace_strmem.c:214) ==14422== by 0x804BAAA: main (libcgrouptest01.c:1255) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14422== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14422== by 0x804BAB5: main (libcgrouptest01.c:251) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007285: strcpy (mc_replace_strmem.c:268) ==14422== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14422== by 0x804BAB5: main (libcgrouptest01.c:251) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x8049381: _ZL14group_modifiedPci (libcgrouptest01.c:1072) ==14422== by 0x804C367: main (libcgrouptest01.c:253) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x8049389: _ZL14group_modifiedPci (libcgrouptest01.c:1072) ==14422== by 0x804C367: main (libcgrouptest01.c:253) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007470: strncmp (mc_replace_strmem.c:314) ==14422== by 0x80493A9: _ZL14group_modifiedPci (libcgrouptest01.c:1072) ==14422== by 0x804C367: main (libcgrouptest01.c:253) TEST 8:PASS : cgroup_modify_cgroup() Ret Value = 0 Parameter same cgroup TEST 9:PASS : cgroup_new_cgroup() Ret Value = 0 ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14422== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14422== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14422== by 0x804BB41: main (libcgrouptest01.c:285) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007285: strcpy (mc_replace_strmem.c:268) ==14422== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14422== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14422== by 0x804BB41: main (libcgrouptest01.c:285) TEST10:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST11:PASS : cgroup_modify_cgroup() Ret Value = 50007 TEST12:PASS : cgroup_new_cgroup() Ret Value = 0 ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14422== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14422== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14422== by 0x804BBF3: main (libcgrouptest01.c:313) ==14422== ==14422== Conditional jump or move depends on uninitialised value(s) ==14422== at 0x4007285: strcpy (mc_replace_strmem.c:268) ==14422== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14422== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14422== by 0x804BBF3: main (libcgrouptest01.c:313) TEST13:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST14:PASS : cgroup_get_cgroup() Ret Value = 50007 Parameter nullcgroup TEST15:PASS : cgroup_get_cgroup() Ret Value = 50002 Parameter not created group TEST16:PASS : cgroup_get_cgroup() Ret Value = 0 TEST 0:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 0:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST17:FAIL : cgroup_get_cgroup() Ret Value = 50017 TEST16:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST17:PASS : cgroup_create_cgroup() Ret Value = 50007 TEST18:PASS : cgroup_delete_cgroup() Ret Value = 50007 TEST19:PASS : cgroup_compare_cgroup() Ret Value = 50011 Parameter nullcgroup TEST20:PASS : cgroup_compare_cgroup() Ret Value = 0 TEST21:PASS : cgroup_compare_cgroup() Ret Value = 50017 ==14422== ==14422== ERROR SUMMARY: 45 errors from 10 contexts (suppressed: 18 from 1) ==14422== malloc/free: in use at exit: 7,356 bytes in 10 blocks. ==14422== malloc/free: 187 allocs, 177 frees, 234,711 bytes allocated. ==14422== For counts of detected errors, rerun with: -v ==14422== searching for pointers to 10 not-freed blocks. ==14422== checked 6,415,132 bytes. ==14422== ==14422== ==14422== 24 bytes in 1 blocks are definitely lost in loss record 1 of 3 ==14422== at 0x4006AEE: malloc (vg_replace_malloc.c:207) ==14422== by 0x8048FF7: check_fsmounted(int) (libcgrouptest01.c:1171) ==14422== at 0x4006AEE: malloc (vg_replace_malloc.c:207) ==14422== by 0x8048FF7: check_fsmounted(int) (libcgrouptest01.c:1171) ==14422== by 0x804B86B: main (libcgrouptest01.c:168) ==14422== ==14422== ==14422== 2,816 bytes in 8 blocks are still reachable in loss record 2 of 3 ==14422== at 0x4006AEE: malloc (vg_replace_malloc.c:207) ==14422== by 0x4C2AC78E: __fopen_internal (in /lib/libc-2.9.so) ==14422== by 0x4C2AC85B: fopen@@GLIBC_2.1 (in /lib/libc-2.9.so) ==14422== by 0x8049155: get_controllers(char const*, int*) (libcgrouptest01.c:979) ==14422== by 0x804B589: main (libcgrouptest01.c:84) ==14422== ==14422== ==14422== 4,516 bytes in 1 blocks are definitely lost in loss record 3 of 3 ==14422== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==14422== by 0x4030D9A: cgroup_new_cgroup (wrapper.c:28) ==14422== by 0x804B056: test_cgroup_get_cgroup(int, int, int) (libcgrouptest01.c:1342) ==14422== by 0x804BC07: main (libcgrouptest01.c:324) ==14422== ==14422== LEAK SUMMARY: ==14422== definitely lost: 4,540 bytes in 2 blocks. ==14422== possibly lost: 0 bytes in 0 blocks. ==14422== still reachable: 2,816 bytes in 8 blocks. ==14422== suppressed: 0 bytes in 0 blocks. Cleanup done Running third set of testcases ============================== ==14473== Memcheck, a memory error detector. ==14473== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al. ==14473== Using LibVEX rev 1804, a library for dynamic binary translation. ==14473== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP. ==14473== Using valgrind-3.3.0, a dynamic binary instrumentation framework. ==14473== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al. ==14473== For more details, rerun with: -v ==14473== C:DBG: fs_mounted as recieved from script=2 C:DBG: mountpoint1 as recieved from script=/dev/cgroup_controllers-1 C:DBG: mountpoint2 as recieved from script=/dev/cgroup_controllers-2 sanity check pass. cgroup TEST 1:PASS : cgroup_init() Ret Value = 0 TEST 2:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST 3:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 4:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 5:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 6:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 7:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST 8:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST 9:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST10:PASS : cgroup_new_cgroup() Ret Value = 0 TEST11:PASS : cgroup_attach_task() Ret Value = 50002 Parameter not created group TEST12:PASS : cgroup_new_cgroup() Ret Value = 0 ==14473== Conditional jump or move depends on uninitialised value(s) ==14473== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14473== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14473== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14473== by 0x804BFB4: main (libcgrouptest01.c:497) TEST13:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST14:PASS : cgroup_new_cgroup() Ret Value = 0 ==14473== ==14473== Conditional jump or move depends on uninitialised value(s) ==14473== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14473== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14473== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14473== by 0x804C014: main (libcgrouptest01.c:518) ==14473== ==14473== Conditional jump or move depends on uninitialised value(s) ==14473== at 0x4007285: strcpy (mc_replace_strmem.c:268) ==14473== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14473== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14473== by 0x804C014: main (libcgrouptest01.c:518) TEST15:PASS : cgroup_modify_cgroup() Ret Value = 0 TEST16:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST17:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST18:PASS : cgroup_new_cgroup() Ret Value = 0 TEST19:PASS : cgroup_create_cgroup() Ret Value = 0 group found under both controllers TEST18:PASS : cgroup_new_cgroup() Ret Value = 0 TEST19:PASS : cgroup_create_cgroup() Ret Value = 0 group found under both controllers TEST20:PASS : cgroup_attach_task() Ret Value = 0 Task found in group/s TEST21:PASS : cgroup_new_cgroup() Ret Value = 0 ==14473== ==14473== Conditional jump or move depends on uninitialised value(s) ==14473== at 0x4007271: strcpy (mc_replace_strmem.c:268) ==14473== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14473== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14473== by 0x804C240: main (libcgrouptest01.c:621) ==14473== ==14473== Conditional jump or move depends on uninitialised value(s) ==14473== at 0x4007285: strcpy (mc_replace_strmem.c:268) ==14473== by 0x402F24B: cgroup_modify_cgroup (api.c:1012) ==14473== by 0x804A317: test_cgroup_modify_cgroup(int, cgroup*, char const*, int, int, int, int, int) (libcgrouptest01.c:888) ==14473== by 0x804C240: main (libcgrouptest01.c:621) TEST22:PASS : cgroup_modify_cgroup() Ret Value = 0 group modified under both controllers TEST23:PASS : cgroup_delete_cgroup() Ret Value = 0 Group deleted from filesystem TEST 0:PASS : cgroup_new_cgroup() Ret Value = 0 TEST 0:PASS : cgroup_create_cgroup() Ret Value = 0 group found in filesystem TEST24:FAIL : cgroup_get_cgroup() Ret Value = 50018 ==14473== ==14473== ERROR SUMMARY: 79 errors from 5 contexts (suppressed: 18 from 1) ==14473== malloc/free: in use at exit: 71,348 bytes in 31 blocks. ==14473== malloc/free: 196 allocs, 165 frees, 228,734 bytes allocated. ==14473== For counts of detected errors, rerun with: -v ==14473== searching for pointers to 31 not-freed blocks. ==14473== checked 6,444,900 bytes. ==14473== ==14473== ==14473== 24 bytes in 1 blocks are definitely lost in loss record 1 of 5 ==14473== at 0x4006AEE: malloc (vg_replace_malloc.c:207) ==14473== by 0x8048FF7: check_fsmounted(int) (libcgrouptest01.c:1171) ==14473== by 0x804BD43: main (libcgrouptest01.c:360) ==14473== ==14473== ==14473== 5,280 bytes in 15 blocks are still reachable in loss record 2 of 5 ==14473== at 0x4006AEE: malloc (vg_replace_malloc.c:207) ==14473== by 0x4C2AC78E: __fopen_internal (in /lib/libc-2.9.so) ==14473== by 0x4C2AC85B: fopen@@GLIBC_2.1 (in /lib/libc-2.9.so) ==14473== by 0x8049155: get_controllers(char const*, int*) (libcgrouptest01.c:979) ==14473== by 0x804B589: main (libcgrouptest01.c:84) ==14473== ==14473== ==14473== 66,044 (18,064 direct, 47,980 indirect) bytes in 4 blocks are definitely lost in loss record 3 of 5 ==14473== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==14473== by 0x4030D9A: cgroup_new_cgroup (wrapper.c:28) ==14473== by 0x8049586: new_cgroup(char*, char*, char*, int, int) (libcgrouptest01.c:1127) ==14473== by 0x8049847: create_new_cgroup_ds(int, char const*, int, int) (libcgrouptest01.c:743) ==14473== by 0x804BF74: main (libcgrouptest01.c:484) ==14473== ==14473== ==14473== 20,980 bytes in 5 blocks are indirectly lost in loss record 4 of 5 ==14473== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==14473== by 0x4030C2C: cgroup_add_value_string (wrapper.c:122) ==14473== by 0x8048F3B: _ZL17add_control_valueP17cgroup_controllerPcS1_i (libcgrouptest01.c:1108) ==14473== by 0x80495F9: new_cgroup(char*, char*, char*, int, int) (libcgrouptest01.c:1142) ==14473== by 0x8049847: create_new_cgroup_ds(int, char const*, int, int) (libcgrouptest01.c:743) ==14473== by 0x804BF74: main (libcgrouptest01.c:484) ==14473== ==14473== ==14473== 27,000 bytes in 6 blocks are indirectly lost in loss record 5 of 5 ==14473== at 0x4004BA2: calloc (vg_replace_malloc.c:397) ==14473== by 0x4030F4B: cgroup_add_controller (wrapper.c:62) ==14473== by 0x80495DE: new_cgroup(char*, char*, char*, int, int) (libcgrouptest01.c:1139) ==14473== by 0x8049847: create_new_cgroup_ds(int, char const*, int, int) (libcgrouptest01.c:743) ==14473== by 0x804BF74: main (libcgrouptest01.c:484) ==14473== ==14473== LEAK SUMMARY: ==14473== definitely lost: 18,088 bytes in 5 blocks. ==14473== indirectly lost: 47,980 bytes in 11 blocks. ==14473== possibly lost: 0 bytes in 0 blocks. ==14473== still reachable: 5,280 bytes in 15 blocks. ==14473== suppressed: 0 bytes in 0 blocks. Cleanup done The cgroup_modify_cgroup uninitialized error is fixed in the clean up patches. After this patch, there are no leaks in the library as per the test cases and valgrind. (The cgroup data structure has to be explictly freed by the caller, so it is not a leak in the library) Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> --- api.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@299 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Intialize all pointers in api.cDhaval Giani2009-01-051-34/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | Recently, while debugging an issue with test cases, I realized the pitfalls of not initializing your pointers. On looking into api.c, I realized that a lot of pointers are not initialized. Hence, this patch. Tested against the libcgrouptest suite. No regressions could be were observed. Balbir says, > We should avoid double initialization specially if a > > *ptr = NULL is followed by > ptr = malloc(...) > > I don't see any concerns right now, but something to be aware of Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@298 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Don't fail cgroup_get_cgroup if fscanf fails ↵Dhaval Giani2008-12-291-16/+13
| | | | | | | | | | | | | | | | cgroup_get_cgroup was failing with the memory controller enabled. It was failing on memory.force_empty. The file has read permissions, but there is no read routine associated with it inside the kernel. fscanf failed and so cgroup_get_cgroup also failed. This was unexpected, cgroup_get_cgroup should have just skipped the file. In order to fix this, change cg_rd_ctrl_file to return more descriptive errors. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@293 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Give write access to the group as wellDhaval Giani2008-12-171-0/+11
| | | | | | | | | | | Though we had group details to allow groups access to the cgroup fs, we had not given the group write access. Correct this bug. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@239 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Better error reporting for libcgroupDhaval Giani2008-12-091-0/+32
| | | | | | | | | | | | | | | | From: Ankita Garg <ankita@in.ibm.com> This patch adds human readable error messages to the configuration parser. The error lookup is implemented as a simple table, indexed by the error. TODO: Save errno at ECGOTHER and pass it down as cgroup_lasterror. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Ankita Garg <ankita@in.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@228 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Merge several bug-fixes and cleanups. No version bump yet, since this isBalbir Singh2008-10-151-21/+36
| | | | | | | | | | an ongoing exercise (after more testing, I'll recommend one). Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@216 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Change how cgroup_get_cgroup worksDhaval Giani2008-09-291-13/+25
| | | | | | | | | | | | | | Since we will not deprecate API now, and will do so with the next release, let's include this one in and get the API right. With this pathc, we now return int type, and the pointer passed as the argument redirects to the cgroup we are reading. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@202 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Configuration rewrite to use the main cgroups API and several bug fixesBalbir Singh2008-09-291-17/+73
| | | | | | | | | | | | | and configuration enhancements. Primarliy Initiated by Dhaval Giani Please see svn log of all branches/balbir-config-cleanup Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@201 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* The automatic classification engine (cgexec, cgclassify, pam_cgroup)Balbir Singh2008-09-291-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | classify tasks. It is useful for an application to know where it has been classified. I propose to add a new API cgroup_get_current_controller_path() that returns the current classification directory for the specified controller. One can easily add on and build new API that will return paths of all mounted controllers, but I want to start with something simple and useful. I've also added a bunch of test cases for the same purpose. Test output # ./pathtest.sh Test FAIL, get path failed for controller cpuset Test PASS, controller cpu path /default Test PASS, controller cpuacct path /default Test PASS, controller memory path /default Test FAIL, get path failed for controller memrlimit I mounted just cpu, cpuacct and memory, thus the path for cpuset and memrlimit could not be found (as expected). Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Reviewed-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@200 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Merge the cgruleseng daemon from Steve OlivieriBalbir Singh2008-09-261-180/+628
| | | | | | | | | | Signed-off-by: Steve Olivieri <sjo@redhat.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@190 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Once we build the path, we don't have all the room in path anymore.Balbir Singh2008-09-201-2/+4
| | | | | | | | | | | | Instead of using sizeof(path), we should use FILENAME_MAX - strlen(path) - 1. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@186 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Fix a warning in api.c, where we ignore the fscanf value.Balbir Singh2008-09-201-1/+6
| | | | | | | | | | | I've tested the patch by running the tests available in the tests directory. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@185 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* More fixes to the earlier attempt to create new cgroup inheriting parent'sBalbir Singh2008-08-221-16/+74
| | | | | | | | | | | attributes. Test cases have also been updated. Tested on an x86_64 box with libcg_ba Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@166 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* This patch adds cgroup_create_cgroup_from_parent() API. I've tested itBalbir Singh2008-08-221-10/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with a modified version of libcg_ba (basic acceptance tests), that I'll send out later. I've also fixed a couple of bugs, I'll list them in order and if desired, I'll split out the patches so that the enhancements can be separate from the bug fixes 1. Fix cg_create_control_group() to succeed if the directory already exists 2. We can't always append a control_file, we need to open it "r+" 3. It's OK for writing values to a control_file to fail, since some of them are read-only and some may not exist in hierarchies below the root 4. Skip over directories while trying to read control file's name value pairs 5. In cg_rd_ctlr_file we don't allocate any memory to value, directly fscanf into it, that's been fixed 6. There might be more fixes that might already be present in trunk, since I hope I've not redone a lot of the fixes, I had branched of trunk very recently Changelog v2 ------------ 1. Refactor cgroup_free_controllers() and use it in cgroup_create_cgroup_from_parent() 2. Check for strdup failure 3. Check if dst == src TODO: 1. Use cg_add_controller() API 2. Use cg_add_value_string() API I'll send out patches for the TODOs later. I've also updated the basic acceptance test (libcg_ba.cpp) Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@165 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Some libcgroup API cleanupsDhaval Giani2008-08-151-12/+9
| | | | | | | | | | | Various libcgroup api cleanups as suggested by balbir during code review Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@159 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix cgroup_fill_cgc()Dhaval Giani2008-08-141-1/+1
| | | | | | | | | | | We were failing on stat's success. Stupid thing to do really. Fixing that now. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@154 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix return values in cgroup_attach_valueDhaval Giani2008-08-141-0/+4
| | | | | | | | | | | cgroup_attach_task_pid() should return ECGROUPNOTEXIST when we get an ENOENT from glibc. This patch makes that correction Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@153 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: beautify strcpy in modify_cgroupDhaval Giani2008-08-141-5/+5
| | | | | | | | | The code looked ugly. De-uglyfy it. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@151 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix up some free errorsDhaval Giani2008-08-141-3/+3
| | | | | | | | | | | | | | Sudhir reported a free() issue, it got traced to this issue. https://sourceforge.net/tracker/index.php?func=detail&aid=2049822&group_id=218421&atid=1043649 Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Sudhir Kumar <skumar@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@150 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix cgroup_modify_cgroupDhaval Giani2008-08-141-3/+5
| | | | | | | | | | | | An almost unused and less tested API. The path was getting misformed. This was because it had not been set in the first place. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@146 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix the delete APIDhaval Giani2008-08-141-0/+5
| | | | | | | | | | | | | | | | The delete call was returning a wrong value even on success. The reason was because in the fallback path, we try to delete all the groups again. Now it is possible that a group might have already been deleted and we return a wrong value. Change the API to check if the group exists before trying to rmdir it in the error path. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@145 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Ensure null is returned if cgroup does not exist in ↵Dhaval Giani2008-08-141-0/+4
| | | | | | | | | | cgroup_get_cgroup() Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@143 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: New API interfaces for task placementDhaval Giani2008-08-131-0/+343
| | | | | | | | | | | | | | | | | | | | | | | From: Vivek Goyal <vgoyal@redhat.com> Enhancement to libcg to do following. - Parse the /etc/cgrules.conf file and place the task in the right cgroup. - Exported two APIs which can place the task based on /etc/cgrules.conf or based on cgroup explicitly specified by the caller. - There can be multiple users. - PAM module (pam_cgroup) - cgexec tool - cgclassify tool - APIs can be directly used by other cgroup aware user progarams. - Classification daemon Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@136 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: check for return code of fprintf()Dhaval Giani2008-08-131-4/+30
| | | | | | | | | | | | | | | | | From: Vivek Goyal <vgoyal@redhat.com> o Adding a task to a particular cgroup currently does fprintf() and never check the return code. Modify it to check for the return code in case fprintf() and fflush() did not succeed. o I ran into the issues when i can't add migration thread to /container/admingroup/tasks and it will fail silently. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@133 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Extend cgroup_get_cgroup for uids as well.Dhaval Giani2008-08-121-3/+55
| | | | | | | | | | | | Now that a new API is available which allows a cgroup structure to be generated with just a name, extend cgroup_get_cgroup to get the uids and gids from the fs itself. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@127 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix segmentation fault in cgroup_init() -take2Dhaval Giani2008-08-091-2/+6
| | | | | | | | | | | | | | | | An artifact from the time when libcgroup could not handle multiple cgroup filesystems mounted at multiple points. It is very much possible a subsystem is not mounted at that point. (FWIW, it is wrong even on a single mount point, but I am quite surprised that no one hit it yet.) V1->V2 A minor cleanup possible. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@120 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Add new API to get cgroup data structure from filesystemDhaval Giani2008-08-061-0/+153
| | | | | | | | | | | | | | | | | New API to get the cgroup datastructure from the mounted filesystem. It accepts the cgroup datastructure with the name of the cgroup which has to populated across various mountpoints. TODO: More testing. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Dan Smith <danms@us.ibm.com> Cc: Paul Menage <menage@google.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@117 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Add more debug statementsDhaval Giani2008-07-291-4/+14
| | | | | | | | | | | | From: Vivek Goyal <vgoyal@redhat.com> o Add some more debug statements Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@115 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix up rentrant functions patch.Dhaval Giani2008-07-231-3/+17
| | | | | | | | | | Some errors were not handled, this patch handles those errors. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@114 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Ensure global data is protectedDhaval Giani2008-07-211-13/+44
| | | | | | | | | | | Add rwlock to ensure access to cg_mount_table is serialized. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Vivek Goyal <vgoyal@redhat.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@110 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Make libcgroup use rentrant functionsDhaval Giani2008-07-211-5/+15
| | | | | | | | | | | | | | | This patch converts functions which have reentrant versions to use those versions. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Paul Menage <menage@google.com> Cc: Dan Smith <danms@us.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@109 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: fix return value in cg_set_conrol_valueDhaval Giani2008-07-211-1/+1
| | | | | | | | | | We don't want to return errno as those results. Setting it to return a libcgroup error value. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@108 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix segmentation fault in cgroup_attach_task_pidDhaval Giani2008-07-081-1/+1
| | | | | | | | | | | | | From: Sudhir Kumar <skumar@linux.vnet.ibm.com> This patch fixes the segmentation fault in libcg api cgroup_attach_task() in case of multiple mounts. Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@103 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Handle null cgroups in APIsDhaval Giani2008-07-081-0/+9
| | | | | | | | | | | | | From: Sudhir Kumar <skumar@linux.vnet.ibm.com> [dhaval@linux.vnet.ibm.com]: correct error codes Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@102 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* From: Sudhir Kumar <sudhir@linux.vnet.ibm.com>Dhaval Giani2008-07-011-4/+4
| | | | | | | | | | | This patch fixes the spell mistake in enum value in the header file and libcg api file. Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@84 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* libcgroup: Fix segmentation fault in APIs.Dhaval Giani2008-06-111-20/+13
| | | | | | | | | | | | | | | | | Dan Smith reported some segmentation faults. It turns out that we did not NULL terminate all the structures when we had moved to the wrapper based approach. With this in mind, the loop checks the index instead of a NULL structure. Also remove unwanted NULL terminations. Thanks to Dan for excellent debugging. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/tags/v0.1c@77 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Some bugs were missed in v0.1b. Fixing those bugs and taggingDhaval Giani2008-06-101-6/+60
| | | | | | | | | v0.1c. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/tags/v0.1c@76 4f4bb910-9a46-0410-90c8-c897d4f1cd53
* Fix more api.c warningsBalbir Singh2008-05-301-4/+12
| | | | | | | | Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/tags/v0.1b@68 4f4bb910-9a46-0410-90c8-c897d4f1cd53