Package org.jnode.driver

Examples of org.jnode.driver.DeviceManager


    }

    @Override
    protected Device doAccept(Token token, int flags) throws CommandSyntaxException {
        try {
            final DeviceManager devMgr = getDeviceManager();
            final Device device = devMgr.getDevice(token.text);
            if (apiClass == null || device.implementsAPI(apiClass)) {
                return device;
            } else {
                throw new CommandSyntaxException("this device does not implement the " +
                        apiClass.getSimpleName() + " API");
View Full Code Here


        }
    }

    @Override
    public void doComplete(CompletionInfo completions, String partial, int flags) {
        final DeviceManager devMgr = getDeviceManager();

        // collect matching devices
        for (Device dev : devMgr.getDevices()) {
            if (apiClass != null && !dev.implementsAPI(apiClass)) {
                continue;
            }
            final String devId = dev.getId();
            if (devId.startsWith(partial)) {
View Full Code Here

        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) {
                    dm.unregister(dev);
                }
            } catch (DriverException ex) {
                // ignore
            }
        }
View Full Code Here

        Device dev = ARG_DEVICE.getValue();
        Formatter<T> formatter = getFormatter();
        formatter.format(dev);

        // restart the device
        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        dm.stop(dev);
        dm.start(dev);
    }
View Full Code Here

                READ_ONLY_FLAG.isSet() ? true : READ_WRITE_FLAG.isSet() ? false
                        : (uid == -1 && gid == -1);

        // Now do the work of mounting the file system, taking care to undo as much as
        // we can in the event of a failure.
        final DeviceManager dm = DeviceUtils.getDeviceManager();
        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

        reloadMBR();

        // restart the device
        try {
            DeviceManager devMan = DeviceUtils.getDeviceManager();
            devMan.stop(current);
            devMan.start(current);
        } catch (DeviceNotFoundException e) {
            throw new Exception("error while restarting device", e);
        } catch (DriverException e) {
            throw new Exception("error while restarting device", e);
        } catch (NameNotFoundException e) {
View Full Code Here

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

        new RamDiskCommand().execute(args);
    }

    public void execute()
        throws NameNotFoundException, DriverException, DeviceAlreadyRegisteredException {
        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        if (FLAG_CREATE.isSet()) {
            // Create
            final int size = ARG_SIZE.isSet() ? ARG_SIZE.getValue() : 4 * 4096;
            RamDiskDevice dev = new RamDiskDevice(null, "dummy", size);
            dev.setDriver(new RamDiskDriver(null));
            dm.register(dev);
        }
    }
View Full Code Here

     * @see org.jnode.driver.Driver#startDevice()
     */
    protected void startDevice() throws DriverException {
        final Device device = getDevice();
        try {
            final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
            if (renameToDevicePrefixOnly()) {
                dm.rename(device, getDevicePrefix(), true);
            } else {
                final String prefix = getDevicePrefix() + '-';
                if (!device.getId().startsWith(prefix)) {
                    dm.rename(device, getDevicePrefix() + '-' + device.getId(), false);
                }
            }
        } catch (DeviceAlreadyRegisteredException ex) {
            log.error("Cannot rename device", ex);
        } catch (NameNotFoundException ex) {
View Full Code Here

     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        final ARPNetworkLayer arp =
                (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        final IPv4Address addr = new IPv4Address(args[0]);
        final IPv4Address myAddr = new IPv4Address(args[1]);
        final Device dev = dm.getDevice(args[2]);
        final long timeout = 5000;

        final HardwareAddress hwAddr;
        hwAddr = arp.getHardwareAddress(addr, myAddr, dev, timeout);

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.