~ubuntu-branches/ubuntu/saucy/s390-tools/saucy

« back to all changes in this revision

Viewing changes to zipl/src/bootmap.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2008-07-15 23:55:41 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080715235541-r79vu6eqh4qim413
Tags: 1.6.2-1
* New upstream version.
* Install udev rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * s390-tools/zipl/src/bootmap.c
3
3
 *   Functions to build the bootmap file.
4
4
 *
5
 
 * Copyright (C) 2001-2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
 
5
 * Copyright IBM Corp. 2001, 2006.
6
6
 *
7
7
 * Author(s): Carsten Otte <cotte@de.ibm.com>
8
8
 *            Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>
23
23
#include "disk.h"
24
24
#include "error.h"
25
25
#include "misc.h"
 
26
#include "zt_common.h"
26
27
 
27
28
 
28
29
/* Header text of the bootmap file */
639
640
}
640
641
 
641
642
 
 
643
#define DUMP_PARAM_MAX_LEN      896
 
644
 
 
645
static char *
 
646
create_dump_fs_parmline(const char* parmline, const char* root_dev,
 
647
                        int part_num, uint64_t mem, int max_cpus)
 
648
{
 
649
        char* result;
 
650
 
 
651
        result = misc_malloc(DUMP_PARAM_MAX_LEN);
 
652
        if (!result)
 
653
                return NULL;
 
654
        snprintf(result, DUMP_PARAM_MAX_LEN, "%s%sroot=%s dump_part=%d "
 
655
                 "dump_mem=%lld maxcpus=%d", parmline ? parmline : "",
 
656
                 parmline ? " " : "", root_dev, part_num,
 
657
                 (unsigned long long) mem, max_cpus);
 
658
        result[DUMP_PARAM_MAX_LEN - 1] = 0;
 
659
        return result;
 
660
}
 
661
 
 
662
 
642
663
static int
643
664
get_dump_fs_parmline(char* partition, char* parameters, uint64_t mem,
644
665
                     char** result, struct disk_info* target_info)
645
666
{
646
 
        char part_param[20];
647
 
        char mem_param[35];
648
667
        char* buffer;
649
668
        struct disk_info* info;
650
669
        int rc;
656
675
                           partition);
657
676
                return rc;
658
677
        }
659
 
        /* Create scsi dump parameter */
660
 
        snprintf(part_param, sizeof(part_param), "dump_part=%d",
661
 
                 info->partnum);
662
 
        snprintf(mem_param, sizeof(mem_param), "dump_mem=%lld",
663
 
                 (unsigned long long) mem);
664
678
        if ((info->type != disk_type_scsi) || (info->partnum == 0)) {
665
679
                error_reason("Device '%s' is not a SCSI partition",
666
680
                             partition);
674
688
                return -1;
675
689
        }
676
690
        disk_free_info(info);
677
 
        if (parameters != NULL) {
678
 
                buffer = misc_malloc(strlen(parameters) + strlen(part_param) +
679
 
                                     strlen(mem_param) + 3);
680
 
                if (buffer != NULL)
681
 
                        sprintf(buffer, "%s %s %s", parameters, part_param,
682
 
                                mem_param);
683
 
        } else
684
 
                buffer = misc_strdup(part_param);
 
691
        buffer = create_dump_fs_parmline(parameters, "/dev/ram0", info->partnum,
 
692
                                         mem, 1);
685
693
        if (buffer == NULL)
686
694
                return -1;
687
695
        *result = buffer;
698
706
        struct job_ipl_data ipl;
699
707
        int rc;
700
708
 
701
 
        /* Ensure that necessary files are accessible */
 
709
        /* Convert fs dump job to IPL job */
702
710
        rc = misc_check_readable_file(FSDUMP_IMAGE);
703
711
        if (rc) {
704
712
                error_text("Need external file '%s' for file system dump",
705
713
                           FSDUMP_IMAGE);
706
714
                return rc;
707
715
        }
708
 
        rc = misc_check_readable_file(FSDUMP_RAMDISK);
709
 
        if (rc) {
710
 
                error_text("Need external file '%s' for file system dump",
711
 
                           FSDUMP_RAMDISK);
712
 
                return rc;
713
 
        }
714
 
        /* Convert fs dump job to IPL job */
715
716
        ipl.image = FSDUMP_IMAGE;
716
717
        ipl.image_addr = DEFAULT_IMAGE_ADDRESS;
717
 
        ipl.ramdisk = FSDUMP_RAMDISK;
718
 
        ipl.ramdisk_addr = DEFAULT_RAMDISK_ADDRESS;
 
718
 
 
719
        /* Ramdisk is no longer required with new initramfs dump system. */
 
720
        if (misc_check_readable_file(FSDUMP_RAMDISK))
 
721
                ipl.ramdisk = NULL;
 
722
        else {
 
723
                ipl.ramdisk = FSDUMP_RAMDISK;
 
724
                ipl.ramdisk_addr = DEFAULT_RAMDISK_ADDRESS;
 
725
        }
 
726
 
719
727
        /* Get file system dump parmline */
720
728
        rc = get_dump_fs_parmline(dump_fs->partition, dump_fs->parmline,
721
729
                                  dump_fs->mem, &ipl.parmline, info);
786
794
                for (i=0; i < job->data.menu.num; i++) {
787
795
                        switch (job->data.menu.entry[i].id) {
788
796
                        case job_ipl:
789
 
                                if (job->data.menu.entry[i].data.ipl.ignore) {
790
 
                                        printf("Ignore #%d: IPL section '%s'\n",
791
 
                                               job->data.menu.entry[i].pos,
792
 
                                               job->data.menu.entry[i].name);
793
 
                                        break;
794
 
                                }
795
797
                                printf("Adding #%d: IPL section '%s'%s\n",
796
798
                                       job->data.menu.entry[i].pos,
797
799
                                       job->data.menu.entry[i].name,
908
910
                free(filename);
909
911
                return -1;
910
912
        }
911
 
        /* Check for supported disk types */
 
913
        /* Check for supported disk and driver types */
912
914
        switch (info->type) {
913
915
        case disk_type_scsi:
 
916
                if (info->drv_name && (strcmp(info->drv_name, "sd") != 0)) {
 
917
                        error_reason("Unsupported device driver '%s'",
 
918
                                     info->drv_name);
 
919
                        disk_free_info(info);
 
920
                        close(fd);
 
921
                        free(filename);
 
922
                        return -1;
 
923
                }
 
924
                break;
914
925
        case disk_type_fba:
915
926
        case disk_type_eckd_classic:
916
927
        case disk_type_eckd_compatible:
 
928
                if (info->drv_name && (strcmp(info->drv_name, "dasd") != 0)) {
 
929
                        error_reason("Unsupported device driver '%s'",
 
930
                                     info->drv_name);
 
931
                        disk_free_info(info);
 
932
                        close(fd);
 
933
                        free(filename);
 
934
                        return -1;
 
935
                }
 
936
                /* Check for valid CHS geometry data. */
 
937
                if ((info->geo.cylinders == 0) || (info->geo.heads == 0) ||
 
938
                    (info->geo.sectors == 0)) {
 
939
                        error_reason("Invalid disk geometry (CHS=%d/%d/%d)",
 
940
                                     info->geo.cylinders, info->geo.heads,
 
941
                                     info->geo.sectors);
 
942
                        disk_free_info(info);
 
943
                        close(fd);
 
944
                        free(filename);
 
945
                        return -1;
 
946
                }
917
947
                break;
918
948
        case disk_type_diag:
919
949
        case disk_type_unknown: