Changeset 3829 in MondoRescue


Ignore:
Timestamp:
Mar 4, 2024, 5:11:25 PM (4 months ago)
Author:
Bruno Cornec
Message:

manages kernel_path dynamically

Location:
branches/3.3/mondo/src/common
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-cli.c

    r3827 r3829  
    672672
    673673    if ((flag_set['k']) && (! bkpinfo->restore_data)) {
    674         strncpy(bkpinfo->kernel_path, flag_val['k'], MAX_STR_LEN);
     674        mr_asprintf(bkpinfo->kernel_path, "%s", flag_val['k']);
    675675        if (!does_file_exist(bkpinfo->kernel_path)) {
    676676            retval++;
  • branches/3.3/mondo/src/common/libmondo-files.c

    r3826 r3829  
    269269 * don't do anything.
    270270 * @param kernel Where to put the found kernel.
    271  * @return 0 for success, 1 for failure.
     271 * @return 0 for success aborts otherwise
    272272 */
    273273int figure_out_kernel_path_interactively_if_necessary(char *kernel)
     
    276276    char *command = NULL;
    277277
    278     if (!kernel[0]) {
    279         tmp = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null");
    280         strcpy(kernel, tmp);
    281         mr_free(tmp);
     278    if (kernel == NULL) {
     279        kernel = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null");
    282280    }
    283281    // If we didn't get anything back, check whether mindi raised a fatal error
    284     if (!kernel[0]) {
     282    if (strcmp(kernel,"") == 0) {
    285283        mr_asprintf(command, "grep 'Fatal error' %s", MINDI_LOGFILE);
    286284        tmp = call_program_and_get_last_line_of_output(command);
     
    295293    } else {
    296294        // If we've found the kernel, allow sysadmin to modify it if he wants
    297         if (!g_text_mode) {
    298             if (!popup_and_get_string("Kernel path", "We found this full path name for your kernel. You should just use it in most cases", kernel, MAX_STR_LEN / 4)) {
    299                 fatal_error("Kernel not found. Please specify with the '-k' flag.");
     295        while ((kernel == NULL) || (strcmp(kernel,"") == 0)) {
     296            if (!g_text_mode) {
     297                tmp = mr_popup_and_get_string("Kernel path", "We found this full path name for your kernel. You should just use it in most cases", kernel);
     298                if (tmp == NULL) {
     299                    fatal_error("Kernel not found. Please specify with the '-k' flag.");
     300                } else {
     301                    mr_free(kernel);
     302                    kernel = tmp;
     303                }
    300304            }
    301305        }
     
    304308
    305309    log_it("Calling Mindi with kernel path of '%s'", kernel);
    306     while (!kernel[0]) {
    307         if (!ask_me_yes_or_no("Kernel not found or invalid. Choose another?")) {
    308             return (1);
    309         }
    310         if (!popup_and_get_string("Kernel path", "What is the full path and filename of your kernel, please?", kernel, MAX_STR_LEN / 4)) {
    311             fatal_error("Kernel not found. Please specify with the '-k' flag.");
    312         }
    313         log_it("User says kernel is at %s", kernel);
    314     }
    315     return (0);
     310    return(0);
    316311}
    317312
  • branches/3.3/mondo/src/common/libmondo-fork.c

    r3728 r3829  
    3434 * Call a program and retrieve its last line of output.
    3535 * @param call The program to run.
    36  * @return The last line of its output.
     36 * @return The last line of its output or the empty string.
    3737 * @note The returned value points to storage that needs to be freed by the
    3838 * caller
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3828 r3829  
    855855    bkpinfo->call_burn_iso = NULL;
    856856    bkpinfo->call_after_iso = NULL;
    857     bkpinfo->kernel_path[0] = '\0';
     857    bkpinfo->kernel_path = NULL;
    858858    bkpinfo->netfs_mount = NULL;
    859859    bkpinfo->netfs_proto = NULL;
  • branches/3.3/mondo/src/common/mondostructures.h

    r3828 r3829  
    560560   * Path to the user's kernel
    561561   */
    562     char kernel_path[MAX_STR_LEN];
     562    char *kernel_path;
    563563
    564564  /**
  • branches/3.3/mondo/src/common/newt-specific.c

    r3828 r3829  
    436436        mr_free(bkpinfo->call_before_iso);
    437437        mr_free(bkpinfo->restore_path);
     438        mr_free(bkpinfo->kernel_path);
    438439        /* Then free the structure */
    439440        paranoid_free(bkpinfo);
Note: See TracChangeset for help on using the changeset viewer.