Dhaval Giani [Fri, 4 Jun 2010 11:30:58 +0000 (13:30 +0200)]
libcgroup: Do not call exit from within the main library
The autogenerated code fromt the lexer was calling exit on a
fatal error. Do not do that. Instead log the message.
While it is still not clear if this is the correct response
for YY_FATAL_ERROR, we need to gracefully handle errors, and
since this is a path which is very rarely hit, this is still
a low risk change and so we will merge it.
Jan Safranek [Mon, 31 May 2010 15:15:22 +0000 (17:15 +0200)]
Add configure option to set destination directory of pam module.
Add configure option to set destination directory of pam module. The module
can be used right after 'make install', no moving of libraries is required.
Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Jan Safranek [Mon, 31 May 2010 15:15:08 +0000 (17:15 +0200)]
Rework the way how the libraries are installed.
As pointed out by Kay Sievers on IRC, the pkgconfig file should point to
/usr/lib, where libcgroup.so symlink is located, not to /lib, where is the
real library libcgroup.so.1.0.36.
Therefore it's better to install libraries to /usr/lib, which generated
the right libcgroup.pc and then move all necessary libs to /lib.
Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Dhaval Giani [Mon, 17 May 2010 16:15:59 +0000 (18:15 +0200)]
libcgroup: Introduce cgroup_basename and modify the functions to use it.
basename() is not safe as it modifies the pointers from time to time.
In order to prevent it, write a safe version of basename which uses basename
internally.
As a side effect, it also clears up the following warning,
api.c: In function ‘cgroup_find_matching_rule’:
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
api.c:2201: warning: passing argument 1 of ‘__xpg_basename’ discards qualifiers from pointer target type
/usr/include/libgen.h:35: note: expected ‘char *’ but argument is of type ‘const char *’
Dhaval Giani [Mon, 17 May 2010 16:15:58 +0000 (18:15 +0200)]
libcgroup: Fix warnings warning about comparisions between signed and unsigned integers
Fix warnings such as
api.c:539: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
api.c:539: warning: signed and unsigned type in conditional expression [-Wsign-compare]
Dhaval Giani [Mon, 17 May 2010 16:15:57 +0000 (18:15 +0200)]
libcgroup: Fix warnings warning of shadowed declaration
Fixes warnings such as
api.c:2764: warning: declaration of ‘stat’ shadows a global declaration [-Wshadow]
/usr/include/sys/stat.h:453: warning: shadowed declaration is here [-Wshadow]
Dhaval Giani [Mon, 17 May 2010 16:15:55 +0000 (18:15 +0200)]
libcgroup: cast CGRULE macros to uid_t
Clears up a few warnings.
api.c:2366: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
api.c:2368: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
api.c:2373: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
api.c:2375: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Allow cgroup_config_table to be dynamically handled
Allow cgconfigparser to create groups > MAX_GROUPS
From: Balbir Singh <balbir@linux.vnet.ibm.com>
Rafael Tinoco <rafael.tinoco@locaweb.com.br> noticed that the maximum
number of cgroups created using cgconfigparser fell short of 2000. Balbir
found a limitation in the code, that limited this number to a predefined
maximum. This patch fixes the limitation, although not in the most
optimized way, since we want to avoid double parsing of the configuraiton
file.
This patch realloc's the data structure that holds parsed cgroups.
Tested via setting MAX_CGROUPS=1 and loading a configuration file with
2 groups defined. Also tested with a large cgroup file
Test results after loading large_cgconfig.conf (generated using a
script). The size is large, but I wanted to send out the test case
since it adds to our regression bucket.
Jan Safranek [Mon, 12 Apr 2010 10:49:08 +0000 (12:49 +0200)]
Use int for getopt() results
On ppc, char is unsigned and getopt()/getopt_long() returning -1 (= end of
arguments) is translated to 255 and results in 'Invalid command line option'.
Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Jan Safranek [Mon, 29 Mar 2010 10:07:00 +0000 (12:07 +0200)]
Add documentation main page
Add very simple main page to include/libcgroup.h. It contains just very
basic info and links to the other modules. Feel free to elaborate more on
this, it could contain lot more:
- how to complie with libcgroup (=pkgconfig)?
- how to report errors
- links to samples
- link to home page
- info about threading
etc.
Jan Safranek [Mon, 29 Mar 2010 10:00:41 +0000 (12:00 +0200)]
Update doxygen config file
Update doxygen config file to 1.6.1 + add comments + change following
settings:
OUTPUT_DIRECTORY = doc/generated
ALWAYS_DETAILED_SEC = YES - we want all function in detailed list
JAVADOC_AUTOBRIEF = YES - IMHO the least painfull way to extract brief
desxcription, see doxygen docs for the other ways. But still painful enough :(
OPTIMIZE_OUTPUT_FOR_C = YES - we're C project
IDL_PROPERTY_SUPPORT = NO - we're C project
WARN_NO_PARAMDOC = YES - document all function parameters please!
INPUT = include - generate public docs only
GENERATE_LATEX = NO - no LaTeX for now, maybe later
*_GRAPH = NO - no call/include graphs in public docs
api: don't keep one copy of the mount table per .c file
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.
add const where applicable, drop const where unnecessary
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++.
include: refuse inclusion of seperate header files
Later on it might make sense to move around function definitions between
header files. Hence make sure that nobody includes any header file
directly except the main one.
Signed-off-by: Lennart Poettering <lennart@poettering.net> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Acked-by: Dhaval Giani <dhaval.giani@gmail.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Dhaval Giani [Thu, 18 Feb 2010 14:56:31 +0000 (15:56 +0100)]
libcgroup: Add pkg-config data
libcgroup was not making an entry into the pkg-config database, which
makes life easier when using multiple libraries. Add the needed data
in order to be registered with the pkg-config database on installation.
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com> Reviewed-by: Jan Safranek <jsafrane@redhat.com> Acked-by: Lennart Poettering <lennnart@poettering.net>
Jan Safranek [Fri, 12 Mar 2010 15:50:20 +0000 (16:50 +0100)]
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/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
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>
Jan Safranek [Fri, 12 Mar 2010 15:50:10 +0000 (16:50 +0100)]
Move private definitions to private header
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>
Jon Bernard [Tue, 9 Mar 2010 21:10:39 +0000 (16:10 -0500)]
Use memset to initialize sigaction struct
The sa_restorer field is not present on some architectures, like alpha.
By using memset, the structure is initialized appropriately regardless of
struct contents.
Signed-off-by: Jon Bernard <jbernard@debian.org> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
Chris [Tue, 9 Mar 2010 16:04:46 +0000 (11:04 -0500)]
init script can miss default group
If there is a directive like *:httpd before * in the cgconfig file, all
processes end up being moved into the wrong group on cgconfig startup, and
the default group is never made. This fixes it for me:
fix cgroup_get_value_string problem with *.stat output
fix cgroup_get_value_string problem with *.stat output
the problem was in the low limit for value for the output of stat variables - now there are used the functions cgroup_read_stats_{begin/next/end} for this purpose
v2:
removed bunch of unnecessary error messages
This patch adds to cgget option -a:
-a print the variables for all controllers which consists given cgroup
adds new option -g to cgget command
* the option has one argument - controller
* cgget -g devices / returns the values of all variables of controller
devices
* the option could be used multiple times
Ken'ichi Ohmichi [Thu, 28 Jan 2010 05:45:48 +0000 (11:15 +0530)]
[PATCH-v2] Add the write error handling to cg_set_control_value().
Changelog since v1:
o Use fopen/fprintf/fclose instead of open/write/close.
o Add the error handling against fclose.
cg_set_control_value() is the function for setting a value to a file
of cgroup file system. And current function does not handle the error
of writing to a file. So we cannot know whether setting value is
enable or not. This patch add the error handling for knowing it.
An invalide namespace configuration. This configuration is invalid
because while cpu and cpuacct have been mounted at the same point,
they have different namespaces.
Dhaval Giani [Thu, 7 Jan 2010 10:54:35 +0000 (16:24 +0530)]
libcgroup: Setup the namespace datastructures
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
Dhaval Giani [Thu, 7 Jan 2010 10:54:34 +0000 (16:24 +0530)]
libcgroup: Introduce the new namespace keyword
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
Dhaval Giani [Wed, 23 Dec 2009 13:04:45 +0000 (18:34 +0530)]
Merge branch 'devel/config3' of git://fedorapeople.org/~jsafrane/libcg
* 'devel/config3' of git://fedorapeople.org/~jsafrane/libcg:
Clean up the init script
Use tools instead of shell scripts
Make cgclear quiert when there is nothing to clear.
Use cgclear on shutdown
Add sample /etc/sysconfig/cgconfig
Don't create sysdefault group whent it's not needed
Move sysdefault handling to separate function
Remove trailing space from lssubsys output
Fix reading of empty parameter values
Fix error text on failed reading of parameter.
cgget tool