Package org.jnode.fs.ramfs

Examples of org.jnode.fs.ramfs.RAMFileSystemType


    @Override
    protected void startPlugin() throws PluginException {
        log.info("start ramfs");
        try {
            FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            RAMFileSystemType type = fSS.getFileSystemType(RAMFileSystemType.ID);

            try {
                VirtualDevice dev =
                        VirtualDeviceFactory.createDevice(RAMFileSystemType.VIRTUAL_DEVICE_NAME);
                log.info(dev.getId() + " registered");

                final RAMFileSystem fs = type.create(dev, true);
                fSS.registerFileSystem(fs);

                final String mountPath = "jnode";
                fSS.mount(mountPath, fs, null);
                log.info("Mounted " + type.getName() + " on " + mountPath);

                FSDirectory root_dir = fs.getRootEntry().getDirectory();
                root_dir.addDirectory("home");
                root_dir.addDirectory("tmp");
                // adding files to /jnode/lib/ required by thecore classes
                FSDirectory libDir = (FSDirectory) root_dir.addDirectory("lib");
                InputStream is = RAMFSPlugin.class.getResourceAsStream("flavormap.properties");
                if (is != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    byte[] buf = new byte[1024];
                    int c;
                    while ((c = is.read(buf)) > -1)
                        baos.write(buf, 0, c);

                    is.close();
                    baos.flush();
                    baos.close();

                    ByteBuffer data = ByteBuffer.wrap(baos.toByteArray());
                    FSFile fmp = (FSFile) libDir.addFile("flavormap.properties");
                    fmp.write(0, data);
                    fmp.flush();
                }
            } catch (DeviceAlreadyRegisteredException ex) {
                log.error("RAMFS is allready running.");
            } catch (FileSystemException ex) {
                log.error("Cannot mount " + type.getName() + " filesystem ", ex);
            } catch (DeviceException ex) {
                log.debug("DeviceExeption.", ex);
            } catch (IOException ex) {
                log.error("Cannot mount RAMFS", ex);
            }
View Full Code Here

TOP

Related Classes of org.jnode.fs.ramfs.RAMFileSystemType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.