|
From: <cr...@us...> - 2008-06-07 03:48:56
|
Revision: 4207
http://jnode.svn.sourceforge.net/jnode/?rev=4207&view=rev
Author: crawley
Date: 2008-06-06 20:48:55 -0700 (Fri, 06 Jun 2008)
Log Message:
-----------
Style fixes
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/fat/command/FormatFatCommand.java
trunk/fs/src/fs/org/jnode/fs/fat/test/FatTest.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDevice.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSFile.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemFormatter.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogIndexNode.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogNodeId.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogThread.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentIndexNode.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentKey.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentLeafNode.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/AbstractKey.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/BTHeaderRecord.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/IndexNode.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/IndexRecord.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/Key.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafNode.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/LeafRecord.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/Node.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/NodeDescriptor.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/tree/RecordData.java
trunk/fs/src/fs/org/jnode/fs/initrd/InitRamdisk.java
trunk/fs/src/fs/org/jnode/fs/iso9660/Descriptor.java
trunk/fs/src/fs/org/jnode/fs/iso9660/EntryRecord.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Constants.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Directory.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660File.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Volume.java
trunk/fs/src/fs/org/jnode/fs/iso9660/PrimaryVolumeDescriptor.java
trunk/fs/src/fs/org/jnode/fs/iso9660/SupplementaryVolumeDescriptor.java
trunk/fs/src/fs/org/jnode/fs/iso9660/VolumeDescriptor.java
Modified: trunk/fs/src/fs/org/jnode/fs/fat/command/FormatFatCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/command/FormatFatCommand.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/fat/command/FormatFatCommand.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -38,14 +38,14 @@
* @author cr...@jn...
*/
public class FormatFatCommand extends AbstractFormatCommand<FatFileSystem> {
-
+
private static class FatTypeArgument extends MappedArgument<FatType> {
private static final Map<String, FatType> MAP = new HashMap<String, FatType>();
static {
MAP.put("fat12", FatType.FAT12);
MAP.put("fat16", FatType.FAT16);
}
-
+
public FatTypeArgument() {
super("fsType", Argument.MANDATORY, new FatType[0], MAP,
true, "the kind of FAT filesystem to create");
@@ -55,7 +55,7 @@
return "fat type";
}
}
-
+
private final FatTypeArgument ARG_FS_TYPE = new FatTypeArgument();
public FormatFatCommand() {
@@ -64,11 +64,11 @@
}
public static void main(String[] args) throws Exception {
- new FormatFatCommand().execute(args);
+ new FormatFatCommand().execute(args);
}
- @Override
- protected FatFileSystemFormatter getFormatter() {
+ @Override
+ protected FatFileSystemFormatter getFormatter() {
return new FatFileSystemFormatter(ARG_FS_TYPE.getValue());
- }
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/test/FatTest.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/test/FatTest.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/fat/test/FatTest.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -28,132 +28,129 @@
import java.net.URLConnection;
import java.nio.ByteBuffer;
+import javax.naming.NameNotFoundException;
+
import org.jnode.driver.block.FileDevice;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSFile;
import org.jnode.fs.FileSystemException;
+import org.jnode.fs.fat.BootSector;
+import org.jnode.fs.fat.FatDirectory;
+import org.jnode.fs.fat.FatFileSystem;
+import org.jnode.fs.fat.FatFileSystemType;
+import org.jnode.fs.fat.GrubFatFormatter;
import org.jnode.fs.service.FileSystemService;
-import org.jnode.fs.fat.*;
-import org.jnode.util.FileUtils;
import org.jnode.naming.InitialNaming;
-import javax.naming.NameNotFoundException;
+import org.jnode.util.FileUtils;
/**
- * <description>
- *
* @author epr
*/
public class FatTest {
+ public static void main(String[] args) throws Exception {
- public static void main(String[] args) throws Exception {
+ PrintWriter out = new PrintWriter(System.out, true);
- PrintWriter out = new PrintWriter(System.out, true);
+ /*
+ * String fn; if (args.length == 0) { fn = "lib/floppy.img"; } else { fn =
+ * args[0]; } printInfo(new File(fn), out);
+ *
+ * System.out.println("\nGenerating new floppy");
+ */
- /*String fn;
- if (args.length == 0) {
- fn = "lib/floppy.img";
- } else {
- fn = args[0];
- }
- printInfo(new File(fn), out);
-
- System.out.println("\nGenerating new floppy");*/
+ File f = new File("build/testfloppy.img");
- File f = new File("build/testfloppy.img");
+ createFloppy(f);
+ printInfo(f, out);
+ }
- createFloppy(f);
- printInfo(f, out);
- }
-
- public static void printInfo(File file, PrintWriter out)
- throws IOException, FileSystemException {
- FileDevice fd = new FileDevice(file, "r");
+ public static void printInfo(File file, PrintWriter out)
+ throws IOException, FileSystemException {
+ FileDevice fd = new FileDevice(file, "r");
try {
- final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
- FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
- FatFileSystem fs = new FatFileSystem(fd, false, type);
- try {
- BootSector bs = fs.getBootSector();
- bs.read(fd);
+ final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
+ FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
+ FatFileSystem fs = new FatFileSystem(fd, false, type);
+ try {
+ BootSector bs = fs.getBootSector();
+ bs.read(fd);
- out.println("OEM name " + bs.getOemName());
- out.println("bytes/sector " + bs.getBytesPerSector());
- out.println("sectors/cluster " + bs.getSectorsPerCluster());
- out.println("#reserved sectors " + bs.getNrReservedSectors());
- out.println("#fats " + bs.getNrFats());
- out.println("#rootdir entries " + bs.getNrRootDirEntries());
- out.println("#logical sectors " + bs.getNrLogicalSectors());
- out.println(
- "Medium descriptor 0x"
- + Integer.toHexString(bs.getMediumDescriptor()));
- out.println("sectors/fat " + bs.getSectorsPerFat());
- out.println("sectors/track " + bs.getSectorsPerTrack());
- out.println("#heads " + bs.getNrHeads());
- out.println("#hidden sectors " + bs.getNrHiddenSectors());
+ out.println("OEM name " + bs.getOemName());
+ out.println("bytes/sector " + bs.getBytesPerSector());
+ out.println("sectors/cluster " + bs.getSectorsPerCluster());
+ out.println("#reserved sectors " + bs.getNrReservedSectors());
+ out.println("#fats " + bs.getNrFats());
+ out.println("#rootdir entries " + bs.getNrRootDirEntries());
+ out.println("#logical sectors " + bs.getNrLogicalSectors());
+ out.println("Medium descriptor 0x" + Integer.toHexString(bs.getMediumDescriptor()));
+ out.println("sectors/fat " + bs.getSectorsPerFat());
+ out.println("sectors/track " + bs.getSectorsPerTrack());
+ out.println("#heads " + bs.getNrHeads());
+ out.println("#hidden sectors " + bs.getNrHiddenSectors());
- fs.getFat().printTo(out);
- fs.getRootDir().printTo(out);
+ fs.getFat().printTo(out);
+ fs.getRootDir().printTo(out);
- try {
- FatDirectory dir = (FatDirectory) fs.getRootEntry().getDirectory().getEntry("AAP").getDirectory();
- dir.printTo(out);
- } catch (FileNotFoundException ex) {
- out.println("No AAP directory");
- }
+ try {
+ FatDirectory dir =
+ (FatDirectory) fs.getRootEntry().getDirectory().getEntry("AAP")
+ .getDirectory();
+ dir.printTo(out);
+ } catch (FileNotFoundException ex) {
+ out.println("No AAP directory");
+ }
- try {
- FatDirectory dir = (FatDirectory) fs.getRootEntry().getDirectory().getEntry("boot").getDirectory();
- dir.printTo(out);
- } catch (FileNotFoundException ex) {
- out.println("No boot directory");
- }
-
- } finally {
- //fd.stop();
- fd.close();
- }
- }catch (NameNotFoundException e){
+ try {
+ FatDirectory dir =
+ (FatDirectory) fs.getRootEntry().getDirectory().getEntry("boot")
+ .getDirectory();
+ dir.printTo(out);
+ } catch (FileNotFoundException ex) {
+ out.println("No boot directory");
+ }
+
+ } finally {
+ // fd.stop();
+ fd.close();
+ }
+ } catch (NameNotFoundException e) {
throw new FileSystemException(e);
}
}
- public static void createFloppy(File f) throws Exception {
+ public static void createFloppy(File f) throws Exception {
- GrubFatFormatter ff = new GrubFatFormatter(0, null, null);
- FileDevice newFd = new FileDevice(f, "rw");
- newFd.setLength(1440 * 1024);
- ff.format(newFd);
+ GrubFatFormatter ff = new GrubFatFormatter(0, null, null);
+ FileDevice newFd = new FileDevice(f, "rw");
+ newFd.setLength(1440 * 1024);
+ ff.format(newFd);
- //newFd.start();
+ // newFd.start();
final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
FatFileSystem fs = new FatFileSystem(newFd, false, type);
- FSDirectory dir = fs.getRootEntry().getDirectory();
- FSDirectory bDir = dir.addDirectory("boot").getDirectory();
- FSDirectory bgDir = bDir.addDirectory("grub").getDirectory();
+ FSDirectory dir = fs.getRootEntry().getDirectory();
+ FSDirectory bDir = dir.addDirectory("boot").getDirectory();
+ FSDirectory bgDir = bDir.addDirectory("grub").getDirectory();
- URLConnection urlConn =
- FatTest
- .class
- .getClassLoader()
- .getResource("menu.lst")
- .openConnection();
- //byte[] buf = new byte[urlConn.getContentLength()];
- ByteBuffer buf = ByteBuffer.allocate(urlConn.getContentLength());
- FileUtils.copy(urlConn.getInputStream(), buf.array());
+ URLConnection urlConn =
+ FatTest.class.getClassLoader().getResource("menu.lst").openConnection();
+ //byte[] buf = new byte[urlConn.getContentLength()];
+ ByteBuffer buf = ByteBuffer.allocate(urlConn.getContentLength());
+ FileUtils.copy(urlConn.getInputStream(), buf.array());
- final FSFile fh1 = dir.addFile("test.lst").getFile();
- fh1.setLength(urlConn.getContentLength());
- fh1.write(0, buf);
+ final FSFile fh1 = dir.addFile("test.lst").getFile();
+ fh1.setLength(urlConn.getContentLength());
+ fh1.write(0, buf);
- final FSFile fh2 = bgDir.addFile("menu.lst").getFile();
- fh2.setLength(urlConn.getContentLength());
- fh2.write(0, buf);
+ final FSFile fh2 = bgDir.addFile("menu.lst").getFile();
+ fh2.setLength(urlConn.getContentLength());
+ fh2.write(0, buf);
- fs.flush();
-
- //newFd.stop();
- newFd.close();
- }
+ fs.flush();
+
+ //newFd.stop();
+ newFd.close();
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDevice.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDevice.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDevice.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -22,7 +22,6 @@
package org.jnode.fs.ftpfs;
import org.jnode.driver.Device;
-import org.jnode.driver.Bus;
/**
* @author Levente S\u00e1ntha
@@ -33,7 +32,7 @@
private String password;
public FTPFSDevice(String host, String user, String password) {
- super(null, "ftp-(" + host +"," + user + ")");
+ super(null, "ftp-(" + host + "," + user + ")");
this.host = host;
this.user = user;
this.password = password;
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -66,7 +66,7 @@
if (entries == null) {
entries = new HashMap<String, FTPFSEntry>();
FTPFile[] ftpFiles = null;
- synchronized(fileSystem){
+ synchronized (fileSystem) {
ftpFiles = fileSystem.dirDetails(path());
}
for (FTPFile f : ftpFiles) {
@@ -81,11 +81,11 @@
}
}
- String path() throws IOException{
+ String path() throws IOException {
StringBuilder p = new StringBuilder("/");
FTPFSDirectory root = fileSystem.getRootEntry();
FTPFSDirectory d = this;
- while (d != root){
+ while (d != root) {
p.insert(0, d.getName());
p.insert(0, '/');
d = d.parent;
@@ -100,6 +100,7 @@
* @throws java.io.IOException
*/
public FTPFSEntry addDirectory(String name) throws IOException {
+ // TODO implement this
return null;
}
@@ -110,6 +111,7 @@
* @throws java.io.IOException
*/
public FTPFSEntry addFile(String name) throws IOException {
+ // TODO implement this
return null;
}
@@ -119,7 +121,7 @@
* @throws java.io.IOException
*/
public void flush() throws IOException {
-
+ // TODO implement me
}
/**
@@ -129,6 +131,6 @@
* @throws java.io.IOException
*/
public void remove(String name) throws IOException {
-
+ // TODO implement this
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSFile.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSFile.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -59,8 +59,8 @@
*/
public synchronized void read(long fileOffset, ByteBuffer dest) throws IOException {
try {
- if(data == null){
- synchronized(fileSystem) {
+ if (data == null) {
+ synchronized (fileSystem) {
fileSystem.chdir(parent.path());
data = fileSystem.get(getName());
//InputStream in = fileSystem.retrieveFileStream(getName());
@@ -71,11 +71,11 @@
}
}
int len = dest.remaining();
- len = Math.min(len,(int) (data.length - fileOffset));
- if(len > 0){
+ len = Math.min(len, (int) (data.length - fileOffset));
+ if (len > 0) {
dest.put(data, (int) fileOffset, len);
}
- }catch(Exception e){
+ } catch (Exception e) {
throw new IOException("Read error");
}
}
@@ -86,7 +86,7 @@
* @throws java.io.IOException
*/
public void flush() throws IOException {
-
+ // TODO implement me
}
/**
@@ -96,7 +96,7 @@
* @throws java.io.IOException
*/
public void setLength(long length) throws IOException {
-
+ // TODO implement me
}
/**
@@ -109,6 +109,6 @@
* @throws java.io.IOException
*/
public void write(long fileOffset, ByteBuffer src) throws IOException {
-
+ // TODO implement me
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -21,16 +21,16 @@
package org.jnode.fs.ftpfs;
-import org.jnode.fs.FileSystem;
-import org.jnode.driver.DeviceListener;
-import org.jnode.driver.Device;
-
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.text.ParseException;
import java.util.Date;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
+import org.jnode.driver.Device;
+import org.jnode.driver.DeviceListener;
+import org.jnode.fs.FileSystem;
+
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.net.ftp.FTPFile;
@@ -44,86 +44,83 @@
private FTPFSDirectory root;
private boolean closed;
private Thread thread;
- final private FTPClient client;
+ private final FTPClient client;
private final FTPFileSystemType type;
-
FTPFileSystem(final FTPFSDevice device, final FTPFileSystemType type) {
this.type = type;
this.client = new FTPClient();
this.device = device;
device.addListener(new DeviceListener() {
public void deviceStarted(Device device) {
- //empty
+ // empty
}
public void deviceStop(Device device) {
try {
close();
- } catch(IOException x){
+ } catch (IOException x) {
+ // FIXME - bad ... use a logger.
x.printStackTrace();
}
}
});
- try{
-
- client.setRemoteHost(device.getHost());
- client.setTimeout(300000);
- AccessController.doPrivileged(
- new PrivilegedAction(){
+ try {
+ client.setRemoteHost(device.getHost());
+ client.setTimeout(300000);
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
- try{
+ try {
client.connect();
return null;
- }catch(Exception e){
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
});
- client.login(device.getUser(),device.getPassword());
- thread = new Thread(new Runnable(){
+ client.login(device.getUser(), device.getPassword());
+ thread = new Thread(new Runnable() {
public void run() {
- try{
- while(!isClosed()){
+ try {
+ while (!isClosed()) {
try {
Thread.sleep(100000);
nop();
- }catch(InterruptedException x){
- //ignore
+ } catch (InterruptedException x) {
+ // ignore
}
}
- } catch(Exception x){
+ } catch (Exception x) {
x.printStackTrace();
}
}
- },"ftpfs_keepalive");
+ }, "ftpfs_keepalive");
thread.start();
FTPFile f = new FTPFile("/", "/", 0, true, new Date(0));
-// FTPFile f = new FTPFile();
-// f.setName(printWorkingDirectory());
+ // FTPFile f = new FTPFile();
+ // f.setName(printWorkingDirectory());
root = new FTPFSDirectory(this, f);
closed = false;
- }catch(Exception e){
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
- final public FTPFileSystemType getType() {
- return type;
- }
+ public final FTPFileSystemType getType() {
+ return type;
+ }
- private synchronized void nop() throws Exception{
- client.dir(root.path());
+ private synchronized void nop() throws Exception {
+ client.dir(root.path());
}
-
/**
* Close this filesystem. After a close, all invocations of method of this
* filesystem or objects created by this filesystem will throw an
* IOException.
- *
+ *
* @throws java.io.IOException
*/
public synchronized void close() throws IOException {
@@ -131,7 +128,7 @@
closed = true;
thread = null;
client.quit();
- } catch(Exception e){
+ } catch (Exception e) {
throw new IOException("Close error");
}
}
@@ -165,31 +162,30 @@
return true;
}
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
- public long getFreeSpace() {
- // TODO implement me
- return 0;
- }
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
- public long getTotalSpace() {
- // TODO implement me
- return 0;
- }
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
- public long getUsableSpace() {
- // TODO implement me
- return 0;
- }
+ FTPFile[] dirDetails(String path) throws IOException, FTPException, ParseException {
+ return client.dirDetails(path);
+ }
- FTPFile[] dirDetails(String path) throws IOException, FTPException, ParseException {
- return client.dirDetails(path);
- }
+ void chdir(String path) throws IOException, FTPException {
+ client.chdir(path);
+ }
- void chdir(String path) throws IOException, FTPException {
- client.chdir(path);
- }
-
- byte[] get(String name) throws IOException, FTPException {
- return client.get(name);
- }
+ byte[] get(String name) throws IOException, FTPException {
+ return client.get(name);
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -24,7 +24,6 @@
import org.jnode.driver.Device;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.fs.util.FSUtils;
/**
* @author Levente S\u00e1ntha
@@ -34,7 +33,7 @@
/**
* Create a filesystem from a given device.
- *
+ *
* @param device
* @param readOnly
*/
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -21,14 +21,19 @@
package org.jnode.fs.ftpfs.command;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+import javax.naming.NameNotFoundException;
+
import org.apache.log4j.Logger;
import org.jnode.driver.DeviceAlreadyRegisteredException;
import org.jnode.driver.DeviceManager;
import org.jnode.driver.DeviceUtils;
import org.jnode.driver.DriverException;
-import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
-import org.jnode.fs.FileSystemType;
import org.jnode.fs.ftpfs.FTPFSDevice;
import org.jnode.fs.ftpfs.FTPFSDriver;
import org.jnode.fs.ftpfs.FTPFileSystem;
@@ -37,15 +42,11 @@
import org.jnode.naming.InitialNaming;
import org.jnode.shell.AbstractCommand;
import org.jnode.shell.CommandLine;
-import org.jnode.shell.syntax.*;
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.FileArgument;
+import org.jnode.shell.syntax.HostNameArgument;
+import org.jnode.shell.syntax.StringArgument;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-import javax.naming.NameNotFoundException;
-
/**
* @author Levente S\u00e1ntha
*/
@@ -73,8 +74,8 @@
public void execute(CommandLine commandLine, InputStream in,
PrintStream out, PrintStream err)
- throws DriverException, NameNotFoundException, DeviceAlreadyRegisteredException,
- FileSystemException, IOException {
+ throws DriverException, NameNotFoundException, DeviceAlreadyRegisteredException,
+ FileSystemException, IOException {
final File mountPoint = MOUNTPOINT_ARG.getValue();
final String host = HOST_ARG.getValue();
final String user = USERNAME_ARG.getValue();
@@ -93,8 +94,7 @@
fss.registerFileSystem(fs);
fss.mount(mountPoint.getAbsolutePath(), fs, null);
ok = true;
- }
- finally {
+ } finally {
if (!ok) {
try {
// If we failed, try to undo the changes that we managed to make
@@ -102,8 +102,7 @@
fss.unregisterFileSystem(dev);
}
dm.unregister(dev);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
Logger log = Logger.getLogger(FTPMountCommand.class);
log.fatal("Cannot undo failed mount attempt", ex);
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -13,53 +13,55 @@
import org.jnode.fs.spi.FSEntryTable;
public class HFSPlusDirectory extends AbstractFSDirectory {
-
- private final Logger log = Logger.getLogger(getClass());
+ private final Logger log = Logger.getLogger(getClass());
- private LeafRecord record;
-
- private CatalogFolder folder;
-
- public HFSPlusDirectory(final HFSPlusEntry e){
- super((HfsPlusFileSystem)e.getFileSystem());
- this.record = e.getRecord();
- this.folder = new CatalogFolder(record.getRecordData());
- log.debug("Associated record:" + record.toString());
- if(record.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER){
- log.debug("Associated folder : " + folder.toString());
- }
- }
-
- @Override
- protected final FSEntry createDirectoryEntry(final String name) throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
+ private LeafRecord record;
- @Override
- protected final FSEntry createFileEntry(final String name) throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
+ private CatalogFolder folder;
- @Override
- protected final FSEntryTable readEntries() throws IOException {
- List<FSEntry> pathList = new LinkedList<FSEntry>();
- LeafRecord[] records = ((HfsPlusFileSystem)getFileSystem()).getCatalog().getRecords(folder.getFolderId());
- for(LeafRecord rec : records) {
- if(rec.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER || rec.getType() == HfsPlusConstants.RECORD_TYPE_FILE){
- String name = ((CatalogKey)rec.getKey()).getNodeName().getUnicodeString();
- HFSPlusEntry e = new HFSPlusEntry((HfsPlusFileSystem)getFileSystem(),null,null,name,rec);
- pathList.add(e);
- }
- }
- return new FSEntryTable(((HfsPlusFileSystem)getFileSystem()),pathList);
- }
+ public HFSPlusDirectory(final HFSPlusEntry e) {
+ super((HfsPlusFileSystem) e.getFileSystem());
+ this.record = e.getRecord();
+ this.folder = new CatalogFolder(record.getRecordData());
+ log.debug("Associated record:" + record.toString());
+ if (record.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER) {
+ log.debug("Associated folder : " + folder.toString());
+ }
+ }
- @Override
- protected void writeEntries(final FSEntryTable entries) throws IOException {
- // TODO Auto-generated method stub
+ @Override
+ protected final FSEntry createDirectoryEntry(final String name) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
- }
+ @Override
+ protected final FSEntry createFileEntry(final String name) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ protected final FSEntryTable readEntries() throws IOException {
+ List<FSEntry> pathList = new LinkedList<FSEntry>();
+ LeafRecord[] records =
+ ((HfsPlusFileSystem) getFileSystem()).getCatalog().getRecords(folder.getFolderId());
+ for (LeafRecord rec : records) {
+ if (rec.getType() == HfsPlusConstants.RECORD_TYPE_FOLDER ||
+ rec.getType() == HfsPlusConstants.RECORD_TYPE_FILE) {
+ String name = ((CatalogKey) rec.getKey()).getNodeName().getUnicodeString();
+ HFSPlusEntry e =
+ new HFSPlusEntry((HfsPlusFileSystem) getFileSystem(), null, null, name, rec);
+ pathList.add(e);
+ }
+ }
+ return new FSEntryTable(((HfsPlusFileSystem) getFileSystem()), pathList);
+ }
+
+ @Override
+ protected void writeEntries(final FSEntryTable entries) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -4,30 +4,30 @@
import org.jnode.fs.spi.AbstractFSEntry;
import org.jnode.fs.spi.FSEntryTable;
-public class HFSPlusEntry extends AbstractFSEntry{
+public class HFSPlusEntry extends AbstractFSEntry {
- private LeafRecord record;
-
- public HFSPlusEntry(final HfsPlusFileSystem fs, final FSEntryTable table,
- final HFSPlusDirectory parent, final String name, final LeafRecord record) {
- super(fs, table, parent, name, getFSEntryType(name, record));
- this.record = record;
- }
+ private LeafRecord record;
- private static int getFSEntryType(final String name, final LeafRecord record) {
- int mode = record.getType();
- if("/".equals(name)) {
- return AbstractFSEntry.ROOT_ENTRY;
- } else if(mode == HfsPlusConstants.RECORD_TYPE_FOLDER) {
- return AbstractFSEntry.DIR_ENTRY;
- } else if(mode == HfsPlusConstants.RECORD_TYPE_FILE) {
- return AbstractFSEntry.FILE_ENTRY;
- } else {
- return AbstractFSEntry.OTHER_ENTRY;
- }
- }
+ public HFSPlusEntry(final HfsPlusFileSystem fs, final FSEntryTable table,
+ final HFSPlusDirectory parent, final String name, final LeafRecord record) {
+ super(fs, table, parent, name, getFSEntryType(name, record));
+ this.record = record;
+ }
- public final LeafRecord getRecord() {
- return record;
- }
+ private static int getFSEntryType(final String name, final LeafRecord record) {
+ int mode = record.getType();
+ if ("/".equals(name)) {
+ return AbstractFSEntry.ROOT_ENTRY;
+ } else if (mode == HfsPlusConstants.RECORD_TYPE_FOLDER) {
+ return AbstractFSEntry.DIR_ENTRY;
+ } else if (mode == HfsPlusConstants.RECORD_TYPE_FILE) {
+ return AbstractFSEntry.FILE_ENTRY;
+ } else {
+ return AbstractFSEntry.OTHER_ENTRY;
+ }
+ }
+
+ public final LeafRecord getRecord() {
+ return record;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -9,47 +9,46 @@
import org.jnode.fs.spi.AbstractFSFile;
public class HFSPlusFile extends AbstractFSFile {
+ private LeafRecord record;
+ private CatalogFile file;
- private LeafRecord record;
- private CatalogFile file;
-
- public HFSPlusFile(final HFSPlusEntry e){
- super((HfsPlusFileSystem)e.getFileSystem());
- this.record = e.getRecord();
- this.file = new CatalogFile(record.getRecordData());
- }
-
- @Override
- public void flush() throws IOException {
- // TODO Auto-generated method stub
+ public HFSPlusFile(final HFSPlusEntry e) {
+ super((HfsPlusFileSystem) e.getFileSystem());
+ this.record = e.getRecord();
+ this.file = new CatalogFile(record.getRecordData());
+ }
- }
+ @Override
+ public void flush() throws IOException {
+ // TODO Auto-generated method stub
- @Override
- public final long getLength() {
- return file.getDataFork().getTotalSize();
- }
+ }
- @Override
- public final void read(final long fileOffset, final ByteBuffer dest) throws IOException {
- HfsPlusFileSystem fs = (HfsPlusFileSystem)getFileSystem();
- for(ExtentDescriptor d: file.getDataFork().getExtents()){
- if(d.getStartBlock() != 0 && d.getBlockCount() != 0){
- long firstOffset = d.getStartBlock()*fs.getVolumeHeader().getBlockSize();
- fs.getApi().read(firstOffset, dest);
- }
- }
- }
+ @Override
+ public final long getLength() {
+ return file.getDataFork().getTotalSize();
+ }
- @Override
- public void write(final long fileOffset, final ByteBuffer src) throws IOException {
- // TODO Auto-generated method stub
+ @Override
+ public final void read(final long fileOffset, final ByteBuffer dest) throws IOException {
+ HfsPlusFileSystem fs = (HfsPlusFileSystem) getFileSystem();
+ for (ExtentDescriptor d : file.getDataFork().getExtents()) {
+ if (d.getStartBlock() != 0 && d.getBlockCount() != 0) {
+ long firstOffset = d.getStartBlock() * fs.getVolumeHeader().getBlockSize();
+ fs.getApi().read(firstOffset, dest);
+ }
+ }
+ }
- }
+ @Override
+ public void write(final long fileOffset, final ByteBuffer src) throws IOException {
+ // TODO Auto-generated method stub
- public void setLength(final long length) throws IOException {
- // TODO Auto-generated method stub
+ }
- }
+ public void setLength(final long length) throws IOException {
+ // TODO Auto-generated method stub
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -4,45 +4,46 @@
import org.jnode.util.BigEndian;
public class HFSPlusForkData {
- public static final int FORK_DATA_LENGTH = 80;
- private static final int EXTENT_OFFSET = 16;
-
- private byte[] data;
-
- public HFSPlusForkData(final byte[] src, final int offset){
- data = new byte[FORK_DATA_LENGTH];
- System.arraycopy(src, offset, data, 0, FORK_DATA_LENGTH);
- }
-
- public final long getTotalSize(){
- return BigEndian.getInt64(data, 0);
- }
-
- public final int getClumpSize(){
- return BigEndian.getInt32(data, 8);
- }
-
- public final int getTotalBlocks(){
- return BigEndian.getInt32(data, 12);
- }
+ public static final int FORK_DATA_LENGTH = 80;
+ private static final int EXTENT_OFFSET = 16;
- public final ExtentDescriptor[] getExtents(){
- ExtentDescriptor[] list = new ExtentDescriptor[8];
- for (int i = 0; i < 8; i++) {
- list[i] = new ExtentDescriptor(data, EXTENT_OFFSET+(i*ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH));
- }
- return list;
- }
-
- public final String toString(){
- StringBuffer s = new StringBuffer();
- s.append("Total size : " ).append(getTotalSize()).append("\n");
- s.append("Clump size : " ).append(getClumpSize()).append("\n");
- s.append("Total Blocks : " ).append(getTotalBlocks()).append("\n");
- ExtentDescriptor[] list = getExtents();
- for (int i = 0; i < list.length; i++) {
- s.append("Extent[" + i + "]: " + list[i].toString());
- }
- return s.toString();
- }
+ private byte[] data;
+
+ public HFSPlusForkData(final byte[] src, final int offset) {
+ data = new byte[FORK_DATA_LENGTH];
+ System.arraycopy(src, offset, data, 0, FORK_DATA_LENGTH);
+ }
+
+ public final long getTotalSize() {
+ return BigEndian.getInt64(data, 0);
+ }
+
+ public final int getClumpSize() {
+ return BigEndian.getInt32(data, 8);
+ }
+
+ public final int getTotalBlocks() {
+ return BigEndian.getInt32(data, 12);
+ }
+
+ public final ExtentDescriptor[] getExtents() {
+ ExtentDescriptor[] list = new ExtentDescriptor[8];
+ for (int i = 0; i < 8; i++) {
+ list[i] = new ExtentDescriptor(
+ data, EXTENT_OFFSET + (i * ExtentDescriptor.EXTENT_DESCRIPTOR_LENGTH));
+ }
+ return list;
+ }
+
+ public final String toString() {
+ StringBuffer s = new StringBuffer();
+ s.append("Total size : ").append(getTotalSize()).append("\n");
+ s.append("Clump size : ").append(getClumpSize()).append("\n");
+ s.append("Total Blocks : ").append(getTotalBlocks()).append("\n");
+ ExtentDescriptor[] list = getExtents();
+ for (int i = 0; i < list.length; i++) {
+ s.append("Extent[" + i + "]: " + list[i].toString());
+ }
+ return s.toString();
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -3,18 +3,17 @@
import org.jnode.fs.FSObject;
public class HFSPlusObject implements FSObject {
+ private HfsPlusFileSystem fs;
- private HfsPlusFileSystem fs;
-
- public HFSPlusObject(final HfsPlusFileSystem fileSystem) {
- this.fs = fileSystem;
- }
+ public HFSPlusObject(final HfsPlusFileSystem fileSystem) {
+ this.fs = fileSystem;
+ }
- public final HfsPlusFileSystem getFileSystem() {
- return fs;
- }
+ public final HfsPlusFileSystem getFileSystem() {
+ return fs;
+ }
- public final boolean isValid() {
- return false;
- }
+ public final boolean isValid() {
+ return false;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -4,30 +4,30 @@
public class HFSUnicodeString {
- /** Length of string in characters. */
- private int length;
-
- private String string;
-
- public HFSUnicodeString(final byte[] src, final int offset){
- byte[] data = new byte[2];
- System.arraycopy(src, offset, data, 0, 2);
- length = BigEndian.getInt16(data, 0);
- data = new byte[length*2];
- System.arraycopy(src, offset+2, data, 0, length*2);
- char[] result = new char[length];
- for(int i = 0; i < length; ++i){
- result[i] = BigEndian.getChar(data, i*2);
- }
- string = new String(result);
- }
+ /** Length of string in characters. */
+ private int length;
- public final int getLength(){
- return length;
- }
-
- public final String getUnicodeString(){
- return string;
- }
-
+ private String string;
+
+ public HFSUnicodeString(final byte[] src, final int offset) {
+ byte[] data = new byte[2];
+ System.arraycopy(src, offset, data, 0, 2);
+ length = BigEndian.getInt16(data, 0);
+ data = new byte[length * 2];
+ System.arraycopy(src, offset + 2, data, 0, length * 2);
+ char[] result = new char[length];
+ for (int i = 0; i < length; ++i) {
+ result[i] = BigEndian.getChar(data, i * 2);
+ }
+ string = new String(result);
+ }
+
+ public final int getLength() {
+ return length;
+ }
+
+ public final String getUnicodeString() {
+ return string;
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -4,24 +4,26 @@
import java.util.Date;
public class HFSUtils {
- public static final long DIFF_TO_JAVA_DATE_IN_MILLIS = 2082844800000L;
- /**
- *
- * @param time time in second since midnight, January 1, 1904, GMT.
- * @return
- */
- public static Date decodeDate(final int time){
- return new Date(time * 1000 - DIFF_TO_JAVA_DATE_IN_MILLIS);
- }
- /**
- *
- * @param time
- * @param dateFormat
- * @return
- */
- public static String printDate(final int time, final String dateFormat){
- Date date = decodeDate(time);
- SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
- return sdf.format(date.getTime());
- }
+ public static final long DIFF_TO_JAVA_DATE_IN_MILLIS = 2082844800000L;
+
+ /**
+ *
+ * @param time time in second since midnight, January 1, 1904, GMT.
+ * @return
+ */
+ public static Date decodeDate(final int time) {
+ return new Date(time * 1000 - DIFF_TO_JAVA_DATE_IN_MILLIS);
+ }
+
+ /**
+ *
+ * @param time
+ * @param dateFormat
+ * @return
+ */
+ public static String printDate(final int time, final String dateFormat) {
+ Date date = decodeDate(time);
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
+ return sdf.format(date.getTime());
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -1,34 +1,35 @@
package org.jnode.fs.hfsplus;
public class HfsPlusConstants {
+ public static final int HFSPLUS_SUPER_MAGIC = 0x482b;
- public static final int HFSPLUS_SUPER_MAGIC = 0x482b;
-
- public static final int HFSPLUS_MIN_VERSION = 4; /* HFS+ */
- public static final int HFSPLUS_CURRENT_VERSION = 5; /* HFSX */
- /* HFS+ volume attributes */
- public static final int HFSPLUS_VOL_UNMNT_BIT = 8;
- public static final int HFSPLUS_VOL_SPARE_BLK_BIT = 9;
- public static final int HFSPLUS_VOL_NOCACHE_BIT = 10;
- public static final int HFSPLUS_VOL_INCNSTNT_BIT = 11;
- public static final int HFSPLUS_VOL_NODEID_REUSED_BIT = 12;
- public static final int HFSPLUS_VOL_JOURNALED_BIT = 13;
- public static final int HFSPLUS_VOL_SOFTLOCK_BIT = 15;
- /* */
- public static final int BT_LEAF_NODE = -1;
+ public static final int HFSPLUS_MIN_VERSION = 4; /* HFS+ */
+ public static final int HFSPLUS_CURRENT_VERSION = 5; /* HFSX */
+
+ /* HFS+ volume attributes */
+ public static final int HFSPLUS_VOL_UNMNT_BIT = 8;
+ public static final int HFSPLUS_VOL_SPARE_BLK_BIT = 9;
+ public static final int HFSPLUS_VOL_NOCACHE_BIT = 10;
+ public static final int HFSPLUS_VOL_INCNSTNT_BIT = 11;
+ public static final int HFSPLUS_VOL_NODEID_REUSED_BIT = 12;
+ public static final int HFSPLUS_VOL_JOURNALED_BIT = 13;
+ public static final int HFSPLUS_VOL_SOFTLOCK_BIT = 15;
+
+ public static final int BT_LEAF_NODE = -1;
public static final int BT_INDEX_NODE = 0;
public static final int BT_HEADER_NODE = 1;
public static final int BT_MAP_NODE = 2;
- /* Types */
- public static final int RECORD_TYPE_FOLDER = 0x0001;
+
+ /* Types */
+ public static final int RECORD_TYPE_FOLDER = 0x0001;
public static final int RECORD_TYPE_FILE = 0x0002;
public static final int RECORD_TYPE_FOLDER_THREAD = 0x0003;
public static final int RECORD_TYPE_FILE_THREAD = 0x0004;
-
- public static final int kJIJournalInFSMask = 0x00000001;
+
+ public static final int kJIJournalInFSMask = 0x00000001;
public static final int kJIJournalOnOtherDeviceMask = 0x00000002;
- public static final int kJIJournalNeedInitMask = 0x00000004;
-
- public static final byte EK_DATA_FORK = (byte)0x00;
- public static final byte EK_RESOURCE_FORK = (byte)0xFF;
+ public static final int kJIJournalNeedInitMask = 0x00000004;
+
+ public static final byte EK_DATA_FORK = (byte) 0x00;
+ public static final byte EK_RESOURCE_FORK = (byte) 0xFF;
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -15,99 +15,103 @@
public class HfsPlusFileSystem extends AbstractFileSystem<HFSPlusEntry> {
+ private final Logger log = Logger.getLogger(getClass());
- private final Logger log = Logger.getLogger(getClass());
- /** HFS volume header */
- private Superblock sb;
- /** Catalog special file for this instance */
- private Catalog catalog;
- /**
- *
- * @param device
- * @param readOnly
- * @param type
- * @throws FileSystemException
- */
- public HfsPlusFileSystem(final Device device, final boolean readOnly, final HfsPlusFileSystemType type) throws FileSystemException {
- super(device, readOnly, type);
- }
- /**
- *
- * @throws FileSystemException
- */
- public void create()throws FileSystemException {
- //TODO implements file system creation.
- }
- /**
- *
- * @throws FileSystemException
- */
- public final void read() throws FileSystemException {
- sb = new Superblock(this);
-
- log.debug("Superblock informations :\n" + sb.toString());
- if(!sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_UNMNT_BIT)){
- log.info(getDevice().getId()
- + " Filesystem has not been cleanly unmounted, mounting it readonly");
- setReadOnly(true);
- }
- if(sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_SOFTLOCK_BIT)){
- log.info(getDevice().getId()
- + " Filesystem is marked locked, mounting it readonly");
- setReadOnly(true);
- }
- if(sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_JOURNALED_BIT)){
- log.info(getDevice().getId()
- + " Filesystem is journaled, write access is not supported. Mounting it readonly");
- setReadOnly(true);
- }
- try {
- catalog = new Catalog(this);
- } catch (IOException e) {
- throw new FileSystemException(e);
- }
- }
+ /** HFS volume header */
+ private Superblock sb;
- @Override
- protected final FSDirectory createDirectory(final FSEntry entry) throws IOException {
- HFSPlusEntry e = (HFSPlusEntry)entry;
- return new HFSPlusDirectory(e);
- }
+ /** Catalog special file for this instance */
+ private Catalog catalog;
- @Override
- protected final FSFile createFile(final FSEntry entry) throws IOException {
- HFSPlusEntry e = (HFSPlusEntry)entry;
- return new HFSPlusFile(e);
- }
+ /**
+ *
+ * @param device
+ * @param readOnly
+ * @param type
+ * @throws FileSystemException
+ */
+ public HfsPlusFileSystem(final Device device, final boolean readOnly,
+ final HfsPlusFileSystemType type) throws FileSystemException {
+ super(device, readOnly, type);
+ }
- @Override
- protected final HFSPlusEntry createRootEntry() throws IOException {
- LeafRecord record = catalog.getRecord(CatalogNodeId.HFSPLUS_POR_CNID);
- if(record != null) {
- return new HFSPlusEntry(this,null,null,"/",record);
- }
- log.debug("Root entry : No record found.");
- return null;
- }
+ /**
+ *
+ * @throws FileSystemException
+ */
+ public void create() throws FileSystemException {
+ // TODO implements file system creation.
+ }
- public final long getFreeSpace() {
- return sb.getFreeBlocks() * sb.getBlockSize();
- }
+ /**
+ *
+ * @throws FileSystemException
+ */
+ public final void read() throws FileSystemException {
+ sb = new Superblock(this);
- public final long getTotalSpace() {
- return sb.getTotalBlocks() * sb.getBlockSize();
- }
+ log.debug("Superblock informations:\n" + sb.toString());
+ if (!sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_UNMNT_BIT)) {
+ log.info(getDevice().getId() +
+ " Filesystem has not been cleanly unmounted, mounting it readonly");
+ setReadOnly(true);
+ }
+ if (sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_SOFTLOCK_BIT)) {
+ log.info(getDevice().getId() + " Filesystem is marked locked, mounting it readonly");
+ setReadOnly(true);
+ }
+ if (sb.isAttribute(HfsPlusConstants.HFSPLUS_VOL_JOURNALED_BIT)) {
+ log.info(getDevice().getId() +
+ " Filesystem is journaled, write access is not supported. Mounting it readonly");
+ setReadOnly(true);
+ }
+ try {
+ catalog = new Catalog(this);
+ } catch (IOException e) {
+ throw new FileSystemException(e);
+ }
+ }
- public final long getUsableSpace() {
- // TODO Auto-generated method stub
- return 0;
- }
+ @Override
+ protected final FSDirectory createDirectory(final FSEntry entry) throws IOException {
+ HFSPlusEntry e = (HFSPlusEntry) entry;
+ return new HFSPlusDirectory(e);
+ }
- public final Catalog getCatalog() {
- return catalog;
- }
+ @Override
+ protected final FSFile createFile(final FSEntry entry) throws IOException {
+ HFSPlusEntry e = (HFSPlusEntry) entry;
+ return new HFSPlusFile(e);
+ }
- public final Superblock getVolumeHeader() {
- return sb;
- }
+ @Override
+ protected final HFSPlusEntry createRootEntry() throws IOException {
+ LeafRecord record = catalog.getRecord(CatalogNodeId.HFSPLUS_POR_CNID);
+ if (record != null) {
+ return new HFSPlusEntry(this, null, null, "/", record);
+ }
+ log.debug("Root entry : No record found.");
+ return null;
+ }
+
+ public final long getFreeSpace() {
+ return sb.getFreeBlocks() * sb.getBlockSize();
+ }
+
+ public final long getTotalSpace() {
+ return sb.getTotalBlocks() * sb.getBlockSize();
+ }
+
+ public final long getUsableSpace() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public final Catalog getCatalog() {
+ return catalog;
+ }
+
+ public final Superblock getVolumeHeader() {
+ return sb;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemFormatter.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemFormatter.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemFormatter.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -10,21 +10,21 @@
public class HfsPlusFileSystemFormatter extends Formatter<HfsPlusFileSystem> {
- protected HfsPlusFileSystemFormatter() {
- super(new HfsPlusFileSystemType());
- }
+ protected HfsPlusFileSystemFormatter() {
+ super(new HfsPlusFileSystemType());
+ }
- @Override
- public final HfsPlusFileSystem format(final Device device) throws FileSystemException {
- try {
+ @Override
+ public final HfsPlusFileSystem format(final Device device) throws FileSystemException {
+ try {
FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
HfsPlusFileSystemType type = fSS.getFileSystemType(HfsPlusFileSystemType.ID);
HfsPlusFileSystem fs = type.create(device, false);
fs.create();
return fs;
- } catch (NameNotFoundException e){
- throw new FileSystemException(e);
+ } catch (NameNotFoundException e) {
+ throw new FileSystemException(e);
}
- }
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -15,35 +15,35 @@
public class HfsPlusFileSystemType implements BlockDeviceFileSystemType<HfsPlusFileSystem> {
public static final Class<HfsPlusFileSystemType> ID = HfsPlusFileSystemType.class;
- public final HfsPlusFileSystem create(final Device device, final boolean readOnly)
- throws FileSystemException {
- HfsPlusFileSystem fs = new HfsPlusFileSystem(device, readOnly, this);
- fs.read();
- return fs;
- }
+ public final HfsPlusFileSystem create(final Device device, final boolean readOnly)
+ throws FileSystemException {
+ HfsPlusFileSystem fs = new HfsPlusFileSystem(device, readOnly, this);
+ fs.read();
+ return fs;
+ }
- public final String getName() {
- return "HFS+";
- }
+ public final String getName() {
+ return "HFS+";
+ }
- public final boolean supports(final PartitionTableEntry pte, final byte[] firstSector,
- final FSBlockDeviceAPI devApi) {
- if(pte!=null) {
- if (pte instanceof IBMPartitionTableEntry) {
- if (((IBMPartitionTableEntry)pte).getSystemIndicator() != IBMPartitionTypes.PARTTYPE_LINUXNATIVE) {
- return false;
- }
- }
- }
- //need to check the magic
- ByteBuffer magic = ByteBuffer.allocate(2);
- try{
- devApi.read(1024, magic);
- } catch(IOException e) {
- return false;
- }
- int magicNumber = BigEndian.getInt16(magic.array(), 0);
- return (magicNumber == HfsPlusConstants.HFSPLUS_SUPER_MAGIC);
- }
+ public final boolean supports(final PartitionTableEntry pte, final byte[] firstSector,
+ final FSBlockDeviceAPI devApi) {
+ if (pte != null) {
+ if (pte instanceof IBMPartitionTableEntry) {
+ if (((IBMPartitionTableEntry) pte).getSystemIndicator() != IBMPartitionTypes.PARTTYPE_LINUXNATIVE) {
+ return false;
+ }
+ }
+ }
+ // need to check the magic
+ ByteBuffer magic = ByteBuffer.allocate(2);
+ try {
+ devApi.read(1024, magic);
+ } catch (IOException e) {
+ return false;
+ }
+ int magicNumber = BigEndian.getInt16(magic.array(), 0);
+ return (magicNumber == HfsPlusConstants.HFSPLUS_SUPER_MAGIC);
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -3,25 +3,26 @@
import org.jnode.util.BigEndian;
public class JournalInfoBlock {
- private byte[] data;
- public JournalInfoBlock(final byte[] src){
- data = new byte[180];
- System.arraycopy(src, 0, data, 0, 180);
- }
-
- public final int getFlag(){
- return BigEndian.getInt32(data, 0);
- }
-
- public final long getOffset(){
- return BigEndian.getInt64(data, 36);
- }
-
- public final long getSize(){
- return BigEndian.getInt64(data, 44);
- }
-
- public final String toString(){
- return "Journal : " + getOffset() + "::" + getSize();
- }
+ private byte[] data;
+
+ public JournalInfoBlock(final byte[] src) {
+ data = new byte[180];
+ System.arraycopy(src, 0, data, 0, 180);
+ }
+
+ public final int getFlag() {
+ return BigEndian.getInt32(data, 0);
+ }
+
+ public final long getOffset() {
+ return BigEndian.getInt64(data, 36);
+ }
+
+ public final long getSize() {
+ return BigEndian.getInt64(data, 44);
+ }
+
+ public final String toString() {
+ return "Journal : " + getOffset() + "::" + getSize();
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2008-06-06 20:57:58 UTC (rev 4206)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2008-06-07 03:48:55 UTC (rev 4207)
@@ -1,5 +1,10 @@
package org.jnode.fs.hfsplus;
+import static org.jnode.fs.hfsplus.HfsPlusConstants.HFSPLUS_SUPER_MAGIC;
+import static org.jnode.fs.hfsplus.HfsPlusConstants.HFSPLUS_VOL_INCNSTNT_BIT;
+import static org.jnode.fs.hfsplus.HfsPlusConstants.HFSPLUS_VOL_JOURNALED_BIT;
+import static org.jnode.fs.hfsplus.HfsPlusConstants.HFSPLUS_VOL_UNMNT_BIT;
+
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -8,258 +13,294 @@
import org.jnode.fs.FileSystemException;
import org.jnode.util.BigEndian;
import org.jnode.util.NumberUtils;
+
+
/**
* HFS+ volume header definition.
*
* @author Fabien L.
- *
+ *
*/
-public class Superblock extends HFSPlusObject {
- /** */
- private final Logger log = Logger.getLogger(getClass());
- /** */
- public static final int SUPERBLOCK_LENGTH = 1024;
- /** Data bytes array that contains superblock informations */
- private byte[] data;
-
- public Superblock(){
- super(null);
- data = new byte[SUPERBLOCK_LENGTH];
- log.setLevel(Level.INFO)...
[truncated message content] |