Package org.jnode.fs.service

Examples of org.jnode.fs.service.FileSystemService


            }

            // The FAT32 Formatter class constructor
            FatFormatter.HDDFormatter(sectorSize, (int) numberOfSectors, clusterSize, (int) offset, api);

            final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
            return type.create(device, false); // not readOnly !
        } catch (IOException ioe) {
            throw new FileSystemException("Formating problem", ioe);
        } catch (ApiNotFoundException e) {
            throw new FileSystemException("Formating problem", e);
View Full Code Here


    }

    @Override
    public final HfsPlusFileSystem format(final Device device) throws FileSystemException {
        try {
            FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
            HfsPlusFileSystemType type = fss.getFileSystemType(HfsPlusFileSystemType.ID);
            HfsPlusFileSystem fs = new HfsPlusFileSystem(device, false, type);
            fs.create(params);
            return fs;
        } catch (NameNotFoundException e) {
            throw new FileSystemException(e);
View Full Code Here

        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");
View Full Code Here

            JIFileSystemType type = null;
            try {
                VirtualDevice dev =
                        VirtualDeviceFactory.createDevice(JIFileSystemType.VIRTUAL_DEVICE_NAME);
                log.info(dev.getId() + " registered");
                final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
                type = fSS.getFileSystemType(JIFileSystemType.ID);

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

                final String mountPath = "jifs";
                fSS.mount(mountPath, fs, null);
                log.info("Mounted " + type.getName() + " on " + mountPath);
                final ExtensionPoint infoEP = getDescriptor().getExtensionPoint("info");
                jifsExtension = new JIFSExtension(infoEP);
            } catch (DeviceAlreadyRegisteredException ex) {
                log.error("jifs is currently running.");
View Full Code Here

     * Stop this plugin
     */
    protected void stopPlugin() {
        log.info("stop jifs");
        try {
            FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            final DeviceManager dm = DeviceUtils.getDeviceManager();
            VirtualDevice dev = (VirtualDevice) dm.getDevice(JIFileSystemType.VIRTUAL_DEVICE_NAME);
            fSS.unregisterFileSystem(dev);
            log.info("jifs unmounted");
            dm.unregister(dev);
            log.info("jifs unregistered");
        } catch (NameNotFoundException e) {
            log.error("filsystemservice / filesystemtype not found");
View Full Code Here

     * (non-Javadoc)
     * @see org.jnode.fs.Formatter#format(org.jnode.driver.Device)
     */
    public synchronized Ext2FileSystem format(Device device) throws FileSystemException {
        try {
            FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            Ext2FileSystemType type = fSS.getFileSystemType(Ext2FileSystemType.ID);
            Ext2FileSystem fs = new Ext2FileSystem(device, false, type);
            fs.create(blockSize);
            return fs;
        } catch (NameNotFoundException e) {
            throw new FileSystemException(e);
View Full Code Here

        final String host = HOST_ARG.getValue();
        final String path = PATH_ARG.getValue();
        final String user = USERNAME_ARG.getValue();
        final String password = PASSWORD_ARG.getValue();
       
        final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
        SMBFileSystemType type = fss.getFileSystemType(SMBFileSystemType.ID);
       
        final SMBFSDevice dev = new SMBFSDevice(host, path, user, password);
        dev.setDriver(new SMBFSDriver());
        final DeviceManager dm = DeviceUtils.getDeviceManager();
        dm.register(dev);
       
        // This controls whether we attempt to undo the effects of the command
        // e.g. when the 'mount' step fails.
        boolean ok = false;
        try {
            final SMBFileSystem fs = type.create(dev, true);
            fss.registerFileSystem(fs);
            try {
                fss.mount(mountPoint.toString(), fs, null);
                ok = true;
            } finally {
                if (!ok) {
                    fss.unregisterFileSystem(dev);
                }
            }
        } finally {
            try {
                if (!ok) {
View Full Code Here

        new MountCommand().execute(args);
    }

    public void execute() throws Exception {
        // Find the filesystem service
        final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
        PrintWriter out = getOutput().getPrintWriter();
        PrintWriter err = getError().getPrintWriter();
        if (!argDevice.isSet()) {
            // List all mounted file systems
            Map<String, FileSystem<?>> filesystems = fss.getMountPoints();
            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(), stringFileSystemEntry.getKey(), type, mode);
            }
        } else {
            // Get the parameters
            final Device dev = argDevice.getValue();
            final File mountPoint = argDir.getValue();
            final File fsPath = argFspath.getValue();

            // Find the filesystem
            final FileSystem<?> fs = fss.getFileSystem(dev);
            if (fs == null) {
                err.format(fmt_err_nofs, dev.getId());
                exit(1);
            } else {
                // Mount it
                fss.mount(mountPoint.toString(), fs, fsPath.toString());
            }
        }
    }
View Full Code Here

        final NFS2Device dev = new NFS2Device(host, remoteDirectory, protocol, uid, gid);
        dev.setDriver(new NFS2Driver());
        dm.register(dev);
        boolean ok = false;
        try {
            final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
            NFS2FileSystemType type = fss.getFileSystemType(NFS2FileSystemType.ID);
            final NFS2FileSystem fs = type.create(dev, readOnly);
            fss.registerFileSystem(fs);
            try {
                fss.mount(mountPoint.getAbsolutePath(), fs, null);
                ok = true;
            } finally {
                if (!ok) {
                    fss.unregisterFileSystem(dev);
                }
            }
        } finally {
            if (!ok) {
                dm.unregister(dev);
View Full Code Here

     * taken from the DfCommand
     */
    private int getFsBlockSize(File file) throws IOException {

        int retValue = DEFAULT_FILESYSTEM_BLOCK_SIZE; // default block size
        FileSystemService fss = null;
        Device device = null;
        String path = null;
        String mp = null;

        try {
            fss = InitialNaming.lookup(FileSystemService.NAME);
            path = file.getCanonicalPath();
            mp = null;

            for (String mountPoint : fss.getMountPoints().keySet()) {
                if (path.startsWith(mountPoint)) {
                    if (mp != null) {
                        if (!mp.startsWith(mountPoint)) {
                            continue;
                        }
                    }
                    mp = mountPoint;
                }
            }

            if (mp != null) {
                device = fss.getMountPoints().get(mp).getDevice();

                if (device instanceof FSBlockDeviceAPI) {
                    retValue = ((FSBlockDeviceAPI) device).getSectorSize();

                } else {
                    logger.warn("No FSBlockDeviceAPI device for device: " + device);
                    logger.info("Using default block-size: " + DEFAULT_FILESYSTEM_BLOCK_SIZE);
                    logger.info("override with --fs-block-size");
                }
            } else {

                logger.warn("No mount point found for " + path);

                for (String mountPoint : fss.getMountPoints().keySet()) {
                    logger.warn("mountpoints on system: " + mountPoint);
                }

                logger.info("Using default block-size: " + DEFAULT_FILESYSTEM_BLOCK_SIZE);
                logger.info("override with --fs-block-size");
View Full Code Here

TOP

Related Classes of org.jnode.fs.service.FileSystemService

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.