Package org.jnode.fs.service

Examples of org.jnode.fs.service.FileSystemService


    }

    public void refresh() {
        super.refresh();
        try {
            FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            addStringln("Registered Filesystems:");
            for (FileSystemType<?> current : fSS.fileSystemTypes()) {
                addStringln("\t" + current.getName());

            }
        } catch (NameNotFoundException e) {
            System.err.print(e);
View Full Code Here


        final String host = HOST_ARG.getValue();
        final String user = USERNAME_ARG.getValue();
        final String password = PASSWORD_ARG.getValue();
        boolean ok = false;
       
        final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
        FTPFileSystemType type = fss.getFileSystemType(FTPFileSystemType.ID);
        final DeviceManager dm = DeviceUtils.getDeviceManager();
        final FTPFSDevice dev = new FTPFSDevice(host, user, password);
        dev.setDriver(new FTPFSDriver());
        FTPFileSystem fs = null;
        try {
            dm.register(dev);
            fs = type.create(dev, true);
            fss.registerFileSystem(fs);
            fss.mount(mountPoint.getAbsolutePath(), fs, null);
            ok = true;
        } catch (Exception ex) {
            getError().getPrintStream().println("FTP mount failed: " + ex.getLocalizedMessage());
            throw ex;
        } finally {
            if (!ok) {
                try {
                    // If we failed, try to undo the changes that we managed to make
                    if (fs != null) {
                        fss.unregisterFileSystem(dev);
                    }
                    dm.unregister(dev);
                } catch (Exception ex) {
                    Logger log = Logger.getLogger(FTPMountCommand.class);
                    log.fatal("Cannot undo failed mount attempt", ex);
View Full Code Here

            FatFormatter ff =
                    FatFormatter.HDFormatter(sectorSize, (int) numberOfSectors, SECTOR_PER_TRACK,
                            NB_HEADS, fatSize, (int) offset, 1, FAT_STANDARD_BS);
            ff.format(api);

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

    public static void printInfo(File file, PrintWriter out)
        throws IOException, FileSystemException {
        FileDevice fd = new FileDevice(file, "r");
        try {
            final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
            FatFileSystem fs = new FatFileSystem(fd, false, type);
            try {
                BootSector bs = fs.getBootSector();
                bs.read(fd);
View Full Code Here

        FileDevice newFd = new FileDevice(f, "rw");
        newFd.setLength(1440 * 1024);
        ff.format(newFd);

        // newFd.start();
        final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
        FatFileSystemType type = fSS.getFileSystemType(FatFileSystemType.ID);
        FatFileSystem fs = new FatFileSystem(newFd, false, type);

        FSDirectory dir = fs.getRootEntry().getDirectory();
        FSDirectory bDir = dir.addDirectory("boot").getDirectory();
        FSDirectory bgDir = bDir.addDirectory("grub").getDirectory();
View Full Code Here

                element.addAttribute("class", fsType.getFsTypeClass().getName());
                extension.addElement(element);
                ep.addExtension(extension);
            }

            FileSystemService fss = new FileSystemPlugin(desc);
            InitialNaming.bind(FileSystemService.class, fss);
        }
        setup = true;
        this.device = config.getDeviceParam().createDevice();
        this.fs = config.getFileSystem().format(this.device);
View Full Code Here

            System.out.println("error when reading disk image");
            System.exit(-1);
        }

        try {
            final FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            NTFSFileSystemType type = fSS.getFileSystemType(NTFSFileSystemType.ID);
            NTFSfs = new NTFSFileSystem(fd, false, type);
        } catch (FileSystemException e) {
            System.out.println("error when constructing Ext2FileSystem");
            e.printStackTrace();
            System.exit(-1);
View Full Code Here

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

    @Override
    protected void stopPlugin() throws PluginException {
        log.info("stop RAMFS");
        try {
            FileSystemService fSS = InitialNaming.lookup(FileSystemService.NAME);
            final DeviceManager dm = DeviceUtils.getDeviceManager();
            VirtualDevice dev = (VirtualDevice) dm.getDevice(RAMFileSystemType.VIRTUAL_DEVICE_NAME);
            fSS.unregisterFileSystem(dev);
            log.info("RAMFS unmounted");
            dm.unregister(dev);
            log.info("RAMFS unregistered");
        } catch (NameNotFoundException e) {
            log.error("filsystemservice / filesystemtype not found");
View Full Code Here

        restart(dm, parentDevice);
        out.println("GRUB has been successfully installed to " + deviceName + ".");
    }

    private String getMountPoint(Device device) throws GrubException {
        FileSystemService fss = null;
        try {
            fss = InitialNaming.lookup(FileSystemService.NAME);
        } catch (NameNotFoundException e) {
            throw new GrubException("filesystem not found", e);
        }

        FileSystem<?> filesystem = fss.getFileSystem(device);
        if (filesystem == null) {
            throw new GrubException("can't find filesystem for device " + device.getId());
        }

        Map<String, FileSystem<?>> mountPoints = fss.getMountPoints();
        String mountPoint = null;
        for (String fullPath : mountPoints.keySet()) {
            FileSystem<?> fs = mountPoints.get(fullPath);
            if (fs == filesystem) {
                mountPoint = fullPath;
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.