All rights reserved. Based on FreeNAS (http://www.freenas.org) Copyright (C) 2005-2006 Olivier Cochard-Labbé . All rights reserved. Based on m0n0wall (http://m0n0.ch/wall) Copyright (C) 2003-2006 Manuel Kasper . All rights reserved. */ /* ========================================================================== */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ========================================================================== */ $pgtitle = array(gettext("System"), gettext("Disks"), gettext("Mount Point"), gettext("Edit")); require_once("freenas_config.inc"); require_once("guiconfig.inc"); require_once("freenas_guiconfig.inc"); require_once("freenas_functions.inc"); $id = $_GET['id']; if (isset($_POST['id'])) $id = $_POST['id']; if (!is_array($freenas_config['mounts']['mount'])) $freenas_config['mounts']['mount'] = array(); mount_sort(); if (!is_array($freenas_config['disks']['disk'])) $freenas_config['disks']['disk'] = array(); disks_sort(); if (!is_array($freenas_config['gvinum']['vdisk'])) $freenas_config['gvinum']['vdisk'] = array(); gvinum_sort(); if (!is_array($freenas_config['gmirror']['vdisk'])) $freenas_config['gmirror']['vdisk'] = array(); gmirror_sort(); if (!is_array($freenas_config['gconcat']['vdisk'])) $freenas_config['gconcat']['vdisk'] = array(); gconcat_sort(); if (!is_array($freenas_config['gstripe']['vdisk'])) $freenas_config['gstripe']['vdisk'] = array(); gstripe_sort(); if (!is_array($freenas_config['graid5']['vdisk'])) $freenas_config['graid5']['vdisk'] = array(); graid5_sort(); $a_mount = &$freenas_config['mounts']['mount']; $a_disk = array_merge($freenas_config['disks']['disk'],$freenas_config['gvinum']['vdisk'],$freenas_config['gmirror']['vdisk'],$freenas_config['gconcat']['vdisk'],$freenas_config['gstripe']['vdisk'],$freenas_config['graid5']['vdisk']); /* Load the cfdevice file*/ $filename=$g['varetc_path']."/cfdevice"; if (file_exists($filename)) $cfdevice = trim(file_get_contents("$filename")); if (isset($id) && $a_mount[$id]) { $pconfig['mdisk'] = $a_mount[$id]['mdisk']; $pconfig['partition'] = $a_mount[$id]['partition']; $pconfig['fullname'] = $a_mount[$id]['fullname']; $pconfig['fstype'] = $a_mount[$id]['fstype']; $pconfig['sharename'] = $a_mount[$id]['sharename']; $pconfig['desc'] = $a_mount[$id]['desc']; } if (! empty($_POST)) { /* hash */ unset($error_bucket); /* simple error list */ unset($input_errors); $pconfig = $_POST; /* input validation */ $reqdfields = split(" ", "partitionno mdisk fstype"); $reqdfieldsn = split(",", "Partition,Mdisk,Fstype"); do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); if (($_POST['sharename'] && !is_validsharename($_POST['sharename']))) { $error_bucket[] = array("error" => gettext("The share name may only consist of the characters a-z, A-Z, 0-9, _ , -."), "field" => "sharename"); } if (($_POST['desc'] && !is_validdesc($_POST['desc']))) { $error_bucket[] = array("error" => gettext("The description name contain invalid characters."), "field" => "desc"); } $device=$_POST['mdisk'].$_POST['partitionno']; if ($device == $cfdevice ) { $error_bucket[] = array("error" => gettext("Can't mount the system partition 1, the DATA partition is the 2."), "field" => "mdisk"); } /* check for name conflicts */ foreach ($a_mount as $mount) { if (isset($id) && ($a_mount[$id]) && ($a_mount[$id] === $mount)) continue; /* Check for duplicate mount point */ if ($mount['mdisk'] == $_POST['mdisk']) { $error_bucket[] = array("error" => gettext("This disk/partition is allready configured."), "field" => "mdisk"); break; } if (($_POST['sharename']) && ($mount['sharename'] == $_POST['sharename'])) { $error_bucket[] = array("error" => gettext("Duplicate Share Name."), "field" => "sharename"); break; } } if (is_array($error_bucket)) foreach($error_bucket as $elem) $input_errors[] =& $elem["error"]; /* if this is an AJAX caller then handle via JSON */ if(isAjax() && is_array($error_bucket)) { input_errors2Ajax(NULL, $error_bucket); exit; } if (!$input_errors) { $mount = array(); $mount['mdisk'] = $_POST['mdisk']; $mount['partition'] = $_POST['partitionno']; $mount['fstype'] = $_POST['fstype']; $mount['desc'] = $_POST['desc']; /* if not sharename given, create one */ if (!$_POST['sharename']) $mount['sharename'] = "disk_{$_POST['mdisk']}_part_{$_POST['partitionno']}"; else $mount['sharename'] = $_POST['sharename']; // Generate fullname $mount['fullname'] = "{$mount['mdisk']}{$mount['partition']}"; if (isset($id) && $a_mount[$id]) $a_mount[$id] = $mount; else $a_mount[] = $mount; touch($d_mountdirty_path); write_config(); pfSenseHeader("disks_mount.php"); exit; } } include("head.inc"); /* put your custom HTML head content here */ /* using some of the $pfSenseHead function calls */ echo $pfSenseHead->getHTML(); ?> ">
  " />
: