Android Open Source - drive-mount Block Device






From Project

Back to project page drive-mount.

License

The source code is released under:

Apache License

If you think the Android project drive-mount listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright  2014 Jan Seeger/*from   w  w  w  .ja va  2  s  .  c o m*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.alphadev.usbstorage.api.device;

import net.alphadev.usbstorage.api.Identifiable;

import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * @author Jan Seeger <jan@alphadev.net>
 */
public interface BlockDevice extends Identifiable, Closeable {
    /**
     * Gets the total length of this device in bytes.
     *
     * @return the total number of bytes on this device
     * @throws java.io.IOException on error getting the size of this device
     */
    public abstract long getSize() throws IOException;

    /**
     * Read a block of data from this device.
     *
     * @param devOffset the byte offset where to read the data from
     * @param dest      the destination buffer where to store the data read
     * @throws IOException on read error
     */
    public abstract void read(long devOffset, ByteBuffer dest)
            throws IOException;

    /**
     * Writes a block of data to this device.
     *
     * @param devOffset the byte offset where to store the data
     * @param src       the source {@code ByteBuffer} to write to the device
     * @throws IOException              on write error
     * @throws IllegalArgumentException if the {@code devOffset} is negative
     *                                  or the write would go beyond the end of the device
     * @see #isReadOnly()
     */
    public abstract void write(long devOffset, ByteBuffer src)
            throws IOException,
            IllegalArgumentException;

    /**
     * Flushes data in caches to the actual storage.
     *
     * @throws IOException on write error
     */
    public abstract void flush() throws IOException;

    /**
     * Returns the size of a sector on this device.
     *
     * @return the sector size in bytes
     * @throws IOException on error determining the sector size
     */
    public int getSectorSize() throws IOException;

    /**
     * Closes this {@code BlockDevice}. No methods of this device may be
     * accesses after this method was called.
     *
     * @throws IOException on error closing this device
     * @see #isClosed()
     */
    public void close() throws IOException;

    /**
     * Checks if this device was already closed. No methods may be called
     * on a closed device (except this method).
     *
     * @return if this device is closed
     */
    public boolean isClosed();

    /**
     * Checks if this {@code BlockDevice} is read-only.
     *
     * @return if this {@code BlockDevice} is read-only
     */
    public boolean isReadOnly();

    void initialize();
}




Java Source Code List

net.alphadev.fat32wrapper.Fat32Provider.java
net.alphadev.fat32wrapper.FatBlockDeviceWrapper.java
net.alphadev.fat32wrapper.FatStorage.java
net.alphadev.fat32wrapper.ReadingFileHandle.java
net.alphadev.usbstorage.DeviceManager.java
net.alphadev.usbstorage.DocumentProviderImpl.java
net.alphadev.usbstorage.StorageManager.java
net.alphadev.usbstorage.UsbBulkDevice.java
net.alphadev.usbstorage.api.Identifiable.java
net.alphadev.usbstorage.api.device.BlockDevice.java
net.alphadev.usbstorage.api.device.BulkDevice.java
net.alphadev.usbstorage.api.device.ReadOnlyException.java
net.alphadev.usbstorage.api.filesystem.FileAttribute.java
net.alphadev.usbstorage.api.filesystem.FileHandle.java
net.alphadev.usbstorage.api.filesystem.FileSystemProvider.java
net.alphadev.usbstorage.api.filesystem.Path.java
net.alphadev.usbstorage.api.filesystem.StorageDevice.java
net.alphadev.usbstorage.api.scsi.ScsiTransferable.java
net.alphadev.usbstorage.api.scsi.Transmittable.java
net.alphadev.usbstorage.bbb.BulkBlockDevice.java
net.alphadev.usbstorage.partition.FileSystemDescriptor.java
net.alphadev.usbstorage.partition.MasterBootRecord.java
net.alphadev.usbstorage.partition.PartitionParameters.java
net.alphadev.usbstorage.partition.Partition.java
net.alphadev.usbstorage.scsi.CommandBlockWrapper.java
net.alphadev.usbstorage.scsi.CommandStatusWrapper.java
net.alphadev.usbstorage.scsi.answer.ModeSenseResponse.java
net.alphadev.usbstorage.scsi.answer.ReadCapacityResponse.java
net.alphadev.usbstorage.scsi.answer.ReadFormatCapacitiesEntry.java
net.alphadev.usbstorage.scsi.answer.ReadFormatCapacitiesHeader.java
net.alphadev.usbstorage.scsi.answer.RequestSenseResponse.java
net.alphadev.usbstorage.scsi.answer.StandardInquiryAnswer.java
net.alphadev.usbstorage.scsi.command.Inquiry.java
net.alphadev.usbstorage.scsi.command.ModeSense.java
net.alphadev.usbstorage.scsi.command.Read10.java
net.alphadev.usbstorage.scsi.command.ReadCapacity.java
net.alphadev.usbstorage.scsi.command.ReadFormatCapacities.java
net.alphadev.usbstorage.scsi.command.RequestSense.java
net.alphadev.usbstorage.scsi.command.ScsiCommand.java
net.alphadev.usbstorage.scsi.command.TestUnitReady.java
net.alphadev.usbstorage.util.BitStitching.java
net.alphadev.usbstorage.util.ParcelFileDescriptorUtil.java