int get_next_line(int const fd, char **line) { static t_list *lst; t_gnl *gnl; char *temp; int ret; if (fd < 0 || line == NULL) return (-1); gnl = get_gnl(&lst, fd); temp = ft_strnew(0); while (gnl->count > 0) { if ((ret = read_buffer(gnl, &lst, &temp, line)) != 0) return (ret); while (gnl->i < gnl->count) { temp = ft_strmerge(temp, get_append(gnl)); if (gnl->nl) { *line = temp; return (1); } } } del_gnl(&lst, fd, &temp); return (0); }
void arch_usage(void) { printf( " none\n\n" "Default options:\n" " --append=\"%s\"\n" " STRING of --append is set from /proc/cmdline as default.\n" ,get_append()); }
void arch_usage(void) { printf( " none\n\n" "Default options:\n" " --append=\"%s\"\n" " --empty-zero=0x%08x\n\n" " STRING of --appned is set form /proc/cmdline as default.\n" " ADDRESS of --empty-zero can be set SHELL environment variable\n" " KEXEC_EMPTY_ZERO as default.\n\n" " ADDRESS can be get in the following method in your system. \n" " 1) \"grep empty_zero /proc/kallsyms\". \n" " 2) \"grep empty_zero System.map\". \n" " 3) CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET in your kernel\n" " config file.\n" ,get_append(), (unsigned int) get_empty_zero(NULL)); }
int zImage_sh_load(int argc, char **argv, const char *buf, off_t len, struct kexec_info *info) { char *command_line; int opt; unsigned long empty_zero, zero_page_base, zero_page_size, k; unsigned long image_base; char *param; static const struct option options[] = { KEXEC_ARCH_OPTIONS {0, 0, 0, 0}, }; static const char short_options[] = KEXEC_ARCH_OPT_STR ""; command_line = 0; while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) { switch (opt) { default: /* Ignore core options */ if (opt < OPT_ARCH_MAX) { break; } case '?': usage(); return -1; case OPT_APPEND: command_line = optarg; break; } } if (!command_line) command_line = get_append(); /* assume the zero page is the page before the vmlinux entry point. * we don't know the page size though, but 64k seems to be max. * put several 4k zero page copies before the entry point to cover * all combinations. */ empty_zero = zImage_head32(buf, HEAD32_KERNEL_START_ADDR); zero_page_size = 0x10000; zero_page_base = virt_to_phys(empty_zero - zero_page_size); while (!valid_memory_range(info, zero_page_base, zero_page_base + zero_page_size - 1)) { zero_page_base += 0x1000; zero_page_size -= 0x1000; if (zero_page_size == 0) die("Unable to determine zero page size from %p \n", (void *)empty_zero); } param = xmalloc(zero_page_size); for (k = 0; k < (zero_page_size / 0x1000); k++) kexec_sh_setup_zero_page(param + (k * 0x1000), 0x1000, command_line); add_segment(info, param, zero_page_size, 0x80000000 | zero_page_base, zero_page_size); /* load image a bit above the zero page, round up to 64k * the zImage will relocate itself, but only up seems supported. */ image_base = (empty_zero + (0x10000 - 1)) & ~(0x10000 - 1); add_segment(info, buf, len, image_base, len); info->entry = (void *)virt_to_phys(image_base); return 0; }