int open_image_dir(char *dir) { int fd, ret; fd = open(dir, O_RDONLY); if (fd < 0) { pr_perror("Can't open dir %s", dir); return -1; } ret = install_service_fd(IMG_FD_OFF, fd); close(fd); fd = ret; if (opts.img_parent) { ret = symlinkat(opts.img_parent, fd, CR_PARENT_LINK); if (ret < 0 && errno != EEXIST) { pr_perror("Can't link parent snapshot"); goto err; } } return 0; err: close_image_dir(); return -1; }
int open_image_dir(char *dir) { int fd, ret; fd = open(dir, O_RDONLY); if (fd < 0) { pr_perror("Can't open dir %s", dir); return -1; } ret = install_service_fd(IMG_FD_OFF, fd); close(fd); fd = ret; if (opts.img_parent) { ret = symlinkat(opts.img_parent, fd, CR_PARENT_LINK); if (ret < 0 && errno != EEXIST) { pr_perror("Can't link parent snapshot"); goto err; } if (opts.img_parent[0] == '/') pr_warn("Absolute paths for parent links " "may not work on restore!\n"); } return 0; err: close_image_dir(); return -1; }
int log_init(const char *output) { int new_logfd, fd; gettimeofday(&start, NULL); buf_off = TS_BUF_OFF; if (output) { new_logfd = open(output, O_CREAT|O_TRUNC|O_WRONLY|O_APPEND, 0600); if (new_logfd < 0) { pr_perror("Can't create log file %s", output); return -1; } } else { new_logfd = dup(DEFAULT_LOGFD); if (new_logfd < 0) { pr_perror("Can't dup log file"); return -1; } } fd = install_service_fd(LOG_FD_OFF, new_logfd); close(new_logfd); if (fd < 0) goto err; return 0; err: pr_perror("Log engine failure, can't duplicate descriptor"); return -1; }
int open_image_dir(char *dir) { int fd, ret; fd = open(dir, O_RDONLY); if (fd < 0) { pr_perror("Can't open dir %s", dir); return -1; } ret = install_service_fd(IMG_FD_OFF, fd); if (opts.img_parent) { int pfd; ret = symlinkat(opts.img_parent, fd, CR_PARENT_LINK); if (ret < 0) { pr_perror("Can't link parent snapshot."); goto err; } pfd = openat(fd, CR_PARENT_LINK, O_RDONLY); if (pfd < 0) { pr_perror("Can't open parent snapshot."); goto err; } ret = install_service_fd(PARENT_FD_OFF, pfd); close(pfd); } close(fd); return ret; err: close_image_dir(); return -1; }
int open_image_dir(void) { int fd, ret; fd = open(".", O_RDONLY); if (fd < 0) { pr_perror("Can't open cwd"); return -1; } ret = install_service_fd(IMG_FD_OFF, fd); close(fd); if (opts.img_parent) { ret = symlink(opts.img_parent, CR_PARENT_LINK); if (ret < 0) { pr_perror("Can't link parent snapshot."); goto err; } fd = open(CR_PARENT_LINK, O_RDONLY); if (fd < 0) { pr_perror("Can't open parent snapshot."); goto err; } ret = install_service_fd(PARENT_FD_OFF, fd); close(fd); } return ret; err: close_image_dir(); return -1; }
int log_init(const char *output) { int new_logfd, fd; gettimeofday(&start, NULL); reset_buf_off(); if (output && !strncmp(output, "-", 2)) { new_logfd = dup(STDOUT_FILENO); if (new_logfd < 0) { pr_perror("Can't dup stdout stream"); return -1; } } else if (output) { new_logfd = open(output, O_CREAT|O_TRUNC|O_WRONLY|O_APPEND, 0600); if (new_logfd < 0) { pr_perror("Can't create log file %s", output); return -1; } } else { new_logfd = dup(DEFAULT_LOGFD); if (new_logfd < 0) { pr_perror("Can't dup log file"); return -1; } } fd = install_service_fd(LOG_FD_OFF, new_logfd); if (fd < 0) goto err; print_versions(); return 0; err: pr_perror("Log engine failure, can't duplicate descriptor"); return -1; }