Changeset 2052


Ignore:
Timestamp:
Oct 23, 2008, 2:55:59 PM (12 years ago)
Author:
Bruno Cornec
Message:

Adds support for dm devices in truncate_to_drive_name

Location:
branches/2.2.8
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.8/mindi/mindi

    r2051 r2052  
    5757CDROM_MODS="$TAPE_MODS $IDE_MODS $USB_MODS $PCMCIA_MODS $SCSI_MODS $NET_MODS af_packet cdrom isocd isofs inflate_fs nls_iso8859-1 nls_base nls_cp437 nls_utf8 sg sr_mod zlib_inflate iso9660"
    5858# Those modules will only go on the backup media, not the boot media.
    59 EXTRA_MODS="$CDROM_MODS vfat fat loop md-mod linear raid0 raid1 xor raid5 raid456 lvm-mod dm-mod dm_mod dm-snapshot dm_snapshot dm-zero dm_zero dm-mirror dm_mirror dm_multipath dm-multipath dm-round-robin dm_round_robin jfs xfs xfs_support pagebuf reiserfs ext2 ext3 minix nfs nfs_acl nfsd lockd sunrpc jbd mbcache"
     59EXTRA_MODS="$CDROM_MODS vfat fat loop md-mod linear raid0 raid1 xor raid5 raid456 lvm-mod dm-mod dm_mod dm-snapshot dm_snapshot dm-zero dm_zero dm-mirror dm_mirror dm-multipath dm_multipath dm-round-robin dm_round_robin jfs xfs xfs_support pagebuf reiserfs ext2 ext3 minix nfs nfs_acl nfsd lockd sunrpc jbd mbcache"
    6060# Replace with that line for HP OCMP e.g.
    6161#DENY_MODS="MPS_Driver_Mapper mps octtldrv tscttl streams kqemu"
  • branches/2.2.8/mondo/src/common/libmondo-devices.c

    r2050 r2052  
    10171017            log_msg(1, "Failed to get harddisk geometry, using old mode");
    10181018        }
    1019 /* 
    1020   if ((fd = open (drive, O_RDONLY)) != -1) {
    1021       if (ioctl (fd, HDIO_GETGEO, &hdgeo) != -1)  {
    1022       close (fd);
    1023       log_msg (2, "Geometry of drive %s is C:%d, H:%d, S%d, its size is %d MB", drive, hdgeo.cylinders, hdgeo.heads, hdgeo.sectors, (hdgeo.cylinders * hdgeo.heads * hdgeo.sectors / 2 / 1024));
    1024       if ( hdgeo.cylinders && hdgeo.heads && hdgeo.sectors ) {
    1025           outvalB = ((long) (hdgeo.cylinders * hdgeo.heads * hdgeo.sectors / 2 / 1024));
    1026       }
    1027       }
    1028       close (fd);
    1029  */
    10301019#endif
    10311020    }
     
    10421031    return (outvalC);
    10431032}
    1044 
    1045 /* The old version */
    1046 #if 0
    1047 long get_phys_size_of_drive(char *drive)
    1048 {
    1049     /*@ pointers **************************************************** */
    1050 #if linux
    1051     FILE *fin;
    1052     char *p;
    1053     char *q;
    1054     char *r;
    1055     /*@ buffers ***************************************************** */
    1056     char *tmp;
    1057     char *command;
    1058 
    1059     /*@ long ******************************************************** */
    1060     long outL;
    1061     long tempLa;
    1062     long tempLb;
    1063     long tempLc;
    1064 
    1065 #endif
    1066 
    1067     struct hd_geometry hdgeo;
    1068     int fd;
    1069 
    1070 #ifdef __FreeBSD__
    1071     off_t o;
    1072 
    1073     if ((fd = open(drive, O_RDONLY)) != -1) {
    1074         if (ioctl(fd, DIOCGMEDIASIZE, &o) != -1) {
    1075             close(fd);
    1076             return (long) (o / (off_t) (1024 * 1024));
    1077         }
    1078         close(fd);
    1079     }
    1080     log_msg(4, "drive = %s, error = %s", drive, strerror(errno));
    1081     fatal_error("GPSOD: Unable to get size of drive");
    1082 #else
    1083 
    1084     malloc_string(tmp);
    1085     malloc_string(command);
    1086 
    1087     if ((fd = open(drive, O_RDONLY)) != -1) {
    1088         if (ioctl(fd, HDIO_GETGEO, &hdgeo) != -1) {
    1089             close(fd);
    1090             log_msg(2,
    1091                     "Geometry of drive %s is C:%d, H:%d, S%d, its size is %d MB",
    1092                     drive, hdgeo.cylinders, hdgeo.heads, hdgeo.sectors,
    1093                     (hdgeo.cylinders * hdgeo.heads * hdgeo.sectors / 2 /
    1094                      1024));
    1095             if (hdgeo.cylinders && hdgeo.heads && hdgeo.sectors) {
    1096                 return ((long)
    1097                         (hdgeo.cylinders * hdgeo.heads * hdgeo.sectors /
    1098                          2 / 1024));
    1099             }
    1100         }
    1101         close(fd);
    1102     }
    1103 
    1104     assert_string_is_neither_NULL_nor_zerolength(drive);
    1105 
    1106     sprintf(command,
    1107             "parted2fdisk -l %s | head -n4 | tr -s '\n' '\t' | tr -s ' ' '\t' | cut -f8,14,16",
    1108             drive);
    1109     strcpy(tmp, call_program_and_get_last_line_of_output(command));
    1110     if (tmp[0]) {
    1111         p = tmp;
    1112         q = strchr(p, ' ');
    1113         if (q) {
    1114             *(q++) = '\0';
    1115             r = strchr(q, ' ');
    1116             if (r) {
    1117                 *(r++) = '\0';
    1118                 tempLa = atol(p);
    1119                 tempLb = atol(q);
    1120                 tempLc = atol(r);
    1121                 outL = tempLa * tempLb / 1024 * tempLc / 1024;
    1122                 if (outL > 100) {
    1123                     paranoid_free(tmp);
    1124                     paranoid_free(command);
    1125                     return (outL);
    1126                 }
    1127             }
    1128         }
    1129     }
    1130 
    1131     /* try to grep for 'Drive xxxx: yyy MB' */
    1132     sprintf(command,
    1133             "parted2fdisk -l %s | grep MB | tr -s ' ' '\t' | cut -f3",
    1134             drive);
    1135     strcpy(tmp, call_program_and_get_last_line_of_output(command));
    1136     if (atol(tmp) > 0) {
    1137         paranoid_free(tmp);
    1138         paranoid_free(command);
    1139         return (atol(tmp));
    1140     }
    1141 
    1142     /* else, do it the old-fashioned way */
    1143     p = strrchr(drive, (int) '/');
    1144     if (p) {
    1145         strcpy(tmp, p + 1);
    1146     } else {
    1147         paranoid_free(tmp);
    1148         paranoid_free(command);
    1149         return (-1);
    1150     }
    1151     sprintf(command, "dmesg | grep %s 2> /dev/null", tmp);
    1152     if (!(fin = popen(command, "r"))) {
    1153         log_OS_error("Cannot popen dmesg command");
    1154     } else {
    1155         fgets(tmp, MAX_STR_LEN - 1, fin);
    1156         while (!feof(fin) && !strstr(tmp, "GB") && !strstr(tmp, "MB")) {
    1157             fgets(tmp, MAX_STR_LEN - 1, fin);
    1158         }
    1159         if (pclose(fin)) {
    1160             log_OS_error("Cannot pclose dmesg fin");
    1161         }
    1162     }
    1163     if (!(p = strstr(tmp, "GB")) && !(p = strstr(tmp, "MB"))) {
    1164         log_msg(3, "Cannot find %s's size: dmesg isn't helping either.",
    1165                 drive);
    1166         paranoid_free(tmp);
    1167         paranoid_free(command);
    1168         return (-1);
    1169     }
    1170     for (; !isdigit(*(p - 1)); p--);
    1171     *p = '\0';
    1172     for (p--; isdigit(*(p - 1)); p--);
    1173     outL = atol(p);
    1174     if (outL <= 0) {
    1175         paranoid_free(tmp);
    1176         paranoid_free(command);
    1177         return (-1);
    1178     }
    1179     if (strstr(tmp, "GB")) {
    1180         outL = outL * 1024;
    1181     }
    1182     paranoid_free(tmp);
    1183     paranoid_free(command);
    1184     return (outL * 19 / 20);
    1185 #endif
    1186 }
    1187 #endif                          /* 0 */
    1188 
    1189 
    1190 
    1191 
    11921033
    11931034/**
  • branches/2.2.8/mondo/src/common/libmondo-mountlist.c

    r1909 r2052  
    1 /* libmondo-mountlist.c                            subroutines for handling mountlist
     1/* subroutines for handling mountlist
    22   $Id$
    3 
    4 
    5 
    6 08/01
    7 - when evaluating mountlist, skip drive entirely if it does not exist
    8 
    9 07/14
    10 - always exclude /devpts, /proc, /sys from mountlist
    11    
    12 06/29/2004
    13 - changed some char[] to *char
    14 - drivelist is struct now, not char[][]
    15 
    16 10/19/2003
    17 - format_device() --- contract /dev/md/N to /dev/mdN to
    18   overcome devfs problems
    19 
    20 06/11
    21 - added support for 5th column in mountlist.txt, for labels
    22 
    23 05/08
    24 - added save_mountlist_to_disk() and load_mountlist()
    25   and misc other funcs from mondorestore.c
    26 
    27 05/05
    28 - added Joshua Oreman's FreeBSD patches
    29 
    30 04/24
    31 - added some assert()'s
    32 
    33 04/23
    34 - cleaned up evaluate_drive_within_mountlist() a bit
    35 
    36 01/15/2003
    37 - added code for LVM (Brian Borgeson)
    38 
    39 10/19/2002
    40 - added some comments
    41 
    42 07/24/2002
    43 - created
    443*/
    454
     
    786745        }
    787746
    788 /*
    789       for (i = strlen (drive); isdigit (drive[i - 1]); i--);
    790       drive[i] = '\0';
    791       if (get_phys_size_of_drive (drive) <= 0 && drive[i - 1] == 'p')
    792     {
    793       i--;
    794       drive[i] = '\0';
    795     }
    796       for (j = 0; j < noof_drives && strcmp (drivelist[j], drive) != 0; j++);
    797 */
    798 
    799747        sprintf(tmp,
    800748                "Putting %s with size %lli in list of drives",
  • branches/2.2.8/mondo/src/common/libmondo-string.c

    r1687 r2052  
    862862        return partition;
    863863    }
     864    /* then see if it's a dm style device */
     865    if (c && strncmp(c, "/dm-", 5) == 0) {
     866        /* yup it's dm, return the full path */
     867        return partition;
     868    }
    864869
    865870    for (i = strlen(partition); isdigit(partition[i - 1]); i--)
  • branches/2.2.8/mondo/src/mondorestore/mondo-prep.c

    r2037 r2052  
    11/***************************************************************************
    2 mondo-prep.c  -  description
    3 -----------------
    4 
    5 begin: Fri Apr 19 16:40:35 EDT 2002
    6 copyright : (C) 2002 Mondo  Hugo Rabson
    7 email     : Hugo Rabson <hugorabson@msn.com>
    8 edited by : by Stan Benoit 4/2002
    9 email     : troff@nakedsoul.org
    10 cvsid     : $Id$
     2$Id$
    113***************************************************************************/
    124
     
    1911 *                                                                         *
    2012 ***************************************************************************/
    21 
    22 /* mondo-prep.c             Hugo Rabson
    23 
    24 
    25 
    26 07/20
    27 - when starting RAID, don't do it twice :)
    28 - moved Joshua's new get_phys_size_of_drive() code
    29   from resize_drive... into get_phys_size_of_drive()
    30 
    31 06/29
    32 - make sure software RAID devices are formatted IF user says they're to be
    33 - drivelist is struct now, not char[][]
    34 
    35 06/26
    36 - drop make_relevant_partition_bootable(); do it yourself in C (mostly)
    37 - offer to reboot if partition table is locked up by the kernel
    38 
    39 06/22
    40 - be sure not to resize non-NTFS images when restoring
    41 - set non-NTFS images' partition types properly
    42 
    43 06/19
    44 - shut down all LVMs and VGs before prepping
    45 
    46 05/07
    47 - usage of parted2fdisk instead of fdisk alone (ia32/ia64 compatibility)
    48   BCO
    49 
    50 03/31
    51 - rewrote partitioning and formatting code to call fdisk once per disk
    52 
    53 10/21/2003
    54 - suspend/resume Newt gui before/after calling do_my_funky_lvm_stuff()
    55 
    56 10/20
    57 - rewrote format_everything() - what a mess it was.
    58   It now does things in three phases:-
    59   - formats software RAID devices (/dev/md0, etc.)
    60   - formats and configures LVM devices
    61   - formats regular partitions (/dev/hda1, /dev/sdb2, etc.)
    62     and any LVMs recently prepped
    63 
    64 10/07
    65 - use strstr(format, "raid") instead of strcmp(format,"raid") to determin
    66   if partition is a RAID component
    67 
    68 09/23
    69 - better comments
    70 
    71 09/18
    72 - better logging of RAID activity
    73 
    74 05/05
    75 - added Joshua Oreman's FreeBSD patches
    76 
    77 04/30
    78 - added textonly mode
    79 
    80 04/24
    81 - added lots of assert()'s and log_OS_error()'s
    82 
    83 04/21
    84 - format_everything() --- don't let bar go too far
    85 - mkfs -c to check for bad blocks when formatting
    86 
    87 04/04
    88 - misc clean-up (Tom Mortell)
    89 
    90 01/15/2003
    91 - added code for LVM and SW Raid (Brian Borgeson)
    92 
    93 12/10/2002
    94 - line 1238: friendlier output
    95 
    96 11/20
    97 - when wiping a given device in preparation for partitioning + formatting
    98   it, don't wipe the MBR; just the partition table. That allows for
    99   stupid-ass Compaq users who like to play with their MBR's.
    100 - disable mountlist.txt-->mountlist.txt.pre-resize copying (superfluous)
    101 
    102 09/09
    103 - run_program_and_log_output() now takes boolean operator to specify
    104   whether it will log its activities in the event of _success_
    105 
    106 07/01 - 07/31
    107 - added hooks to libmondo
    108 - RAID enhancements (Philippe de Muyter)
    109 
    110 01/01 - 03/31
    111 - partition_device() will refuse to partition /dev/mdX now (cos it's a
    112   virtual drive); however, it will return 0 (i.e. not an error)
    113 - make_list_of_drives() will exclude /dev/md* from list
    114 - mkreiserfs -ff instead of -q (Andy Glass)
    115 - don't resize drive if drive not found (or if its size cannot be det'd)
    116 - when generating list of drives from mountlist, skip the 'p' at the end
    117   of drive name if /dev/ida/ or /dev/cciss/; just do it (Michael Eisenberg)
    118 - don't specify journal size when formatting ext3
    119   (used to have -Jsize=10 in the call to mkfs)
    120 - handles files >2GB in size
    121 - format interactively, if Interactive Mode
    122 - removed reference to g_tape_size
    123 - when executing /tmp/i-want-my-lvm, only record the error# if the command
    124   was _not_ an 'insmod' command
    125 - pass partition size to fdisk in Kilobytes now, not Megabytes
    126 - log fdisk's output to /tmp/mondo-restore.log if it fails
    127 - don't try to format partitions of type 'image'
    128 - don't type to set types of 'image' partitions
    129 - if format code is 1 or 2 chars then assume it is a hex string
    130 - took out all '/ /' comments
    131 - don't extrapolate/add partition from RAID dev to mountlist if it's already
    132   present in mountlist
    133 - less repetitive logging in the event of vacuum-packing of last part'n
    134 - no extrapolation at all: RAID partitions should be listed in mountlist
    135   already, thanks to either Mindi v0.5x or the mountlist editor itself
    136 - no longer say, 'and logging to...' when setting a partition's type
    137 - don't run mkfs on RAID partitions (/dev/hd*, /dev/sd*); just set type
    138 - the setting of a partition's type now takes place in a separate subroutine
    139   from the subroutine that actually creates the partition
    140 - no need to set type if 83: 83 is the default (under fdisk)
    141 - turned on '-Wall'; cleaned up some cruft
    142 - if vacuum-packing partition (i.e. size=0MB --> max) then say, "(maximum)"
    143   not, "(0 MB)"
    144 
    145 11/22/2001
    146 - preliminary code review
    147 - created on Nov 22nd, 2001
    148 */
    14913
    15014/**
Note: See TracChangeset for help on using the changeset viewer.