]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Fix api.c warnings, include wrapper.c in Makefile. More changes to
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Fri, 30 May 2008 17:50:23 +0000 (17:50 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Fri, 30 May 2008 17:50:23 +0000 (17:50 +0000)
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

Makefile
Makefile.in
api.c
libcgroup.h
libcgroup.spec.in
tests/Makefile

index 951a7fd60c40cdaf4eb78b5514392a0852115353..269edf59a239db6e251cc70806832ea44bb4dfff 100644 (file)
--- 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
index b610417f26931719d91aedfb6068e3ced9028adc..172b225bd96edc9d4b18c0a7e16f8ced3e1ccc81 100644 (file)
@@ -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 fce70a7bbfc46229c1a292de3384d53e9bb5b6b1..b60d534062c4aa28f2164237a192169ee6e8be51 100644 (file)
--- 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;
+                       }
                }
        }
 
index 0913623a1cf045c3daacaf06119c9b7e91b60d18..ccd82efa4cc96bfe7f209037285a5416318da81d 100644 (file)
@@ -115,6 +115,7 @@ enum cgroup_errors {
        ECGVALUEEXISTS,
        ECGINVAL,
        ECGCONTROLLERCREATEFAILED,
+       ECGFAIL,
 };
 
 #define CG_MAX_MSG_SIZE                256
index a1aaf18f82a5a3a83b9b26e0751c1ca0dc392271..a918e44e0bb25f4127c1794fe10ea6362f2f14de 100644 (file)
@@ -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
index 0870f10f22a31bf6b891ac10ace697d2ab153c46..707302a0ff761bbe78757fb4f45fed52650bf933 100644 (file)
@@ -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)