Ejemplo n.º 1
0
function mke2fs($dev, $label, $maxfds = 0)
{
    $debug = $GLOBALS["VERBOSE"];
    $label_cmd = null;
    $maxfds_cmd = null;
    $label = strtolower(str_replace(" ", "_", $label));
    $label = trim(substr($label, 0, 16));
    $unix = new unix();
    $mkfs_ext4 = $unix->find_program("mkfs.ext4");
    if ($maxfds > 0) {
        $maxfds_cmd = " -I 128 -N {$maxfds}";
    }
    if (!is_file($mkfs_ext4)) {
        $mkfs_ext4 = $unix->find_program("mkfs.ext3");
    }
    if (!$unix->IsExt4()) {
        $mkfs_ext4 = $unix->find_program("mkfs.ext3");
    }
    if ($label != null) {
        $label_cmd = " -L {$label}";
    }
    echo "Starting......: " . date("H:i:s") . " {$dev} formatting...\n";
    $cmd = "{$mkfs_ext4} {$label_cmd}{$maxfds_cmd} -q {$dev} 2>&1";
    exec($cmd, $results);
    if ($debug) {
        echo "mke2fs({$dev}) -> {$cmd} " . count($results) . " rows\n";
    }
    if ($debug) {
        while (list($num, $line) = each($results)) {
            echo "mke2fs() -> {$line}\n";
        }
    }
    if (ifFileSystem($dev)) {
        return true;
    }
}
Ejemplo n.º 2
0
function mke2fs($dev)
{
    $debug = $GLOBALS["VERBOSE"];
    $unix = new unix();
    $mkfs_ext4 = $unix->find_program("mkfs.ext4");
    if (!is_file($mkfs_ext4)) {
        $mkfs_ext4 = $unix->find_program("mkfs.ext3");
    }
    if (!$unix->IsExt4()) {
        $mkfs_ext4 = $unix->find_program("mkfs.ext3");
    }
    echo "Starting......: {$dev} formatting...\n";
    $cmd = "{$mkfs_ext4} -q {$dev} 2>&1";
    exec($cmd, $results);
    if ($debug) {
        echo "mke2fs({$dev}) -> {$cmd} " . count($results) . " rows\n";
    }
    if ($debug) {
        while (list($num, $line) = each($results)) {
            echo "mke2fs() -> {$line}\n";
        }
    }
    if (ifFileSystem($dev)) {
        return true;
    }
}