|
From: <fd...@us...> - 2007-04-15 21:46:07
|
Revision: 3169
http://jnode.svn.sourceforge.net/jnode/?rev=3169&view=rev
Author: fduminy
Date: 2007-04-15 14:46:06 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
update of JPartition : refactor around stamps-mvc for better separation
of model, view and controller
Modified Paths:
--------------
trunk/fs/src/driver/org/jnode/driver/block/PartitionableBlockDeviceAPI.java
trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java
trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java
Modified: trunk/fs/src/driver/org/jnode/driver/block/PartitionableBlockDeviceAPI.java
===================================================================
--- trunk/fs/src/driver/org/jnode/driver/block/PartitionableBlockDeviceAPI.java 2007-04-15 21:43:33 UTC (rev 3168)
+++ trunk/fs/src/driver/org/jnode/driver/block/PartitionableBlockDeviceAPI.java 2007-04-15 21:46:06 UTC (rev 3169)
@@ -49,4 +49,6 @@
* @throws IOException
*/
public PartitionTable<PTE> getPartitionTable() throws IOException;
+
+ public String toString();
}
Modified: trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2007-04-15 21:43:33 UTC (rev 3168)
+++ trunk/fs/src/fs/org/jnode/partitions/command/FdiskCommand.java 2007-04-15 21:46:06 UTC (rev 3169)
@@ -146,7 +146,7 @@
}
final String deviceId = ARG_DEVICE.getValue(cmdLine);
- final PartitionHelper helper = new PartitionHelper(deviceId, dm);
+ final PartitionHelper helper = new PartitionHelper(deviceId);
// initMBR
if (isInitMBR) {
Modified: trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java 2007-04-15 21:43:33 UTC (rev 3168)
+++ trunk/fs/src/fs/org/jnode/partitions/command/PartitionHelper.java 2007-04-15 21:46:06 UTC (rev 3169)
@@ -3,9 +3,13 @@
import java.io.IOException;
import java.nio.ByteBuffer;
+import javax.naming.NameNotFoundException;
+
import org.jnode.driver.ApiNotFoundException;
+import org.jnode.driver.Device;
import org.jnode.driver.DeviceManager;
import org.jnode.driver.DeviceNotFoundException;
+import org.jnode.driver.DeviceUtils;
import org.jnode.driver.DriverException;
import org.jnode.driver.block.BlockDeviceAPI;
import org.jnode.driver.bus.ide.IDEConstants;
@@ -27,21 +31,26 @@
public static final boolean SECTORS = false;
private final IDEDevice current;
- private final DeviceManager dm;
private final BlockDeviceAPI api;
private ByteBuffer MBR;
private BootSector bs;
-
- public PartitionHelper(String deviceId, DeviceManager dm)
+
+ public PartitionHelper(String deviceId)
+ throws DeviceNotFoundException, ApiNotFoundException, IOException, NameNotFoundException
+ {
+ this((IDEDevice)DeviceUtils.getDeviceManager().getDevice(deviceId));
+ }
+
+ public PartitionHelper(IDEDevice device)
throws DeviceNotFoundException, ApiNotFoundException, IOException
{
- this.current = (IDEDevice)dm.getDevice(deviceId);
- this.dm = dm;
+ this.current = device;
this.api = current.getAPI(BlockDeviceAPI.class);
reloadMBR();
}
+
public void initMbr() throws DeviceNotFoundException, ApiNotFoundException,
IOException
@@ -78,15 +87,23 @@
// restart the device
try {
- dm.stop(current);
- dm.start(current);
+ DeviceManager devMan = DeviceUtils.getDeviceManager();
+ devMan.stop(current);
+ devMan.start(current);
} catch (DeviceNotFoundException e) {
e.printStackTrace();
} catch (DriverException e) {
e.printStackTrace();
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
}
}
+ public boolean hasValidMBR()
+ {
+ return IBMPartitionTable.containsPartitionTable(MBR.array());
+ }
+
private void reloadMBR() throws IOException
{
this.MBR = ByteBuffer.allocate(IDEConstants.SECTOR_SIZE);
@@ -96,7 +113,7 @@
private void checkMBR() throws IOException
{
- if (!IBMPartitionTable.containsPartitionTable(MBR.array()))
+ if (!hasValidMBR())
throw new IOException("This device doesn't contain a valid MBR, use --initmbr.");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|