Those functions are only used by tzip module.
Change-Id: I28a861373835a6e26bed39de8280c29b348c7552
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
return;
}
-#define CMD_FROZEN "FROZEN"
-#define CMD_THAWED "THAWED"
-static int freeze_processes_on_path(const char *frz_name, const char *part_path)
-{
- char *fuser_cmd = NULL;
- FILE *fuser_fp;
- char *line = NULL;
- size_t len = 0;
- int task_fd;
- int freezer_fd;
- char *freezer_procs;
- char *freezer_state;
- int ret;
-
- ret = asprintf(&fuser_cmd, "fuser -m %s | grep -o '[0-9]*'", part_path);
- if (ret < 0)
- return -1;
-
- fuser_fp = popen(fuser_cmd, "r");
- free(fuser_cmd);
- if (fuser_fp == NULL)
- return -1;
-
- ret = asprintf(&freezer_procs, "/sys/fs/cgroup/freezer/%s/cgroup.procs", frz_name);
- if (ret < 0) {
- pclose(fuser_fp);
- return -1;
- }
-
- task_fd = open(freezer_procs, O_RDWR);
- free(freezer_procs);
- if (task_fd < 0) {
- pclose(fuser_fp);
- return -1;
- }
-
- while (getline(&line, &len, fuser_fp) != -1) {
- int ret;
- int str_len = strlen(line);
- if (str_len <= 1)
- continue;
-
- ret = write(task_fd, line, str_len-1);
- if (ret < 0)
- break;
- }
-
- close(task_fd);
- free(line);
- pclose(fuser_fp);
-
- ret = asprintf(&freezer_state, "/sys/fs/cgroup/freezer/%s/freezer.state", frz_name);
- if (ret < 0)
- return -1;
-
- freezer_fd = open(freezer_state, O_RDWR);
- free(freezer_state);
- if (freezer_fd < 0)
- return -1;
-
- ret = write(freezer_fd, CMD_FROZEN, strlen(CMD_FROZEN));
- close(freezer_fd);
- if (ret < 0)
- return -1;
-
- return 0;
-}
-
-static bool check_frozen(const char *frz_name)
-{
- char *state_path = NULL;
- char *line = NULL;
- size_t len = 0;
- FILE *fd;
- int ret;
- bool result = false;
-
- ret = asprintf(&state_path, "/sys/fs/cgroup/freezer/%s/freezer.state", frz_name);
- if (ret < 0)
- return false;
-
- fd = fopen(state_path, "r");
- free(state_path);
- if (fd == NULL)
- return false;
-
- ret = getline(&line, &len, fd);
- if (ret != -1 && line) {
- if (!strncmp(line, CMD_FROZEN, strlen(CMD_FROZEN)))
- result = true;
- else
- result = false;
-
- }
-
- free(line);
- fclose(fd);
-
- return result;
-}
-
-static int thaw_processes_on_path(const char *frz_name)
-{
- int freezer_fd;
- int ret;
-
- char *freezer_state;
- ret = asprintf(&freezer_state, "/sys/fs/cgroup/freezer/%s/freezer.state", frz_name);
- if (ret < 0)
- return -1;
-
- freezer_fd = open(freezer_state, O_RDWR);
- free(freezer_state);
- if (freezer_fd < 0)
- return -1;
-
- ret = write(freezer_fd, CMD_THAWED, strlen(CMD_THAWED));
- close(freezer_fd);
- if (ret < 0)
- return -1;
-
- return 0;
-}
-
-void suspend_path(const char *frz_name, const char *path, const int max_retry)
-{
- bool frozen = false;
- int retry = 0;
-
- freeze_processes_on_path(frz_name, path);
-
- do {
- usleep((useconds_t)MSEC_TO_USEC(500));
-
- frozen = check_frozen(frz_name);
-
- retry++;
-
- } while (!frozen && retry < max_retry);
-}
-
-void resume_path(const char *frz_name, const char *path)
-{
- thaw_processes_on_path(frz_name);
-}
-
int get_privilege(pid_t pid, char *name, size_t len)
{
char path[PATH_MAX];
int get_systemd_reboot_param(char *buf, unsigned bufsize);
int terminate_process(const char *partition, bool force);
int mount_check(const char* path);
-void suspend_path(const char *frz_name, const char *path, const int max_retry);
-void resume_path(const char *frz_name, const char *path);
void umount_partition_by_kill(const char *path, const int max_retry);
int get_privilege(pid_t pid, char *name, size_t len);
bool is_emulator(void);
static int tzip_unmount_zipfs(const char *mount_point);
static int tzip_mount_zipfs(const char *src_file, const char *mount_point, const char *smack);
+#define CMD_FROZEN "FROZEN"
+#define CMD_THAWED "THAWED"
+static int freeze_processes_on_path(const char *frz_name, const char *part_path)
+{
+ char *fuser_cmd = NULL;
+ FILE *fuser_fp;
+ char *line = NULL;
+ size_t len = 0;
+ int task_fd;
+ int freezer_fd;
+ char *freezer_procs;
+ char *freezer_state;
+ int ret;
+
+ ret = asprintf(&fuser_cmd, "fuser -m %s | grep -o '[0-9]*'", part_path);
+ if (ret < 0)
+ return -1;
+
+ fuser_fp = popen(fuser_cmd, "r");
+ free(fuser_cmd);
+ if (fuser_fp == NULL)
+ return -1;
+
+ ret = asprintf(&freezer_procs, "/sys/fs/cgroup/freezer/%s/cgroup.procs", frz_name);
+ if (ret < 0) {
+ pclose(fuser_fp);
+ return -1;
+ }
+
+ task_fd = open(freezer_procs, O_RDWR);
+ free(freezer_procs);
+ if (task_fd < 0) {
+ pclose(fuser_fp);
+ return -1;
+ }
+
+ while (getline(&line, &len, fuser_fp) != -1) {
+ int ret;
+ int str_len = strlen(line);
+ if (str_len <= 1)
+ continue;
+
+ ret = write(task_fd, line, str_len-1);
+ if (ret < 0)
+ break;
+ }
+
+ close(task_fd);
+ free(line);
+ pclose(fuser_fp);
+
+ ret = asprintf(&freezer_state, "/sys/fs/cgroup/freezer/%s/freezer.state", frz_name);
+ if (ret < 0)
+ return -1;
+
+ freezer_fd = open(freezer_state, O_RDWR);
+ free(freezer_state);
+ if (freezer_fd < 0)
+ return -1;
+
+ ret = write(freezer_fd, CMD_FROZEN, strlen(CMD_FROZEN));
+ close(freezer_fd);
+ if (ret < 0)
+ return -1;
+
+ return 0;
+}
+
+static bool check_frozen(const char *frz_name)
+{
+ char *state_path = NULL;
+ char *line = NULL;
+ size_t len = 0;
+ FILE *fd;
+ int ret;
+ bool result = false;
+
+ ret = asprintf(&state_path, "/sys/fs/cgroup/freezer/%s/freezer.state", frz_name);
+ if (ret < 0)
+ return false;
+
+ fd = fopen(state_path, "r");
+ free(state_path);
+ if (fd == NULL)
+ return false;
+
+ ret = getline(&line, &len, fd);
+ if (ret != -1 && line) {
+ if (!strncmp(line, CMD_FROZEN, strlen(CMD_FROZEN)))
+ result = true;
+ else
+ result = false;
+
+ }
+
+ free(line);
+ fclose(fd);
+
+ return result;
+}
+
+static int thaw_processes_on_path(const char *frz_name)
+{
+ int freezer_fd;
+ int ret;
+
+ char *freezer_state;
+ ret = asprintf(&freezer_state, "/sys/fs/cgroup/freezer/%s/freezer.state", frz_name);
+ if (ret < 0)
+ return -1;
+
+ freezer_fd = open(freezer_state, O_RDWR);
+ free(freezer_state);
+ if (freezer_fd < 0)
+ return -1;
+
+ ret = write(freezer_fd, CMD_THAWED, strlen(CMD_THAWED));
+ close(freezer_fd);
+ if (ret < 0)
+ return -1;
+
+ return 0;
+}
+
+static void suspend_path(const char *frz_name, const char *path, const int max_retry)
+{
+ bool frozen = false;
+ int retry = 0;
+
+ freeze_processes_on_path(frz_name, path);
+
+ do {
+ usleep((useconds_t)MSEC_TO_USEC(500));
+
+ frozen = check_frozen(frz_name);
+
+ retry++;
+
+ } while (!frozen && retry < max_retry);
+}
+
+static void resume_path(const char *frz_name, const char *path)
+{
+ thaw_processes_on_path(frz_name);
+}
+
static int check_path_available(char *mountpath)
{
const char *path;