int cgroup_get_task_begin(char *cgroup, char *controller, void **handle,
pid_t *pid);
+/**
+ * Register the unchanged process to a cgrulesengd daemon.
+ * If the daemon does not work, this function returns 0 as success.
+ * @param pid: The process id
+ * @param flags Bit flags to change the behavior, as defined above
+ * @return 0 on success, > 0 on error.
+ */
+int cgroup_register_unchanged_process(pid_t pid, int flags);
+
/**
* Read the next task value
* @handle: The handle used for iterating
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/socket.h>
#include <fcntl.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <pwd.h>
#include <libgen.h>
#include <assert.h>
+#include <linux/un.h>
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION 0.01
return ret;
}
+int cgroup_register_unchanged_process(pid_t pid, int flags)
+{
+ int sk;
+ int ret = 1;
+ char buff[sizeof(CGRULE_SUCCESS_STORE_PID)];
+ struct sockaddr_un addr;
+
+ sk = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (sk < 0)
+ return 1;
+
+ bzero((char *)&addr, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, CGRULE_CGRED_TEMP_FILE);
+
+ if (connect(sk, (struct sockaddr *)&addr,
+ sizeof(addr.sun_family) + strlen(CGRULE_CGRED_TEMP_FILE)) < 0) {
+ /* If the daemon does not work, this function returns 0
+ * as success. */
+ ret = 0;
+ goto close;
+ }
+ if (write(sk, &pid, sizeof(pid)) < 0)
+ goto close;
+
+ if (write(sk, &flags, sizeof(flags)) < 0)
+ goto close;
+
+ if (read(sk, buff, sizeof(buff)) < 0)
+ goto close;
+
+ if (strncmp(buff, CGRULE_SUCCESS_STORE_PID, sizeof(buff)))
+ goto close;
+
+ ret = 0;
+close:
+ close(sk);
+ return ret;
+}
+
int cgroup_get_subsys_mount_point(char *controller, char **mount_point)
{
int i;
cgroup_get_uid_gid_from_procfs;
cgroup_get_subsys_mount_point;
cgroup_get_procname_from_procfs;
+ cgroup_register_unchanged_process;
cgroup_change_cgroup_flags;
} CGROUP_0.33;