]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Rename dbg() to cgroup_dbg()
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Wed, 25 Feb 2009 13:43:27 +0000 (13:43 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Wed, 25 Feb 2009 13:43:27 +0000 (13:43 +0000)
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

api.c
cgclassify.c
cgrulesengd.c
cgrulesengd.h
config.c
libcgroup-internal.h
tools-common.c
tools-common.h

diff --git a/api.c b/api.c
index 1fb0e97c63384ed6abbef7c511beaacecb5b724d..968f9e1316b8b95f66e43d929c9a7f7bc70b8414 100644 (file)
--- a/api.c
+++ b/api.c
@@ -111,7 +111,7 @@ static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group)
 {
        int ret = 0;
        const char *filename = fts->fts_path;
-       dbg("seeing file %s\n", filename);
+       cgroup_dbg("seeing file %s\n", filename);
        switch (ent->fts_info) {
        case FTS_ERR:
                errno = ent->fts_errno;
@@ -151,14 +151,14 @@ fail_chown:
 static int cg_chown_recursive(char **path, uid_t owner, gid_t group)
 {
        int ret = 0;
-       dbg("path is %s\n", *path);
+       cgroup_dbg("path is %s\n", *path);
        FTS *fts = fts_open(path, FTS_PHYSICAL | FTS_NOCHDIR |
                                FTS_NOSTAT, NULL);
        while (1) {
                FTSENT *ent;
                ent = fts_read(fts);
                if (!ent) {
-                       dbg("fts_read failed\n");
+                       cgroup_dbg("fts_read failed\n");
                        break;
                }
                ret = cg_chown_file(fts, ent, owner, group);
@@ -195,7 +195,7 @@ static void cgroup_free_rule(struct cgroup_rule *r)
 
        /* Make sure our rule is not NULL, first. */
        if (!r) {
-               dbg("Warning: Attempted to free NULL rule.\n");
+               cgroup_dbg("Warning: Attempted to free NULL rule.\n");
                return;
        }
 
@@ -220,7 +220,7 @@ static void cgroup_free_rule_list(struct cgroup_rule_list *rl)
 
        /* Make sure we're not freeing NULL memory! */
        if (!(rl->head)) {
-               dbg("Warning: Attempted to free NULL list.\n");
+               cgroup_dbg("Warning: Attempted to free NULL list.\n");
                return;
        }
 
@@ -306,7 +306,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
        pthread_rwlock_wrlock(&rl_lock);
        fp = fopen(CGRULES_CONF_FILE, "r");
        if (!fp) {
-               dbg("Failed to open configuration file %s with"
+               cgroup_dbg("Failed to open configuration file %s with"
                                " error: %s\n", CGRULES_CONF_FILE,
                                strerror(errno));
                last_errno = errno;
@@ -315,7 +315,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
 
        buff = calloc(CGROUP_RULE_MAXLINE, sizeof(char));
        if (!buff) {
-               dbg("Out of memory?  Error: %s\n", strerror(errno));
+               cgroup_dbg("Out of memory?  Error: %s\n", strerror(errno));
                last_errno = errno;
                ret = ECGOTHER;
                goto close_unlock;
@@ -332,7 +332,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                cgroup_free_rule_list(lst);
 
        /* Now, parse the configuration file one line at a time. */
-       dbg("Parsing configuration file.\n");
+       cgroup_dbg("Parsing configuration file.\n");
        while ((itr = fgets(buff, CGROUP_RULE_MAXLINE, fp)) != NULL) {
                linenum++;
 
@@ -358,7 +358,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                 * of it (begins with %), then we should skip this rule too.
                 */
                if (skipped && *itr == '%') {
-                       dbg("Warning: Skipped child of invalid rule,"
+                       cgroup_dbg("Warning: Skipped child of invalid rule,"
                                        " line %d.\n", linenum);
                        memset(buff, '\0', CGROUP_RULE_MAXLINE);
                        continue;
@@ -374,7 +374,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                memset(destination, '\0', FILENAME_MAX);
                i = sscanf(itr, "%s%s%s", user, controllers, destination);
                if (i != 3) {
-                       dbg("Failed to parse configuration file on"
+                       cgroup_dbg("Failed to parse configuration file on"
                                        " line %d.\n", linenum);
                        goto parsefail;
                }
@@ -390,7 +390,8 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                 */
                if ((!cache) && matched && (strncmp(user, "%", 1) != 0)) {
                        /* If we make it here, we finished (non-cache). */
-                       dbg("Parsing of configuration file complete.\n\n");
+                       cgroup_dbg("Parsing of configuration file"
+                               " complete.\n\n");
                        ret = -1;
                        goto cleanup;
                }
@@ -401,7 +402,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                                uid = CGRULE_INVALID;
                                gid = grp->gr_gid;
                        } else {
-                               dbg("Warning: Entry for %s not"
+                               cgroup_dbg("Warning: Entry for %s not"
                                                "found.  Skipping rule on line"
                                                " %d.\n", itr, linenum);
                                memset(buff, '\0', CGROUP_RULE_MAXLINE);
@@ -418,7 +419,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                                uid = pwd->pw_uid;
                                gid = CGRULE_INVALID;
                        } else {
-                               dbg("Warning: Entry for %s not"
+                               cgroup_dbg("Warning: Entry for %s not"
                                                "found.  Skipping rule on line"
                                                " %d.\n", user, linenum);
                                memset(buff, '\0', CGROUP_RULE_MAXLINE);
@@ -457,7 +458,8 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                 */
                newrule = calloc(1, sizeof(struct cgroup_rule));
                if (!newrule) {
-                       dbg("Out of memory?  Error: %s\n", strerror(errno));
+                       cgroup_dbg("Out of memory?  Error: %s\n",
+                               strerror(errno));
                        last_errno = errno;
                        ret = ECGOTHER;
                        goto cleanup;
@@ -472,7 +474,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                /* Parse the controller list, and add that to newrule too. */
                stok_buff = strtok(controllers, ",");
                if (!stok_buff) {
-                       dbg("Failed to parse controllers on line"
+                       cgroup_dbg("Failed to parse controllers on line"
                                        " %d\n", linenum);
                        goto destroyrule;
                }
@@ -480,7 +482,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                i = 0;
                do {
                        if (i >= MAX_MNT_ELEMENTS) {
-                               dbg("Too many controllers listed"
+                               cgroup_dbg("Too many controllers listed"
                                        " on line %d\n", linenum);
                                goto destroyrule;
                        }
@@ -488,7 +490,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                        newrule->controllers[i] = strndup(stok_buff,
                                                        strlen(stok_buff) + 1);
                        if (!(newrule->controllers[i])) {
-                               dbg("Out of memory?  Error was: %s\n",
+                               cgroup_dbg("Out of memory?  Error was: %s\n",
                                        strerror(errno));
                                goto destroyrule;
                        }
@@ -504,13 +506,13 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
                        lst->tail = newrule;
                }
 
-                dbg("Added rule %s (UID: %d, GID: %d) -> %s for controllers:",
-                        lst->tail->name, lst->tail->uid, lst->tail->gid,
-                       lst->tail->destination);
+               cgroup_dbg("Added rule %s (UID: %d, GID: %d) -> %s for"
+                       " controllers:", lst->tail->name, lst->tail->uid,
+                       lst->tail->gid, lst->tail->destination);
                 for (i = 0; lst->tail->controllers[i]; i++) {
-                       dbg(" %s", lst->tail->controllers[i]);
+                       cgroup_dbg(" %s", lst->tail->controllers[i]);
                }
-               dbg("\n");
+               cgroup_dbg("\n");
 
                /* Finally, clear the buffer. */
                memset(buff, '\0', CGROUP_RULE_MAXLINE);
@@ -519,7 +521,7 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
        }
 
        /* If we make it here, there were no errors. */
-       dbg("Parsing of configuration file complete.\n\n");
+       cgroup_dbg("Parsing of configuration file complete.\n\n");
        ret = (matched && !cache) ? -1 : 0;
        goto cleanup;
 
@@ -629,13 +631,13 @@ int cgroup_init()
                                mntopt = strtok_r(mntopt, ",", &strtok_buffer);
 
                                if (strcmp(mntopt, controllers[i]) == 0) {
-                                       dbg("matched %s:%s\n", mntopt,
+                                       cgroup_dbg("matched %s:%s\n", mntopt,
                                                controllers[i]);
                                        strcpy(cg_mount_table[found_mnt].name,
                                                controllers[i]);
                                        strcpy(cg_mount_table[found_mnt].path,
                                                ent->mnt_dir);
-                                       dbg("Found cgroup option %s, "
+                                       cgroup_dbg("Found cgroup option %s, "
                                                " count %d\n",
                                                ent->mnt_opts, found_mnt);
                                        found_mnt++;
@@ -765,7 +767,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
        int i, ret = 0;
 
        if (!cgroup_initialized) {
-               dbg ("libcgroup is not initialized\n");
+               cgroup_dbg("libcgroup is not initialized\n");
                return ECGROUPNOTINITIALIZED;
        }
        if(!cgroup)
@@ -792,7 +794,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
                        }
                        ret = fprintf(tasks, "%d", tid);
                        if (ret < 0) {
-                               dbg("Error writing tid %d to %s:%s\n",
+                               cgroup_dbg("Error writing tid %d to %s:%s\n",
                                                tid, path, strerror(errno));
                                fclose(tasks);
                                last_errno = errno;
@@ -802,7 +804,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
                        ret = fflush(tasks);
                        if (ret) {
                                last_errno = errno;
-                               dbg("Error writing tid  %d to %s:%s\n",
+                               cgroup_dbg("Error writing tid  %d to %s:%s\n",
                                                tid, path, strerror(errno));
                                fclose(tasks);
                                return ECGOTHER;
@@ -813,7 +815,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
        } else {
                for (i = 0; i < cgroup->index; i++) {
                        if (!cgroup_test_subsys_mounted(cgroup->controller[i]->name)) {
-                               dbg("subsystem %s is not mounted\n",
+                               cgroup_dbg("subsystem %s is not mounted\n",
                                        cgroup->controller[i]->name);
                                return ECGROUPSUBSYSNOTMOUNTED;
                        }
@@ -828,7 +830,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
 
                        tasks = fopen(path, "w");
                        if (!tasks) {
-                               dbg("fopen failed for %s:%s", path,
+                               cgroup_dbg("fopen failed for %s:%s", path,
                                                        strerror(errno));
 
                                switch (errno) {
@@ -843,7 +845,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
                        ret = fprintf(tasks, "%d", tid);
                        if (ret < 0) {
                                last_errno = errno;
-                               dbg("Error writing tid %d to %s:%s\n",
+                               cgroup_dbg("Error writing tid %d to %s:%s\n",
                                                tid, path, strerror(errno));
                                fclose(tasks);
                                return ECGOTHER;
@@ -851,7 +853,7 @@ int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
                        ret = fflush(tasks);
                        if (ret) {
                                last_errno = errno;
-                               dbg("Error writing tid  %d to %s:%s\n",
+                               cgroup_dbg("Error writing tid  %d to %s:%s\n",
                                                tid, path, strerror(errno));
                                fclose(tasks);
                                return ECGOTHER;
@@ -941,7 +943,8 @@ static int cg_mkdir_p(const char *path)
                i = j;
                ret = chdir(wd);
                if (ret) {
-                       dbg("could not chdir to child directory (%s)\n", wd);
+                       cgroup_dbg("could not chdir to child directory (%s)\n",
+                               wd);
                        break;
                }
                free(wd);
@@ -951,7 +954,7 @@ static int cg_mkdir_p(const char *path)
        if (ret) {
                last_errno = errno;
                ret = ECGOTHER;
-               dbg("could not go back to old directory (%s)\n", cwd);
+               cgroup_dbg("could not go back to old directory (%s)\n", cwd);
        }
 
 done:
@@ -1045,7 +1048,7 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
 
        for (i = 0; i < cgroup->index; i++) {
                if (!cgroup_test_subsys_mounted(cgroup->controller[i]->name)) {
-                       dbg("subsystem %s is not mounted\n",
+                       cgroup_dbg("subsystem %s is not mounted\n",
                                cgroup->controller[i]->name);
                        return ECGROUPSUBSYSNOTMOUNTED;
                }
@@ -1212,7 +1215,7 @@ int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
                }
 
                if (!ignore_ownership) {
-                       dbg("Changing ownership of %s\n", fts_path[0]);
+                       cgroup_dbg("Changing ownership of %s\n", fts_path[0]);
                        error = cg_chown_recursive(fts_path,
                                cgroup->control_uid, cgroup->control_gid);
                }
@@ -1223,7 +1226,7 @@ int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
                for (j = 0; j < cgroup->controller[k]->index; j++) {
                        ret = snprintf(path, FILENAME_MAX, "%s%s", base,
                                        cgroup->controller[k]->values[j]->name);
-                       dbg("setting %s to %s, error %d\n", path,
+                       cgroup_dbg("setting %s to %s, error %d\n", path,
                                cgroup->controller[k]->values[j]->name, ret);
                        if (ret < 0 || ret >= FILENAME_MAX) {
                                last_errno = errno;
@@ -1296,14 +1299,14 @@ char *cgroup_find_parent(char *name)
        }
        pthread_rwlock_unlock(&cg_mount_table_lock);
 
-       dbg("path is %s\n", child);
+       cgroup_dbg("path is %s\n", child);
        dir = dirname(child);
-       dbg("directory name is %s\n", dir);
+       cgroup_dbg("directory name is %s\n", dir);
 
        if (asprintf(&parent, "%s/..", dir) < 0)
                return NULL;
 
-       dbg("parent's name is %s\n", parent);
+       cgroup_dbg("parent's name is %s\n", parent);
 
        if (stat(dir, &stat_child) < 0)
                goto free_parent;
@@ -1315,7 +1318,7 @@ char *cgroup_find_parent(char *name)
         * Is the specified "name" a mount point?
         */
        if (stat_parent.st_dev != stat_child.st_dev) {
-               dbg("parent is a mount point\n");
+               cgroup_dbg("parent is a mount point\n");
                strcpy(parent, ".");
        } else {
                dir = strdup(name);
@@ -1354,7 +1357,7 @@ int cgroup_create_cgroup_from_parent(struct cgroup *cgroup,
        if (!parent)
                return ret;
 
-       dbg("parent is %s\n", parent);
+       cgroup_dbg("parent is %s\n", parent);
        parent_cgroup = cgroup_new_cgroup(parent);
        if (!parent_cgroup)
                goto err_nomem;
@@ -1362,12 +1365,12 @@ int cgroup_create_cgroup_from_parent(struct cgroup *cgroup,
        if (cgroup_get_cgroup(parent_cgroup))
                goto err_parent;
 
-       dbg("got parent group for %s\n", parent_cgroup->name);
+       cgroup_dbg("got parent group for %s\n", parent_cgroup->name);
        ret = cgroup_copy_cgroup(cgroup, parent_cgroup);
        if (ret)
                goto err_parent;
 
-       dbg("copied parent group %s to %s\n", parent_cgroup->name,
+       cgroup_dbg("copied parent group %s to %s\n", parent_cgroup->name,
                                                        cgroup->name);
        ret = cgroup_create_cgroup(cgroup, ignore_ownership);
 
@@ -1720,7 +1723,7 @@ static int cg_prepare_cgroup(struct cgroup *cgroup, pid_t pid,
        struct cgroup_controller *cptr = NULL;
 
        /* Fill in cgroup details.  */
-       dbg("Will move pid %d to cgroup '%s'\n", pid, dest);
+       cgroup_dbg("Will move pid %d to cgroup '%s'\n", pid, dest);
 
        strcpy(cgroup->name, dest);
 
@@ -1736,12 +1739,13 @@ static int cg_prepare_cgroup(struct cgroup *cgroup, pid_t pid,
                        pthread_rwlock_rdlock(&cg_mount_table_lock);
                        for (i = 0; i < CG_CONTROLLER_MAX &&
                                cg_mount_table[i].name[0] != '\0'; i++) {
-                               dbg("Adding controller %s\n",
+                               cgroup_dbg("Adding controller %s\n",
                                        cg_mount_table[i].name);
                                cptr = cgroup_add_controller(cgroup,
                                                cg_mount_table[i].name);
                                if (!cptr) {
-                                       dbg("Adding controller '%s' failed\n",
+                                       cgroup_dbg("Adding controller '%s'"
+                                               " failed\n",
                                                cg_mount_table[i].name);
                                        pthread_rwlock_unlock(&cg_mount_table_lock);
                                        return ECGROUPNOTALLOWED;
@@ -1752,10 +1756,11 @@ static int cg_prepare_cgroup(struct cgroup *cgroup, pid_t pid,
                }
 
                /* it is individual controller names and not "*" */
-               dbg("Adding controller %s\n", controller);
+               cgroup_dbg("Adding controller %s\n", controller);
                cptr = cgroup_add_controller(cgroup, controller);
                if (!cptr) {
-                       dbg("Adding controller '%s' failed\n", controller);
+                       cgroup_dbg("Adding controller '%s' failed\n",
+                               controller);
                        return ECGROUPNOTALLOWED;
                }
        }
@@ -1915,7 +1920,7 @@ int cgroup_change_cgroup_uid_gid_flags(const uid_t uid, const gid_t gid,
 
        /* We need to check this before doing anything else! */
        if (!cgroup_initialized) {
-               dbg("libcgroup is not initialized\n");
+               cgroup_dbg("libcgroup is not initialized\n");
                ret = ECGROUPNOTINITIALIZED;
                goto finished;
        }
@@ -1926,18 +1931,19 @@ int cgroup_change_cgroup_uid_gid_flags(const uid_t uid, const gid_t gid,
         * find the first match in the cached list (rl).
         */
        if (!(flags & CGFLAG_USECACHE)) {
-               dbg("Not using cached rules for PID %d.\n", pid);
+               cgroup_dbg("Not using cached rules for PID %d.\n", pid);
                ret = cgroup_parse_rules(false, uid, gid);
 
                /* The configuration file has an error!  We must exit now. */
                if (ret != -1 && ret != 0) {
-                       dbg("Failed to parse the configuration rules.\n");
+                       cgroup_dbg("Failed to parse the configuration"
+                               " rules.\n");
                        goto finished;
                }
 
                /* We did not find a matching rule, so we're done. */
                if (ret == 0) {
-                       dbg("No rule found to match PID: %d, UID: %d, "
+                       cgroup_dbg("No rule found to match PID: %d, UID: %d, "
                                "GID: %d\n", pid, uid, gid);
                        goto finished;
                }
@@ -1948,25 +1954,25 @@ int cgroup_change_cgroup_uid_gid_flags(const uid_t uid, const gid_t gid,
                /* Find the first matching rule in the cached list. */
                tmp = cgroup_find_matching_rule_uid_gid(uid, gid);
                if (!tmp) {
-                       dbg("No rule found to match PID: %d, UID: %d, "
+                       cgroup_dbg("No rule found to match PID: %d, UID: %d, "
                                "GID: %d\n", pid, uid, gid);
                        ret = 0;
                        goto finished;
                }
        }
-       dbg("Found matching rule %s for PID: %d, UID: %d, GID: %d\n",
+       cgroup_dbg("Found matching rule %s for PID: %d, UID: %d, GID: %d\n",
                        tmp->name, pid, uid, gid);
 
        /* If we are here, then we found a matching rule, so execute it. */
        do {
-               dbg("Executing rule %s for PID %d... ", tmp->name, pid);
+               cgroup_dbg("Executing rule %s for PID %d... ", tmp->name, pid);
                ret = cgroup_change_cgroup_path(tmp->destination,
                                pid, tmp->controllers);
                if (ret) {
-                       dbg("FAILED! (Error Code: %d)\n", ret);
+                       cgroup_dbg("FAILED! (Error Code: %d)\n", ret);
                        goto finished;
                }
-               dbg("OK!\n");
+               cgroup_dbg("OK!\n");
 
                /* Now, check for multi-line rules.  As long as the "next"
                 * rule starts with '%', it's actually part of the rule that
@@ -2008,7 +2014,7 @@ int cgroup_change_cgroup_path(char *dest, pid_t pid, char *controllers[])
        struct cgroup cgroup;
 
        if (!cgroup_initialized) {
-               dbg("libcgroup is not initialized\n");
+               cgroup_dbg("libcgroup is not initialized\n");
                return ECGROUPNOTINITIALIZED;
        }
        memset(&cgroup, 0, sizeof(struct cgroup));
@@ -2019,7 +2025,7 @@ int cgroup_change_cgroup_path(char *dest, pid_t pid, char *controllers[])
        /* Add task to cgroup */
        ret = cgroup_attach_task_pid(&cgroup, pid);
        if (ret) {
-               dbg("cgroup_attach_task_pid failed:%d\n", ret);
+               cgroup_dbg("cgroup_attach_task_pid failed:%d\n", ret);
                return ret;
        }
        return 0;
@@ -2089,9 +2095,9 @@ int cgroup_reload_cached_rules()
        /* Return codes */
        int ret = 0;
 
-       dbg("Reloading cached rules from %s.\n", CGRULES_CONF_FILE);
+       cgroup_dbg("Reloading cached rules from %s.\n", CGRULES_CONF_FILE);
        if ((ret = cgroup_parse_rules(true, CGRULE_INVALID, CGRULE_INVALID))) {
-               dbg("Error parsing configuration file \"%s\": %d.\n",
+               cgroup_dbg("Error parsing configuration file \"%s\": %d.\n",
                        CGRULES_CONF_FILE, ret);
                ret = ECGROUPPARSEFAIL;
                goto finished;
@@ -2117,7 +2123,8 @@ int cgroup_init_rules_cache()
        /* Attempt to read the configuration file and cache the rules. */
        ret = cgroup_parse_rules(true, CGRULE_INVALID, CGRULE_INVALID);
        if (ret) {
-               dbg("Could not initialize rule cache, error was: %d\n", ret);
+               cgroup_dbg("Could not initialize rule cache, error was: %d\n",
+                       ret);
                cgroup_rules_loaded = false;
        } else {
                cgroup_rules_loaded = true;
@@ -2144,13 +2151,14 @@ int cgroup_get_current_controller_path(pid_t pid, const char *controller,
                return ECGOTHER;
 
        if (!cgroup_initialized) {
-               dbg("libcgroup is not initialized\n");
+               cgroup_dbg("libcgroup is not initialized\n");
                return ECGROUPNOTINITIALIZED;
        }
 
        ret = asprintf(&path, "/proc/%d/cgroup", pid);
        if (ret <= 0) {
-               dbg("cannot allocate memory (/proc/pid/cgroup) ret %d\n", ret);
+               cgroup_dbg("cannot allocate memory (/proc/pid/cgroup) ret %d\n",
+                       ret);
                return ret;
        }
 
@@ -2183,7 +2191,8 @@ int cgroup_get_current_controller_path(pid_t pid, const char *controller,
                 * disappear :)
                 */
                if (ret != 3 || ret == EOF) {
-                       dbg("read failed for pid_cgroup_fd ret %d\n", ret);
+                       cgroup_dbg("read failed for pid_cgroup_fd ret %d\n",
+                               ret);
                        last_errno = errno;
                        ret = ECGOTHER;
                        goto done;
index df9cb724a30f2258c51422000f625a85175f74be..c0446087d29ced979ae470aec250238ce9f19db5 100644 (file)
@@ -46,7 +46,7 @@ int euid_of_pid(pid_t pid)
        sprintf(path, "/proc/%d/status", pid);
        fp = fopen(path, "r");
        if (!fp) {
-               dbg("Error in opening file %s:%s\n", path,
+               cgroup_dbg("Error in opening file %s:%s\n", path,
                                strerror(errno));
                return -1;
        }
@@ -55,7 +55,7 @@ int euid_of_pid(pid_t pid)
                if (!strncmp(buf, "Uid:", 4)) {
                        sscanf((buf + 5), "%d%d%d%d", (int *)&ruid,
                                (int *)&euid, (int *)&suid, (int *)&fsuid);
-                       dbg("Scanned proc values are %d %d %d %d\n",
+                       cgroup_dbg("Scanned proc values are %d %d %d %d\n",
                                ruid, euid, suid, fsuid);
                        return euid;
                }
@@ -81,7 +81,7 @@ int egid_of_pid(pid_t pid)
        sprintf(path, "/proc/%d/status", pid);
        fp = fopen(path, "r");
        if (!fp) {
-               dbg("Error in opening file %s:%s\n", path,
+               cgroup_dbg("Error in opening file %s:%s\n", path,
                                strerror(errno));
                return -1;
        }
@@ -90,7 +90,7 @@ int egid_of_pid(pid_t pid)
                if (!strncmp(buf, "Gid:", 4)) {
                        sscanf((buf + 5), "%d%d%d%d", (int *)&rgid,
                                (int *)&egid, (int *)&sgid, (int *)&fsgid);
-                       dbg("Scanned proc values are %d %d %d %d\n",
+                       cgroup_dbg("Scanned proc values are %d %d %d %d\n",
                                rgid, egid, sgid, fsgid);
                        return egid;
                }
index 3a304762e807291eb4e5146976e339b11d9bf092..8efdce1aace9f88976aa054dfdf25dc9e8b71db0 100644 (file)
@@ -323,7 +323,7 @@ int cgre_create_netlink_socket_process_msg()
         */
        sk_nl = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
        if (sk_nl == -1) {
-               dbg("socket sk_nl error");
+               cgroup_dbg("socket sk_nl error");
                return rc;
        }
 
@@ -339,14 +339,14 @@ int cgre_create_netlink_socket_process_msg()
 
        err = bind(sk_nl, (struct sockaddr *)&my_nla, sizeof(my_nla));
        if (err == -1) {
-               dbg("binding sk_nl error");
+               cgroup_dbg("binding sk_nl error");
                goto close_and_exit;
        }
 
        nl_hdr = (struct nlmsghdr *)buff;
        cn_hdr = (struct cn_msg *)NLMSG_DATA(nl_hdr);
        mcop_msg = (enum proc_cn_mcast_op*)&cn_hdr->data[0];
-       dbg("sending proc connector: PROC_CN_MCAST_LISTEN... ");
+       cgroup_dbg("sending proc connector: PROC_CN_MCAST_LISTEN... ");
        memset(buff, 0, sizeof(buff));
        *mcop_msg = PROC_CN_MCAST_LISTEN;
 
@@ -363,13 +363,13 @@ int cgre_create_netlink_socket_process_msg()
        cn_hdr->seq = 0;
        cn_hdr->ack = 0;
        cn_hdr->len = sizeof(enum proc_cn_mcast_op);
-       dbg("sending netlink message len=%d, cn_msg len=%d\n",
+       cgroup_dbg("sending netlink message len=%d, cn_msg len=%d\n",
                nl_hdr->nlmsg_len, (int) sizeof(struct cn_msg));
        if (send(sk_nl, nl_hdr, nl_hdr->nlmsg_len, 0) != nl_hdr->nlmsg_len) {
-               dbg("failed to send proc connector mcast ctl op!\n");
+               cgroup_dbg("failed to send proc connector mcast ctl op!\n");
                goto close_and_exit;
        }
-       dbg("sent\n");
+       cgroup_dbg("sent\n");
 
        for(memset(buff, 0, sizeof(buff)), from_nla_len = sizeof(from_nla);
        ; memset(buff, 0, sizeof(buff)), from_nla_len = sizeof(from_nla)) {
@@ -502,7 +502,7 @@ int cgre_start_daemon(const char *logp, const int logf,
                /* Change the file mode mask. */
                umask(0);
        } else {
-               dbg("Not using daemon mode.\n");
+               cgroup_dbg("Not using daemon mode.\n");
                pid = getpid();
        }
 
index 1f6d9850032cf416343f07147afbe60f3c428822..1840143afcf05ec3a36cd7868abbb65ea7f11a20 100644 (file)
@@ -33,9 +33,9 @@ __BEGIN_DECLS
 
 /* A simple macro for printing messages only when CGROUP_DEBUG is defined. */
 #ifdef CGROUP_DEBUG
-  #define dbg(a...) printf(a)
+  #define cgroup_dbg(a...) printf(a)
 #else
-  #define dbg(a...) do {} while (0)
+  #define cgroup_dbg(a...) do {} while (0)
 #endif /* CGROUP_DEBUG */
 
 /* The following ten macros are all for the Netlink code. */
index e60a36f0d28ebac7bcab631ab7f2b3e34bf1ea50..7e827ee421234bfa6b171c42a299ffffd890c47b 100644 (file)
--- a/config.c
+++ b/config.c
@@ -109,7 +109,7 @@ int cgroup_config_parse_controller_options(char *controller, char *name_value)
                &config_cgroup_table[cgroup_table_index];
        char *nm_pairs, *nv_buf;
 
-       dbg("Adding controller %s, value %s\n", controller, name_value);
+       cgroup_dbg("Adding controller %s, value %s\n", controller, name_value);
        cgc = cgroup_add_controller(config_cgroup, controller);
 
        if (!cgc)
@@ -123,7 +123,7 @@ int cgroup_config_parse_controller_options(char *controller, char *name_value)
                goto done;
 
        nm_pairs = strtok_r(name_value, ":", &nv_buf);
-       dbg("[1] name value pair being processed is %s\n", nm_pairs);
+       cgroup_dbg("[1] name value pair being processed is %s\n", nm_pairs);
        name = strtok_r(nm_pairs, " ", &buffer);
 
        if (!name)
@@ -134,14 +134,15 @@ int cgroup_config_parse_controller_options(char *controller, char *name_value)
        if (!value)
                goto parse_error;
 
-       dbg("name is %s, value is %s\n", name, value);
+       cgroup_dbg("name is %s, value is %s\n", name, value);
        error = cgroup_add_value_string(cgc, name, value);
 
        if (error)
                goto parse_error;
 
        while ((nm_pairs = strtok_r(NULL, ":", &nv_buf))) {
-               dbg("[2] name value pair being processed is %s\n", nm_pairs);
+               cgroup_dbg("[2] name value pair being processed is %s\n",
+                       nm_pairs);
                name = strtok_r(nm_pairs, " ", &buffer);
 
                if (!name)
@@ -152,7 +153,7 @@ int cgroup_config_parse_controller_options(char *controller, char *name_value)
                if (!value)
                        goto parse_error;
 
-               dbg("name is %s, value is %s\n", name, value);
+               cgroup_dbg("name is %s, value is %s\n", name, value);
                error = cgroup_add_value_string(cgc, name, value);
 
                if (error)
@@ -401,7 +402,8 @@ int cgroup_config_create_groups()
        for (i = 0; i < cgroup_table_index; i++) {
                struct cgroup *cgroup = &config_cgroup_table[i];
                error = cgroup_create_cgroup(cgroup, 0);
-               dbg("creating group %s, error %d\n", cgroup->name, error);
+               cgroup_dbg("creating group %s, error %d\n", cgroup->name,
+                       error);
                if (error)
                        return error;
        }
@@ -440,10 +442,10 @@ int cgroup_config_unmount_controllers(void)
                 */
                error = umount(config_mount_table[i].path);
                if (error < 0)
-                       dbg("Unmount failed\n");
+                       cgroup_dbg("Unmount failed\n");
                error = rmdir(config_mount_table[i].path);
                if (error < 0)
-                       dbg("rmdir failed\n");
+                       cgroup_dbg("rmdir failed\n");
        }
 
        return 0;
@@ -459,13 +461,13 @@ int cgroup_config_load_config(const char *pathname)
        yyin = fopen(pathname, "r");
 
        if (!yyin) {
-               dbg("Failed to open file %s\n", pathname);
+               cgroup_dbg("Failed to open file %s\n", pathname);
                last_errno = errno;
                return ECGOTHER;
        }
 
        if (yyparse() != 0) {
-               dbg("Failed to parse file %s\n", pathname);
+               cgroup_dbg("Failed to parse file %s\n", pathname);
                return ECGROUPPARSEFAIL;
        }
 
@@ -478,7 +480,7 @@ int cgroup_config_load_config(const char *pathname)
                goto err_mnt;
 
        error = cgroup_config_create_groups();
-       dbg("creating all cgroups now, error=%d\n", error);
+       cgroup_dbg("creating all cgroups now, error=%d\n", error);
        if (error)
                goto err_grp;
 
index 87cef5210c7179fea3729771559745aa67402503..001da1a65c9509cdb3aa7735db9064cbd802004f 100644 (file)
@@ -28,9 +28,9 @@ __BEGIN_DECLS
 #define CGROUP_BUFFER_LEN (5 * FILENAME_MAX)
 
 #ifdef CGROUP_DEBUG
-#define dbg(x...) printf(x)
+#define cgroup_dbg(x...) printf(x)
 #else
-#define dbg(x...) do {} while (0)
+#define cgroup_dbg(x...) do {} while (0)
 #endif
 
 struct control_value {
index 2cedf23e3ed0930bc7af2288dfe1e0d6a56d12d0..0bb666f5735e2f04ce4f6f3738c54e92dde38425 100644 (file)
@@ -45,13 +45,13 @@ int parse_cgroup_spec(struct cgroup_group_spec *cdptr[], char *optarg)
 
        /* Extract list of controllers */
        cptr = strtok(optarg, ":");
-       dbg("list of controllers is %s\n", cptr);
+       cgroup_dbg("list of controllers is %s\n", cptr);
        if (!cptr)
                return -1;
 
        /* Extract cgroup path */
        pathptr = strtok(NULL, ":");
-       dbg("cgroup path is %s\n", pathptr);
+       cgroup_dbg("cgroup path is %s\n", pathptr);
        if (!pathptr)
                return -1;
 
index 2ef6c9084d4626f11077d875238b3bc9540e033f..34379730781986a2f408fbce2fa1068a21f11e6b 100644 (file)
@@ -22,9 +22,9 @@
 #include <libcgroup.h>
 
 #ifdef CGROUP_DEBUG
-#define dbg(x...) printf(x)
+#define cgroup_dbg(x...) printf(x)
 #else
-#define dbg(x...) do {} while (0)
+#define cgroup_dbg(x...) do {} while (0)
 #endif
 
 /**