ACC SHELL

Path : /usr/share/YaST2/include/partitioning/
File Upload :
Current File : //usr/share/YaST2/include/partitioning/raid_lib.ycp

/**
 * File:
 *   raid_lib.ycp
 *
 * Module:
 *    configuration of raid:
 *
 * Summary:
 *
 * Authors:
 *   mike <mike@suse.de>
 *
 * $Id: raid_lib.ycp 60217 2010-01-04 11:39:28Z aschnell $
 */
{
  import "Partitions";

  textdomain "storage";


/*
 * Get all partitions, we can probably use as raid devices
 * Add needed information: is_raid, disksize
 */
define list<map> get_possible_rds( map<string,map> targetMap )
    ``{
    list<map> ret = [];

    //////////////////////////////////////////////////////////////////////
    // add the devicename i.e /dev/hda1 or /dev/system/usr to partition list
    // and the device key  <subdevice>/<maindevice> i.e. 1//dev/hda

    targetMap = mapmap( string dev, map devmap, targetMap,
	``{
	list<map> partitions = 
	    maplist( map part, devmap["partitions"]:[],
		``{
		part["maindev"] = dev;
		return( part );
		});

	return( $[ dev: add( devmap, "partitions", partitions)] );
	});

    ////////////////////////////////////////////////////////////
    // Look for all partitions:
    // not LVM ( here I mean /dev/<lvm_volumegroup>/<lv> entrys!
    //           there are only the lv's in the targetMap under 
    //           /dev/<lvm_volumegroup>/<lv> !)
    // no mountpoint
    // id 0x83 or 0x8e or 0xfd
    // no RAID devices (this is for experts only, by hand)

    list<map> allret = [];

    list<symbol> allowed_ctypes = [ `CT_DISK, `CT_DMRAID, `CT_DMMULTIPATH ];
    list types_no = [ `lvm, `sw_raid ];
    list fsids = [ Partitions::fsid_lvm, Partitions::fsid_raid, 
                   Partitions::fsid_native ];
    list ubs = [ `UB_NONE, `UB_MD ];
    list allowed_enc_types = [ `none ];

    foreach (string dev, map devmap, targetMap, {
	if (contains(allowed_ctypes, devmap["type"]:`CT_UNKNOWN))
	{
	ret = filter( map p, devmap["partitions"]:[],
		      ``( size(p["mount"]:"")==0 &&
			  !contains( types_no, p["type"]:`primary ) &&
			  contains(allowed_enc_types, p["enc_type"]:`none) &&
			  contains( ubs, p["used_by_type"]:`UB_NONE ) && 
			  (!haskey(p,"fsid")||contains( fsids, p["fsid"]:0 ))));
        allret = (list<map>)merge(allret, ret );
	}
	});
    return( allret );
    };
}

ACC SHELL 2018