From: <ls...@us...> - 2007-10-17 18:30:20
|
Revision: 3557 http://jnode.svn.sourceforge.net/jnode/?rev=3557&view=rev Author: lsantha Date: 2007-10-17 11:30:15 -0700 (Wed, 17 Oct 2007) Log Message: ----------- Initial version of NFS file system implementation by Andrei Dore. Modified Paths: -------------- trunk/all/build.xml trunk/all/conf/default-plugin-list.xml trunk/fs/.classpath trunk/fs/build.xml trunk/net/.classpath trunk/net/build.xml trunk/net/descriptors/org.jnode.net.command.xml Added Paths: ----------- trunk/fs/descriptors/org.jnode.fs.nfs.command.xml trunk/fs/descriptors/org.jnode.fs.nfs.xml trunk/fs/src/fs/org/jnode/fs/nfs/ trunk/fs/src/fs/org/jnode/fs/nfs/command/ trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/ 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/rpc/ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/DirPath.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/FileHandle.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Mount1Client.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/MountResult.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Name.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/AbstractResult.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/Entry.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileAttribute.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileType.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/ListDirectoryResult.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/LookupResult.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/NFS2Client.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/ReadFileResult.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/Status.java trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/Time.java trunk/net/descriptors/org.acplt.oncrpc.xml trunk/net/lib/oncrpc.jar trunk/net/src/net/org/jnode/net/command/RpcInfoCommand.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2007-10-16 08:24:55 UTC (rev 3556) +++ trunk/all/build.xml 2007-10-17 18:30:15 UTC (rev 3557) @@ -50,6 +50,7 @@ <property name="edtftpj.jar" value="${root.dir}/fs/lib/edtftpj-1.5.2.jar"/> <property name="jcifs.jar" value="${root.dir}/fs/lib/jcifs-1.2.6.jar"/> <property name="ejc.jar" value="${root.dir}/core/lib/ejc-3.1.1.jar"/> + <property name="oncrpc.jar" value="${root.dir}/net/lib/oncrpc.jar"/> <!-- libraries needed to run tests --> <property name="jmock-cglib.jar" value="${root.dir}/core/lib/jmock-cglib-1.0.1.jar"/> @@ -217,7 +218,8 @@ <libalias name="edtftpj.jar" alias="${edtftpj.jar}"/> <libalias name="jcifs.jar" alias="${jcifs.jar}"/> <libalias name="ejc.jar" alias="${ejc.jar}"/> - + <libalias name="oncrpc.jar" alias="${oncrpc.jar}"/> + <descriptors dir="${descriptors.dir}/"> <include name="*.xml"/> <exclude name="*plugin-list.xml"/> Modified: trunk/all/conf/default-plugin-list.xml =================================================================== --- trunk/all/conf/default-plugin-list.xml 2007-10-16 08:24:55 UTC (rev 3556) +++ trunk/all/conf/default-plugin-list.xml 2007-10-17 18:30:15 UTC (rev 3557) @@ -119,6 +119,9 @@ <plugin id="jcifs"/> <plugin id="org.jnode.fs.smbfs"/> <plugin id="org.jnode.fs.smbfs.command"/> + + <plugin id="org.jnode.fs.nfs"/> + <plugin id="org.jnode.fs.nfs.command"/> <plugin id="org.jnode.partitions"/> @@ -140,6 +143,8 @@ <plugin id="org.jnode.protocol"/> <plugin id="org.jnode.protocol.ftp"/> <plugin id="org.jnode.protocol.tftp"/> + + <plugin id="org.acplt.oncrpc"/> <plugin id="org.jnode.shell"/> <plugin id="org.jnode.shell.help"/> Modified: trunk/fs/.classpath =================================================================== --- trunk/fs/.classpath 2007-10-16 08:24:55 UTC (rev 3556) +++ trunk/fs/.classpath 2007-10-17 18:30:15 UTC (rev 3557) @@ -17,5 +17,6 @@ <classpathentry kind="lib" path="/JNode-Core/lib/commons-net-1.1.0.jar"/> <classpathentry kind="lib" path="/JNode-Core/lib/jcfe.jar"/> <classpathentry kind="lib" path="/JNode-Core/lib/jfunc.jar"/> + <classpathentry kind="lib" path="/JNode-Net/lib/oncrpc.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/fs/build.xml =================================================================== --- trunk/fs/build.xml 2007-10-16 08:24:55 UTC (rev 3556) +++ trunk/fs/build.xml 2007-10-17 18:30:15 UTC (rev 3557) @@ -14,6 +14,7 @@ <pathelement location="${edtftpj.jar}"/> <pathelement location="${commons-net.jar}"/> <pathelement location="${jcifs.jar}"/> + <pathelement location="${oncrpc.jar}"/> <path refid="cp"/> </path> Added: trunk/fs/descriptors/org.jnode.fs.nfs.command.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.nfs.command.xml (rev 0) +++ trunk/fs/descriptors/org.jnode.fs.nfs.command.xml 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.fs.nfs.command" + name="NFS file system commands for JNode" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + + <requires> + <import plugin="org.jnode.shell"/> + <import plugin="org.jnode.fs.nfs"/> + </requires> + + <runtime> + <library name="jnode-fs.jar"> + <export name="org.jnode.fs.nfs.command.*"/> + </library> + </runtime> + + <extension point="org.jnode.shell.aliases"> + <alias name="nfsmount" + class="org.jnode.fs.nfs.command.NFSMountCommand"/> + </extension> + + <extension point="org.jnode.security.permissions"> + <permission class="java.net.SocketPermission" name="*" actions="connect,resolve"/> + </extension> + +</plugin> \ No newline at end of file Added: trunk/fs/descriptors/org.jnode.fs.nfs.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.nfs.xml (rev 0) +++ trunk/fs/descriptors/org.jnode.fs.nfs.xml 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.fs.nfs" + name="NFS file system for JNode" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + + <requires> + <import plugin="org.jnode.fs"/> + <import plugin="org.acplt.oncrpc"/> + </requires> + + <runtime> + <library name="jnode-fs.jar"> + <export name="org.jnode.fs.nfs.*"/> + <export name="org.jnode.fs.nfs.nfs2.*"/> + <export name="org.jnode.fs.nfs.nfs2.rpc.mount.*"/> + <export name="org.jnode.fs.nfs.nfs2.rpc.nfs.*"/> + </library> + </runtime> + + + <extension point="org.jnode.fs.types"> + <type class="org.jnode.fs.nfs.nfs2.NFS2FileSystemType"/> + </extension> + + + <extension point="org.jnode.security.permissions"> + <permission class="java.net.SocketPermission" name="*" actions="connect,resolve"/> + </extension> + +</plugin> \ No newline at end of file Added: trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSMountCommand.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,82 @@ +/* + * $Id: NFSMountCommand.java 2945 2006-12-20 08:51:17Z qades $ + * + * 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.nfs.command; + +import java.io.InputStream; +import java.io.PrintStream; + +import org.jnode.driver.DeviceManager; +import org.jnode.driver.DeviceUtils; +import org.jnode.fs.FileSystem; +import org.jnode.fs.FileSystemType; +import org.jnode.fs.nfs.nfs2.NFS2Device; +import org.jnode.fs.nfs.nfs2.NFS2Driver; +import org.jnode.fs.nfs.nfs2.NFS2FileSystemType; +import org.jnode.fs.service.FileSystemService; +import org.jnode.naming.InitialNaming; +import org.jnode.shell.Command; +import org.jnode.shell.CommandLine; +import org.jnode.shell.help.Argument; +import org.jnode.shell.help.Help; +import org.jnode.shell.help.Parameter; +import org.jnode.shell.help.ParsedArguments; +import org.jnode.shell.help.argument.FileArgument; + +/** + * @author Andrei Dore + */ +public class NFSMountCommand implements Command { + private static final FileArgument MOUNTPOINT_ARG = new FileArgument("directory", "the mountpoint"); + private static final Argument HOST_ARG = new Argument("host", "NFS host"); + private static final Argument REMOTE_DIRECTORY_ARG = new Argument("remoteDir", "remote directory"); + static Help.Info HELP_INFO = new Help.Info("mount", "Mount an NFS filesystem", + new Parameter[]{new Parameter(MOUNTPOINT_ARG, Parameter.MANDATORY), + new Parameter(HOST_ARG, Parameter.MANDATORY), new Parameter(REMOTE_DIRECTORY_ARG, Parameter.MANDATORY) + }); + + public static void main(String[] args) throws Exception { + new NFSMountCommand().execute(new CommandLine(args), System.in, + System.out, System.err); + } + + public void execute(CommandLine commandLine, InputStream in, + PrintStream out, PrintStream err) throws Exception { + ParsedArguments cmdLine = HELP_INFO.parse(commandLine.toStringArray()); + + final String mount_point = MOUNTPOINT_ARG.getValue(cmdLine); + final String host = HOST_ARG.getValue(cmdLine); + final String remoteDirectory = REMOTE_DIRECTORY_ARG.getValue(cmdLine); + + + final NFS2Device dev = new NFS2Device(host, remoteDirectory); + dev.setDriver(new NFS2Driver()); + final DeviceManager dm = DeviceUtils.getDeviceManager(); + dm.register(dev); + final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME); + FileSystemType type = fss.getFileSystemTypeForNameSystemTypes(NFS2FileSystemType.NAME); + final FileSystem fs = type.create(dev, true); + fss.registerFileSystem(fs); + fss.mount(mount_point, fs, null); + + + } +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Device.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Device.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Device.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,51 @@ +/* + * $Id: FTPFSDevice.java 2224 2006-01-01 12:49:03Z epr $ + * + * 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.nfs.nfs2; + +import org.jnode.driver.Device; + +/** + * @author Andrei Dore + */ +public class NFS2Device extends Device { + private String host; + private String remoteDirectory; + + + public NFS2Device(String host, String remoteDirectory) { + super(null, "nfs-(" + host + "," + remoteDirectory + ")"); + this.host = host; + this.remoteDirectory = remoteDirectory; + + } + + public String getHost() { + return host; + } + + + public String getRemoteDirectory() { + return remoteDirectory; + } + + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Directory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Directory.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Directory.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,172 @@ +/* + * $Id: FTPFSDirectory.java 2260 2006-01-22 11:10:07Z lsantha $ + * + * 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.nfs.nfs2; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.acplt.oncrpc.OncRpcException; +import org.jnode.fs.FSDirectory; +import org.jnode.fs.FSEntry; +import org.jnode.fs.nfs.nfs2.rpc.nfs.Entry; +import org.jnode.fs.nfs.nfs2.rpc.nfs.ListDirectoryResult; +import org.jnode.fs.nfs.nfs2.rpc.nfs.LookupResult; +import org.jnode.fs.nfs.nfs2.rpc.nfs.NFS2Client; +import org.jnode.fs.nfs.nfs2.rpc.nfs.Status; + +/** + * @author Andrei Dore + */ +public class NFS2Directory extends NFS2Object implements FSDirectory { + + private static final Iterator<NFS2Entry> EMPTY_ENTRY_ITERATOR = new EmptyIterator(); + + private byte[] fileHandle; + + NFS2Directory(NFS2FileSystem fileSystem, byte[] fileHandle) { + super(fileSystem); + this.fileHandle = fileHandle; + } + + /** + * Gets the entry with the given name. + * + * @param name + * @throws java.io.IOException + */ + public NFS2Entry getEntry(String name) throws IOException { + + NFS2Client nfsClient = ((NFS2FileSystem) getFileSystem()).getNFSClient(); + + LookupResult lookupResult; + try { + lookupResult = nfsClient.lookup(fileHandle, name); + } catch (OncRpcException e) { + throw new IOException("Can not call the rpc method"); + } + + if (lookupResult != null && lookupResult.getStatus() == Status.NFS_OK) { + + NFS2Entry nfs2Entry = new NFS2Entry((NFS2FileSystem) getFileSystem(), this, name, lookupResult + .getFileHandle(), lookupResult.getFileAttribute()); + + return nfs2Entry; + + } + + return null; + + } + + /** + * 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 NFS2Entry> iterator() throws IOException { + + NFS2Client nfsClient = ((NFS2FileSystem) getFileSystem()).getNFSClient(); + + try { + ListDirectoryResult result = nfsClient.listDirectory(fileHandle, new byte[NFS2Client.COOKIE_SIZE], 1024); + + if (result.getStatus() == Status.NFS_OK) { + + if (result.isEof()) { + + return EMPTY_ENTRY_ITERATOR; + } + + Entry entry = result.getEntry(); + + List<NFS2Entry> nfsEntryList = new ArrayList<NFS2Entry>(); + while (entry != null) { + + LookupResult lookupResult = nfsClient.lookup(fileHandle, entry.getName()); + + if (lookupResult.getStatus() == Status.NFS_OK) { + + NFS2Entry nfs2Entry = new NFS2Entry((NFS2FileSystem) getFileSystem(), this, entry.getName(), + lookupResult.getFileHandle(), lookupResult.getFileAttribute()); + + + nfsEntryList.add(nfs2Entry); + + } + + entry = entry.getNextEntry(); + + } + + + return nfsEntryList.iterator(); + + } else { + throw new IOException("Response is not ok." + result.getStatus()); + // return null; + } + + } catch (OncRpcException e) { + throw new IOException( + "An error occurs when the nfs file system tried to fetch the content of the directory", e); + } + + } + + public FSEntry addDirectory(String name) throws IOException { + // TODO Auto-generated method stub + return null; + } + + public FSEntry addFile(String name) throws IOException { + // TODO Auto-generated method stub + return null; + } + + public void flush() throws IOException { + // TODO Auto-generated method stub + + } + + public void remove(String name) throws IOException { + // TODO Auto-generated method stub + + } + + private static final class EmptyIterator implements Iterator<NFS2Entry> { + + public boolean hasNext() { + return false; + } + + public NFS2Entry next() { + return null; + } + + public void remove() { + + } + + } + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Driver.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Driver.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Driver.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,56 @@ +/* + * $Id: NFSDriver.java 2224 2006-01-01 12:49:03Z epr $ + * + * 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.nfs.nfs2; + +import org.jnode.driver.DeviceAlreadyRegisteredException; +import org.jnode.driver.Driver; +import org.jnode.driver.DriverException; + +/** + * @author Andrei Dore + */ +public class NFS2Driver extends Driver { + /** + * Start the device. + * + * @throws org.jnode.driver.DriverException + * + */ + protected void startDevice() throws DriverException { + try { + NFS2Device device = (NFS2Device) getDevice(); + device.getManager().rename(device, device.getId(), true); + } catch (DeviceAlreadyRegisteredException ex) { + throw new DriverException(ex); + } + } + + /** + * Stop the device. + * + * @throws org.jnode.driver.DriverException + * + */ + protected void stopDevice() throws DriverException { + + } +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Entry.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,133 @@ +/* + * $Id: FTPFSEntry.java 2260 2006-01-22 11:10:07Z lsantha $ + * + * 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.nfs.nfs2; + +import java.io.IOException; + +import org.jnode.fs.FSAccessRights; +import org.jnode.fs.FSDirectory; +import org.jnode.fs.FSEntry; +import org.jnode.fs.FSFile; +import org.jnode.fs.nfs.nfs2.rpc.nfs.FileAttribute; +import org.jnode.fs.nfs.nfs2.rpc.nfs.FileType; + +/** + * @author Andrei Dore + */ +public class NFS2Entry extends NFS2Object implements FSEntry { + + private NFS2Directory parent; + + private NFS2Directory directory; + + private NFS2File file; + + private byte[] fileHandle; + + private FileAttribute fileAttribute; + + private String name; + + NFS2Entry(NFS2FileSystem fileSystem, NFS2Directory parent, String name, byte[] fileHandle, + FileAttribute fileAttribute) { + super(fileSystem); + + this.parent = parent; + this.name = name; + this.fileAttribute = fileAttribute; + + if (fileAttribute.getType() == FileType.DIRECTORY) { + directory = new NFS2Directory(fileSystem, fileHandle); + + } else if (fileAttribute.getType() == FileType.FILE) { + file = new NFS2File(fileSystem, fileHandle, fileAttribute); + + } + + } + + public FSDirectory getParent() { + return parent; + } + + public String getName() { + return name; + } + + public FSAccessRights getAccessRights() throws IOException { + // TODO Auto-generated method stub + return null; + } + + public FSDirectory getDirectory() throws IOException { + if (!isDirectory()) { + throw new IOException(getName() + " is not a directory"); + } + + return directory; + } + + public FSFile getFile() throws IOException { + if (!isFile()) { + throw new IOException(getName() + " is not a file"); + } + + return file; + } + + public long getLastModified() throws IOException { + return fileAttribute.getLastModified().getMicroSeconds(); + } + + public boolean isDirectory() { + + if (fileAttribute.getType() == FileType.DIRECTORY) { + return true; + } + + return false; + } + + public boolean isDirty() throws IOException { + return false; + } + + public boolean isFile() { + + if (fileAttribute.getType() == FileType.FILE) { + return true; + } + + return false; + } + + public void setLastModified(long lastModified) throws IOException { + // TODO Auto-generated method stub + + } + + public void setName(String newName) throws IOException { + // TODO Auto-generated method stub + + } + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2File.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2File.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2File.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,118 @@ +/* + * $Id: FTPFSFile.java 2406 2006-03-23 06:17:24Z lsantha $ + * + * 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.nfs.nfs2; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import org.acplt.oncrpc.OncRpcException; +import org.jnode.fs.FSFile; +import org.jnode.fs.nfs.nfs2.rpc.nfs.FileAttribute; +import org.jnode.fs.nfs.nfs2.rpc.nfs.NFS2Client; +import org.jnode.fs.nfs.nfs2.rpc.nfs.ReadFileResult; +import org.jnode.fs.nfs.nfs2.rpc.nfs.Status; + +/** + * @author Andrei Dore + */ +public class NFS2File extends NFS2Object implements FSFile { + + private byte[] fileHandle; + private FileAttribute fileAttribute; + + NFS2File(NFS2FileSystem fileSystem, byte[] fileHandle, FileAttribute fileAttribute) { + super(fileSystem); + this.fileHandle = fileHandle; + this.fileAttribute = fileAttribute; + } + + /** + * Gets the length (in bytes) of this file + * + * @return long + */ + public long getLength() { + return fileAttribute.getSize(); + } + + /** + * 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 java.io.IOException + */ + public void read(long fileOffset, ByteBuffer dest) throws IOException { + + NFS2Client client = getNFSClient(); + + try { + ReadFileResult result = client.readFile(fileHandle, (int) fileOffset, dest.remaining()); + + if (result.getStatus() == Status.NFS_OK) { + fileAttribute = result.getFileAttribute(); + dest.put(result.getData()); + } else { + throw new IOException("Error " + result.getStatus()); + } + + } catch (OncRpcException e) { + throw new IOException(e.getMessage(), e); + } + + } + + /** + * Flush any cached data to the disk. + * + * @throws java.io.IOException + */ + public void flush() throws IOException { + + } + + /** + * Sets the length of this file. + * + * @param length + * @throws java.io.IOException + */ + public void setLength(long length) 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 java.io.IOException + */ + public void write(long fileOffset, ByteBuffer src) throws IOException { + + } + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystem.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,178 @@ +/* + * $Id: FTPFileSystem.java 3337 2007-06-30 11:58:44Z 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.nfs.nfs2; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.OncRpcProtocols; +import org.jnode.driver.Device; +import org.jnode.driver.DeviceListener; +import org.jnode.fs.FSEntry; +import org.jnode.fs.FileSystem; +import org.jnode.fs.FileSystemException; +import org.jnode.fs.nfs.nfs2.rpc.mount.DirPath; +import org.jnode.fs.nfs.nfs2.rpc.mount.Mount1Client; +import org.jnode.fs.nfs.nfs2.rpc.mount.MountResult; +import org.jnode.fs.nfs.nfs2.rpc.nfs.NFS2Client; + +/** + * @author Andrei Dore + */ +public class NFS2FileSystem implements FileSystem { + + private NFS2Device device; + + private NFS2RootEntry root; + + private Mount1Client mountClient; + private NFS2Client nfsClient; + + private boolean closed; + + public NFS2FileSystem(final NFS2Device device) throws FileSystemException { + this.device = device; + device.addListener(new DeviceListener() { + public void deviceStarted(Device device) { + } + + public void deviceStop(Device device) { + try { + close(); + } catch (IOException x) { + // Ignore this + } + } + }); + + try { + mountClient = new Mount1Client(InetAddress.getByName(device.getHost()), OncRpcProtocols.ONCRPC_UDP); + + nfsClient = new NFS2Client(InetAddress.getByName(device.getHost()), OncRpcProtocols.ONCRPC_UDP); + + MountResult result = mountClient.mount(new DirPath(device.getRemoteDirectory())); + + // + if (result.getStatus() == Mount1Client.MOUNT_OK) { + + root = new NFS2RootEntry(this, result.getDirectory().getValue()); + + } else { + throw new IOException("The status of the call it is not ok "); + } + + } catch (Exception e) { + + // Not good . Improve exception handling . Give more detail . + throw new FileSystemException(e.getMessage(), e); + } + + } + + /** + * 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 { + + // Improve the exception !!!!!!!!!!!!!!! + Exception unmountException = null; + try { + mountClient.unmount(new DirPath(device.getRemoteDirectory())); + } catch (OncRpcException ex) { + unmountException = ex; + } + + Exception nfsException = null; + try { + nfsClient.close(); + } catch (OncRpcException ex) { + nfsException = ex; + } + + Exception mountException = null; + try { + mountClient.close(); + } catch (OncRpcException ex) { + mountException = ex; + } + + if (unmountException != null || nfsException != null || mountException != null) { + throw new IOException("Can not close the nfs file system "); + } + + } + + /** + * Gets the device this FS driver operates on. + */ + public NFS2Device getDevice() { + return device; + } + + /** + * Gets the root entry of this filesystem. This is usually a directory, but + * this is not required. + */ + public FSEntry getRootEntry() throws IOException { + return root; + } + + /** + * Is this filesystem closed. + */ + public synchronized boolean isClosed() { + return closed; + } + + /** + * Is the filesystem mounted in readonly mode ? + */ + 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; + } + + NFS2Client getNFSClient() { + return nfsClient; + } + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2FileSystemType.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,77 @@ +/* + * $Id: NFSFileSystemType.java 2452 2006-04-09 16:44:50Z 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.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; + +/** + * @author Andrei Dore + */ +public class NFS2FileSystemType implements FileSystemType<NFS2FileSystem> { + public static final String NAME = "NFS2"; + + /** + * Create a filesystem from a given device. + * + * @param device + * @param readOnly + */ + public NFS2FileSystem create(Device device, boolean readOnly) throws FileSystemException { + return new NFS2FileSystem((NFS2Device) device); + } + + /** + * Gets the unique name of this file system type. + */ + public String getName() { + return NAME; + } + + /** + * 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; + } + + /** + * Format a filesystem for a given device according to its Partition table entry. + * + * @param device The device on which you want to format with this FileSystemType + * @param specificOptions the specific options for this filesystemType + * @return the newly created FileSystem + * @throws org.jnode.fs.FileSystemException + * + */ + public NFS2FileSystem format(Device device, Object specificOptions) throws FileSystemException { + return null; + } +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Object.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Object.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2Object.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,28 @@ +package org.jnode.fs.nfs.nfs2; + +import org.jnode.fs.FSObject; +import org.jnode.fs.FileSystem; +import org.jnode.fs.nfs.nfs2.rpc.nfs.NFS2Client; + +public class NFS2Object implements FSObject { + + private NFS2FileSystem fileSystem; + + NFS2Object(NFS2FileSystem fileSystem) { + this.fileSystem = fileSystem; + } + + public FileSystem getFileSystem() { + return fileSystem; + } + + public boolean isValid() { + // TODO Auto-generated method stub + return false; + } + + public NFS2Client getNFSClient() { + return fileSystem.getNFSClient(); + } + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2RootEntry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2RootEntry.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/NFS2RootEntry.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,74 @@ +package org.jnode.fs.nfs.nfs2; + +import java.io.IOException; + +import org.jnode.fs.FSAccessRights; +import org.jnode.fs.FSDirectory; +import org.jnode.fs.FSEntry; +import org.jnode.fs.FSFile; + +public class NFS2RootEntry extends NFS2Object implements FSEntry { + + private byte[] fileHandle; + + private NFS2Directory directory; + + NFS2RootEntry(NFS2FileSystem fileSystem, byte[] fileHandle) { + + super(fileSystem); + + this.fileHandle = fileHandle; + + directory = new NFS2Directory(fileSystem, fileHandle); + + } + + public FSAccessRights getAccessRights() throws IOException { + // TODO Auto-generated method stub + return null; + } + + public FSDirectory getDirectory() throws IOException { + return directory; + } + + public FSFile getFile() throws IOException { + throw new IOException("It is not a file. It is the root of the file system."); + } + + public long getLastModified() throws IOException { + return 0; + } + + public String getName() { + return "/"; + } + + public FSDirectory getParent() { + return null; + } + + public boolean isDirectory() { + return true; + } + + public boolean isDirty() throws IOException { + return false; + } + + public boolean isFile() { + return false; + } + + public void setLastModified(long lastModified) throws IOException { + throw new IOException("Cannot change last modified of root directory"); + + } + + public void setName(String newName) throws IOException { + throw new IOException("Cannot change name of root directory"); + + } + + +} Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/DirPath.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/DirPath.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/DirPath.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,48 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:09 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.mount; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public class DirPath implements XdrAble { + + private String value; + + + public DirPath() { + } + + public DirPath(String value) { + this.value = value; + } + + public DirPath(XdrDecodingStream xdr) + throws OncRpcException, IOException { + xdrDecode(xdr); + } + + public void xdrEncode(XdrEncodingStream xdr) + throws OncRpcException, IOException { + xdr.xdrEncodeString(value); + } + + public void xdrDecode(XdrDecodingStream xdr) + throws OncRpcException, IOException { + value = xdr.xdrDecodeString(); + } + + public String getValue() { + return value; + } + + +} +// End of DirPath.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/FileHandle.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/FileHandle.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/FileHandle.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,48 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:09 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.mount; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public class FileHandle implements XdrAble { + + private byte[] value; + + + public FileHandle() { + } + + public FileHandle(byte[] value) { + this.value = value; + } + + public FileHandle(XdrDecodingStream xdr) + throws OncRpcException, IOException { + xdrDecode(xdr); + } + + public void xdrEncode(XdrEncodingStream xdr) + throws OncRpcException, IOException { + xdr.xdrEncodeOpaque(value, Mount1Client.FILE_HANDLE_SIZE); + } + + public void xdrDecode(XdrDecodingStream xdr) + throws OncRpcException, IOException { + value = xdr.xdrDecodeOpaque(Mount1Client.FILE_HANDLE_SIZE); + } + + public byte[] getValue() { + return value; + } + + +} +// End of FileHandle.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Mount1Client.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Mount1Client.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Mount1Client.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,99 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:09 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.mount; + +import java.io.IOException; +import java.net.InetAddress; + +import org.acplt.oncrpc.OncRpcClientStub; +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrVoid; + +/** + * The class <code>Mount1Client</code> implements the client stub proxy for + * the MOUNTPROG remote program. It provides method stubs which, when called, in + * turn call the appropriate remote method (procedure). + */ +public class Mount1Client extends OncRpcClientStub { + + private static final int MOUNT_CODE = 100005; + private static final int MOUNT_VERSION = 1; + + private static final int PROCEDURE_TEST = 0; + private static final int PROCEDURE_MOUNT = 1; + private static final int PROCEDURE_UNMOUNT = 3; + + public static final int FILE_HANDLE_SIZE = 32; + public static final int MAX_PATH_LENGHT = 1024; + public static final int MAX_NAME_LENGHT = 255; + + public static final int MOUNT_OK = 0; + + /** + * Constructs a <code>Mount1Client</code> client stub proxy object from + * which the MOUNTPROG remote program can be accessed. + * + * @param host Internet address of host where to contact the remote + * program. + * @param protocol {@link org.acplt.oncrpc.OncRpcProtocols Protocol} to be + * used for ONC/RPC calls. + * @throws OncRpcException if an ONC/RPC error occurs. + * @throws IOException if an I/O error occurs. + */ + public Mount1Client(InetAddress host, int protocol) throws OncRpcException, IOException { + super(host, MOUNT_CODE, 1, 0, protocol); + } + + /** + * Constructs a <code>Mount1Client</code> client stub proxy object from + * which the MOUNTPROG remote program can be accessed. + * + * @param host Internet address of host where to contact the remote + * program. + * @param port Port number at host where the remote program can be + * reached. + * @param protocol {@link org.acplt.oncrpc.OncRpcProtocols Protocol} to be + * used for ONC/RPC calls. + * @throws OncRpcException if an ONC/RPC error occurs. + * @throws IOException if an I/O error occurs. + */ + public Mount1Client(InetAddress host, int port, int protocol) throws OncRpcException, IOException { + super(host, MOUNT_CODE, 1, port, protocol); + } + + /** + * Call remote procedure test. + * + * @throws OncRpcException if an ONC/RPC error occurs. + * @throws IOException if an I/O error occurs. + */ + public void test() throws OncRpcException, IOException { + XdrVoid argument = XdrVoid.XDR_VOID; + XdrVoid result = XdrVoid.XDR_VOID; + client.call(PROCEDURE_TEST, MOUNT_VERSION, argument, result); + } + + /** + * Call remote procedure mount. + * + * @param dirPath parameter (of type DirPath) to the remote procedure call. + * @return Result from remote procedure call (of type MountResult). + * @throws OncRpcException if an ONC/RPC error occurs. + * @throws IOException if an I/O error occurs. + */ + public MountResult mount(DirPath dirPath) throws OncRpcException, IOException { + MountResult result = new MountResult(); + client.call(PROCEDURE_MOUNT, MOUNT_VERSION, dirPath, result); + return result; + } + + public void unmount(DirPath dirPath) throws OncRpcException, IOException { + client.call(PROCEDURE_UNMOUNT, MOUNT_VERSION, dirPath, XdrVoid.XDR_VOID); + + } + +} +// End of Mount1Client.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/MountResult.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/MountResult.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/MountResult.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,61 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:09 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.mount; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public class MountResult implements XdrAble { + private int status; + private FileHandle directory; + + public MountResult() { + } + + public MountResult(XdrDecodingStream xdr) + throws OncRpcException, IOException { + xdrDecode(xdr); + } + + public void xdrEncode(XdrEncodingStream xdr) + throws OncRpcException, IOException { + xdr.xdrEncodeInt(status); + switch (status) { + case 0: + directory.xdrEncode(xdr); + break; + default: + break; + } + } + + public void xdrDecode(XdrDecodingStream xdr) + throws OncRpcException, IOException { + status = xdr.xdrDecodeInt(); + switch (status) { + case 0: + directory = new FileHandle(xdr); + break; + default: + break; + } + } + + public int getStatus() { + return status; + } + + public FileHandle getDirectory() { + return directory; + } + + +} +// End of MountResult.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Name.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Name.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/mount/Name.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,48 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:09 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.mount; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public class Name implements XdrAble { + + private String value; + + + public Name() { + } + + public Name(String value) { + this.value = value; + } + + public Name(XdrDecodingStream xdr) + throws OncRpcException, IOException { + xdrDecode(xdr); + } + + public void xdrEncode(XdrEncodingStream xdr) + throws OncRpcException, IOException { + xdr.xdrEncodeString(value); + } + + public void xdrDecode(XdrDecodingStream xdr) + throws OncRpcException, IOException { + value = xdr.xdrDecodeString(); + } + + public String getValue() { + return value; + } + + +} +// End of Name.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/AbstractResult.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/AbstractResult.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/AbstractResult.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,36 @@ +package org.jnode.fs.nfs.nfs2.rpc.nfs; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public abstract class AbstractResult implements XdrAble { + + private int status; + + public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, IOException { + // TODO Auto-generated method stub + + } + + public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, IOException { + status = xdr.xdrDecodeInt(); + switch (status) { + case Status.NFS_OK: + decode(xdr); + break; + default: + break; + } + + } + + public int getStatus() { + return status; + } + + public abstract void decode(XdrDecodingStream xdr) throws OncRpcException, IOException; +} \ No newline at end of file Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/Entry.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/Entry.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/Entry.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,85 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:51 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.nfs; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public class Entry implements XdrAble { + private int fileId; + private String name; + private byte[] cookie; + private Entry nextEntry; + + public Entry() { + } + + public Entry(XdrDecodingStream xdr) throws OncRpcException, IOException { + xdrDecode(xdr); + } + + + public void setFileId(int x) { + this.fileId = x; + } + + public int getFileId() { + return this.fileId; + } + + public void setName(String x) { + this.name = x; + } + + public String getName() { + return this.name; + } + + public void setCookie(byte[] x) { + this.cookie = x; + } + + public byte[] getCookie() { + return this.cookie; + } + + public void setNextEntry(Entry x) { + this.nextEntry = x; + } + + public Entry getNextEntry() { + return this.nextEntry; + } + + + public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, IOException { + Entry currentEntry = this; + do { + xdr.xdrEncodeInt(currentEntry.getFileId()); + xdr.xdrEncodeString(currentEntry.getName()); + xdr.xdrEncodeOpaque(currentEntry.getCookie(), NFS2Client.COOKIE_SIZE); + currentEntry = currentEntry.getNextEntry(); + xdr.xdrEncodeBoolean(currentEntry != null); + } while (currentEntry != null); + } + + public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, IOException { + Entry currentEntry = this; + do { + currentEntry.setFileId(xdr.xdrDecodeInt()); + currentEntry.setName(xdr.xdrDecodeString()); + currentEntry.setCookie(xdr.xdrDecodeOpaque(NFS2Client.COOKIE_SIZE)); + currentEntry.setNextEntry(xdr.xdrDecodeBoolean() ? new Entry() : null); + currentEntry = currentEntry.getNextEntry(); + } while (currentEntry != null); + } + +} +// End of Entry.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileAttribute.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileAttribute.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileAttribute.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,185 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:51 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.nfs; + +import java.io.IOException; + +import org.acplt.oncrpc.OncRpcException; +import org.acplt.oncrpc.XdrAble; +import org.acplt.oncrpc.XdrDecodingStream; +import org.acplt.oncrpc.XdrEncodingStream; + +public class FileAttribute implements XdrAble { + protected int type; + protected int mode; + protected int nlink; + protected int uid; + protected int gid; + protected int size; + protected int blocksize; + protected int rdev; + protected int blocks; + protected int fsid; + protected int fileid; + protected Time lastAccessed; + protected Time lastModified; + protected Time lastStatusChanged; + + public void setType(int x) { + this.type = x; + } + + public int getType() { + return this.type; + } + + public void setMode(int x) { + this.mode = x; + } + + public int getMode() { + return this.mode; + } + + public void setNlink(int x) { + this.nlink = x; + } + + public int getNlink() { + return this.nlink; + } + + public void setUid(int x) { + this.uid = x; + } + + public int getUid() { + return this.uid; + } + + public void setGid(int x) { + this.gid = x; + } + + public int getGid() { + return this.gid; + } + + public void setSize(int x) { + this.size = x; + } + + public int getSize() { + return this.size; + } + + public void setBlocksize(int x) { + this.blocksize = x; + } + + public int getBlocksize() { + return this.blocksize; + } + + public void setRdev(int x) { + this.rdev = x; + } + + public int getRdev() { + return this.rdev; + } + + public void setBlocks(int x) { + this.blocks = x; + } + + public int getBlocks() { + return this.blocks; + } + + public void setFsid(int x) { + this.fsid = x; + } + + public int getFsid() { + return this.fsid; + } + + public void setFileid(int x) { + this.fileid = x; + } + + public int getFileid() { + return this.fileid; + } + + public void setLastAccessed(Time x) { + this.lastAccessed = x; + } + + public Time getLastAccessed() { + return this.lastAccessed; + } + + public void setLastModified(Time x) { + this.lastModified = x; + } + + public Time getLastModified() { + return this.lastModified; + } + + public void setLastStatusChanged(Time x) { + this.lastStatusChanged = x; + } + + public Time getLastStatusChanged() { + return this.lastStatusChanged; + } + + public FileAttribute() { + } + + public FileAttribute(XdrDecodingStream xdr) throws OncRpcException, IOException { + xdrDecode(xdr); + } + + public void xdrEncode(XdrEncodingStream xdr) throws OncRpcException, IOException { + xdr.xdrEncodeInt(type); + xdr.xdrEncodeInt(mode); + xdr.xdrEncodeInt(nlink); + xdr.xdrEncodeInt(uid); + xdr.xdrEncodeInt(gid); + xdr.xdrEncodeInt(size); + xdr.xdrEncodeInt(blocksize); + xdr.xdrEncodeInt(rdev); + xdr.xdrEncodeInt(blocks); + xdr.xdrEncodeInt(fsid); + xdr.xdrEncodeInt(fileid); + lastAccessed.xdrEncode(xdr); + lastModified.xdrEncode(xdr); + lastStatusChanged.xdrEncode(xdr); + } + + public void xdrDecode(XdrDecodingStream xdr) throws OncRpcException, IOException { + type = xdr.xdrDecodeInt(); + mode = xdr.xdrDecodeInt(); + nlink = xdr.xdrDecodeInt(); + uid = xdr.xdrDecodeInt(); + gid = xdr.xdrDecodeInt(); + size = xdr.xdrDecodeInt(); + blocksize = xdr.xdrDecodeInt(); + rdev = xdr.xdrDecodeInt(); + blocks = xdr.xdrDecodeInt(); + fsid = xdr.xdrDecodeInt(); + fileid = xdr.xdrDecodeInt(); + lastAccessed = new Time(xdr); + lastModified = new Time(xdr); + lastStatusChanged = new Time(xdr); + } + +} +// End of FileAttribute.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileType.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/FileType.java 2007-10-17 18:30:15 UTC (rev 3557) @@ -0,0 +1,21 @@ +/* + * Automatically generated by jrpcgen 1.0.7 on 10/5/07 11:51 PM + * jrpcgen is part of the "Remote Tea" ONC/RPC package for Java + * See http://remotetea.sourceforge.net for details + */ +package org.jnode.fs.nfs.nfs2.rpc.nfs; + +/** + * Enumeration (collection of constants). + */ +public interface FileType { + + public static final int NON_FILE = 0; + public static final int FILE = 1; + public static final int DIRECTORY = 2; + public static final int BLOCK_SPECIAL_DEVICE = 3; + public static final int CHARACTER_SPECIAL_DEVICE = 4; + public static final int SYMBOLIC_LINK = 5; + +} +// End of FileType.java Added: trunk/fs/src/fs/org/jnode/fs/nfs/nfs2/rpc/nfs/ListDirectoryRe... [truncated message content] |