Package org.jnode.fs.ext2

Examples of org.jnode.fs.ext2.Ext2FileSystemType


    @Test
    public void testReadExt4SpecialFiles() throws Exception {

        device = new FileDevice(FileSystemTestUtils.getTestFile("test/fs/ext4/test-special-files.ext4"), "r");
        Ext2FileSystemType type = fss.getFileSystemType(Ext2FileSystemType.ID);
        Ext2FileSystem fs = type.create(device, true);

        String expectedStructure =
            "type: EXT2 vol: total:15728640 free:13918208\n" +
                "  /; \n" +
                "    lost+found; \n" +
View Full Code Here


        FileSystemTestConfigurationListBuilder fatBuilder =
            new FileSystemTestConfigurationListBuilder().osType(OsType.OTHER_OS).accessMode(FSAccessMode.BOTH)
                .filename(DISK_FILE_NAME).fileSize("33M");

        configs
            .addAll(defaultBuilder.fsType(FSType.EXT2).formatter(new Ext2FileSystemFormatter(BlockSize._1Kb)).build());
        configs
            .addAll(defaultBuilder.fsType(FSType.EXT2).formatter(new Ext2FileSystemFormatter(BlockSize._4Kb)).build());
        /* TODO Fix HFS failures
        configs.addAll(
            defaultBuilder.fsType(FSType.HFS_PLUS).formatter(new HfsPlusFileSystemFormatter(new HFSPlusParams()))
                .build());*/

 
View Full Code Here

    }

    @Override
    protected Ext2FileSystemFormatter getFormatter() {
        if (ARG_BLOCK_SIZE.isSet()) {
            return new Ext2FileSystemFormatter(ARG_BLOCK_SIZE.getValue());
        } else {
            return new Ext2FileSystemFormatter(BlockSize._4Kb);
        }
    }
View Full Code Here

    private UserFacade() {
        refreshDevicesFromOS();

        addFormatter(new FatFileSystemFormatter(FatType.FAT32));
        addFormatter(new org.jnode.fs.jfat.FatFileSystemFormatter(ClusterSize._16Kb));
        addFormatter(new Ext2FileSystemFormatter(BlockSize._4Kb));
    }
View Full Code Here

    @Test
    public void testReadExt4SpecialFiles() throws Exception {

        device = new FileDevice(FileSystemTestUtils.getTestFile("test/fs/ext4/test-special-files.ext4"), "r");
        Ext2FileSystemType type = fss.getFileSystemType(Ext2FileSystemType.ID);
        Ext2FileSystem fs = type.create(device, true);

        String expectedStructure =
            "type: EXT2 vol: total:15728640 free:13918208\n" +
                "  /; \n" +
                "    lost+found; \n" +
View Full Code Here

    public byte[] getBlock(long nr) throws IOException {
        if (isClosed()) throw new IOException("FS closed (fs instance: " + this + ")");
        // log.debug("blockCache size: "+blockCache.size());

        int blockSize = superblock.getBlockSize();
        Block result;

        Integer key = Integer.valueOf((int) nr);
        synchronized (blockCache) {
            // check if the block has already been retrieved
            if (blockCache.containsKey(key)) {
                result = blockCache.get(key);
                return result.getData();
            }
        }

        // perform the time-consuming disk read outside of the synchronized
        // block
        // advantage:
        // -the lock is held for a shorter time, so other blocks that are
        // already in the cache can be returned immediately and
        // do not have to wait for a long disk read
        // disadvantage:
        // -a single block can be retrieved more than once. However,
        // the block will be put in the cache only once in the second
        // synchronized block
        ByteBuffer data = ByteBuffer.allocate(blockSize);
        log.debug("Reading block " + nr + " (offset: " + nr * blockSize + ") from disk");
        getApi().read(nr * blockSize, data);

        // synchronize again
        synchronized (blockCache) {
            // check if the block has already been retrieved
            if (!blockCache.containsKey(key)) {
                result = new Block(this, nr, data.array());
                blockCache.put(key, result);
                return result.getData();
            } else {
                // it is important to ALWAYS return the block that is in
                // the cache (it is used in synchronization)
                result = blockCache.get(key);
                return result.getData();
            }
        }
    }
View Full Code Here

    public void writeBlock(long nr, byte[] data, boolean forceWrite) throws IOException {
        if (isClosed()) throw new IOException("FS closed");

        if (isReadOnly()) throw new ReadOnlyFileSystemException("Filesystem is mounted read-only!");

        Block block;

        Integer key = Integer.valueOf((int) nr);
        int blockSize = superblock.getBlockSize();
        // check if the block is in the cache
        synchronized (blockCache) {
            if (blockCache.containsKey(key)) {
                block = blockCache.get(key);
                // update the data in the cache
                block.setData(data);
                if (forceWrite || SYNC_WRITE) {
                    // write the block to disk
                    ByteBuffer dataBuf = ByteBuffer.wrap(data, 0, blockSize);
                    getApi().write(nr * blockSize, dataBuf);
                    // timedWrite(nr, data);
                    block.setDirty(false);

                    log.debug("writing block " + nr + " to disk");
                } else block.setDirty(true);
            } else {
                // If the block was not in the cache, I see no reason to put it
                // in the cache when it is written.
                // It is simply written to disk.
                ByteBuffer dataBuf = ByteBuffer.wrap(data, 0, blockSize);
View Full Code Here

     */
    public Ext2FileSystem(Device device, boolean readOnly, Ext2FileSystemType type) throws FileSystemException {
        super(device, readOnly, type);
        log.setLevel(Level.DEBUG);

        blockCache = new BlockCache(50, (float) 0.75);
        inodeCache = new INodeCache(50, (float) 0.75);

        // groupDescriptorLock = new Object();
        // superblockLock = new Object();
    }
View Full Code Here

    public Ext2FileSystem(Device device, boolean readOnly, Ext2FileSystemType type) throws FileSystemException {
        super(device, readOnly, type);
        log.setLevel(Level.DEBUG);

        blockCache = new BlockCache(50, (float) 0.75);
        inodeCache = new INodeCache(50, (float) 0.75);

        // groupDescriptorLock = new Object();
        // superblockLock = new Object();
    }
View Full Code Here

        if (i < blockCount) {
            long blockIndex = getDataBlockNr(i);
            //overwrite the block
            fs.writeBlock(blockIndex, data, false);
        } else {
            throw new UnallocatedBlockException("Block " + i + " not yet reserved " +
                "for the inode");
        }
    }
View Full Code Here

TOP

Related Classes of org.jnode.fs.ext2.Ext2FileSystemType

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.