/** * Create and initialize device * * @param name string Device Comment * @param dir string Device dir * @param size int Free space * @param priority int Priority * @return void */ public function srvCreateDevice($name, $dir, $size, $priority = 0) { if (!is_dir($dir)) { mkdir($dir) or die("Cannot mkdir('{$dir}')"); chmod($dir, 0775) or die("Cannot chmod('{$dir}')"); } M('Db')->exec("INSERT INTO rm_objectfs_device(info,priority,mount_path,total_size,used_size)\n\t\t\tVALUES(?,?,?,?,0)", $name, $priority, $dir, $size); $devId = M('Db')->lastInsertId(); $this->_mapper->devInit($devId); $this->_mapper->devSetPreferred($devId, $dir); }