+int is_install_pkg_file = 0;
+
+static void set_syncfile_smack_label(char *src) {
+ char *label_transmuted = NULL;
+ char *label = NULL;
+ char *src_chr = strrchr(src, '/');
+ int pos = src_chr - src + 1;
+ char dirname[512];
+
+ if (getuid() != 0) {
+ D("need root permission to set smack label: %d\n", getuid());
+ return;
+ }
+
+ snprintf(dirname, pos, "%s", src);
+
+ //D("src:[%s], dirname:[%s]\n", src, dirname);
+ int rc = smack_getlabel(dirname, &label_transmuted, SMACK_LABEL_TRANSMUTE);
+
+ if (rc == 0 && label_transmuted != NULL) {
+ if (!strcmp("TRUE", label_transmuted)) {
+ rc = smack_getlabel(dirname, &label, SMACK_LABEL_ACCESS);
+ if (rc == 0 && label != NULL) {
+ if (smack_setlabel(src, label, SMACK_LABEL_ACCESS) == -1) {
+ D("unable to set sync file smack label %s due to %s\n", label, strerror(errno));
+ }
+ free(label);
+ }
+ } else{
+ D("fail to set label, is it transmuted?:%s\n", label_transmuted);
+ }
+ free(label_transmuted);
+ } else {
+ if (smack_setlabel(src, SMACK_SYNC_FILE_LABEL, SMACK_LABEL_ACCESS) == -1) {
+ D("unable to set sync file smack label %s due to (errno:%d)\n", SMACK_SYNC_FILE_LABEL, errno);
+ }
+ }
+}
+
+static int sync_send_label_notify(int s, const char *path, int success)
+{
+ char buffer[512] = {0,};
+ snprintf(buffer, sizeof(buffer), "%d:%s", success, path);
+
+ int len = sdb_write(s, buffer, sizeof(buffer));
+
+ return len;
+}
+
+static void sync_read_label_notify(int s)
+{
+ char buffer[512] = {0,};
+
+ while (1) {
+ int len = sdb_read(s, buffer, sizeof(buffer));
+ if (len < 0) {
+ D("sync notify read error : (errno:%d)\n", errno);
+ exit(-1);
+ }
+
+ if (buffer[0] == '0') {
+ D("sync notify child process exit\n");
+ exit(-1);
+ }
+ buffer[511] = '\0';
+ char *path = buffer;
+ path++;
+ path++;
+ set_syncfile_smack_label(path);
+ }
+}
+
+static int mkdirs(int noti_fd, char *name)