home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
usr
/
share
/
YaST2
/
include
/
partitioning
/
auto_part_create.ycp
next >
Wrap
Text File
|
2006-11-29
|
4KB
|
149 lines
/**
* Module: auto_part_create.ycp
*
* Authors: Andreas Schwab (schwab@suse.de)
* Klaus KΣmpf (kkaempf@suse.de)
*
* Purpose: This module creates the neccessary partitions
* in the targetMap
*
* $Id: auto_part_create.ycp 33627 2006-10-24 10:39:14Z fehr $
*
* used globals
*
* defined functions
*/
{
textdomain "storage";
import "Storage";
import "Partitions";
import "ProductFeatures";
include "partitioning/do_proposal_flexible.ycp";
boolean create_partitions( map<string,map> tgmap, map disk, list<map> partitions )
{
y2milestone( "create_partitions disk:%1",
haskey(disk,"partitions")?remove(disk,"partitions"):disk );
y2milestone( "create_partitions partitions %1", partitions );
boolean ret = false;
boolean has_flex = has_flex_proposal();
string vm = Storage::ProposalVM();
y2milestone( "create_partitions flex %1 vm %2", has_flex, vm );
disk["partitions"] = partitions;
map keep = find( map p, partitions,
``(!p["delete"]:false&&p["type"]:`unknown!=`free));
if( size(vm)==0 )
{
if( has_flex )
{
map flex = do_flexible_disk( disk );
if( flex["ok"]:false )
partitions = flex["disk","partitions"]:[];
}
else
{
integer num_del_exist = size(filter(map p, partitions,
``(p["type"]:`unknown!=`free&&
p["delete"]:false)));
integer num_del_free = size(filter(map p, partitions,
``(p["type"]:`unknown==`free&&
p["delete"]:false)));
map r = can_swap_reuse( disk["device"]:"", partitions, tgmap );
if( haskey( r, "partitions" ))
partitions = r["partitions"]:[];
else if( haskey( r, "targets" ))
tgmap = r["targets"]:$[];
y2milestone( "create_partitions num_del_exist %1 num_del_free %2 swap_reuse %3",
num_del_exist, num_del_free, size(r)>0 );
y2milestone( "create_partitions keep %1", keep );
if( keep!=nil && size(r)>0 && num_del_exist==1 && num_del_free==0 )
{
y2milestone( "create_partitions single special" );
boolean first = true;
partitions = maplist( map p, partitions,
``{
if( p["delete"]:false && first )
{
p = remove( p, "delete" );
first = false;
p["format"] = true;
p["used_fs"] = Partitions::DefaultFs();
p["mount"] = "/";
y2milestone( "create_partitions single p %1", p );
}
return( p );
});
}
else
{
partitions = get_proposal( size(r)>0, disk );
}
}
y2milestone( "create_partitions %1", partitions );
}
else
{
map id_save = $[];
disk["partitions"] = maplist( map p, disk["partitions"]:[],
``{
if( !p["delete"]:false &&
p["type"]:`unknown!=`free && p["type"]:`unknown!=`extended )
{
id_save[p["device"]:""] = p["fsid"]:0;
p["fsid"] = Partitions::fsid_hibernation;
}
return( p );
});
y2milestone( "create_partitions id_save %1", id_save );
y2milestone( "create_partitions ps %1", disk["partitions"]:[] );
map r = get_proposal_vm( tgmap, vm, disk );
ret = r["ok"]:false;
if( ret )
{
string ddev = disk["device"]:"";
tgmap = r["target"]:$[];
tgmap[ddev,"partitions"] = maplist( map p, tgmap[ddev,"partitions"]:[],
``{
if( haskey( id_save, p["device"]:"" ))
p["fsid"] = id_save[p["device"]:""]:0;
return( p );
});
y2milestone( "create_partitions ps %1", tgmap[ddev,"partitions"]:[] );
}
}
keep = find( map p, partitions,
``(!p["delete"]:false&&!p["create"]:false));
partitions = filter( map p, partitions, ``(p["type"]:`unknown!=`free));
y2milestone( "create_partitions keep %1", keep );
Storage::SetWholeDisk( keep == nil );
if( size(vm)==0 )
{
partitions = maplist( map p, partitions,
``{
if( size(p["mount"]:"")>0 && !p["delete"]:false )
p["fstopt"] = FileSystems::DefaultFstabOptions( p );
if( p["format"]:false && !p["delete"]:false )
p["fs_options"] = FileSystems::DefaultFormatOptions( p );
return( p );
});
ret = size(partitions)>0;
if( ret )
{
tgmap[disk["device"]:"","partitions"] = partitions;
tgmap = Storage::SpecialBootHandling(tgmap);
}
}
if( ret )
{
Storage::SetTargetMap( tgmap );
Storage::AddMountPointsForWin(tgmap);
}
y2milestone( "create_partitions ret %1", ret );
return( ret );
}; // create_partitions
}