|
From: <ga...@us...> - 2012-04-19 15:53:00
|
Revision: 5897
http://jnode.svn.sourceforge.net/jnode/?rev=5897&view=rev
Author: galatnm
Date: 2012-04-19 15:52:49 +0000 (Thu, 19 Apr 2012)
Log Message:
-----------
Filesystem code cleanup.
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
trunk/fs/src/fs/org/jnode/fs/fat/FatLfnDirectory.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java
trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemManager.java
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java
Modified: trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java 2012-04-19 12:57:10 UTC (rev 5896)
+++ trunk/fs/src/fs/org/jnode/fs/command/MountCommand.java 2012-04-19 15:52:49 UTC (rev 5897)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.PrintWriter;
import java.util.Map;
-
import org.jnode.driver.Device;
import org.jnode.driver.block.BlockDeviceAPI;
import org.jnode.fs.FileSystem;
@@ -68,12 +67,12 @@
if (!argDevice.isSet()) {
// List all mounted file systems
Map<String, FileSystem<?>> filesystems = fss.getMountPoints();
- for (String mountPoint : filesystems.keySet()) {
- FileSystem<?> fs = filesystems.get(mountPoint);
+ for (Map.Entry<String, FileSystem<?>> stringFileSystemEntry : filesystems.entrySet()) {
+ FileSystem<?> fs = stringFileSystemEntry.getValue();
Device device = fs.getDevice();
String mode = fs.isReadOnly() ? "ro" : "rw";
String type = fs.getType().getName();
- out.format(fmt_mount, device.getId(), mountPoint, type, mode);
+ out.format(fmt_mount, device.getId(), stringFileSystemEntry.getKey(), type, mode);
}
} else {
// Get the parameters
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatLfnDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatLfnDirectory.java 2012-04-19 12:57:10 UTC (rev 5896)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatLfnDirectory.java 2012-04-19 15:52:49 UTC (rev 5897)
@@ -23,10 +23,10 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
-
import org.jnode.fs.FSEntry;
import org.jnode.fs.ReadOnlyFileSystemException;
@@ -171,9 +171,7 @@
for (LfnEntry currentEntry : shortNameIndex.values()) {
FatBasicDirEntry[] encoded = currentEntry.compactForm();
- for (int i = 0; i < encoded.length; i++) {
- destination.add(encoded[i]);
- }
+ Collections.addAll(destination, encoded);
}
final int size = destination.size();
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2012-04-19 12:57:10 UTC (rev 5896)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2012-04-19 15:52:49 UTC (rev 5897)
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.apache.log4j.Logger;
@@ -273,9 +274,7 @@
List<LeafRecord> lfList = new LinkedList<LeafRecord>();
for (IndexRecord rec : records) {
LeafRecord[] lfr = getRecords(parentID, rec.getIndex());
- for (LeafRecord lr : lfr) {
- lfList.add(lr);
- }
+ Collections.addAll(lfList, lfr);
}
return lfList.toArray(new LeafRecord[lfList.size()]);
} else if (nd.isLeafNode()) {
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java 2012-04-19 12:57:10 UTC (rev 5896)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/CompressedDataRun.java 2012-04-19 15:52:49 UTC (rev 5897)
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.Arrays;
-
import org.apache.log4j.Logger;
import org.jnode.util.LittleEndian;
@@ -311,9 +310,7 @@
(realSrcOffset < realDestOffset && realSrcOffset + length > realDestOffset ||
realDestOffset < realSrcOffset && realDestOffset + length > realSrcOffset)) {
- for (int i = 0; i < length; i++) {
- destArray[realDestOffset + i] = srcArray[realSrcOffset + i];
- }
+ System.arraycopy(srcArray, realSrcOffset + 0, destArray, realDestOffset + 0, length);
return;
}
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemManager.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemManager.java 2012-04-19 12:57:10 UTC (rev 5896)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemManager.java 2012-04-19 15:52:49 UTC (rev 5897)
@@ -22,9 +22,9 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.jnode.driver.Device;
import org.jnode.fs.FileSystem;
@@ -33,8 +33,9 @@
*/
final class FileSystemManager {
/** All registed filesystems (device, fs) */
- private final Map<Device, FileSystem<?>> filesystems = new HashMap<Device, FileSystem<?>>();
+ private Map<Device, FileSystem<?>> filesystems = Collections.synchronizedMap(new HashMap<Device, FileSystem<?>>());
+
/**
* Register a mounted filesystem
*
@@ -42,9 +43,7 @@
*/
public void registerFileSystem(FileSystem<?> fs) {
final Device device = fs.getDevice();
- synchronized (this) {
- filesystems.put(device, fs);
- }
+ filesystems.put(device, fs);
}
/**
@@ -52,7 +51,7 @@
*
* @param device
*/
- public synchronized FileSystem<?> unregisterFileSystem(Device device) {
+ public FileSystem<?> unregisterFileSystem(Device device) {
return filesystems.remove(device);
}
@@ -62,7 +61,7 @@
* @param device
* @return null if no filesystem was found.
*/
- public synchronized FileSystem<?> getFileSystem(Device device) {
+ public FileSystem<?> getFileSystem(Device device) {
return filesystems.get(device);
}
@@ -70,7 +69,7 @@
* Gets all registered filesystems. All instances of the returned collection
* are instanceof FileSystem.
*/
- public synchronized Collection<FileSystem<?>> fileSystems() {
+ public Collection<FileSystem<?>> fileSystems() {
return new ArrayList<FileSystem<?>>(filesystems.values());
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java 2012-04-19 12:57:10 UTC (rev 5896)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java 2012-04-19 15:52:49 UTC (rev 5897)
@@ -22,17 +22,14 @@
import java.io.IOException;
import java.io.VMFile;
-import org.jnode.java.io.VMFileSystemAPI;
import java.io.VMIOUtils;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
-
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-
import org.apache.log4j.Logger;
import org.jnode.driver.Device;
import org.jnode.driver.DeviceAlreadyRegisteredException;
@@ -42,6 +39,7 @@
import org.jnode.fs.FileSystemException;
import org.jnode.fs.FileSystemType;
import org.jnode.fs.service.FileSystemService;
+import org.jnode.java.io.VMFileSystemAPI;
import org.jnode.naming.InitialNaming;
import org.jnode.plugin.Plugin;
import org.jnode.plugin.PluginDescriptor;
@@ -160,9 +158,9 @@
public Map<String, String> getDeviceMountPoints() {
Map<String, FileSystem<?>> mounts = api.getMountPoints();
Map<String, String> result = new TreeMap<String, String>();
- for (String path : mounts.keySet()) {
- FileSystem<?> fs = (FileSystem<?>) mounts.get(path);
- result.put(fs.getDevice().getId(), path);
+ for (Map.Entry<String, FileSystem<?>> stringFileSystemEntry : mounts.entrySet()) {
+ FileSystem<?> fs = (FileSystem<?>) stringFileSystemEntry.getValue();
+ result.put(fs.getDevice().getId(), stringFileSystemEntry.getKey());
}
return result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|