diff --git a/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc b/gosa-plugins/fai/admin/fai/class_faiDiskEntry.inc
index 19f85219cc85c0a26710988b4873a3ab39ee21bc..a1f0e420e8e9cf34b6938194007111b681e54a00 100644 (file)
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes = array("DISKcn","DISKdescription");
+ var $UsedAttrs = array("cn","description","FAIpartitionType",
+ "FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
+ "FAIfsTuneOptions", "FAIfsCreateOptions", "FAImountOptions",
+ "FAIfsOptions","FAIpartitionFlags","FAIdiskOption");
+
var $objectclasses= array();
var $DISKcn = "";
var $DISKdescription = "";
- var $DISKFAIdiskOptions = "";
+ var $DISKFAIdiskOptions = "";
+
+ var $partitions = array();
+ var $is_edit = false;
+ var $old_cn = "";
+ var $status = "new";
+ var $deletePartitions = array();
+ var $fstabkey = "device";
+ var $disklabel = "msdos";
+ var $FAIstate = "";
+ var $FAIdiskType = "disk";
- var $partitions = array();
- var $UsedAttrs = array();
- var $is_edit = false;
- var $old_cn = "";
- var $status = "new";
- var $deletePartitions = array();
- var $fstabkey = "device";
- var $disklabel = "msdos";
-
- var $FAIstate = "";
- var $FAIdiskType = "disk";
-
- function faiDiskEntry (&$config, $dn= NULL,$usedDiskNames=array(),$disk=false)
+ var $lvmDevices = array();
+
+ function faiDiskEntry (&$config, $dn= NULL,$parent,$disk,$type)
{
plugin::plugin ($config, $dn);
- $this->UsedAttrs = array("cn","description","FAIpartitionType","FAIpartitionNr","FAIfsType","FAImountPoint","FAIpartitionSize",
- "FAImountOptions","FAIfsOptions","FAIpartitionFlags");
-
- /* Default status is new */
+
+ // Set default attributes
+ $this->parent = $parent;
+ $this->FAIdiskType = $type;
$this->status = "new";
-
- /* We want to edit an entry */
+
+ // If disk is not empty, then we are going to edit
+ // an existing disk, load disk info now.
if($disk){
- /* Set disk status */
+ // Get devices used in volume base disks.
+ if($disk['FAIlvmDevice']){
+ $this->lvmDevices = $disk['FAIlvmDevice'];
+ }
+
+ // Get disk status
$this->status = $disk['status'];
- /* Walk through partitions */
+ // Load default attributes
+ $this->DISKcn = $disk['cn'];
+ $this->DISKdescription = $disk['description'];
+ $this->is_edit = true;
+ $this->old_cn = $disk['cn'];
+
+ // Load partition info
foreach($disk['partitions'] as $name => $values){
- /* If a partition is already marked as delete, attach it to deletePartitions only. */
+ // Do not load removed partitions
if($values['status'] == "delete"){
unset($disk['partitions'][$name]);
$this->deletePartitions[]=$values;
}else{
- /* Set status, to know which partition must be deleted from ldap
- new : Neu partition entry // save
- edited : Update partition entry in ldap
- deleted: Remove partition from ldap
- */
-
/* If status is not new, set to edit mode.
* New means that this partition currently wasn't saved to ldap.
*/
if($disk['partitions'][$name]['status']!="new"){
$disk['partitions'][$name]['status']="edited";
}
-
+
+ // Load partition attributes
$disk['partitions'][$name]['old_cn']= $disk['partitions'][$name]['cn'];
-
- /* Assign empty attributes, if attribute is missing */
+ $disk['partitions'][$name]['FAIdiskType']= $this->FAIdiskType;
foreach($this->UsedAttrs as $attr){
if(!isset($values[$attr])){
$disk['partitions'][$name][$attr]="";
}
}
-
if (preg_match('/^_/', $disk['partitions'][$name]['FAIfsType'])){
- $disk['partitions'][$name]['FAIfsType']= preg_replace('/^_/', '', $disk['partitions'][$name]['FAIfsType']);
+ $disk['partitions'][$name]['FAIfsType']=
+ preg_replace('/^_/', '', $disk['partitions'][$name]['FAIfsType']);
}
}
}
- /* Set default attributes */
- $this->DISKcn = $disk['cn'];
- $this->DISKdescription = $disk['description'];
$this->partitions = $disk['partitions'];
- $this->is_edit = true;
- $this->old_cn = $disk['cn'];
- /* Move faiDiskOption */
+ /* Load FAIdiskOptions.
+ * Some options are disk related and some are used for partitions.
+ * - fstabkey -> disk
+ * - disklabel -> disk
+ * - bootable -> partition
+ * - preserve -> partition
+ * - resize -> partition
+ */
if (isset($disk['FAIdiskOption'])){
foreach($disk['FAIdiskOption'] as $option) {
+
+ // Get fstab key
if (preg_match("/fstabkey:(device|label|uuid)/", $option)){
$this->fstabkey= preg_replace("/^.*fstabkey:(device|label|uuid).*$/", "$1", $option);
- break;
+ continue;
}
+
+ // Get disk label
if (preg_match("/disklabel:(msdos|gpt)/", $option)){
$this->disklabel= preg_replace("/^.*disklabel:(msdos|gpt).*$/", "$1", $option);
- break;
+ continue;
+ }
+
+ // Load bootable flag for partitions
+ if (preg_match("/^bootable:/", $option)){
+ $bootable = split(",", trim(preg_replace("/^bootable:/","",$option),","));
+ foreach($bootable as $bootflag){
+ if(isset($this->partitions[$bootflag])){
+ $this->partitions[$bootflag]['bootable'] = TRUE;
+ }
+ }
+ continue;
+ }
+
+ // Load resize flag for partitions
+ if (preg_match("/^resize:/", $option)){
+ $resize = split(",", trim(preg_replace("/^resize:/","",$option),","));
+ foreach($resize as $id){
+ if(isset($this->partitions[$bootflag])){
+ $this->partitions[$id]['resize'] = TRUE;
+ }
+ }
+ continue;
+ }
+
+ // Load preserve_always flag for partitions
+ if (preg_match("/^preserve_always:/", $option)){
+ $preserve = split(",", trim(preg_replace("/^preserve_always:/","",$option),","));
+ foreach($preserve as $presflag){
+ if(isset($this->partitions[$bootflag])){
+ $this->partitions[$presflag]['preserve'] = TRUE;
+ $this->partitions[$presflag]['preserveType'] = 'always';
+ }
+ }
+ continue;
+ }
+
+ // Load preserve_reinstall flag for partitions
+ if (preg_match("/^preserve_reinstall:/", $option)){
+ $preserve = split(",", trim(preg_replace("/^preserve_reinstall:/","",$option),","));
+ foreach($preserve as $presflag){
+ if(isset($this->partitions[$bootflag])){
+ $this->partitions[$presflag]['preserve'] = TRUE;
+ $this->partitions[$presflag]['preserveType'] = 'reinstall';
+ }
+ }
+ continue;
}
}
} else {
$this->fstabkey= "device";
}
-
}
}
/* Call parent execute */
plugin::execute();
- /* Fill templating stuff */
+ // Fill templating stuff
$smarty = get_smarty();
$s_action = "";
$s_entry = "";
$display = "";
- /* Load parameters */
- if (isset($_POST['disklabel']) && preg_match("/^(msdos|gpt)$/", $_POST['disklabel'])){
- $this->disklabel= $_POST['disklabel'];
- }
- if (isset($_POST['fstabkey']) && preg_match("/^(device|label|uuid)$/", $_POST['fstabkey'])){
- $this->fstabkey= $_POST['fstabkey'];
- }
-
- /* Assign values
- * And Checkbox selection
- */
- foreach($this->attributes as $attrs){
- $smarty->assign($attrs,$this->$attrs);
- if($this->$attrs){
- $smarty->assign($attrs."CHK"," ");
- }else{
- $smarty->assign($attrs."CHK"," disabled ");
- }
+ // Remove partition
+ if(isset($_POST['addLvmPartition']) && isset($_POST['lvmPartitionAdd'])){
+ $name = $_POST['lvmPartitionAdd'];
+ $this->lvmDevices[$name] = array("name" => $name);
}
/* Check all Posts if there is something usefull for us,
* The number specifies the index we want to delete
*/
foreach($_POST as $name => $value){
- if((preg_match("/Delete_.*/",$name)) && $this->acl_is_removeable() && !preg_match("/freeze/i",$this->FAIstate)){
+ if((preg_match("/RemovePartition_/",$name)) &&
+ $this->acl_is_removeable() &&
+ !preg_match("/freeze/i",$this->FAIstate)){
$tmp = split("_",$name);
- $s_action = "remove";
- $s_entry = $tmp[1];
+ $this->removePartition($tmp[1]);
+ break;
}
+ if(preg_match("/^EditPartition_/",$name)){
+ $id = preg_replace("/^EditPartition_/","",$name);
+ $id = preg_replace("/_.*$/","",$id);
+ if(isset($this->partitions[$id])){
+ $this->dialog = new faiPartition($this->config,$this->partitions[$id], $this,$this->FAIdiskType);
+ break;
+ }
+ }
}
- /* To remove a partition we unset the index posted.
- * We must sort the index again, else we possibly got problems
- * with partitions order.
+ /* Create a new partition for this disk.
*/
- if($s_action == "remove" && $this->acl_is_removeable() && !preg_match("/freeze/i",$this->FAIstate)){
- if($this->partitions[$s_entry]['status'] == "edited"){
- $this->deletePartitions[$s_entry]= $this->partitions[$s_entry];
- $this->deletePartitions[$s_entry]['FAIpartitionNr']=$s_entry;
- unset($this->partitions[$s_entry]);
- }else{
- unset($this->partitions[$s_entry]);
- }
- $tmp= array();
- foreach($this->partitions as $part){
- $tmp[count($tmp)+1]=$part;
- }
- $this->partitions = $tmp;
+ if(isset($_POST['AddPartition']) && !preg_match("/freeze/i",$this->FAIstate)){
+ $this->dialog = new faiPartition($this->config, array(), $this,$this->FAIdiskType);
}
- /* To add a partitions we only append an empty
- * array to the already defined partitions.
+ /* Handle partition dialogs.
*/
- if(isset($_POST['AddPartition']) && $this->acl_is_createable() && !preg_match("/freeze/i",$this->FAIstate)){
- foreach($this->UsedAttrs as $attr){
- $tmp[$attr] = "";
+ if($this->dialog instanceOf plugin && isset($_POST['PartitionCancel'])){
+ $this->dialog = null;
+ }
+ if($this->dialog instanceOf plugin && isset($_POST['PartitionSave'])){
+ $this->dialog->save_object();
+ $this->updatePartition($this->dialog->save());
+ $this->dialog = null;
+ }
+ if($this->dialog instanceOf plugin){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+ // Assign checkbox related values.
+ foreach($this->attributes as $attrs){
+ $smarty->assign($attrs,$this->$attrs);
+ if($this->$attrs){
+ $smarty->assign($attrs."CHK"," ");
+ }else{
+ $smarty->assign($attrs."CHK"," disabled ");
}
- $tmp["old_cn"] = "";
- $tmp['status']="new";
- $this->partitions[count($this->partitions)+1]=$tmp;
}
- /* $setup contains a table with the partitions.
- */
+ // Assign disk info to smarty.
$smarty->assign("setup", $this->generateParts());
+ $smarty->assign("sub_object_is_createable",$this->acl_is_createable());
+ $smarty->assign("freeze",preg_match("/freeze/i",$this->FAIstate));
+ $smarty->assign("fstabkeys", array("device" => _("Device"), "label" => _("Label"), "uuid" => _("UUID")));
+ $smarty->assign("disklabels", array("msdos" => "MSDOS", "gpt" => "GPT"));
+ $smarty->assign("fstabkey", $this->fstabkey);
+ $smarty->assign("disklabel", $this->disklabel);
+ $smarty->assign("FAIdiskType", $this->FAIdiskType);
+ $smarty->assign("plist", $this->getPartitionList());
+ $smarty->assign("physicalPartitionList", $this->getAvailablePartitions());
+
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);
}
+ // Assign partitions
$tmp = $this->plInfo();
$sacl = "";
foreach($tmp['plProvidedAcls'] as $name => $translated){
$smarty->assign($name."ACL",$acl);
}
- $smarty->assign("sub_object_is_createable",$this->acl_is_createable());
- $smarty->assign("freeze",preg_match("/freeze/i",$this->FAIstate));
-
- // Fill boxes
- $smarty->assign("fstabkeys", array("device" => _("Device"), "label" => _("Label"), "uuid" => _("UUID")));
- $smarty->assign("disklabels", array("msdos" => "MSDOS", "gpt" => "GPT"));
- $smarty->assign("fstabkey", $this->fstabkey);
- $smarty->assign("disklabel", $this->disklabel);
-
- /* Fetch template and show the result
- */
$display.= $smarty->fetch(get_template_path('faiDiskEntry.tpl', TRUE));
return($display);
}
- function generateParts()
+ function getPartitionList()
{
- /* Define Arrays with allowed syntax */
- $PartitionTypes = array("primary"=>_("primary"),"logical"=>_("logical"));
- $FAIfsTypes = array("ext2","ext3","xfs","swap","reiser","dosfat16","winfat32");
-
- /* Display Header */
- $str = "";
- if (count($this->partitions)){
- $str .= "<tr>";
- $str .= "<td><b>"._("Type")."</b></td>";
- $str .= "<td><b>"._("FS type")."</b></td>";
- $str .= "<td><b>"._("Mount point")."</b></td>";
- $str .= "<td><b>"._("Size in MB")."</b></td>";
- $str .= "<td><b>"._("Mount options")."</b></td>";
- $str .= "<td><b>"._("FS option")."</b></td>";
- $str .= "<td><b>"._("Preserve")."</b></td>";
- $str .= "<td> </td>";
- $str .= "</tr>";
- }
-
- /* Walk through all defined partitions.
- * Create a new row for each partition and append it to
- * the header defined above.
- * To be able to check the posts later, we append a key to each single postfield. like cn_1 ... cn_2
- */
- foreach($this->partitions as $key => $part){
-
- $dis = "";
- if($part['FAIpartitionFlags'] == "preserve"){
- $dis = " disabled ";
+ $divlist = new divSelectBox("RaidList");
+ $disks = $this->parent->disks;
+ $objs = $disks;
+ foreach($disks as $disk){
+ foreach($disk['partitions'] as $id => $part){
+ $objs[$disk['cn'].$id] = $part;
}
+ }
- $disableALL = "";
- if (preg_match("/freeze/", $this->FAIstate)){
- $disableALL = " disabled ";
- }
-
- if($part['status']!="delete"){
-
- /* Generate Partition select box
- */
- $PartitionType = "";
- if($this->acl_is_writeable("FAIpartitionType")){
- $PartitionType = "<select name='FAIpartitionType_".$key."' id='FAIpartitionType_".$key."' ".$disableALL.">";
- foreach($PartitionTypes as $type => $PTname){
- if($part['FAIpartitionType'] == $type){
- $PartitionType .="<option value='".$type."' selected >".$PTname."</option>";
- }else{
- $PartitionType .="<option value='".$type."'>".$PTname."</option>";
- }
- }
- $PartitionType.="</select>";
- }elseif($this->acl_is_readable("FAIpartitionType")){
- $PartitionType = $part['FAIpartitionType'];
- }
-
-
- /* Generate fsType select box
- */
- $FAIfsType= "";
- if($this->acl_is_writeable("FAIfsType")){
- $FAIfsType= "<select name='FAIfsType_".$key."' id='FAIfsType_".$key."' ".$dis." ".$disableALL.">";
- foreach($FAIfsTypes as $type){
- if($part['FAIfsType'] == $type){
- $FAIfsType .="<option value='".$type."' selected >".$type."</option>";
- }else{
- $FAIfsType .="<option value='".$type."'>".$type."</option>";
- }
- }
- $FAIfsType.="</select>";
- }elseif($this->acl_is_readable("FAIfsType")){
- $FAIfsType = $part['FAIfsType'];
- }
+ $list = array();
+ foreach($this->lvmDevices as $device){
+ $list[$device] = $device;
- foreach(array("FAImountPoint","FAIpartitionSize","FAImountOptions","FAIfsOptions") as $attr){
- $$attr = "";
- if($this->acl_is_writeable($attr)){
- $$attr = "<input name='".$attr."_".$key."' ".$disableALL." ".$dis."
- value='".$part[$attr]."' id='".$attr."_".$key."'>";
+ if(isset($objs[$device]['FAIpartitionSize'])){
+ $list[$device].= _("Size").": ";
+ $list[$device].= $objs[$device]['FAIpartitionSize'];
+ }
+ }
+ return($list);
+ }
- }elseif($this->acl_is_readable($attr)){
- $$attr = $part[$attr];
- }
+
+ function getAvailablePartitions(){
+ $array = array();
+ foreach($this->parent->disks as $disk){
+ foreach($disk['partitions'] as $key => $part){
+ $name = $disk['cn'].$key;
+ if(!isset($this->lvmDevices[$name])){
+ $array[$name] = $name;
}
+ }
+ }
+ return($array);
+ }
- $str .= "\n<tr>";
- $str .= "\n<td>".$PartitionType."</td>";
- $str .= "\n<td>".$FAIfsType."</td>";
- $str .= "\n<td>".$FAImountPoint."</td>";
- $str .= "\n<td>".$FAIpartitionSize."</td>";
- $str .= "\n<td>".$FAImountOptions."</td>";
- $str .= "\n<td>".$FAIfsOptions."</td>";
- $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ".
- "changeState('FAIpartitionSize_".$key."') ; ".
- "changeState('FAImountOptions_".$key."') ; ".
- "changeState('FAIfsType_".$key."') ; ".
- "changeState('FAIfsOptions_".$key."') ; \"";
-
- if($this->acl_is_writeable("FAIpartitionFlags")){
- if($part['FAIpartitionFlags']!=false){
- $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' checked ".$changeState." ".$disableALL."></td>";
- }else{
- $str .= "\n<td><input type='checkbox' name='FAIpartitionFlags_".$key."' value='preserve' ".$changeState." ".$disableALL."></td>";
- }
+ /* Remove the selected partition and shift the following partitions
+ * to fill gap.
+ * Additionally update the partition numbers correspondingly.
+ */
+ function removePartition($id)
+ {
+ $start = false;
+ foreach($this->partitions as $key => $part){
+ if($id == $key){
+ $start = true;
+ }
+ if($start){
+ if($this->partitions[$key]['status'] == "edited"){
+ $this->deletePartitions[$key]= $this->partitions[$key];
+ $this->deletePartitions[$key]['FAIpartitionNr']=$key;
+ unset($this->partitions[$key]);
}else{
- if($part['FAIpartitionFlags']!=false){
- $str .= "<td>"._("False")."</td>";
- }else{
- $str .= "<td>"._("True")."</td>";
- }
+ unset($this->partitions[$key]);
}
- if($this->acl_is_removeable()){
- $str .= "\n<td><input type='submit' name='Delete_".$key."' value='"._("Remove")."' ".$disableALL."></td>";
- }else{
- $str .= "\n<td><input type='submit' name='restricted' disabled value='"._("Remove")."'></td>";
+ if(isset($this->partitions[($key+1)])){
+ if(isset($this->deletePartitions[$key])){
+ unset($this->deletePartitions[$key]);
+ }
+ $this->partitions[$key] = $this->partitions[($key+1)];
+ $this->partitions[$key]['FAIpartitionNr'] = $key;
+ $this->partitions[$key]['status'] = "new";
}
- $str .= "\n</tr>";
}
}
-
- if(!empty($str)){
- $str = "<table summary='' style='width:100%'>".$str."</table>";
+ $tmp= array();
+ foreach($this->partitions as $part){
+ $tmp[count($tmp)+1]=$part;
}
- return($str);
+ $this->partitions = $tmp;
+ }
+
+ /* Add or update a partition
+ */
+ function updatePartition($part)
+ {
+ if(!isset($part['FAIpartitionNr']) || $part['FAIpartitionNr'] == "undefined"){
+ $part['FAIpartitionNr'] = count($this->partitions) + 1;
+ $part['cn'] = count($this->partitions) + 1;
+ }
+ $this->partitions[$part['FAIpartitionNr']] = $part;
}
+
+ function generateParts()
+ {
+
+ $divlist = new divSelectBox("DiskEntries");
+ foreach($this->partitions as $key => $part){
+ $number =array(
+ "string" => $part['FAIpartitionNr'],
+ "attach" => "style='width:20px;'");
+ $size =array(
+ "string" => $part['FAIpartitionSize'],
+ "attach" => "style='width:100px;'");
+ $fstype =array(
+ "string" => $part['FAIfsType'],
+ "attach" => "style='width:60px;'");
+ $type =array(
+ "string" => $part['FAIpartitionType'],
+ "attach" => "style='width:80px;'");
+ $opt =array(
+ "string" => $part['FAImountOptions'],
+ "attach" => "style='width:80px;'");
+ $fsopt =array(
+ "string" => $part['FAIfsOptions'],
+ "attach" => "style='width:80px;'");
+ $flags =array(
+ "string" => $part['FAIpartitionFlags'],
+ "attach" => "style='width:80px;'");
+ $mntp =array("string" => $part['FAImountPoint']);
+
+
+ $action =array(
+ "string" => "<input type='image' src='images/lists/edit.png' name='EditPartition_".$key."'>".
+ "<input type='image' src='images/lists/trash.png' name='RemovePartition_".$key."'>",
+ "attach" => "style='width:40px;'");
+
+
+ $fields = array($number,$type,$mntp,$size,$fstype, $opt,$fsopt,$flags,$action);
+ $divlist->AddEntry($fields);
+ }
+ return($divlist->DrawList());
+ }
+
+
function save()
{
$tmp = array();
/* Attach partitions */
foreach($this->partitions as $key=>$val) {
$this->partitions[$key]['FAIpartitionNr']=$key;
+ $this->partitions[$key]['cn']=$key;
}
/* Attach deleted */
$tmp['status'] = $this->status;
$tmp['FAIdiskType'] = $this->FAIdiskType;
+ $tmp['FAIlvmDevice'] = array();
+ foreach($this->lvmDevices as $dev){
+ $tmp['FAIlvmDevice'][] = $dev;
+ }
+
/* Assemble flags */
$tmp['FAIdiskOption'] = array("fstabkey:".$this->fstabkey, "disklabel:".$this->disklabel);
$tmp['rename']['from'] = $this->old_cn;
$tmp['rename']['to'] = $this->DISKcn;
}
+
+ // Build up disk options
+ $bootable = "";
+ $resize = "";
+ $preserve_always = "";
+ $preserve_reinstall = "";
+
+ foreach($tmp['partitions'] as $id => $part){
+ if(isset($part['bootable']) && $part['bootable']){
+ $bootable .= $id.",";
+ }
+ if(isset($part['resize']) && $part['resize']){
+ $resize .= $id.",";
+ }
+ if(isset($part['preserve']) && $part['preserve']){
+ if($part['preserveType'] == "always"){
+ $preserve_always .= $id.",";
+ }else{
+ $preserve_reinstall .= $id.",";
+ }
+ }
+ $tmp['partitions'][$id]['status'] = $part['status'];
+
+ // Unset non valid attributes
+ foreach(array("bootable","encrypted","preserve","preserveType","resize","FAIdiskType") as $attr){
+ if(isset($tmp['partitions'][$id][$attr])){
+ unset($tmp['partitions'][$id][$attr]);
+ }
+ }
+ }
+
+ if(!empty($bootable)){
+ $tmp['FAIdiskOption'][] = "bootable:".trim($bootable,",");
+ }
+ if(!empty($resize)){
+ $tmp['FAIdiskOption'][] = "resize:".trim($resize,",");
+ }
+ if(!empty($preserve_always)){
+ $tmp['FAIdiskOption'][] = "preserve_always:".trim($preserve_always,",");
+ }
+ if(!empty($preserve_reinstall)){
+ $tmp['FAIdiskOption'][] = "preserve_reinstall:".trim($preserve_reinstall,",");
+ }
+
+ $tmp['status'] = $this->status;
return($tmp);
}
if((isset($_POST['TableEntryFrameSubmitted'])) && !preg_match("/freeze/", $this->FAIstate) ){
plugin::save_object();
- foreach($this->partitions as $key => $part){
- foreach($this->UsedAttrs as $attrs){
-
- if($this->acl_is_writeable($attrs)){
-
- if(isset($_POST[$attrs."_".$key])){
- $this->partitions[$key][$attrs] = $_POST[$attrs."_".$key];
- }else{
- $this->partitions[$key][$attrs] = false;
- }
- }
- }
-
- /* Adapt ext3 to have -j option */
- if ($this->partitions[$key]["FAIfsType"] == "ext3") {
- $this->partitions[$key]["FAIfsOptions"]= preg_replace('/\s*-j\s*/', '', $this->partitions[$key]["FAIfsOptions"]);
- $this->partitions[$key]["FAIfsOptions"]= "-j ".$this->partitions[$key]["FAIfsOptions"];
- }
+ // Save posted disk label and fstab key
+ if (isset($_POST['disklabel']) && preg_match("/^(msdos|gpt)$/", $_POST['disklabel'])){
+ $this->disklabel= $_POST['disklabel'];
+ }
+ if (isset($_POST['fstabkey']) && preg_match("/^(device|label|uuid)$/", $_POST['fstabkey'])){
+ $this->fstabkey= $_POST['fstabkey'];
}
-
}
}
$alreadyUsed[$attrs] = array();
}
- foreach($this->partitions as $key => $part){
-
- /* Skip all checks, if preserve is set */
- if($part['FAIpartitionFlags'] == "preserve"){
- $this->partitions[$key]['FAIfsType'] = "preserve";
- $this->partitions[$key]['FAIpartitionSize'] = "preserve";
- continue;
- }
-
- if($part['FAImountPoint'] != "-" && (in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint']))&&($part['FAIfsType']!="swap")){
- $message[]=sprintf(_("Please enter a unique mount point for partition %s"),($key));
- }
-
- if($part['FAIfsType']!="swap" && $part['FAImountPoint'] != "-"){
- if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){
- $message[]= msgPool::invalid(sprintf(_("partition %s mount point"),$key));
- }
- }
- if($part['FAIfsType'] == "swap"){
- if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){
- $message[]=sprintf(_("File system type 'swap' is already used, change file system type for partition %s."),$key);
- }
- }
- if(($part['FAIfsType'] == "swap")&&(!empty($part['FAImountPoint']))&&($part['FAImountPoint']!="swap")){
- $message[]=_("Please use 'swap' as mount point, if 'swap' is used as fs-type.");
- }
-
- $tmp = split("-",$part['FAIpartitionSize']);
- switch (count($tmp)){
- case 0:
- $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
- break;
- case 1:
- if (!tests::is_id($tmp[0]) &&(!empty($tmp[1]))){
- $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
- }
- break;
-
- case 2:
- if( !tests::is_id($tmp[0]) && !tests::is_id($tmp[1]) && !empty($tmp[1]) ){
- $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
- }elseif(!empty($tmp[1]) && $tmp[0]>=$tmp[1]){
- $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
- }
- break;
-
- default:
- $message[]= msgPool::invalid(sprintf(_("partition %s size"),$key));
- }
-
- foreach($this->UsedAttrs as $attrs){
- $alreadyUsed[$attrs][$key] = $part[$attrs];
- }
- }
-
$cnt = 0;
foreach($this->partitions as $key => $part){
if($part['FAIpartitionType'] == "primary"){