On Mon, Feb 23, 2009 at 04:01:22PM +0530, Balbir Singh wrote: > * Jan Safranek <[email protected]> [2009-02-23 11:10:06]: > > > Balbir Singh wrote: > >> Feature: Provide new libcgroup walk tree API > >> > >> From: Balbir Singh <[email protected]> > >> > >> 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. Everytime > >> a node is visited, a callback function is invoked that can act or record > >> the node being visited. > >> > >> 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 > >> Walking post dir > >> --------------- > >> f -> e, [/cgroup/cpu///a/e/f] > >> e -> a, [/cgroup/cpu///a/e] > >> f -> a, [/cgroup/cpu///a/f] > >> x -> a, [/cgroup/cpu///a/x] > >> d -> c, [/cgroup/cpu///a/b/c/d] > >> c -> b, [/cgroup/cpu///a/b/c] > >> b -> a, [/cgroup/cpu///a/b] > >> a -> , [/cgroup/cpu///a] > >> default -> , [/cgroup/cpu///default] > >> -> , [/cgroup/cpu///] > > > > IMHO the API user is not interested into full path to group > > (/cgroup/cpu///a/e/f), but to group name (a/e/f), which can be used in > > later calls to the API (like cgroup_new_cgroup()). > > > >> +/* > >> + * TODO: Need to decide a better place to put this function. > >> + */ > >> +int cgroup_walk_tree(char *controller, char *base_path, const int depth, > >> + enum cgroup_walk_type type, cgroup_walk_callback cb, > >> + void *arg) > >> +{ > >> + int ret = 0; > >> + dbg("path is %s\n", path); > > Use base_path here ^. > > > > Yes. Thanks, > > > > >> +typedef void *(*cgroup_walk_callback)(const struct cgroup_file_info *info, > >> + void *arg); > > > > I am still not convinced that callbacks are the best... I'd rewrite it > > to iterator, if I had enough time... which will be after F11 beta, > > probably next week :(. > > > > Yes, due to the time constraint, I've shyed away from the iterator. An > iterator would require a DFS walk. Notice, I think we can write an > iterator, but might not have sufficient test cases for it to be proven > as working. > > > The rest of the patch looks good to me. > > Lets do the rewrite after the freeze. >
So do you want to push it in now or a bit later on? thanks, -- regards, Dhaval ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Libcg-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libcg-devel
