Package org.jnode.driver

Examples of org.jnode.driver.DeviceManager


    public static void main(String[] args) throws Exception {
        new FdiskCommand().execute(args);
    }

    public void execute() throws Exception {
        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        PrintWriter out = getOutput().getPrintWriter();
        PrintWriter err = getError().getPrintWriter();
        if (!ARG_DEVICE.isSet()) {
            // Show all devices.
            listAvailableDevices(dm, out);
View Full Code Here


        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

    public void refresh() {
        super.refresh();
        final TreeMap<String, Device> tm = new TreeMap<String, Device>();
        try {
            final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
            for (Device dev : dm.getDevices()) {
                tm.put(dev.getId(), dev);
            }
        } catch (javax.naming.NameNotFoundException E) {
            System.err.println("could not find DeviceManager");
        }
View Full Code Here

            throw new DriverException("Interrupted while INQUIRY device", ex);
        }

        // Register the generic SCSI device.
        try {
            final DeviceManager dm = ideDev.getManager();
            synchronized (dm) {
                dm.rename(scsiDevice, "sg", true);
                dm.register(scsiDevice);
                dm.rename(ideDev, SCSIHostControllerAPI.DEVICE_PREFIX, true);
            }
        } catch (DeviceAlreadyRegisteredException ex) {
            throw new DriverException(ex);
        }
    }
View Full Code Here

    }

    public SCSITest(String[] args) throws ApiNotFoundException,
        NameNotFoundException, DeviceNotFoundException {
        processArgs(args);
        final DeviceManager dm = InitialNaming
            .lookup(DeviceManager.NAME);
        final Device dev = dm.getDevice(name);
        api = dev.getAPI(SCSIDeviceAPI.class);
    }
View Full Code Here

    }

    public static RamDiskDevice createRamDisk(int size) {
        RamDiskDevice dev = null;
        try {
            final DeviceManager dm = InitialNaming
                .lookup(DeviceManager.NAME);
            dev = new RamDiskDevice(null, "dummy", size);
            dev.setDriver(new RamDiskDriver(null));
            dm.register(dev);
        } catch (NameNotFoundException e) {
            log.error(e);
        } catch (DeviceAlreadyRegisteredException e) {
            log.error(e);
        } catch (DriverException e) {
View Full Code Here

    private static final Logger log = Logger.getLogger(FloppyTest.class);

    public static void main(String[] args) {

        try {
            final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
            final Device fd0 = dm.getDevice("fd0");
            final BlockDeviceAPI api = fd0.getAPI(BlockDeviceAPI.class);
            try {

                final ByteBuffer buf = ByteBuffer.allocate(512);
                api.read(0, buf);
View Full Code Here

* @author gbin
*/
public class LowLevelIoTest {

    public static void main(String[] args) {
        DeviceManager dm;
        try {
            dm = InitialNaming.lookup(DeviceManager.NAME);

            IDEDevice current = (IDEDevice) dm.getDevice(args[0]);
            BlockDeviceAPI api = current.getAPI(BlockDeviceAPI.class);

            int size = (int) (Math.random() * 5 /*256*/) * 512;
            int offset = (int) (Math.random() * 10000) * 512;
            System.out.println("Create Random Buffer");
View Full Code Here

public class IDETest {

    public static void main(String[] args)
        throws NamingException, ApiNotFoundException, IOException, DeviceNotFoundException {

        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        final String name = (args.length > 0) ? args[0] : "hda";

        IDEDevice dev = (IDEDevice) dm.getDevice(name);
        IDEDeviceAPI<?> api = dev.getAPI(IDEDeviceAPI.class);
        IDEDriveDescriptor descr = dev.getDescriptor();

        System.out.println("LBA support   : " + descr.supportsLBA());
        System.out.println("DMA support   : " + descr.supportsDMA());
View Full Code Here

    @Override
    protected void startDevice() throws DriverException {
        final Device dev = getDevice();
        // Rename the device
        try {
            final DeviceManager dm = dev.getManager();
            synchronized (dm) {
                dm.rename(dev, "sg", true);
            }
        } catch (DeviceAlreadyRegisteredException ex) {
            throw new DriverException(ex);
        }
View Full Code Here

TOP

Related Classes of org.jnode.driver.DeviceManager

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.