Author: juhliarik
Date: Wed Apr 22 13:48:59 2009
New Revision: 56908
URL: http://svn.opensuse.org/viewcvs/yast?rev=56908&view=rev
Log:
added new module for handling storage devices and adapting to new
perl-Bootloader
Added:
trunk/bootloader/src/modules/BootStorage.ycp
Modified:
trunk/bootloader/src/modules/BootArch.ycp
trunk/bootloader/src/modules/BootCommon.ycp
trunk/bootloader/src/modules/BootGRUB.ycp
trunk/bootloader/src/modules/BootPOWERLILO.ycp
trunk/bootloader/src/modules/Bootloader_API.pm
trunk/bootloader/src/modules/Makefile.am
trunk/bootloader/src/routines/lib_iface.ycp
trunk/bootloader/src/routines/lilolike.ycp
trunk/bootloader/src/routines/misc.ycp
Modified: trunk/bootloader/src/modules/BootArch.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootArch.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/modules/BootArch.ycp (original)
+++ trunk/bootloader/src/modules/BootArch.ycp Wed Apr 22 13:48:59 2009
@@ -152,7 +152,48 @@
return (Arch::i386 () || Arch::x86_64 () || Arch::ia64 ());
}
-} // EOF
+
+/**
+ * Return architecture as string
+ * @return string type of architecture e.g. "i386"
+ */
+global string StrArch ()
+{
+ string ret = Arch::architecture();
+ if ((ret == "ppc") || (ret == "ppc64"))
+ {
+ if (Arch::board_iseries ())
+ {
+ ret = "iseries";
+ }
+ else if (Arch::board_prep ())
+ {
+ ret = "prep";
+ }
+ else if (Arch::board_chrp ())
+ {
+ ret = "chrp";
+ }
+ else if (Arch::board_mac_new ())
+ {
+ ret = "pmac";
+ }
+ else if (Arch::board_mac_old ())
+ {
+ ret = "pmac";
+ }
+ else
+ {
+ ret = "unknown";
+ }
+
+ }
+
+ y2milestone("Type of architecture: %1", ret);
+ return ret;
+}
+
+}
/*
* Local variables:
Modified: trunk/bootloader/src/modules/BootCommon.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootCommon.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/modules/BootCommon.ycp (original)
+++ trunk/bootloader/src/modules/BootCommon.ycp Wed Apr 22 13:48:59 2009
@@ -35,6 +35,7 @@
import "Popup";
import "Package";
import "PackagesProposal";
+import "BootStorage";
import "Linuxrc";
@@ -74,11 +75,7 @@
global integer cached_settings_base_data_change_time = nil;
-/**
- * Saved change time from target map - only for MapAllPartitions()
- */
-global integer disk_change_time_MapAllPartitions = nil;
/**
@@ -364,20 +361,6 @@
"zipl", "ppc"];
-/**
- * bnc #468922 - problem with longtime running the parsing a huge number of disks
- * map the map of all partitions with info about it ->
- * necessary for Dev2MountByDev() in routines/misc.ycp
- */
-global map all_partitions = $[];
-
-/**
- * bnc #468922 - problem with longtime running the parsing a huge number of disks
- * map target map try to minimalize calling Storage::GetTargetMap()
- *
- */
-map target_map = $[];
-
global define string getLoaderType (boolean recheck);
global define list<string> getBootloaders ();
global define list<string> Summary ();
@@ -506,7 +489,7 @@
: "";
// try to use label or udev id for device name... FATE #302219
if ((resume != "") && (resume != nil))
- resume = Dev2MountByDev(resume);
+ resume = BootStorage::Dev2MountByDev(resume);
// FIXME:
@@ -620,7 +603,7 @@
"image" : kernel_fn,
"initrd" : initrd_fn,
// try to use label or udev id for device name... FATE #302219
- "root" : Dev2MountByDev(RootPartitionDevice),
+ "root" : BootStorage::Dev2MountByDev(RootPartitionDevice),
"append" : (title == "failsafe")
? BootArch::FailsafeKernelParams ()
: BootArch::DefaultKernelParams (resume),
@@ -658,7 +641,7 @@
* @return bootloader settings
*/
global define map Export () {
- MapDevices();
+
map exp = $[
"global": remapGlobals(globals),
"sections" : remapSections(sections),
@@ -731,7 +714,7 @@
k = Storage::SLES9PersistentDevNames(k);
y2milestone( "devmap: dev name after SLES9 persistent dev name translation: %1", k);
}
- return $[Dev2MountByDev(k) : v];
+ return $[BootStorage::Dev2MountByDev(k) : v];
});
// convert custom boot device names in globals to the kernel device names
@@ -744,7 +727,7 @@
v = Storage::SLES9PersistentDevNames(v);
y2milestone( "globals: dev name after SLES9 persistent dev name translation: %1", v);
}
- return $[k : Dev2MountByDev(v)];
+ return $[k : BootStorage::Dev2MountByDev(v)];
} else {
return $[k : v];
}
@@ -760,7 +743,7 @@
rdev = Storage::SLES9PersistentDevNames(rdev);
y2milestone( "sections: dev name after SLES9 persistent dev name translation: %1", rdev);
}
- s["root"] = Dev2MountByDev(rdev);
+ s["root"] = BootStorage::Dev2MountByDev(rdev);
return s;
});
return true;
@@ -828,7 +811,7 @@
// convert the stage1_dev
map my_globals = mapmap (string k , string v, globals, {
if ((k == "stage1_dev") || (regexpmatch(k, "^boot_.*custom$" )))
- return $[k : BootCommon::Dev2MountByDev(v)];
+ return $[k : BootStorage::Dev2MountByDev(v)];
else
return $[k : v];
});
@@ -839,8 +822,7 @@
y2milestone ("device map before mapping %1", device_mapping);
map my_device_mapping =
mapmap (string k , string v, device_mapping, {
- //return $[BootCommon::Dev2MountByDev(k) : v];
- return $[BootCommon::Dev2MountByDev(k) : v];
+ return $[BootStorage::Dev2MountByDev(k) : v];
});
y2milestone ("device map after mapping %1", my_device_mapping);
if ((globals["trusted_grub"]:"" == "true") && (haskey(globals, "gfxmenu")))
Modified: trunk/bootloader/src/modules/BootGRUB.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootGRUB.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/modules/BootGRUB.ycp (original)
+++ trunk/bootloader/src/modules/BootGRUB.ycp Wed Apr 22 13:48:59 2009
@@ -26,6 +26,7 @@
import "Arch";
import "BootCommon";
+import "BootStorage";
import "Kernel";
import "Mode";
import "Stage";
@@ -318,7 +319,7 @@
{
// set up the new section entry
map new_sect = $[
- "root" : BootCommon::Dev2MountByDev(dev),
+ "root" : BootStorage::Dev2MountByDev(dev),
"__changed" : true,
"__auto" : true,
"__devs" : [dev]
@@ -328,7 +329,7 @@
{
// mountable bootable => chainloader (label: to be decided)
new_sect["noverifyroot"] = "true";
- new_sect["chainloader"] = BootCommon::Dev2MountByDev(dev);
+ new_sect["chainloader"] = BootStorage::Dev2MountByDev(dev);
new_sect["blockoffset"] = "1";
new_sect["type"] = "other";
}
@@ -402,7 +403,7 @@
"name" : BootCommon::translateSectionTitle (label),
"type" : "other",
"original_name" : label,
- "chainloader" : BootCommon::Dev2MountByDev(dev),
+ "chainloader" : BootStorage::Dev2MountByDev(dev),
"__changed" : true,
"__auto" : true,
"__devs" : [dev],
@@ -420,7 +421,7 @@
"name" : BootCommon::translateSectionTitle("hard disk"),
"original_name" : "hard_disk",
"type" : "other",
- "chainloader" : BootCommon::Dev2MountByDev(BootCommon::mbrDisk),
+ "chainloader" : BootStorage::Dev2MountByDev(BootCommon::mbrDisk),
"__changed" : true,
"__auto" : true,
"__devs" : [],
@@ -829,7 +830,7 @@
boolean ret = false;
string boot_disk = BootCommon::getBootDisk();
if (boot_disk != "")
- ret = checkBootDeviceInDeviceMap(boot_disk, BootCommon::Dev2MountByDev(boot_disk));
+ ret = checkBootDeviceInDeviceMap(boot_disk, BootStorage::Dev2MountByDev(boot_disk));
return ret;
Modified: trunk/bootloader/src/modules/BootPOWERLILO.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootPOWERLILO.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/modules/BootPOWERLILO.ycp (original)
+++ trunk/bootloader/src/modules/BootPOWERLILO.ycp Wed Apr 22 13:48:59 2009
@@ -27,6 +27,7 @@
import "Arch";
import "BootArch";
import "BootCommon";
+import "BootStorage";
import "Installation";
import "Kernel";
import "Mode";
@@ -908,7 +909,7 @@
// convert
map my_globals = mapmap (string k , string v, BootCommon::globals, {
if ((k == "stage1_dev") || (regexpmatch(k, "^boot_.*custom$" )))
- return $[k : BootCommon::Dev2MountByDev(v)];
+ return $[k : BootStorage::Dev2MountByDev(v)];
else
return $[k : v];
});
Added: trunk/bootloader/src/modules/BootStorage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootStorage.ycp?rev=56908&view=auto
==============================================================================
--- trunk/bootloader/src/modules/BootStorage.ycp (added)
+++ trunk/bootloader/src/modules/BootStorage.ycp Wed Apr 22 13:48:59 2009
@@ -0,0 +1,399 @@
+/**
+ * File:
+ * modules/BootStorage.ycp
+ *
+ * Module:
+ * Bootloader installation and configuration
+ *
+ * Summary:
+ * Module includes specific functions for handling storage data.
+ * The idea is handling all storage data necessary for bootloader
+ * in one module.
+ *
+ * Authors:
+ * Jozef Uhliarik
+ *
+ *
+ *
+ *
+ */
+
+{
+
+module "BootStorage";
+
+textdomain "bootloader";
+
+import "Storage";
+import "Arch";
+
+
+/**
+ * Saved change time from target map - only for MapAllPartitions()
+ */
+
+global integer disk_change_time_InitBootloader = nil;
+
+
+/**
+ * Saved change time from target map - only for MapAllPartitions()
+ */
+
+global integer disk_change_time_MapAllPartitions = nil;
+
+
+/**
+ * bnc #468922 - problem with longtime running the parsing a huge number of disks
+ * map the map of all partitions with info about it ->
+ * necessary for Dev2MountByDev() in routines/misc.ycp
+ */
+global map all_partitions = $[];
+
+/**
+ * bnc #468922 - problem with longtime running the parsing a huge number of disks
+ * map target map try to minimalize calling Storage::GetTargetMap()
+ *
+ */
+map target_map = $[];
+
+
+global map uuid_partitions = $[];
+global map id_partitions = $[];
+global map label_partitions = $[];
+global map path_partitions = $[];
+
+global map uuid_disks = $[];
+global map id_disks = $[];
+global map path_disks = $[];
+global map all_devices = $[];
+
+
+/** FATE #302219 - Use and choose persistent device names for disk devices
+ * Function prepare maps with mapping disks and partitions by uuid, id, path
+ * and label.
+ *
+ */
+void MapDevices()
+{
+ string dev_by_something = "";
+ map devices = (map)Storage::GetTargetMap();
+ foreach (string k, map v, devices,
+ {
+ // map disk by uuid
+ if ((v["uuid"]:nil != "") && (v["uuid"]:nil != nil))
+ {
+ dev_by_something = "/dev/disk/by-uuid/"+v["uuid"]:"";
+ uuid_disks[dev_by_something]= k;
+ all_devices[dev_by_something]= k;
+ }
+ // map disk by path
+ if ((v["path"]:nil != "") && (v["path"]:nil != nil))
+ {
+ dev_by_something = "/dev/disk/by-path/"+v["path"]:"";
+ path_disks[dev_by_something]= k;
+ all_devices[dev_by_something]= k;
+ }
+ // map disk by id
+ if ((v["udev_id"]:nil != nil) && (v["udev_id", 0]:nil != ""))
+ {
+ dev_by_something = "/dev/disk/by-id/"+v["udev_id", 0]:"";
+ id_disks[dev_by_something] = k;
+ all_devices[dev_by_something]= k;
+ }
+ // map partitions from disk...
+
+ foreach (map p, (list<map>)(v["partitions"]:[]),
+ {
+ // map partition by uuid
+ if ((p["uuid"]:nil != "") && (p["uuid"]:nil != nil))
+ {
+ dev_by_something = "/dev/disk/by-uuid/"+p["uuid"]:"";
+ uuid_partitions[dev_by_something]= p["device"]:"";
+ all_devices[dev_by_something]= p["device"]:"";
+ }
+
+ // map partition by path
+ if ((p["path"]:nil != "") && (p["path"]:nil != nil))
+ {
+ dev_by_something = "/dev/disk/by-path/"+p["path"]:"";
+ path_partitions[dev_by_something]= p["device"]:"";
+ all_devices[dev_by_something]= p["device"]:"";
+ }
+
+ // map partition by label
+ if ((p["label"]:nil != "") && (p["label"]:nil != nil))
+ {
+ dev_by_something = "/dev/disk/by-label/"+p["label"]:"";
+ label_partitions[dev_by_something]= p["device"]:"";
+ all_devices[dev_by_something]= p["device"]:"";
+ }
+
+ // map disk by id
+ if ((p["udev_id"]:nil != nil) && (p["udev_id", 0]:nil != ""))
+ {
+ dev_by_something = "/dev/disk/by-id/"+p["udev_id", 0]:"";
+ id_partitions[dev_by_something] = p["device"]:"";
+ all_devices[dev_by_something]= p["device"]:"";
+ }
+
+ }); // end of foreach (map p, (list<map>)(v["partitions"]:[]),
+ }); // end of foreach (string k, map v, devices,
+
+ y2milestone("disks mapping by-id: %1", id_disks);
+ y2milestone("disks mapping by-uuid: %1", uuid_disks);
+ y2milestone("disks mapping by-path: %1", path_disks);
+
+ y2milestone("partitions mapping by-id: %1", id_partitions);
+ y2milestone("partitions mapping by-uuid: %1", uuid_partitions);
+ y2milestone("partitions mapping by-path: %1", path_partitions);
+ y2milestone("partitions mapping by-label: %1", label_partitions);
+}
+
+
+
+/** FATE #302219 - Use and choose persistent device names for disk devices
+ * Converts a "/dev/disk/by-" device name to the corresponding kernel
+ * device name, if a mapping for this name can be found in the map from
+ * yast2-storage. If the given device name is not a "/dev/disk/by-" device
+ * name, it is left unchanged. Also, if the information about the device
+ * name cannot be found in the target map from yast2-storage, the device
+ * name is left unchanged.
+ *
+ * @param dev string device name
+ * @return string kernel device name
+ */
+
+global define string MountByDev2Dev(string dev)
+{
+ y2milestone ("MountByDev2Dev: %1", dev);
+
+ if (!regexpmatch(dev, "^/dev/disk/by-"))
+ return dev;
+ string ret = dev;
+
+ // check if it is device name by id
+ if (search(dev, "/dev/disk/by-id/") != nil)
+ {
+ if (haskey(id_partitions, dev))
+ ret = id_partitions[dev]:"";
+
+ if (haskey(id_disks, dev))
+ ret = id_disks[dev]:"";
+ y2milestone("Device %1 was converted to: %2", dev, ret);
+ return ret;
+ }
+
+ // check if it is device name by uuid
+ if (search(dev, "/dev/disk/by-uuid/") != nil)
+ {
+ if (haskey(uuid_partitions, dev))
+ ret = uuid_partitions[dev]:"";
+
+ if (haskey(uuid_disks, dev))
+ ret = uuid_disks[dev]:"";
+ y2milestone("Device %1 was converted to: %2", dev, ret);
+ return ret;
+ }
+
+ // check if it is device name by path
+ if (search(dev, "/dev/disk/by-path/") != nil)
+ {
+ if (haskey(path_partitions, dev))
+ ret = path_partitions[dev]:"";
+
+ if (haskey(path_disks, dev))
+ ret = path_disks[dev]:"";
+ y2milestone("Device %1 was converted to: %2", dev, ret);
+ return ret;
+ }
+
+ // check if it is device name by label
+ // only partition are supported
+ if (search(dev, "/dev/disk/by-label/") != nil)
+ {
+ if (haskey(label_partitions, dev))
+ ret = label_partitions[dev]:"";
+ y2milestone("Device %1 was converted to: %2", dev, ret);
+ return ret;
+ }
+
+ y2milestone("Device %1 was converted to: %2", dev, ret);
+ return ret;
+}
+
+
+
+
+
+/**
+ * Init and fullfil internal data for perl-Bootloader
+ *
+ * @return true if init reset/fullfil data or false and used cached data
+ */
+
+global boolean InitMapDevices ()
+{
+ boolean ret = false;
+ if (disk_change_time_InitBootloader != Storage::GetTargetChangeTime())
+ {
+ y2milestone("Init internal data from storage");
+ MapDevices();
+ disk_change_time_InitBootloader = Storage::GetTargetChangeTime();
+ ret = true;
+ }
+
+ return ret;
+}
+
+
+
+/**
+ * bnc #468922 - problem with longtime running the parsing a huge number of disks
+ * Function initialize all_partitions only if storage change
+ * partitioning of disk
+ * true if init all_partitions
+ */
+
+boolean MapAllPartitions()
+{
+ boolean ret = false;
+ if ((disk_change_time_MapAllPartitions != Storage::GetTargetChangeTime())
+ || (size(all_partitions) < 1) || (size(target_map) < 1))
+ {
+ // save last change time from storage for MapAllPartitions()
+ disk_change_time_MapAllPartitions = Storage::GetTargetChangeTime();
+
+ all_partitions = $[];
+ target_map = $[];
+ // get target map
+ target_map = (map)Storage::GetTargetMap();
+ // map all partitions
+ foreach (string k, map v, target_map,
+ {
+ foreach (map p, (list<map>)(v["partitions"]:[]),
+ {
+ all_partitions[p["device"]:""] = p;
+ });
+ });
+ ret = true;
+ }
+
+ return ret;
+}
+
+/** FATE #302219 - Use and choose persistent device names for disk devices
+ * Converts a device name to the corresponding device name it should be
+ * mounted by, according to the "mountby" setting for the device from
+ * yast2-storage. As a safeguard against problems, if the "mountby" device
+ * name does not exist in the information from yast2-storage, it will
+ * fallback to the "kernel name" ("/dev/sdXY").
+ *
+ * @param dev string device name
+ * @return string device name according to "mountby"
+ */
+global define string Dev2MountByDev(string dev)
+{
+ y2milestone ("Dev2MountByDev: %1", dev);
+
+ // (`id,`uuid,`path,`device,`label)
+ symbol by_mount = nil;
+ if (Arch::ppc())
+ by_mount = `id;
+ else
+ by_mount = Storage::GetDefaultMountBy();
+
+ //by_mount = `id;
+ y2milestone("Default mount by is %1", by_mount);
+
+ // add all_partitions to partitions
+ if (MapAllPartitions())
+ y2milestone("Init all_partitions was done");
+
+ map partitions = all_partitions;
+ map devices = target_map;
+
+ string ret = dev;
+ switch(by_mount)
+ {
+ // convert to udev_id
+ case (`id):
+ // partitions
+ if ((partitions[dev, "udev_id"]:nil != nil) && (partitions[dev, "udev_id", 0]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-id/%1", partitions[dev, "udev_id", 0]:"");
+ y2milestone ("Device name: %1 is converted to udev id: %2", dev, ret);
+ return ret;
+ }
+ // disks
+ if ((devices[dev, "udev_id"]:nil != nil) && (devices[dev, "udev_id", 0]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-id/%1", devices[dev, "udev_id", 0]:"");
+ y2milestone ("Device name: %1 is converted to udev id: %2", dev, ret);
+ return ret;
+ }
+ break;
+
+ // convert to uuid
+ case (`uuid):
+ // partitions
+ if ((partitions[dev, "uuid"]:nil != nil) && (partitions[dev, "uuid"]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-uuid/%1", partitions[dev, "uuid"]:"");
+ y2milestone ("Device name: %1 is converted to uuid: %2", dev, ret);
+ return ret;
+ }
+ // disks
+ if ((devices[dev, "uuid"]:nil != nil) && (devices[dev, "uuid"]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-uuid/%1", devices[dev, "uuid"]:"");
+ y2milestone ("Device name: %1 is converted to uuid: %2", dev, ret);
+ return ret;
+ }
+ break;
+
+ // convert to udev_path
+ case (`path):
+ // partitions
+ if ((partitions[dev, "udev_path"]:nil != nil) && (partitions[dev, "udev_path"]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-path/%1", partitions[dev, "udev_path"]:"");
+ y2milestone ("Device name: %1 is converted to udev path: %2", dev, ret);
+ return ret;
+ }
+ // disks
+ if ((devices[dev, "udev_path"]:nil != nil) && (devices[dev, "udev_path"]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-path/%1", devices[dev, "udev_path"]:"");
+ y2milestone ("Device name: %1 is converted to udev path: %2", dev, ret);
+ return ret;
+ }
+ break;
+
+ // convert to label
+ case (`label):
+ // partitions
+ if ((partitions[dev, "label"]:nil != nil) && (partitions[dev, "label"]:nil != ""))
+ {
+ ret = sformat ("/dev/disk/by-label/%1", partitions[dev, "label"]:"");
+ y2milestone ("Device name: %1 is converted to label: %2", dev, ret);
+ return ret;
+ }
+ // disks
+ y2milestone ("Disk doesn't support labels - name: %1 is converted to label: %2", dev, ret);
+ return ret;
+ break;
+
+ // convert to device or uknown type
+ default:
+ y2warning ("Convert %1 to `device or unknwn type, result: %2", dev, ret);
+ return ret;
+ break;
+ }
+
+ return ret;
+}
+
+
+
+
+}
Modified: trunk/bootloader/src/modules/Bootloader_API.pm
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/Bootloader_API.pm?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/modules/Bootloader_API.pm (original)
+++ trunk/bootloader/src/modules/Bootloader_API.pm Wed Apr 22 13:48:59 2009
@@ -50,11 +50,11 @@
}
-BEGIN { $TYPEINFO{setLoaderType} = ["function", "void", "string"]; }
+BEGIN { $TYPEINFO{setLoaderType} = ["function", "void", "string", "string"]; }
# do library initialization for a specific bootloader type
sub setLoaderType($) {
- my ($lt) = @_;
- my $ret = $lib_ref->SetLoaderType($lt);
+ my ($lt, $arch) = @_;
+ my $ret = $lib_ref->SetLoaderType($lt, $arch);
@lines_cache = ();
$lines_cache_index = 0;
@@ -62,6 +62,16 @@
return $ret;
}
+BEGIN { $TYPEINFO{defineUdevMapping} = ["function", "integer", ["map", "string", "string"]]; }
+# do library initialization for a specific bootloader type
+sub defineUdevMapping($) {
+ my ($udev_mapping) = @_;
+ my $ret = $lib_ref->DefineUdevMapping($udev_mapping);
+
+ DumpLog();
+ return $ret;
+}
+
BEGIN { $TYPEINFO{updateBootloader} = ["function", "boolean", "boolean"]; }
sub updateBootloader() {
my ($avoid_init) = @_;
Modified: trunk/bootloader/src/modules/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/Makefile.am?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/modules/Makefile.am (original)
+++ trunk/bootloader/src/modules/Makefile.am Wed Apr 22 13:48:59 2009
@@ -15,7 +15,8 @@
BootPOWERLILO.ycp \
BootZIPL.ycp \
Bootloader_API.pm \
- BootSupportCheck.ycp
+ BootSupportCheck.ycp \
+ BootStorage.ycp
Bootloader_API.pm:
test -f Bootloader_API.pm || exit 1
Modified: trunk/bootloader/src/routines/lib_iface.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/routines/lib_iface.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/routines/lib_iface.ycp (original)
+++ trunk/bootloader/src/routines/lib_iface.ycp Wed Apr 22 13:48:59 2009
@@ -61,7 +61,7 @@
{
// save last change time from storage
disk_change_time_checkCallingDiskInfo = Storage::GetTargetChangeTime();
- y2milestone("disk was changes by storage or partinfo is empty: %1", size(partinfo));
+ y2milestone("disk was changed by storage or partinfo is empty: %1", size(partinfo));
y2milestone("generate partinfo, md_info, mountpoints and multipath_mapping");
ret = true;
} else {
@@ -157,7 +157,7 @@
// adding moundby (by-id) via user preference
foreach(list partition, partinfo, {
list tmp =[];
- string mount_by = BootCommon::Dev2MountByDev(tostring(partition[0]:""));
+ string mount_by = BootStorage::Dev2MountByDev(tostring(partition[0]:""));
if (mount_by != tostring(partition[0]:""))
{
tmp = add(partition, mount_by);
@@ -191,8 +191,13 @@
if (!force && loader == library_initialized)
return false;
+ BootStorage::InitMapDevices ();
y2milestone ("Initializing lib for %1", loader);
- System::Bootloader_API::setLoaderType (loader);
+ string architecture = BootArch::StrArch();
+ System::Bootloader_API::setLoaderType (loader, architecture);
+ integer out = System::Bootloader_API::defineUdevMapping(BootStorage::all_devices);
+ if (out == nil)
+ y2error("perl-Bootloader library was not initialized");
y2milestone ("Putting partitioning into library");
// pass all needed disk/partition information to library
SetDiskInfo();
Modified: trunk/bootloader/src/routines/lilolike.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/routines/lilolike.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/routines/lilolike.ycp (original)
+++ trunk/bootloader/src/routines/lilolike.ycp Wed Apr 22 13:48:59 2009
@@ -640,7 +640,7 @@
// bnc# 335526 - Installing memtest with lilo screws up installation
if (search(s["original_name"]:"", "memtest") == nil)
{
- append = setKernelParamToLine (append, "resume", BootCommon::Dev2MountByDev(getLargestSwapPartition ()));
+ append = setKernelParamToLine (append, "resume", BootStorage::Dev2MountByDev(getLargestSwapPartition ()));
s["append"] = append;
}
}
@@ -763,7 +763,7 @@
if (! haskey (BootCommon::getSwapPartitions (), resume))
{
append = setKernelParamToLine (append,
- "resume", BootCommon::Dev2MountByDev(getLargestSwapPartition ()));
+ "resume", BootStorage::Dev2MountByDev(getLargestSwapPartition ()));
s["append"] = append;
linux_resume_added = true;
}
@@ -822,14 +822,14 @@
s = $[
"name": label,
"original_name": sect_type,
- "root": BootCommon::Dev2MountByDev(dev)
+ "root": BootStorage::Dev2MountByDev(dev)
];
if (dev != nil && IsPartitionBootable(dev))
{
// bootable => chainloader
s["noverifyroot"] = "true";
- s["chainloader"] = BootCommon::Dev2MountByDev(dev);
+ s["chainloader"] = BootStorage::Dev2MountByDev(dev);
s["blockoffset"] = "1";
s["type"] = "other";
y2milestone ("Updating section \"%1\" booting other installation to use chainloader entry", s["name"]:"");
@@ -959,7 +959,7 @@
y2milestone ("Updating resume device of section %1", label);
resume = BootCommon::UpdateDevice (resume);
option = BootCommon::setKernelParamToLine (
- option, "resume", BootCommon::Dev2MountByDev(resume));
+ option, "resume", BootStorage::Dev2MountByDev(resume));
}
}
s["append"] = option;
Modified: trunk/bootloader/src/routines/misc.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/routines/misc.ycp?rev=56908&r1=56907&r2=56908&view=diff
==============================================================================
--- trunk/bootloader/src/routines/misc.ycp (original)
+++ trunk/bootloader/src/routines/misc.ycp Wed Apr 22 13:48:59 2009
@@ -148,160 +148,8 @@
return floppy_devices;
}
-global map uuid_partitions = $[];
-global map id_partitions = $[];
-global map label_partitions = $[];
-global map path_partitions = $[];
-
-global map uuid_disks = $[];
-global map id_disks = $[];
-global map path_disks = $[];
-
-/** FATE #302219 - Use and choose persistent device names for disk devices
- * Function prepare maps with mapping disks and partitions by uuid, id, path
- * and label.
- *
- */
-
-global void MapDevices()
-{
- string dev_by_something = "";
- map devices = (map)Storage::GetTargetMap();
- foreach (string k, map v, devices,
- {
- // map disk by uuid
- if ((v["uuid"]:nil != "") && (v["uuid"]:nil != nil))
- {
- dev_by_something = "/dev/disk/by-uuid/"+v["uuid"]:"";
- uuid_disks[dev_by_something]= k;
- }
- // map disk by path
- if ((v["path"]:nil != "") && (v["path"]:nil != nil))
- {
- dev_by_something = "/dev/disk/by-path/"+v["path"]:"";
- path_disks[dev_by_something]= k;
- }
- // map disk by id
- if ((v["udev_id"]:nil != nil) && (v["udev_id", 0]:nil != ""))
- {
- dev_by_something = "/dev/disk/by-id/"+v["udev_id", 0]:"";
- id_disks[dev_by_something] = k;
- }
- // map partitions from disk...
-
- foreach (map p, (list<map>)(v["partitions"]:[]),
- {
- // map partition by uuid
- if ((p["uuid"]:nil != "") && (p["uuid"]:nil != nil))
- {
- dev_by_something = "/dev/disk/by-uuid/"+p["uuid"]:"";
- uuid_partitions[dev_by_something]= p["device"]:"";
- }
-
- // map partition by path
- if ((p["path"]:nil != "") && (p["path"]:nil != nil))
- {
- dev_by_something = "/dev/disk/by-path/"+p["path"]:"";
- path_partitions[dev_by_something]= p["device"]:"";
- }
-
- // map partition by label
- if ((p["label"]:nil != "") && (p["label"]:nil != nil))
- {
- dev_by_something = "/dev/disk/by-label/"+p["label"]:"";
- label_partitions[dev_by_something]= p["device"]:"";
- }
-
- // map disk by id
- if ((p["udev_id"]:nil != nil) && (p["udev_id", 0]:nil != ""))
- {
- dev_by_something = "/dev/disk/by-id/"+p["udev_id", 0]:"";
- id_partitions[dev_by_something] = p["device"]:"";
- }
-
- }); // end of foreach (map p, (list<map>)(v["partitions"]:[]),
- }); // end of foreach (string k, map v, devices,
- y2milestone("disks mapping by-id: %1", id_disks);
- y2milestone("disks mapping by-uuid: %1", uuid_disks);
- y2milestone("disks mapping by-path: %1", path_disks);
-
- y2milestone("partitions mapping by-id: %1", id_partitions);
- y2milestone("partitions mapping by-uuid: %1", uuid_partitions);
- y2milestone("partitions mapping by-path: %1", path_partitions);
- y2milestone("partitions mapping by-label: %1", label_partitions);
-}
-
-
-/** FATE #302219 - Use and choose persistent device names for disk devices
- * Converts a "/dev/disk/by-" device name to the corresponding kernel
- * device name, if a mapping for this name can be found in the map from
- * yast2-storage. If the given device name is not a "/dev/disk/by-" device
- * name, it is left unchanged. Also, if the information about the device
- * name cannot be found in the target map from yast2-storage, the device
- * name is left unchanged.
- *
- * @param dev string device name
- * @return string kernel device name
- */
-
-global define string MountByDev2Dev(string dev)
-{
- y2milestone ("MountByDev2Dev: %1", dev);
-
- if (!regexpmatch(dev, "^/dev/disk/by-"))
- return dev;
- string ret = dev;
-
- // check if it is device name by id
- if (search(dev, "/dev/disk/by-id/") != nil)
- {
- if (haskey(id_partitions, dev))
- ret = id_partitions[dev]:"";
-
- if (haskey(id_disks, dev))
- ret = id_disks[dev]:"";
- y2milestone("Device %1 was converted to: %2", dev, ret);
- return ret;
- }
-
- // check if it is device name by uuid
- if (search(dev, "/dev/disk/by-uuid/") != nil)
- {
- if (haskey(uuid_partitions, dev))
- ret = uuid_partitions[dev]:"";
-
- if (haskey(uuid_disks, dev))
- ret = uuid_disks[dev]:"";
- y2milestone("Device %1 was converted to: %2", dev, ret);
- return ret;
- }
-
- // check if it is device name by path
- if (search(dev, "/dev/disk/by-path/") != nil)
- {
- if (haskey(path_partitions, dev))
- ret = path_partitions[dev]:"";
-
- if (haskey(path_disks, dev))
- ret = path_disks[dev]:"";
- y2milestone("Device %1 was converted to: %2", dev, ret);
- return ret;
- }
- // check if it is device name by label
- // only partition are supported
- if (search(dev, "/dev/disk/by-label/") != nil)
- {
- if (haskey(label_partitions, dev))
- ret = label_partitions[dev]:"";
- y2milestone("Device %1 was converted to: %2", dev, ret);
- return ret;
- }
-
- y2milestone("Device %1 was converted to: %2", dev, ret);
- return ret;
-}
/**
* Function remap device map to device name (/dev/sda)
* or to label (ufo_disk)
@@ -325,7 +173,7 @@
// convert device names in device map to the device names by device or label
ret = mapmap (string k , string v, device_mapping,
{
- return $[BootCommon::MountByDev2Dev(k) : v];
+ return $[BootStorage::MountByDev2Dev(k) : v];
});
return ret;
@@ -352,27 +200,27 @@
if (haskey(globals_set, "boot_custom"))
{
- globals_set["boot_custom"] = BootCommon::MountByDev2Dev(globals_set["boot_custom"]:"");
+ globals_set["boot_custom"] = BootStorage::MountByDev2Dev(globals_set["boot_custom"]:"");
}
if (haskey(globals_set, "boot_chrp_custom"))
{
- globals_set["boot_chrp_custom"] = BootCommon::MountByDev2Dev(globals_set["boot_chrp_custom"]:"");
+ globals_set["boot_chrp_custom"] = BootStorage::MountByDev2Dev(globals_set["boot_chrp_custom"]:"");
}
if (haskey(globals_set, "boot_pmac_custom"))
{
- globals_set["boot_pmac_custom"] = BootCommon::MountByDev2Dev(globals_set["boot_pmac_custom"]:"");
+ globals_set["boot_pmac_custom"] = BootStorage::MountByDev2Dev(globals_set["boot_pmac_custom"]:"");
}
if (haskey(globals_set, "boot_iseries_custom"))
{
- globals_set["boot_iseries_custom"] = BootCommon::MountByDev2Dev(globals_set["boot_iseries_custom"]:"");
+ globals_set["boot_iseries_custom"] = BootStorage::MountByDev2Dev(globals_set["boot_iseries_custom"]:"");
}
if (haskey(globals_set, "boot_prep_custom"))
{
- globals_set["boot_prep_custom"] = BootCommon::MountByDev2Dev(globals_set["boot_prep_custom"]:"");
+ globals_set["boot_prep_custom"] = BootStorage::MountByDev2Dev(globals_set["boot_prep_custom"]:"");
}
return globals_set;
}
@@ -403,7 +251,7 @@
y2debug("value of resume: %1",resume_arg[1]:"");
if (dev != "")
{
- string resume = "resume="+BootCommon::MountByDev2Dev(dev);
+ string resume = "resume="+BootStorage::MountByDev2Dev(dev);
y2debug("remap resume: %1",resume);
new_append = add(new_append, resume);
} else {
@@ -456,7 +304,7 @@
if (s["root"]:"" != "")
{
string rdev = s["root"]:"";
- s["root"] = BootCommon::MountByDev2Dev(rdev);
+ s["root"] = BootStorage::MountByDev2Dev(rdev);
if (s["append"]:"" != "")
s["append"] = remapResume(s["append"]:"");
@@ -465,7 +313,7 @@
}
if (s["chainloader"]:"" != "")
- s["chainloader"] = BootCommon::MountByDev2Dev(s["chainloader"]:"");
+ s["chainloader"] = BootStorage::MountByDev2Dev(s["chainloader"]:"");
return s;
});
@@ -473,151 +321,7 @@
return temp_sec;
}
-/**
- * bnc #468922 - problem with longtime running the parsing a huge number of disks
- * Function initialize BootCommon::all_partitions only if storage change
- * partitioning of disk
- * true if init all_partitions
- */
-
-boolean MapAllPartitions()
-{
- boolean ret = false;
- if ((disk_change_time_MapAllPartitions != Storage::GetTargetChangeTime())
- || (size(BootCommon::all_partitions) < 1) || (size(BootCommon::target_map) < 1))
- {
- // save last change time from storage for MapAllPartitions()
- disk_change_time_MapAllPartitions = Storage::GetTargetChangeTime();
-
- BootCommon::all_partitions = $[];
- BootCommon::target_map = $[];
- // get target map
- BootCommon::target_map = (map)Storage::GetTargetMap();
- // map all partitions
- foreach (string k, map v, BootCommon::target_map,
- {
- foreach (map p, (list<map>)(v["partitions"]:[]),
- {
- all_partitions[p["device"]:""] = p;
- });
- });
- ret = true;
- }
-
- return ret;
-}
-/** FATE #302219 - Use and choose persistent device names for disk devices
- * Converts a device name to the corresponding device name it should be
- * mounted by, according to the "mountby" setting for the device from
- * yast2-storage. As a safeguard against problems, if the "mountby" device
- * name does not exist in the information from yast2-storage, it will
- * fallback to the "kernel name" ("/dev/sdXY").
- *
- * @param dev string device name
- * @return string device name according to "mountby"
- */
-global define string Dev2MountByDev(string dev)
-{
- y2milestone ("Dev2MountByDev: %1", dev);
-
- // (`id,`uuid,`path,`device,`label)
- symbol by_mount = nil;
- if (Arch::ppc())
- by_mount = `id;
- else
- by_mount = Storage::GetDefaultMountBy();
-
- //by_mount = `id;
- y2milestone("Default mount by is %1", by_mount);
-
- // add all_partitions to partitions
- if (MapAllPartitions())
- y2milestone("Init BootCommon::all_partitions was done");
-
- map partitions = BootCommon::all_partitions;
- map devices = BootCommon::target_map;
-
- string ret = dev;
- switch(by_mount)
- {
- // convert to udev_id
- case (`id):
- // partitions
- if ((partitions[dev, "udev_id"]:nil != nil) && (partitions[dev, "udev_id", 0]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-id/%1", partitions[dev, "udev_id", 0]:"");
- y2milestone ("Device name: %1 is converted to udev id: %2", dev, ret);
- return ret;
- }
- // disks
- if ((devices[dev, "udev_id"]:nil != nil) && (devices[dev, "udev_id", 0]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-id/%1", devices[dev, "udev_id", 0]:"");
- y2milestone ("Device name: %1 is converted to udev id: %2", dev, ret);
- return ret;
- }
- break;
-
- // convert to uuid
- case (`uuid):
- // partitions
- if ((partitions[dev, "uuid"]:nil != nil) && (partitions[dev, "uuid"]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-uuid/%1", partitions[dev, "uuid"]:"");
- y2milestone ("Device name: %1 is converted to uuid: %2", dev, ret);
- return ret;
- }
- // disks
- if ((devices[dev, "uuid"]:nil != nil) && (devices[dev, "uuid"]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-uuid/%1", devices[dev, "uuid"]:"");
- y2milestone ("Device name: %1 is converted to uuid: %2", dev, ret);
- return ret;
- }
- break;
-
- // convert to udev_path
- case (`path):
- // partitions
- if ((partitions[dev, "udev_path"]:nil != nil) && (partitions[dev, "udev_path"]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-path/%1", partitions[dev, "udev_path"]:"");
- y2milestone ("Device name: %1 is converted to udev path: %2", dev, ret);
- return ret;
- }
- // disks
- if ((devices[dev, "udev_path"]:nil != nil) && (devices[dev, "udev_path"]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-path/%1", devices[dev, "udev_path"]:"");
- y2milestone ("Device name: %1 is converted to udev path: %2", dev, ret);
- return ret;
- }
- break;
-
- // convert to label
- case (`label):
- // partitions
- if ((partitions[dev, "label"]:nil != nil) && (partitions[dev, "label"]:nil != ""))
- {
- ret = sformat ("/dev/disk/by-label/%1", partitions[dev, "label"]:"");
- y2milestone ("Device name: %1 is converted to label: %2", dev, ret);
- return ret;
- }
- // disks
- y2milestone ("Disk doesn't support labels - name: %1 is converted to label: %2", dev, ret);
- return ret;
- break;
-
- // convert to device or uknown type
- default:
- y2warning ("Convert %1 to `device or unknwn type, result: %2", dev, ret);
- return ret;
- break;
- }
-
- return ret;
-}
/**
* Returns list of partitions with "mount by" hints. Goes through the list
@@ -694,7 +398,7 @@
if ((type == `boot) && (bl == "grub"))
{
// check if device is in device map
- if (haskey(device_mapping, k) || (haskey(device_mapping, Dev2MountByDev(k))))
+ if (haskey(device_mapping, k) || (haskey(device_mapping, BootStorage::Dev2MountByDev(k))))
partitions = (list<map>)merge (partitions, (list<map>)(v["partitions"]:[]));
} else {
partitions = (list<map>)merge (partitions, (list<map>)(v["partitions"]:[]));
@@ -740,7 +444,7 @@
// filter out disk which are not in device map
if ((bl == "grub") && (type == `boot))
all_disks = (list<string>) filter(string k, all_disks, {
- if (haskey(device_mapping, k) || (haskey(device_mapping, Dev2MountByDev(k))))
+ if (haskey(device_mapping, k) || (haskey(device_mapping, BootStorage::Dev2MountByDev(k))))
return true;
else
return false;
@@ -1782,7 +1486,7 @@
if (search(key, "resume=") != nil)
{
list <string> tmp = splitstring(key,"=");
- key = Dev2MountByDev(tmp[1]:"");
+ key = BootStorage::Dev2MountByDev(tmp[1]:"");
}
if (search(default_append, key) != nil)
deuce = deuce +1;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org