summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalbir Singh <balbir@linux.vnet.ibm.com>2008-05-30 17:50:23 +0000
committerBalbir Singh <balbir@linux.vnet.ibm.com>2008-05-30 17:50:23 +0000
commit33b354a4c8c85a90ab4ac32c2a75f23a7eb8f81b (patch)
tree41e3cc8764d2af560515eaf0957b35d34ebb071d
parentdf1357a592d94389273708c70a7c415e9dc15d6d (diff)
downloadlibcg-33b354a4c8c85a90ab4ac32c2a75f23a7eb8f81b.tar.gz
libcg-33b354a4c8c85a90ab4ac32c2a75f23a7eb8f81b.tar.xz
libcg-33b354a4c8c85a90ab4ac32c2a75f23a7eb8f81b.zip
Fix api.c warnings, include wrapper.c in Makefile. More changes to
spec file based on bugzilla input. Removed %makeinstall 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/tags/v0.1b@67 4f4bb910-9a46-0410-90c8-c897d4f1cd53
-rw-r--r--Makefile5
-rw-r--r--Makefile.in5
-rw-r--r--api.c36
-rw-r--r--libcgroup.h1
-rw-r--r--libcgroup.spec.in4
-rw-r--r--tests/Makefile3
6 files changed, 18 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 951a7fd..269edf5 100644
--- a/Makefile
+++ b/Makefile
@@ -39,8 +39,9 @@ y.tab.c: parse.y lex.yy.c
lex.yy.c: lex.l
$(LEX) lex.l
-libcgroup.so: api.c libcgroup.h
- $(CXX) $(CFLAGS) -shared -fPIC -Wl,--soname,$@.$(VERSION) -o $@ api.c
+libcgroup.so: api.c libcgroup.h wrapper.c
+ $(CXX) $(CFLAGS) -shared -fPIC -Wl,--soname,$@.$(VERSION) -o $@ api.c \
+ wrapper.c
ln -sf $@ $@.$(VERSION)
install: libcgroup.so
diff --git a/Makefile.in b/Makefile.in
index b610417..172b225 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -39,8 +39,9 @@ y.tab.c: parse.y lex.yy.c
lex.yy.c: lex.l
$(LEX) lex.l
-libcgroup.so: api.c libcgroup.h
- $(CXX) $(CFLAGS) -shared -fPIC -Wl,--soname,$@.$(VERSION) -o $@ api.c
+libcgroup.so: api.c libcgroup.h wrapper.c
+ $(CXX) $(CFLAGS) -shared -fPIC -Wl,--soname,$@.$(VERSION) -o $@ api.c \
+ wrapper.c
ln -sf $@ $@.$(VERSION)
install: libcgroup.so
diff --git a/api.c b/api.c
index fce70a7..b60d534 100644
--- a/api.c
+++ b/api.c
@@ -104,10 +104,9 @@ static int cg_chown_recursive(char **path, uid_t owner, gid_t group)
int cgroup_init()
{
FILE *proc_mount;
- struct mntent *ent, *found_ent = NULL;
+ struct mntent *ent;
int found_mnt = 0;
int ret = 0;
- char *mntent_tok;
static char *controllers[CG_CONTROLLER_MAX];
FILE *proc_cgroup;
char subsys_name[FILENAME_MAX];
@@ -179,31 +178,6 @@ int cgroup_init()
return ret;
}
-static char **get_mounted_controllers(char *mountpoint)
-{
- char **controllers;
- int i, j;
-
- i = 0;
- j = 0;
-
- controllers = (char **) malloc(sizeof(char *) * CG_CONTROLLER_MAX);
-
- for (i = 0; i < CG_CONTROLLER_MAX && cg_mount_table[i].name != NULL;
- i++) {
- if (strcmp(cg_mount_table[i].name, mountpoint) == 0) {
- controllers[j] = (char *)malloc(sizeof(char) *
- FILENAME_MAX);
- strcpy(controllers[j], cg_mount_table[i].name);
- j++;
- }
- }
- controllers[j] = (char *)malloc(sizeof(char) * FILENAME_MAX);
- controllers[j][0] = '\0';
-
- return controllers;
-}
-
static int cg_test_mounted_fs()
{
FILE *proc_mount;
@@ -350,7 +324,6 @@ static int cg_create_control_group(char *path)
*/
static int cg_set_control_value(char *path, char *val)
{
- int error;
FILE *control_file;
if (!cg_test_mounted_fs())
return ECGROUPNOTMOUNTED;
@@ -486,7 +459,12 @@ int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
if (!ignore_ownership) {
strcpy(path, base);
strcat(path, "/tasks");
- chown(path, cgroup->tasks_uid, cgroup->tasks_gid);
+ error = chown(path, cgroup->tasks_uid,
+ cgroup->tasks_gid);
+ if (!error) {
+ error = ECGFAIL;
+ goto err;
+ }
}
}
diff --git a/libcgroup.h b/libcgroup.h
index 0913623..ccd82ef 100644
--- a/libcgroup.h
+++ b/libcgroup.h
@@ -115,6 +115,7 @@ enum cgroup_errors {
ECGVALUEEXISTS,
ECGINVAL,
ECGCONTROLLERCREATEFAILED,
+ ECGFAIL,
};
#define CG_MAX_MSG_SIZE 256
diff --git a/libcgroup.spec.in b/libcgroup.spec.in
index a1aaf18..a918e44 100644
--- a/libcgroup.spec.in
+++ b/libcgroup.spec.in
@@ -18,7 +18,7 @@ administrate and monitor control groups and the associated controllers.
%package devel
Summary: Development libraries to develop applications that utilize control groups
Group: Development/Libraries
-Requires: libcgroup >= 0.1b
+Requires: libcgroup >= @PACKAGE_VERSION@
%description devel
It provides API to create/delete and modify cgroup nodes. It will also in the
@@ -36,7 +36,7 @@ make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
-%makeinstall
+make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
diff --git a/tests/Makefile b/tests/Makefile
index 0870f10..707302a 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,6 +1,7 @@
-CXXFLAGS = -g -O2 -Wall -DDEBUG
LDFLAGS = -L ..
LIBS = -lcgroup
+INC = -I ..
+CXXFLAGS = -g -O2 -Wall -DDEBUG $(INC)
libcg_ba: libcg_ba.cpp
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS) $(LIBS)