|
From: <fd...@us...> - 2007-06-30 11:58:47
|
Revision: 3337
http://jnode.svn.sourceforge.net/jnode/?rev=3337&view=rev
Author: fduminy
Date: 2007-06-30 04:58:44 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
integration of OpenJDK: added binding with VM for new File APIs (jdk 1.6)
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java
trunk/fs/src/fs/org/jnode/fs/FSEntry.java
trunk/fs/src/fs/org/jnode/fs/FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/fat/FatBasicDirEntry.java
trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java
trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/spi/UnixFSAccessRights.java
Removed Paths:
-------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2AccessRights.java
Modified: trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -38,4 +38,15 @@
public Principal getOwner()
throws IOException;
+ public boolean canRead();
+
+ public boolean canWrite();
+
+ public boolean canExecute();
+
+ public boolean setReadable(boolean enable, boolean owneronly);
+
+ public boolean setWritable(boolean enable, boolean owneronly);
+
+ public boolean setExecutable(boolean enable, boolean owneronly);
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSEntry.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/FSEntry.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -103,5 +103,5 @@
* @return true if the entry need to be saved
* @throws IOException
*/
- public boolean isDirty() throws IOException;
+ public boolean isDirty() throws IOException;
}
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -59,4 +59,10 @@
* Is this filesystem closed.
*/
public boolean isClosed();
+
+ public long getTotalSpace();
+
+ public long getFreeSpace();
+
+ public long getUsableSpace();
}
Deleted: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2AccessRights.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2AccessRights.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2AccessRights.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -1,55 +0,0 @@
-/*
- * $Id$
- *
- * JNode.org
- * Copyright (C) 2003-2006 JNode.org
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package org.jnode.fs.ext2;
-
-import java.security.Principal;
-
-import org.jnode.fs.FSAccessRights;
-import org.jnode.fs.FileSystem;
-
-/**
- * @author Andras Nagy
- */
-public class Ext2AccessRights implements FSAccessRights {
-
- /**
- * @see org.jnode.fs.FSAccessRights#getOwner()
- */
- public Principal getOwner() {
- return null;
- }
-
- /**
- * @see org.jnode.fs.FSObject#isValid()
- */
- public boolean isValid() {
- return false;
- }
-
- /**
- * @see org.jnode.fs.FSObject#getFileSystem()
- */
- public FileSystem getFileSystem() {
- return null;
- }
-
-}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -986,4 +986,19 @@
protected synchronized INodeCache getInodeCache() {
return inodeCache;
}
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatBasicDirEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatBasicDirEntry.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatBasicDirEntry.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -21,6 +21,10 @@
package org.jnode.fs.fat;
+import java.io.IOException;
+
+import org.jnode.fs.FSAccessRights;
+
/**
* @author gbin
*/
@@ -40,5 +44,4 @@
public void write(byte[] dest, int offset) {
System.arraycopy(rawData, 0, dest, offset, 32);
}
-
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -28,6 +28,7 @@
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
import org.jnode.fs.FSFile;
+import org.jnode.fs.spi.UnixFSAccessRights;
import org.jnode.fs.util.DosUtils;
import org.jnode.util.LittleEndian;
import org.jnode.util.NumberUtils;
@@ -58,6 +59,9 @@
/** Directory this entry is a part of */
private final AbstractDirectory parent;
+ /** access rights of the entry */
+ private final FSAccessRights rights;
+
public static FatBasicDirEntry fatDirEntryFactory(AbstractDirectory dir, byte[] src, int offset) {
int flags = LittleEndian.getUInt8(src, offset + 0x0b);
boolean r = (flags & F_READONLY) != 0;
@@ -98,6 +102,7 @@
this.flags = F_ARCHIVE;
this.lastModified = System.currentTimeMillis();
this._dirty = false;
+ this.rights = new UnixFSAccessRights(getFileSystem());
}
/**
@@ -135,6 +140,7 @@
this.startCluster = LittleEndian.getUInt16(src, offset + 0x1a);
this.length = LittleEndian.getUInt32(src, offset + 0x1c);
this._dirty = false;
+ this.rights = new UnixFSAccessRights(getFileSystem());
}
/**
@@ -511,6 +517,7 @@
public FSDirectory getParent() {
return parent;
}
+
/**
* Gets the accessrights for this entry.
@@ -518,6 +525,6 @@
* @throws IOException
*/
public FSAccessRights getAccessRights() throws IOException {
- throw new IOException("Not implemented yet");
- }
+ return rights;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -196,4 +196,20 @@
// TODO Auto-generated method stub
return null;
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -153,4 +153,20 @@
public boolean isReadOnly() {
return true;
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -107,4 +107,20 @@
// TODO Auto-generated method stub
return null;
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -80,4 +80,20 @@
protected FSEntry createRootEntry() {
return rootEntry;
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -204,12 +204,16 @@
throw new UnsupportedOperationException ( "getFile" );
}
+ /**
+ * Gets the accessrights for this entry.
+ *
+ * @throws IOException
+ */
+ public FSAccessRights getAccessRights() throws IOException {
+ throw new IOException("Not implemented yet");
+ }
- public FSAccessRights getAccessRights() {
- throw new UnsupportedOperationException ( "getAccessRights" );
- }
-
public String getPath() {
StringBuilder path = new StringBuilder ( 1024 );
FatDirectory parent = (FatDirectory)getParent();
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -114,4 +114,19 @@
return out.toString();
}
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -23,13 +23,13 @@
import org.jnode.fs.FSEntry;
import org.jnode.fs.FSDirectory;
+import org.jnode.fs.spi.UnixFSAccessRights;
/**
* @author Andreas H\u00e4nel
*/
public interface ExtFSEntry extends FSEntry {
-
public void setParent(FSDirectory parent);
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -117,4 +117,21 @@
protected FSEntry createRootEntry() throws IOException {
return null;
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -103,4 +103,20 @@
// TODO Auto-generated method stub
return null;
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -99,9 +99,9 @@
*
* @param file
*/
- public boolean canRead(String file) {
- // TODO implement me
- return true;
+ public boolean canRead(String file) throws IOException {
+ final FSEntry entry = getEntry(file);
+ return (entry != null) && (entry.getAccessRights().canRead());
}
/**
@@ -109,12 +109,44 @@
*
* @param file
*/
- public boolean canWrite(String file) {
- // TODO implement me
- return false;
+ public boolean canWrite(String file) throws IOException {
+ final FSEntry entry = getEntry(file);
+ return (entry != null) && (entry.getAccessRights().canWrite());
}
/**
+ * Can the given file be executed to?
+ *
+ * @param file
+ */
+ public boolean canExecute(String file) throws IOException {
+ final FSEntry entry = getEntry(file);
+ return (entry != null) && (entry.getAccessRights().canExecute());
+ }
+
+
+ public boolean setReadable(String file, boolean enable,
+ boolean owneronly) throws IOException
+ {
+ final FSEntry entry = getEntry(file);
+ return (entry != null) && (entry.getAccessRights().setReadable(enable, owneronly));
+ }
+
+ public boolean setWritable(String file, boolean enable,
+ boolean owneronly) throws IOException
+ {
+ final FSEntry entry = getEntry(file);
+ return (entry != null) && (entry.getAccessRights().setWritable(enable, owneronly));
+ }
+
+ public boolean setExecutable(String file, boolean enable,
+ boolean owneronly) throws IOException
+ {
+ final FSEntry entry = getEntry(file);
+ return (entry != null) && (entry.getAccessRights().setExecutable(enable, owneronly));
+ }
+
+ /**
* Gets the length in bytes of the given file or 0 if the file does not
* exist.
*
@@ -180,8 +212,9 @@
* @throws IOException
*/
public void setReadOnly(String file) throws IOException {
- throw new IOException("Not implemented yet");
- // TODO implement me
+ setReadable(file, true, true);
+ setWritable(file, false, true);
+ setExecutable(file, false, true);
}
/**
@@ -274,14 +307,13 @@
} catch (IOException ex) {
// Not found
log.debug("parent.getEntry failed", ex);
- ex.printStackTrace();
return null;
}
} else {
return null;
}
} catch (IOException e) {
- log.debug("Filesystem.getRootEntry failed", e);
+ log.debug("Filesystem.getEntry failed", e);
return null;
}
@@ -404,7 +436,7 @@
*
* @param file
* absolute path
- * @return the directory entry, null if not exite or not a directory
+ * @return the directory entry, null if not exist or not a directory
* @throws IOException
*/
private FSDirectory getParentDirectoryEntry(String file) throws IOException {
@@ -463,4 +495,38 @@
return (idx >= 0) ? path.substring(idx + 1) : path;
}
}
+
+ public long getTotalSpace(String path) throws IOException
+ {
+ final FSEntry entry = getEntry(path);
+ long length = 0L;
+ if(entry != null)
+ {
+ length = entry.getFileSystem().getTotalSpace();
+ }
+ return length;
+ }
+
+ public long getFreeSpace(String path) throws IOException
+ {
+ final FSEntry entry = getEntry(path);
+ long length = 0L;
+ if(entry != null)
+ {
+ length = entry.getFileSystem().getFreeSpace();
+ }
+ return length;
+ }
+
+ public long getUsableSpace(String path) throws IOException
+ {
+ final FSEntry entry = getEntry(path);
+ long length = 0L;
+ if(entry != null)
+ {
+ length = entry.getFileSystem().getUsableSpace();
+ }
+ return length;
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -92,4 +92,20 @@
final void unregisterFileSystem(Device dev) {
root.unregisterFileSystem(dev);
}
+
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -91,4 +91,19 @@
public boolean isReadOnly() {
return true;
}
+
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
+
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java 2007-06-30 11:56:19 UTC (rev 3336)
+++ trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSEntry.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -64,7 +64,7 @@
private long lastModified;
/** access rights of the entry */
- private FSAccessRights rights;
+ final private FSAccessRights rights;
/** Parent directory of the entry */
private FSDirectory parent; // parent is null for a root
@@ -104,7 +104,7 @@
this.table = table;
this.lastModified = System.currentTimeMillis();
this.parent = parent;
- //TODO : this.rights = ???????;
+ this.rights = new UnixFSAccessRights(fs);
}
/**
Added: trunk/fs/src/fs/org/jnode/fs/spi/UnixFSAccessRights.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/spi/UnixFSAccessRights.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/spi/UnixFSAccessRights.java 2007-06-30 11:58:44 UTC (rev 3337)
@@ -0,0 +1,178 @@
+package org.jnode.fs.spi;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.BitSet;
+
+import org.jnode.fs.FSAccessRights;
+import org.jnode.fs.FileSystem;
+
+import sun.security.acl.GroupImpl;
+
+import com.sun.security.auth.UserPrincipal;
+
+/**
+ *
+ * @author Fabien DUMINY (fduminy at jnode.org)
+ *
+ */
+public class UnixFSAccessRights implements FSAccessRights
+{
+ final private FileSystem filesystem;
+
+ private Principal owner;
+ private Group group;
+
+ final private Rights ownerRights = new Rights(true, true, true);
+ final private Rights groupRights = new Rights();
+ final private Rights worldRights = new Rights();
+
+
+ public UnixFSAccessRights(FileSystem filesystem)
+ {
+ if(filesystem == null)
+ {
+ throw new NullPointerException("filesystem can't be null");
+ }
+ this.filesystem = filesystem;
+
+ // TODO manages users & groups in JNode
+ owner = new UserPrincipal("root");
+ group = new GroupImpl("admins");
+ group.addMember(owner);
+ }
+
+ private Principal getUser()
+ {
+ // TODO manages users & groups in JNode
+ // we should find the user from the context
+ return owner;
+ }
+
+ private Rights getUserRights()
+ {
+ Principal user = getUser();
+
+ Rights rights = worldRights;
+ if(owner.equals(user))
+ {
+ rights = ownerRights;
+ }
+ else if(group.isMember(user))
+ {
+ rights = groupRights;
+ }
+
+ return rights;
+ }
+
+ public boolean canExecute() {
+ return getUserRights().isExecute();
+ }
+
+ public boolean canRead() {
+ return getUserRights().isRead();
+ }
+
+ public boolean canWrite() {
+ return getUserRights().isWrite();
+ }
+
+ public Principal getOwner() {
+ return owner;
+ }
+
+ public boolean setExecutable(boolean enable, boolean owneronly)
+ {
+ if(!owner.equals(getUser()))
+ {
+ return false;
+ }
+
+ ownerRights.setExecute(enable);
+ if(!owneronly)
+ {
+ groupRights.setExecute(enable);
+ worldRights.setExecute(enable);
+ }
+ return true;
+ }
+
+ public boolean setReadable(boolean enable, boolean owneronly)
+ {
+ if(!owner.equals(getUser()))
+ {
+ return false;
+ }
+
+ ownerRights.setRead(enable);
+ if(!owneronly)
+ {
+ groupRights.setRead(enable);
+ worldRights.setRead(enable);
+ }
+ return true;
+ }
+
+ public boolean setWritable(boolean enable, boolean owneronly)
+ {
+ if(!owner.equals(getUser()))
+ {
+ return false;
+ }
+
+ ownerRights.setWrite(enable);
+ if(!owneronly)
+ {
+ groupRights.setWrite(enable);
+ worldRights.setWrite(enable);
+ }
+ return true;
+ }
+
+ public FileSystem getFileSystem() {
+ return filesystem;
+ }
+
+ public boolean isValid() {
+ return true;
+ }
+
+ private static class Rights
+ {
+ private boolean read = false;
+ private boolean write = false;
+ private boolean execute = false;
+
+ public Rights()
+ {
+ this(false, false, false);
+ }
+
+ public Rights(boolean read, boolean write, boolean execute) {
+ this.read = read;
+ this.write = write;
+ this.execute = execute;
+ }
+
+ public boolean isRead() {
+ return read;
+ }
+ public void setRead(boolean read) {
+ this.read = read;
+ }
+ public boolean isWrite() {
+ return write;
+ }
+ public void setWrite(boolean write) {
+ this.write = write;
+ }
+ public boolean isExecute() {
+ return execute;
+ }
+ public void setExecute(boolean execute) {
+ this.execute = execute;
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-08-04 10:09:46
|
Revision: 3378
http://jnode.svn.sourceforge.net/jnode/?rev=3378&view=rev
Author: lsantha
Date: 2007-08-04 03:09:43 -0700 (Sat, 04 Aug 2007)
Log Message:
-----------
Fixed the problem with file access rights in cp command.
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java 2007-08-04 09:31:03 UTC (rev 3377)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatRootEntry.java 2007-08-04 10:09:43 UTC (rev 3378)
@@ -115,7 +115,7 @@
* @throws IOException
*/
public FSAccessRights getAccessRights() throws IOException {
- throw new IOException("Not implemented yet");
+ throw new UnsupportedOperationException("not implemented yet");
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java 2007-08-04 09:31:03 UTC (rev 3377)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java 2007-08-04 10:09:43 UTC (rev 3378)
@@ -114,7 +114,7 @@
* @see org.jnode.fs.FSEntry#getAccessRights()
*/
public FSAccessRights getAccessRights() throws IOException {
- throw new UnsupportedOperationException("not yet implemented");
+ throw new UnsupportedOperationException("not implemented yet");
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2007-08-04 09:31:03 UTC (rev 3377)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2007-08-04 10:09:43 UTC (rev 3378)
@@ -210,7 +210,7 @@
* @throws IOException
*/
public FSAccessRights getAccessRights() throws IOException {
- throw new IOException("Not implemented yet");
+ throw new UnsupportedOperationException("not implemented yet");
}
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2007-08-04 09:31:03 UTC (rev 3377)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2007-08-04 10:09:43 UTC (rev 3378)
@@ -262,7 +262,6 @@
* are relative to the given directory.
*
* @param directory
- * @param filter
*/
public String[] list(String directory) throws IOException {
final FSEntry entry = getEntry(directory);
@@ -291,10 +290,16 @@
{
FSEntry entry = getEntry(path);
if(entry == null)
- {
- throw new FileNotFoundException("file not found: "+path);
- }
- return entry.getAccessRights();
+ throw new FileNotFoundException("file not found: "+path);
+
+ try {
+ return entry.getAccessRights();
+ }catch(UnsupportedOperationException e){
+ //todo review
+ //this feature is not implemented yet in al file system implementations
+ //return null in those cases
+ return null;
+ }
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fd...@us...> - 2008-01-19 22:48:50
|
Revision: 3718
http://jnode.svn.sourceforge.net/jnode/?rev=3718&view=rev
Author: fduminy
Date: 2008-01-19 14:48:47 -0800 (Sat, 19 Jan 2008)
Log Message:
-----------
- added generics to FileSystem
- replaced key of type String by a key of type Class<FileSystemType> for registered file system types (method getFileSystemTypeForNameSystemTypes)
- moved supports(...) method from FileSystemType to a subclass named BlockDeviceFileSystemType
- fixed some warnings related to type safety
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/FileSystem.java
trunk/fs/src/fs/org/jnode/fs/FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/Formatter.java
trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.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/iso9660/ISO9660FileSystem.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java
trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java
trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemMounter.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemTypeManager.java
trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java
trunk/fs/src/fs/org/jnode/fs/spi/AbstractFileSystem.java
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java
Added: trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -0,0 +1,43 @@
+/*
+ * $Id: FileSystemType.java 3668 2007-12-30 22:20:07Z fduminy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.fs;
+
+import org.jnode.driver.block.FSBlockDeviceAPI;
+import org.jnode.partitions.PartitionTableEntry;
+
+/**
+ * Specific kind of FileSystemType for block devices
+ *
+ * @author epr
+ */
+public interface BlockDeviceFileSystemType<T extends FileSystem<?>> extends FileSystemType<T> {
+ /**
+ * Can this file system type be used on the given first sector of a
+ * blockdevice?
+ *
+ * @param pte
+ * The partition table entry, if any. If null, there is no
+ * partition table entry.
+ * @param firstSector
+ */
+ public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi);
+}
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs;
import java.io.IOException;
@@ -28,7 +28,7 @@
/**
* @author epr
*/
-public interface FileSystem {
+public interface FileSystem<T extends FSEntry> {
/**
* Gets the device this FS driver operates on.
@@ -39,7 +39,7 @@
* Gets the root entry of this filesystem. This is usually a directory, but
* this is not required.
*/
- public FSEntry getRootEntry() throws IOException;
+ public T getRootEntry() throws IOException;
/**
* Is the filesystem mounted in readonly mode ?
@@ -50,7 +50,7 @@
* Close this filesystem. After a close, all invocations of method of this
* filesystem or objects created by this filesystem will throw an
* IOException.
- *
+ *
* @throws IOException
*/
public void close() throws IOException;
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -22,16 +22,13 @@
package org.jnode.fs;
import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
-import org.jnode.partitions.PartitionTableEntry;
/**
- * Descriptor and entry point for a class of filesystems. Samples of
- * FileSystemType's are FAT16, EXT3.
+ * Descriptor and entry point for a class of filesystems.
*
* @author epr
*/
-public interface FileSystemType<T extends FileSystem> {
+public interface FileSystemType<T extends FileSystem<?>> {
/**
* Gets the unique name of this file system type.
@@ -39,17 +36,6 @@
public String getName();
/**
- * Can this file system type be used on the given first sector of a
- * blockdevice?
- *
- * @param pte
- * The partition table entry, if any. If null, there is no
- * partition table entry.
- * @param firstSector
- */
- public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi);
-
- /**
* Create a filesystem from a given device.
*
* @param device
Modified: trunk/fs/src/fs/org/jnode/fs/Formatter.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/Formatter.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/Formatter.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -9,7 +9,7 @@
*
* @param <T>
*/
-abstract public class Formatter<T extends FileSystem> implements Cloneable {
+abstract public class Formatter<T extends FileSystem<?>> implements Cloneable {
private final FileSystemType<T> type;
protected Formatter(FileSystemType<T> type)
Modified: trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -46,7 +46,7 @@
* @author Fabien DUMINY (fduminy at jnode.org)
*
*/
-abstract public class AbstractFormatCommand<T extends FileSystem> extends AbstractCommand {
+abstract public class AbstractFormatCommand<T extends FileSystem<?>> extends AbstractCommand {
private static final DeviceArgument ARG_DEVICE = new DeviceArgument("device-id",
"the device to format");
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -43,7 +43,7 @@
* @author Andras Nagy
*
*/
-public class Ext2FileSystem extends AbstractFileSystem {
+public class Ext2FileSystem extends AbstractFileSystem<Ext2Entry> {
private Superblock superblock;
private GroupDescriptor groupDescriptors[];
@@ -175,8 +175,8 @@
+ " #MaxMount: " + superblock.getMaxMntCount() + "\n"
+ " Last mount time: " + sdf.format(Ext2Utils.decodeDate(superblock.getMTime()).getTime()) + "\n"
+ " Last write time: " + sdf.format(Ext2Utils.decodeDate(superblock.getWTime()).getTime()) + "\n"
- + " #blocks: " + superblock.getBlocksCount() + "\n"
- + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n"
+ + " #blocks: " + superblock.getBlocksCount() + "\n"
+ + " #blocks/group: " + superblock.getBlocksPerGroup() + "\n"
+ " #block groups: " + groupCount + "\n"
+ " block size: " + superblock.getBlockSize() + "\n"
+ " #inodes: " + superblock.getINodesCount() + "\n"
@@ -310,7 +310,7 @@
/**
* @see org.jnode.fs.spi.AbstractFileSystem#createRootEntry()
*/
- public FSEntry createRootEntry() throws IOException {
+ public Ext2Entry createRootEntry() throws IOException {
try {
return new Ext2Entry(getINode(Ext2Constants.EXT2_ROOT_INO), "/",
Ext2Constants.EXT2_FT_DIR, this, null);
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -29,6 +29,7 @@
import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -36,9 +37,9 @@
/**
* @author Andras Nagy
*/
-public class Ext2FileSystemType implements FileSystemType<Ext2FileSystem> {
+public class Ext2FileSystemType implements BlockDeviceFileSystemType<Ext2FileSystem> {
- public static final String NAME = "EXT2";
+ public static final Class<Ext2FileSystemType> NAME = Ext2FileSystemType.class;
/**
* @see org.jnode.fs.FileSystemType#create(Device, boolean)
@@ -53,7 +54,7 @@
* @see org.jnode.fs.FileSystemType#getName()
*/
public String getName() {
- return NAME;
+ return "EXT2";
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -35,7 +35,7 @@
/**
* @author epr
*/
-public class FatFileSystem extends AbstractFileSystem {
+public class FatFileSystem extends AbstractFileSystem<FatRootEntry> {
private BootSector bs;
private Fat fat;
@@ -123,7 +123,7 @@
* Gets the root entry of this filesystem. This is usually a director, but
* this is not required.
*/
- public FSEntry getRootEntry() {
+ public FatRootEntry getRootEntry() {
return rootEntry;
}
@@ -192,7 +192,7 @@
/**
*
*/
- protected FSEntry createRootEntry() throws IOException {
+ protected FatRootEntry createRootEntry() throws IOException {
// TODO Auto-generated method stub
return null;
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -25,6 +25,7 @@
import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -32,16 +33,16 @@
/**
* @author epr
*/
-public class FatFileSystemType implements FileSystemType<FatFileSystem> {
+public class FatFileSystemType implements BlockDeviceFileSystemType<FatFileSystem> {
/** Name of this filesystem type */
- public static final String NAME = "FAT";
+ public static final Class<FatFileSystemType> NAME = FatFileSystemType.class;
/**
* Gets the unique name of this file system type.
*/
public String getName() {
- return NAME;
+ return "FAT";
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.ftpfs;
import org.jnode.fs.FileSystem;
@@ -37,7 +37,7 @@
/**
* @author Levente S\u00e1ntha
*/
-public class FTPFileSystem extends FTPClient implements FileSystem {
+public class FTPFileSystem extends FTPClient implements FileSystem<FTPFSDirectory> {
private FTPFSDevice device;
private FTPFSDirectory root;
private boolean closed;
@@ -153,20 +153,20 @@
public boolean isReadOnly() {
return true;
}
-
+
public long getFreeSpace() {
// TODO implement me
return 0;
}
public long getTotalSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
}
public long getUsableSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
- }
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -32,7 +32,7 @@
* @author Levente S\u00e1ntha
*/
public class FTPFileSystemType implements FileSystemType<FTPFileSystem> {
- public static final String NAME = "FTPFS";
+ public static final Class<FTPFileSystemType> NAME = FTPFileSystemType.class;
/**
* Create a filesystem from a given device.
*
@@ -47,19 +47,6 @@
* Gets the unique name of this file system type.
*/
public String getName() {
- return NAME;
+ return "FTPFS";
}
-
- /**
- * Can this file system type be used on the given first sector of a
- * blockdevice?
- *
- * @param pte The partition table entry, if any. If null, there is no
- * partition table entry.
- * @param firstSector
- */
- public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi) {
- return false;
- }
-
}
\ No newline at end of file
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.ftpfs.command;
import org.jnode.driver.DeviceManager;
@@ -27,6 +27,7 @@
import org.jnode.fs.FileSystemType;
import org.jnode.fs.ftpfs.FTPFSDevice;
import org.jnode.fs.ftpfs.FTPFSDriver;
+import org.jnode.fs.ftpfs.FTPFileSystem;
import org.jnode.fs.ftpfs.FTPFileSystemType;
import org.jnode.fs.service.FileSystemService;
import org.jnode.naming.InitialNaming;
@@ -72,8 +73,8 @@
final DeviceManager dm = DeviceUtils.getDeviceManager();
dm.register(dev);
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
- FileSystemType type = fss.getFileSystemTypeForNameSystemTypes(FTPFileSystemType.NAME);
- final FileSystem fs = type.create(dev, true);
+ FTPFileSystemType type = fss.getFileSystemTypeForNameSystemTypes(FTPFileSystemType.NAME);
+ final FTPFileSystem fs = type.create(dev, true);
fss.registerFileSystem(fs);
fss.mount(mount_point, fs, null);
}
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.iso9660;
import java.io.IOException;
@@ -35,7 +35,7 @@
* @author Chira
* @author Ewout Prangsma (ep...@us...)
*/
-public class ISO9660FileSystem extends AbstractFileSystem {
+public class ISO9660FileSystem extends AbstractFileSystem<ISO9660Entry> {
private final ISO9660Volume volume;
private ISO9660Entry rootEntry;
@@ -59,7 +59,7 @@
/**
* @see org.jnode.fs.FileSystem#getRootEntry()
*/
- public FSEntry getRootEntry() throws IOException {
+ public ISO9660Entry getRootEntry() throws IOException {
if (rootEntry == null) {
rootEntry = new ISO9660Entry(this, volume.getRootDirectoryEntry());
}
@@ -85,7 +85,7 @@
}
/**
- *
+ *
*/
protected FSFile createFile(FSEntry entry) throws IOException {
// TODO Auto-generated method stub
@@ -93,7 +93,7 @@
}
/**
- *
+ *
*/
protected FSDirectory createDirectory(FSEntry entry) throws IOException {
// TODO Auto-generated method stub
@@ -101,9 +101,9 @@
}
/**
- *
+ *
*/
- protected FSEntry createRootEntry() throws IOException {
+ protected ISO9660Entry createRootEntry() throws IOException {
// TODO Auto-generated method stub
return null;
}
@@ -115,12 +115,12 @@
}
public long getTotalSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
}
public long getUsableSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -29,17 +29,18 @@
import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.partitions.PartitionTableEntry;
/**
* @author Chira
*/
-public class ISO9660FileSystemType implements FileSystemType<ISO9660FileSystem> {
+public class ISO9660FileSystemType implements BlockDeviceFileSystemType<ISO9660FileSystem> {
- public static final String NAME = "ISO9660";
+ public static final Class<ISO9660FileSystemType> NAME = ISO9660FileSystemType.class;
public final String getName() {
- return NAME;
+ return "ISO9660";
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.jarfs;
import java.util.Map;
@@ -32,11 +32,11 @@
import org.jnode.fs.spi.AbstractFileSystem;
/**
- *
+ *
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
*
*/
-public class JarFileSystem extends AbstractFileSystem {
+public class JarFileSystem extends AbstractFileSystem<JarFSEntry> {
private JarFile jarFile;
private JarFSCache cache;
@@ -48,7 +48,7 @@
public JarFileSystem(JarFileDevice device)
throws FileSystemException {
super(device, true); // jar file systems are always readOnly
-
+
jarFile = device.getJarFile();
cache = new JarFSCache();
rootEntry = FSTreeBuilder.build(this, jarFile, cache);
@@ -58,42 +58,42 @@
{
return jarFile;
}
-
+
/**
- *
+ *
*/
protected FSFile createFile(FSEntry entry) {
return new JarFSFile((JarFSEntry) entry);
}
/**
- *
+ *
*/
protected FSDirectory createDirectory(FSEntry entry) {
Map<String, JarFSEntry> entries = cache.getChildEntries((JarFSEntry) entry);
return new JarFSDirectory((JarFSEntry) entry, entries);
}
-
+
/**
- *
+ *
*/
- protected FSEntry createRootEntry() {
+ protected JarFSEntry createRootEntry() {
return rootEntry;
}
-
+
public long getFreeSpace() {
// TODO implement me
return 0;
}
public long getTotalSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
}
public long getUsableSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
- }
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -36,22 +36,13 @@
*/
public class JarFileSystemType implements FileSystemType<JarFileSystem> {
- public static final String NAME = "jar";
+ public static final Class<JarFileSystemType> NAME = JarFileSystemType.class;
public final String getName() {
- return NAME;
+ return "jar";
}
/**
- * @see org.jnode.fs.FileSystemType#supports(PartitionTableEntry, byte[],
- * FSBlockDeviceAPI)
- */
- public boolean supports(PartitionTableEntry pte, byte[] firstSector,
- FSBlockDeviceAPI devApi) {
- return false;
- }
-
- /**
* @see org.jnode.fs.FileSystemType#create(Device, boolean)
*/
public JarFileSystem create(Device device, boolean readOnly) throws FileSystemException {
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -25,18 +25,18 @@
/**
* @author gvt
*/
-public class FatFileSystem extends AbstractFileSystem {
+public class FatFileSystem extends AbstractFileSystem<FatRootDirectory> {
private static final Logger log =
Logger.getLogger ( FatFileSystem.class );
private Fat fat;
private final CodePage cp;
-
+
public FatFileSystem ( Device device, String codePageName, boolean readOnly )
throws FileSystemException {
super ( device, readOnly );
-
+
try {
fat = Fat.create ( getApi() );
}
@@ -59,8 +59,8 @@
public int getClusterSize() {
return fat.getClusterSize();
}
-
+
public Fat getFat() {
return fat;
}
@@ -81,16 +81,16 @@
return
entry.getFile();
}
-
-
+
+
protected FSDirectory createDirectory ( FSEntry entry )
throws IOException {
return
entry.getDirectory();
}
-
- protected FSEntry createRootEntry()
+
+ protected FatRootDirectory createRootEntry()
throws IOException {
return
new FatRootDirectory ( this );
@@ -103,8 +103,8 @@
fat.flush();
log.debug ( getFat().getCacheStat() );
}
-
+
public String toString() {
StrWriter out = new StrWriter();
@@ -121,12 +121,12 @@
}
public long getTotalSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
}
public long getUsableSpace() {
- // TODO implement me
+ // TODO implement me
return 0;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java 2008-01-19 22:38:34 UTC (rev 3717)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java 2008-01-19 22:48:47 UTC (rev 3718)
@@ -26,6 +26,7 @@
import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -35,12 +36,12 @@
* @author gvt
* @author Tango
*/
-public class FatFileSystemType implements FileSystemType<FatFileSystem> {
- public static final String NAME="JFAT";
+public class FatFileSystemType implements BlockDeviceFileSystemType<FatFileSystem> {
+ public static final Class<FatFileSystemType> NAME=FatFileSyste...
[truncated message content] |
|
From: <ga...@us...> - 2008-01-31 15:28:15
|
Revision: 3740
http://jnode.svn.sourceforge.net/jnode/?rev=3740&view=rev
Author: galatnm
Date: 2008-01-31 07:28:12 -0800 (Thu, 31 Jan 2008)
Log Message:
-----------
Initial release.
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/hfsplus/
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/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/
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/extent/
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/
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
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,43 @@
+package org.jnode.fs.hfsplus;
+
+import java.io.IOException;
+
+import org.jnode.fs.FSEntry;
+import org.jnode.fs.hfsplus.tree.LeafNode;
+import org.jnode.fs.spi.AbstractFSDirectory;
+import org.jnode.fs.spi.FSEntryTable;
+
+public class HFSPlusDirectory extends AbstractFSDirectory {
+
+ private LeafNode record;
+
+ public HFSPlusDirectory(HfsPlusFileSystem fs, LeafNode record){
+ super(fs);
+ this.record = record;
+ }
+
+ @Override
+ protected FSEntry createDirectoryEntry(String name) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected FSEntry createFileEntry(String name) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected FSEntryTable readEntries() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void writeEntries(FSEntryTable entries) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusEntry.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,27 @@
+package org.jnode.fs.hfsplus;
+
+import org.jnode.fs.FSDirectory;
+import org.jnode.fs.hfsplus.tree.LeafRecord;
+import org.jnode.fs.spi.AbstractFSEntry;
+import org.jnode.fs.spi.FSEntryTable;
+
+public class HFSPlusEntry extends AbstractFSEntry {
+
+ public HFSPlusEntry(HfsPlusFileSystem fs, FSEntryTable table,
+ FSDirectory parent, String name, LeafRecord record) {
+ super(fs, table, parent, name, getFSEntryType(name, record));
+ }
+
+ static private int getFSEntryType(String name, 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;
+ }
+
+}
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusFile.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,47 @@
+package org.jnode.fs.hfsplus;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.jnode.fs.hfsplus.tree.LeafRecord;
+import org.jnode.fs.spi.AbstractFSFile;
+
+public class HFSPlusFile extends AbstractFSFile {
+
+ private LeafRecord record;
+
+ public HFSPlusFile(HfsPlusFileSystem fs, LeafRecord record){
+ super(fs);
+ this.record = record;
+ }
+
+ @Override
+ public void flush() throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public long getLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void read(long fileOffset, ByteBuffer dest) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void write(long fileOffset, ByteBuffer src) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLength(long length) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,51 @@
+package org.jnode.fs.hfsplus;
+
+import org.apache.log4j.Logger;
+import org.jnode.fs.hfsplus.extent.ExtentDescriptor;
+import org.jnode.util.BigEndian;
+
+public class HFSPlusForkData {
+ public final static int FORK_DATA_LENGTH = 80;
+ private static final int EXTENT_OFFSET = 16;
+
+ private final Logger log = Logger.getLogger(getClass());
+
+ private byte data[];
+
+ public HFSPlusForkData(byte[] src, int offset){
+ data = new byte[FORK_DATA_LENGTH];
+ System.arraycopy(src, offset, data, 0, FORK_DATA_LENGTH);
+ }
+
+ public long getTotalSize(){
+ return BigEndian.getInt64(data, 0);
+ }
+
+ public int getClumpSize(){
+ return BigEndian.getInt32(data, 8);
+ }
+
+ public int getTotalBlocks(){
+ return BigEndian.getInt32(data, 12);
+ }
+
+ public 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 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();
+ }
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusObject.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,22 @@
+package org.jnode.fs.hfsplus;
+
+import org.jnode.fs.FSObject;
+import org.jnode.fs.FileSystem;
+import org.jnode.fs.nfs.nfs2.NFS2FileSystem;
+
+public class HFSPlusObject implements FSObject {
+
+ private HfsPlusFileSystem fs;
+
+ public HFSPlusObject(HfsPlusFileSystem fileSystem) {
+ this.fs = fileSystem;
+ }
+
+ public FileSystem getFileSystem() {
+ return fs;
+ }
+
+ public boolean isValid() {
+ return false;
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,26 @@
+package org.jnode.fs.hfsplus;
+
+import org.jnode.util.BigEndian;
+
+
+public class HFSUnicodeString {
+ private byte[] data;
+
+ public HFSUnicodeString(byte[] src, int offset){
+ data = new byte[src.length];
+ System.arraycopy(src, offset, data, 0, src.length);
+ }
+
+ public int getLength(){
+ return BigEndian.getInt16(data, 0);
+ }
+
+ public String getUnicodeString(){
+ char[] result = new char[(getLength())/2];
+ for(int i = 1; i < result.length; ++i){
+ result[i] = BigEndian.getChar(data, i*2);
+ }
+ return new String(result);
+ }
+
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUnicodeString.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,31 @@
+package org.jnode.fs.hfsplus;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+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 Calendar decodeDate(int time){
+ Calendar ref = Calendar.getInstance();
+ ref.setTime(new Date((time*1000)-DIFF_TO_JAVA_DATE_IN_MILLIS));
+ return ref;
+ }
+ /**
+ *
+ * @param time
+ * @param dateFormat
+ * @return
+ */
+ public static String printDate(int time, String dateFormat){
+ Calendar ref = decodeDate(time);
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
+ return sdf.format(ref.getTime());
+ }
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSUtils.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,34 @@
+package org.jnode.fs.hfsplus;
+
+public class HfsPlusConstants {
+
+ 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 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;
+ 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 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;
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusConstants.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,69 @@
+package org.jnode.fs.hfsplus;
+
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+import org.jnode.driver.Device;
+import org.jnode.fs.FSDirectory;
+import org.jnode.fs.FSEntry;
+import org.jnode.fs.FSFile;
+import org.jnode.fs.FileSystemException;
+import org.jnode.fs.hfsplus.catalog.Catalog;
+import org.jnode.fs.hfsplus.catalog.CatalogNodeId;
+import org.jnode.fs.hfsplus.tree.LeafRecord;
+import org.jnode.fs.spi.AbstractFileSystem;
+
+
+public class HfsPlusFileSystem extends AbstractFileSystem<HFSPlusEntry> {
+
+ private final Logger log = Logger.getLogger(getClass());
+
+ private Superblock sb;
+
+ public HfsPlusFileSystem(Device device, boolean readOnly) throws FileSystemException {
+ super(device, readOnly);
+ }
+
+ public void read() throws FileSystemException {
+ sb = new Superblock(this);
+ log.debug("Superblock informations :\n" + sb.toString());
+ }
+
+ @Override
+ protected FSDirectory createDirectory(FSEntry entry) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected FSFile createFile(FSEntry entry) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected HFSPlusEntry createRootEntry() throws IOException {
+ Catalog cf = new Catalog(sb, this);
+ int currentOffset = cf.init();
+ LeafRecord record = cf.getRecord(CatalogNodeId.HFSPLUS_POR_CNID, currentOffset);
+ if(record != null) {
+ record.toString();
+ return new HFSPlusEntry(this,null,null,"/",record);
+ }
+ log.debug("Root entry : No record found.");
+ return null;
+ }
+
+ public long getFreeSpace() {
+ return sb.getFreeBlocks() * sb.getBlockSize();
+ }
+
+ public long getTotalSpace() {
+ return sb.getTotalBlocks() * sb.getBlockSize();
+ }
+
+ public long getUsableSpace() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,46 @@
+package org.jnode.fs.hfsplus;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.jnode.driver.Device;
+import org.jnode.driver.block.FSBlockDeviceAPI;
+import org.jnode.fs.BlockDeviceFileSystemType;
+import org.jnode.fs.FileSystemException;
+import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.partitions.ibm.IBMPartitionTableEntry;
+import org.jnode.partitions.ibm.IBMPartitionTypes;
+import org.jnode.util.BigEndian;
+
+public class HfsPlusFileSystemType implements BlockDeviceFileSystemType<HfsPlusFileSystem> {
+ public static final Class<HfsPlusFileSystemType> ID = HfsPlusFileSystemType.class;
+ public HfsPlusFileSystem create(Device device, boolean readOnly)
+ throws FileSystemException {
+ HfsPlusFileSystem fs = new HfsPlusFileSystem(device, readOnly);
+ fs.read();
+ return fs;
+ }
+
+ public String getName() {
+ return "HFS+";
+ }
+
+ public boolean supports(PartitionTableEntry pte, byte[] firstSector,
+ 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);
+ }
+
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/JournalInfoBlock.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,27 @@
+package org.jnode.fs.hfsplus;
+
+import org.jnode.util.BigEndian;
+
+public class JournalInfoBlock {
+ private byte[] data;
+ public JournalInfoBlock(byte[] src){
+ data = new byte[180];
+ System.arraycopy(src, 0, data, 0, 180);
+ }
+
+ public int getFlag(){
+ return BigEndian.getInt32(data, 0);
+ }
+
+ public long getOffset(){
+ return BigEndian.getInt64(data, 36);
+ }
+
+ public long getSize(){
+ return BigEndian.getInt64(data, 44);
+ }
+
+ public String toString(){
+ return "Journal : " + getOffset() + "::" + getSize();
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,198 @@
+package org.jnode.fs.hfsplus;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+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(HfsPlusFileSystem fs) throws FileSystemException {
+ super(fs);
+ log.setLevel(Level.INFO);
+ try {
+ ByteBuffer b = ByteBuffer.allocate(SUPERBLOCK_LENGTH);
+ //skip the first 1024 bytes (bootsector) and read the superblock
+ fs.getApi().read(1024, b);
+ data = new byte[SUPERBLOCK_LENGTH];
+ System.arraycopy(b.array(), 0, data, 0, SUPERBLOCK_LENGTH);
+ if(getMagic() != HfsPlusConstants.HFSPLUS_SUPER_MAGIC)
+ throw new FileSystemException("Not hfs+ superblock ("+getMagic()+": bad magic)");
+ } catch (IOException e) {
+ throw new FileSystemException(e);
+ }
+ }
+
+ public int getMagic() {
+ return BigEndian.getInt16(data, 0);
+ }
+
+ public int getVersion() {
+ return BigEndian.getInt16(data, 2);
+ }
+
+ public int getAttributes(){
+ return BigEndian.getInt32(data, 4);
+ }
+ /**
+ * Get string representation of attribute.
+ *
+ * @return
+ */
+ public String getAttributesAsString(){
+ String s = "";
+ s = s + ((isAttribute(HfsPlusConstants.HFSPLUS_VOL_UNMNT_BIT))?" kHFSVolumeUnmountedBit":"");
+ s = s + ((isAttribute(HfsPlusConstants.HFSPLUS_VOL_INCNSTNT_BIT))?" kHFSBootVolumeInconsistentBit":"");
+ s = s + ((isAttribute(HfsPlusConstants.HFSPLUS_VOL_JOURNALED_BIT))?" kHFSVolumeJournaledBit":"");
+ return s;
+ }
+ /**
+ * Check if a specific attribute is set.
+ *
+ * @param maskBit See constants.
+ *
+ * @return true if attribute is set.
+ */
+ public boolean isAttribute(int maskBit){
+ return (((getAttributes() >> maskBit) & 0x1) != 0);
+ }
+
+ public int getLastMountedVersion(){
+ return BigEndian.getInt32(data, 8);
+ }
+
+ public int getJournalInfoBlock(){
+ return BigEndian.getInt32(data, 12);
+ }
+
+ public int getCreateDate(){
+ return BigEndian.getInt32(data, 16);
+ }
+
+ public int getModifyDate(){
+ return BigEndian.getInt32(data, 20);
+ }
+
+ public int getBackupDate(){
+ return BigEndian.getInt32(data, 24);
+ }
+
+ public int getCheckedDate(){
+ return BigEndian.getInt32(data, 28);
+ }
+ //
+ public int getFileCount(){
+ return BigEndian.getInt32(data, 32);
+ }
+ public int getFolderCount(){
+ return BigEndian.getInt32(data, 36);
+ }
+ //
+ public int getBlockSize(){
+ return BigEndian.getInt32(data, 40);
+ }
+ public int getTotalBlocks(){
+ return BigEndian.getInt32(data, 44);
+ }
+ public int getFreeBlocks(){
+ return BigEndian.getInt32(data, 48);
+ }
+ //
+ public int getNextAllocation(){
+ return BigEndian.getInt32(data, 52);
+ }
+ public long getRsrcClumpSize(){
+ return BigEndian.getInt32(data, 56);
+ }
+ public int getDataClumpSize(){
+ return BigEndian.getInt32(data, 60);
+ }
+
+ public int getNextCatalogId(){
+ return BigEndian.getInt32(data, 64);
+ }
+
+ public int getWriteCount(){
+ return BigEndian.getInt32(data, 68);
+ }
+
+ public long getEncodingsBmp(){
+ return BigEndian.getInt64(data, 72);
+ }
+
+ public byte[] getFinderInfo(){
+ byte[] result=new byte[32];
+ System.arraycopy(data, 80, result, 0, 32);
+ return result;
+ }
+
+ public HFSPlusForkData getAllocationFile(){
+ return new HFSPlusForkData(data,112);
+ }
+
+ public HFSPlusForkData getExtentsFile(){
+ return new HFSPlusForkData(data,192);
+ }
+
+ public HFSPlusForkData getCatalogFile(){
+ return new HFSPlusForkData(data,272);
+ }
+
+ public HFSPlusForkData getAttributesFile(){
+ return new HFSPlusForkData(data,352);
+ }
+
+ public HFSPlusForkData getStartupFile(){
+ return new HFSPlusForkData(data,432);
+ }
+
+
+ public String toString(){
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("Magic :").append(NumberUtils.hex(getMagic(),4)).append("\n");
+ buffer.append("Version :").append(getVersion()).append("\n").append("\n");
+ buffer.append("Attributes :").append(getAttributesAsString()).append("\n").append("\n");
+
+ buffer.append("Create date :").append(HFSUtils.printDate(getCreateDate(),"EEE MMM d HH:mm:ss yyyy")).append("\n");
+ buffer.append("Modify date :").append(HFSUtils.printDate(getModifyDate(),"EEE MMM d HH:mm:ss yyyy")).append("\n");
+ buffer.append("Backup date :").append(HFSUtils.printDate(getBackupDate(),"EEE MMM d HH:mm:ss yyyy")).append("\n");
+ buffer.append("Checked date :").append(HFSUtils.printDate(getCheckedDate(),"EEE MMM d HH:mm:ss yyyy")).append("\n").append("\n");
+
+ buffer.append("File count :").append(getFileCount()).append("\n");
+ buffer.append("Folder count :").append(getFolderCount()).append("\n").append("\n");
+ buffer.append("Block size :").append(getBlockSize()).append("\n");
+ buffer.append("Total blocks :").append(getTotalBlocks()).append("\n");
+ buffer.append("Free blocks :").append(getFreeBlocks()).append("\n").append("\n");
+ buffer.append("Next catalog ID :").append(getNextCatalogId()).append("\n");
+ buffer.append("Write count :").append(getWriteCount()).append("\n");
+ buffer.append("Encoding bmp :").append(getEncodingsBmp()).append("\n");
+ buffer.append("Finder Infos :").append(getFinderInfo()).append("\n").append("\n");
+ buffer.append("Finder Infos :").append(getJournalInfoBlock()).append("\n").append("\n");
+ buffer.append("Allocation file").append("\n");
+ buffer.append(getAllocationFile().toString()).append("\n");
+ buffer.append("Extents file").append("\n");
+ buffer.append(getExtentsFile().toString()).append("\n");
+ buffer.append("Catalog file").append("\n");
+ buffer.append(getCatalogFile().toString()).append("\n");
+ buffer.append("Attributes file").append("\n");
+ buffer.append(getAttributesFile().toString()).append("\n");
+ buffer.append("Startup file").append("\n");
+ buffer.append(getStartupFile().toString()).append("\n");
+ return buffer.toString();
+ }
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,86 @@
+package org.jnode.fs.hfsplus.catalog;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.log4j.Logger;
+import org.jnode.fs.hfsplus.HfsPlusConstants;
+import org.jnode.fs.hfsplus.HfsPlusFileSystem;
+import org.jnode.fs.hfsplus.Superblock;
+import org.jnode.fs.hfsplus.extent.ExtentDescriptor;
+import org.jnode.fs.hfsplus.tree.BTHeaderRecord;
+import org.jnode.fs.hfsplus.tree.IndexRecord;
+import org.jnode.fs.hfsplus.tree.LeafRecord;
+import org.jnode.fs.hfsplus.tree.NodeDescriptor;
+import org.jnode.fs.spi.AbstractFileSystem;
+
+public class Catalog {
+ private final Logger log = Logger.getLogger(getClass());
+ /** */
+ private AbstractFileSystem<?> fs;
+ /** */
+ private Superblock header;
+ /** */
+ private NodeDescriptor btnd;
+ /** */
+ private BTHeaderRecord bthr;
+
+ public Catalog(Superblock header, HfsPlusFileSystem fs){
+ this.header = header;
+ this.fs = fs;
+ }
+
+ public int init() throws IOException {
+ int offset = 0;
+ ExtentDescriptor current = header.getCatalogFile().getExtents()[0];
+ if(current.getStartBlock() != 0 && current.getBlockCount() != 0){
+ ByteBuffer buffer = ByteBuffer.allocate(14);
+ offset = current.getStartBlock()*header.getBlockSize();
+ fs.getApi().read(offset, buffer);
+ btnd = new NodeDescriptor(buffer.array());
+ log.debug("BTNodeDescriptor informations :\n" + btnd.toString());
+ offset = offset + 14;
+ buffer = ByteBuffer.allocate(106);
+ fs.getApi().read(offset, buffer);
+ bthr = new BTHeaderRecord(buffer.array());
+ log.debug("BTHeaderRec informations :\n" + bthr.toString());
+ offset = offset + 106;
+ offset = current.getStartBlock()*header.getBlockSize();
+ }
+ return offset;
+ }
+
+ public NodeDescriptor getBTNodeDescriptor() {
+ return btnd;
+ }
+
+ public BTHeaderRecord getBTHeaderRecord() {
+ return bthr;
+ }
+
+ public LeafRecord getRecord(CatalogNodeId parentID, int currentOffset) throws IOException{
+ int currentNodeNumber = getBTHeaderRecord().getRootNode();
+ int currentNodeSize = getBTHeaderRecord().getNodeSize();
+ ByteBuffer buffer = ByteBuffer.allocate(currentNodeSize);
+ fs.getApi().read(currentOffset + (currentNodeNumber*currentNodeSize), buffer);
+ NodeDescriptor currentBtnd = new NodeDescriptor(buffer.array());
+ log.debug("Current node descriptor :\n" + currentBtnd.toString());
+ while(currentBtnd.getKind() == HfsPlusConstants.BT_INDEX_NODE) {
+ CatalogIndexNode currentIndexNode = new CatalogIndexNode(currentBtnd, buffer.array(), currentNodeSize);
+ IndexRecord record = currentIndexNode.find(parentID);
+ currentNodeNumber = record.getIndex();
+ currentOffset = currentNodeNumber*currentNodeSize;
+ buffer = ByteBuffer.allocate(currentNodeSize);
+ fs.getApi().read(currentOffset, buffer);
+ currentBtnd = new NodeDescriptor(buffer.array());
+ }
+ if(currentBtnd.getKind() == HfsPlusConstants.BT_LEAF_NODE) {
+ CatalogLeafNode leaf = new CatalogLeafNode(currentBtnd, buffer.array(), currentNodeSize);
+ LeafRecord lr = leaf.find(parentID);
+ log.debug("Leaf record :\n" + lr.toString());
+ return lr;
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,10 @@
+package org.jnode.fs.hfsplus.catalog;
+
+public class CatalogFile {
+ private byte[] data;
+
+ public CatalogFile(byte[] src){
+ data = new byte[248];
+ System.arraycopy(src, 0, data, 0, 248);
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2008-01-31 15:28:12 UTC (rev 3740)
@@ -0,0 +1,10 @@
+package org.jnode.fs.hfsplus.catalog;
+
+public class CatalogFolder {
+ private byte[] data;
+
+ public CatalogFolder(byte[] src){
+ data = new byte[88];
+ System.arraycopy(src, 0, data, 0, 88);
+ }
+}
Added: trunk/fs/src/fs/org/j...
[truncated message content] |
|
From: <fd...@us...> - 2008-02-05 22:55:00
|
Revision: 3761
http://jnode.svn.sourceforge.net/jnode/?rev=3761&view=rev
Author: fduminy
Date: 2008-02-05 14:54:57 -0800 (Tue, 05 Feb 2008)
Log Message:
-----------
in all FileSystemType implementations : replaced ID attribute by a getInstance() method
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.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/HfsPlusFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java
trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java
trunk/fs/src/fs/org/jnode/fs/util/FSUtils.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -26,10 +26,9 @@
import org.jnode.driver.Device;
import org.jnode.driver.block.FSBlockDeviceAPI;
-import org.jnode.fs.FileSystem;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.fs.FileSystemException;
-import org.jnode.fs.FileSystemType;
-import org.jnode.fs.BlockDeviceFileSystemType;
+import org.jnode.fs.util.FSUtils;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -39,7 +38,10 @@
*/
public class Ext2FileSystemType implements BlockDeviceFileSystemType<Ext2FileSystem> {
- public static final Class<Ext2FileSystemType> ID = Ext2FileSystemType.class;
+ public static Ext2FileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(Ext2FileSystemType.class);
+ }
/**
* @see org.jnode.fs.FileSystemType#create(Device, boolean)
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -23,9 +23,9 @@
import org.jnode.driver.Device;
import org.jnode.driver.block.FSBlockDeviceAPI;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.fs.FileSystemException;
-import org.jnode.fs.FileSystemType;
-import org.jnode.fs.BlockDeviceFileSystemType;
+import org.jnode.fs.util.FSUtils;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -35,9 +35,12 @@
*/
public class FatFileSystemType implements BlockDeviceFileSystemType<FatFileSystem> {
- /** Name of this filesystem type */
- public static final Class<FatFileSystemType> ID = FatFileSystemType.class;
+ public static FatFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(FatFileSystemType.class);
+ }
+
/**
* Gets the unique name of this file system type.
*/
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -21,18 +21,20 @@
package org.jnode.fs.ftpfs;
+import org.jnode.driver.Device;
+import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.fs.FileSystem;
-import org.jnode.fs.FileSystemException;
-import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
-import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.fs.util.FSUtils;
/**
* @author Levente S\u00e1ntha
*/
public class FTPFileSystemType implements FileSystemType<FTPFileSystem> {
- public static final Class<FTPFileSystemType> ID = FTPFileSystemType.class;
+ public static FTPFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(FTPFileSystemType.class);
+ }
+
/**
* Create a filesystem from a given device.
*
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/command/FTPMountCommand.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -73,7 +73,7 @@
final DeviceManager dm = DeviceUtils.getDeviceManager();
dm.register(dev);
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
- FTPFileSystemType type = fss.getFileSystemType(FTPFileSystemType.ID);
+ FTPFileSystemType type = FTPFileSystemType.getInstance();
final FTPFileSystem fs = type.create(dev, true);
fss.registerFileSystem(fs);
fss.mount(mount_point, fs, null);
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -7,13 +7,19 @@
import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.fs.FileSystemException;
+import org.jnode.fs.util.FSUtils;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
import org.jnode.util.BigEndian;
public class HfsPlusFileSystemType implements BlockDeviceFileSystemType<HfsPlusFileSystem> {
- public static final Class<HfsPlusFileSystemType> ID = HfsPlusFileSystemType.class;
+
+ public static HfsPlusFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(HfsPlusFileSystemType.class);
+ }
+
public HfsPlusFileSystem create(Device device, boolean readOnly)
throws FileSystemException {
HfsPlusFileSystem fs = new HfsPlusFileSystem(device, readOnly);
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -26,10 +26,9 @@
import org.jnode.driver.Device;
import org.jnode.driver.block.FSBlockDeviceAPI;
-import org.jnode.fs.FileSystem;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.fs.FileSystemException;
-import org.jnode.fs.FileSystemType;
-import org.jnode.fs.BlockDeviceFileSystemType;
+import org.jnode.fs.util.FSUtils;
import org.jnode.partitions.PartitionTableEntry;
/**
@@ -37,7 +36,10 @@
*/
public class ISO9660FileSystemType implements BlockDeviceFileSystemType<ISO9660FileSystem> {
- public static final Class<ISO9660FileSystemType> ID = ISO9660FileSystemType.class;
+ public static ISO9660FileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(ISO9660FileSystemType.class);
+ }
public final String getName() {
return "ISO9660";
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -22,12 +22,10 @@
package org.jnode.fs.jarfs;
import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.driver.block.JarFileDevice;
-import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.fs.util.FSUtils;
/**
*
@@ -35,6 +33,10 @@
*
*/
public class JarFileSystemType implements FileSystemType<JarFileSystem> {
+ public static JarFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(JarFileSystemType.class);
+ }
public static final Class<JarFileSystemType> ID = JarFileSystemType.class;
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -21,12 +21,11 @@
*/
package org.jnode.fs.jfat;
-import org.apache.log4j.Logger;
import org.jnode.driver.Device;
import org.jnode.driver.block.FSBlockDeviceAPI;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.fs.FileSystemException;
-import org.jnode.fs.FileSystemType;
-import org.jnode.fs.BlockDeviceFileSystemType;
+import org.jnode.fs.util.FSUtils;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -37,9 +36,13 @@
* @author Tango
*/
public class FatFileSystemType implements BlockDeviceFileSystemType<FatFileSystem> {
- public static final Class<FatFileSystemType> ID=FatFileSystemType.class;
+ public static FatFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(FatFileSystemType.class);
+ }
+
public String getName() {
return "JFAT";
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -23,19 +23,19 @@
import org.apache.log4j.Logger;
import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
-import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.fs.util.FSUtils;
/**
* @author Andreas H\u00e4nel
*/
public class JIFileSystemType implements FileSystemType<JIFileSystem> {
+ public static JIFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(JIFileSystemType.class);
+ }
- /** Name of this filesystem type */
- public static final Class<JIFileSystemType> ID = JIFileSystemType.class;
public static final String VIRTUAL_DEVICE_NAME = "jifs";
/** Logger*/
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -70,12 +70,12 @@
protected void startPlugin() throws PluginException {
log.info("start jifs");
try {
- FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
- JIFileSystemType type = fSS.getFileSystemType(JIFileSystemType.ID);
+ JIFileSystemType type = JIFileSystemType.getInstance();
try {
VirtualDevice dev = VirtualDeviceFactory.createDevice(JIFileSystemType.VIRTUAL_DEVICE_NAME);
log.info(dev.getId() + " registered");
final JIFileSystem fs = type.create(dev, true);
+ final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
fSS.registerFileSystem(fs);
final String mountPath = "jifs";
@@ -100,8 +100,6 @@
} catch (NameNotFoundException e) {
log.error("filsystemservice / filesystemtype not found");
- } catch (FileSystemException e) {
- log.error(e);
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -141,8 +141,7 @@
dm.register(dev);
final FileSystemService fss = InitialNaming
.lookup(FileSystemService.NAME);
- NFS2FileSystemType type = fss
- .getFileSystemType(NFS2FileSystemType.ID);
+ NFS2FileSystemType type = NFS2FileSystemType.getInstance();
final NFS2FileSystem fs = type.create(dev, readOnly);
fss.registerFileSystem(fs);
fss.mount(mount_point, fs, null);
Modified: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -22,20 +22,22 @@
package org.jnode.fs.nfs.nfs2;
import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.fs.util.FSUtils;
/**
* @author Andrei Dore
*/
public class NFS2FileSystemType implements FileSystemType<NFS2FileSystem> {
- public static final Class<NFS2FileSystemType> ID = NFS2FileSystemType.class;
+ public static NFS2FileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(NFS2FileSystemType.class);
+ }
/**
* Create a filesystem from a given device.
- *
+ *
* @param device
* @param readOnly
*/
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -23,10 +23,9 @@
import org.jnode.driver.Device;
import org.jnode.driver.block.FSBlockDeviceAPI;
-import org.jnode.fs.FileSystem;
+import org.jnode.fs.BlockDeviceFileSystemType;
import org.jnode.fs.FileSystemException;
-import org.jnode.fs.FileSystemType;
-import org.jnode.fs.BlockDeviceFileSystemType;
+import org.jnode.fs.util.FSUtils;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTypes;
@@ -37,7 +36,10 @@
*/
public class NTFSFileSystemType implements BlockDeviceFileSystemType<NTFSFileSystem> {
- public static final Class<NTFSFileSystemType> ID = NTFSFileSystemType.class;
+ public static NTFSFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(NTFSFileSystemType.class);
+ }
public static final String TAG = "NTFS";
Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -1,10 +1,9 @@
package org.jnode.fs.ramfs;
import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.fs.util.FSUtils;
/**
* FileSystemType for RAMFS, a filesystem implementation in system RAM
@@ -15,8 +14,10 @@
private static final int DEFAULT_SIZE = 104857600;
- /** the name of this filesystem */
- public static final Class<RAMFileSystemType> ID = RAMFileSystemType.class;
+ public static RAMFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(RAMFileSystemType.class);
+ }
/** Virtual Device name for this filesystem */
public static final String VIRTUAL_DEVICE_NAME = "ramfsdevice";
Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/ramfs/def/RAMFSPlugin.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -51,7 +51,7 @@
try {
FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
- RAMFileSystemType type = fSS.getFileSystemType(RAMFileSystemType.ID);
+ RAMFileSystemType type = RAMFileSystemType.getInstance();
try {
@@ -83,8 +83,6 @@
}
} catch (NameNotFoundException e){
log.error("filsystemservice / filesystemtype not found");
- } catch (FileSystemException e){
- log.error(e);
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -22,16 +22,18 @@
package org.jnode.fs.smbfs;
import org.jnode.driver.Device;
-import org.jnode.driver.block.FSBlockDeviceAPI;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.fs.util.FSUtils;
/**
* @author Levente S\u00e1ntha
*/
public class SMBFileSystemType implements FileSystemType<SMBFileSystem> {
- public static final Class<SMBFileSystemType> ID = SMBFileSystemType.class;
+ public static SMBFileSystemType getInstance()
+ {
+ return FSUtils.getFileSystemType(SMBFileSystemType.class);
+ }
/**
* Create a filesystem from a given device.
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/command/SMBMountCommand.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -76,7 +76,7 @@
final DeviceManager dm = DeviceUtils.getDeviceManager();
dm.register(dev);
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
- SMBFileSystemType type = fss.getFileSystemType(SMBFileSystemType.ID);
+ SMBFileSystemType type = SMBFileSystemType.getInstance();
final SMBFileSystem fs = type.create(dev, true);
fss.registerFileSystem(fs);
fss.mount(mount_point, fs, null);
Modified: trunk/fs/src/fs/org/jnode/fs/util/FSUtils.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/util/FSUtils.java 2008-02-05 22:28:59 UTC (rev 3760)
+++ trunk/fs/src/fs/org/jnode/fs/util/FSUtils.java 2008-02-05 22:54:57 UTC (rev 3761)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.util;
import java.io.IOException;
@@ -26,26 +26,34 @@
import java.text.SimpleDateFormat;
import java.util.Date;
+import javax.naming.NameNotFoundException;
+
import org.apache.log4j.Logger;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
import org.jnode.fs.FSFile;
+import org.jnode.fs.FileSystem;
+import org.jnode.fs.FileSystemException;
+import org.jnode.fs.FileSystemType;
+import org.jnode.fs.ftpfs.FTPFileSystemType;
+import org.jnode.fs.service.FileSystemService;
+import org.jnode.naming.InitialNaming;
/**
- *
+ *
* @author Fabien DUMINY
*/
-public class FSUtils {
+public class FSUtils {
- private static final Logger log = Logger.getLogger(FSUtils.class);
+ private static final Logger log = Logger.getLogger(FSUtils.class);
private static final int MAX_DUMP_SIZE = 256;
private static final int LINE_SIZE = 16;
-
+
protected static DateFormat dateFormat = new SimpleDateFormat();
-
+
/**
* @param path
* @param separator
@@ -55,25 +63,25 @@
int idx = path.lastIndexOf(separator);
if(idx >= 0) {
path = path.substring(idx+1);
- }
+ }
return path;
}
/**
* @param path
* @param separator
- * @return
+ * @return
*/
public static String getParentName(String path, char separator) {
int idx = path.lastIndexOf(separator);
if(idx < 0) {
path = "";
} else {
- path = path.substring(0, idx);
+ path = path.substring(0, idx);
}
return path;
}
-
+
/**
* @param entry
* @param deep
@@ -82,8 +90,8 @@
public static String toString(FSEntry entry, boolean deep) {
if(entry == null)
return "<FSEntry>NULL</FSEntry>";
-
- StringBuilder sb = new StringBuilder(2048);
+
+ StringBuilder sb = new StringBuilder(2048);
sb.append("<FSEntry>");
sb.append(" name="+entry.getName());
try {
@@ -99,7 +107,7 @@
log.error("error in isDirty", e1);
}
sb.append(" isValid="+entry.isValid());
-
+
sb.append(" isFile="+entry.isFile());
if(deep && entry.isFile()) {
try {
@@ -107,10 +115,10 @@
} catch (IOException e2) {
sb.append(" getFile=###"+e2.getMessage()+"###");
log.error("error in getFile", e2);
- }
+ }
}
- sb.append(" isDir="+entry.isDirectory());
+ sb.append(" isDir="+entry.isDirectory());
if(deep && entry.isDirectory())
try {
sb.append(toString(entry.getDirectory()));
@@ -119,7 +127,7 @@
log.error("error in getDirectory", e3);
}
sb.append("</FSEntry>");
-
+
return sb.toString();
}
@@ -141,32 +149,32 @@
public static String toString(FSDirectory dir, boolean deep) throws IOException {
if(dir == null)
return "<FSDirectory>NULL</FSDirectory>";
-
+
String str = "<FSDirectory>isValid="+dir.isValid()+"</FSDirectory>";
if(deep)
str += "\n" + dir.toString(); // also print entry table
-
+
return str;
}
-
+
/**
* @param file
* @return
*/
- public static String toString(FSFile file) {
+ public static String toString(FSFile file) {
if(file == null)
return "<FSEntry>NULL</FSEntry>";
-
+
StringBuilder sb = new StringBuilder(32);
sb.append("<FSFile>");
sb.append(" isValid"+file.isValid());
sb.append(" length"+file.getLength());
sb.append("</FSFile>");
-
+
return sb.toString();
}
-
+
/**
* @param str
* @param date
@@ -175,7 +183,7 @@
public static String toStringDate(String str, long date) {
return toString(str, new Date(date));
}
-
+
/**
* @param str
* @param date
@@ -184,7 +192,7 @@
public static String toString(String str, Date date) {
return str + dateFormat.format(date);
}
-
+
/**
* @param data
* @return
@@ -192,7 +200,7 @@
public static String toString(byte[] data) {
return toString(data, 0, data.length);
}
-
+
/**
* @param data
* @param offset
@@ -202,32 +210,32 @@
public static String toString(byte[] data, int offset, int length) {
StringBuilder sb = new StringBuilder(1024);
StringBuilder chars = new StringBuilder(LINE_SIZE);
-
+
int l = Math.min(Math.min(length - offset, data.length - offset),
MAX_DUMP_SIZE);
int mod = l % LINE_SIZE;
if(mod != 0) l += LINE_SIZE - mod;
-
+
for(int i = 0 ; i < l ; i++) {
if((i % 16) == 0) {
sb.append(lpad(Integer.toHexString(i), 4)).append(" - ");
chars.setLength(0); // empty
}
-
+
int idx = offset + i;
- boolean end = (idx >= data.length);
+ boolean end = (idx >= data.length);
if(!end) {
sb.append(lpad(Integer.toHexString(data[idx]),2)).append(' ');
chars.append((char) data[idx]);
}
-
+
if(((i % 16) == 15) || end) {
sb.append(" ").append(chars.toString()).append('\n');
}
}
return sb.toString();
}
-
+
/**
* @param str
* @param size
@@ -241,10 +249,10 @@
int nbBlanks = size - str.length();
for(int i = 0 ; i < nbBlanks ; i++ )
pad += " ";
-
+
return pad + str;
}
-
+
/**
* @param data
* @param offset
@@ -257,7 +265,20 @@
for(int i = offset ; i < l ; i++) {
sb.append((char) data[i]);
}
-
+
return sb.toString();
- }
+ }
+
+ public static <T extends FileSystemType<? extends FileSystem<?>>> T getFileSystemType(Class<T> typeClass)
+ {
+ try {
+ final FileSystemService fss = InitialNaming
+ .lookup(FileSystemService.NAME);
+ return fss.getFileSystemType(typeClass);
+ } catch (NameNotFoundException e) {
+ throw new RuntimeException(typeClass.getName() + " not properly registered", e);
+ } catch (FileSystemException e) {
+ throw new RuntimeException("internal error", e);
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fd...@us...> - 2008-02-05 22:56:14
|
Revision: 3762
http://jnode.svn.sourceforge.net/jnode/?rev=3762&view=rev
Author: fduminy
Date: 2008-02-05 14:56:13 -0800 (Tue, 05 Feb 2008)
Log Message:
-----------
added getType() method to FileSystem interface
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -30,6 +30,8 @@
*/
public interface FileSystem<T extends FSEntry> {
+ public FileSystemType<? extends FileSystem<T>> getType();
+
/**
* Gets the device this FS driver operates on.
*/
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -37,6 +37,7 @@
import org.jnode.fs.ext2.cache.Block;
import org.jnode.fs.ext2.cache.BlockCache;
import org.jnode.fs.ext2.cache.INodeCache;
+import org.jnode.fs.smbfs.SMBFileSystemType;
import org.jnode.fs.spi.AbstractFileSystem;
/**
@@ -84,6 +85,10 @@
//superblockLock = new Object();
}
+ final public Ext2FileSystemType getType() {
+ return Ext2FileSystemType.getInstance();
+ }
+
public void read() throws FileSystemException {
ByteBuffer data;
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -90,6 +90,10 @@
}
}
+ final public FatFileSystemType getType() {
+ return FatFileSystemType.getInstance();
+ }
+
/**
* Flush all changed structures to the device.
*
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -26,24 +26,29 @@
import org.jnode.driver.Device;
import java.io.IOException;
+import java.text.ParseException;
import java.util.Date;
import java.security.PrivilegedAction;
import java.security.AccessController;
import com.enterprisedt.net.ftp.FTPClient;
+import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.net.ftp.FTPFile;
/**
* @author Levente S\u00e1ntha
*/
-public class FTPFileSystem extends FTPClient implements FileSystem<FTPFSDirectory> {
+public class FTPFileSystem implements FileSystem<FTPFSDirectory> {
private FTPFSDevice device;
private FTPFSDirectory root;
private boolean closed;
private Thread thread;
+ final private FTPClient client;
+
public FTPFileSystem(final FTPFSDevice device) {
+ this.client = new FTPClient();
this.device = device;
device.addListener(new DeviceListener() {
public void deviceStarted(Device device) {
@@ -60,13 +65,13 @@
});
try{
- setRemoteHost(device.getHost());
- setTimeout(300000);
+ client.setRemoteHost(device.getHost());
+ client.setTimeout(300000);
AccessController.doPrivileged(
new PrivilegedAction(){
public Object run() {
try{
- connect();
+ client.connect();
return null;
}catch(Exception e){
throw new RuntimeException(e);
@@ -74,7 +79,7 @@
}
});
- login(device.getUser(),device.getPassword());
+ client.login(device.getUser(),device.getPassword());
thread = new Thread(new Runnable(){
public void run() {
try{
@@ -103,8 +108,12 @@
}
+ final public FTPFileSystemType getType() {
+ return FTPFileSystemType.getInstance();
+ }
+
private synchronized void nop() throws Exception{
- dir(root.path());
+ client.dir(root.path());
}
@@ -119,7 +128,7 @@
try {
closed = true;
thread = null;
- quit();
+ client.quit();
} catch(Exception e){
throw new IOException("Close error");
}
@@ -169,4 +178,16 @@
// TODO implement me
return 0;
}
+
+ FTPFile[] dirDetails(String path) throws IOException, FTPException, ParseException {
+ return client.dirDetails(path);
+ }
+
+ void chdir(String path) throws IOException, FTPException {
+ client.chdir(path);
+ }
+
+ byte[] get(String name) throws IOException, FTPException {
+ return client.get(name);
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -19,13 +19,17 @@
private final Logger log = Logger.getLogger(getClass());
private Superblock sb;
-
+
private Catalog catalog;
public HfsPlusFileSystem(Device device, boolean readOnly) throws FileSystemException {
super(device, readOnly);
}
+ final public HfsPlusFileSystemType getType() {
+ return HfsPlusFileSystemType.getInstance();
+ }
+
public void read() throws FileSystemException {
sb = new Superblock(this);
log.debug("Superblock informations :\n" + sb.toString());
@@ -57,7 +61,7 @@
public long getFreeSpace() {
return sb.getFreeBlocks() * sb.getBlockSize();
}
-
+
public long getTotalSpace() {
return sb.getTotalBlocks() * sb.getBlockSize();
}
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -56,6 +56,10 @@
}
}
+ final public ISO9660FileSystemType getType() {
+ return ISO9660FileSystemType.getInstance();
+ }
+
/**
* @see org.jnode.fs.FileSystem#getRootEntry()
*/
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -29,6 +29,7 @@
import org.jnode.fs.FSEntry;
import org.jnode.fs.FSFile;
import org.jnode.fs.FileSystemException;
+import org.jnode.fs.iso9660.ISO9660FileSystemType;
import org.jnode.fs.spi.AbstractFileSystem;
/**
@@ -54,6 +55,10 @@
rootEntry = FSTreeBuilder.build(this, jarFile, cache);
}
+ final public JarFileSystemType getType() {
+ return JarFileSystemType.getInstance();
+ }
+
public JarFile getJarFile()
{
return jarFile;
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -18,6 +18,7 @@
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSFile;
import org.jnode.fs.FileSystemException;
+import org.jnode.fs.ext2.Ext2FileSystemType;
import org.jnode.fs.spi.AbstractFileSystem;
@@ -55,6 +56,9 @@
this ( device, "ISO_8859_1", readOnly );
}
+ final public FatFileSystemType getType() {
+ return FatFileSystemType.getInstance();
+ }
public int getClusterSize() {
return fat.getClusterSize();
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -30,6 +30,7 @@
import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.jifs.directories.JIFSDrootDir;
+import org.jnode.fs.nfs.nfs2.NFS2FileSystemType;
/**
* @author Andreas H\u00e4nel
@@ -55,6 +56,10 @@
//}
}
+ final public JIFileSystemType getType() {
+ return JIFileSystemType.getInstance();
+ }
+
/**
* Is the filesystem mounted in readonly mode ?
*/
Modified: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -116,11 +116,15 @@
}
+ final public NFS2FileSystemType getType() {
+ return NFS2FileSystemType.getInstance();
+ }
+
/**
* 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 void close() throws IOException {
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -56,6 +56,10 @@
}
}
+ final public NTFSFileSystemType getType() {
+ return NTFSFileSystemType.getInstance();
+ }
+
/**
* @see org.jnode.fs.FileSystem#getRootEntry()
*/
Modified: trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java 2008-02-05 22:54:57 UTC (rev 3761)
+++ trunk/fs/src/fs/org/jnode/fs/ramfs/RAMFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
@@ -6,6 +6,7 @@
import org.jnode.fs.FSEntry;
import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
+import org.jnode.fs.smbfs.SMBFileSystemType;
/**
* A Filesystem implementation in the system RAM.
@@ -41,6 +42,10 @@
root = new RAMDirectory(this, null, "");
}
+ final public RAMFileSystemType getType() {
+ return RAMFileSystemType.getInstance();
+ }
+
/**
* (non-Javadoc)
* @see org.jnode.fs.FileSystem#getDevice()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fd...@us...> - 2008-02-05 22:56:56
|
Revision: 3763
http://jnode.svn.sourceforge.net/jnode/?rev=3763&view=rev
Author: fduminy
Date: 2008-02-05 14:56:51 -0800 (Tue, 05 Feb 2008)
Log Message:
-----------
added getType() method to FileSystem interface
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java 2008-02-05 22:56:13 UTC (rev 3762)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java 2008-02-05 22:56:51 UTC (rev 3763)
@@ -27,6 +27,7 @@
import org.jnode.driver.Device;
import org.jnode.fs.FSEntry;
import org.jnode.fs.FileSystem;
+import org.jnode.fs.FileSystemType;
/**
* @author Ewout Prangsma (ep...@us...)
@@ -37,6 +38,11 @@
private final Device dev;
private final VirtualDirEntry root;
+ final public FileSystemType<FileSystem<VirtualDirEntry>> getType()
+ {
+ throw new UnsupportedOperationException("should not be called");
+ }
+
/**
* Initialize this instance.
* @throws IOException
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-02-05 22:56:13 UTC (rev 3762)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-02-05 22:56:51 UTC (rev 3763)
@@ -21,14 +21,14 @@
package org.jnode.fs.smbfs;
-import org.jnode.fs.FileSystem;
-
import java.io.IOException;
import jcifs.smb.NtlmAuthenticator;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
+import org.jnode.fs.FileSystem;
+
/**
* @author Levente S\u00e1ntha
*/
@@ -47,6 +47,10 @@
}
}
+ final public SMBFileSystemType getType() {
+ return SMBFileSystemType.getInstance();
+ }
+
protected NtlmPasswordAuthentication getNtlmPasswordAuthentication() {
return new NtlmPasswordAuthentication( "", device.getUser(), device.getPassword() );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2008-06-05 14:26:20
|
Revision: 4201
http://jnode.svn.sourceforge.net/jnode/?rev=4201&view=rev
Author: crawley
Date: 2008-06-05 07:26:18 -0700 (Thu, 05 Jun 2008)
Log Message:
-----------
Fixes for Java compilation warnings and CheckStyle warnings
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java
trunk/fs/src/fs/org/jnode/fs/FSDirectory.java
trunk/fs/src/fs/org/jnode/fs/FSEntry.java
trunk/fs/src/fs/org/jnode/fs/FSEntryTableIgnoreCase.java
trunk/fs/src/fs/org/jnode/fs/FSFile.java
trunk/fs/src/fs/org/jnode/fs/FSObject.java
trunk/fs/src/fs/org/jnode/fs/FileSystem.java
trunk/fs/src/fs/org/jnode/fs/FileSystemException.java
trunk/fs/src/fs/org/jnode/fs/FileSystemFullException.java
trunk/fs/src/fs/org/jnode/fs/FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/Formatter.java
trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java
trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java
trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java
trunk/fs/src/fs/org/jnode/fs/command/CdCommand.java
trunk/fs/src/fs/org/jnode/fs/command/CpCommand.java
trunk/fs/src/fs/org/jnode/fs/command/DFCommand.java
trunk/fs/src/fs/org/jnode/fs/command/DeleteCommand.java
trunk/fs/src/fs/org/jnode/fs/command/DirCommand.java
trunk/fs/src/fs/org/jnode/fs/command/EjectCommand.java
trunk/fs/src/fs/org/jnode/fs/command/HexdumpCommand.java
trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java
trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
trunk/fs/src/fs/org/jnode/fs/command/PwdCommand.java
trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Directory.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Driver.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java
Modified: trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/BlockDeviceFileSystemType.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -26,18 +26,17 @@
/**
* Specific kind of FileSystemType for block devices
- *
+ *
* @author epr
*/
public interface BlockDeviceFileSystemType<T extends FileSystem<?>> extends FileSystemType<T> {
- /**
- * Can this file system type be used on the given first sector of a
- * blockdevice?
- *
- * @param pte
- * The partition table entry, if any. If null, there is no
- * partition table entry.
- * @param firstSector
- */
- public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi);
+ /**
+ * Can this file system type be used on the given first sector of a
+ * blockdevice?
+ *
+ * @param pte The partition table entry, if any. If null, there is no
+ * partition table entry.
+ * @param firstSector
+ */
+ public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi);
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FSAccessRights.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -30,23 +30,23 @@
* @author epr
*/
public interface FSAccessRights extends FSObject {
-
- /**
- * Gets the owner of the entry.
- * @throws IOException
- */
- public Principal getOwner()
- throws IOException;
- public boolean canRead();
+ /**
+ * Gets the owner of the entry.
+ *
+ * @throws IOException
+ */
+ public Principal getOwner() throws IOException;
- public boolean canWrite();
+ public boolean canRead();
- public boolean canExecute();
+ public boolean canWrite();
- public boolean setReadable(boolean enable, boolean owneronly);
+ public boolean canExecute();
- public boolean setWritable(boolean enable, boolean owneronly);
+ public boolean setReadable(boolean enable, boolean owneronly);
- public boolean setExecutable(boolean enable, boolean owneronly);
+ public boolean setWritable(boolean enable, boolean owneronly);
+
+ public boolean setExecutable(boolean enable, boolean owneronly);
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSDirectory.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FSDirectory.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -28,51 +28,50 @@
* @author epr
*/
public interface FSDirectory extends FSObject {
-
- /**
- * Gets an iterator used to iterate over all the entries of this
- * directory.
- * All elements returned by the iterator must be instanceof FSEntry.
- */
- public Iterator<? extends FSEntry> iterator()
- throws IOException;
-
- /**
- * Gets the entry with the given name.
- * @param name
- * @throws IOException
- */
- public FSEntry getEntry(String name)
- throws IOException;
-
- /**
- * Add a new file with a given name to this directory.
- * @param name
- * @throws IOException
- */
- public FSEntry addFile(String name)
- throws IOException;
- /**
- * Add a new (sub-)directory with a given name to this directory.
- * @param name
- * @throws IOException
- */
- public FSEntry addDirectory(String name)
- throws IOException;
-
- /**
- * Remove the entry with the given name from this directory.
- * @param name
- * @throws IOException
- */
- public void remove(String name)
- throws IOException;
-
- /**
- * Save all dirty (unsaved) data to the device
- * @throws IOException
- */
- public void flush() throws IOException;
+ /**
+ * Gets an iterator used to iterate over all the entries of this directory.
+ * All elements returned by the iterator must be instanceof FSEntry.
+ */
+ public Iterator<? extends FSEntry> iterator() throws IOException;
+ /**
+ * Gets the entry with the given name.
+ *
+ * @param name
+ * @throws IOException
+ */
+ public FSEntry getEntry(String name) throws IOException;
+
+ /**
+ * Add a new file with a given name to this directory.
+ *
+ * @param name
+ * @throws IOException
+ */
+ public FSEntry addFile(String name) throws IOException;
+
+ /**
+ * Add a new (sub-)directory with a given name to this directory.
+ *
+ * @param name
+ * @throws IOException
+ */
+ public FSEntry addDirectory(String name) throws IOException;
+
+ /**
+ * Remove the entry with the given name from this directory.
+ *
+ * @param name
+ * @throws IOException
+ */
+ public void remove(String name) throws IOException;
+
+ /**
+ * Save all dirty (unsaved) data to the device
+ *
+ * @throws IOException
+ */
+ public void flush() throws IOException;
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSEntry.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FSEntry.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -19,6 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
package org.jnode.fs;
import java.io.IOException;
@@ -28,80 +29,79 @@
*/
/**
* Entry of an FSDirectory.
+ *
* @author epr
*/
public interface FSEntry extends FSObject {
-
- /**
- * Gets the name of this entry.
- */
- public String getName();
-
- /**
- * Gets the directory this entry is a part of.
- */
- public FSDirectory getParent();
-
- /**
- * Gets the last modification time of this entry.
- * @throws IOException
- */
- public long getLastModified()
- throws IOException;
+ /**
+ * Gets the name of this entry.
+ */
+ public String getName();
- /**
- * Is this entry refering to a file?
- */
- public boolean isFile();
+ /**
+ * Gets the directory this entry is a part of.
+ */
+ public FSDirectory getParent();
- /**
- * Is this entry refering to a (sub-)directory?
- */
- public boolean isDirectory();
+ /**
+ * Gets the last modification time of this entry.
+ *
+ * @throws IOException
+ */
- /**
- * Sets the name of this entry.
- */
- public void setName(String newName)
- throws IOException;
-
- /**
- * Gets the last modification time of this entry.
- * @throws IOException
- */
- public void setLastModified(long lastModified)
- throws IOException;
-
- /**
- * Gets the file this entry refers to. This method can only be called
- * if <code>isFile</code> returns true.
- *
- * @return The file described by this entry
- */
- public FSFile getFile()
- throws IOException;
+ public long getLastModified() throws IOException;
- /**
- * Gets the directory this entry refers to. This method can only be called
- * if <code>isDirectory</code> returns true.
- *
- * @return The directory described by this entry
- */
- public FSDirectory getDirectory()
- throws IOException;
-
- /**
- * Gets the accessrights for this entry.
- * @throws IOException
- */
- public FSAccessRights getAccessRights()
- throws IOException;
-
- /**
- * Indicate if the entry has been modified in memory (ie need to be saved)
- * @return true if the entry need to be saved
- * @throws IOException
- */
- public boolean isDirty() throws IOException;
+ /**
+ * Is this entry refering to a file?
+ */
+ public boolean isFile();
+
+ /**
+ * Is this entry refering to a (sub-)directory?
+ */
+ public boolean isDirectory();
+
+ /**
+ * Sets the name of this entry.
+ */
+ public void setName(String newName) throws IOException;
+
+ /**
+ * Gets the last modification time of this entry.
+ *
+ * @throws IOException
+ */
+ public void setLastModified(long lastModified) throws IOException;
+
+ /**
+ * Gets the file this entry refers to. This method can only be called if
+ * <code>isFile</code> returns true.
+ *
+ * @return The file described by this entry
+ */
+ public FSFile getFile() throws IOException;
+
+ /**
+ * Gets the directory this entry refers to. This method can only be called
+ * if <code>isDirectory</code> returns true.
+ *
+ * @return The directory described by this entry
+ */
+ public FSDirectory getDirectory() throws IOException;
+
+ /**
+ * Gets the accessrights for this entry.
+ *
+ * @throws IOException
+ */
+ public FSAccessRights getAccessRights() throws IOException;
+
+ /**
+ * Indicate if the entry has been modified in memory (ie need to be saved)
+ *
+ * @return true if the entry need to be saved
+ * @throws IOException
+ */
+ public boolean isDirty() throws IOException;
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSEntryTableIgnoreCase.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSEntryTableIgnoreCase.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FSEntryTableIgnoreCase.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -23,32 +23,34 @@
import java.util.List;
-import org.jnode.fs.spi.*;
import org.jnode.fs.spi.AbstractFileSystem;
+import org.jnode.fs.spi.FSEntryTable;
/**
* A child class of FSEntryTable that ignore the case of entry names.
- *
+ *
* @author Fabien DUMINY
*/
public class FSEntryTableIgnoreCase extends FSEntryTable {
- /**
- * Construct a FSEntryTableIgnoreCase from a list of FSEntry
- * @param fs
- * @param entryList
- */
- public FSEntryTableIgnoreCase(AbstractFileSystem fs, List<FSEntry> entryList) {
- super(fs, entryList);
- }
-
- /**
- * To Ignore case, we convert all entry names to upper case
- */
- protected String normalizeName(String name)
- {
- if(name == null)
- return null;
-
- return name.toUpperCase();
- }
+
+ /**
+ * Construct a FSEntryTableIgnoreCase from a list of FSEntry
+ *
+ * @param fs
+ * @param entryList
+ */
+ public FSEntryTableIgnoreCase(AbstractFileSystem<?> fs, List<FSEntry> entryList) {
+ super(fs, entryList);
+ }
+
+ /**
+ * To Ignore case, we convert all entry names to upper case
+ */
+ protected String normalizeName(String name) {
+ if (name == null) {
+ return null;
+ }
+
+ return name.toUpperCase();
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSFile.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FSFile.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -25,57 +25,58 @@
import java.nio.ByteBuffer;
/**
- * A FSFile is a representation of a single block of bytes on a filesystem.
- * It is comparable to an inode in Unix.
+ * A FSFile is a representation of a single block of bytes on a filesystem. It
+ * is comparable to an inode in Unix.
*
- * An FSFile does not have any knownledge of who is using this file. It is also possible
- * that is system uses a single FSFile instances to create two inputstream's for
- * two different principals.
+ * An FSFile does not have any knowledge of who is using this file. It is also
+ * possible that the system uses a single FSFile instance to create two
+ * inputstream's for two different principals.
*
* @author epr
*/
public interface FSFile extends FSObject {
- /**
- * Gets the length (in bytes) of this file
- * @return long
- */
- public long getLength();
-
- /**
- * Sets the length of this file.
- * @param length
- * @throws IOException
- */
- public void setLength(long length)
- throws IOException;
+ /**
+ * Gets the length (in bytes) of this file
+ *
+ * @return long
+ */
+ public long getLength();
- /**
- * Read <code>len</code> bytes from the given position.
- * The read data is read fom this file starting at offset <code>fileOffset</code>
- * and stored in <code>dest</code> starting at offset <code>ofs</code>.
- * @param fileOffset
- * @param dest
- * @throws IOException
- */
- public void read(long fileOffset, ByteBuffer dest)
- throws IOException;
-
- /**
- * Write <code>len</code> bytes to the given position.
- * The data is read from <code>src</code> starting at offset
- * <code>ofs</code> and written to this file starting at offset <code>fileOffset</code>.
- * @param fileOffset
- * @param src
- * @throws IOException
- */
- public void write(long fileOffset, ByteBuffer src)
- throws IOException;
-
- /**
- * Flush any cached data to the disk.
- * @throws IOException
- */
- public void flush()
- throws IOException;
+ /**
+ * Sets the length of this file.
+ *
+ * @param length
+ * @throws IOException
+ */
+ public void setLength(long length) throws IOException;
+
+ /**
+ * Read <code>len</code> bytes from the given position. The read data is
+ * read fom this file starting at offset <code>fileOffset</code> and
+ * stored in <code>dest</code> starting at offset <code>ofs</code>.
+ *
+ * @param fileOffset
+ * @param dest
+ * @throws IOException
+ */
+ public void read(long fileOffset, ByteBuffer dest) throws IOException;
+
+ /**
+ * Write <code>len</code> bytes to the given position. The data is read
+ * from <code>src</code> starting at offset <code>ofs</code> and written
+ * to this file starting at offset <code>fileOffset</code>.
+ *
+ * @param fileOffset
+ * @param src
+ * @throws IOException
+ */
+ public void write(long fileOffset, ByteBuffer src) throws IOException;
+
+ /**
+ * Flush any cached data to the disk.
+ *
+ * @throws IOException
+ */
+ public void flush() throws IOException;
}
Modified: trunk/fs/src/fs/org/jnode/fs/FSObject.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSObject.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FSObject.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -18,28 +18,28 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs;
/**
- * This interface is the base interface objects that are part of a FileSystem.
- *
+ * This interface is the base interface for objects that are part of a FileSystem.
+ *
* @author epr
*/
public interface FSObject {
-
- /**
- * Is this object still valid.
- *
- * An object is not valid anymore if it has been removed from the filesystem.
- * All invocations on methods (exception this method) of invalid objects
- * must throw an IOException.
- */
- public boolean isValid();
-
- /**
- * Gets the filesystem to which this object belongs.
- */
- public FileSystem getFileSystem();
+ /**
+ * Is this object still valid.
+ *
+ * An object is not valid anymore if it has been removed from the
+ * filesystem. All invocations on methods (exception this method) of invalid
+ * objects must throw an IOException.
+ */
+ public boolean isValid();
+
+ /**
+ * Gets the filesystem to which this object belongs.
+ */
+ public FileSystem<?> getFileSystem();
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -30,7 +30,7 @@
*/
public interface FileSystem<T extends FSEntry> {
- public FileSystemType<? extends FileSystem<T>> getType();
+ public FileSystemType<? extends FileSystem<T>> getType();
/**
* Gets the device this FS driver operates on.
@@ -52,7 +52,7 @@
* Close this filesystem. After a close, all invocations of method of this
* filesystem or objects created by this filesystem will throw an
* IOException.
- *
+ *
* @throws IOException
*/
public void close() throws IOException;
@@ -62,9 +62,9 @@
*/
public boolean isClosed();
- public long getTotalSpace() throws IOException;
+ public long getTotalSpace() throws IOException;
- public long getFreeSpace() throws IOException;
+ public long getFreeSpace() throws IOException;
- public long getUsableSpace() throws IOException;
+ public long getUsableSpace() throws IOException;
}
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystemException.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystemException.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystemException.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -19,6 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
package org.jnode.fs;
/**
@@ -26,32 +27,32 @@
*/
public class FileSystemException extends Exception {
- /**
- *
- */
- public FileSystemException() {
- super();
- }
+ /**
+ *
+ */
+ public FileSystemException() {
+ super();
+ }
- /**
- * @param message
- * @param cause
- */
- public FileSystemException(String message, Throwable cause) {
- super(message, cause);
- }
+ /**
+ * @param message
+ * @param cause
+ */
+ public FileSystemException(String message, Throwable cause) {
+ super(message, cause);
+ }
- /**
- * @param cause
- */
- public FileSystemException(Throwable cause) {
- super(cause);
- }
+ /**
+ * @param cause
+ */
+ public FileSystemException(Throwable cause) {
+ super(cause);
+ }
- /**
- * @param s
- */
- public FileSystemException(String s) {
- super(s);
- }
+ /**
+ * @param s
+ */
+ public FileSystemException(String s) {
+ super(s);
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystemFullException.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystemFullException.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystemFullException.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -23,10 +23,9 @@
import java.io.IOException;
-public class FileSystemFullException extends IOException
-{
- public FileSystemFullException(String message)
- {
+public class FileSystemFullException extends IOException {
+
+ public FileSystemFullException(String message) {
super(message);
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystemType.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystemType.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -25,21 +25,21 @@
/**
* Descriptor and entry point for a class of filesystems.
- *
+ *
* @author epr
*/
public interface FileSystemType<T extends FileSystem<?>> {
- /**
- * Gets the unique name of this file system type.
- */
- public String getName();
+ /**
+ * Gets the unique name of this file system type.
+ */
+ public String getName();
- /**
- * Create a filesystem from a given device.
- *
- * @param device
- * @param readOnly
- */
- public T create(Device device, boolean readOnly) throws FileSystemException;
+ /**
+ * Create a filesystem from a given device.
+ *
+ * @param device
+ * @param readOnly
+ */
+ public T create(Device device, boolean readOnly) throws FileSystemException;
}
Modified: trunk/fs/src/fs/org/jnode/fs/Formatter.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/Formatter.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/Formatter.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -1,39 +1,35 @@
package org.jnode.fs;
import org.jnode.driver.Device;
-import org.jnode.fs.ext2.Ext2FileSystemType;
/**
- *
+ *
* @author Fabien DUMINY (fduminy at jnode.org)
- *
+ *
* @param <T>
*/
-abstract public class Formatter<T extends FileSystem<?>> implements Cloneable {
- private final FileSystemType<T> type;
+public abstract class Formatter<T extends FileSystem<?>> implements Cloneable {
+ private final FileSystemType<T> type;
- protected Formatter(FileSystemType<T> type)
- {
- this.type = type;
- }
+ protected Formatter(FileSystemType<T> type) {
+ this.type = type;
+ }
/**
* Format the given device
- *
+ *
* @param device The device we want to format
* @return the newly created FileSystem
* @throws FileSystemException
*/
- abstract public T format(Device device) throws FileSystemException;
+ public abstract T format(Device device) throws FileSystemException;
- final public FileSystemType<T> getFileSystemType()
- {
- return type;
- }
+ public final FileSystemType<T> getFileSystemType() {
+ return type;
+ }
- @SuppressWarnings("unchecked")
- public Formatter<T> clone() throws CloneNotSupportedException
- {
- return (Formatter<T>) super.clone();
- }
+ @SuppressWarnings("unchecked")
+ public Formatter<T> clone() throws CloneNotSupportedException {
+ return (Formatter<T>) super.clone();
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -29,25 +29,28 @@
* New exception allowing to handle cases where a FileSystem is mounted readOnly
*/
public class ReadOnlyFileSystemException extends IOException {
- /**
- * @param message
- * @param cause
- */
- public ReadOnlyFileSystemException(String message, Throwable cause) {
- super(message);
- initCause(cause);
- }
- /**
- * @param cause
- */
- public ReadOnlyFileSystemException(Throwable cause) {
- super();
- initCause(cause);
- }
- /**
- * @param message
- */
- public ReadOnlyFileSystemException(String message) {
- super(message);
- }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ReadOnlyFileSystemException(String message, Throwable cause) {
+ super(message);
+ initCause(cause);
+ }
+
+ /**
+ * @param cause
+ */
+ public ReadOnlyFileSystemException(Throwable cause) {
+ super();
+ initCause(cause);
+ }
+
+ /**
+ * @param message
+ */
+ public ReadOnlyFileSystemException(String message) {
+ super(message);
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -54,11 +54,10 @@
registerArguments(ARG_DEVICE);
}
- abstract protected Formatter<T> getFormatter();
+ protected abstract Formatter<T> getFormatter();
- final public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err)
- throws FileSystemException, NameNotFoundException, DeviceNotFoundException, DriverException {
+ public final void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ throws FileSystemException, NameNotFoundException, DeviceNotFoundException, DriverException {
Device dev = ARG_DEVICE.getValue();
Formatter<T> formatter = getFormatter();
formatter.format(dev);
Modified: trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/command/CatCommand.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -69,8 +69,7 @@
}
public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err)
- throws IOException {
+ PrintStream out, PrintStream err) throws IOException {
File[] files = ARG_FILE.getValues();
String[] urls = ARG_URL.getValues();
boolean ok = true;
@@ -82,14 +81,13 @@
is = url.openStream();
if (is == null) {
ok = false;
- }
- else {
+ } else {
process(is, out);
}
} catch (MalformedURLException ex) {
err.println("Malformed url '" + urlString + "': " + ex.getMessage());
} catch (IOException ex) {
- err.println("Can't fetch url '" + urlString + "': " + ex.getMessage());
+ err.println("Can't fetch url '" + urlString + "': " + ex.getMessage());
} finally {
if (is != null) {
try {
@@ -100,16 +98,14 @@
}
}
}
- }
- else if (files != null && files.length > 0) {
+ } else if (files != null && files.length > 0) {
for (File file : files) {
InputStream is = null;
try {
is = openFile(file, err);
if (is == null) {
ok = false;
- }
- else {
+ } else {
process(is, out);
}
} finally {
@@ -122,8 +118,7 @@
}
}
}
- }
- else {
+ } else {
process(in, out);
}
if (out.checkError()) {
@@ -163,14 +158,11 @@
// that the exception message is accurate and detailed!)
if (!file.exists()) {
err.println("File doesn't exist: '" + file + "'");
- }
- else if (!file.canRead()) {
+ } else if (!file.canRead()) {
err.println("File not readable: '" + file + "'");
- }
- else if (file.isDirectory()) {
+ } else if (file.isDirectory()) {
err.println("Can't 'cat' a directory: '" + file + "'");
- }
- else {
+ } else {
is = new FileInputStream(file);
}
return is;
Modified: trunk/fs/src/fs/org/jnode/fs/command/CdCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/CdCommand.java 2008-06-05 12:58:04 UTC (rev 4200)
+++ trunk/fs/src/fs/org/jnode/fs/command/CdCommand.java 2008-06-05 14:26:18 UTC (rev 4201)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.command;
import java.io.File;
@@ -29,8 +29,7 @@
import org.jnode.shell.AbstractCommand;
import org.jnode.shell.CommandLine;
import org.jnode.shell.syntax.Argument;
-import org.jnode.shell.syntax.FileArgument;
-import org.jnode.test.AnnotationTest.A;
+import org.jnode.shell.syntax.FileArgument;
/**
* The CdCommand class changes the current directory as given by the "user.dir" property.
@@ -41,37 +40,37 @@
*/
public class CdCommand extends AbstractCommand {
- private final FileArgument ARG_DIR = new FileArgument(
- "directory", Argument.OPTIONAL, "the directory to change to");
+ private final FileArgument ARG_DIR...
[truncated message content] |
|
From: <cr...@us...> - 2008-06-06 11:57:18
|
Revision: 4202
http://jnode.svn.sourceforge.net/jnode/?rev=4202&view=rev
Author: crawley
Date: 2008-06-06 04:57:12 -0700 (Fri, 06 Jun 2008)
Log Message:
-----------
Checkstyle fixes
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java
trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java
trunk/fs/src/fs/org/jnode/fs/ext2/BlockBitmap.java
trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java
trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2DirectoryRecord.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Print.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Utils.java
trunk/fs/src/fs/org/jnode/fs/ext2/FSBitmap.java
trunk/fs/src/fs/org/jnode/fs/ext2/GroupDescriptor.java
trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
trunk/fs/src/fs/org/jnode/fs/ext2/INodeBitmap.java
trunk/fs/src/fs/org/jnode/fs/ext2/INodeDescriptor.java
trunk/fs/src/fs/org/jnode/fs/ext2/INodeReservation.java
trunk/fs/src/fs/org/jnode/fs/ext2/INodeTable.java
trunk/fs/src/fs/org/jnode/fs/ext2/Superblock.java
trunk/fs/src/fs/org/jnode/fs/ext2/cache/Block.java
trunk/fs/src/fs/org/jnode/fs/ext2/cache/BlockCache.java
trunk/fs/src/fs/org/jnode/fs/ext2/cache/CacheEvent.java
trunk/fs/src/fs/org/jnode/fs/ext2/cache/CacheListener.java
trunk/fs/src/fs/org/jnode/fs/ext2/cache/INodeCache.java
trunk/fs/src/fs/org/jnode/fs/ext2/command/FormatExt2Command.java
trunk/fs/src/fs/org/jnode/fs/ext2/exception/UnallocatedBlockException.java
trunk/fs/src/fs/org/jnode/fs/ext2/test/command/CopyTest.java
trunk/fs/src/fs/org/jnode/fs/ext2/test/command/FillTest.java
trunk/fs/src/fs/org/jnode/fs/ext2/test/command/WriteTest.java
Modified: trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/command/MkdirCommand.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -57,6 +57,6 @@
if (!dir.mkdir()) {
err.println("Can't create directory.");
exit(1);
- }
+ }
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -75,8 +75,7 @@
String type = fs.getType().getName();
out.println(device.getId() + " on " + mountPoint + " type " + type + " (" + mode + ')');
}
- }
- else {
+ } else {
// Get the parameters
final Device dev = ARG_DEV.getValue();
final File mountPoint = ARG_DIR.getValue();
Modified: trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/command/TouchCommand.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -52,7 +52,7 @@
}
public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws Exception {
+ throws Exception {
File file = ARG_FILE.getValue();
if (!file.exists()) {
File parentFile = file.getParentFile();
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/BlockBitmap.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/BlockBitmap.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/BlockBitmap.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -25,84 +25,82 @@
* @author Andras Nagy
*/
public class BlockBitmap extends FSBitmap {
- /**
- * Test whether the block is free, and if yes:
- * - mark it as used
- * - prealloc the next free blocks, at most 7
- *
- * SYNCHRONIZATION:
- * BlockBitmap.testAndSetBlock() is not synchronized, so
- * Ext2FileSystem.testAndSetBlock() is synchronized to the bitmap block
- * it operates on.
- */
- protected static BlockReservation testAndSetBlock(byte[] data, int index) {
- if( isFree(data, index) ) {
- setBit(data, index);
- //do preallocation
- int j=0;
- while( (j<Ext2Constants.EXT2_PREALLOC_BLOCK) && isFree(data, index+1+j) ) {
- setBit(data, index+1+j);
- j++;
- }
- return new BlockReservation(true, index, j);
+ /**
+ * Test whether the block is free, and if yes: - mark it as used - prealloc
+ * the next free blocks, at most 7
+ *
+ * SYNCHRONIZATION: BlockBitmap.testAndSetBlock() is not synchronized, so
+ * Ext2FileSystem.testAndSetBlock() is synchronized to the bitmap block it
+ * operates on.
+ */
+ protected static BlockReservation testAndSetBlock(byte[] data, int index) {
+ if (isFree(data, index)) {
+ setBit(data, index);
+ // do preallocation
+ int j = 0;
+ while ((j < Ext2Constants.EXT2_PREALLOC_BLOCK) && isFree(data, index + 1 + j)) {
+ setBit(data, index + 1 + j);
+ j++;
+ }
+ return new BlockReservation(true, index, j);
- } else
- return new BlockReservation(false, -1, -1);
- }
+ } else
+ return new BlockReservation(false, -1, -1);
+ }
- /**
- * Find free blocks in the bitmap. First check
- * for a whole byte of free blocks (0x00) in the bitmap, then check for
- * any free bit. If a block is found, mark it as allocated.
- * If the following blocks are free, then they are preallocated (at most 7
- * blocks), but preallocation can't be performed over the group boundary
- * (because the bitmap data is only available for a single block group).
- *
- * SYNCHRONIZATION:
- * BlockBitmap.findFreeBlocks() is not synchronized, so
- * Ext2FileSystem.findFreeBlocks() is synchronized to the bitmap block
- * it operates on.
- */
- protected static BlockReservation findFreeBlocks(byte[] data, int metadataLength ) {
- //BlockReservation result;
- int nonfullBitmap=-1; //points to a nonfull byte in the bitmap
-
- //skip the metadata (superblock copy?, groupgrescriptor copies?, inode table)
- int first = (int)Ext2Utils.ceilDiv(metadataLength, 8);
-
- for(int i=first; i<data.length; i++) {
- if(data[i]==0x00) {
- //allocate the block and do preallocation
- //preallocate a fixed number of blocks (7)
- data[i]=(byte)0xFF;
- return new BlockReservation(true, ((long)i)*8, 7);
- }
-
- if((nonfullBitmap==-1) && (data[i]!=0xFF))
- nonfullBitmap=i;
- }
-
- //a full byte of 0x00 was not found in the bitmap:
- //go for any free bit
+ /**
+ * Find free blocks in the bitmap. First check for a whole byte of free
+ * blocks (0x00) in the bitmap, then check for any free bit. If a block is
+ * found, mark it as allocated. If the following blocks are free, then they
+ * are preallocated (at most 7 blocks), but preallocation can't be performed
+ * over the group boundary (because the bitmap data is only available for a
+ * single block group).
+ *
+ * SYNCHRONIZATION: BlockBitmap.findFreeBlocks() is not synchronized, so
+ * Ext2FileSystem.findFreeBlocks() is synchronized to the bitmap block it
+ * operates on.
+ */
+ protected static BlockReservation findFreeBlocks(byte[] data, int metadataLength) {
+ // BlockReservation result;
+ int nonfullBitmap = -1; // points to a nonfull byte in the bitmap
- // no free bit found:
- if(nonfullBitmap==-1)
- return new BlockReservation(false, -1, -1);
-
- // a free bit has been found:
- for(int i=0; i<8; i++)
- if(isFree(data[nonfullBitmap], i)) {
- setBit(data, nonfullBitmap, i);
- int block = nonfullBitmap*8 + i;
- //do preallocation:
- int j=0;
- while( (j<Ext2Constants.EXT2_PREALLOC_BLOCK) && isFree(data, block+1+j) ) {
- setBit(data, block+1+j);
- j++;
- }
- return new BlockReservation(true, block, j);
- }
-
- return new BlockReservation(false, -1, -1);
- }
+ // skip the metadata (superblock copy?, groupgrescriptor copies?, inode
+ // table)
+ int first = (int) Ext2Utils.ceilDiv(metadataLength, 8);
+
+ for (int i = first; i < data.length; i++) {
+ if (data[i] == 0x00) {
+ // allocate the block and do preallocation
+ // preallocate a fixed number of blocks (7)
+ data[i] = (byte) 0xFF;
+ return new BlockReservation(true, ((long) i) * 8, 7);
+ }
+
+ if ((nonfullBitmap == -1) && (data[i] != 0xFF))
+ nonfullBitmap = i;
+ }
+
+ // a full byte of 0x00 was not found in the bitmap:
+ // go for any free bit
+
+ // no free bit found:
+ if (nonfullBitmap == -1)
+ return new BlockReservation(false, -1, -1);
+
+ // a free bit has been found:
+ for (int i = 0; i < 8; i++)
+ if (isFree(data[nonfullBitmap], i)) {
+ setBit(data, nonfullBitmap, i);
+ int block = nonfullBitmap * 8 + i;
+ //do preallocation:
+ int j = 0;
+ while ((j < Ext2Constants.EXT2_PREALLOC_BLOCK) && isFree(data, block + 1 + j)) {
+ setBit(data, block + 1 + j);
+ j++;
+ }
+ return new BlockReservation(true, block, j);
+ }
+
+ return new BlockReservation(false, -1, -1);
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -22,76 +22,81 @@
package org.jnode.fs.ext2;
/**
- * Class used to return information to the INode when the FSBitmap
- * makes a reservation.
+ * Class used to return information to the INode when the FSBitmap makes a
+ * reservation.
*
* @author Andras Nagy
*/
public class BlockReservation {
- private long block;
- private int preallocCount;
- private boolean successful;
- private long freeBlocksCount;
-
- public BlockReservation(boolean successful, long block, int preallocCount) {
- this.successful = successful;
- this.block = block;
- this.preallocCount = preallocCount;
- }
+ private long block;
+ private int preallocCount;
+ private boolean successful;
+ private long freeBlocksCount;
- public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) {
- this.successful = successful;
- this.block = block;
- this.preallocCount = preallocCount;
- this.freeBlocksCount = freeBlocksCount;
- }
+ public BlockReservation(boolean successful, long block, int preallocCount) {
+ this.successful = successful;
+ this.block = block;
+ this.preallocCount = preallocCount;
+ }
- /**
- * Returns the block index (from the beginning of the partition).
- * @return long
- */
- public long getBlock() {
- return block;
- }
+ public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) {
+ this.successful = successful;
+ this.block = block;
+ this.preallocCount = preallocCount;
+ this.freeBlocksCount = freeBlocksCount;
+ }
- /**
- * Returns the preallocCount.
- * @return int
- */
- public int getPreallocCount() {
- return preallocCount;
- }
+ /**
+ * Returns the block index (from the beginning of the partition).
+ *
+ * @return long
+ */
+ public long getBlock() {
+ return block;
+ }
- /**
- * Returns the successful.
- * @return boolean
- */
- public boolean isSuccessful() {
- return successful;
- }
+ /**
+ * Returns the preallocCount.
+ *
+ * @return int
+ */
+ public int getPreallocCount() {
+ return preallocCount;
+ }
- /**
- * Sets the block.
- * @param block The block to set
- */
- public void setBlock(long block) {
- this.block = block;
- }
+ /**
+ * Returns the successful.
+ *
+ * @return boolean
+ */
+ public boolean isSuccessful() {
+ return successful;
+ }
- /**
- * Returns how many free blocks are in the block group
- * @return
- */
- public long getFreeBlocksCount() {
- return freeBlocksCount;
- }
+ /**
+ * Sets the block.
+ *
+ * @param block The block to set
+ */
+ public void setBlock(long block) {
+ this.block = block;
+ }
- /**
- * Sets how many free blocks are in the block group
- * @param l number of free blocks in the block group
- */
- public void setFreeBlocksCount(long l) {
- freeBlocksCount = l;
- }
+ /**
+ * Returns how many free blocks are in the block group
+ *
+ * @return
+ */
+ public long getFreeBlocksCount() {
+ return freeBlocksCount;
+ }
+ /**
+ * Sets how many free blocks are in the block group
+ * @param l number of free blocks in the block group
+ */
+ public void setFreeBlocksCount(long l) {
+ freeBlocksCount = l;
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/BlockSize.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -2,20 +2,17 @@
import org.jnode.util.BinaryScaleFactor;
-
public enum BlockSize {
- _1Kb(1),
- _2Kb(2),
- _4Kb(4);
+ _1Kb(1), _2Kb(2), _4Kb(4);
private final int size;
- private BlockSize(int blockSizeKb)
- {
- this.size = (int) (blockSizeKb * BinaryScaleFactor.K.getMultiplier()); //Converted into KB
+ private BlockSize(int blockSizeKb) {
+ /* The size is converted to kilobytes */
+ this.size = (int) (blockSizeKb * BinaryScaleFactor.K.getMultiplier());
}
- final public int getSize() {
- return size;
- }
+ public final int getSize() {
+ return size;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -25,92 +25,92 @@
* @author Andras Nagy
*/
public class Ext2Constants {
- //file types that are stored in the directory records
- public static final int EXT2_FT_UNKNOWN = 0;
- public static final int EXT2_FT_REG_FILE= 1;
- public static final int EXT2_FT_DIR = 2;
- public static final int EXT2_FT_CHRDEV = 3;
- public static final int EXT2_FT_BLKDEV = 4;
- public static final int EXT2_FT_FIFO = 5;
- public static final int EXT2_FT_SOCK = 6;
- public static final int EXT2_FT_SYMLINK = 7;
- public static final int EXT2_FT_MAX = 8;
-
- //inode constants
- public static final int EXT2_BAD_INO = 0x01; //bad blocks inode
- public static final int EXT2_ROOT_INO = 0x02; //root directory inode
- public static final int EXT2_ACL_IDX_INO = 0x03; //ACL index node
- public static final int EXT2_ACL_DATA_INO = 0x04; //ACL data inode
- public static final int EXT2_BOOT_LOADER_INO= 0x05; //boot loader inode
- public static final int EXT2_UNDEL_DIR_INO = 0x06; //undelete directory inode
-
- //i_mode masks and values
- public static final int EXT2_S_IFMT = 0xF000; //format mask
- public static final int EXT2_S_IFSOCK = 0xC000; //socket
- public static final int EXT2_S_IFLNK = 0xA000; //symbolic link
- public static final int EXT2_S_IFREG = 0x8000; //regular file
- public static final int EXT2_S_IFBLK = 0x6000; //block device
- public static final int EXT2_S_IFDIR = 0x4000; //directory
- public static final int EXT2_S_IFCHR = 0x2000; //character device
- public static final int EXT2_S_IFIFO = 0x1000; //fifo
- //access rights
- public static final int EXT2_S_ISUID = 0x0800; //SUID
- public static final int EXT2_S_ISGID = 0x0400; //SGID
- public static final int EXT2_S_ISVTX = 0x0200; //sticky bit
- public static final int EXT2_S_IRWXU = 0x01C0; //user access right mask
- public static final int EXT2_S_IRUSR = 0x0100; //read
- public static final int EXT2_S_IWUSR = 0x0080; //write
- public static final int EXT2_S_IXUSR = 0x0040; //execute
- public static final int EXT2_S_IRWXG = 0x0038; //group access right mask
- public static final int EXT2_S_IRGRP = 0x0020; //read
- public static final int EXT2_S_IWGRP = 0x0010; //write
- public static final int EXT2_S_IXGRP = 0x0008; //execute
- public static final int EXT2_S_IRWXO = 0x0007; //others access right mask
- public static final int EXT2_S_IROTH = 0x0004; //read
- public static final int EXT2_S_IWOTH = 0x0002; //write
- public static final int EXT2_S_IXOTH = 0x0001; //execute
+ // file types that are stored in the directory records
+ public static final int EXT2_FT_UNKNOWN = 0;
+ public static final int EXT2_FT_REG_FILE = 1;
+ public static final int EXT2_FT_DIR = 2;
+ public static final int EXT2_FT_CHRDEV = 3;
+ public static final int EXT2_FT_BLKDEV = 4;
+ public static final int EXT2_FT_FIFO = 5;
+ public static final int EXT2_FT_SOCK = 6;
+ public static final int EXT2_FT_SYMLINK = 7;
+ public static final int EXT2_FT_MAX = 8;
- //revision level values (stored in the superblock)
- public static final int EXT2_GOOD_OLD_REV = 0;
- public static final int EXT2_DYNAMIC_REV = 1;
-
- public static final int EXT2_PREALLOC_BLOCK = 7;
-
- //behaviour control flags in the inode
- public static final long EXT2_INDEX_FL = 0x00010000; //hash indexed directory
+ // inode constants
+ public static final int EXT2_BAD_INO = 0x01; // bad blocks inode
+ public static final int EXT2_ROOT_INO = 0x02; // root directory inode
+ public static final int EXT2_ACL_IDX_INO = 0x03; // ACL index node
+ public static final int EXT2_ACL_DATA_INO = 0x04; // ACL data inode
+ public static final int EXT2_BOOT_LOADER_INO = 0x05; // boot loader inode
+ public static final int EXT2_UNDEL_DIR_INO = 0x06; // undelete directory inode
- //Filesystem state constants
- public static final int EXT2_VALID_FS = 0x0001; // cleanly unmounted
- public static final int EXT2_ERROR_FS = 0x0002;
-
- //what to do when errors are detected
- public static final int EXT2_ERRORS_CONTINUE= 0x0001;
- public static final int EXT2_ERRORS_RO = 0x0002;
- public static final int EXT2_ERRORS_PANIC = 0x0003;
- public static final int EXT2_ERRORS_DEFAULT = EXT2_ERRORS_CONTINUE;
-
-
- //S_FEATURE_RO_COMPAT constants
- public static final long EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x0001;
- public static final long EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x0002;
- public static final long EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x0004;
+ // i_mode masks and values
+ public static final int EXT2_S_IFMT = 0xF000; // format mask
+ public static final int EXT2_S_IFSOCK = 0xC000; // socket
+ public static final int EXT2_S_IFLNK = 0xA000; // symbolic link
+ public static final int EXT2_S_IFREG = 0x8000; // regular file
+ public static final int EXT2_S_IFBLK = 0x6000; // block device
+ public static final int EXT2_S_IFDIR = 0x4000; // directory
+ public static final int EXT2_S_IFCHR = 0x2000; // character device
+ public static final int EXT2_S_IFIFO = 0x1000; // fifo
+
+ // access rights
+ public static final int EXT2_S_ISUID = 0x0800; // SUID
+ public static final int EXT2_S_ISGID = 0x0400; // SGID
+ public static final int EXT2_S_ISVTX = 0x0200; // sticky bit
+ public static final int EXT2_S_IRWXU = 0x01C0; // user access right mask
+ public static final int EXT2_S_IRUSR = 0x0100; // read
+ public static final int EXT2_S_IWUSR = 0x0080; // write
+ public static final int EXT2_S_IXUSR = 0x0040; // execute
+ public static final int EXT2_S_IRWXG = 0x0038; // group access right mask
+ public static final int EXT2_S_IRGRP = 0x0020; // read
+ public static final int EXT2_S_IWGRP = 0x0010; // write
+ public static final int EXT2_S_IXGRP = 0x0008; // execute
+ public static final int EXT2_S_IRWXO = 0x0007; // others access right mask
+ public static final int EXT2_S_IROTH = 0x0004; // read
+ public static final int EXT2_S_IWOTH = 0x0002; // write
+ public static final int EXT2_S_IXOTH = 0x0001; // execute
- //S_FEATURE_INCOMPAT constants
- public static final long EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x0001;
- public static final long EXT2_FEATURE_INCOMPAT_FILETYPE = 0x0002;
- public static final long EXT3_FEATURE_INCOMPAT_RECOVER = 0x0004;
- public static final long EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x0008;
- public static final long EXT2_FEATURE_INCOMPAT_META_BG = 0x0010;
+ // revision level values (stored in the superblock)
+ public static final int EXT2_GOOD_OLD_REV = 0;
+ public static final int EXT2_DYNAMIC_REV = 1;
- //constants specific to this (JNode) implementation
- /**
- * When searching for free blocks, block groups that have at least
- * EXT2_BLOCK_THRESHOLD_RATIO/100 * BlocksPerGroup free blocks are considered first
- * - if this constant is too high, it will lead to higher disk fragmentation
- * - if it is too low, then files might be scattered among multiple block groups
- * on very full partitions (higher file fragmentation)
- * intervall: [0; 100)
- */
- public static final int EXT2_BLOCK_THRESHOLD_PERCENT = 5;
+ public static final int EXT2_PREALLOC_BLOCK = 7;
+ // behaviour control flags in the inode
+ public static final long EXT2_INDEX_FL = 0x00010000; // hash indexed directory
+
+ // Filesystem state constants
+ public static final int EXT2_VALID_FS = 0x0001; // cleanly unmounted
+ public static final int EXT2_ERROR_FS = 0x0002;
+
+ // what to do when errors are detected
+ public static final int EXT2_ERRORS_CONTINUE = 0x0001;
+ public static final int EXT2_ERRORS_RO = 0x0002;
+ public static final int EXT2_ERRORS_PANIC = 0x0003;
+ public static final int EXT2_ERRORS_DEFAULT = EXT2_ERRORS_CONTINUE;
+
+ // S_FEATURE_RO_COMPAT constants
+ public static final long EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x0001;
+ public static final long EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x0002;
+ public static final long EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x0004;
+
+ // S_FEATURE_INCOMPAT constants
+ public static final long EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x0001;
+ public static final long EXT2_FEATURE_INCOMPAT_FILETYPE = 0x0002;
+ public static final long EXT3_FEATURE_INCOMPAT_RECOVER = 0x0004;
+ public static final long EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x0008;
+ public static final long EXT2_FEATURE_INCOMPAT_META_BG = 0x0010;
+
+ // constants specific to this (JNode) implementation
+ /**
+ * When searching for free blocks, block groups that have at least
+ * EXT2_BLOCK_THRESHOLD_RATIO/100 * BlocksPerGroup free blocks are
+ * considered first - if this constant is too high, it will lead to higher
+ * disk fragmentation - if it is too low, then files might be scattered
+ * among multiple block groups on very full partitions (higher file
+ * fragmentation) intervall: [0; 100)
+ */
+ public static final int EXT2_BLOCK_THRESHOLD_PERCENT = 5;
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2008-06-05 14:26:18 UTC (rev 4201)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2008-06-06 11:57:12 UTC (rev 4202)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.ext2;
import java.io.IOException;
@@ -76,8 +76,7 @@
*/
public FSEntry createDirectoryEntry(String name) throws IOException {
if (!canWrite())
- throw new IOException(
- "Filesystem or directory is mounted read-only!");
+ throw new IOException("Filesystem or directory is mounted read-only!");
//create a new iNode for the file
//TODO: access rights, file type, UID and GID should be passed through
@@ -87,33 +86,28 @@
Ext2Entry newEntry;
Ext2FileSystem fs = (Ext2FileSystem) getFileSystem();
try {
- int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU
- | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO);
- newINode = fs.createINode((int) iNode.getGroup(),
- Ext2Constants.EXT2_S_IFDIR, rights, 0, 0);
+ int rights =
+ 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO);
+ newINode = fs.createINode((int) iNode.getGroup(), Ext2Constants.EXT2_S_IFDIR, rights, 0, 0);
- dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(),
- Ext2Constants.EXT2_FT_DIR, name);
+ dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, name);
addDirectoryRecord(dr);
newINode.setLinksCount(newINode.getLinksCount() + 1);
- newEntry = new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_DIR,
- fs, this);
+ newEntry = new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_DIR, fs, this);
//add "."
Ext2Directory newDir = new Ext2Directory(newEntry);
- Ext2DirectoryRecord drThis = new Ext2DirectoryRecord(fs, newINode
- .getINodeNr(), Ext2Constants.EXT2_FT_DIR, ".");
+ Ext2DirectoryRecord drThis =
+ new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_DIR, ".");
newINode.setLinksCount(2);
newDir.addDirectoryRecord(drThis);
//add ".."
- long parentINodeNr = ((Ext2Directory) entry.getDirectory())
- .getINode().getINodeNr();
- Ext2DirectoryRecord drParent = new Ext2DirectoryRecord(fs,
- parentINodeNr, Ext2Constants.EXT2_FT_DIR, "..");
+ long parentINodeNr = ((Ext2Directory) entry.getDirectory()).getINode().getINodeNr();
+ Ext2DirectoryRecord drParent = new Ext2DirectoryRecord(fs, parentINodeNr, Ext2Constants.EXT2_FT_DIR, "..");
newDir.addDirectoryRecord(drParent);
//increase the reference count for the parent directory
@@ -121,8 +115,7 @@
parentINode.setLinksCount(parentINode.getLinksCount() + 1);
//update the number of used directories in the block group
- int group = (int) ((newINode.getINodeNr() - 1) / fs.getSuperblock()
- .getINodesPerGroup());
+ int group = (int) ((newINode.getINodeNr() - 1) / fs.getSuperblock().getINodesPerGroup());
fs.modifyUsedDirsCount(group, 1);
//update the new inode
@@ -145,8 +138,7 @@
*/
public FSEntry createFileEntry(String name) throws IOException {
if (!canWrite())
- throw new IOException(
- "Filesystem or directory is mounted read-only!");
+ throw new IOException("Filesystem or directory is mounted read-only!");
//create a new iNode for the file
//TODO: access rights, file type, UID and GID should be passed through
@@ -155,13 +147,11 @@
Ext2DirectoryRecord dr;
Ext2FileSystem fs = (Ext2FileSystem) getFileSystem();
try {
- int rights = 0xFFFF & (Ext2Constants.EXT2_S_IRWXU
- | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO);
- newINode = fs.createINode((int) iNode.getGroup(),
- Ext2Constants.EXT2_S_IFREG, rights, 0, 0);
+ int rights =
+ 0xFFFF & (Ext2Constants.EXT2_S_IRWXU | Ext2Constants.EXT2_S_IRWXG | Ext2Constants.EXT2_S_IRWXO);
+ newINode = fs.createINode((int) iNode.getGroup(), Ext2Constants.EXT2_S_IFREG, rights, 0, 0);
- dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(),
- Ext2Constants.EXT2_FT_REG_FILE, name);
+ dr = new Ext2DirectoryRecord(fs, newINode.getINodeNr(), Ext2Constants.EXT2_FT_REG_FILE, name);
addDirectoryRecord(dr);
@@ -172,8 +162,7 @@
ioe.initCause(ex);
throw ioe;
}
- return new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_REG_FILE,
- fs, this);
+ return new Ext2Entry(newINode, name, Ext2Constants.EXT2_FT_REG_FILE, fs, this);
}
/**
@@ -184,11 +173,9 @@
* @return @throws
* IOException
*/
- protected FSEntry addINode(int iNodeNr, String linkName, int fileType)
- throws IOException {
+ protected FSEntry addINode(int iNodeNr, String linkName, int fileType) throws IOException {
if (!canWrite())
- throw new IOException(
- "Filesystem or directory is mounted read-only!");
+ throw new IOException("Filesystem or directory is mounted read-only!");
//TODO: access rights, file type, UID and GID should be passed through
// the FSDirectory interface
@@ -214,8 +201,7 @@
...
[truncated message content] |
|
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,re...
[truncated message content] |
|
From: <cr...@us...> - 2008-06-07 10:22:08
|
Revision: 4208
http://jnode.svn.sourceforge.net/jnode/?rev=4208&view=rev
Author: crawley
Date: 2008-06-07 03:22:01 -0700 (Sat, 07 Jun 2008)
Log Message:
-----------
Checkstyle changes
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/jarfs/FSTreeBuilder.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSCache.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSDirectory.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSEntry.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSFile.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jfat/BootSector.java
trunk/fs/src/fs/org/jnode/fs/jfat/ClusterSize.java
trunk/fs/src/fs/org/jnode/fs/jfat/CodePage.java
trunk/fs/src/fs/org/jnode/fs/jfat/CodePageDecoder.java
trunk/fs/src/fs/org/jnode/fs/jfat/CodePageEncoder.java
trunk/fs/src/fs/org/jnode/fs/jfat/Fat.java
trunk/fs/src/fs/org/jnode/fs/jfat/Fat32.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatAttr.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatCache.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatCase.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatChain.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatDirEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatDirectory.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatDotDirEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFile.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemFormatter.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFormatter.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFsInfo.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatLongDirEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatMarshal.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatName.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatObject.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatRecord.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatRootDirectory.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatShortDirEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatTable.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatUtils.java
trunk/fs/src/fs/org/jnode/fs/jfat/StrWriter.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/FatFormatCommand.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubException.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrub.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/MBRFormatter.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/Stage1_5.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/Stage2.java
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/FSTreeBuilder.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/FSTreeBuilder.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/FSTreeBuilder.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -29,52 +29,45 @@
import org.jnode.fs.util.FSUtils;
-public class FSTreeBuilder
-{
+public class FSTreeBuilder {
public static final char separator = '/';
+
@SuppressWarnings("unchecked")
- public static JarFSEntry build(JarFileSystem fs, JarFile jarFile, JarFSCache cache)
- {
+ public static JarFSEntry build(JarFileSystem fs, JarFile jarFile, JarFSCache cache) {
JarFSEntry root = new JarFSEntry(fs, null, null, jarFile.getName());
Map<String, JarFSEntry> nameToJarFSEntry = new HashMap<String, JarFSEntry>();
nameToJarFSEntry.put("", root);
-
- for(Enumeration<JarEntry> entries = jarFile.entries() ; entries.hasMoreElements() ; )
- {
+
+ for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
JarEntry entry = entries.nextElement();
JarFSEntry fsEntry = getJarFSEntry(fs, nameToJarFSEntry, entry, null);
cache.put(entry, fsEntry);
}
-
+
return root;
}
-
- public static JarFSEntry getJarFSEntry(JarFileSystem fs,
- Map<String, JarFSEntry> nameToJarFSEntry, JarEntry jarEntry, String fullName)
- {
+
+ public static JarFSEntry getJarFSEntry(JarFileSystem fs,
+ Map<String, JarFSEntry> nameToJarFSEntry, JarEntry jarEntry, String fullName) {
fullName = (fullName == null) ? jarEntry.getName() : fullName;
-
+
JarFSEntry fsEntry = nameToJarFSEntry.get(fullName);
- if(fsEntry == null)
- {
+ if (fsEntry == null) {
String parent = FSUtils.getParentName(fullName, separator);
JarFSEntry parentFSEntry;
- if("".equals(parent))
- {
+ if ("".equals(parent)) {
// parent is the root
parentFSEntry = nameToJarFSEntry.get("");
- }
- else
- {
+ } else {
// recursive call
parentFSEntry = getJarFSEntry(fs, nameToJarFSEntry, null, parent);
}
-
+
String name = FSUtils.getName(jarEntry.getName(), separator);
fsEntry = new JarFSEntry(fs, parentFSEntry, jarEntry, name);
nameToJarFSEntry.put(fullName, fsEntry);
}
-
+
return fsEntry;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSCache.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSCache.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSCache.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -30,46 +30,39 @@
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
*
*/
-public class JarFSCache
-{
- private Map<JarEntry,JarFSEntry> jarFSEntries = new java.util.Hashtable<JarEntry,JarFSEntry>();
- private Map<JarFSEntry,Map<String, JarFSEntry>> childEntries = new java.util.Hashtable<JarFSEntry,Map<String, JarFSEntry>>();
-
- public JarFSCache()
- {
+public class JarFSCache {
+ private Map<JarEntry, JarFSEntry> jarFSEntries =
+ new java.util.Hashtable<JarEntry, JarFSEntry>();
+ private Map<JarFSEntry, Map<String, JarFSEntry>> childEntries =
+ new java.util.Hashtable<JarFSEntry, Map<String, JarFSEntry>>();
+
+ public JarFSCache() {
}
-
- public JarFSEntry get(JarEntry jarEntry)
- {
+
+ public JarFSEntry get(JarEntry jarEntry) {
return jarFSEntries.get(jarEntry);
}
- public Object put(JarEntry jarEntry, JarFSEntry fsEntry)
- {
+ public Object put(JarEntry jarEntry, JarFSEntry fsEntry) {
return jarFSEntries.put(jarEntry, fsEntry);
}
-
- public boolean isEmpty()
- {
+
+ public boolean isEmpty() {
return (jarFSEntries.size() == 0);
}
-
- public Map<String, JarFSEntry> getChildEntries(JarFSEntry entry)
- {
+
+ public Map<String, JarFSEntry> getChildEntries(JarFSEntry entry) {
Map<String, JarFSEntry> children = childEntries.get(entry);
- if(children == null)
- {
+ if (children == null) {
children = new java.util.Hashtable<String, JarFSEntry>();
- for(JarFSEntry jarFSEntry : jarFSEntries.values())
- {
- if(jarFSEntry.getParentFSEntry().equals(entry))
- {
+ for (JarFSEntry jarFSEntry : jarFSEntries.values()) {
+ if (jarFSEntry.getParentFSEntry().equals(entry)) {
children.put(jarFSEntry.getName(), jarFSEntry);
}
}
childEntries.put(entry, children);
}
-
+
return children;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSDirectory.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSDirectory.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -33,7 +33,7 @@
/**
*
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
- *
+ *
*/
public final class JarFSDirectory implements FSDirectory {
@@ -43,7 +43,7 @@
/**
* @param entry
*/
- public JarFSDirectory(JarFSEntry entry, Map<String, JarFSEntry> entries) {
+ public JarFSDirectory(JarFSEntry entry, Map<String, JarFSEntry> entries) {
this.entry = entry;
this.jarEntries = entries;
}
@@ -51,8 +51,8 @@
/**
* @see org.jnode.fs.FSDirectory#iterator()
*/
- public Iterator<? extends FSEntry> iterator() {
- return jarEntries.values().iterator();
+ public Iterator<? extends FSEntry> iterator() {
+ return jarEntries.values().iterator();
}
/**
@@ -97,12 +97,12 @@
return entry.getFileSystem();
}
- /**
- * Save all dirty (unsaved) data to the device
- * @throws IOException
- */
- public void flush() throws IOException
- {
- //jar file systems are always readOnly
- }
+ /**
+ * Save all dirty (unsaved) data to the device
+ *
+ * @throws IOException
+ */
+ public void flush() throws IOException {
+ // jar file systems are always readOnly
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSEntry.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSEntry.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -31,10 +31,8 @@
import org.jnode.fs.FileSystem;
import org.jnode.fs.ReadOnlyFileSystemException;
-/**
- *
+/**
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
- *
*/
public final class JarFSEntry implements FSEntry {
@@ -50,16 +48,14 @@
this.name = name;
}
- public JarEntry getJarEntry()
- {
+ public JarEntry getJarEntry() {
return jarEntry;
}
- public JarFSEntry getParentFSEntry()
- {
+ public JarFSEntry getParentFSEntry() {
return parent;
}
-
+
/**
* @see org.jnode.fs.FSEntry#getName()
*/
@@ -67,67 +63,55 @@
return name;
}
- public FSDirectory getParent()
- {
+ public FSDirectory getParent() {
// TODO Auto-generated method stub
return null;
}
- public long getLastModified() throws IOException
- {
+ public long getLastModified() throws IOException {
return jarEntry.getTime();
}
- public boolean isFile()
- {
+ public boolean isFile() {
return !jarEntry.isDirectory();
}
- public boolean isDirectory()
- {
+ public boolean isDirectory() {
return jarEntry.isDirectory();
}
- public void setName(String newName) throws IOException
- {
+ public void setName(String newName) throws IOException {
throw new ReadOnlyFileSystemException("jar file system is readonly");
}
- public void setLastModified(long lastModified) throws IOException
- {
+ public void setLastModified(long lastModified) throws IOException {
throw new ReadOnlyFileSystemException("jar file system is readonly");
}
- public FSFile getFile() throws IOException
- {
+ public FSFile getFile() throws IOException {
// TODO Auto-generated method stub
return null;
}
- public FSDirectory getDirectory() throws IOException
- {
+ public FSDirectory getDirectory() throws IOException {
// TODO Auto-generated method stub
return null;
}
- public FSAccessRights getAccessRights() throws IOException
- {
+ public FSAccessRights getAccessRights() throws IOException {
// TODO Auto-generated method stub
return null;
}
- public boolean isDirty() throws IOException
- {
+ public boolean isDirty() throws IOException {
return false;
}
- public boolean isValid()
- {
+ public boolean isValid() {
return true;
}
- public FileSystem getFileSystem()
- {
+ public FileSystem getFileSystem() {
return fs;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSFile.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFSFile.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -32,10 +32,8 @@
import org.jnode.fs.FileSystem;
import org.jnode.fs.ReadOnlyFileSystemException;
-/**
- *
+/**
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
- *
*/
public class JarFSFile implements FSFile {
@@ -65,13 +63,12 @@
/**
* @see org.jnode.fs.FSFile#read(long, byte[], int, int)
*/
- public void read(long fileOffset, ByteBuffer destBuf)
- throws IOException {
- final JarFileSystem fs = (JarFileSystem) getFileSystem();
+ public void read(long fileOffset, ByteBuffer destBuf) throws IOException {
+ final JarFileSystem fs = (JarFileSystem) getFileSystem();
final JarFile jarFile = fs.getJarFile();
final InputStream is = jarFile.getInputStream(entry.getJarEntry());
is.skip(fileOffset);
- InputStreamChannel isc = new InputStreamChannel(is);
+ InputStreamChannel isc = new InputStreamChannel(is);
isc.read(destBuf);
isc.close();
is.close();
@@ -79,10 +76,8 @@
/**
* @see org.jnode.fs.FSFile#write(long, byte[], int, int)
- */
- //public void write(long fileOffset, byte[] src, int off, int len)
- public void write(long fileOffset, ByteBuffer src)
- throws IOException {
+ */
+ public void write(long fileOffset, ByteBuffer src) throws IOException {
throw new ReadOnlyFileSystemException("Not yet implemented");
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -32,9 +32,9 @@
import org.jnode.fs.spi.AbstractFileSystem;
/**
- *
+ *
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
- *
+ *
*/
public class JarFileSystem extends AbstractFileSystem<JarFSEntry> {
@@ -45,8 +45,7 @@
/**
* @see org.jnode.fs.FileSystem#getDevice()
*/
- public JarFileSystem(JarFileDevice device, JarFileSystemType type)
- throws FileSystemException {
+ public JarFileSystem(JarFileDevice device, JarFileSystemType type) throws FileSystemException {
super(device, true, type); // jar file systems are always readOnly
jarFile = device.getJarFile();
@@ -54,46 +53,44 @@
rootEntry = FSTreeBuilder.build(this, jarFile, cache);
}
- public JarFile getJarFile()
- {
+ public JarFile getJarFile() {
return jarFile;
}
/**
- *
+ *
*/
- protected FSFile createFile(FSEntry entry) {
- return new JarFSFile((JarFSEntry) entry);
- }
+ protected FSFile createFile(FSEntry entry) {
+ return new JarFSFile((JarFSEntry) entry);
+ }
- /**
- *
- */
- protected FSDirectory createDirectory(FSEntry entry) {
+ /**
+ *
+ */
+ protected FSDirectory createDirectory(FSEntry entry) {
Map<String, JarFSEntry> entries = cache.getChildEntries((JarFSEntry) entry);
return new JarFSDirectory((JarFSEntry) entry, entries);
- }
+ }
- /**
- *
- */
- protected JarFSEntry createRootEntry() {
- return rootEntry;
- }
+ /**
+ *
+ */
+ protected JarFSEntry createRootEntry() {
+ return rootEntry;
+ }
+ 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;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystemType.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -25,12 +25,11 @@
import org.jnode.driver.block.JarFileDevice;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
-import org.jnode.fs.util.FSUtils;
/**
- *
+ *
* @author Fabien DUMINY (fduminy at users.sourceforge.net)
- *
+ *
*/
public class JarFileSystemType implements FileSystemType<JarFileSystem> {
public static final Class<JarFileSystemType> ID = JarFileSystemType.class;
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/BootSector.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/BootSector.java 2008-06-07 03:48:55 UTC (rev 4207)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/BootSector.java 2008-06-07 10:22:01 UTC (rev 4208)
@@ -24,24 +24,19 @@
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.Arrays;
import org.apache.log4j.Logger;
-import org.jnode.fs.FileSystemException;
-import org.jnode.fs.jfat.StrWriter;
import org.jnode.driver.block.BlockDeviceAPI;
import org.jnode.partitions.ibm.IBMPartitionTable;
import org.jnode.util.LittleEndian;
import org.jnode.util.NumberUtils;
-
/**
* @author gvt
* @author Tango
*/
public class BootSector {
- private static final Logger log =
- Logger.getLogger ( BootSector.class );
+ private static final Logger log = Logger.getLogger(BootSector.class);
private static final int IFAT12 = 12;
private static final int IFAT16 = 16;
@@ -53,9 +48,9 @@
private static final String SFAT12 = "FAT12";
private static final String SFAT16 = "FAT16";
private static final String SFAT32 = "FAT32";
-
+
private byte[] sector;
- private int type;
+ private int type;
private boolean dirty;
/*
@@ -63,320 +58,289 @@
*/
private byte[] BS_jmpBoot;
private String BS_OEMName;
- private int BPB_BytsPerSec;
- private int BPB_SecPerClus;
- private int BPB_RsvdSecCnt;
- private int BPB_NumFATs;
- private int BPB_RootEntCnt;
- private int BPB_TotSec16;
- private int BPB_Media;
- private int BPB_FATSz16;
- private int BPB_SecPerTrk;
- private int BPB_NumHeads;
- private long BPB_HiddSec;
- private long BPB_TotSec32;
+ private int BPB_BytsPerSec;
+ private int BPB_SecPerClus;
+ private int BPB_RsvdSecCnt;
+ private int BPB_NumFATs;
+ private int BPB_RootEntCnt;
+ private int BPB_TotSec16;
+ private int BPB_Media;
+ private int BPB_FATSz16;
+ private int BPB_SecPerTrk;
+ private int BPB_NumHeads;
+ private long BPB_HiddSec;
+ private long BPB_TotSec32;
-
/*
* FAT32 only fields;
*/
- private long BPB_FATSz32;
- private int BPB_ExtFlags;
- private int BPB_FSVer;
- private long BPB_RootClus;
- private int BPB_FSInfo;
- private int BPB_BkBootSec;
+ private long BPB_FATSz32;
+ private int BPB_ExtFlags;
+ private int BPB_FSVer;
+ private long BPB_RootClus;
+ private int BPB_FSInfo;
+ private int BPB_BkBootSec;
private byte[] BPB_Reserved;
-
/*
* Common fields, different offsets
*/
- private int BS_DrvNum;
- private int BS_Reserved1;
- private int BS_BootSig;
- private long BS_VolID;
+ private int BS_DrvNum;
+ private int BS_Reserved1;
+ private int BS_BootSig;
+ private long BS_VolID;
private String BS_VolLab;
private String BS_FilSysType;
-
-
/*
* computed fields
*/
- private long RootDirSectors;
- private long FATSz;
- private long FirstDataSector;
- private long TotSec;
- private long DataSec;
- private long CountOfClusters;
+ private long RootDirSectors;
+ private long FATSz;
+ private long FirstDataSector;
+ private long TotSec;
+ private long DataSec;
+ private long CountOfClusters;
+ public BootSector(int size) {
+ sector = new byte[size];
+ dirty = false;
+ }
- public BootSector ( int size ) {
- sector = new byte[size];
- dirty = false;
+ public BootSector(byte[] sector) {
+ this.sector = new byte[sector.length];
+ System.arraycopy(sector, 0, this.sector, 0, sector.length);
+ decode();
+ dirty = false;
}
-
-
- public BootSector ( byte[] sector ) {
- this.sector = new byte[sector.length];
- System.arraycopy ( sector, 0, this.sector, 0, sector.length );
- decode();
- dirty = false;
- }
-
public boolean isaValidBootSector() {
- return IBMPartitionTable.containsPartitionTable(sector);
+ return IBMPartitionTable.containsPartitionTable(sector);
}
-
- public synchronized void read ( BlockDeviceAPI device )
- throws IOException {
- device.read ( 0, ByteBuffer.wrap ( sector ) );
- decode();
+ public synchronized void read(BlockDeviceAPI device) throws IOException {
+ device.read(0, ByteBuffer.wrap(sector));
+ decode();
dirty = false;
}
+ public synchronized void write(BlockDeviceAPI device, long offset) throws IOException {
+ //encode();//TODO: Notice here once (Changed Now)
+ device.write(offset, ByteBuffer.wrap(sector));
- public synchronized void write ( BlockDeviceAPI device,long offset )
- throws IOException
- {
- //encode();//TODO: Notice here once (Changed Now)
- device.write (offset, ByteBuffer.wrap ( sector ) );
-
dirty = false;
}
-
private void compute() {
- RootDirSectors = ( ( BPB_RootEntCnt * 32 ) +
- ( BPB_BytsPerSec - 1 ) ) / BPB_BytsPerSec;
+ RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec - 1)) / BPB_BytsPerSec;
- if ( BPB_FATSz16 != 0 )
- FATSz = BPB_FATSz16;
- else
- FATSz = BPB_FATSz32;
+ if (BPB_FATSz16 != 0)
+ FATSz = BPB_FATSz16;
+ else
+ FATSz = BPB_FATSz32;
- FirstDataSector = BPB_RsvdSecCnt +
- ( BPB_NumFATs * FATSz ) + RootDirSectors;
+ FirstDataSector = BPB_RsvdSecCnt + (BPB_NumFATs * FATSz) + RootDirSectors;
- if ( BPB_TotSec16 != 0 )
- TotSec = BPB_TotSec16;
- else
- TotSec = BPB_TotSec32;
+ if (BPB_TotSec16 != 0)
+ TotSec = BPB_TotSec16;
+ else
+ TotSec = BPB_TotSec32;
- DataSec = TotSec - ( BPB_RsvdSecCnt + ( BPB_NumFATs * FATSz ) +
- RootDirSectors );
+ DataSec = TotSec - (BPB_RsvdSecCnt + (BPB_NumFATs * FATSz) + RootDirSectors);
- CountOfClusters = DataSec / BPB_SecPerClus;
+ CountOfClusters = DataSec / BPB_SecPerClus;
- if ( CountOfClusters < SZFAT12 )
- type = IFAT12;
- else if ( CountOfClusters < SZFAT16 )
- type = IFAT16;
- else
- type = IFAT32;
+ if (CountOfClusters < SZFAT12)
+ type = IFAT12;
+ else if (CountOfClusters < SZFAT16)
+ type = IFAT16;
+ else
+ type = IFAT32;
}
-
private void decode() {
- BS_jmpBoot = getBytes ( 0, 3 );
- BS_OEMName = getString ( 3, 8 );
- BPB_BytsPerSec = get16 ( 11 );
- BPB_SecPerClus = get8 ( 13 );
- BPB_RsvdSecCnt = get16 ( 14 );
- BPB_NumFATs = get8 ( 16 );
- BPB_RootEntCnt = get16 ( 17 );
- BPB_TotSec16 = get16 ( 19 );
- BPB_Media = get8 ( 21 );
- BPB_FATSz16 = get16 ( 22 );
- BPB_SecPerTrk = get16 ( 24 );
- BPB_NumHeads = get16 ( 26 );
- BPB_HiddSec = get32 ( 28 );
- BPB_TotSec32 = get32 ( 32 );
+ BS_jmpBoot = getBytes(0, 3);
+ BS_OEMName = getString(3, 8);
+ BPB_BytsPerSec = get16(11);
+ BPB_SecPerClus = get8(13);
+ BPB_RsvdSecCnt = get16(14);
+ BPB_NumFATs = get8(16);
+ BPB_RootEntCnt = get16(17);
+ BPB_TotSec16 = get16(19);
+ BPB_Media = get8(21);
+ BPB_FATSz16 = get16(22);
+ BPB_SecPerTrk = get16(24);
+ BPB_NumHeads = get16(26);
+ BPB_HiddSec = get32(28);
+ BPB_TotSec32 = get32(32);
- if ( BPB_FATSz16 == 0 )
- BPB_FATSz32 = get32 ( 36 );
+ if (BPB_FATSz16 == 0)
+ BPB_FATSz32 = get32(36);
- compute();
+ compute();
- if ( !isFat32() ) {
- BS_DrvNum = get8 ( 36 );
- BS_Reserved1 = get8 ( 37 );
- BS_BootSig = get8 ( 38 );
- BS_VolID = get32 ( 39 );
- BS_VolLab = getString ( 43, 11 );
- BS_FilSysType = getString ( 54, 8 );
- }
- else {
- BPB_ExtFlags = get16 ( 40 );
- BPB_FSVer = get16 ( 42 );
- BPB_RootClus = get32 ( 44 );
- BPB_FSInfo = get16 ( 48 );
- BPB_BkBootSec = get16 ( 50 );
- BPB_Reserved = getBytes ( 52, 12 );
+ if (!isFat32()) {
+ BS_DrvNum = get8(36);
+ BS_Reserved1 = get8(37);
+ BS_BootSig = get8(38);
+ BS_VolID = get32(39);
+ BS_VolLab = getString(43, 11);
+ BS_FilSysType = getString(54, 8);
+ } else {
+ BPB_ExtFlags = get16(40);
+ BPB_FSVer = get16(42);
+ BPB_RootClus = get32(44);
+ BPB_FSInfo = get16(48);
+ BPB_BkBootSec = get16(50);
+ BPB_Reserved = getBytes(52, 12);
- BS_DrvNum = get8 ( 64 );
- BS_Reserved1 = get8 ( 65 );
- BS_BootSig = get8 ( 66 );
- BS_VolID = get32 ( 67 );
- BS_VolLab = getString ( 71, 11 );
- BS_FilSysType = getString ( 82, 8 );
- }
+ BS_DrvNum = get8(64);
+ BS_Reserved1 = get8(65);
+ BS_BootSig = get8(66);
+ BS_VolID = get32(67);
+ BS_VolLab = getString(71, 11);
+ BS_FilSysType = getString(82, 8);
+ }
}
-
private void encode() {
- setBytes ( 0, 3, BS_jmpBoot );
- setString ( 3, 8, BS_OEMName );
- set16 ( 11, BPB_BytsPerSec );
- set8 ( 13, BPB_SecPerClus );
- set16 ( 14, BPB_RsvdSecCnt );
- set8 ( 16, BPB_NumFATs );
- set16 ( 17, BPB_RootEntCnt );
- set16 ( 19, BPB_TotSec16 );
- set8 ( 21, BPB_Media );
- set16 ( 22, BPB_FATSz16 );
- set16 ( 24, BPB_SecPerTrk );
- set16 ( 26, BPB_NumHeads );
- set32 ( 28, BPB_HiddSec );
- set32 ( 32, BPB_TotSec32 );
+ setBytes(0, 3, BS_jmpBoot);
+ setString(3, 8, BS_OEMName);
+ set16(11, BPB_BytsPerSec);
+ set8(13, BPB_SecPerClus);
+ set16(14, BPB_RsvdSecCnt);
+ set8(16, BPB_NumFATs);
+ set16(17, BPB_RootEntCnt);
+ set16(19, BPB_TotSec16);
+ set8(21, BPB_Media);
+ set16(22, BPB_FATSz16);
+ set16(24, BPB_SecPerTrk);
+ set16(26, BPB_NumHeads);
+ set32(28, BPB_HiddSec);
+ set32(32, BPB_TotSec32);
- if ( !isFat32() ) {
- set8 ( 36, BS_DrvNum );
- set8 ( 37, BS_Reserved1 );
- set8 ( 38, BS_BootSig );
- set32 ( 39, BS_VolID );
- setString ( 43, 11, BS_VolLab );
- setString ( 54, 8, BS_FilSysType );
- }
- else {
- set32 ( 36, BPB_FATSz32 );
- set16 ( 40, BPB_ExtFlags );
- set16 ( 42, BPB_FSVer );
- set32 ( 44, BPB_RootClus );
- set16 ( 48, BPB_FSInfo );
- set16 ( 50, BPB_BkBootSec );
- setBytes ( 52, 12, BPB_Reserved );
+ if (!isFat32()) {
+ set8(36, BS_DrvNum);
+ set8(37, BS_Reserved1);
+ set8(38, BS_BootSig);
+ set32(39, BS_VolID);
+ setString(43, 11, BS_VolLab);
+ setString(54, 8, BS_FilSysType);
+ } else {
+ set32(36, BPB_FATSz32);
+ set16(40, BPB_ExtFlags);
+ set16(42, BPB_FSVer);
+ set32(44, BPB_RootClus);
+ set16(48, BPB_FSInfo);
+ set16(50, BPB_BkBootSec);
+ setBytes(52, 12, BPB_Reserved);
- set8 ( 64, BS_DrvNum );
- set8 ( 65, BS_Reserved1 );
- set8 ( 66, BS_BootSig );
- set32 ( 67, BS_VolID );
- setString ( 71, 11, BS_VolLab );
- setString ( 82, 8, BS_FilSysType );
- }
+ set8(64, BS_DrvNum);
+ set8(65, BS_Reserved1);
+ set8(66, BS_BootSig);
+ set32(67, BS_VolID);
+ setString(71, 11, BS_VolLab);
+ setString(82, 8, BS_FilSysType);
+ }
}
-
-
- protected int get8 ( int offset ) {
- return LittleEndian.getUInt8 ( sector, offset );
+
+ protected int get8(int offset) {
+ return LittleEndian.getUInt8(sector, offset);
}
-
- protected void set8 ( int offset, int value ) {
- LittleEndian.setInt8 ( sector, offset, value );
+ protected void set8(int offset, int value) {
+ LittleEndian.setInt8(sector, offset, value);
dirty = true;
}
-
- protected int get16 ( int offset ) {
- return LittleEndian.getUInt16 ( sector, offset );
+ protected int get16(int offset) {
+ return LittleEndian.getUInt16(sector, offset);
}
-
- protected void set16 ( int offset, int value ) {
- LittleEndian.setInt16 ( sector, offset, value );
+ protected void set16(int offset, int value) {
+ LittleEndian.setInt16(sector, offset, value);
dirty = true;
}
-
- protected long get32 ( int offset ) {
- ret...
[truncated message content] |
|
From: <cr...@us...> - 2008-06-07 11:48:37
|
Revision: 4209
http://jnode.svn.sourceforge.net/jnode/?rev=4209&view=rev
Author: crawley
Date: 2008-06-07 04:48:31 -0700 (Sat, 07 Jun 2008)
Log Message:
-----------
style changes
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java
trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSExtension.java
trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java
trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDpluginJars.java
trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDplugins.java
trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDrootDir.java
trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFdevices.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFfilesystems.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFfragmentJar.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFmemory.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFplugin.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFpluginJar.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFthread.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFuptime.java
trunk/fs/src/fs/org/jnode/fs/jifs/files/JIFSFversion.java
trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java
trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Device.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Directory.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Driver.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2File.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Object.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2RootEntry.java
trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/TableEntry.java
trunk/fs/src/fs/org/jnode/fs/ntfs/AttributeListAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/AttributeListAttributeNonRes.java
trunk/fs/src/fs/org/jnode/fs/ntfs/AttributeListAttributeRes.java
trunk/fs/src/fs/org/jnode/fs/ntfs/AttributeListBlock.java
trunk/fs/src/fs/org/jnode/fs/ntfs/AttributeListEntry.java
trunk/fs/src/fs/org/jnode/fs/ntfs/BootRecord.java
trunk/fs/src/fs/org/jnode/fs/ntfs/DataRun.java
trunk/fs/src/fs/org/jnode/fs/ntfs/FileNameAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/FileRecord.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexAllocationAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexBlock.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntry.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntryIterator.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexHeader.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexRoot.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexRootAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/MasterFileTable.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSDirectory.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFile.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSIndex.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSNonResidentAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSRecord.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSResidentAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSStructure.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSUTIL.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSVolume.java
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/ExtFSEntry.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -21,14 +21,14 @@
package org.jnode.fs.jifs;
+import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
-import org.jnode.fs.FSDirectory;
/**
* @author Andreas H\u00e4nel
*/
public interface ExtFSEntry extends FSEntry {
- public void setParent(FSDirectory parent);
-
+ public void setParent(FSDirectory parent);
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -47,9 +47,9 @@
public JIFSDirectory() {
entries = new HashMap<String, FSEntry>();
}
-
+
public JIFSDirectory(String name) {
- this();
+ this();
label = name;
}
@@ -61,9 +61,9 @@
public void refresh() {
return;
}
-
+
protected void clear() {
- entries.clear();
+ entries.clear();
}
public void addFSE(FSEntry entry) {
@@ -74,7 +74,7 @@
* Flush the contents of this directory to the persistent storage
*/
public void flush() throws IOException {
- //TODO -> extended FSEntry maybe have to be flushed
+ // TODO -> extended FSEntry maybe have to be flushed
}
public FSEntry addDirectory(String name) {
@@ -131,7 +131,7 @@
}
public void setName(String name) {
- this.label=name;
+ this.label = name;
}
public boolean isDirectory() {
@@ -145,11 +145,11 @@
public FSDirectory getParent() {
return parent;
}
-
- public void setParent(FSDirectory parent){
- this.parent=parent;
- }
+ public void setParent(FSDirectory parent) {
+ this.parent = parent;
+ }
+
public String getName() {
return label;
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFSFile.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -40,134 +40,135 @@
*/
public class JIFSFile implements ExtFSEntry, FSFile {
- protected String name;
- protected StringBuffer data = new StringBuffer();
- protected boolean isvalid = true;
-
- private FSDirectory parent = null;
-
- public JIFSFile() {
- refresh();
- }
-
- public JIFSFile(String name) {
- this.name = name;
- }
-
- public JIFSFile(String name, FSDirectory parent) {
- this(name);
- this.parent = parent;
- refresh();
- }
+ protected String name;
+ protected StringBuffer data = new StringBuffer();
+ protected boolean isvalid = true;
- /**
- * Flush the contents of this file to the persistent storage.<br>
- * Does nothing, because the JIFSFile is a virtual File.
- */
- public void flush() throws IOException {
- }
+ private FSDirectory parent = null;
- public long getLength(){
- return data.length();
- }
-
- protected void cleardata(){
- data.delete(0,data.length());
- }
-
- protected void addString(String add){
- data.append(add);
- }
-
- protected void addStringln(String add){
- addString(add);
- addStringln();
- }
-
- protected void addStringln(){
- addString("\n");
- }
-
- public void refresh(){
- cleardata();
- addString("JIFSFile\nFilename :"+name+"\n");
- }
-
- //public void read(long fileOffset, byte[] dest, int off, int len){
- public void read(long fileOffset, ByteBuffer destBuf){
- refresh();
- byte[] readdata = data.toString().getBytes();
- destBuf.put(readdata, (int)fileOffset, destBuf.remaining());
- }
-
- //public void write(long fileOffset, byte[] src, int off, int len) throws IOException{
- public void write(long fileOffset, ByteBuffer src) throws IOException{
- throw new IOException("can not write to JNIFSFile..");
- }
-
- public void setLength(long length){
- return;
- }
+ public JIFSFile() {
+ refresh();
+ }
- public boolean isValid(){
- return isvalid;
- }
-
- public FileSystem getFileSystem(){
- //TODO
- return null;
- }
-
- public boolean isDirty(){
- return false;
- }
-
- public FSAccessRights getAccessRights(){
- return null;
- }
-
- public FSDirectory getDirectory(){
- return null;
- }
-
- public FSFile getFile(){
- return this;
- }
-
- public void setLastModified(long l){
- return;
- }
-
- public long getLastModified(){
- return System.currentTimeMillis();
- }
-
- public void setName(String name){
- this.name=name;
- }
-
- public boolean isDirectory(){
- return false;
- }
-
- public boolean isFile(){
- return true;
- }
-
- public FSDirectory getParent(){
- return parent;
- }
-
- public void setParent(FSDirectory parent){
- this.parent=parent;
- }
-
- public String getName(){
- return name;
- }
-
- public Iterator<FSEntry> iterator(){
- return new JIFSDirIterator(new HashSet<FSEntry>());
- }
+ public JIFSFile(String name) {
+ this.name = name;
+ }
+ public JIFSFile(String name, FSDirectory parent) {
+ this(name);
+ this.parent = parent;
+ refresh();
+ }
+
+ /**
+ * Flush the contents of this file to the persistent storage.<br>
+ * Does nothing, because the JIFSFile is a virtual File.
+ */
+ public void flush() throws IOException {
+ }
+
+ public long getLength() {
+ return data.length();
+ }
+
+ protected void cleardata() {
+ data.delete(0, data.length());
+ }
+
+ protected void addString(String add) {
+ data.append(add);
+ }
+
+ protected void addStringln(String add) {
+ addString(add);
+ addStringln();
+ }
+
+ protected void addStringln() {
+ addString("\n");
+ }
+
+ public void refresh() {
+ cleardata();
+ addString("JIFSFile\nFilename :" + name + "\n");
+ }
+
+ // public void read(long fileOffset, byte[] dest, int off, int len){
+ public void read(long fileOffset, ByteBuffer destBuf) {
+ refresh();
+ byte[] readdata = data.toString().getBytes();
+ destBuf.put(readdata, (int) fileOffset, destBuf.remaining());
+ }
+
+ // public void write(long fileOffset, byte[] src, int off, int len) throws
+ // IOException{
+ public void write(long fileOffset, ByteBuffer src) throws IOException {
+ throw new IOException("can not write to JNIFSFile..");
+ }
+
+ public void setLength(long length) {
+ return;
+ }
+
+ public boolean isValid() {
+ return isvalid;
+ }
+
+ public FileSystem getFileSystem() {
+ // TODO
+ return null;
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public FSAccessRights getAccessRights() {
+ return null;
+ }
+
+ public FSDirectory getDirectory() {
+ return null;
+ }
+
+ public FSFile getFile() {
+ return this;
+ }
+
+ public void setLastModified(long l) {
+ return;
+ }
+
+ public long getLastModified() {
+ return System.currentTimeMillis();
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isDirectory() {
+ return false;
+ }
+
+ public boolean isFile() {
+ return true;
+ }
+
+ public FSDirectory getParent() {
+ return parent;
+ }
+
+ public void setParent(FSDirectory parent) {
+ this.parent = parent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Iterator<FSEntry> iterator() {
+ return new JIFSDirIterator(new HashSet<FSEntry>());
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -30,115 +30,107 @@
import org.jnode.fs.FileSystem;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.jifs.directories.JIFSDrootDir;
-import org.jnode.fs.nfs.nfs2.NFS2FileSystemType;
/**
* @author Andreas H\u00e4nel
*/
public class JIFileSystem implements FileSystem<JIFSDirectory> {
- private JIFSDirectory rootDir = null;
- private Device device;
+ private JIFSDirectory rootDir = null;
+ private Device device;
private final JIFileSystemType type;
/**
- * Constructor for JIFileSystem in specified readOnly mode
- */
- public JIFileSystem(Device device, boolean readOnly, JIFileSystemType type) throws FileSystemException {
- if (readOnly==false){
- throw new FileSystemException("JIFS can not be created as writable...");
- }
- this.device = device;
+ * Constructor for JIFileSystem in specified readOnly mode
+ */
+ public JIFileSystem(Device device, boolean readOnly, JIFileSystemType type)
+ throws FileSystemException {
+ if (readOnly == false) {
+ throw new FileSystemException("JIFS can not be created as writable...");
+ }
+ this.device = device;
this.type = type;
- //try {
- //rootDir = new JIFSDirectory(this.device.getId(), true);
- rootDir = new JIFSDrootDir(device.getId());
- //} catch ( IOException e){
- // e.printStackTrace();
- //}
- }
+ rootDir = new JIFSDrootDir(device.getId());
+ }
- final public JIFileSystemType getType() {
- return type;
- }
+ public final JIFileSystemType getType() {
+ return type;
+ }
- /**
- * Is the filesystem mounted in readonly mode ?
- */
- public boolean isReadOnly()
- {
- return true; // always readOnly
- }
+ /**
+ * Is the filesystem mounted in readonly mode ?
+ */
+ public boolean isReadOnly() {
+ return true; // always readOnly
+ }
+ public void close() {
+ return;
+ }
- public void close(){
- return;
- }
-
public boolean isClosed() {
return false;
}
- public Device getDevice(){
- return device;
- }
+ public Device getDevice() {
+ return device;
+ }
- /**
- * Flush all changed structures to the device. Since JIFS is readonly, this method does nothing.
- *
- * @throws IOException
- */
- public void flush() throws IOException {
- return;
- }
+ /**
+ * Flush all changed structures to the device. Since JIFS is readonly, this
+ * method does nothing.
+ *
+ * @throws IOException
+ */
+ public void flush() throws IOException {
+ return;
+ }
- /**
- * Gets the root entry of this filesystem. This is usually a director, but
- * this is not required.
- *
- * @return rootDir
- */
- public JIFSDirectory getRootEntry() {
- return rootDir;
- }
+ /**
+ * Gets the root entry of this filesystem. This is usually a director, but
+ * this is not required.
+ *
+ * @return rootDir
+ */
+ public JIFSDirectory getRootEntry() {
+ return rootDir;
+ }
- /**
- * Gets the file for the given entry.
- *
- * @return null
- * @param entry
- */
- public synchronized JIFSFile getFile(FSEntry entry) {
- return null;
- }
+ /**
+ * Gets the file for the given entry.
+ *
+ * @return null
+ * @param entry
+ */
+ public synchronized JIFSFile getFile(FSEntry entry) {
+ return null;
+ }
+ protected FSFile createFile(FSEntry entry) throws IOException {
+ return null;
+ }
- protected FSFile createFile(FSEntry entry) throws IOException {
- return null;
- }
+ protected FSDirectory createDirectory(FSEntry entry) throws IOException {
+ return null;
+ }
- protected FSDirectory createDirectory(FSEntry entry) throws IOException {
- return null;
- }
+ protected FSEntry createRootEntry() throws IOException {
+ return null;
+ }
- protected FSEntry createRootEntry() throws IOException {
- return null;
- }
+ public long getFreeSpace() {
+ // TODO implement me
+ return 0;
+ }
+ public long getTotalSpace() {
+ // TODO implement me
+ return 0;
+ }
- public long getFreeSpace() {
- // TODO implement me
- return 0;
- }
+ public long getUsableSpace() {
+ // TODO implement me
+ return 0;
+ }
- public long getTotalSpace() {
- // TODO implement me
- return 0;
- }
-
- public long getUsableSpace() {
- // TODO implement me
- return 0;
- }
-
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystemType.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -19,7 +19,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
- package org.jnode.fs.jifs;
+package org.jnode.fs.jifs;
import org.apache.log4j.Logger;
import org.jnode.driver.Device;
@@ -34,8 +34,8 @@
public static final String VIRTUAL_DEVICE_NAME = "jifs";
- /** Logger*/
- private static final Logger log = Logger.getLogger(JIFileSystemType.class);
+ /** Logger */
+ private static final Logger log = Logger.getLogger(JIFileSystemType.class);
/**
* Gets the unique name of this file system type.
@@ -44,19 +44,19 @@
return "JIFS";
}
- /**
- * Create a filesystem for a given device.
- *
- * @param device
- * @param readOnly
- * @return JIFileSystem(device,readOnly)
- * @throws FileSystemException
- */
- public JIFileSystem create(Device device, boolean readOnly) throws FileSystemException {
- JIFileSystem ret = new JIFileSystem(device, readOnly, this);
- if (ret== null){
- log.error("got NULL from the JIFileSystem...");
- }
- return ret;
- }
+ /**
+ * Create a filesystem for a given device.
+ *
+ * @param device
+ * @param readOnly
+ * @return JIFileSystem(device,readOnly)
+ * @throws FileSystemException
+ */
+ public JIFileSystem create(Device device, boolean readOnly) throws FileSystemException {
+ JIFileSystem ret = new JIFileSystem(device, readOnly, this);
+ if (ret == null) {
+ log.error("got NULL from the JIFileSystem...");
+ }
+ return ret;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -26,7 +26,6 @@
import javax.naming.NameNotFoundException;
-import org.apache.log4j.Logger;
import org.jnode.naming.InitialNaming;
import org.jnode.plugin.Plugin;
import org.jnode.plugin.PluginManager;
@@ -38,52 +37,50 @@
import org.jnode.shell.help.Syntax;
import org.jnode.shell.help.argument.OptionArgument;
-//todo fix class name
+// TODO fix class name
+// TODO this class is actually just PluginCommand specialized for JIFS ...
/**
* Just mounts initial JIFS on /Jifs
*
* @author Andreas H\u00e4nel
*/
-public class CreateJIFSCommand extends AbstractCommand{
+public class CreateJIFSCommand extends AbstractCommand {
- private static final Logger log = Logger.getLogger(CreateJIFSCommand.class);
-
- static final OptionArgument ACTION = new OptionArgument("action",
- "Action to perform", new OptionArgument.Option[] {
- new OptionArgument.Option("start", "start the jifs"),
- new OptionArgument.Option("stop", "stop the jifs"),
- new OptionArgument.Option("restart", "restart the jifs"),
- });
-
+ static final OptionArgument ACTION =
+ new OptionArgument("action", "Action to perform", new OptionArgument.Option[] {
+ new OptionArgument.Option("start", "start the jifs"),
+ new OptionArgument.Option("stop", "stop the jifs"),
+ new OptionArgument.Option("restart", "restart the jifs")});
+
static final Parameter PARAM_ACTION = new Parameter(ACTION, Parameter.MANDATORY);
-
- public static Help.Info HELP_INFO = new Help.Info("jifs",
- new Syntax[] { new Syntax(
- "JIFS - Jnode Information FileSystem",
- new Parameter[] { PARAM_ACTION })});
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception {
- ParsedArguments cmdLine = HELP_INFO.parse(commandLine);
- String Act = ACTION.getValue(cmdLine);
-
- try{
- final PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
- final Plugin p = mgr.getRegistry().getPluginDescriptor("org.jnode.fs.jifs.def").getPlugin();
- if (new String("start").equals(Act)){
- p.start();
- }
- if (new String("stop").equals(Act)){
- p.stop();
- }
- if (new String("restart").equals(Act)){
- p.stop();
- p.start();
- }
- } catch (NameNotFoundException N){
- System.err.println(N);
- }
+ public static Help.Info HELP_INFO =
+ new Help.Info("jifs", new Syntax[] {new Syntax("JIFS - Jnode Information FileSystem",
+ new Parameter[] {PARAM_ACTION})});
- }
-
-
+ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ throws Exception {
+ ParsedArguments cmdLine = HELP_INFO.parse(commandLine);
+ String Act = ACTION.getValue(cmdLine);
+
+ try {
+ final PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
+ final Plugin p =
+ mgr.getRegistry().getPluginDescriptor("org.jnode.fs.jifs.def").getPlugin();
+ if (new String("start").equals(Act)) {
+ p.start();
+ }
+ if (new String("stop").equals(Act)) {
+ p.stop();
+ }
+ if (new String("restart").equals(Act)) {
+ p.stop();
+ p.start();
+ }
+ } catch (NameNotFoundException N) {
+ System.err.println(N);
+ }
+
+ }
+
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSExtension.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSExtension.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSExtension.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -46,101 +46,101 @@
* @author Andreas H\u00e4nel
*/
final class JIFSExtension implements ExtensionPointListener {
-
- /** My logger */
- private static final Logger log = Logger.getLogger(JIFSExtension.class);
- /** The org.jnode.fs.jifs.def.info extension point */
- private final ExtensionPoint infoEP;
- private JIFSDirectory extdir;
-
- protected JIFSExtension(ExtensionPoint infoEP){
- if (infoEP == null) {
- throw new IllegalArgumentException("The info extension-point cannot be null.");
- }
- this.infoEP = infoEP;
- try {
- FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
- final DeviceManager dm = DeviceUtils.getDeviceManager();
- VirtualDevice dev = (VirtualDevice) dm.getDevice(JIFileSystemType.VIRTUAL_DEVICE_NAME);
- JIFSDirectory rootdir = (JIFSDirectory)fSS.getFileSystem(dev).getRootEntry();
- extdir = (JIFSDirectory)rootdir.getEntry("extended").getDirectory();
- } catch (NameNotFoundException e){
- log.error("filesystemservice / filesystemtype not found");
- } catch (DeviceNotFoundException ex){
- log.info("no jifs present");
- } catch (IOException ex){
- log.error(ex);
+ /** My logger */
+ private static final Logger log = Logger.getLogger(JIFSExtension.class);
+
+ /** The org.jnode.fs.jifs.def.info extension point */
+ private final ExtensionPoint infoEP;
+ private JIFSDirectory extdir;
+
+ protected JIFSExtension(ExtensionPoint infoEP) {
+
+ if (infoEP == null) {
+ throw new IllegalArgumentException("The info extension-point cannot be null.");
}
+ this.infoEP = infoEP;
+ try {
+ FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
+ final DeviceManager dm = DeviceUtils.getDeviceManager();
+ VirtualDevice dev = (VirtualDevice) dm.getDevice(JIFileSystemType.VIRTUAL_DEVICE_NAME);
+ JIFSDirectory rootdir = (JIFSDirectory) fSS.getFileSystem(dev).getRootEntry();
+ extdir = (JIFSDirectory) rootdir.getEntry("extended").getDirectory();
+ } catch (NameNotFoundException e) {
+ log.error("filesystemservice / filesystemtype not found");
+ } catch (DeviceNotFoundException ex) {
+ log.info("no jifs present");
+ } catch (IOException ex) {
+ log.error(ex);
+ }
refresh();
- }
-
-
- /**
- * An extension has been added to an extension point
- * @param point
- * @param extension
- */
- public void extensionAdded(ExtensionPoint point, Extension extension){
- refresh();
- }
+ }
- /**
- * An extension has been removed from an extension point
- * @param point
- * @param extension
- */
- public void extensionRemoved(ExtensionPoint point, Extension extension){
- refresh();
- }
-
- private void refresh(){
- if (extdir==null){return;}
- extdir.refresh();
- final Extension[] extensions = infoEP.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- final Extension ext = extensions[i];
- final ConfigurationElement[] elements = ext.getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- addEntry(elements[j]);
- }
- }
- }
-
-
- private void addEntry(ConfigurationElement element){
- final String className = element.getAttribute("class");
- final String entryName = element.getAttribute("name");
- if (className != null) {
- try {
- final ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Class<?> c = cl.loadClass(className);
- Object o = c.newInstance();
- ExtFSEntry entry = (ExtFSEntry)o;
- if (entry.getName()==null){
- if (entryName!=null){
- entry.setName(entryName);
- } else {
- entry.setName(className);
- }
- }
- entry.setParent(extdir);
- FSEntry add = entry;
- extdir.addFSE(add);
- } catch (ClassCastException ex) {
- log.error(
- "Given class "
- + className
- + " does not implement .");
- } catch (ClassNotFoundException ex) {
- log.error("Cannot load " + className);
- } catch (IllegalAccessException ex) {
- log.error("No access to " + className);
- } catch (InstantiationException ex) {
- log.error(ex);
- } catch (IOException ex){
- log.error("could not set name of file: "+ entryName );
- }
- }
- }
+ /**
+ * An extension has been added to an extension point
+ *
+ * @param point
+ * @param extension
+ */
+ public void extensionAdded(ExtensionPoint point, Extension extension) {
+ refresh();
+ }
+
+ /**
+ * An extension has been removed from an extension point
+ *
+ * @param point
+ * @param extension
+ */
+ public void extensionRemoved(ExtensionPoint point, Extension extension) {
+ refresh();
+ }
+
+ private void refresh() {
+ if (extdir == null) {
+ return;
+ }
+ extdir.refresh();
+ final Extension[] extensions = infoEP.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ final Extension ext = extensions[i];
+ final ConfigurationElement[] elements = ext.getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ addEntry(elements[j]);
+ }
+ }
+ }
+
+ private void addEntry(ConfigurationElement element) {
+ final String className = element.getAttribute("class");
+ final String entryName = element.getAttribute("name");
+ if (className != null) {
+ try {
+ final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class<?> c = cl.loadClass(className);
+ Object o = c.newInstance();
+ ExtFSEntry entry = (ExtFSEntry) o;
+ if (entry.getName() == null) {
+ if (entryName != null) {
+ entry.setName(entryName);
+ } else {
+ entry.setName(className);
+ }
+ }
+ entry.setParent(extdir);
+ FSEntry add = entry;
+ extdir.addFSE(add);
+ } catch (ClassCastException ex) {
+ log.error("Given class " + className + " does not implement .");
+ } catch (ClassNotFoundException ex) {
+ log.error("Cannot load " + className);
+ } catch (IllegalAccessException ex) {
+ log.error("No access to " + className);
+ } catch (InstantiationException ex) {
+ log.error(ex);
+ } catch (IOException ex) {
+ log.error("could not set name of file: " + entryName);
+ }
+ }
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java 2008-06-07 10:22:01 UTC (rev 4208)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/def/JIFSPlugin.java 2008-06-07 11:48:31 UTC (rev 4209)
@@ -21,18 +21,20 @@
package org.jnode.fs.jifs.def;
+import java.io.IOException;
+
+import javax.naming.NameNotFoundException;
+
import org.apache.log4j.Logger;
import org.jnode.driver.DeviceAlreadyRegisteredException;
+import org.jnode.driver.DeviceException;
import org.jnode.driver.DeviceManager;
import org.jnode.driver.DeviceNotFoundException;...
[truncated message content] |
|
From: <ls...@us...> - 2008-06-15 17:08:34
|
Revision: 4249
http://jnode.svn.sourceforge.net/jnode/?rev=4249&view=rev
Author: lsantha
Date: 2008-06-15 10:08:33 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
File systems sizes are -1 when undefined.
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
Modified: trunk/fs/src/fs/org/jnode/fs/FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/FileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -62,9 +62,24 @@
*/
public boolean isClosed();
+ /**
+ * The total size of this file system.
+ * @return if -1 this feature is unsupported
+ * @throws IOException if an I/O error occurs
+ */
public long getTotalSpace() throws IOException;
+ /**
+ * The free space of this file system.
+ * @return if -1 this feature is unsupported
+ * @throws IOException if an I/O error occurs
+ */
public long getFreeSpace() throws IOException;
+ /**
+ * The usabe space of this file system.
+ * @return if -1 this feature is unsupported
+ * @throws IOException if an I/O error occurs
+ */
public long getUsableSpace() throws IOException;
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -947,6 +947,6 @@
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -203,16 +203,16 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -164,17 +164,17 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
FTPFile[] dirDetails(String path) throws IOException, FTPException, ParseException {
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -104,7 +104,7 @@
public final long getUsableSpace() {
// TODO Auto-generated method stub
- return 0;
+ return -1;
}
public final Catalog getCatalog() {
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -110,16 +110,16 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/jarfs/JarFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -81,16 +81,16 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -89,16 +89,16 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -120,17 +120,17 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -106,16 +106,16 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/VirtualFS.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -100,16 +100,16 @@
public long getFreeSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getTotalSpace() {
// TODO implement me
- return 0;
+ return -1;
}
public long getUsableSpace() {
// TODO implement me
- return 0;
+ return -1;
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-06-15 15:47:01 UTC (rev 4248)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-06-15 17:08:33 UTC (rev 4249)
@@ -98,24 +98,16 @@
return false;
}
- public long getFreeSpace() {
- try {
- return root.smbFile.getDiskFreeSpace();
- } catch (SmbException e) {
- return 0;
- }
+ public long getFreeSpace() throws IOException {
+ return root.smbFile.getDiskFreeSpace();
}
- public long getTotalSpace() {
+ public long getTotalSpace() throws IOException {
//todo fix it
- return 1;
+ return -1;
}
- public long getUsableSpace() {
- try {
- return root.smbFile.getDiskFreeSpace();
- } catch (SmbException e) {
- return 0;
- }
+ public long getUsableSpace() throws IOException {
+ return root.smbFile.getDiskFreeSpace();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2008-06-15 17:12:51
|
Revision: 4251
http://jnode.svn.sourceforge.net/jnode/?rev=4251&view=rev
Author: lsantha
Date: 2008-06-15 10:12:49 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
Codestyle fixes.
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/command/DFCommand.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
Modified: trunk/fs/src/fs/org/jnode/fs/command/DFCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/DFCommand.java 2008-06-15 17:09:21 UTC (rev 4250)
+++ trunk/fs/src/fs/org/jnode/fs/command/DFCommand.java 2008-06-15 17:12:49 UTC (rev 4251)
@@ -23,12 +23,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
-import java.io.StringWriter;
import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.Map;
-
import javax.naming.NameNotFoundException;
-
import org.jnode.driver.Device;
import org.jnode.driver.DeviceManager;
import org.jnode.fs.FileSystem;
@@ -41,25 +39,24 @@
/**
* The DF command prints disk usage information for devices with filesystems.
- *
+ *
* @author ga...@jn...
* @author cr...@jn...
* @author Levente S\u00e1ntha
- *
*/
public class DFCommand extends AbstractCommand {
-
+
private final DeviceArgument ARG_DEVICE = new DeviceArgument(
- "device", Argument.OPTIONAL,
- "The device for which disk usage inforrmation should be displayed");
+ "device", Argument.OPTIONAL,
+ "The device for which disk usage inforrmation should be displayed");
public DFCommand() {
super("Print file system usage information");
registerArguments(ARG_DEVICE);
}
-
+
public void execute(CommandLine commandLine, InputStream in,
- PrintStream out, PrintStream err) throws NameNotFoundException {
+ PrintStream out, PrintStream err) throws NameNotFoundException {
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
final Map<String, String> mountPoints = fss.getDeviceMountPoints();
StringWriter sw = new StringWriter();
@@ -91,8 +88,8 @@
out.print(sw.toString());
}
+
/**
- *
* @param out
* @param dev
* @param fs
@@ -114,7 +111,7 @@
str = free < 0 ? "unknown" : String.valueOf(free);
format(out, str, false);
-
+
out.println(mountPoint);
} catch (IOException ex) {
out.println("\tError getting disk usage information for " + mountPoint + " on " + dev.getId() +
@@ -125,14 +122,14 @@
private void format(PrintWriter out, String str, boolean left) {
int ln;
ln = 15 - str.length();
- if(ln < 0) str = str.substring(0, 15);
+ if (ln < 0) str = str.substring(0, 15);
else {
- if(left){
+ if (left) {
out.print(str);
}
- for(int i = 0; i < ln; i++) out.print(' ');
+ for (int i = 0; i < ln; i++) out.print(' ');
}
- if(!left)
+ if (!left)
out.print(str);
out.print(' ');
}
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java 2008-06-15 17:09:21 UTC (rev 4250)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660DTime.java 2008-06-15 17:12:49 UTC (rev 4251)
@@ -1,9 +1,9 @@
package org.jnode.fs.iso9660;
-import org.jnode.util.LittleEndian;
import java.util.Calendar;
+import java.util.GregorianCalendar;
import java.util.TimeZone;
-import java.util.GregorianCalendar;
+import org.jnode.util.LittleEndian;
/**
* ISO9660 datetime structure.
@@ -12,38 +12,53 @@
*/
public class ISO9660DTime {
- /** Length of the structure. */
+ /**
+ * Length of the structure.
+ */
static final int LENGTH = 7;
- /** Number of years since 1900. */
+ /**
+ * Number of years since 1900.
+ */
private final int/*uint8*/ year;
- /** Month of the year from 1 to 12. */
+ /**
+ * Month of the year from 1 to 12.
+ */
private final int/*uint8*/ month;
- /** Day of the month from 1 to 31. */
+ /**
+ * Day of the month from 1 to 31.
+ */
private final int/*uint8*/ day;
- /** Hour of the day from 0 to 23. */
+ /**
+ * Hour of the day from 0 to 23.
+ */
private final int/*uint8*/ hour;
- /** Minute of the hour from 0 to 59. */
+ /**
+ * Minute of the hour from 0 to 59.
+ */
private final int/*uint8*/ minute;
- /** Second of the minute from 0 to 59. */
+ /**
+ * Second of the minute from 0 to 59.
+ */
private final int/*uint8*/ second;
- /** GMT values -48 .. + 52 in 15 minute intervals (e.g. -48 = GMT-12, +48=GMT+12, 0=UTC.) */
+ /**
+ * GMT values -48 .. + 52 in 15 minute intervals (e.g. -48 = GMT-12, +48=GMT+12, 0=UTC.)
+ */
private final int/*int8*/ gmtOffset;
/**
* Constructs an ISO9660 datetime structure by reading from the provided byte array.
*
* @param buff the byte array from which to read.
- * @param off offset into the byte array at which to read the struct.
+ * @param off offset into the byte array at which to read the struct.
*/
- public ISO9660DTime(byte[] buff, int off)
- {
+ public ISO9660DTime(byte[] buff, int off) {
year = LittleEndian.getUInt8(buff, off);
month = LittleEndian.getUInt8(buff, off + 1);
day = LittleEndian.getUInt8(buff, off + 2);
@@ -58,8 +73,7 @@
*
* @return the date as millis since 1970.
*/
- public long toJavaMillis()
- {
+ public long toJavaMillis() {
// Force use of the Gregorian calendar in UTC and manually offset hours later.
// Mainly because it isn't convenient to create a TimeZone from a UTC/GMT offset.
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-06-15 17:09:21 UTC (rev 4250)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-06-15 17:12:49 UTC (rev 4251)
@@ -24,7 +24,6 @@
import java.io.IOException;
import jcifs.smb.NtlmAuthenticator;
import jcifs.smb.NtlmPasswordAuthentication;
-import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
import org.jnode.fs.FileSystem;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|