| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
standard file system embedded system usually small size. storage space
Top Searches for this datasheetApplication Note Adding External File System TINI standard file system embedded system usually small size. storage space Tiny Internet Interfaces (TINI®) platform exception. TINI's file system resides on-board limited size this RAM. Because this constraint, important provide alternatives data storage. This application note describes technique adding external file system. providing method accessing other file systems, TINI users longer limited type amount information they process. Since TINI also uses operating heap, using remote file system allows more used running applications. Once file system been mounted, there appears difference between file that resides local file system that external. interactions with files occur through standard java.io classes com.dalsemi.fs.DSFile class. System Overview There implementing external file system. First, com.dalsemi.fs.FileSystemDriver interface must implemented. This class native library, rely server running elsewhere (like example included this application note), number other options. Second, class classes) must made available process that uses external file system. This done placing copy class TINI's classpath building directly into application that will file system. Finally, file system needs mounted. This done either calling com.dalsemi.fs.DSFile.mount() method from inside application using mount command slush. com.dalsemi.fs.FileSystemDriver interface been written that variety systems implemented. developer freedom handle files manner that appropriate design. Possibilities include Network File System (NFS), file system where files written read from server, disk drive connected TINI. This example uses custom design that uses TINI's on-board TCP/IP network stack access files from remote server. Figure shows system's configuration. TINI's file system holds reference file system driver. Whenever remote file accessed, appropriate method driver called. driver then communicates with remote host over network process request. three steps 081202 AN709 Figure System Block Diagram TINI FILE SYSTEM REMOTE DRIVER INTERNET/ ETHERNET SERVER REMOTE HOST TINI Software class that implements com.dalsemi.fs.FileSystemDriver interface. driver's init() method called automatically whenever file system mounted. This gives driver opportunity perform initialization that might necessary. Some examples include resetting initializing hardware, allocating buffers, establishing network connections. this example, init() method attempts establish socket connection with remote server specified parameters. Upon successful connection, server sends port number that driver must send file system commands. This allows original port remain open additional connections. NetworkFileSystemDriver DataInputStream null; DataOutputStream null; Socket null; public void init(String[] args) throws Exception //args[0] address file system server. //args[1] port connect port Integer.parseInt(args[1]); newPort Socket(args[0], port); //Once connected server will send back port connect //to. This original server port will remain available //for additional connections. newPort in.readInt(); finally if(in null) {in.close();} if(sck null) {sck.close();} //Open socket input output streams. //We'll wrap them Data streams convenience. Socket(args[0], newPort); AN709 unmount() method driver called when file system unmounted. driver should this method release resources using (e.g., buffers, network connections, ports, etc.). example presented here, driver attempts notify server about disconnect. driver then closes connection with server. public void unmount() //Send command byte. //This will notify server close end. out.writeByte(CLOSE); finally //We don't care what server does, still need close end. in.close(); out.close(); sck.close(); catch(IOException remaining methods class file system operations (e.g., open, close, read, write, etc.). Each follows flow chart shown Figure These methods were kept simple possible order most workload onto server. example implementation file system operations (File.exists()) given below. //out DataOutputStream command socket between client host. //in DataInputStream command socket between client host. //EXISTS byte that server understands "does file exist" command. public boolean exists(String fileName) //Send command byte necessary arguments. out.writeByte(EXISTS); writeString(fileName); //Get result. return in.readBoolean(); catch(Exception return false; AN709 Figure Client Block Diagram FILE OPERATION SEND COMMAND BYTE SERVER PARAMETERS REQUIRED? SEND PARAMETERS SERVER RESULT EXPECTED? READ RESULTS FROM SERVER RETURN Server Software NetworkFileSystemHost class acts file system server that resides remote host. This server multithreaded handle multiple simultaneous connections. When server starts, creates server socket that waits incoming connections. //Create socket accept incoming connections. ServerSocket ServerSocket(3453); System.out.println("Server running. Waiting connections."); Socket ss.accept(); When connection requested, server responds with port number which client should connect creates thread that listens given port commands from client. //Open server socket send port number client. //We want keep original free more connections. DataOutputStream ServerSocket ServerSocket(0); //Start thread handle connection. thread will //be responsible file system operations. SessionThread(ss2).start(); out.flush(); AN709 thread continues handling commands until receives disconnect command. listing below shows server handles this command. server's counterpart exists() function TINI software also shown. //out DataOutputStream command socket between client host. //in DataInputStream command socket between client host. boolean closed false; while(!closed) byte command in.readByte(); switch(command) case DISCONNECT: //Close communication socket requested. in.close(); out.close(); sck.close(); //Clean open files held this thread. closeOpenFiles(openRand); closeOpenFiles(openRead); closeOpenFiles(openWrite); //Set state closed. This will stop main //loop run() method allow thread //terminate. closed true; break; case EXISTS: //Get parameters this operation. String fName readString(); //Send result. File File(parent, fName); out.writeBoolean(f.exists()); break; //Handle other commands here. Figure illustrates entire program flow server. AN709 Figure File System Server FILE SYSTEM SERVER COMMAND THREAD TERMINATE THREAD WAIT CLIENT CONNECTION RECEIVE COMMAND FROM CLIENT CLOSE CONNECTION START COMMAND HANDLING THREAD COMMAND DISCONNECT? CLOSE FILES THAT OPENED SEND COMMAND PORT NUMBER CLIENT PARAMETERS REQUIRED? READ PARAMETERS FROM CLIENT RESULT EXPECTED? SEND RESULT CLIENT AN709 Running Example example, complete following steps: Install TINIOS 1.10. Include mount unmount commands slush. this, first extract source commands from OptionalSlushCommandsSrc.jar file compile them. Then class files into directory TINI. following commands slush prompt: addc mount addc unmount Compile source files included with this example using following commands: javac -bootclasspath <TINI1.10>\bin\tiniclasses.jar NetworkFileSystemDriver.java javac NetworkFileSystemHost.java where <TINI1.10> TINI 1.10 installation directory. NetworkFileSystemDriver.class file into /tiniext directory TINI. Start file system server with following command: java NetworkFileSystemHost <startDir> where <startDir> directory that visible from TINI file system. slush, mount file system with following command: mount NetworkFileSystemDriver <host 3453 where <host address system where server running. There will directory root TINI's file system called "mnt." This directory shows files that available from remote server. These files accessed just like files that reside TINI's internal file system available processes created slush. Associated Files Files associated with AN709 located Conclusion using built- TCP/IP capabilities TINI, standard file system extended without much overhead TINI system. This frees applications developed TINI from constraints internal file system. More also made available since data files, files, etc., stored remotely. AN709 MAXIM INTEGRATED PRODUCTS/DALLAS SEMICONDUCTOR CONTACT INFORMATION Company Addresses: Maxim Integrated Products, Inc. Gabriel Drive Sunnyvale, 94086 Tel: 408-737-7600 Fax: 408-737-7194 Dallas Semiconductor 4401 Beltwood Parkway Dallas, 75244 Tel: 972-371-4448 Fax: 972-371-4799 Product Literature/Samples Requests: 800-998-8800 408-737-7600 Sales Customer Service: World Wide Website Product Information Ordering Information Site: ftp://ftp.dalsemi.com TINI registered trademark Dallas Semiconductor. Java trademark Microsystems AN709 Appendix following documentation com.dalsemi.fs.FileSystemDriver interface. com.dalsemi.fs Interface FileSystemDriver public interface FileSystemDriver This interface used implement external file systems. Anyone wishing extend TINI's file system must first implement this interface. class then passed com.dalsemi.fs.DSFile.mount() method creation. Nearly every method this interface takes either file name file descriptor. File names will Strings that include name mount point itself. example, have mount point named "mnt", mounted file system there directory called test, TINI would access file that directory using String "/mnt/test/myfile." name would then passed driver "test/myfile." When accessing mount point itself ("/mnt"), represented empty string (""). Methods that file descriptor file descriptor returned openReadingFD, openWritingFD, openRandomFD methods. What contained file descriptor developer. Many methods also parameter. This person trying perform operation. that have high assumed have administrator privileges. Method Summary available(Object number bytes that read without blocking. boolean canExec(String fileName, byte uid) Determines given file executable. boolean canRead(String fileName, byte uid) Determines given file readable. boolean canWrite(String fileName, byte uid) Determines given file writable. void close(Object Closes file descriptor's stream releases system resources used. boolean delete(String fileName, byte uid) Removes specified file from mounted file system. boolean exists(String fileName) Determines given file exists mounted file system. byte[] getContents(String fileName, byte uid) Gets complete contents file mounted file system. long getLength(Object Gets length file represented file descriptor. long getOffset(Object Gets current offset into file. getOtherPermissions(String fileName) Gets other (non-owner) permissions given file. getUser(String fileName) AN709 Gets owner file. getUserPermissions(String fileName) Gets user/owner permissions given file. void init(String[] args) This method will called first time mounted file system accessed. boolean isDirectory(String fileName) Determines given name represents directory. boolean isFile(String fileName) Determines given name represents file directory. long lastModified(String fileName) Indicates time file last modified. long length(String fileName) Gets length file. String[] list(String fileName, byte uid) Retrieves listing files directory specified. boolean mkdir(String fileName, byte uid) Creates directory mounted file system. Object openRandomFD(String fileName, byte uid) Opens given file random access. Object openReadingFD(String fileName, byte uid) Opens given file reading. Object openWritingFD(String fileName, boolean append, byte uid) Opens given file writing. readBytes(Object byte[] data, start, length) Reads from file represented file descriptor. boolean rename(String srcname, String destname, byte uid) Changes name file. void seek(Object long Moves file pointer given location, measured bytes from beginning file. void setOtherPermissions(String fileName, perms, byte uid) Changes other (non-owner) permissions given file. void setUser(String fileName, byte newUID, byte uid) Sets owner given file. void setUserPermissions(String fileName, perms, byte uid) Changes user/owner permissions given file. long skipBytes(Object long Skips next bytes data from stream. AN709 void touch(String fileName, byte uid) Updates last modified time given file current time. void unmount() Allows driver chance clean release resources used when mount point removed. void writeBytes(Object byte[] data, start, length) Writes given data file represented file descriptor. Method Detail init public void init(String[] args) throws Exception This method will called first time mounted file system accessed. Parameters: args arguments needed initialize file system. Throws: Exception exists public boolean exists(String fileName) Determines given file exists mounted file system. This method should match behavior java.io.File.exists(). Parameters: fileName file. Returns: true file exists. canWrite public boolean canWrite(String fileName, byte uid) Determines given file writable. file does exists, driver should determine created return accordingly. This method should match behavior java.io.File.canWrite(). Parameters: fileName file. user that trying access file. Returns: true file written this user. AN709 canRead public boolean canRead(String fileName, byte uid) Determines given file readable. This method should match behavior java.io.File.canRead(). Parameters: fileName file. user that trying access file. Returns: true file read this user. canExec public boolean canExec(String fileName, byte uid) Determines given file executable. This method should match behavior Parameters: fileName file. user that trying access file. Returns: true file executed this user. isFile public boolean isFile(String fileName) Determines given name represents file directory. This method should match behavior java.io.File.isFile(). Parameters: fileName file. Returns: true fileName represents file. isDirectory public boolean isDirectory(String fileName) Determines given name represents directory. This method should match behavior java.io.File.isDirectory(). Parameters: fileName file. Returns: true fileName represents directory. lastModified public long lastModified(String fileName) Indicates time file last modified. This method should match behavior java.io.File.lastModified(). Parameters: fileName file. Returns: modification time file. length public long length(String fileName) Gets length file. This method should match behavior java.io.File.length(). Parameters: fileName file. Returns: length file. AN709 mkdir public boolean mkdir(String fileName, byte uid) Creates directory mounted file system. This method should match behavior java.io.File.mkdir(). Parameters: fileName name directory create. user that trying create directory. Returns: true directory created. rename public boolean rename(String srcname, String destname, byte uid) Changes name file. This method should match behavior java.io.File.renameTo(File dest). Parameters: srcname name file changed. destname name file. user that trying rename file. Returns: true file renamed. list public String[] list(String fileName, byte uid) Retrieves listing files directory specified. This method should match behavior java.io.File.list(). Parameters: fileName directory listing from. user trying retreive list. Returns: list files, null fileName doesn't represent directory. AN709 delete public boolean delete(String fileName, byte uid) Removes specified file from mounted file system. This method should match behavior java.io.File.delete(). Parameters: fileName File delete. user trying delete file. Returns: true file removed. touch public void touch(String fileName, byte uid) throws IOException Updates last modified time given file current time. This method should match behavior com.dalsemi.fs.DSFile.touch(). Parameters: fileName file touch. user trying update file. Throws: IOException setUserPermissions public void setUserPermissions(String fileName, perms, byte uid) throws IOException Changes user/owner permissions given file. This method should match behavior perms). Parameters: fileName file. perms permissions. user that trying change file. Throws: IOException setOtherPermissions public void setOtherPermissions(String fileName, perms, byte uid) throws IOException Changes other (non-owner) permissions given file. This method should match behavior perms). Parameters: fileName file. perms permissions. user that trying change file. AN709 setUser public void setUser(String fileName, byte newUID, byte uid) throws IOException Sets owner given file. This method should match behavior uid). Parameters: fileName file. newUID owner. user that trying change file. Throws: IOException getUserPermissions public getUserPermissions(String fileName) throws FileNotFoundException Gets user/owner permissions given file. This method should match behavior Parameters: fileName file. Returns: user permissions. Throws: FileNotFoundException getOtherPermissions public getOtherPermissions(String fileName) throws FileNotFoundException Gets other (non-owner) permissions given file. This method should match behavior Parameters: fileName file. Returns: other permissions. Throws: FileNotFoundException getUser public getUser(String fileName) throws FileNotFoundException Gets owner file. This method should match behavior Parameters: fileName file. Returns: file's owner. Throws: FileNotFoundException AN709 openWritingFD public Object openWritingFD(String fileName, boolean append, byte uid) throws IOException Opens given file writing. file descriptor that returned will used identify file other driver calls. file descriptor length should hold information driver needs identify associated file stream's state. This method should match behavior java.io.FileOutputStream(String name, boolean append). Parameters: fileName name file open. append true file exists, file should opened file pointer file. false file exists, contents file should erased file's length user trying open file. Returns: file descriptor. Throws: IOException openReadingFD public Object openReadingFD(String fileName, byte uid) throws FileNotFoundException Opens given file reading. file descriptor that returned will used identify file other driver calls. file descriptor length should hold information driver needs identify associated file stream's state. This method should match behavior java.io.FileInputStream(String name). Parameters: fileName name file open. user trying open file. Returns: file descriptor. Throws: FileNotFoundException openRandomFD public Object openRandomFD(String fileName, byte uid) throws IOException Opens given file random access. file descriptor that returned will used identify file other driver calls. file descriptor length should hold information driver needs identify associated file stream's state. This method should match behavior java.io.RandomAccessFile(String name, String mode). Parameters: fileName name file open. user trying open file. Returns: file descriptor. Throws: IOException AN709 writeBytes public void writeBytes(Object byte[] data, start, length) throws IOException Writes given data file represented file descriptor. This method should match behavior off, len). Parameters: file descriptor identifying file write data data write. start start offset data. length number bytes write. Throws: IOException readBytes public readBytes(Object byte[] data, start, length) throws IOException Reads from file represented file descriptor. This method should match behavior java.io.InputStream.read(byte[] off, len). Parameters: file descriptor identifying file read from. data buffer store data that read. start start offset buffer. length number bytes read. Returns: number bytes read. Throws: IOException seek public void seek(Object long throws IOException Moves file pointer given location, measured bytes from beginning file. This method should match behavior pos). Parameters: file descriptor identifying file. position file pointer. Throws: IOException AN709 skipBytes public long skipBytes(Object long throws IOException Skips next bytes data from stream. This method should match behavior java.io.InputStream.skip(long file descriptor represents FileInputStream should match behavior file descriptor represents RandomAccessFile. Parameters: file descriptor identifying file. number bytes skip. Returns: actual number bytes skipped. Throws: IOException getOffset public long getOffset(Object throws IOException Gets current offset into file. This method should match behavior Parameters: file descriptor identifying file. Returns: current position file pointer. Throws: IOException getLength public long getLength(Object throws IOException Gets length file represented file descriptor. This method should match behavior Parameters: file descriptor identifying file. Returns: length file. Throws: IOException available public available(Object throws IOException number bytes that read without blocking. This method should match behavior Parameters: file descriptor identifying file. Returns: number bytes available. AN709 close public void close(Object throws IOException Closes file descriptor's stream releases system resources used. This method should match behavior depending type file descriptor passed Parameters: file descriptor identifying file. Throws: IOException unmount public void unmount() Allows driver chance clean release resources used when mount point removed. getContents public byte[] getContents(String fileName, byte uid) throws IOException Gets complete contents file mounted file system. This method will called when system attempts execute file located mounted file system. Parameters: fileName file retreive. user trying execute file. Returns: contents file. Throws: IOException Other recent searchesPT7C5037 - PT7C5037 PT7C5037 Datasheet MA1000 - MA1000 MA1000 Datasheet MA1050 - MA1050 MA1050 Datasheet M48T86 - M48T86 M48T86 Datasheet FJN3307R - FJN3307R FJN3307R Datasheet FJN4307R - FJN4307R FJN4307R Datasheet EZIO-G400 - EZIO-G400 EZIO-G400 Datasheet DUY20C-A - DUY20C-A DUY20C-A Datasheet BAM80 - BAM80 BAM80 Datasheet B3100 - B3100 B3100 Datasheet
Privacy Policy | Disclaimer |