Package org.jnode.driver

Examples of org.jnode.driver.Device


        new JGrubInstallCommand().execute(args);
    }

    public void execute()
        throws GrubException {
        Device device = ARG_DEVICE.getValue();

        JGrub jgrub = new JGrub(getOutput().getPrintWriter(), device);
        jgrub.install();
    }
View Full Code Here


        }
        final String parentDeviceName = deviceName.substring(0, i + 1);
        final int partitionNumber = Integer.parseInt(deviceName.substring(i + 1));
        //

        final Device parentDevice = getDevice(dm, parentDeviceName);
        final BlockDeviceAPI parentDeviceApi = getBlockDeviceAPI(parentDevice);

        stage1.format(parentDeviceApi);
        stage1_5.format(parentDeviceApi, partitionNumber);
View Full Code Here

            throw new GrubException("device must be a partition device", e);
        }
    }

    private Device getDevice(DeviceManager dm, String deviceName) throws GrubException {
        Device parentDevice = null;
        try {
            parentDevice = dm.getDevice(deviceName);
        } catch (DeviceNotFoundException e1) {
            throw new GrubException("can't find device with name " + deviceName, e1);
        }
View Full Code Here

    @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

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

    public void execute() throws ApiNotFoundException, IOException {
        final Device dev;
        if (!argDevice.isSet()) {
            Iterator<Device> iter = DeviceUtils.getDevicesByAPI(RemovableDeviceAPI.class).iterator();
            dev = iter.hasNext() ? iter.next() : null;
        } else {
            dev = argDevice.getValue();
        }

        if (dev == null) {
            getError().getPrintWriter().println("No removable device found.");
            return;
        }

        final RemovableDeviceAPI api = dev.getAPI(RemovableDeviceAPI.class);
        try {
            if (!api.canEject()) {
                getError().getPrintWriter().format("No device found to %s.",
                    argLoad.isSet() ? "load" : "eject");
                return;
            }

            if (argLoad.isSet()) {
                api.load();
            } else {
                api.eject();
            }
        } catch (IOException ex) {
            getError().getPrintWriter().format(fmt_failed, dev.getId(), ex.getLocalizedMessage());
            exit(1);
        }
    }
View Full Code Here

    protected abstract Formatter<T> getFormatter();

    public final void execute()
        throws FileSystemException, NameNotFoundException, DeviceNotFoundException, DriverException {
        Device dev = ARG_DEVICE.getValue();
        Formatter<T> formatter = getFormatter();
        formatter.format(dev);

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

        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

        fss         = InitialNaming.lookup(FileSystemService.NAME);
        dm          = InitialNaming.lookup(DeviceManager.NAME);
        mountPoints = fss.getDeviceMountPoints();
        out         = getOutput().getPrintWriter(true);
       
        Device device = null;
       
        printHeader();
       
        if (argPath.isSet()) {
            device = getDeviceForPath(argPath.getValue());
View Full Code Here

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

     */
    public void findDevices(DeviceManager devMan, Bus bus)
        throws DeviceException {
        try {
            // Register floppy controller device
            Device fdcDev = new FloppyControllerDevice(bus);
            fdcDev.setDriver(new FloppyControllerDriver());
            devMan.register(fdcDev);
        } catch (DriverException ex) {
            throw new DeviceException(ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.jnode.driver.Device

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.