static int wlan_device_get_mac_addr(unsigned char *buf) { char macaddr[20]; int mac_len = 0; void *fp; if (!buf){ pr_err("%s, null parameter !!\n", __func__); return -EFAULT; } fp = open_image(CUSTOMER_MAC_FILE); if (fp == NULL) return -EFAULT; mac_len = get_image_block(macaddr, 17, fp); if (mac_len < 17) return -EFAULT; wlan_mac_addr[0] = (unsigned char)((char2bin(macaddr[0]) << 4) | char2bin(macaddr[1])); wlan_mac_addr[1] = (unsigned char)((char2bin(macaddr[3]) << 4) | char2bin(macaddr[4])); wlan_mac_addr[2] = (unsigned char)((char2bin(macaddr[6]) << 4) | char2bin(macaddr[7])); wlan_mac_addr[3] = (unsigned char)((char2bin(macaddr[9]) << 4) | char2bin(macaddr[10])); wlan_mac_addr[4] = (unsigned char)((char2bin(macaddr[12]) << 4) | char2bin(macaddr[13])); wlan_mac_addr[5] = (unsigned char)((char2bin(macaddr[15]) << 4) | char2bin(macaddr[16])); memcpy(buf, wlan_mac_addr, IFHWADDRLEN); pr_info("wifi mac: %x:%x:%x:%x:%x:%x\n", wlan_mac_addr[0], wlan_mac_addr[1], wlan_mac_addr[2], wlan_mac_addr[3], wlan_mac_addr[4], wlan_mac_addr[5]); close_image(fp); return 0; }
struct cr_fdset *cr_fdset_open_range(int pid, int from, int to, unsigned long flags) { struct cr_fdset *fdset; unsigned int i; int ret = -1; fdset = alloc_cr_fdset(to - from); if (!fdset) goto err; from++; fdset->fd_off = from; for (i = from; i < to; i++) { ret = open_image(i, flags, pid); if (ret < 0) { if (!(flags & O_CREAT)) /* caller should check himself */ continue; goto err; } fdset->_fds[i - from] = ret; } return fdset; err: close_cr_fdset(&fdset); return NULL; }
struct cr_imgset *cr_imgset_open_range(int pid, int from, int to, unsigned long flags) { struct cr_imgset *imgset; unsigned int i; imgset = alloc_cr_imgset(to - from); if (!imgset) goto err; from++; imgset->fd_off = from; for (i = from; i < to; i++) { struct cr_img *img; img = open_image(i, flags, pid); if (!img) { if (!(flags & O_CREAT)) /* caller should check himself */ continue; goto err; } imgset->_imgs[i - from] = img; } return imgset; err: close_cr_imgset(&imgset); return NULL; }
/* This function also initializes the data and code heaps */ void factor_vm::load_image(vm_parameters* p) { FILE* file = open_image(p); if (file == NULL) { std::cout << "Cannot open image file: " << p->image_path << std::endl; char *msg = threadsafe_strerror(errno); std::cout << "strerror:2: " << msg << std::endl; free(msg); exit(1); } image_header h; if (raw_fread(&h, sizeof(image_header), 1, file) != 1) fatal_error("Cannot read image header", 0); if (h.magic != image_magic) fatal_error("Bad image: magic number check failed", h.magic); if (h.version != image_version) fatal_error("Bad image: version number check failed", h.version); load_data_heap(file, &h, p); load_code_heap(file, &h, p); raw_fclose(file); /* Certain special objects in the image are known to the runtime */ memcpy(special_objects, h.special_objects, sizeof(special_objects)); cell data_offset = data->tenured->start - h.data_relocation_base; cell code_offset = code->allocator->start - h.code_relocation_base; fixup_heaps(data_offset, code_offset); /* Store image path name */ special_objects[OBJ_IMAGE] = allot_alien(false_object, (cell)p->image_path); }
int check_img_inventory(void) { int fd, ret = -1; InventoryEntry *he; fd = open_image(CR_FD_INVENTORY, O_RSTR); if (fd < 0) return -1; if (pb_read_one(fd, &he, PB_INVENTORY) < 0) goto out_close; fdinfo_per_id = he->has_fdinfo_per_id ? he->fdinfo_per_id : false; ns_per_id = he->has_ns_per_id ? he->ns_per_id : false; if (he->root_ids) { root_ids = xmalloc(sizeof(*root_ids)); if (!root_ids) goto out_err; memcpy(root_ids, he->root_ids, sizeof(*root_ids)); } if (he->img_version != CRTOOLS_IMAGES_V1) { pr_err("Not supported images version %u\n", he->img_version); goto out_err; } ret = 0; out_err: inventory_entry__free_unpacked(he, NULL); out_close: close(fd); return ret; }
int write_img_inventory(void) { int fd; InventoryEntry he = INVENTORY_ENTRY__INIT; struct pstree_item crt = { }; pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1); fd = open_image(CR_FD_INVENTORY, O_DUMP); if (fd < 0) return -1; he.img_version = CRTOOLS_IMAGES_V1; he.fdinfo_per_id = true; he.has_fdinfo_per_id = true; he.ns_per_id = true; he.has_ns_per_id = true; crt.state = TASK_ALIVE; crt.pid.real = getpid(); if (get_task_ids(&crt)) { close(fd); return -1; } he.root_ids = crt.ids; if (pb_write_one(fd, &he, PB_INVENTORY) < 0) return -1; xfree(crt.ids); close(fd); return 0; }
int cpu_dump_cpuinfo(void) { CpuinfoEntry cpu_info = CPUINFO_ENTRY__INIT; CpuinfoX86Entry cpu_x86_info = CPUINFO_X86_ENTRY__INIT; CpuinfoX86Entry *cpu_x86_info_ptr = &cpu_x86_info; struct cr_img *img; img = open_image(CR_FD_CPUINFO, O_DUMP); if (!img) return -1; cpu_info.x86_entry = &cpu_x86_info_ptr; cpu_info.n_x86_entry = 1; cpu_x86_info.vendor_id = (rt_cpu_info.x86_vendor == X86_VENDOR_INTEL) ? CPUINFO_X86_ENTRY__VENDOR__INTEL : CPUINFO_X86_ENTRY__VENDOR__AMD; cpu_x86_info.cpu_family = rt_cpu_info.x86_family; cpu_x86_info.model = rt_cpu_info.x86_model; cpu_x86_info.stepping = rt_cpu_info.x86_mask; cpu_x86_info.capability_ver = 1; cpu_x86_info.n_capability = ARRAY_SIZE(rt_cpu_info.x86_capability); cpu_x86_info.capability = (void *)rt_cpu_info.x86_capability; if (rt_cpu_info.x86_model_id[0]) cpu_x86_info.model_id = rt_cpu_info.x86_model_id; if (pb_write_one(img, &cpu_info, PB_CPUINFO) < 0) { close_image(img); return -1; } close_image(img); return 0; }
static int tmpfs_dump(struct mount_info *pm) { int ret = -1; char tmpfs_path[PATH_MAX]; int fd, fd_img = -1; DIR *fdir = NULL; fdir = open_mountpoint(pm); if (fdir == NULL) return -1; fd = dirfd(fdir); if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) & ~FD_CLOEXEC) == -1) { pr_perror("Can not drop FD_CLOEXEC"); goto out; } fd_img = open_image(CR_FD_TMPFS, O_DUMP, pm->mnt_id); if (fd_img < 0) goto out; snprintf(tmpfs_path, sizeof(tmpfs_path), "/proc/self/fd/%d", fd); ret = cr_system(-1, fd_img, -1, "tar", (char *[]) { "tar", "--create", "--gzip", "--check-links", "--preserve-permissions", "--sparse", "--numeric-owner", "--directory", tmpfs_path, ".", NULL });
static gboolean open_event( GtkWidget *widget, gpointer data ) { GtkWidget *dialog; GtkFileFilter *filter = gtk_file_filter_new(); gtk_file_filter_add_pattern(filter, "*.jpc"); dialog = gtk_file_chooser_dialog_new ("Open File", GTK_WINDOW(bdk_window.fenster), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { char *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); open_image(filename); } gtk_widget_destroy (dialog); return FALSE; }
static int prepare_ipc_var(int pid) { int ret; struct cr_img *img; IpcVarEntry *var; pr_info("Restoring IPC variables\n"); img = open_image(CR_FD_IPC_VAR, O_RSTR, pid); if (!img) return -1; ret = pb_read_one(img, &var, PB_IPC_VAR); close_image(img); if (ret <= 0) { pr_err("Failed to read IPC namespace variables\n"); return -EFAULT; } ret = ipc_sysctl_req(var, CTL_WRITE); ipc_var_entry__free_unpacked(var, NULL); if (ret < 0) { pr_err("Failed to prepare IPC namespace variables\n"); return -EFAULT; } return 0; }
int prepare_utsns(int pid) { int ret; struct cr_img *img; UtsnsEntry *ue; struct sysctl_req req[] = { { "kernel/hostname" }, { "kernel/domainname" }, }; img = open_image(CR_FD_UTSNS, O_RSTR, pid); if (!img) return -1; ret = pb_read_one(img, &ue, PB_UTSNS); if (ret < 0) goto out; req[0].arg = ue->nodename; req[0].type = CTL_STR(strlen(ue->nodename)); req[1].arg = ue->domainname; req[1].type = CTL_STR(strlen(ue->domainname)); ret = sysctl_op(req, ARRAY_SIZE(req), CTL_WRITE, CLONE_NEWUTS); utsns_entry__free_unpacked(ue, NULL); out: close_image(img); return ret; }
int dump_uts_ns(int ns_id) { int ret; struct cr_img *img; struct utsname ubuf; UtsnsEntry ue = UTSNS_ENTRY__INIT; img = open_image(CR_FD_UTSNS, O_DUMP, ns_id); if (!img) return -1; ret = uname(&ubuf); if (ret < 0) { pr_perror("Error calling uname"); goto err; } ue.nodename = ubuf.nodename; ue.domainname = ubuf.domainname; ret = pb_write_one(img, &ue, PB_UTSNS); err: close_image(img); return ret < 0 ? -1 : 0; }
void write_stats(int what) { StatsEntry stats = STATS_ENTRY__INIT; DumpStatsEntry dstats = DUMP_STATS_ENTRY__INIT; char *name; int fd; pr_info("Writing stats\n"); if (what == DUMP_STATS) { stats.dump = &dstats; encode_time(TIME_FREEZING, &dstats.freezing_time); encode_time(TIME_FROZEN, &dstats.frozen_time); encode_time(TIME_MEMDUMP, &dstats.memdump_time); encode_time(TIME_MEMWRITE, &dstats.memwrite_time); dstats.pages_scanned = counts[CNT_PAGES_SCANNED]; dstats.pages_skipped_parent = counts[CNT_PAGES_SKIPPED_PARENT]; dstats.pages_written = counts[CNT_PAGES_WRITTEN]; name = "dump"; } else return; fd = open_image(CR_FD_STATS, O_DUMP, name); if (fd >= 0) { pb_write_one(fd, &stats, PB_STATS); close(fd); } }
int main(int argc, char* argv[]) { FILE *in; int **image; double **image_i; double **image_d; int c; int N; int coeff_start = 5000, wm_length = 10000; double wm_alpha = 0.2; int width, height; pgm_init(&argc, argv); wm_init2(); while ((c = getopt(argc, argv, "a:s:l:")) != EOF) { switch (c) { case 'a': wm_alpha = atof(optarg); break; case 's': coeff_start = atoi(optarg); break; case 'l': wm_length = atoi(optarg); break; } } argc -= optind; argv += optind; in = stdin; open_image(in, &width, &height); image = imatrix(height, width); load_image(image, in, width, height); if (height == width) N = height; else { fprintf(stderr, "Cannot Proccess non-square images!\n"); exit( -11); } image_i = dmatrix(height, width); image_d = dmatrix(height, width); if (image_d == NULL) { fprintf(stderr, "Unable to allocate the double array\n"); exit(1); } matrix_i2d(image, image_i, N); hartley(image_i, image_d, N); read_watermark(image_d, N, coeff_start, wm_length, wm_alpha); freematrix_d(image_i, height); freematrix_d(image_d, height); fclose(in); exit(EXIT_SUCCESS); }
/***********************************************************************//** * @brief Open FITS image * * @param[in] vptr FITS file pointer * * Open FITS image in FITS file. Opening means connecting the FITS file * pointer to the image and reading the image and axes dimensions. ***************************************************************************/ void GFitsImage::data_open(void* vptr) { // Open image open_image(vptr); // Return return; }
int main(int argc, char* argv[]) { FILE *in; int **image_i; double *image_f = NULL; int N; int c; int coeff_start = 5000, wm_length = 10000; double wm_alpha = 0.2; pgm_init(&argc, argv); wm_init2(); while ((c = getopt(argc, argv, "a:s:l:")) != EOF) { switch (c) { case 'a': wm_alpha = atof(optarg); break; case 's': coeff_start = atoi(optarg); break; case 'l': wm_length = atoi(optarg); break; } } argc -= optind; argv += optind; in = stdin; open_image(in, &width, &height); image_i = imatrix(height, width); load_image(image_i, in, width, height); if (height == width) N = height; else { fprintf(stderr, "Cannot Proccess non-square images!\n"); exit( -11); } initialize_constants(); image_f = (double *)calloc(N * N, sizeof(double)); if (image_f == NULL) { printf("Unable to allocate the float array\n"); exit(1); } put_image_from_int_2_double(image_i, image_f, N); fct2d(image_f, N, N); read_watermark(image_f, N, coeff_start, wm_length, wm_alpha); fclose(in); freematrix(image_i, height); free(image_f); exit(EXIT_SUCCESS); }
int check_img_inventory(void) { int ret = -1; struct cr_img *img; InventoryEntry *he; img = open_image(CR_FD_INVENTORY, O_RSTR); if (!img) return -1; if (pb_read_one(img, &he, PB_INVENTORY) < 0) goto out_close; fdinfo_per_id = he->has_fdinfo_per_id ? he->fdinfo_per_id : false; ns_per_id = he->has_ns_per_id ? he->ns_per_id : false; if (he->root_ids) { root_ids = xmalloc(sizeof(*root_ids)); if (!root_ids) goto out_err; memcpy(root_ids, he->root_ids, sizeof(*root_ids)); } if (he->has_root_cg_set) { if (he->root_cg_set == 0) { pr_err("Corrupted root cgset\n"); goto out_err; } root_cg_set = he->root_cg_set; } image_lsm = he->lsmtype; switch (he->img_version) { case CRTOOLS_IMAGES_V1: /* good old images. OK */ img_common_magic = false; break; case CRTOOLS_IMAGES_V1_1: /* newer images with extra magic in the head */ break; default: pr_err("Not supported images version %u\n", he->img_version); goto out_err; } ret = 0; out_err: inventory_entry__free_unpacked(he, NULL); out_close: close_image(img); return ret; }
int collect_image(struct collect_image_info *cinfo) { int fd, ret; void *(*o_alloc)(size_t size) = malloc; void (*o_free)(void *ptr) = free; pr_info("Collecting %d/%d (flags %x)\n", cinfo->fd_type, cinfo->pb_type, cinfo->flags); fd = open_image(cinfo->fd_type, O_RSTR); if (fd < 0) { if ((cinfo->flags & COLLECT_OPTIONAL) && (errno == ENOENT)) return 0; else return -1; } if (cinfo->flags & COLLECT_SHARED) { o_alloc = shmalloc; o_free = shfree_last; } while (1) { void *obj; ProtobufCMessage *msg; if (cinfo->priv_size) { ret = -1; obj = o_alloc(cinfo->priv_size); if (!obj) break; } else obj = NULL; ret = pb_read_one_eof(fd, &msg, cinfo->pb_type); if (ret <= 0) { o_free(obj); break; } ret = cinfo->collect(obj, msg); if (ret < 0) { o_free(obj); cr_pb_descs[cinfo->pb_type].free(msg, NULL); break; } if (!cinfo->priv_size) cr_pb_descs[cinfo->pb_type].free(msg, NULL); } close(fd); pr_debug(" `- ... done\n"); return ret; }
static int restore_tcp_conn_state(int sk, struct inet_sk_info *ii) { int ifd, aux; TcpStreamEntry *tse; pr_info("Restoring TCP connection id %x ino %x\n", ii->ie->id, ii->ie->ino); ifd = open_image(CR_FD_TCP_STREAM, O_RSTR, ii->ie->ino); if (ifd < 0) goto err; if (pb_read_one(ifd, &tse, PB_TCP_STREAM) < 0) goto err_c; if (restore_tcp_seqs(sk, tse)) goto err_c; if (inet_bind(sk, ii)) goto err_c; if (inet_connect(sk, ii)) goto err_c; if (restore_tcp_opts(sk, tse)) goto err_c; if (restore_tcp_queues(sk, tse, ifd)) goto err_c; if (tse->has_nodelay && tse->nodelay) { aux = 1; if (restore_opt(sk, SOL_TCP, TCP_NODELAY, &aux)) goto err_c; } if (tse->has_cork && tse->cork) { aux = 1; if (restore_opt(sk, SOL_TCP, TCP_CORK, &aux)) goto err_c; } tcp_stream_entry__free_unpacked(tse, NULL); close(ifd); return 0; err_c: tcp_stream_entry__free_unpacked(tse, NULL); close(ifd); err: return -1; }
static int open_remap_ghost(struct reg_file_info *rfi, RemapFilePathEntry *rfe) { struct ghost_file *gf = container_of(rfi->remap, struct ghost_file, remap); GhostFileEntry *gfe = NULL; struct cr_img *img; if (rfi->remap->rpath[0]) return 0; img = open_image(CR_FD_GHOST_FILE, O_RSTR, rfe->remap_id); if (!img) goto err; if (pb_read_one(img, &gfe, PB_GHOST_FILE) < 0) goto close_ifd; /* * For old formats where optional has_[dev|ino] is * not present we will have zeros here which is quite * a sign for "absent" fields. */ gf->dev = gfe->dev; gf->ino = gfe->ino; gf->remap.rmnt_id = rfi->rfe->mnt_id; if (S_ISDIR(gfe->mode)) strncpy(gf->remap.rpath, rfi->path, PATH_MAX); else ghost_path(gf->remap.rpath, PATH_MAX, rfi, rfe); if (create_ghost(gf, gfe, img)) goto close_ifd; close_image(img); gf->remap.is_dir = S_ISDIR(gfe->mode); gf->remap.uid = gfe->uid; gf->remap.gid = gfe->gid; ghost_file_entry__free_unpacked(gfe, NULL); return 0; close_ifd: close_image(img); err: if (gfe) ghost_file_entry__free_unpacked(gfe, NULL); return -1; }
int write_img_inventory(InventoryEntry *he) { struct cr_img *img; pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1); img = open_image(CR_FD_INVENTORY, O_DUMP); if (!img) return -1; if (pb_write_one(img, he, PB_INVENTORY) < 0) return -1; xfree(he->root_ids); close_image(img); return 0; }
int prepare_seccomp_filters(void) { struct cr_img *img; int ret; img = open_image(CR_FD_SECCOMP, O_RSTR); if (!img) return -1; ret = pb_read_one_eof(img, &se, PB_SECCOMP); close_image(img); if (ret <= 0) return 0; /* there were no filters */ BUG_ON(!se); return 0; }
int write_img_inventory(void) { int fd; InventoryEntry he = INVENTORY_ENTRY__INIT; pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1); fd = open_image(CR_FD_INVENTORY, O_DUMP); if (fd < 0) return -1; he.img_version = CRTOOLS_IMAGES_V1; if (pb_write_one(fd, &he, PB_INVENTORY) < 0) return -1; close(fd); return 0; }
static gchar *menu_open (void) { //GtkWidget *pWindow; //GtkWidget *pButton; GtkWidget *pFileSelection; GtkWidget *pDialog; gchar *sChemin=""; /* Creation de la fenetre de selection */ pFileSelection = gtk_file_chooser_dialog_new("Ouvrir...",NULL ,GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN, GTK_RESPONSE_OK,NULL); /* On limite les actions a cette fenetre */ gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); /* Affichage fenetre */ switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { case GTK_RESPONSE_OK: /* Recuperation du chemin */ sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Chemin du fichier :\n%s", sChemin); gtk_dialog_run(GTK_DIALOG(pDialog)); gtk_widget_destroy(pDialog); break; default: break; } gtk_widget_destroy(pFileSelection); open_image(sChemin,p_vBox); g_free(sChemin); return sChemin ; }
int write_img_inventory(void) { struct cr_img *img; InventoryEntry he = INVENTORY_ENTRY__INIT; struct { struct pstree_item i; struct dmp_info d; } crt = { }; pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1); img = open_image(CR_FD_INVENTORY, O_DUMP); if (!img) return -1; he.img_version = CRTOOLS_IMAGES_V1_1; he.fdinfo_per_id = true; he.has_fdinfo_per_id = true; he.ns_per_id = true; he.has_ns_per_id = true; he.lsmtype = host_lsm_type(); crt.i.state = TASK_ALIVE; crt.i.pid.real = getpid(); if (get_task_ids(&crt.i)) { close_image(img); return -1; } he.has_root_cg_set = true; if (dump_task_cgroup(NULL, &he.root_cg_set)) return -1; he.root_ids = crt.i.ids; if (pb_write_one(img, &he, PB_INVENTORY) < 0) return -1; xfree(crt.i.ids); close_image(img); return 0; }
int cpu_validate_cpuinfo(void) { CpuinfoX86Entry *img_x86_entry; CpuinfoEntry *img_cpu_info; struct cr_img *img; int ret = -1; img = open_image(CR_FD_CPUINFO, O_RSTR); if (!img) return -1; if (pb_read_one(img, &img_cpu_info, PB_CPUINFO) < 0) goto err; if (img_cpu_info->n_x86_entry != 1) { pr_err("No x86 related cpuinfo in image, " "corruption (n_x86_entry = %zi)\n", img_cpu_info->n_x86_entry); goto err; } img_x86_entry = img_cpu_info->x86_entry[0]; if (img_x86_entry->vendor_id != CPUINFO_X86_ENTRY__VENDOR__INTEL && img_x86_entry->vendor_id != CPUINFO_X86_ENTRY__VENDOR__AMD) { pr_err("Unknown cpu vendor %d\n", img_x86_entry->vendor_id); goto err; } if (img_x86_entry->n_capability != ARRAY_SIZE(rt_cpu_info.x86_capability)) { pr_err("Image carries %u words while %u expected\n", (unsigned)img_x86_entry->n_capability, (unsigned)ARRAY_SIZE(rt_cpu_info.x86_capability)); goto err; } ret = cpu_validate_features(img_x86_entry); err: close_image(img); return ret; }
static int prepare_ipc_shm(int pid) { int ret; struct cr_img *img; pr_info("Restoring IPC shared memory\n"); img = open_image(CR_FD_IPCNS_SHM, O_RSTR, pid); if (!img) return -1; while (1) { IpcShmEntry *shm; ret = pb_read_one_eof(img, &shm, PB_IPC_SHM); if (ret < 0) { pr_err("Failed to read IPC shared memory segment\n"); ret = -EIO; goto err; } if (ret == 0) break; pr_info_ipc_shm(shm); ret = prepare_ipc_shm_seg(img, shm); ipc_shm_entry__free_unpacked(shm, NULL); if (ret < 0) { pr_err("Failed to prepare shm segment\n"); goto err; } } close_image(img); return 0; err: close_image(img); return ret; }
static int prepare_ipc_msg(int pid) { int ret; struct cr_img *img; pr_info("Restoring IPC message queues\n"); img = open_image(CR_FD_IPCNS_MSG, O_RSTR, pid); if (!img) return -1; while (1) { IpcMsgEntry *msq; ret = pb_read_one_eof(img, &msq, PB_IPCNS_MSG_ENT); if (ret < 0) { pr_err("Failed to read IPC messages queue\n"); ret = -EIO; goto err; } if (ret == 0) break; pr_info_ipc_msg_entry(msq); ret = prepare_ipc_msg_queue(img, msq); ipc_msg_entry__free_unpacked(msq, NULL); if (ret < 0) { pr_err("Failed to prepare messages queue\n"); goto err; } } close_image(img); return 0; err: close_image(img); return ret; }
static int prepare_ipc_sem(int pid) { int ret; struct cr_img *img; pr_info("Restoring IPC semaphores sets\n"); img = open_image(CR_FD_IPCNS_SEM, O_RSTR, pid); if (!img) return -1; while (1) { IpcSemEntry *sem; ret = pb_read_one_eof(img, &sem, PB_IPC_SEM); if (ret < 0) { ret = -EIO; goto err; } if (ret == 0) break; pr_info_ipc_sem_entry(sem); ret = prepare_ipc_sem_desc(img, sem); ipc_sem_entry__free_unpacked(sem, NULL); if (ret < 0) { pr_err("Failed to prepare semaphores set\n"); goto err; } } close_image(img); return 0; err: close_image(img); return ret; }
static int scene_reloadimage(dword selidx) { int result; reset_image_ptr(); if (where == scene_in_zip || where == scene_in_chm || where == scene_in_rar) STRCPY_S(filename, filelist[selidx].compname->ptr); else { STRCPY_S(filename, config.shortpath); STRCAT_S(filename, filelist[selidx].shortname->ptr); } if (config.use_image_queue) { result = cache_get_image(selidx); } else { result = open_image(selidx); } if (result != 0) { report_image_error(result); return -1; } // already calc brightness in cacher if (!config.use_image_queue && config.imgbrightness != 100) { recalc_brightness(); } STRCPY_S(config.lastfile, filelist[selidx].compname->ptr); STRCPY_S(prev_path, config.path); STRCPY_S(prev_shortpath, config.shortpath); STRCPY_S(prev_lastfile, filelist[selidx].compname->ptr); prev_where = where; oldangle = 0; return 0; }