/* * Returns the contents of the current command line to be used with * --reuse-cmdline option. The function gets called from architecture specific * code. If we load a panic kernel, that function will strip the * "crashkernel=" option because it does not make sense that the crashkernel * reserves memory for a crashkernel (well, it would not boot since the * amount is exactly the same as the crashkernel has overall memory). Also, * remove the BOOT_IMAGE from lilo (and others) since that doesn't make * sense here any more. The kernel could be different even if we reuse the * commandline. * * The function returns dynamically allocated memory. */ char *get_command_line(void) { FILE *fp; size_t len; char *line = NULL; fp = fopen("/proc/cmdline", "r"); if (!fp) die("Could not read /proc/cmdline."); // getline(&line, &len, fp); line = fgetln(fp, &len); fclose(fp); if (line) { /* strip newline */ *(line + strlen(line) - 1) = 0; remove_parameter(line, "BOOT_IMAGE"); if (kexec_flags & KEXEC_ON_CRASH) remove_parameter(line, "crashkernel"); } else line = strdup(""); return line; }
generic_device::~generic_device() { remove_parameter(); m_protocol->stop(); { write_lock_t lock{m_mutex}; m_children.clear(); } m_protocol.reset(); }