mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-28 12:51:52 +01:00
-updated libntfs-wii to version 2012.1.15
-updated libext2fs to e2fsprogs 1.42 -updated libfat to R4883 Thanks to USB Loader GX for the new libs
This commit is contained in:
parent
db893ac4e1
commit
30bc03c9fa
2
Makefile
2
Makefile
@ -78,7 +78,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80A00
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -ljpeg -lwiilight -lntfs -lfat -lext2fs -lmodplay
|
||||
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -ljpeg -lwiilight -lmodplay
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
@ -1,22 +1,22 @@
|
||||
/**
|
||||
* ext2.h - devoptab file routines for EXT2/3/4-based devices.
|
||||
*
|
||||
* Copyright (c) 2010 Dimok
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program/include file is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/********************************************************************************
|
||||
* ext2.h - devoptab file routines for EXT2/3/4-based devices. *
|
||||
* *
|
||||
* Copyright (c) 2010 Dimok *
|
||||
* *
|
||||
* This program/include file is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as published *
|
||||
* by the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program/include file is distributed in the hope that it will be *
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
********************************************************************************/
|
||||
#ifndef __EXT2_H_
|
||||
#define __EXT2_H_
|
||||
|
||||
@ -28,17 +28,24 @@ extern "C" {
|
||||
#include <gccore.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
/* EXT2 cache options */
|
||||
#define CACHE_DEFAULT_PAGE_COUNT 8 /* The default number of pages in the cache */
|
||||
#define CACHE_DEFAULT_PAGE_SIZE 128 /* The default number of sectors per cache page */
|
||||
/**
|
||||
* EXT2 cache options
|
||||
*
|
||||
* It is recommended to use more pages instead of large page sizes for cache due to the sporadic write behaviour of ext file system.
|
||||
* It will significantly increase the speed. A page size of 32 is mostly suffiecient. The larger the page count the faster the
|
||||
* read/write between smaller files will be. Larger page sizes result in faster read/write of single big files.
|
||||
*/
|
||||
#define EXT2_CACHE_DEFAULT_PAGE_COUNT 64 /* The default number of pages in the cache */
|
||||
#define EXT2_CACHE_DEFAULT_PAGE_SIZE 32 /* The default number of sectors per cache page */
|
||||
|
||||
/* EXT2 mount flags */
|
||||
#define EXT2_FLAG_RW 0x00001 /* Open the filesystem for reading and writing. Without this flag, the filesystem is opened for reading only. */
|
||||
#define EXT2_FLAG_FORCE 0x00400 /* Open the filesystem regardless of the feature sets listed in the superblock */
|
||||
#define EXT2_FLAG_JOURNAL_DEV_OK 0x01000 /* Only open external journal devices if this flag is set (e.g. ext3/ext4) */
|
||||
#define EXT2_FLAG_64BITS 0x20000 /* Use the new style 64-Bit bitmaps. For more information see gen_bitmap64.c */
|
||||
#define EXT2_FLAG_PRINT_PROGRESS 0x40000 /* If this flag is set the progress of file operations will be printed to stdout */
|
||||
#define EXT2_FLAG_DEFAULT (EXT2_FLAG_RW | EXT2_FLAG_64BITS | EXT2_FLAG_JOURNAL_DEV_OK)
|
||||
#define EXT2_FLAG_RW 0x00001 /* Open the filesystem for reading and writing. Without this flag, the filesystem is opened for reading only. */
|
||||
#define EXT2_FLAG_FORCE 0x00400 /* Open the filesystem regardless of the feature sets listed in the superblock */
|
||||
#define EXT2_FLAG_JOURNAL_DEV_OK 0x01000 /* Only open external journal devices if this flag is set (e.g. ext3/ext4) */
|
||||
#define EXT2_FLAG_64BITS 0x20000 /* Use the new style 64-Bit bitmaps. For more information see gen_bitmap64.c */
|
||||
#define EXT2_FLAG_PRINT_PROGRESS 0x40000 /* If this flag is set the progress of file operations will be printed to stdout */
|
||||
#define EXT2_FLAG_SKIP_MMP 0x100000 /* Open without multi-mount protection check. */
|
||||
#define EXT2_FLAG_DEFAULT (EXT2_FLAG_RW | EXT2_FLAG_64BITS | EXT2_FLAG_JOURNAL_DEV_OK | EXT2_FLAG_SKIP_MMP)
|
||||
|
||||
/**
|
||||
* Find all EXT2/3/4 partitions on a block device.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
fat.h
|
||||
Simple functionality for startup, mounting and unmounting of FAT-based devices.
|
||||
|
||||
|
||||
Copyright (c) 2006 - 2009
|
||||
Michael "Chishm" Chisholm
|
||||
Dave "WinterMute" Murphy
|
||||
@ -71,7 +71,7 @@ extern bool fatInitDefault (void);
|
||||
/*
|
||||
Mount the device pointed to by interface, and set up a devoptab entry for it as "name:".
|
||||
You can then access the filesystem using "name:/".
|
||||
This will mount the active partition or the first valid partition on the disc,
|
||||
This will mount the active partition or the first valid partition on the disc,
|
||||
and will use a cache size optimized for the host system.
|
||||
*/
|
||||
extern bool fatMountSimple (const char* name, const DISC_INTERFACE* interface);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* ntfs.h - Simple functionality for startup, mounting and unmounting of NTFS-based devices.
|
||||
*
|
||||
* Copyright (c) 2010 Dimok
|
||||
* Copyright (c) 2009 Rhys "Shareese" Koedijk
|
||||
* Copyright (c) 2006 Michael "Chishm" Chisholm
|
||||
*
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,4 +6,5 @@ to the Nintendo GameCube/Wii port of ext2fs.
|
||||
|
||||
Michael "Chishm" Chisholm
|
||||
rodries
|
||||
Rhys "Shareese" Koedijk
|
||||
Rhys "Shareese" Koedijk
|
||||
Dimok
|
27
portlibs/sources/libcustomext2fs/Makefile
Normal file
27
portlibs/sources/libcustomext2fs/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
default: cube-release wii-release
|
||||
|
||||
all: debug release
|
||||
|
||||
debug: cube-debug wii-debug
|
||||
|
||||
release: cube-release wii-release
|
||||
|
||||
cube-debug:
|
||||
$(MAKE) -C source PLATFORM=cube BUILD=cube_debug
|
||||
|
||||
wii-debug:
|
||||
$(MAKE) -C source PLATFORM=wii BUILD=wii_debug
|
||||
|
||||
cube-release:
|
||||
$(MAKE) -C source PLATFORM=cube BUILD=cube_release
|
||||
|
||||
wii-release:
|
||||
$(MAKE) -C source PLATFORM=wii BUILD=wii_release
|
||||
|
||||
clean:
|
||||
$(MAKE) -C source clean
|
||||
|
||||
install: cube-release wii-release
|
||||
$(MAKE) -C source install
|
||||
|
@ -1,22 +1,22 @@
|
||||
/**
|
||||
* ext2.h - devoptab file routines for EXT2/3/4-based devices.
|
||||
*
|
||||
* Copyright (c) 2010 Dimok
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program/include file is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/********************************************************************************
|
||||
* ext2.h - devoptab file routines for EXT2/3/4-based devices. *
|
||||
* *
|
||||
* Copyright (c) 2010 Dimok *
|
||||
* *
|
||||
* This program/include file is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as published *
|
||||
* by the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program/include file is distributed in the hope that it will be *
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
********************************************************************************/
|
||||
#ifndef __EXT2_H_
|
||||
#define __EXT2_H_
|
||||
|
||||
@ -28,17 +28,24 @@ extern "C" {
|
||||
#include <gccore.h>
|
||||
#include <ogc/disc_io.h>
|
||||
|
||||
/* EXT2 cache options */
|
||||
#define CACHE_DEFAULT_PAGE_COUNT 8 /* The default number of pages in the cache */
|
||||
#define CACHE_DEFAULT_PAGE_SIZE 128 /* The default number of sectors per cache page */
|
||||
/**
|
||||
* EXT2 cache options
|
||||
*
|
||||
* It is recommended to use more pages instead of large page sizes for cache due to the sporadic write behaviour of ext file system.
|
||||
* It will significantly increase the speed. A page size of 32 is mostly suffiecient. The larger the page count the faster the
|
||||
* read/write between smaller files will be. Larger page sizes result in faster read/write of single big files.
|
||||
*/
|
||||
#define EXT2_CACHE_DEFAULT_PAGE_COUNT 64 /* The default number of pages in the cache */
|
||||
#define EXT2_CACHE_DEFAULT_PAGE_SIZE 32 /* The default number of sectors per cache page */
|
||||
|
||||
/* EXT2 mount flags */
|
||||
#define EXT2_FLAG_RW 0x00001 /* Open the filesystem for reading and writing. Without this flag, the filesystem is opened for reading only. */
|
||||
#define EXT2_FLAG_FORCE 0x00400 /* Open the filesystem regardless of the feature sets listed in the superblock */
|
||||
#define EXT2_FLAG_JOURNAL_DEV_OK 0x01000 /* Only open external journal devices if this flag is set (e.g. ext3/ext4) */
|
||||
#define EXT2_FLAG_64BITS 0x20000 /* Use the new style 64-Bit bitmaps. For more information see gen_bitmap64.c */
|
||||
#define EXT2_FLAG_PRINT_PROGRESS 0x40000 /* If this flag is set the progress of file operations will be printed to stdout */
|
||||
#define EXT2_FLAG_DEFAULT (EXT2_FLAG_RW | EXT2_FLAG_64BITS | EXT2_FLAG_JOURNAL_DEV_OK)
|
||||
#define EXT2_FLAG_RW 0x00001 /* Open the filesystem for reading and writing. Without this flag, the filesystem is opened for reading only. */
|
||||
#define EXT2_FLAG_FORCE 0x00400 /* Open the filesystem regardless of the feature sets listed in the superblock */
|
||||
#define EXT2_FLAG_JOURNAL_DEV_OK 0x01000 /* Only open external journal devices if this flag is set (e.g. ext3/ext4) */
|
||||
#define EXT2_FLAG_64BITS 0x20000 /* Use the new style 64-Bit bitmaps. For more information see gen_bitmap64.c */
|
||||
#define EXT2_FLAG_PRINT_PROGRESS 0x40000 /* If this flag is set the progress of file operations will be printed to stdout */
|
||||
#define EXT2_FLAG_SKIP_MMP 0x100000 /* Open without multi-mount protection check. */
|
||||
#define EXT2_FLAG_DEFAULT (EXT2_FLAG_RW | EXT2_FLAG_64BITS | EXT2_FLAG_JOURNAL_DEV_OK | EXT2_FLAG_SKIP_MMP)
|
||||
|
||||
/**
|
||||
* Find all EXT2/3/4 partitions on a block device.
|
@ -28,9 +28,7 @@ LIBDIR := ../lib
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS = -O3 -Wall $(MACHDEP) $(INCLUDE) -DGEKKO \
|
||||
-DHAVE_UNISTD_H -DHAVE_SYS_STAT_H -DHAVE_SYS_TYPES_H -DHAVE_UTIME_H -DWORDS_BIGENDIAN \
|
||||
-DHAVE_ERRNO_H -DHAVE_STRDUP -DHAVE_SYS_RESOURCE_H
|
||||
CFLAGS = -O2 -Wall -Wno-unused $(MACHDEP) $(INCLUDE) -DGEKKO -DWORDS_BIGENDIAN
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
ASFLAGS := -g
|
||||
export EXT2BIN := $(LIBDIR)/$(PLATFORM)/libext2fs.a
|
||||
@ -100,14 +98,13 @@ clean:
|
||||
all: $(EXT2BIN)
|
||||
|
||||
install:
|
||||
cp ../include/ext2.h ../../../include
|
||||
cp ext2_frag.h ../../../include
|
||||
cp ../lib/wii/libext2fs.a ../../../lib
|
||||
cp ../include/ext2.h $(DEVKITPRO)/libogc/include
|
||||
cp ../lib/wii/libext2fs.a $(DEVKITPRO)/libogc/lib/wii
|
||||
cp ../lib/cube/libext2fs.a $(DEVKITPRO)/libogc/lib/cube
|
||||
|
||||
wii-install:
|
||||
cp ../include/ext2.h ../../../include
|
||||
cp ext2_frag.h ../../../include
|
||||
cp ../lib/wii/libext2fs.a ../../../lib
|
||||
cp ../include/ext2.h $(DEVKITPRO)/libogc/include
|
||||
cp ../lib/wii/libext2fs.a $(DEVKITPRO)/libogc/lib/wii
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -52,6 +53,11 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
|
||||
else
|
||||
old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
|
||||
|
||||
for (i=0; i < fs->super->s_blocks_per_group; i++, blk++)
|
||||
ext2fs_fast_unmark_block_bitmap2(map, blk);
|
||||
|
||||
blk = (group * fs->super->s_blocks_per_group) +
|
||||
fs->super->s_first_data_block;
|
||||
for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) {
|
||||
if ((blk == super_blk) ||
|
||||
(old_desc_blk && old_desc_blocks &&
|
||||
@ -64,8 +70,6 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
|
||||
(blk < ext2fs_inode_table_loc(fs, group)
|
||||
+ fs->inode_blocks_per_group)))
|
||||
ext2fs_fast_mark_block_bitmap2(map, blk);
|
||||
else
|
||||
ext2fs_fast_unmark_block_bitmap2(map, blk);
|
||||
}
|
||||
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
|
||||
ext2fs_group_desc_csum_set(fs, group);
|
||||
@ -149,6 +153,7 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
|
||||
ext2fs_block_bitmap map, blk64_t *ret)
|
||||
{
|
||||
blk64_t i;
|
||||
int c_ratio;
|
||||
|
||||
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
||||
|
||||
@ -159,6 +164,9 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
|
||||
if (!goal || (goal >= ext2fs_blocks_count(fs->super)))
|
||||
goal = fs->super->s_first_data_block;
|
||||
i = goal;
|
||||
c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
|
||||
if (c_ratio > 1)
|
||||
goal &= ~EXT2FS_CLUSTER_MASK(fs);
|
||||
check_block_uninit(fs, map,
|
||||
(i - fs->super->s_first_data_block) /
|
||||
EXT2_BLOCKS_PER_GROUP(fs->super));
|
||||
@ -173,7 +181,7 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
|
||||
*ret = i;
|
||||
return 0;
|
||||
}
|
||||
i++;
|
||||
i = (i + c_ratio) & ~(c_ratio - 1);
|
||||
if (i >= ext2fs_blocks_count(fs->super))
|
||||
i = fs->super->s_first_data_block;
|
||||
} while (i != goal);
|
||||
@ -254,6 +262,7 @@ errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
|
||||
int num, ext2fs_block_bitmap map, blk64_t *ret)
|
||||
{
|
||||
blk64_t b = start;
|
||||
int c_ratio;
|
||||
|
||||
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
||||
|
||||
@ -267,6 +276,9 @@ errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
|
||||
finish = start;
|
||||
if (!num)
|
||||
num = 1;
|
||||
c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
|
||||
b &= ~(c_ratio - 1);
|
||||
finish &= ~(c_ratio -1);
|
||||
do {
|
||||
if (b+num-1 > ext2fs_blocks_count(fs->super))
|
||||
b = fs->super->s_first_data_block;
|
||||
@ -274,7 +286,7 @@ errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
|
||||
*ret = b;
|
||||
return 0;
|
||||
}
|
||||
b++;
|
||||
b += c_ratio;
|
||||
} while (b != finish);
|
||||
return EXT2_ET_BLOCK_ALLOC_FAIL;
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -59,6 +60,9 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
|
||||
|
||||
if (super_blk || (group == 0))
|
||||
ext2fs_mark_block_bitmap2(bmap, super_blk);
|
||||
if ((group == 0) && (fs->blocksize == 1024) &&
|
||||
EXT2FS_CLUSTER_RATIO(fs) > 1)
|
||||
ext2fs_mark_block_bitmap2(bmap, 0);
|
||||
|
||||
if (old_desc_blk) {
|
||||
if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap)
|
||||
@ -71,15 +75,7 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
|
||||
if (new_desc_blk)
|
||||
ext2fs_mark_block_bitmap2(bmap, new_desc_blk);
|
||||
|
||||
if (group == fs->group_desc_count-1) {
|
||||
num_blocks = (ext2fs_blocks_count(fs->super) -
|
||||
fs->super->s_first_data_block) %
|
||||
fs->super->s_blocks_per_group;
|
||||
if (!num_blocks)
|
||||
num_blocks = fs->super->s_blocks_per_group;
|
||||
} else
|
||||
num_blocks = fs->super->s_blocks_per_group;
|
||||
|
||||
num_blocks = ext2fs_group_blocks_count(fs, group);
|
||||
num_blocks -= 2 + fs->inode_blocks_per_group + used_blks;
|
||||
|
||||
return num_blocks ;
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ext2_fs.h"
|
||||
@ -77,7 +78,8 @@ void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
|
||||
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
|
||||
ext2fs_group_desc_csum_set(fs, group);
|
||||
|
||||
ext2fs_free_blocks_count_add(fs->super, -inuse);
|
||||
ext2fs_free_blocks_count_add(fs->super,
|
||||
-inuse * EXT2FS_CLUSTER_RATIO(fs));
|
||||
ext2fs_mark_super_dirty(fs);
|
||||
ext2fs_mark_bb_dirty(fs);
|
||||
if (fs->block_alloc_stats)
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -35,45 +36,45 @@
|
||||
* tables can be allocated continously and in order.
|
||||
*/
|
||||
static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
|
||||
ext2fs_block_bitmap bmap, int offset, int size,
|
||||
ext2fs_block_bitmap bmap, int rem_grp,
|
||||
int elem_size)
|
||||
{
|
||||
int flexbg, flexbg_size;
|
||||
int flexbg, flexbg_size, size;
|
||||
blk64_t last_blk, first_free = 0;
|
||||
dgrp_t last_grp;
|
||||
|
||||
flexbg_size = 1 << fs->super->s_log_groups_per_flex;
|
||||
flexbg = group / flexbg_size;
|
||||
size = rem_grp * elem_size;
|
||||
|
||||
if (size > (int) (fs->super->s_blocks_per_group / 8))
|
||||
size = (int) fs->super->s_blocks_per_group / 8;
|
||||
|
||||
if (offset)
|
||||
offset -= 1;
|
||||
|
||||
/*
|
||||
* Don't do a long search if the previous block
|
||||
* search is still valid.
|
||||
*/
|
||||
if (start_blk && group % flexbg_size) {
|
||||
if (ext2fs_test_block_bitmap_range2(bmap, start_blk + elem_size,
|
||||
size))
|
||||
return start_blk + elem_size;
|
||||
}
|
||||
if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk,
|
||||
elem_size))
|
||||
return start_blk;
|
||||
|
||||
start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg);
|
||||
last_grp = group | (flexbg_size - 1);
|
||||
if (last_grp > fs->group_desc_count)
|
||||
last_grp = fs->group_desc_count;
|
||||
if (last_grp > fs->group_desc_count-1)
|
||||
last_grp = fs->group_desc_count-1;
|
||||
last_blk = ext2fs_group_last_block2(fs, last_grp);
|
||||
|
||||
/* Find the first available block */
|
||||
if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, 1, bmap,
|
||||
&first_free))
|
||||
if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, size,
|
||||
bmap, &first_free) == 0)
|
||||
return first_free;
|
||||
|
||||
if (ext2fs_get_free_blocks2(fs, first_free + offset, last_blk, size,
|
||||
bmap, &first_free))
|
||||
if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, elem_size,
|
||||
bmap, &first_free) == 0)
|
||||
return first_free;
|
||||
|
||||
if (ext2fs_get_free_blocks2(fs, 0, last_blk, elem_size, bmap,
|
||||
&first_free) == 0)
|
||||
return first_free;
|
||||
|
||||
return first_free;
|
||||
@ -82,10 +83,11 @@ static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
|
||||
errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||
ext2fs_block_bitmap bmap)
|
||||
{
|
||||
unsigned int j;
|
||||
errcode_t retval;
|
||||
blk64_t group_blk, start_blk, last_blk, new_blk, blk;
|
||||
dgrp_t last_grp = 0;
|
||||
int j, rem_grps = 0, flexbg_size = 0;
|
||||
int rem_grps = 0, flexbg_size = 0;
|
||||
|
||||
group_blk = ext2fs_group_first_block2(fs, group);
|
||||
last_blk = ext2fs_group_last_block2(fs, group);
|
||||
@ -98,9 +100,9 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||
fs->super->s_log_groups_per_flex) {
|
||||
flexbg_size = 1 << fs->super->s_log_groups_per_flex;
|
||||
last_grp = group | (flexbg_size - 1);
|
||||
rem_grps = last_grp - group;
|
||||
if (last_grp > fs->group_desc_count)
|
||||
last_grp = fs->group_desc_count;
|
||||
if (last_grp > fs->group_desc_count-1)
|
||||
last_grp = fs->group_desc_count-1;
|
||||
rem_grps = last_grp - group + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -122,10 +124,10 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||
if (flexbg_size) {
|
||||
blk64_t prev_block = 0;
|
||||
|
||||
if (group && ext2fs_block_bitmap_loc(fs, group - 1))
|
||||
prev_block = ext2fs_block_bitmap_loc(fs, group - 1);
|
||||
if (group % flexbg_size)
|
||||
prev_block = ext2fs_block_bitmap_loc(fs, group - 1) + 1;
|
||||
start_blk = flexbg_offset(fs, group, prev_block, bmap,
|
||||
0, rem_grps, 1);
|
||||
rem_grps, 1);
|
||||
last_blk = ext2fs_group_last_block2(fs, last_grp);
|
||||
}
|
||||
|
||||
@ -150,10 +152,13 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||
|
||||
if (flexbg_size) {
|
||||
blk64_t prev_block = 0;
|
||||
if (group && ext2fs_inode_bitmap_loc(fs, group - 1))
|
||||
prev_block = ext2fs_inode_bitmap_loc(fs, group - 1);
|
||||
if (group % flexbg_size)
|
||||
prev_block = ext2fs_inode_bitmap_loc(fs, group - 1) + 1;
|
||||
else
|
||||
prev_block = ext2fs_block_bitmap_loc(fs, group) +
|
||||
flexbg_size;
|
||||
start_blk = flexbg_offset(fs, group, prev_block, bmap,
|
||||
flexbg_size, rem_grps, 1);
|
||||
rem_grps, 1);
|
||||
last_blk = ext2fs_group_last_block2(fs, last_grp);
|
||||
}
|
||||
|
||||
@ -181,15 +186,16 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
|
||||
*/
|
||||
if (flexbg_size) {
|
||||
blk64_t prev_block = 0;
|
||||
if (group && ext2fs_inode_table_loc(fs, group - 1))
|
||||
prev_block = ext2fs_inode_table_loc(fs, group - 1);
|
||||
if (last_grp == fs->group_desc_count)
|
||||
rem_grps = last_grp - group;
|
||||
|
||||
if (group % flexbg_size)
|
||||
prev_block = ext2fs_inode_table_loc(fs, group - 1) +
|
||||
fs->inode_blocks_per_group;
|
||||
else
|
||||
prev_block = ext2fs_inode_bitmap_loc(fs, group) +
|
||||
flexbg_size;
|
||||
|
||||
group_blk = flexbg_offset(fs, group, prev_block, bmap,
|
||||
flexbg_size * 2,
|
||||
fs->inode_blocks_per_group *
|
||||
rem_grps,
|
||||
fs->inode_blocks_per_group);
|
||||
rem_grps, fs->inode_blocks_per_group);
|
||||
last_blk = ext2fs_group_last_block2(fs, last_grp);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -177,7 +178,7 @@ int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk)
|
||||
return high;
|
||||
|
||||
while (low < high) {
|
||||
mid = (low+high)/2;
|
||||
mid = ((unsigned)low + (unsigned)high)/2;
|
||||
if (mid == low || mid == high)
|
||||
break;
|
||||
if (blk == bb->list[mid])
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -13,6 +13,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -27,6 +28,7 @@
|
||||
#include "ext2_fs.h"
|
||||
#include "ext2fs.h"
|
||||
#include "ext2fsP.h"
|
||||
#include "bmap64.h"
|
||||
|
||||
void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
@ -90,9 +92,9 @@ errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
|
||||
|
||||
fs->write_bitmaps = ext2fs_write_bitmaps;
|
||||
|
||||
start = fs->super->s_first_data_block;
|
||||
end = ext2fs_blocks_count(fs->super)-1;
|
||||
real_end = ((__u64) EXT2_BLOCKS_PER_GROUP(fs->super)
|
||||
start = EXT2FS_B2C(fs, fs->super->s_first_data_block);
|
||||
end = EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super)-1);
|
||||
real_end = ((__u64) EXT2_CLUSTERS_PER_GROUP(fs->super)
|
||||
* (__u64) fs->group_desc_count)-1 + start;
|
||||
|
||||
if (fs->flags & EXT2_FLAG_64BITS)
|
||||
@ -110,6 +112,56 @@ errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
|
||||
(ext2fs_generic_bitmap *) ret));
|
||||
}
|
||||
|
||||
/*
|
||||
* ext2fs_allocate_block_bitmap() really allocates a per-cluster
|
||||
* bitmap for backwards compatibility. This function allocates a
|
||||
* block bitmap which is truly per-block, even if clusters/bigalloc
|
||||
* are enabled. mke2fs and e2fsck need this for tracking the
|
||||
* allocation of the file system metadata blocks.
|
||||
*/
|
||||
errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
|
||||
const char *descr,
|
||||
ext2fs_block_bitmap *ret)
|
||||
{
|
||||
__u64 start, end, real_end;
|
||||
ext2fs_generic_bitmap bmap;
|
||||
errcode_t retval;
|
||||
|
||||
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
||||
|
||||
fs->write_bitmaps = ext2fs_write_bitmaps;
|
||||
|
||||
if (!fs->cluster_ratio_bits)
|
||||
return ext2fs_allocate_block_bitmap(fs, descr, ret);
|
||||
|
||||
if ((fs->flags & EXT2_FLAG_64BITS) == 0)
|
||||
return EXT2_ET_CANT_USE_LEGACY_BITMAPS;
|
||||
|
||||
start = fs->super->s_first_data_block;
|
||||
end = ext2fs_blocks_count(fs->super)-1;
|
||||
real_end = ((__u64) EXT2_BLOCKS_PER_GROUP(fs->super)
|
||||
* (__u64) fs->group_desc_count)-1 + start;
|
||||
|
||||
retval = ext2fs_alloc_generic_bmap(fs, EXT2_ET_MAGIC_BLOCK_BITMAP64,
|
||||
EXT2FS_BMAP64_BITARRAY, start,
|
||||
end, real_end, descr, &bmap);
|
||||
if (retval)
|
||||
return retval;
|
||||
bmap->cluster_bits = 0;
|
||||
*ret = bmap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
ext2fs_generic_bitmap bmap = bitmap;
|
||||
|
||||
if (!EXT2FS_IS_64_BITMAP(bmap))
|
||||
return 0;
|
||||
|
||||
return bmap->cluster_bits;
|
||||
}
|
||||
|
||||
errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t end, ext2_ino_t *oend)
|
||||
{
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
@ -12,6 +12,8 @@
|
||||
#ifndef _BITOPS_H_
|
||||
#define _BITOPS_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
extern int ext2fs_set_bit(unsigned int nr,void * addr);
|
||||
extern int ext2fs_clear_bit(unsigned int nr, void * addr);
|
||||
extern int ext2fs_test_bit(unsigned int nr, const void * addr);
|
||||
@ -33,6 +35,8 @@ extern __u64 ext2fs_swab64(__u64 val);
|
||||
#define ext2fs_le32_to_cpu(x) ext2fs_swab32((x))
|
||||
#define ext2fs_cpu_to_le16(x) ext2fs_swab16((x))
|
||||
#define ext2fs_le16_to_cpu(x) ext2fs_swab16((x))
|
||||
#define ext2fs_cpu_to_be64(x) ((__u64)(x))
|
||||
#define ext2fs_be64_to_cpu(x) ((__u64)(x))
|
||||
#define ext2fs_cpu_to_be32(x) ((__u32)(x))
|
||||
#define ext2fs_be32_to_cpu(x) ((__u32)(x))
|
||||
#define ext2fs_cpu_to_be16(x) ((__u16)(x))
|
||||
@ -44,6 +48,8 @@ extern __u64 ext2fs_swab64(__u64 val);
|
||||
#define ext2fs_le32_to_cpu(x) ((__u32)(x))
|
||||
#define ext2fs_cpu_to_le16(x) ((__u16)(x))
|
||||
#define ext2fs_le16_to_cpu(x) ((__u16)(x))
|
||||
#define ext2fs_cpu_to_be64(x) ext2fs_swab64((x))
|
||||
#define ext2fs_be64_to_cpu(x) ext2fs_swab64((x))
|
||||
#define ext2fs_cpu_to_be32(x) ext2fs_swab32((x))
|
||||
#define ext2fs_be32_to_cpu(x) ext2fs_swab32((x))
|
||||
#define ext2fs_cpu_to_be16(x) ext2fs_swab16((x))
|
||||
@ -634,5 +640,4 @@ _INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
|
||||
#undef _INLINE_
|
||||
#endif
|
||||
|
||||
#endif
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -11,6 +11,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ext2fs.h"
|
||||
|
||||
/*
|
||||
@ -42,6 +43,25 @@ blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group)
|
||||
(fs->super->s_blocks_per_group - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of blocks in a group
|
||||
*/
|
||||
int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group)
|
||||
{
|
||||
int num_blocks;
|
||||
|
||||
if (group == fs->group_desc_count - 1) {
|
||||
num_blocks = (ext2fs_blocks_count(fs->super) -
|
||||
fs->super->s_first_data_block) %
|
||||
fs->super->s_blocks_per_group;
|
||||
if (!num_blocks)
|
||||
num_blocks = fs->super->s_blocks_per_group;
|
||||
} else
|
||||
num_blocks = fs->super->s_blocks_per_group;
|
||||
|
||||
return num_blocks;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the inode data block count
|
||||
*/
|
||||
@ -455,23 +475,24 @@ void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum)
|
||||
|
||||
/*
|
||||
* Get the acl block of a file
|
||||
*
|
||||
* XXX Ignoring 64-bit file system flag - most places where this is
|
||||
* called don't have access to the fs struct, and the high bits should
|
||||
* be 0 in the non-64-bit case anyway.
|
||||
*/
|
||||
blk64_t ext2fs_file_acl_block(const struct ext2_inode *inode)
|
||||
blk64_t ext2fs_file_acl_block(ext2_filsys fs, const struct ext2_inode *inode)
|
||||
{
|
||||
return (inode->i_file_acl |
|
||||
(__u64) inode->osd2.linux2.l_i_file_acl_high << 32);
|
||||
blk64_t blk = inode->i_file_acl;
|
||||
|
||||
if (fs && fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
|
||||
blk |= ((__u64) inode->osd2.linux2.l_i_file_acl_high) << 32;
|
||||
return blk;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the acl block of a file
|
||||
*/
|
||||
void ext2fs_file_acl_block_set(struct ext2_inode *inode, blk64_t blk)
|
||||
void ext2fs_file_acl_block_set(ext2_filsys fs, struct ext2_inode *inode,
|
||||
blk64_t blk)
|
||||
{
|
||||
inode->i_file_acl = blk;
|
||||
inode->osd2.linux2.l_i_file_acl_high = (__u64) blk >> 32;
|
||||
if (fs && fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
|
||||
inode->osd2.linux2.l_i_file_acl_high = (__u64) blk >> 32;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -453,6 +454,17 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
|
||||
uninit = 0;
|
||||
if (extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
|
||||
uninit = EXT2_EXTENT_SET_BMAP_UNINIT;
|
||||
#if 0
|
||||
printf("lblk %llu pblk %llu len %d blockcnt %llu\n",
|
||||
extent.e_lblk, extent.e_pblk,
|
||||
extent.e_len, blockcnt);
|
||||
#endif
|
||||
if (extent.e_lblk + extent.e_len <= blockcnt)
|
||||
continue;
|
||||
if (extent.e_lblk > blockcnt)
|
||||
blockcnt = extent.e_lblk;
|
||||
j = blockcnt - extent.e_lblk;
|
||||
blk += j;
|
||||
for (blockcnt = extent.e_lblk, j = 0;
|
||||
j < extent.e_len;
|
||||
blk++, blockcnt++, j++) {
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -129,6 +130,106 @@ static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags,
|
||||
return retval;
|
||||
}
|
||||
|
||||
static errcode_t extent_bmap(ext2_filsys fs, ext2_ino_t ino,
|
||||
struct ext2_inode *inode,
|
||||
ext2_extent_handle_t handle,
|
||||
char *block_buf, int bmap_flags, blk64_t block,
|
||||
int *ret_flags, int *blocks_alloc,
|
||||
blk64_t *phys_blk);
|
||||
|
||||
static errcode_t implied_cluster_alloc(ext2_filsys fs, ext2_ino_t ino,
|
||||
struct ext2_inode *inode,
|
||||
ext2_extent_handle_t handle,
|
||||
blk64_t block, blk64_t *phys_blk)
|
||||
{
|
||||
blk64_t base_block, pblock = 0;
|
||||
int i;
|
||||
|
||||
if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
||||
EXT4_FEATURE_RO_COMPAT_BIGALLOC))
|
||||
return 0;
|
||||
|
||||
base_block = block & ~EXT2FS_CLUSTER_MASK(fs);
|
||||
for (i = 0; i < EXT2FS_CLUSTER_RATIO(fs); i++) {
|
||||
if (block == base_block)
|
||||
return 0;
|
||||
extent_bmap(fs, ino, inode, handle, 0, 0,
|
||||
base_block + i, 0, 0, &pblock);
|
||||
if (pblock)
|
||||
break;
|
||||
}
|
||||
if (pblock == 0)
|
||||
return 0;
|
||||
*phys_blk = pblock - i + (block - base_block);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static errcode_t extent_bmap(ext2_filsys fs, ext2_ino_t ino,
|
||||
struct ext2_inode *inode,
|
||||
ext2_extent_handle_t handle,
|
||||
char *block_buf, int bmap_flags, blk64_t block,
|
||||
int *ret_flags, int *blocks_alloc,
|
||||
blk64_t *phys_blk)
|
||||
{
|
||||
struct ext2fs_extent extent;
|
||||
unsigned int offset;
|
||||
errcode_t retval = 0;
|
||||
blk64_t blk64 = 0;
|
||||
int alloc = 0;
|
||||
|
||||
if (bmap_flags & BMAP_SET) {
|
||||
retval = ext2fs_extent_set_bmap(handle, block,
|
||||
*phys_blk, 0);
|
||||
return retval;
|
||||
}
|
||||
retval = ext2fs_extent_goto(handle, block);
|
||||
if (retval) {
|
||||
/* If the extent is not found, return phys_blk = 0 */
|
||||
if (retval == EXT2_ET_EXTENT_NOT_FOUND)
|
||||
goto got_block;
|
||||
return retval;
|
||||
}
|
||||
retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
|
||||
if (retval)
|
||||
return retval;
|
||||
offset = block - extent.e_lblk;
|
||||
if (block >= extent.e_lblk && (offset <= extent.e_len)) {
|
||||
*phys_blk = extent.e_pblk + offset;
|
||||
if (ret_flags && extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
|
||||
*ret_flags |= BMAP_RET_UNINIT;
|
||||
}
|
||||
got_block:
|
||||
if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) {
|
||||
implied_cluster_alloc(fs, ino, inode, handle, block, &blk64);
|
||||
if (blk64)
|
||||
goto set_extent;
|
||||
retval = extent_bmap(fs, ino, inode, handle, block_buf,
|
||||
0, block-1, 0, blocks_alloc, &blk64);
|
||||
if (retval)
|
||||
blk64 = 0;
|
||||
retval = ext2fs_alloc_block2(fs, blk64, block_buf,
|
||||
&blk64);
|
||||
if (retval)
|
||||
return retval;
|
||||
blk64 &= ~EXT2FS_CLUSTER_MASK(fs);
|
||||
blk64 += EXT2FS_CLUSTER_MASK(fs) & block;
|
||||
alloc++;
|
||||
set_extent:
|
||||
retval = ext2fs_extent_set_bmap(handle, block,
|
||||
blk64, 0);
|
||||
if (retval)
|
||||
return retval;
|
||||
/* Update inode after setting extent */
|
||||
retval = ext2fs_read_inode(fs, ino, inode);
|
||||
if (retval)
|
||||
return retval;
|
||||
*blocks_alloc += alloc;
|
||||
*phys_blk = blk64;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
|
||||
char *block_buf, int bmap_flags, blk64_t block,
|
||||
int *ret_flags, blk64_t *phys_blk)
|
||||
@ -156,54 +257,6 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
|
||||
}
|
||||
addr_per_block = (blk_t) fs->blocksize >> 2;
|
||||
|
||||
if (inode->i_flags & EXT4_EXTENTS_FL) {
|
||||
struct ext2fs_extent extent;
|
||||
unsigned int offset;
|
||||
|
||||
retval = ext2fs_extent_open2(fs, ino, inode, &handle);
|
||||
if (retval)
|
||||
goto done;
|
||||
if (bmap_flags & BMAP_SET) {
|
||||
retval = ext2fs_extent_set_bmap(handle, block,
|
||||
*phys_blk, 0);
|
||||
goto done;
|
||||
}
|
||||
retval = ext2fs_extent_goto(handle, block);
|
||||
if (retval) {
|
||||
/* If the extent is not found, return phys_blk = 0 */
|
||||
if (retval == EXT2_ET_EXTENT_NOT_FOUND)
|
||||
goto got_block;
|
||||
goto done;
|
||||
}
|
||||
retval = ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent);
|
||||
if (retval)
|
||||
goto done;
|
||||
offset = block - extent.e_lblk;
|
||||
if (block >= extent.e_lblk && (offset <= extent.e_len)) {
|
||||
*phys_blk = extent.e_pblk + offset;
|
||||
if (ret_flags && extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
|
||||
*ret_flags |= BMAP_RET_UNINIT;
|
||||
}
|
||||
got_block:
|
||||
if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) {
|
||||
retval = ext2fs_alloc_block(fs, b, block_buf, &b);
|
||||
if (retval)
|
||||
goto done;
|
||||
retval = ext2fs_extent_set_bmap(handle, block,
|
||||
(blk64_t) b, 0);
|
||||
if (retval)
|
||||
goto done;
|
||||
/* Update inode after setting extent */
|
||||
retval = ext2fs_read_inode(fs, ino, inode);
|
||||
if (retval)
|
||||
return retval;
|
||||
blocks_alloc++;
|
||||
*phys_blk = b;
|
||||
}
|
||||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!block_buf) {
|
||||
retval = ext2fs_get_array(2, fs->blocksize, &buf);
|
||||
if (retval)
|
||||
@ -211,6 +264,16 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
|
||||
block_buf = buf;
|
||||
}
|
||||
|
||||
if (inode->i_flags & EXT4_EXTENTS_FL) {
|
||||
retval = ext2fs_extent_open2(fs, ino, inode, &handle);
|
||||
if (retval)
|
||||
goto done;
|
||||
retval = extent_bmap(fs, ino, inode, handle, block_buf,
|
||||
bmap_flags, block, ret_flags,
|
||||
&blocks_alloc, phys_blk);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (block < EXT2_NDIR_BLOCKS) {
|
||||
if (bmap_flags & BMAP_SET) {
|
||||
b = *phys_blk;
|
@ -16,6 +16,7 @@ struct ext2fs_struct_generic_bitmap {
|
||||
int flags;
|
||||
__u64 start, end;
|
||||
__u64 real_end;
|
||||
int cluster_bits;
|
||||
char *description;
|
||||
void *private;
|
||||
errcode_t base_error_code;
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -140,7 +141,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
|
||||
|
||||
while (ino) {
|
||||
if ((inode.i_links_count == 0) ||
|
||||
!ext2fs_inode_has_valid_blocks(&inode))
|
||||
!ext2fs_inode_has_valid_blocks2(fs, &inode))
|
||||
goto next;
|
||||
|
||||
pb.ino = ino;
|
@ -12,6 +12,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -37,11 +38,11 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
|
||||
blk64_t first_block = fs->super->s_first_data_block;
|
||||
blk64_t last_block = ext2fs_blocks_count(fs->super)-1;
|
||||
blk64_t blk, b;
|
||||
int j;
|
||||
unsigned int j;
|
||||
|
||||
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
|
||||
|
||||
retval = ext2fs_allocate_block_bitmap(fs, "check_desc map", &bmap);
|
||||
retval = ext2fs_allocate_subcluster_bitmap(fs, "check_desc map", &bmap);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
@ -53,8 +54,6 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
|
||||
EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
|
||||
first_block = ext2fs_group_first_block2(fs, i);
|
||||
last_block = ext2fs_group_last_block2(fs, i);
|
||||
if (i == (fs->group_desc_count - 1))
|
||||
last_block = ext2fs_blocks_count(fs->super)-1;
|
||||
}
|
||||
|
||||
/*
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -73,6 +74,8 @@ errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
|
||||
int has_super;
|
||||
|
||||
group_block = ext2fs_group_first_block2(fs, group);
|
||||
if (group_block == 0 && fs->blocksize == 1024)
|
||||
group_block = 1; /* Deal with 1024 blocksize && bigalloc */
|
||||
|
||||
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
|
||||
old_desc_blocks = fs->super->s_first_meta_bg;
|
||||
@ -150,14 +153,7 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs,
|
||||
&ret_new_desc_blk2,
|
||||
&ret_used_blks);
|
||||
|
||||
if (group == fs->group_desc_count-1) {
|
||||
numblocks = (ext2fs_blocks_count(fs->super) -
|
||||
(blk64_t) fs->super->s_first_data_block) %
|
||||
(blk64_t) fs->super->s_blocks_per_group;
|
||||
if (!numblocks)
|
||||
numblocks = fs->super->s_blocks_per_group;
|
||||
} else
|
||||
numblocks = fs->super->s_blocks_per_group;
|
||||
numblocks = ext2fs_group_blocks_count(fs, group);
|
||||
|
||||
if (ret_super_blk)
|
||||
*ret_super_blk = (blk_t)ret_super_blk2;
|
||||
@ -265,6 +261,11 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
|
||||
}
|
||||
|
||||
errcode_t ext2fs_flush(ext2_filsys fs)
|
||||
{
|
||||
return ext2fs_flush2(fs, 0);
|
||||
}
|
||||
|
||||
errcode_t ext2fs_flush2(ext2_filsys fs, int flags)
|
||||
{
|
||||
dgrp_t i;
|
||||
errcode_t retval;
|
||||
@ -406,14 +407,16 @@ write_primary_superblock_only:
|
||||
ext2fs_swap_super(super_shadow);
|
||||
#endif
|
||||
|
||||
retval = io_channel_flush(fs->io);
|
||||
if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC))
|
||||
retval = io_channel_flush(fs->io);
|
||||
retval = write_primary_superblock(fs, super_shadow);
|
||||
if (retval)
|
||||
goto errout;
|
||||
|
||||
fs->flags &= ~EXT2_FLAG_DIRTY;
|
||||
|
||||
retval = io_channel_flush(fs->io);
|
||||
if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC))
|
||||
retval = io_channel_flush(fs->io);
|
||||
errout:
|
||||
fs->super->s_state = fs_state;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
@ -426,6 +429,11 @@ errout:
|
||||
}
|
||||
|
||||
errcode_t ext2fs_close(ext2_filsys fs)
|
||||
{
|
||||
return ext2fs_close2(fs, 0);
|
||||
}
|
||||
|
||||
errcode_t ext2fs_close2(ext2_filsys fs, int flags)
|
||||
{
|
||||
errcode_t retval;
|
||||
int meta_blks;
|
||||
@ -451,10 +459,15 @@ errcode_t ext2fs_close(ext2_filsys fs)
|
||||
fs->flags |= EXT2_FLAG_SUPER_ONLY | EXT2_FLAG_DIRTY;
|
||||
}
|
||||
if (fs->flags & EXT2_FLAG_DIRTY) {
|
||||
retval = ext2fs_flush(fs);
|
||||
retval = ext2fs_flush2(fs, flags);
|
||||
if (retval)
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = ext2fs_mmp_stop(fs);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
ext2fs_free(fs);
|
||||
return 0;
|
||||
}
|
603
portlibs/sources/libcustomext2fs/source/config.h
Normal file
603
portlibs/sources/libcustomext2fs/source/config.h
Normal file
@ -0,0 +1,603 @@
|
||||
/* lib/config.h. Generated from config.h.in by configure. */
|
||||
/* lib/config.h.in. Generated from configure.in by autoheader. */
|
||||
#ifndef __CONFIG_H_
|
||||
#define __CONFIG_H_
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* Define to 1 if debugging the blkid library */
|
||||
/* #undef CONFIG_BLKID_DEBUG */
|
||||
|
||||
/* Define to 1 to compile findfs */
|
||||
/* #undef CONFIG_BUILD_FINDFS 1 */
|
||||
|
||||
/* Define to 1 if debugging ext3/4 journal code */
|
||||
/* #undef CONFIG_JBD_DEBUG */
|
||||
|
||||
/* Define to 1 if the testio I/O manager should be enabled */
|
||||
/* #undef CONFIG_TESTIO_DEBUG 1 */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to 1 if ext2 compression enabled */
|
||||
/* #undef ENABLE_COMPRESSION */
|
||||
|
||||
/* Define to 1 if ext3/4 htree support enabled */
|
||||
#define ENABLE_HTREE 1
|
||||
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
#define ENABLE_NLS 1
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define to 1 if you have the <argz.h> header file. */
|
||||
#define HAVE_ARGZ_H 1
|
||||
|
||||
/* Define to 1 if you have the `asprintf' function. */
|
||||
#define HAVE_ASPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `backtrace' function. */
|
||||
/* #undef HAVE_BACKTRACE 1 */
|
||||
|
||||
/* Define to 1 if you have the `blkid_probe_get_topology' function. */
|
||||
/* #undef HAVE_BLKID_PROBE_GET_TOPOLOGY */
|
||||
|
||||
/* Define to 1 if you have the `chflags' function. */
|
||||
/* #undef HAVE_CHFLAGS */
|
||||
|
||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||
*/
|
||||
/* #undef HAVE_DCGETTEXT 1 */
|
||||
|
||||
/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you
|
||||
don't. */
|
||||
/* #undef HAVE_DECL_FEOF_UNLOCKED 1 */
|
||||
|
||||
/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if
|
||||
you don't. */
|
||||
/* #undef HAVE_DECL_FGETS_UNLOCKED 0 */
|
||||
|
||||
/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you
|
||||
don't. */
|
||||
/* #undef HAVE_DECL_GETC_UNLOCKED 1 */
|
||||
|
||||
/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you
|
||||
don't. */
|
||||
/* #undef HAVE_DECL__SNPRINTF 0 */
|
||||
|
||||
/* Define to 1 if you have the declaration of `_snwprintf', and to 0 if you
|
||||
don't. */
|
||||
/* #undef HAVE_DECL__SNWPRINTF 0 */
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file. */
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define to 1 if dlopen/libdl exists */
|
||||
/* #undef HAVE_DLOPEN 1 */
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
/* #undef HAVE_EXECINFO_H 1 */
|
||||
|
||||
/* Define to 1 if Ext2 ioctls present */
|
||||
/* #undef HAVE_EXT2_IOCTLS 1 */
|
||||
|
||||
/* Define to 1 if you have the `fallocate' function. */
|
||||
/* #undef HAVE_FALLOCATE 1 */
|
||||
|
||||
/* Define to 1 if you have the `fallocate64' function. */
|
||||
/* #undef HAVE_FALLOCATE64 1 */
|
||||
|
||||
/* Define to 1 if you have the `fchown' function. */
|
||||
/* #undef HAVE_FCHOWN 1 */
|
||||
|
||||
/* Define to 1 if you have the `fdatasync' function. */
|
||||
/* #undef HAVE_FDATASYNC 1 */
|
||||
|
||||
/* Define to 1 if you have the `fstat64' function. */
|
||||
/* #undef HAVE_FSTAT64 1 */
|
||||
|
||||
/* Define to 1 if you have the `ftruncate64' function. */
|
||||
/* #undef HAVE_FTRUNCATE64 1 */
|
||||
|
||||
/* Define to 1 if you have the `fwprintf' function. */
|
||||
/* #undef HAVE_FWPRINTF 1 */
|
||||
|
||||
/* Define to 1 if you have the `getcwd' function. */
|
||||
/* #undef HAVE_GETCWD 1 */
|
||||
|
||||
/* Define to 1 if you have the `getdtablesize' function. */
|
||||
/* #undef HAVE_GETDTABLESIZE 1 */
|
||||
|
||||
/* Define to 1 if you have the `getegid' function. */
|
||||
/* #undef HAVE_GETEGID 1 */
|
||||
|
||||
/* Define to 1 if you have the `geteuid' function. */
|
||||
/* #undef HAVE_GETEUID 1 */
|
||||
|
||||
/* Define to 1 if you have the `getgid' function. */
|
||||
/* #undef HAVE_GETGID 1 */
|
||||
|
||||
/* Define to 1 if you have the `getmntinfo' function. */
|
||||
/* #undef HAVE_GETMNTINFO */
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
/* #undef HAVE_GETOPT_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
/* #undef HAVE_GETPAGESIZE 1 */
|
||||
|
||||
/* Define to 1 if you have the `getrlimit' function. */
|
||||
/* #undef HAVE_GETRLIMIT 1 */
|
||||
|
||||
/* Define to 1 if you have the `getrusage' function. */
|
||||
/* #undef HAVE_GETRUSAGE 1 */
|
||||
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
/* #undef HAVE_GETTEXT 1 */
|
||||
|
||||
/* Define to 1 if you have the `getuid' function. */
|
||||
/* #undef HAVE_GETUID 1 */
|
||||
|
||||
/* Define if you have the iconv() function. */
|
||||
/* #undef HAVE_ICONV 1 */
|
||||
|
||||
/* Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>. */
|
||||
#define HAVE_INTMAX_T 1
|
||||
|
||||
/* Define to 1 if the system has the type `intptr_t'. */
|
||||
#define HAVE_INTPTR_T 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and
|
||||
declares uintmax_t. */
|
||||
#define HAVE_INTTYPES_H_WITH_UINTMAX 1
|
||||
|
||||
/* Define to 1 if you have the `jrand48' function. */
|
||||
/* #undef HAVE_JRAND48 1 */
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
/* #undef HAVE_LANGINFO_CODESET 1 */
|
||||
|
||||
/* Define if your <locale.h> file defines LC_MESSAGES. */
|
||||
#define HAVE_LC_MESSAGES 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/falloc.h> header file. */
|
||||
/* #undef HAVE_LINUX_FALLOC_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <linux/fd.h> header file. */
|
||||
/* #undef HAVE_LINUX_FD_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <linux/major.h> header file. */
|
||||
/* #undef HAVE_LINUX_MAJOR_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `llseek' function. */
|
||||
/* #undef HAVE_LLSEEK 1 */
|
||||
|
||||
/* Define to 1 if llseek declared in unistd.h */
|
||||
/* #undef HAVE_LLSEEK_PROTOTYPE */
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define if you have the 'long double' type. */
|
||||
#define HAVE_LONG_DOUBLE 1
|
||||
|
||||
/* Define if you have the 'long long' type. */
|
||||
#define HAVE_LONG_LONG 1
|
||||
|
||||
/* Define to 1 if you have the `lseek64' function. */
|
||||
/* #undef HAVE_LSEEK64 1 */
|
||||
|
||||
/* Define to 1 if lseek64 declared in unistd.h */
|
||||
#define HAVE_LSEEK64_PROTOTYPE 1
|
||||
|
||||
/* Define to 1 if you have the `mallinfo' function. */
|
||||
/* #undef HAVE_MALLINFO 1 */
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the `mbstowcs' function. */
|
||||
#define HAVE_MBSTOWCS 1
|
||||
|
||||
/* Define to 1 if you have the `memalign' function. */
|
||||
#define HAVE_MEMALIGN 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
/* #undef HAVE_MEMORY_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `mempcpy' function. */
|
||||
/* #undef HAVE_MEMPCPY 1 */
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
/* #undef HAVE_MMAP 1 */
|
||||
|
||||
/* Define to 1 if you have the <mntent.h> header file. */
|
||||
/* #undef HAVE_MNTENT_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `munmap' function. */
|
||||
/* #undef HAVE_MUNMAP 1 */
|
||||
|
||||
/* Define to 1 if you have the `nanosleep' function. */
|
||||
#define HAVE_NANOSLEEP 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
/* #undef HAVE_NETINET_IN_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <net/if_dl.h> header file. */
|
||||
/* #undef HAVE_NET_IF_DL_H */
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
/* #undef HAVE_NET_IF_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <nl_types.h> header file. */
|
||||
/* #undef HAVE_NL_TYPES_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `open64' function. */
|
||||
/* #undef HAVE_OPEN64 1 */
|
||||
|
||||
/* Define to 1 if optreset for getopt is present */
|
||||
/* #undef HAVE_OPTRESET */
|
||||
|
||||
/* Define to 1 if you have the `pathconf' function. */
|
||||
/* #undef HAVE_PATHCONF 1 */
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
/* #undef HAVE_PATHS_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `posix_fadvise' function. */
|
||||
/* #undef HAVE_POSIX_FADVISE 1 */
|
||||
|
||||
/* Define to 1 if you have the `posix_memalign' function. */
|
||||
/* #undef HAVE_POSIX_MEMALIGN 1 */
|
||||
|
||||
/* Define if your printf() function supports format strings with positions. */
|
||||
#define HAVE_POSIX_PRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `prctl' function. */
|
||||
/* #undef HAVE_PRCTL 1 */
|
||||
|
||||
/* Define to 1 if you have the `putenv' function. */
|
||||
/* #undef HAVE_PUTENV 1 */
|
||||
|
||||
/* Define to 1 if you have the `quotactl' function. */
|
||||
/* #undef HAVE_QUOTACTL 1 */
|
||||
|
||||
/* Define to 1 if dirent has d_reclen */
|
||||
/* #undef HAVE_RECLEN_DIRENT 1 */
|
||||
|
||||
/* Define to 1 if if struct sockaddr contains sa_len */
|
||||
/* #undef HAVE_SA_LEN */
|
||||
|
||||
/* Define to 1 if you have the <semaphore.h> header file. */
|
||||
/* #undef HAVE_SEMAPHORE_H 1 */
|
||||
|
||||
/* Define to 1 if sem_init() exists */
|
||||
/* #undef HAVE_SEM_INIT 1 */
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
/* #undef HAVE_SETENV 1 */
|
||||
|
||||
/* Define to 1 if you have the <setjmp.h> header file. */
|
||||
/* #undef HAVE_SETJMP_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#define HAVE_SETLOCALE 1
|
||||
|
||||
/* Define to 1 if you have the `setresgid' function. */
|
||||
/* #undef HAVE_SETRESGID 1 */
|
||||
|
||||
/* Define to 1 if you have the `setresuid' function. */
|
||||
/* #undef HAVE_SETRESUID 1*/
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `srandom' function. */
|
||||
/* #undef HAVE_SRANDOM 1 */
|
||||
|
||||
/* Define to 1 if struct stat has st_flags */
|
||||
/* #undef HAVE_STAT_FLAGS */
|
||||
|
||||
/* Define to 1 if you have the <stdarg.h> header file. */
|
||||
#define HAVE_STDARG_H 1
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define if <stdint.h> exists, doesn't clash with <sys/types.h>, and declares
|
||||
uintmax_t. */
|
||||
#define HAVE_STDINT_H_WITH_UINTMAX 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `stpcpy' function. */
|
||||
#define HAVE_STPCPY 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
/* #undef HAVE_STRINGS_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strnlen' function. */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
/* Define to 1 if you have the `strptime' function. */
|
||||
#define HAVE_STRPTIME 1
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#define HAVE_STRTOUL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
#define HAVE_STRTOULL 1
|
||||
|
||||
/* Define to 1 if you have the `sync_file_range' function. */
|
||||
/* #undef HAVE_SYNC_FILE_RANGE 1 */
|
||||
|
||||
/* Define to 1 if you have the `sysconf' function. */
|
||||
/* #undef HAVE_SYSCONF 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/disklabel.h> header file. */
|
||||
/* #undef HAVE_SYS_DISKLABEL_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/disk.h> header file. */
|
||||
/* #undef HAVE_SYS_DISK_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/file.h> header file. */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
/* #undef HAVE_SYS_IOCTL_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/mkdev.h> header file. */
|
||||
/* #undef HAVE_SYS_MKDEV_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
/* #undef HAVE_SYS_MMAN_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/mount.h> header file. */
|
||||
/* #undef HAVE_SYS_MOUNT_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/prctl.h> header file. */
|
||||
/* #undef HAVE_SYS_PRCTL_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/queue.h> header file. */
|
||||
#define HAVE_SYS_QUEUE_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/quota.h> header file. */
|
||||
/* #undef HAVE_SYS_QUOTA_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
/* #undef HAVE_SYS_SELECT_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKET_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKIO_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/syscall.h> header file. */
|
||||
/* #undef HAVE_SYS_SYSCALL_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
|
||||
/* #undef HAVE_SYS_SYSMACROS_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/un.h> header file. */
|
||||
/* #undef HAVE_SYS_UN_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <termio.h> header file. */
|
||||
/* #undef HAVE_TERMIO_H 1 */
|
||||
|
||||
/* Define to 1 if you have the `tsearch' function. */
|
||||
/* #undef HAVE_TSEARCH 1 */
|
||||
|
||||
/* Define to 1 if ssize_t declared */
|
||||
#define HAVE_TYPE_SSIZE_T 1
|
||||
|
||||
/* Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>. */
|
||||
#define HAVE_UINTMAX_T 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define if you have the 'unsigned long long' type. */
|
||||
#define HAVE_UNSIGNED_LONG_LONG 1
|
||||
|
||||
/* Define to 1 if you have the `usleep' function. */
|
||||
#define HAVE_USLEEP 1
|
||||
|
||||
/* Define to 1 if you have the `utime' function. */
|
||||
/* #undef HAVE_UTIME 1 */
|
||||
|
||||
/* Define to 1 if you have the <utime.h> header file. */
|
||||
#define HAVE_UTIME_H 1
|
||||
|
||||
/* Define to 1 if you have the `valloc' function. */
|
||||
/* #undef HAVE_VALLOC 1 */
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#define HAVE_VPRINTF 1
|
||||
|
||||
/* Define if you have the 'wchar_t' type. */
|
||||
#define HAVE_WCHAR_T 1
|
||||
|
||||
/* Define to 1 if you have the `wcslen' function. */
|
||||
#define HAVE_WCSLEN 1
|
||||
|
||||
/* Define if you have the 'wint_t' type. */
|
||||
#define HAVE_WINT_T 1
|
||||
|
||||
/* Define to 1 if you have the `__argz_count' function. */
|
||||
/* #undef HAVE___ARGZ_COUNT 1 */
|
||||
|
||||
/* Define to 1 if you have the `__argz_next' function. */
|
||||
/* #undef HAVE___ARGZ_NEXT 1 */
|
||||
|
||||
/* Define to 1 if you have the `__argz_stringify' function. */
|
||||
/* #undef HAVE___ARGZ_STRINGIFY 1 */
|
||||
|
||||
/* Define to 1 if you have the `__fsetlocking' function. */
|
||||
/* #undef HAVE___FSETLOCKING 1 */
|
||||
|
||||
/* Define to 1 if you have the `__secure_getenv' function. */
|
||||
/* #undef HAVE___SECURE_GETENV 1 */
|
||||
|
||||
/* Define as const if the declaration of iconv() needs const. */
|
||||
/* #undef ICONV_CONST */
|
||||
|
||||
/* Define if integer division by zero raises signal SIGFPE. */
|
||||
/* #undef INTDIV0_RAISES_SIGFPE 1 */
|
||||
|
||||
/* package name for gettext */
|
||||
#define PACKAGE "e2fsprogs"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME ""
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING ""
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME ""
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION ""
|
||||
|
||||
/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
|
||||
/* #undef PRI_MACROS_BROKEN */
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* Define as the maximum value of type 'size_t', if the system doesn't define
|
||||
it. */
|
||||
/* #undef SIZE_MAX */
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* If the compiler supports a TLS storage class define it to that here */
|
||||
/* #undef TLS __thread */
|
||||
|
||||
/* Define to 1 to build uuidd */
|
||||
/* #undef USE_UUIDD 1 */
|
||||
|
||||
/* version for gettext */
|
||||
#define VERSION "0.14.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#define WORDS_BIGENDIAN 1
|
||||
|
||||
/* Define to 1 if Apple Darwin libintl workaround is needed */
|
||||
/* #undef _INTL_REDIRECT_MACROS */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
/* #undef inline */
|
||||
#endif
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define as the type of the result of subtracting two pointers, if the system
|
||||
doesn't define it. */
|
||||
/* #undef ptrdiff_t */
|
||||
|
||||
/* Define to empty if the C compiler doesn't support this keyword. */
|
||||
/* #undef signed */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to unsigned long or unsigned long long if <stdint.h> and
|
||||
<inttypes.h> don't define. */
|
||||
/* #undef uintmax_t */
|
||||
|
||||
#endif
|
@ -5,6 +5,7 @@
|
||||
* Version 2. See the file COPYING for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
1144
portlibs/sources/libcustomext2fs/source/crc32c.c
Normal file
1144
portlibs/sources/libcustomext2fs/source/crc32c.c
Normal file
File diff suppressed because it is too large
Load Diff
51
portlibs/sources/libcustomext2fs/source/crc32c_defs.h
Normal file
51
portlibs/sources/libcustomext2fs/source/crc32c_defs.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This is the CRC32c polynomial, as outlined by Castagnoli.
|
||||
* x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+
|
||||
* x^8+x^6+x^0
|
||||
*/
|
||||
#define CRCPOLY_LE 0x82F63B78
|
||||
#define CRCPOLY_BE 0x1EDC6F41
|
||||
|
||||
/* How many bits at a time to use. Valid values are 1, 2, 4, 8, 32 and 64. */
|
||||
/* For less performance-sensitive, use 4 */
|
||||
#ifndef CRC_LE_BITS
|
||||
# define CRC_LE_BITS 64
|
||||
#endif
|
||||
#ifndef CRC_BE_BITS
|
||||
# define CRC_BE_BITS 64
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Little-endian CRC computation. Used with serial bit streams sent
|
||||
* lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
|
||||
*/
|
||||
#if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \
|
||||
CRC_LE_BITS & CRC_LE_BITS-1
|
||||
# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Big-endian CRC computation. Used with serial bit streams sent
|
||||
* msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
|
||||
*/
|
||||
#if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \
|
||||
CRC_BE_BITS & CRC_BE_BITS-1
|
||||
# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"
|
||||
#endif
|
||||
|
||||
|
||||
#define ___constant_swab32(x) \
|
||||
((uint32_t)( \
|
||||
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
|
||||
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
|
||||
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
|
||||
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
|
||||
|
||||
|
||||
#if (__GNUC__ >= 3)
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
1065
portlibs/sources/libcustomext2fs/source/crc32c_table.h
Normal file
1065
portlibs/sources/libcustomext2fs/source/crc32c_table.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
@ -46,7 +47,7 @@ STATIC __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
|
||||
desc = ext2fs_group_desc(fs, fs->group_desc, group);
|
||||
|
||||
if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
|
||||
int offset = offsetof(struct ext2_group_desc, bg_checksum);
|
||||
size_t offset = offsetof(struct ext2_group_desc, bg_checksum);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
struct ext4_group_desc swabdesc;
|
||||
@ -127,10 +128,10 @@ errcode_t ext2fs_set_gdt_csum(ext2_filsys fs)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < fs->group_desc_count; i++) {
|
||||
unsigned int old_csum = ext2fs_bg_checksum(fs, i);
|
||||
int old_unused = ext2fs_bg_itable_unused(fs, i);
|
||||
unsigned int old_flags = ext2fs_bg_flags(fs, i);
|
||||
int old_free_inodes_count = ext2fs_bg_free_inodes_count(fs, i);
|
||||
__u32 old_csum = ext2fs_bg_checksum(fs, i);
|
||||
__u32 old_unused = ext2fs_bg_itable_unused(fs, i);
|
||||
__u32 old_flags = ext2fs_bg_flags(fs, i);
|
||||
__u32 old_free_inodes_count = ext2fs_bg_free_inodes_count(fs, i);
|
||||
|
||||
if (old_free_inodes_count == sb->s_inodes_per_group) {
|
||||
ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -60,7 +61,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size,
|
||||
struct ext2_db_entry2 *list,
|
||||
ext2_dblist *ret_dblist)
|
||||
{
|
||||
ext2_dblist dblist;
|
||||
ext2_dblist dblist = 0;
|
||||
errcode_t retval;
|
||||
ext2_ino_t num_dirs;
|
||||
size_t len;
|
||||
@ -73,7 +74,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size,
|
||||
|
||||
retval = ext2fs_get_mem(sizeof(struct ext2_struct_dblist), &dblist);
|
||||
if (retval)
|
||||
return retval;
|
||||
goto cleanup;
|
||||
memset(dblist, 0, sizeof(struct ext2_struct_dblist));
|
||||
|
||||
dblist->magic = EXT2_ET_MAGIC_DBLIST;
|
||||
@ -172,7 +173,7 @@ errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
|
||||
sizeof(struct ext2_db_entry2),
|
||||
&dblist->list);
|
||||
if (retval) {
|
||||
dblist->size -= 100;
|
||||
dblist->size = old_size / sizeof(struct ext2_db_entry2);
|
||||
return retval;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
@ -11,6 +11,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -217,11 +218,13 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len,
|
||||
switch (version) {
|
||||
case EXT2_HASH_LEGACY_UNSIGNED:
|
||||
unsigned_flag++;
|
||||
/* fallthrough */
|
||||
case EXT2_HASH_LEGACY:
|
||||
hash = dx_hack_hash(name, len, unsigned_flag);
|
||||
break;
|
||||
case EXT2_HASH_HALF_MD4_UNSIGNED:
|
||||
unsigned_flag++;
|
||||
/* fallthrough */
|
||||
case EXT2_HASH_HALF_MD4:
|
||||
p = name;
|
||||
while (len > 0) {
|
||||
@ -235,6 +238,7 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len,
|
||||
break;
|
||||
case EXT2_HASH_TEA_UNSIGNED:
|
||||
unsigned_flag++;
|
||||
/* fallthrough */
|
||||
case EXT2_HASH_TEA:
|
||||
p = name;
|
||||
while (len > 0) {
|
@ -52,12 +52,12 @@ CACHE* cache_constructor (unsigned int numberOfPages, unsigned int sectorsPerPag
|
||||
|
||||
if(numberOfPages==0 || sectorsPerPage==0) return NULL;
|
||||
|
||||
if (numberOfPages < 4) {
|
||||
numberOfPages = 4;
|
||||
if (numberOfPages < 32) {
|
||||
numberOfPages = 32;
|
||||
}
|
||||
|
||||
if (sectorsPerPage < 32) {
|
||||
sectorsPerPage = 32;
|
||||
if (sectorsPerPage < 16) {
|
||||
sectorsPerPage = 16;
|
||||
}
|
||||
|
||||
cache = (CACHE*) mem_alloc (sizeof(CACHE));
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
@ -12,6 +12,14 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
/* Image types */
|
||||
#define E2IMAGE_RAW 1
|
||||
#define E2IMAGE_QCOW2 2
|
||||
|
||||
/* Image flags */
|
||||
#define E2IMAGE_INSTALL_FLAG 1
|
||||
#define E2IMAGE_SCRAMBLE_FLAG 2
|
||||
#define E2IMAGE_IS_QCOW2_FLAG 3
|
||||
|
||||
struct ext2_image_hdr {
|
||||
__u32 magic_number; /* This must be EXT2_ET_MAGIC_E2IMAGE */
|
||||
@ -36,16 +44,3 @@ struct ext2_image_hdr {
|
||||
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
|
||||
__u32 offset_reserved[8];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -21,6 +22,7 @@
|
||||
struct expand_dir_struct {
|
||||
int done;
|
||||
int newblocks;
|
||||
blk64_t goal;
|
||||
errcode_t err;
|
||||
};
|
||||
|
||||
@ -33,18 +35,25 @@ static int expand_dir_proc(ext2_filsys fs,
|
||||
{
|
||||
struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
|
||||
blk64_t new_blk;
|
||||
static blk64_t last_blk = 0;
|
||||
char *block;
|
||||
errcode_t retval;
|
||||
|
||||
if (*blocknr) {
|
||||
last_blk = *blocknr;
|
||||
if (blockcnt >= 0)
|
||||
es->goal = *blocknr;
|
||||
return 0;
|
||||
}
|
||||
retval = ext2fs_new_block2(fs, last_blk, 0, &new_blk);
|
||||
if (retval) {
|
||||
es->err = retval;
|
||||
return BLOCK_ABORT;
|
||||
if (blockcnt &&
|
||||
(EXT2FS_B2C(fs, es->goal) == EXT2FS_B2C(fs, es->goal+1)))
|
||||
new_blk = es->goal+1;
|
||||
else {
|
||||
es->goal &= ~EXT2FS_CLUSTER_MASK(fs);
|
||||
retval = ext2fs_new_block2(fs, es->goal, 0, &new_blk);
|
||||
if (retval) {
|
||||
es->err = retval;
|
||||
return BLOCK_ABORT;
|
||||
}
|
||||
es->newblocks++;
|
||||
}
|
||||
if (blockcnt > 0) {
|
||||
retval = ext2fs_new_dir_block(fs, 0, 0, &block);
|
||||
@ -63,6 +72,8 @@ static int expand_dir_proc(ext2_filsys fs,
|
||||
memset(block, 0, fs->blocksize);
|
||||
retval = io_channel_write_blk64(fs->io, new_blk, 1, block);
|
||||
}
|
||||
if (blockcnt >= 0)
|
||||
es->goal = new_blk;
|
||||
if (retval) {
|
||||
es->err = retval;
|
||||
return BLOCK_ABORT;
|
||||
@ -70,7 +81,6 @@ static int expand_dir_proc(ext2_filsys fs,
|
||||
ext2fs_free_mem(&block);
|
||||
*blocknr = new_blk;
|
||||
ext2fs_block_alloc_stats2(fs, new_blk, +1);
|
||||
es->newblocks++;
|
||||
|
||||
if (es->done)
|
||||
return (BLOCK_CHANGED | BLOCK_ABORT);
|
||||
@ -98,6 +108,7 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir)
|
||||
|
||||
es.done = 0;
|
||||
es.err = 0;
|
||||
es.goal = 0;
|
||||
es.newblocks = 0;
|
||||
|
||||
retval = ext2fs_block_iterate3(fs, dir, BLOCK_FLAG_APPEND,
|
@ -89,7 +89,7 @@ bool ext2Mount(const char *name, const DISC_INTERFACE *interface, sec_t startSec
|
||||
io_chan->private_data = fd;
|
||||
io_chan->flags = flags;
|
||||
|
||||
retval = ext2fs_open2(io_chan->name, 0, io_chan->flags, 0, 0, &io_chan, &fs);
|
||||
retval = ext2fs_open2(io_chan->name, 0, io_chan->flags, 0, 0, io_chan, &fs);
|
||||
if(retval)
|
||||
{
|
||||
ext2_log_trace("error mounting %i\n", (int) retval);
|
||||
@ -223,7 +223,7 @@ int ext2FindPartitions (const DISC_INTERFACE *interface, sec_t **out_partitions)
|
||||
int i;
|
||||
|
||||
union {
|
||||
u8 buffer[512];
|
||||
u8 buffer[MAX_SECTOR_SIZE];
|
||||
MASTER_BOOT_RECORD mbr;
|
||||
EXTENDED_BOOT_RECORD ebr;
|
||||
} sector;
|
||||
@ -249,27 +249,30 @@ int ext2FindPartitions (const DISC_INTERFACE *interface, sec_t **out_partitions)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ext2_super_block * super = (struct ext2_super_block *) malloc(SUPERBLOCK_SIZE); //1024 bytes
|
||||
if(!super)
|
||||
// Allocate 4 x max sector size in case of 4096 sector size
|
||||
u8 *buffer = (u8 *) mem_alloc(4 * MAX_SECTOR_SIZE);
|
||||
if(!buffer)
|
||||
{
|
||||
ext2_log_trace("no memory for superblock");
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
// Super is always at offset SUPERBLOCK_OFFSET
|
||||
struct ext2_super_block * super = (struct ext2_super_block *) (buffer + SUPERBLOCK_OFFSET); //1024 bytes
|
||||
|
||||
partitions = (sec_t *) malloc(sizeof(sec_t));
|
||||
if(!partitions)
|
||||
{
|
||||
ext2_log_trace("no memory for partitions");
|
||||
errno = ENOMEM;
|
||||
mem_free(super);
|
||||
mem_free(buffer);
|
||||
return -1;
|
||||
}
|
||||
// Read the first sector on the device
|
||||
if (!interface->readSectors(0, 1, §or.buffer)) {
|
||||
errno = EIO;
|
||||
mem_free(partitions);
|
||||
mem_free(super);
|
||||
mem_free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -295,7 +298,7 @@ int ext2FindPartitions (const DISC_INTERFACE *interface, sec_t **out_partitions)
|
||||
case PARTITION_TYPE_LINUX:
|
||||
|
||||
// Read and validate the EXT partition
|
||||
if (interface->readSectors(part_lba+SUPERBLOCK_OFFSET/BYTES_PER_SECTOR, SUPERBLOCK_SIZE/BYTES_PER_SECTOR, super))
|
||||
if (interface->readSectors(part_lba, 4, buffer))
|
||||
{
|
||||
if (ext2fs_le16_to_cpu(super->s_magic) == EXT2_SUPER_MAGIC)
|
||||
{
|
||||
@ -334,7 +337,7 @@ int ext2FindPartitions (const DISC_INTERFACE *interface, sec_t **out_partitions)
|
||||
next_erb_lba = ext2fs_le32_to_cpu(sector.ebr.next_ebr.lba_start);
|
||||
|
||||
// Check if this partition has a valid EXT boot record
|
||||
if (interface->readSectors(part_lba+SUPERBLOCK_OFFSET/BYTES_PER_SECTOR, SUPERBLOCK_SIZE/BYTES_PER_SECTOR, super))
|
||||
if (interface->readSectors(part_lba, 4, buffer))
|
||||
{
|
||||
if (ext2fs_le16_to_cpu(super->s_magic) == EXT2_SUPER_MAGIC)
|
||||
{
|
||||
@ -361,7 +364,7 @@ int ext2FindPartitions (const DISC_INTERFACE *interface, sec_t **out_partitions)
|
||||
{
|
||||
// Check if this partition has a valid EXT boot record anyway,
|
||||
// it might be misrepresented due to a lazy partition editor
|
||||
if (interface->readSectors(part_lba+SUPERBLOCK_OFFSET/BYTES_PER_SECTOR, SUPERBLOCK_SIZE/BYTES_PER_SECTOR, super))
|
||||
if (interface->readSectors(part_lba, 4, buffer))
|
||||
{
|
||||
if (ext2fs_le16_to_cpu(super->s_magic) == EXT2_SUPER_MAGIC)
|
||||
{
|
||||
@ -386,7 +389,7 @@ int ext2FindPartitions (const DISC_INTERFACE *interface, sec_t **out_partitions)
|
||||
// As a last-ditched effort, search the first 64 sectors of the device for stray EXT partitions
|
||||
for (i = 1; i < 64; i++)
|
||||
{
|
||||
if (interface->readSectors(i+SUPERBLOCK_OFFSET/BYTES_PER_SECTOR, SUPERBLOCK_SIZE/BYTES_PER_SECTOR, super))
|
||||
if (interface->readSectors(i, 4, buffer))
|
||||
{
|
||||
if (ext2fs_le16_to_cpu(super->s_magic) == EXT2_SUPER_MAGIC)
|
||||
{
|
||||
@ -412,8 +415,8 @@ cleanup:
|
||||
|
||||
if(partitions && partition_count == 0)
|
||||
mem_free(partitions);
|
||||
if(super)
|
||||
mem_free(super);
|
||||
if(buffer)
|
||||
mem_free(buffer);
|
||||
|
||||
return ret;
|
||||
}
|
199
portlibs/sources/libcustomext2fs/source/ext2_err.c
Normal file
199
portlibs/sources/libcustomext2fs/source/ext2_err.c
Normal file
@ -0,0 +1,199 @@
|
||||
/*
|
||||
* ext2_err.c:
|
||||
* This file is automatically generated; please do not edit it.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define N_(a) a
|
||||
|
||||
static const char * const text[] = {
|
||||
N_( "EXT2FS Library version 1.42"),
|
||||
N_( "Wrong magic number for ext2_filsys structure"),
|
||||
N_( "Wrong magic number for badblocks_list structure"),
|
||||
N_( "Wrong magic number for badblocks_iterate structure"),
|
||||
N_( "Wrong magic number for inode_scan structure"),
|
||||
N_( "Wrong magic number for io_channel structure"),
|
||||
N_( "Wrong magic number for unix io_channel structure"),
|
||||
N_( "Wrong magic number for io_manager structure"),
|
||||
N_( "Wrong magic number for block_bitmap structure"),
|
||||
N_( "Wrong magic number for inode_bitmap structure"),
|
||||
N_( "Wrong magic number for generic_bitmap structure"),
|
||||
N_( "Wrong magic number for test io_channel structure"),
|
||||
N_( "Wrong magic number for directory block list structure"),
|
||||
N_( "Wrong magic number for icount structure"),
|
||||
N_( "Wrong magic number for Powerquest io_channel structure"),
|
||||
N_( "Wrong magic number for ext2 file structure"),
|
||||
N_( "Wrong magic number for Ext2 Image Header"),
|
||||
N_( "Wrong magic number for inode io_channel structure"),
|
||||
N_( "Wrong magic number for ext4 extent handle"),
|
||||
N_( "Bad magic number in super-block"),
|
||||
N_( "Filesystem revision too high"),
|
||||
N_( "Attempt to write to filesystem opened read-only"),
|
||||
N_( "Can't read group descriptors"),
|
||||
N_( "Can't write group descriptors"),
|
||||
N_( "Corrupt group descriptor: bad block for block bitmap"),
|
||||
N_( "Corrupt group descriptor: bad block for inode bitmap"),
|
||||
N_( "Corrupt group descriptor: bad block for inode table"),
|
||||
N_( "Can't write an inode bitmap"),
|
||||
N_( "Can't read an inode bitmap"),
|
||||
N_( "Can't write an block bitmap"),
|
||||
N_( "Can't read an block bitmap"),
|
||||
N_( "Can't write an inode table"),
|
||||
N_( "Can't read an inode table"),
|
||||
N_( "Can't read next inode"),
|
||||
N_( "Filesystem has unexpected block size"),
|
||||
N_( "EXT2 directory corrupted"),
|
||||
N_( "Attempt to read block from filesystem resulted in short read"),
|
||||
N_( "Attempt to write block to filesystem resulted in short write"),
|
||||
N_( "No free space in the directory"),
|
||||
N_( "Inode bitmap not loaded"),
|
||||
N_( "Block bitmap not loaded"),
|
||||
N_( "Illegal inode number"),
|
||||
N_( "Illegal block number"),
|
||||
N_( "Internal error in ext2fs_expand_dir"),
|
||||
N_( "Not enough space to build proposed filesystem"),
|
||||
N_( "Illegal block number passed to ext2fs_mark_block_bitmap"),
|
||||
N_( "Illegal block number passed to ext2fs_unmark_block_bitmap"),
|
||||
N_( "Illegal block number passed to ext2fs_test_block_bitmap"),
|
||||
N_( "Illegal inode number passed to ext2fs_mark_inode_bitmap"),
|
||||
N_( "Illegal inode number passed to ext2fs_unmark_inode_bitmap"),
|
||||
N_( "Illegal inode number passed to ext2fs_test_inode_bitmap"),
|
||||
N_( "Attempt to fudge end of block bitmap past the real end"),
|
||||
N_( "Attempt to fudge end of inode bitmap past the real end"),
|
||||
N_( "Illegal indirect block found" ),
|
||||
N_( "Illegal doubly indirect block found" ),
|
||||
N_( "Illegal triply indirect block found" ),
|
||||
N_( "Block bitmaps are not the same"),
|
||||
N_( "Inode bitmaps are not the same"),
|
||||
N_( "Illegal or malformed device name"),
|
||||
N_( "A block group is missing an inode table"),
|
||||
N_( "The ext2 superblock is corrupt"),
|
||||
N_( "Illegal generic bit number passed to ext2fs_mark_generic_bitmap"),
|
||||
N_( "Illegal generic bit number passed to ext2fs_unmark_generic_bitmap"),
|
||||
N_( "Illegal generic bit number passed to ext2fs_test_generic_bitmap"),
|
||||
N_( "Too many symbolic links encountered."),
|
||||
N_( "The callback function will not handle this case"),
|
||||
N_( "The inode is from a bad block in the inode table"),
|
||||
N_( "Filesystem has unsupported feature(s)"),
|
||||
N_( "Filesystem has unsupported read-only feature(s)"),
|
||||
N_( "IO Channel failed to seek on read or write"),
|
||||
N_( "Memory allocation failed"),
|
||||
N_( "Invalid argument passed to ext2 library"),
|
||||
N_( "Could not allocate block in ext2 filesystem"),
|
||||
N_( "Could not allocate inode in ext2 filesystem"),
|
||||
N_( "Ext2 inode is not a directory"),
|
||||
N_( "Too many references in table"),
|
||||
N_( "File not found by ext2_lookup"),
|
||||
N_( "File open read-only"),
|
||||
N_( "Ext2 directory block not found"),
|
||||
N_( "Ext2 directory already exists"),
|
||||
N_( "Unimplemented ext2 library function"),
|
||||
N_( "User cancel requested"),
|
||||
N_( "Ext2 file too big"),
|
||||
N_( "Supplied journal device not a block device"),
|
||||
N_( "Journal superblock not found"),
|
||||
N_( "Journal must be at least 1024 blocks"),
|
||||
N_( "Unsupported journal version"),
|
||||
N_( "Error loading external journal"),
|
||||
N_( "Journal not found"),
|
||||
N_( "Directory hash unsupported"),
|
||||
N_( "Illegal extended attribute block number"),
|
||||
N_( "Cannot create filesystem with requested number of inodes"),
|
||||
N_( "E2image snapshot not in use"),
|
||||
N_( "Too many reserved group descriptor blocks"),
|
||||
N_( "Resize inode is corrupt"),
|
||||
N_( "Tried to set block bmap with missing indirect block"),
|
||||
N_( "TDB: Success"),
|
||||
N_( "TDB: Corrupt database"),
|
||||
N_( "TDB: IO Error"),
|
||||
N_( "TDB: Locking error"),
|
||||
N_( "TDB: Out of memory"),
|
||||
N_( "TDB: Record exists"),
|
||||
N_( "TDB: Lock exists on other keys"),
|
||||
N_( "TDB: Invalid parameter"),
|
||||
N_( "TDB: Record does not exist"),
|
||||
N_( "TDB: Write not permitted"),
|
||||
N_( "Ext2fs directory block list is empty"),
|
||||
N_( "Attempt to modify a block mapping via a read-only block iterator"),
|
||||
N_( "Wrong magic number for ext4 extent saved path"),
|
||||
N_( "Wrong magic number for 64-bit generic bitmap"),
|
||||
N_( "Wrong magic number for 64-bit block bitmap"),
|
||||
N_( "Wrong magic number for 64-bit inode bitmap"),
|
||||
N_( "Wrong magic number --- RESERVED_13"),
|
||||
N_( "Wrong magic number --- RESERVED_14"),
|
||||
N_( "Wrong magic number --- RESERVED_15"),
|
||||
N_( "Wrong magic number --- RESERVED_16"),
|
||||
N_( "Wrong magic number --- RESERVED_17"),
|
||||
N_( "Wrong magic number --- RESERVED_18"),
|
||||
N_( "Wrong magic number --- RESERVED_19"),
|
||||
N_( "Corrupt extent header"),
|
||||
N_( "Corrupt extent index"),
|
||||
N_( "Corrupt extent"),
|
||||
N_( "No free space in extent map"),
|
||||
N_( "Inode does not use extents"),
|
||||
N_( "No 'next' extent"),
|
||||
N_( "No 'previous' extent"),
|
||||
N_( "No 'up' extent"),
|
||||
N_( "No 'down' extent"),
|
||||
N_( "No current node"),
|
||||
N_( "Ext2fs operation not supported"),
|
||||
N_( "No room to insert extent in node"),
|
||||
N_( "Splitting would result in empty node"),
|
||||
N_( "Extent not found"),
|
||||
N_( "Operation not supported for inodes containing extents"),
|
||||
N_( "Extent length is invalid"),
|
||||
N_( "I/O Channel does not support 64-bit block numbers"),
|
||||
N_( "Can't check if filesystem is mounted due to missing mtab file"),
|
||||
N_( "Filesystem too large to use legacy bitmaps"),
|
||||
N_( "MMP: invalid magic number"),
|
||||
N_( "MMP: device currently active"),
|
||||
N_( "MMP: fsck being run"),
|
||||
N_( "MMP: block number beyond filesystem range"),
|
||||
N_( "MMP: undergoing an unknown operation"),
|
||||
N_( "MMP: filesystem still in use"),
|
||||
N_( "MMP: open with O_DIRECT failed"),
|
||||
0
|
||||
};
|
||||
|
||||
struct error_table {
|
||||
char const * const * msgs;
|
||||
long base;
|
||||
int n_msgs;
|
||||
};
|
||||
struct et_list {
|
||||
struct et_list *next;
|
||||
const struct error_table * table;
|
||||
};
|
||||
extern struct et_list *_et_list;
|
||||
|
||||
const struct error_table et_ext2_error_table = { text, 2133571328L, 145 };
|
||||
|
||||
static struct et_list link = { 0, 0 };
|
||||
|
||||
void initialize_ext2_error_table_r(struct et_list **list);
|
||||
void initialize_ext2_error_table(void);
|
||||
|
||||
void initialize_ext2_error_table(void) {
|
||||
initialize_ext2_error_table_r(&_et_list);
|
||||
}
|
||||
|
||||
/* For Heimdal compatibility */
|
||||
void initialize_ext2_error_table_r(struct et_list **list)
|
||||
{
|
||||
struct et_list *et, **end;
|
||||
|
||||
for (end = list, et = *list; et; end = &et->next, et = et->next)
|
||||
if (et->table->msgs == text)
|
||||
return;
|
||||
et = malloc(sizeof(struct et_list));
|
||||
if (et == 0) {
|
||||
if (!link.table)
|
||||
et = &link;
|
||||
else
|
||||
return;
|
||||
}
|
||||
et->table = &et_ext2_error_table;
|
||||
et->next = 0;
|
||||
*end = et;
|
||||
}
|
169
portlibs/sources/libcustomext2fs/source/ext2_err.h
Normal file
169
portlibs/sources/libcustomext2fs/source/ext2_err.h
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* ext2_err.h:
|
||||
* This file is automatically generated; please do not edit it.
|
||||
*/
|
||||
#ifndef EXT2_ERR_H_
|
||||
#define EXT2_ERR_H_
|
||||
|
||||
#include "com_err.h"
|
||||
|
||||
#define EXT2_ET_OK (0)
|
||||
#define EXT2_ET_BASE (2133571328L)
|
||||
#define EXT2_ET_MAGIC_EXT2FS_FILSYS (2133571329L)
|
||||
#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L)
|
||||
#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L)
|
||||
#define EXT2_ET_MAGIC_INODE_SCAN (2133571332L)
|
||||
#define EXT2_ET_MAGIC_IO_CHANNEL (2133571333L)
|
||||
#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL (2133571334L)
|
||||
#define EXT2_ET_MAGIC_IO_MANAGER (2133571335L)
|
||||
#define EXT2_ET_MAGIC_BLOCK_BITMAP (2133571336L)
|
||||
#define EXT2_ET_MAGIC_INODE_BITMAP (2133571337L)
|
||||
#define EXT2_ET_MAGIC_GENERIC_BITMAP (2133571338L)
|
||||
#define EXT2_ET_MAGIC_TEST_IO_CHANNEL (2133571339L)
|
||||
#define EXT2_ET_MAGIC_DBLIST (2133571340L)
|
||||
#define EXT2_ET_MAGIC_ICOUNT (2133571341L)
|
||||
#define EXT2_ET_MAGIC_PQ_IO_CHANNEL (2133571342L)
|
||||
#define EXT2_ET_MAGIC_EXT2_FILE (2133571343L)
|
||||
#define EXT2_ET_MAGIC_E2IMAGE (2133571344L)
|
||||
#define EXT2_ET_MAGIC_INODE_IO_CHANNEL (2133571345L)
|
||||
#define EXT2_ET_MAGIC_EXTENT_HANDLE (2133571346L)
|
||||
#define EXT2_ET_BAD_MAGIC (2133571347L)
|
||||
#define EXT2_ET_REV_TOO_HIGH (2133571348L)
|
||||
#define EXT2_ET_RO_FILSYS (2133571349L)
|
||||
#define EXT2_ET_GDESC_READ (2133571350L)
|
||||
#define EXT2_ET_GDESC_WRITE (2133571351L)
|
||||
#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571352L)
|
||||
#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571353L)
|
||||
#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571354L)
|
||||
#define EXT2_ET_INODE_BITMAP_WRITE (2133571355L)
|
||||
#define EXT2_ET_INODE_BITMAP_READ (2133571356L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571357L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_READ (2133571358L)
|
||||
#define EXT2_ET_INODE_TABLE_WRITE (2133571359L)
|
||||
#define EXT2_ET_INODE_TABLE_READ (2133571360L)
|
||||
#define EXT2_ET_NEXT_INODE_READ (2133571361L)
|
||||
#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571362L)
|
||||
#define EXT2_ET_DIR_CORRUPTED (2133571363L)
|
||||
#define EXT2_ET_SHORT_READ (2133571364L)
|
||||
#define EXT2_ET_SHORT_WRITE (2133571365L)
|
||||
#define EXT2_ET_DIR_NO_SPACE (2133571366L)
|
||||
#define EXT2_ET_NO_INODE_BITMAP (2133571367L)
|
||||
#define EXT2_ET_NO_BLOCK_BITMAP (2133571368L)
|
||||
#define EXT2_ET_BAD_INODE_NUM (2133571369L)
|
||||
#define EXT2_ET_BAD_BLOCK_NUM (2133571370L)
|
||||
#define EXT2_ET_EXPAND_DIR_ERR (2133571371L)
|
||||
#define EXT2_ET_TOOSMALL (2133571372L)
|
||||
#define EXT2_ET_BAD_BLOCK_MARK (2133571373L)
|
||||
#define EXT2_ET_BAD_BLOCK_UNMARK (2133571374L)
|
||||
#define EXT2_ET_BAD_BLOCK_TEST (2133571375L)
|
||||
#define EXT2_ET_BAD_INODE_MARK (2133571376L)
|
||||
#define EXT2_ET_BAD_INODE_UNMARK (2133571377L)
|
||||
#define EXT2_ET_BAD_INODE_TEST (2133571378L)
|
||||
#define EXT2_ET_FUDGE_BLOCK_BITMAP_END (2133571379L)
|
||||
#define EXT2_ET_FUDGE_INODE_BITMAP_END (2133571380L)
|
||||
#define EXT2_ET_BAD_IND_BLOCK (2133571381L)
|
||||
#define EXT2_ET_BAD_DIND_BLOCK (2133571382L)
|
||||
#define EXT2_ET_BAD_TIND_BLOCK (2133571383L)
|
||||
#define EXT2_ET_NEQ_BLOCK_BITMAP (2133571384L)
|
||||
#define EXT2_ET_NEQ_INODE_BITMAP (2133571385L)
|
||||
#define EXT2_ET_BAD_DEVICE_NAME (2133571386L)
|
||||
#define EXT2_ET_MISSING_INODE_TABLE (2133571387L)
|
||||
#define EXT2_ET_CORRUPT_SUPERBLOCK (2133571388L)
|
||||
#define EXT2_ET_BAD_GENERIC_MARK (2133571389L)
|
||||
#define EXT2_ET_BAD_GENERIC_UNMARK (2133571390L)
|
||||
#define EXT2_ET_BAD_GENERIC_TEST (2133571391L)
|
||||
#define EXT2_ET_SYMLINK_LOOP (2133571392L)
|
||||
#define EXT2_ET_CALLBACK_NOTHANDLED (2133571393L)
|
||||
#define EXT2_ET_BAD_BLOCK_IN_INODE_TABLE (2133571394L)
|
||||
#define EXT2_ET_UNSUPP_FEATURE (2133571395L)
|
||||
#define EXT2_ET_RO_UNSUPP_FEATURE (2133571396L)
|
||||
#define EXT2_ET_LLSEEK_FAILED (2133571397L)
|
||||
#define EXT2_ET_NO_MEMORY (2133571398L)
|
||||
#define EXT2_ET_INVALID_ARGUMENT (2133571399L)
|
||||
#define EXT2_ET_BLOCK_ALLOC_FAIL (2133571400L)
|
||||
#define EXT2_ET_INODE_ALLOC_FAIL (2133571401L)
|
||||
#define EXT2_ET_NO_DIRECTORY (2133571402L)
|
||||
#define EXT2_ET_TOO_MANY_REFS (2133571403L)
|
||||
#define EXT2_ET_FILE_NOT_FOUND (2133571404L)
|
||||
#define EXT2_ET_FILE_RO (2133571405L)
|
||||
#define EXT2_ET_DB_NOT_FOUND (2133571406L)
|
||||
#define EXT2_ET_DIR_EXISTS (2133571407L)
|
||||
#define EXT2_ET_UNIMPLEMENTED (2133571408L)
|
||||
#define EXT2_ET_CANCEL_REQUESTED (2133571409L)
|
||||
#define EXT2_ET_FILE_TOO_BIG (2133571410L)
|
||||
#define EXT2_ET_JOURNAL_NOT_BLOCK (2133571411L)
|
||||
#define EXT2_ET_NO_JOURNAL_SB (2133571412L)
|
||||
#define EXT2_ET_JOURNAL_TOO_SMALL (2133571413L)
|
||||
#define EXT2_ET_JOURNAL_UNSUPP_VERSION (2133571414L)
|
||||
#define EXT2_ET_LOAD_EXT_JOURNAL (2133571415L)
|
||||
#define EXT2_ET_NO_JOURNAL (2133571416L)
|
||||
#define EXT2_ET_DIRHASH_UNSUPP (2133571417L)
|
||||
#define EXT2_ET_BAD_EA_BLOCK_NUM (2133571418L)
|
||||
#define EXT2_ET_TOO_MANY_INODES (2133571419L)
|
||||
#define EXT2_ET_NOT_IMAGE_FILE (2133571420L)
|
||||
#define EXT2_ET_RES_GDT_BLOCKS (2133571421L)
|
||||
#define EXT2_ET_RESIZE_INODE_CORRUPT (2133571422L)
|
||||
#define EXT2_ET_SET_BMAP_NO_IND (2133571423L)
|
||||
#define EXT2_ET_TDB_SUCCESS (2133571424L)
|
||||
#define EXT2_ET_TDB_ERR_CORRUPT (2133571425L)
|
||||
#define EXT2_ET_TDB_ERR_IO (2133571426L)
|
||||
#define EXT2_ET_TDB_ERR_LOCK (2133571427L)
|
||||
#define EXT2_ET_TDB_ERR_OOM (2133571428L)
|
||||
#define EXT2_ET_TDB_ERR_EXISTS (2133571429L)
|
||||
#define EXT2_ET_TDB_ERR_NOLOCK (2133571430L)
|
||||
#define EXT2_ET_TDB_ERR_EINVAL (2133571431L)
|
||||
#define EXT2_ET_TDB_ERR_NOEXIST (2133571432L)
|
||||
#define EXT2_ET_TDB_ERR_RDONLY (2133571433L)
|
||||
#define EXT2_ET_DBLIST_EMPTY (2133571434L)
|
||||
#define EXT2_ET_RO_BLOCK_ITERATE (2133571435L)
|
||||
#define EXT2_ET_MAGIC_EXTENT_PATH (2133571436L)
|
||||
#define EXT2_ET_MAGIC_GENERIC_BITMAP64 (2133571437L)
|
||||
#define EXT2_ET_MAGIC_BLOCK_BITMAP64 (2133571438L)
|
||||
#define EXT2_ET_MAGIC_INODE_BITMAP64 (2133571439L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_13 (2133571440L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_14 (2133571441L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_15 (2133571442L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_16 (2133571443L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_17 (2133571444L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_18 (2133571445L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_19 (2133571446L)
|
||||
#define EXT2_ET_EXTENT_HEADER_BAD (2133571447L)
|
||||
#define EXT2_ET_EXTENT_INDEX_BAD (2133571448L)
|
||||
#define EXT2_ET_EXTENT_LEAF_BAD (2133571449L)
|
||||
#define EXT2_ET_EXTENT_NO_SPACE (2133571450L)
|
||||
#define EXT2_ET_INODE_NOT_EXTENT (2133571451L)
|
||||
#define EXT2_ET_EXTENT_NO_NEXT (2133571452L)
|
||||
#define EXT2_ET_EXTENT_NO_PREV (2133571453L)
|
||||
#define EXT2_ET_EXTENT_NO_UP (2133571454L)
|
||||
#define EXT2_ET_EXTENT_NO_DOWN (2133571455L)
|
||||
#define EXT2_ET_NO_CURRENT_NODE (2133571456L)
|
||||
#define EXT2_ET_OP_NOT_SUPPORTED (2133571457L)
|
||||
#define EXT2_ET_CANT_INSERT_EXTENT (2133571458L)
|
||||
#define EXT2_ET_CANT_SPLIT_EXTENT (2133571459L)
|
||||
#define EXT2_ET_EXTENT_NOT_FOUND (2133571460L)
|
||||
#define EXT2_ET_EXTENT_NOT_SUPPORTED (2133571461L)
|
||||
#define EXT2_ET_EXTENT_INVALID_LENGTH (2133571462L)
|
||||
#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 (2133571463L)
|
||||
#define EXT2_NO_MTAB_FILE (2133571464L)
|
||||
#define EXT2_ET_CANT_USE_LEGACY_BITMAPS (2133571465L)
|
||||
#define EXT2_ET_MMP_MAGIC_INVALID (2133571466L)
|
||||
#define EXT2_ET_MMP_FAILED (2133571467L)
|
||||
#define EXT2_ET_MMP_FSCK_ON (2133571468L)
|
||||
#define EXT2_ET_MMP_BAD_BLOCK (2133571469L)
|
||||
#define EXT2_ET_MMP_UNKNOWN_SEQ (2133571470L)
|
||||
#define EXT2_ET_MMP_CHANGE_ABORT (2133571471L)
|
||||
#define EXT2_ET_MMP_OPEN_DIRECT (2133571472L)
|
||||
extern const struct error_table et_ext2_error_table;
|
||||
extern void initialize_ext2_error_table(void);
|
||||
|
||||
/* For compatibility with Heimdal */
|
||||
extern void initialize_ext2_error_table_r(struct et_list **list);
|
||||
|
||||
#define ERROR_TABLE_BASE_ext2 (2133571328L)
|
||||
|
||||
/* for compatibility with older versions... */
|
||||
#define init_ext2_err_tbl initialize_ext2_error_table
|
||||
#define ext2_err_base ERROR_TABLE_BASE_ext2
|
||||
|
||||
#endif
|
||||
|
@ -108,6 +108,18 @@
|
||||
(s)->s_log_cluster_size)
|
||||
#define EXT2_CLUSTER_SIZE_BITS(s) ((s)->s_log_cluster_size + 10)
|
||||
|
||||
/*
|
||||
* Macro-instructions used to manage fragments
|
||||
*
|
||||
* Note: for backwards compatibility only, for the dump program.
|
||||
* Ext2/3/4 will never support fragments....
|
||||
*/
|
||||
#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
|
||||
#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
|
||||
#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
|
||||
#define EXT2_FRAG_SIZE(s) EXT2_BLOCK_SIZE(s)
|
||||
#define EXT2_FRAGS_PER_BLOCK(s) 1
|
||||
|
||||
/*
|
||||
* ACL structures
|
||||
*/
|
||||
@ -142,7 +154,9 @@ struct ext2_group_desc
|
||||
__u16 bg_free_inodes_count; /* Free inodes count */
|
||||
__u16 bg_used_dirs_count; /* Directories count */
|
||||
__u16 bg_flags;
|
||||
__u32 bg_reserved[2];
|
||||
__u32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
|
||||
__u16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
|
||||
__u16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
|
||||
__u16 bg_itable_unused; /* Unused inodes count */
|
||||
__u16 bg_checksum; /* crc16(s_uuid+grouo_num+group_desc)*/
|
||||
};
|
||||
@ -159,7 +173,9 @@ struct ext4_group_desc
|
||||
__u16 bg_free_inodes_count; /* Free inodes count */
|
||||
__u16 bg_used_dirs_count; /* Directories count */
|
||||
__u16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
|
||||
__u32 bg_reserved[2]; /* Likely block/inode bitmap checksum */
|
||||
__u32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
|
||||
__u16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
|
||||
__u16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bitmap) LSB */
|
||||
__u16 bg_itable_unused; /* Unused inodes count */
|
||||
__u16 bg_checksum; /* crc16(sb_uuid+group+desc) */
|
||||
__u32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
|
||||
@ -169,7 +185,10 @@ struct ext4_group_desc
|
||||
__u16 bg_free_inodes_count_hi;/* Free inodes count MSB */
|
||||
__u16 bg_used_dirs_count_hi; /* Directories count MSB */
|
||||
__u16 bg_itable_unused_hi; /* Unused inodes count MSB */
|
||||
__u32 bg_reserved2[3];
|
||||
__u32 bg_exclude_bitmap_hi; /* Exclude bitmap block MSB */
|
||||
__u16 bg_block_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bitmap) MSB */
|
||||
__u16 bg_inode_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bitmap) MSB */
|
||||
__u32 bg_reserved;
|
||||
};
|
||||
|
||||
#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */
|
||||
@ -228,10 +247,15 @@ struct ext2_dx_countlimit {
|
||||
|
||||
#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
|
||||
#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
|
||||
#define EXT2_CLUSTERS_PER_GROUP(s) (EXT2_SB(s)->s_clusters_per_group)
|
||||
#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
|
||||
/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
|
||||
#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
|
||||
#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
|
||||
#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((((unsigned) 1 << 16) - 8) * \
|
||||
(EXT2_CLUSTER_SIZE(s) / \
|
||||
EXT2_BLOCK_SIZE(s)))
|
||||
#define EXT2_MAX_CLUSTERS_PER_GROUP(s) (((unsigned) 1 << 16) - 8)
|
||||
#define EXT2_MAX_INODES_PER_GROUP(s) (((unsigned) 1 << 16) - \
|
||||
EXT2_INODES_PER_BLOCK(s))
|
||||
#ifdef __KERNEL__
|
||||
#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
|
||||
#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
|
||||
@ -322,6 +346,7 @@ struct ext4_new_group_input {
|
||||
#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
|
||||
#define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input)
|
||||
#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
|
||||
#define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
|
||||
|
||||
/*
|
||||
* Structure of an inode on the disk
|
||||
@ -357,7 +382,8 @@ struct ext2_inode {
|
||||
__u16 l_i_file_acl_high;
|
||||
__u16 l_i_uid_high; /* these 2 fields */
|
||||
__u16 l_i_gid_high; /* were reserved2[0] */
|
||||
__u32 l_i_reserved2;
|
||||
__u16 l_i_checksum_lo; /* crc32c(uuid+inum+inode) */
|
||||
__u16 l_i_reserved;
|
||||
} linux2;
|
||||
struct {
|
||||
__u8 h_i_frag; /* Fragment number */
|
||||
@ -404,7 +430,8 @@ struct ext2_inode_large {
|
||||
__u16 l_i_file_acl_high;
|
||||
__u16 l_i_uid_high; /* these 2 fields */
|
||||
__u16 l_i_gid_high; /* were reserved2[0] */
|
||||
__u32 l_i_reserved2;
|
||||
__u16 l_i_checksum_lo; /* crc32c(uuid+inum+inode) */
|
||||
__u16 l_i_reserved;
|
||||
} linux2;
|
||||
struct {
|
||||
__u8 h_i_frag; /* Fragment number */
|
||||
@ -416,7 +443,7 @@ struct ext2_inode_large {
|
||||
} hurd2;
|
||||
} osd2; /* OS dependent 2 */
|
||||
__u16 i_extra_isize;
|
||||
__u16 i_pad1;
|
||||
__u16 i_checksum_hi; /* crc32c(uuid+inum+inode) */
|
||||
__u32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
|
||||
__u32 i_mtime_extra; /* extra Modification time (nsec << 2 | epoch) */
|
||||
__u32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
|
||||
@ -435,7 +462,6 @@ struct ext2_inode_large {
|
||||
#define i_gid_low i_gid
|
||||
#define i_uid_high osd2.linux2.l_i_uid_high
|
||||
#define i_gid_high osd2.linux2.l_i_gid_high
|
||||
#define i_reserved2 osd2.linux2.l_i_reserved2
|
||||
#else
|
||||
#if defined(__GNU__)
|
||||
|
||||
@ -588,7 +614,7 @@ struct ext2_super_block {
|
||||
__u16 s_want_extra_isize; /* New inodes should reserve # bytes */
|
||||
__u32 s_flags; /* Miscellaneous flags */
|
||||
__u16 s_raid_stride; /* RAID stride */
|
||||
__u16 s_mmp_interval; /* # seconds to wait in MMP checking */
|
||||
__u16 s_mmp_update_interval; /* # seconds to wait in MMP checking */
|
||||
__u64 s_mmp_block; /* Block for multi-mount protection */
|
||||
__u32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
|
||||
__u8 s_log_groups_per_flex; /* FLEX_BG group size */
|
||||
@ -617,7 +643,8 @@ struct ext2_super_block {
|
||||
__u32 s_usr_quota_inum; /* inode number of user quota file */
|
||||
__u32 s_grp_quota_inum; /* inode number of group quota file */
|
||||
__u32 s_overhead_blocks; /* overhead blocks/clusters in fs */
|
||||
__u32 s_reserved[109]; /* Padding to the end of the block */
|
||||
__u32 s_reserved[108]; /* Padding to the end of the block */
|
||||
__u32 s_checksum; /* crc32c(superblock) */
|
||||
};
|
||||
|
||||
#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
|
||||
@ -665,7 +692,9 @@ struct ext2_super_block {
|
||||
#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
|
||||
#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
|
||||
#define EXT2_FEATURE_COMPAT_LAZY_BG 0x0040
|
||||
#define EXT2_FEATURE_COMPAT_EXCLUDE_INODE 0x0080
|
||||
/* #define EXT2_FEATURE_COMPAT_EXCLUDE_INODE 0x0080 not used, legacy */
|
||||
#define EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP 0x0100
|
||||
|
||||
|
||||
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
|
||||
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
|
||||
@ -677,6 +706,7 @@ struct ext2_super_block {
|
||||
#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080
|
||||
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
|
||||
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
|
||||
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
|
||||
|
||||
#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
|
||||
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
|
||||
@ -691,7 +721,8 @@ struct ext2_super_block {
|
||||
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000
|
||||
|
||||
#define EXT2_FEATURE_COMPAT_SUPP 0
|
||||
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
|
||||
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
|
||||
EXT4_FEATURE_INCOMPAT_MMP)
|
||||
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
|
||||
EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
|
||||
@ -772,28 +803,52 @@ struct ext2_dir_entry_2 {
|
||||
~EXT2_DIR_ROUND)
|
||||
|
||||
/*
|
||||
* This structure will be used for multiple mount protection. It will be
|
||||
* written into the block number saved in the s_mmp_block field in the
|
||||
* superblock.
|
||||
* This structure is used for multiple mount protection. It is written
|
||||
* into the block number saved in the s_mmp_block field in the superblock.
|
||||
* Programs that check MMP should assume that if SEQ_FSCK (or any unknown
|
||||
* code above SEQ_MAX) is present then it is NOT safe to use the filesystem,
|
||||
* regardless of how old the timestamp is.
|
||||
*
|
||||
* The timestamp in the MMP structure will be updated by e2fsck at some
|
||||
* arbitary intervals (start of passes, after every few groups of inodes
|
||||
* in pass1 and pass1b). There is no guarantee that e2fsck is updating
|
||||
* the MMP block in a timely manner, and the updates it does are purely
|
||||
* for the convenience of the sysadmin and not for automatic validation.
|
||||
*
|
||||
* Note: Only the mmp_seq value is used to determine whether the MMP block
|
||||
* is being updated. The mmp_time, mmp_nodename, and mmp_bdevname
|
||||
* fields are only for informational purposes for the administrator,
|
||||
* due to clock skew between nodes and hostname HA service takeover.
|
||||
*/
|
||||
#define EXT2_MMP_MAGIC 0x004D4D50 /* ASCII for MMP */
|
||||
#define EXT2_MMP_CLEAN 0xFF4D4D50 /* Value of mmp_seq for clean unmount */
|
||||
#define EXT2_MMP_FSCK_ON 0xE24D4D50 /* Value of mmp_seq when being fscked */
|
||||
#define EXT4_MMP_MAGIC 0x004D4D50U /* ASCII for MMP */
|
||||
#define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
|
||||
#define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */
|
||||
#define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */
|
||||
|
||||
struct mmp_struct {
|
||||
__u32 mmp_magic;
|
||||
__u32 mmp_seq;
|
||||
__u64 mmp_time;
|
||||
char mmp_nodename[64];
|
||||
char mmp_bdevname[32];
|
||||
__u16 mmp_interval;
|
||||
__u32 mmp_magic; /* Magic number for MMP */
|
||||
__u32 mmp_seq; /* Sequence no. updated periodically */
|
||||
__u64 mmp_time; /* Time last updated */
|
||||
char mmp_nodename[64]; /* Node which last updated MMP block */
|
||||
char mmp_bdevname[32]; /* Bdev which last updated MMP block */
|
||||
__u16 mmp_check_interval; /* Changed mmp_check_interval */
|
||||
__u16 mmp_pad1;
|
||||
__u32 mmp_pad2;
|
||||
__u32 mmp_pad2[227];
|
||||
};
|
||||
|
||||
/*
|
||||
* Interval in number of seconds to update the MMP sequence number.
|
||||
* Default interval for MMP update in seconds.
|
||||
*/
|
||||
#define EXT2_MMP_DEF_INTERVAL 5
|
||||
#define EXT4_MMP_UPDATE_INTERVAL 5
|
||||
|
||||
/*
|
||||
* Maximum interval for MMP update in seconds.
|
||||
*/
|
||||
#define EXT4_MMP_MAX_UPDATE_INTERVAL 300
|
||||
|
||||
/*
|
||||
* Minimum interval for MMP checking in seconds.
|
||||
*/
|
||||
#define EXT4_MMP_MIN_CHECK_INTERVAL 5
|
||||
|
||||
#endif /* _LINUX_EXT2_FS_H */
|
@ -249,7 +249,7 @@ static ext2_ino_t ext2PathToInode(ext2_vd *vd, const char * path)
|
||||
|
||||
filename[i] = '\0';
|
||||
|
||||
errorcode = ext2fs_namei(vd->fs, vd->root, parent, filename, &ino);
|
||||
errorcode = ext2fs_namei_follow(vd->fs, vd->root, parent, filename, &ino);
|
||||
if(errorcode != EXT2_ET_OK)
|
||||
return 0;
|
||||
|
||||
@ -389,7 +389,7 @@ static ext2_ino_t ext2CreateSymlink(ext2_vd *vd, const char *path, const char *
|
||||
if (!err)
|
||||
{
|
||||
inode.i_block[0] = blk;
|
||||
inode.i_blocks = vd->fs->blocksize / BYTES_PER_SECTOR;
|
||||
inode.i_blocks = vd->fs->blocksize / 512;
|
||||
vd->fs->io->manager->write_blk(vd->fs->io, blk, 1, buffer);
|
||||
ext2fs_block_alloc_stats(vd->fs, blk, +1);
|
||||
}
|
@ -26,8 +26,9 @@ typedef struct struct_io_manager *io_manager;
|
||||
typedef struct struct_io_channel *io_channel;
|
||||
typedef struct struct_io_stats *io_stats;
|
||||
|
||||
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
|
||||
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
|
||||
#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
|
||||
#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
|
||||
|
||||
#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
|
||||
|
143
portlibs/sources/libcustomext2fs/source/ext2_types.h
Normal file
143
portlibs/sources/libcustomext2fs/source/ext2_types.h
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* If linux/types.h is already been included, assume it has defined
|
||||
* everything we need. (cross fingers) Other header files may have
|
||||
* also defined the types that we need.
|
||||
*/
|
||||
#ifndef _EXT2_TYPES_H
|
||||
#define _EXT2_TYPES_H
|
||||
|
||||
#define __S8_TYPEDEF __signed__ char
|
||||
#define __U8_TYPEDEF unsigned char
|
||||
#define __S16_TYPEDEF __signed__ short
|
||||
#define __U16_TYPEDEF unsigned short
|
||||
#define __S32_TYPEDEF __signed__ int
|
||||
#define __U32_TYPEDEF unsigned int
|
||||
#define __S64_TYPEDEF __signed__ long long
|
||||
#define __U64_TYPEDEF unsigned long long
|
||||
|
||||
#ifdef __U8_TYPEDEF
|
||||
typedef __U8_TYPEDEF __u8;
|
||||
#else
|
||||
typedef unsigned char __u8;
|
||||
#endif
|
||||
|
||||
#ifdef __S8_TYPEDEF
|
||||
typedef __S8_TYPEDEF __s8;
|
||||
#else
|
||||
typedef signed char __s8;
|
||||
#endif
|
||||
|
||||
#ifdef __U16_TYPEDEF
|
||||
typedef __U16_TYPEDEF __u16;
|
||||
#else
|
||||
#if (4 == 2)
|
||||
typedef unsigned int __u16;
|
||||
#else
|
||||
#if (2 == 2)
|
||||
typedef unsigned short __u16;
|
||||
#else
|
||||
?==error: undefined 16 bit type
|
||||
#endif /* SIZEOF_SHORT == 2 */
|
||||
#endif /* SIZEOF_INT == 2 */
|
||||
#endif /* __U16_TYPEDEF */
|
||||
|
||||
#ifdef __S16_TYPEDEF
|
||||
typedef __S16_TYPEDEF __s16;
|
||||
#else
|
||||
#if (4 == 2)
|
||||
typedef int __s16;
|
||||
#else
|
||||
#if (2 == 2)
|
||||
typedef short __s16;
|
||||
#else
|
||||
?==error: undefined 16 bit type
|
||||
#endif /* SIZEOF_SHORT == 2 */
|
||||
#endif /* SIZEOF_INT == 2 */
|
||||
#endif /* __S16_TYPEDEF */
|
||||
|
||||
|
||||
#ifdef __U32_TYPEDEF
|
||||
typedef __U32_TYPEDEF __u32;
|
||||
#else
|
||||
#if (4 == 4)
|
||||
typedef unsigned int __u32;
|
||||
#else
|
||||
#if (4 == 4)
|
||||
typedef unsigned long __u32;
|
||||
#else
|
||||
#if (2 == 4)
|
||||
typedef unsigned short __u32;
|
||||
#else
|
||||
?== error: undefined 32 bit type
|
||||
#endif /* SIZEOF_SHORT == 4 */
|
||||
#endif /* SIZEOF_LONG == 4 */
|
||||
#endif /* SIZEOF_INT == 4 */
|
||||
#endif /* __U32_TYPEDEF */
|
||||
|
||||
#ifdef __S32_TYPEDEF
|
||||
typedef __S32_TYPEDEF __s32;
|
||||
#else
|
||||
#if (4 == 4)
|
||||
typedef int __s32;
|
||||
#else
|
||||
#if (4 == 4)
|
||||
typedef long __s32;
|
||||
#else
|
||||
#if (2 == 4)
|
||||
typedef short __s32;
|
||||
#else
|
||||
?== error: undefined 32 bit type
|
||||
#endif /* SIZEOF_SHORT == 4 */
|
||||
#endif /* SIZEOF_LONG == 4 */
|
||||
#endif /* SIZEOF_INT == 4 */
|
||||
#endif /* __S32_TYPEDEF */
|
||||
|
||||
#ifdef __U64_TYPEDEF
|
||||
typedef __U64_TYPEDEF __u64;
|
||||
#else
|
||||
#if (4 == 8)
|
||||
typedef unsigned int __u64;
|
||||
#else
|
||||
#if (4 == 8)
|
||||
typedef unsigned long __u64;
|
||||
#else
|
||||
#if (8 == 8)
|
||||
typedef unsigned long long __u64;
|
||||
#endif /* SIZEOF_LONG_LONG == 8 */
|
||||
#endif /* SIZEOF_LONG == 8 */
|
||||
#endif /* SIZEOF_INT == 8 */
|
||||
#endif /* __U64_TYPEDEF */
|
||||
|
||||
#ifdef __S64_TYPEDEF
|
||||
typedef __S64_TYPEDEF __s64;
|
||||
#else
|
||||
#if (4 == 8)
|
||||
typedef int __s64;
|
||||
#else
|
||||
#if (4 == 8)
|
||||
typedef long __s64;
|
||||
#else
|
||||
#if (8 == 8)
|
||||
#if defined(__GNUC__)
|
||||
typedef __signed__ long long __s64;
|
||||
#else
|
||||
typedef signed long long __s64;
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* SIZEOF_LONG_LONG == 8 */
|
||||
#endif /* SIZEOF_LONG == 8 */
|
||||
#endif /* SIZEOF_INT == 8 */
|
||||
#endif /* __S64_TYPEDEF */
|
||||
|
||||
#undef __S8_TYPEDEF
|
||||
#undef __U8_TYPEDEF
|
||||
#undef __S16_TYPEDEF
|
||||
#undef __U16_TYPEDEF
|
||||
#undef __S32_TYPEDEF
|
||||
#undef __U32_TYPEDEF
|
||||
#undef __S64_TYPEDEF
|
||||
#undef __U64_TYPEDEF
|
||||
|
||||
#endif /* _*_TYPES_H */
|
||||
|
||||
/* These defines are needed for the public ext2fs.h header file */
|
||||
#define HAVE_SYS_TYPES_H 1
|
@ -41,11 +41,7 @@ void ext2CloseFile (ext2_file_state *file)
|
||||
|
||||
// Sync the file (and its attributes) to disc
|
||||
if(file->write)
|
||||
{
|
||||
// Read in node changes before writing them
|
||||
ext2fs_read_inode(file->vd->fs, file->ni->ino, &file->ni->ni);
|
||||
ext2UpdateTimes(file->vd, file->ni, EXT2_UPDATE_ACTIME);
|
||||
}
|
||||
|
||||
if (file->read)
|
||||
ext2UpdateTimes(file->vd, file->ni, EXT2_UPDATE_ATIME);
|
||||
@ -243,11 +239,25 @@ ssize_t ext2_write_r (struct _reent *r, int fd, const char *ptr, size_t len)
|
||||
// Lock
|
||||
ext2Lock(file->vd);
|
||||
|
||||
u32 writen = 0;
|
||||
errcode_t err = 0;
|
||||
u32 written = 0;
|
||||
|
||||
// Write to the files data atrribute
|
||||
errcode_t err = ext2fs_file_write(file->fd, ptr, len, &writen);
|
||||
if (writen <= 0 || err) {
|
||||
while (len > 0)
|
||||
{
|
||||
u32 wrote = 0;
|
||||
|
||||
err = ext2fs_file_write(file->fd, ptr, len, &wrote);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
len -= wrote;
|
||||
ptr += wrote;
|
||||
written += wrote;
|
||||
}
|
||||
|
||||
// Check for errors
|
||||
if (err) {
|
||||
ext2Unlock(file->vd);
|
||||
r->_errno = errno;
|
||||
return (err ? err : -1);
|
||||
@ -256,7 +266,7 @@ ssize_t ext2_write_r (struct _reent *r, int fd, const char *ptr, size_t len)
|
||||
// Unlock
|
||||
ext2Unlock(file->vd);
|
||||
|
||||
return (writen == 0 ? -1 : writen);
|
||||
return (written == 0 ? -1 : written);
|
||||
}
|
||||
|
||||
ssize_t ext2_read_r (struct _reent *r, int fd, char *ptr, size_t len)
|
@ -29,6 +29,10 @@ extern "C" {
|
||||
#define NO_INLINE_FUNCS
|
||||
#endif
|
||||
|
||||
#ifndef _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE 600 /* for posix_memalign() */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Where the master copy of the superblock is located, and how big
|
||||
* superblocks are supposed to be. We define SUPERBLOCK_SIZE because
|
||||
@ -37,7 +41,7 @@ extern "C" {
|
||||
* 1032 bytes long).
|
||||
*/
|
||||
#define SUPERBLOCK_OFFSET 1024
|
||||
#define SUPERBLOCK_SIZE 1024
|
||||
#define SUPERBLOCK_SIZE 1024
|
||||
|
||||
/*
|
||||
* The last ext2fs revision level that this version of the library is
|
||||
@ -53,9 +57,18 @@ extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef __USE_XOPEN2K
|
||||
/* If the "#define _XOPEN_SOURCE 600" didn't succeed in declaring
|
||||
* posix_memalign(), maybe due to <features.h> or <stdlib.h> included beforej
|
||||
* _XOPEN_SOURCE, declare it here to avoid compiler warnings. */
|
||||
extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size);
|
||||
#endif
|
||||
|
||||
#include "ext2_types.h"
|
||||
#include "com_err.h"
|
||||
#include "ext2_fs.h"
|
||||
#include "ext3_extents.h"
|
||||
|
||||
@ -68,6 +81,7 @@ typedef __u64 ext2_off64_t;
|
||||
typedef __s64 e2_blkcnt_t;
|
||||
typedef __u32 ext2_dirhash_t;
|
||||
|
||||
#include "com_err.h"
|
||||
#include "ext2_io.h"
|
||||
#include "ext2_err.h"
|
||||
#include "ext2_ext_attr.h"
|
||||
@ -171,6 +185,7 @@ typedef struct ext2_file *ext2_file_t;
|
||||
#define EXT2_FLAG_64BITS 0x20000
|
||||
#define EXT2_FLAG_PRINT_PROGRESS 0x40000
|
||||
#define EXT2_FLAG_DIRECT_IO 0x80000
|
||||
#define EXT2_FLAG_SKIP_MMP 0x100000
|
||||
|
||||
/*
|
||||
* Special flag in the ext2 inode i_flag field that means that this is
|
||||
@ -180,10 +195,9 @@ typedef struct ext2_file *ext2_file_t;
|
||||
|
||||
/*
|
||||
* Flags for mkjournal
|
||||
*
|
||||
* EXT2_MKJOURNAL_V1_SUPER Make a (deprecated) V1 journal superblock
|
||||
*/
|
||||
#define EXT2_MKJOURNAL_V1_SUPER 0x0000001
|
||||
#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */
|
||||
#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/
|
||||
|
||||
struct opaque_ext2_group_desc;
|
||||
|
||||
@ -194,11 +208,11 @@ struct struct_ext2_filsys {
|
||||
char * device_name;
|
||||
struct ext2_super_block * super;
|
||||
unsigned int blocksize;
|
||||
int clustersize;
|
||||
int fragsize;
|
||||
dgrp_t group_desc_count;
|
||||
unsigned long desc_blocks;
|
||||
struct opaque_ext2_group_desc * group_desc;
|
||||
int inode_blocks_per_group;
|
||||
unsigned int inode_blocks_per_group;
|
||||
ext2fs_inode_bitmap inode_map;
|
||||
ext2fs_block_bitmap block_map;
|
||||
/* XXX FIXME-64: not 64-bit safe, but not used? */
|
||||
@ -216,10 +230,11 @@ struct struct_ext2_filsys {
|
||||
struct ext2_image_hdr * image_header;
|
||||
__u32 umask;
|
||||
time_t now;
|
||||
int cluster_ratio_bits;
|
||||
/*
|
||||
* Reserved for future expansion
|
||||
*/
|
||||
__u32 reserved[7];
|
||||
__u32 reserved[6];
|
||||
|
||||
/*
|
||||
* Reserved for the use of the calling application.
|
||||
@ -238,6 +253,18 @@ struct struct_ext2_filsys {
|
||||
errcode_t (*get_alloc_block)(ext2_filsys fs, blk64_t goal,
|
||||
blk64_t *ret);
|
||||
void (*block_alloc_stats)(ext2_filsys fs, blk64_t blk, int inuse);
|
||||
|
||||
/*
|
||||
* Buffers for Multiple mount protection(MMP) block.
|
||||
*/
|
||||
void *mmp_buf;
|
||||
void *mmp_cmp;
|
||||
int mmp_fd;
|
||||
|
||||
/*
|
||||
* Time at which e2fsck last updated the MMP block.
|
||||
*/
|
||||
long mmp_last_written;
|
||||
};
|
||||
|
||||
#include "bitops.h"
|
||||
@ -519,6 +546,7 @@ typedef struct ext2_icount *ext2_icount_t;
|
||||
EXT3_FEATURE_INCOMPAT_RECOVER|\
|
||||
EXT3_FEATURE_INCOMPAT_EXTENTS|\
|
||||
EXT4_FEATURE_INCOMPAT_FLEX_BG|\
|
||||
EXT4_FEATURE_INCOMPAT_MMP|\
|
||||
EXT4_FEATURE_INCOMPAT_64BIT)
|
||||
#else
|
||||
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\
|
||||
@ -527,14 +555,27 @@ typedef struct ext2_icount *ext2_icount_t;
|
||||
EXT3_FEATURE_INCOMPAT_RECOVER|\
|
||||
EXT3_FEATURE_INCOMPAT_EXTENTS|\
|
||||
EXT4_FEATURE_INCOMPAT_FLEX_BG|\
|
||||
EXT4_FEATURE_INCOMPAT_MMP|\
|
||||
EXT4_FEATURE_INCOMPAT_64BIT)
|
||||
#endif
|
||||
#ifdef CONFIG_QUOTA
|
||||
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
|
||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
|
||||
EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
|
||||
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
|
||||
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
|
||||
EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
|
||||
EXT4_FEATURE_RO_COMPAT_BIGALLOC|\
|
||||
EXT4_FEATURE_RO_COMPAT_QUOTA)
|
||||
#else
|
||||
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
|
||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
|
||||
EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
|
||||
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
|
||||
EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
|
||||
EXT4_FEATURE_RO_COMPAT_BIGALLOC)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
|
||||
@ -543,6 +584,29 @@ typedef struct ext2_icount *ext2_icount_t;
|
||||
#define EXT2_LIB_SOFTSUPP_INCOMPAT (0)
|
||||
#define EXT2_LIB_SOFTSUPP_RO_COMPAT (EXT4_FEATURE_RO_COMPAT_BIGALLOC)
|
||||
|
||||
|
||||
/* Translate a block number to a cluster number */
|
||||
#define EXT2FS_CLUSTER_RATIO(fs) (1 << (fs)->cluster_ratio_bits)
|
||||
#define EXT2FS_CLUSTER_MASK(fs) (EXT2FS_CLUSTER_RATIO(fs) - 1)
|
||||
#define EXT2FS_B2C(fs, blk) ((blk) >> (fs)->cluster_ratio_bits)
|
||||
/* Translate a cluster number to a block number */
|
||||
#define EXT2FS_C2B(fs, cluster) ((cluster) << (fs)->cluster_ratio_bits)
|
||||
/* Translate # of blks to # of clusters */
|
||||
#define EXT2FS_NUM_B2C(fs, blks) (((blks) + EXT2FS_CLUSTER_MASK(fs)) >> \
|
||||
(fs)->cluster_ratio_bits)
|
||||
|
||||
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||
typedef struct stat64 ext2fs_struct_stat;
|
||||
#else
|
||||
typedef struct stat ext2fs_struct_stat;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For ext2fs_close2() and ext2fs_flush2(), this flag allows you to
|
||||
* avoid the fsync call.
|
||||
*/
|
||||
#define EXT2_FLAG_FLUSH_NO_SYNC 1
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
@ -656,6 +720,10 @@ extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
|
||||
extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
|
||||
const char *descr,
|
||||
ext2fs_block_bitmap *ret);
|
||||
extern errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs,
|
||||
const char *descr,
|
||||
ext2fs_block_bitmap *ret);
|
||||
extern int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap);
|
||||
extern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
|
||||
const char *descr,
|
||||
ext2fs_inode_bitmap *ret);
|
||||
@ -712,6 +780,7 @@ extern errcode_t ext2fs_get_block_bitmap_range2(ext2fs_block_bitmap bmap,
|
||||
extern dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t);
|
||||
extern blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group);
|
||||
extern blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group);
|
||||
extern int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group);
|
||||
extern blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs,
|
||||
struct ext2_inode *inode);
|
||||
extern blk64_t ext2fs_inode_i_blocks(ext2_filsys fs,
|
||||
@ -763,8 +832,10 @@ extern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
|
||||
extern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
|
||||
extern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group);
|
||||
extern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum);
|
||||
extern blk64_t ext2fs_file_acl_block(const struct ext2_inode *inode);
|
||||
extern void ext2fs_file_acl_block_set(struct ext2_inode *inode, blk64_t blk);
|
||||
extern blk64_t ext2fs_file_acl_block(ext2_filsys fs,
|
||||
const struct ext2_inode *inode);
|
||||
extern void ext2fs_file_acl_block_set(ext2_filsys fs,
|
||||
struct ext2_inode *inode, blk64_t blk);
|
||||
|
||||
/* block.c */
|
||||
extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
|
||||
@ -822,7 +893,9 @@ extern errcode_t ext2fs_check_desc(ext2_filsys fs);
|
||||
|
||||
/* closefs.c */
|
||||
extern errcode_t ext2fs_close(ext2_filsys fs);
|
||||
extern errcode_t ext2fs_close2(ext2_filsys fs, int flags);
|
||||
extern errcode_t ext2fs_flush(ext2_filsys fs);
|
||||
extern errcode_t ext2fs_flush2(ext2_filsys fs, int flags);
|
||||
extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block);
|
||||
extern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
|
||||
dgrp_t group,
|
||||
@ -838,6 +911,10 @@ extern int ext2fs_super_and_bgd_loc(ext2_filsys fs,
|
||||
int *ret_meta_bg);
|
||||
extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
|
||||
|
||||
/* crc32c.c */
|
||||
extern __u32 ext2fs_crc32c_be(__u32 crc, unsigned char const *p, size_t len);
|
||||
extern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len);
|
||||
|
||||
/* csum.c */
|
||||
extern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group);
|
||||
extern int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group);
|
||||
@ -1088,6 +1165,8 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
|
||||
errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
|
||||
__u64 start, unsigned int num,
|
||||
void *in);
|
||||
errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
|
||||
ext2fs_block_bitmap *bitmap);
|
||||
|
||||
/* getsize.c */
|
||||
extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
||||
@ -1227,21 +1306,21 @@ extern errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num,
|
||||
extern errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
|
||||
blk64_t *ret_blk, int *ret_count);
|
||||
extern errcode_t ext2fs_create_journal_superblock(ext2_filsys fs,
|
||||
__u32 size, int flags,
|
||||
__u32 num_blocks, int flags,
|
||||
char **ret_jsb);
|
||||
extern errcode_t ext2fs_add_journal_device(ext2_filsys fs,
|
||||
ext2_filsys journal_dev);
|
||||
extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size,
|
||||
extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks,
|
||||
int flags);
|
||||
extern int ext2fs_default_journal_size(__u64 blocks);
|
||||
extern int ext2fs_default_journal_size(__u64 num_blocks);
|
||||
|
||||
/* openfs.c */
|
||||
extern errcode_t ext2fs_open(const char *name, int flags, int superblock,
|
||||
unsigned int block_size, io_channel * chan,
|
||||
unsigned int block_size, io_channel chan,
|
||||
ext2_filsys *ret_fs);
|
||||
extern errcode_t ext2fs_open2(const char *name, const char *io_options,
|
||||
int flags, int superblock,
|
||||
unsigned int block_size, io_channel * chan,
|
||||
unsigned int block_size, io_channel chan,
|
||||
ext2_filsys *ret_fs);
|
||||
extern blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs,
|
||||
blk64_t group_block, dgrp_t i);
|
||||
@ -1261,6 +1340,16 @@ errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
|
||||
errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name,
|
||||
ext2_ino_t ino, int flags);
|
||||
|
||||
/* mmp.c */
|
||||
errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf);
|
||||
errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf);
|
||||
errcode_t ext2fs_mmp_clear(ext2_filsys fs);
|
||||
errcode_t ext2fs_mmp_init(ext2_filsys fs);
|
||||
errcode_t ext2fs_mmp_start(ext2_filsys fs);
|
||||
errcode_t ext2fs_mmp_update(ext2_filsys fs);
|
||||
errcode_t ext2fs_mmp_stop(ext2_filsys fs);
|
||||
unsigned ext2fs_mmp_new_seq(void);
|
||||
|
||||
/* read_bb.c */
|
||||
extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
|
||||
ext2_badblocks_list *bb_list);
|
||||
@ -1296,9 +1385,12 @@ extern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
|
||||
int bufsize);
|
||||
extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
|
||||
struct ext2_inode *f, int hostorder);
|
||||
extern void ext2fs_swap_mmp(struct mmp_struct *mmp);
|
||||
|
||||
/* valid_blk.c */
|
||||
extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
|
||||
extern int ext2fs_inode_has_valid_blocks2(ext2_filsys fs,
|
||||
struct ext2_inode *inode);
|
||||
|
||||
/* version.c */
|
||||
extern int ext2fs_parse_version_string(const char *ver_string);
|
||||
@ -1315,6 +1407,11 @@ extern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
|
||||
extern errcode_t ext2fs_get_mem(unsigned long size, void *ptr);
|
||||
extern errcode_t ext2fs_get_memalign(unsigned long size,
|
||||
unsigned long align, void *ptr);
|
||||
extern errcode_t ext2fs_get_memzero(unsigned long size, void *ptr);
|
||||
extern errcode_t ext2fs_get_array(unsigned long count,
|
||||
unsigned long size, void *ptr);
|
||||
extern errcode_t ext2fs_get_arrayzero(unsigned long count,
|
||||
unsigned long size, void *ptr);
|
||||
extern errcode_t ext2fs_free_mem(void *ptr);
|
||||
extern errcode_t ext2fs_resize_mem(unsigned long old_size,
|
||||
unsigned long size, void *ptr);
|
||||
@ -1336,6 +1433,9 @@ extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
|
||||
struct ext2_inode *inode);
|
||||
extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
|
||||
extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b);
|
||||
extern int ext2fs_open_file(const char *pathname, int flags, mode_t mode);
|
||||
extern int ext2fs_stat(const char *path, ext2fs_struct_stat *buf);
|
||||
extern int ext2fs_fstat(int fd, ext2fs_struct_stat *buf);
|
||||
|
||||
/*
|
||||
* The actual inlined functions definitions themselves...
|
||||
@ -1371,30 +1471,39 @@ _INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_get_memalign(unsigned long size,
|
||||
unsigned long align, void *ptr)
|
||||
_INLINE_ errcode_t ext2fs_get_memzero(unsigned long size, void *ptr)
|
||||
{
|
||||
void *pp;
|
||||
|
||||
#ifdef HWRVL
|
||||
pp = mem_align(32, size);
|
||||
#else
|
||||
pp = mem_alloc(size);
|
||||
#endif
|
||||
if (!pp)
|
||||
return EXT2_ET_NO_MEMORY;
|
||||
|
||||
memcpy(ptr, &pp, sizeof (pp));
|
||||
memset(pp, 0, size);
|
||||
memcpy(ptr, &pp, sizeof(pp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_get_array(unsigned long count, unsigned long size, void *ptr)
|
||||
{
|
||||
if (count && (-1UL)/count<size)
|
||||
return EXT2_ET_NO_MEMORY; //maybe define EXT2_ET_OVERFLOW ?
|
||||
return EXT2_ET_NO_MEMORY;
|
||||
return ext2fs_get_mem(count*size, ptr);
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_get_arrayzero(unsigned long count,
|
||||
unsigned long size, void *ptr)
|
||||
{
|
||||
void *pp;
|
||||
|
||||
if (count && (-1UL)/count<size)
|
||||
return EXT2_ET_NO_MEMORY;
|
||||
pp = mem_calloc(count, size);
|
||||
if (!pp)
|
||||
return EXT2_ET_NO_MEMORY;
|
||||
memcpy(ptr, &pp, sizeof(pp));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free memory
|
||||
*/
|
||||
@ -1562,6 +1671,40 @@ _INLINE_ __u64 ext2fs_div64_ceil(__u64 a, __u64 b)
|
||||
return ((a - 1) / b) + 1;
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_open_file(const char *pathname, int flags, mode_t mode)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (mode)
|
||||
#if defined(HAVE_OPEN64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||
return open64(pathname, flags, mode);
|
||||
else
|
||||
return open64(pathname, flags);
|
||||
#else
|
||||
return open(pathname, flags, mode);
|
||||
else
|
||||
return open(pathname, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_stat(const char *path, ext2fs_struct_stat *buf)
|
||||
{
|
||||
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||
return stat64(path, buf);
|
||||
#else
|
||||
return stat(path, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fstat(int fd, ext2fs_struct_stat *buf)
|
||||
{
|
||||
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||
return fstat64(fd, buf);
|
||||
#else
|
||||
return fstat(fd, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef _INLINE_
|
||||
#endif
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
#define EXT2FS_MAX_NESTED_LINKS 8
|
||||
|
||||
/*
|
||||
* Badblocks list
|
||||
*/
|
||||
@ -138,6 +140,6 @@ extern errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bitmap,
|
||||
extern errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, unsigned int num,
|
||||
void *out);
|
||||
extern int ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func);
|
||||
extern void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap,const char *func);
|
||||
|
||||
extern int ext2fs_mem_is_zero(const char *mem, size_t len);
|
@ -11,6 +11,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -82,9 +83,9 @@ errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block, void *inbuf)
|
||||
{
|
||||
errcode_t retval;
|
||||
char *write_buf;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
char *buf = NULL;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
retval = ext2fs_get_mem(fs->blocksize, &buf);
|
||||
if (retval)
|
||||
return retval;
|
||||
@ -94,8 +95,9 @@ errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block, void *inbuf)
|
||||
write_buf = (char *) inbuf;
|
||||
#endif
|
||||
retval = io_channel_write_blk64(fs->io, block, 1, write_buf);
|
||||
if (buf)
|
||||
ext2fs_free_mem(&buf);
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
ext2fs_free_mem(&buf);
|
||||
#endif
|
||||
if (!retval)
|
||||
ext2fs_mark_changed(fs);
|
||||
return retval;
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -253,9 +254,8 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
|
||||
handle->path[0].max_entries = ext2fs_le16_to_cpu(eh->eh_max);
|
||||
handle->path[0].curr = 0;
|
||||
handle->path[0].end_blk =
|
||||
((((__u64) handle->inode->i_size_high << 32) +
|
||||
handle->inode->i_size + (fs->blocksize - 1))
|
||||
>> EXT2_BLOCK_SIZE_BITS(fs->super));
|
||||
(EXT2_I_SIZE(handle->inode) + fs->blocksize - 1) >>
|
||||
EXT2_BLOCK_SIZE_BITS(fs->super);
|
||||
handle->path[0].visit_num = 1;
|
||||
handle->level = 0;
|
||||
handle->magic = EXT2_ET_MAGIC_EXTENT_HANDLE;
|
||||
@ -374,9 +374,11 @@ retry:
|
||||
case EXT2_EXTENT_ROOT:
|
||||
handle->level = 0;
|
||||
path = handle->path + handle->level;
|
||||
/* fallthrough */
|
||||
case EXT2_EXTENT_FIRST_SIB:
|
||||
path->left = path->entries;
|
||||
path->curr = 0;
|
||||
/* fallthrough */
|
||||
case EXT2_EXTENT_NEXT_SIB:
|
||||
if (path->left <= 0)
|
||||
return EXT2_ET_EXTENT_NO_NEXT;
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -22,7 +23,7 @@ struct ext2_file {
|
||||
errcode_t magic;
|
||||
ext2_filsys fs;
|
||||
ext2_ino_t ino;
|
||||
struct ext2_inode inode;
|
||||
struct ext2_inode *inode;
|
||||
int flags;
|
||||
__u64 pos;
|
||||
blk64_t blockno;
|
||||
@ -56,13 +57,9 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
|
||||
file->fs = fs;
|
||||
file->ino = ino;
|
||||
file->flags = flags & EXT2_FILE_MASK;
|
||||
|
||||
if (inode) {
|
||||
memcpy(&file->inode, inode, sizeof(struct ext2_inode));
|
||||
} else {
|
||||
retval = ext2fs_read_inode(fs, ino, &file->inode);
|
||||
if (retval)
|
||||
goto fail;
|
||||
file->inode = inode;
|
||||
if (!inode) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
retval = ext2fs_get_array(3, fs->blocksize, &file->buf);
|
||||
@ -102,7 +99,7 @@ struct ext2_inode *ext2fs_file_get_inode(ext2_file_t file)
|
||||
{
|
||||
if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
|
||||
return NULL;
|
||||
return &file->inode;
|
||||
return file->inode;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -121,15 +118,12 @@ errcode_t ext2fs_file_flush(ext2_file_t file)
|
||||
!(file->flags & EXT2_FILE_BUF_DIRTY))
|
||||
return 0;
|
||||
|
||||
// Flushing out the new size - Dimok
|
||||
ext2fs_write_inode(file->fs, file->ino, &file->inode);
|
||||
|
||||
/*
|
||||
* OK, the physical block hasn't been allocated yet.
|
||||
* Allocate it.
|
||||
*/
|
||||
if (!file->physblock) {
|
||||
retval = ext2fs_bmap2(fs, file->ino, &file->inode,
|
||||
retval = ext2fs_bmap2(fs, file->ino, file->inode,
|
||||
BMAP_BUFFER, file->ino ? BMAP_ALLOC : 0,
|
||||
file->blockno, 0, &file->physblock);
|
||||
if (retval)
|
||||
@ -181,7 +175,7 @@ static errcode_t load_buffer(ext2_file_t file, int dontfill)
|
||||
errcode_t retval;
|
||||
|
||||
if (!(file->flags & EXT2_FILE_BUF_VALID)) {
|
||||
retval = ext2fs_bmap2(fs, file->ino, &file->inode,
|
||||
retval = ext2fs_bmap2(fs, file->ino, file->inode,
|
||||
BMAP_BUFFER, 0, file->blockno, 0,
|
||||
&file->physblock);
|
||||
if (retval)
|
||||
@ -230,7 +224,7 @@ errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
|
||||
EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE);
|
||||
fs = file->fs;
|
||||
|
||||
while ((file->pos < EXT2_I_SIZE(&file->inode)) && (wanted > 0)) {
|
||||
while ((file->pos < EXT2_I_SIZE(file->inode)) && (wanted > 0)) {
|
||||
retval = sync_buffer_position(file);
|
||||
if (retval)
|
||||
goto fail;
|
||||
@ -242,7 +236,7 @@ errcode_t ext2fs_file_read(ext2_file_t file, void *buf,
|
||||
c = fs->blocksize - start;
|
||||
if (c > wanted)
|
||||
c = wanted;
|
||||
left = EXT2_I_SIZE(&file->inode) - file->pos ;
|
||||
left = EXT2_I_SIZE(file->inode) - file->pos ;
|
||||
if (c > left)
|
||||
c = left;
|
||||
|
||||
@ -300,11 +294,11 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
|
||||
nbytes -= c;
|
||||
}
|
||||
|
||||
// I don't see why changing size is my duty - Dimok
|
||||
if(EXT2_I_SIZE(&file->inode) < file->pos)
|
||||
// Modify file size in inode if required
|
||||
if(EXT2_I_SIZE(file->inode) < file->pos)
|
||||
{
|
||||
file->inode.i_size = file->pos & 0xFFFFFFFF;
|
||||
file->inode.i_size_high = (file->pos >> 32) & 0xFFFFFFFF;
|
||||
file->inode->i_size = file->pos & 0xFFFFFFFF;
|
||||
file->inode->i_size_high = (file->pos >> 32) & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
fail:
|
||||
@ -323,7 +317,7 @@ errcode_t ext2fs_file_llseek(ext2_file_t file, __u64 offset,
|
||||
else if (whence == EXT2_SEEK_CUR)
|
||||
file->pos += offset;
|
||||
else if (whence == EXT2_SEEK_END)
|
||||
file->pos = EXT2_I_SIZE(&file->inode) + offset;
|
||||
file->pos = EXT2_I_SIZE(file->inode) + offset;
|
||||
else
|
||||
return EXT2_ET_INVALID_ARGUMENT;
|
||||
|
||||
@ -336,7 +330,7 @@ errcode_t ext2fs_file_llseek(ext2_file_t file, __u64 offset,
|
||||
errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset,
|
||||
int whence, ext2_off_t *ret_pos)
|
||||
{
|
||||
__u64 loffset, ret_loffset = 0;
|
||||
__u64 loffset, ret_loffset;
|
||||
errcode_t retval;
|
||||
|
||||
loffset = offset;
|
||||
@ -354,7 +348,7 @@ errcode_t ext2fs_file_get_lsize(ext2_file_t file, __u64 *ret_size)
|
||||
{
|
||||
if (file->magic != EXT2_ET_MAGIC_EXT2_FILE)
|
||||
return EXT2_ET_MAGIC_EXT2_FILE;
|
||||
*ret_size = EXT2_I_SIZE(&file->inode);
|
||||
*ret_size = EXT2_I_SIZE(file->inode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -386,15 +380,14 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
|
||||
|
||||
truncate_block = ((size + file->fs->blocksize - 1) >>
|
||||
EXT2_BLOCK_SIZE_BITS(file->fs->super)) + 1;
|
||||
old_size = file->inode.i_size +
|
||||
(((blk64_t) file->inode.i_size_high) << 32);
|
||||
old_size = EXT2_I_SIZE(file->inode);
|
||||
old_truncate = ((old_size + file->fs->blocksize - 1) >>
|
||||
EXT2_BLOCK_SIZE_BITS(file->fs->super)) + 1;
|
||||
|
||||
file->inode.i_size = size & 0xffffffff;
|
||||
file->inode.i_size_high = (size >> 32);
|
||||
file->inode->i_size = size & 0xffffffff;
|
||||
file->inode->i_size_high = (size >> 32);
|
||||
if (file->ino) {
|
||||
retval = ext2fs_write_inode(file->fs, file->ino, &file->inode);
|
||||
retval = ext2fs_write_inode(file->fs, file->ino, file->inode);
|
||||
if (retval)
|
||||
return retval;
|
||||
}
|
||||
@ -402,7 +395,7 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
|
||||
if (truncate_block <= old_truncate)
|
||||
return 0;
|
||||
|
||||
return ext2fs_punch(file->fs, file->ino, &file->inode, 0,
|
||||
return ext2fs_punch(file->fs, file->ino, file->inode, 0,
|
||||
truncate_block, ~0ULL);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -33,6 +34,7 @@
|
||||
|
||||
#include "ext2_fs.h"
|
||||
#include "ext2fs.h"
|
||||
#include "ext2fsP.h"
|
||||
|
||||
struct dir_list {
|
||||
char *name;
|
||||
@ -127,6 +129,7 @@ char *ext2fs_find_block_device(dev_t device)
|
||||
struct dir_list *list = 0, *new_list = 0;
|
||||
struct dir_list *current;
|
||||
char *ret_path = 0;
|
||||
int level = 0;
|
||||
|
||||
/*
|
||||
* Add the starting directories to search...
|
||||
@ -153,6 +156,9 @@ char *ext2fs_find_block_device(dev_t device)
|
||||
if (list == 0) {
|
||||
list = new_list;
|
||||
new_list = 0;
|
||||
/* Avoid infinite loop */
|
||||
if (++level >= EXT2FS_MAX_NESTED_LINKS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
free_dirlist(&list);
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
@ -65,9 +66,13 @@ errcode_t ext2fs_sync_device(int fd, int flushb)
|
||||
#ifdef BLKFLSBUF
|
||||
if (ioctl (fd, BLKFLSBUF, 0) == 0)
|
||||
return 0;
|
||||
#elif defined(__linux__)
|
||||
#warning BLKFLSBUF not defined
|
||||
#endif
|
||||
#ifdef FDFLUSH
|
||||
ioctl (fd, FDFLUSH, 0); /* In case this is a floppy */
|
||||
#elif defined(__linux__)
|
||||
#warning FDFLUSH not defined
|
||||
#endif
|
||||
}
|
||||
return 0;
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -53,6 +54,11 @@ void ext2fs_free(ext2_filsys fs)
|
||||
if (fs->icache)
|
||||
ext2fs_free_inode_cache(fs->icache);
|
||||
|
||||
if (fs->mmp_buf)
|
||||
ext2fs_free_mem(&fs->mmp_buf);
|
||||
if (fs->mmp_cmp)
|
||||
ext2fs_free_mem(&fs->mmp_cmp);
|
||||
|
||||
fs->magic = 0;
|
||||
|
||||
ext2fs_free_mem(&fs);
|
@ -47,6 +47,59 @@ static bool device_gekko_io_readsectors(io_channel dev, sec_t sector, sec_t numS
|
||||
static s64 device_gekko_io_writebytes(io_channel dev, s64 offset, s64 count, const void *buf);
|
||||
static bool device_gekko_io_writesectors(io_channel dev, sec_t sector, sec_t numSectors, const void* buffer);
|
||||
|
||||
/**
|
||||
* Get the sector size of the device
|
||||
*/
|
||||
static int readSectorSize(const DISC_INTERFACE* interace)
|
||||
{
|
||||
int counter1 = 0;
|
||||
int counter2 = 0;
|
||||
int i;
|
||||
|
||||
u8 *memblock = (u8 *) mem_alloc(MAX_SECTOR_SIZE);
|
||||
if(!memblock)
|
||||
return 512;
|
||||
|
||||
memset(memblock, 0x00, MAX_SECTOR_SIZE);
|
||||
|
||||
if(!interace->readSectors(0, 1, memblock)) {
|
||||
mem_free(memblock);
|
||||
return 512;
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_SECTOR_SIZE; ++i)
|
||||
{
|
||||
if(memblock[i] != 0x00)
|
||||
counter1++;
|
||||
}
|
||||
|
||||
memset(memblock, 0xFF, MAX_SECTOR_SIZE);
|
||||
|
||||
if(!interace->readSectors(0, 1, memblock)) {
|
||||
mem_free(memblock);
|
||||
return 512;
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_SECTOR_SIZE; ++i)
|
||||
{
|
||||
if(memblock[i] != 0xFF)
|
||||
counter2++;
|
||||
}
|
||||
|
||||
mem_free(memblock);
|
||||
|
||||
if(counter1 <= 512 && counter2 <= 512)
|
||||
return 512;
|
||||
|
||||
if(counter1 <= 1024 && counter2 <= 1024)
|
||||
return 1024;
|
||||
|
||||
if(counter1 <= 2048 && counter2 <= 2048)
|
||||
return 2048;
|
||||
|
||||
return 4096;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -78,8 +131,9 @@ static errcode_t device_gekko_io_open(const char *name, int flags, io_channel *d
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct ext2_super_block * super = (struct ext2_super_block *) mem_alloc(SUPERBLOCK_SIZE); //1024 bytes
|
||||
if(!super)
|
||||
// Allocate 4 x max sector size in case of 4096 sector size
|
||||
u8 *buffer = (u8 *) mem_alloc(4 * MAX_SECTOR_SIZE);
|
||||
if(!buffer)
|
||||
{
|
||||
ext2_log_trace("no memory for superblock");
|
||||
errno = ENOMEM;
|
||||
@ -87,44 +141,49 @@ static errcode_t device_gekko_io_open(const char *name, int flags, io_channel *d
|
||||
}
|
||||
|
||||
// Check that there is a valid EXT boot sector at the start of the device
|
||||
if (!interface->readSectors(fd->startSector+SUPERBLOCK_OFFSET/BYTES_PER_SECTOR, SUPERBLOCK_SIZE/BYTES_PER_SECTOR, super))
|
||||
if (!interface->readSectors(fd->startSector, 4, buffer))
|
||||
{
|
||||
ext2_log_trace("read failure @ sector %d\n", fd->startSector);
|
||||
errno = EROFS;
|
||||
mem_free(super);
|
||||
mem_free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct ext2_super_block * super = (struct ext2_super_block *) (buffer + SUPERBLOCK_OFFSET);
|
||||
|
||||
if(ext2fs_le16_to_cpu(super->s_magic) != EXT2_SUPER_MAGIC)
|
||||
{
|
||||
mem_free(super);
|
||||
ext2_log_trace("super mismatch: read %04X - expected %04X\n", ext2fs_le16_to_cpu(super->s_magic), EXT2_SUPER_MAGIC);
|
||||
mem_free(buffer);
|
||||
errno = EROFS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Parse the boot sector
|
||||
fd->sectorSize = BYTES_PER_SECTOR;
|
||||
fd->offset = 0;
|
||||
fd->sectorCount = 0;
|
||||
|
||||
switch(ext2fs_le32_to_cpu(super->s_log_block_size))
|
||||
{
|
||||
case 1:
|
||||
fd->sectorCount = (sec_t) ((u64) ext2fs_le32_to_cpu(super->s_blocks_count) * (u64) 2048 / (u64) BYTES_PER_SECTOR);
|
||||
(*dev)->block_size = 2048;
|
||||
break;
|
||||
case 2:
|
||||
fd->sectorCount = (sec_t) ((u64) ext2fs_le32_to_cpu(super->s_blocks_count) * (u64) 4096 / (u64) BYTES_PER_SECTOR);
|
||||
(*dev)->block_size = 4096;
|
||||
break;
|
||||
case 3:
|
||||
fd->sectorCount = (sec_t) ((u64) ext2fs_le32_to_cpu(super->s_blocks_count) * (u64) 8192 / (u64) BYTES_PER_SECTOR);
|
||||
(*dev)->block_size = 8192;
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
fd->sectorCount = (sec_t) ((u64) ext2fs_le32_to_cpu(super->s_blocks_count) * (u64) 1024 / (u64) BYTES_PER_SECTOR);
|
||||
(*dev)->block_size = 1024;
|
||||
break;
|
||||
}
|
||||
|
||||
mem_free(super);
|
||||
|
||||
// Parse the boot sector
|
||||
fd->sectorSize = readSectorSize(interface);
|
||||
fd->offset = 0;
|
||||
fd->sectorCount = 0;
|
||||
fd->sectorCount = (sec_t) ((u64) ext2fs_le32_to_cpu(super->s_blocks_count) * (u64) ((*dev)->block_size) / (u64) fd->sectorSize);
|
||||
|
||||
mem_free(buffer);
|
||||
|
||||
// Create the cache
|
||||
fd->cache = cache_constructor(fd->cachePageCount, fd->cachePageSize, interface, fd->startSector + fd->sectorCount, fd->sectorSize);
|
@ -27,7 +27,7 @@
|
||||
#include "disc_cache.h"
|
||||
#include "ext2fs.h"
|
||||
|
||||
#define BYTES_PER_SECTOR 512
|
||||
#define MAX_SECTOR_SIZE (4096)
|
||||
|
||||
/**
|
||||
* gekko_fd - Gekko device driver descriptor
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -25,7 +26,6 @@
|
||||
#endif
|
||||
|
||||
#include "ext2_fs.h"
|
||||
#include "ext2fs.h"
|
||||
#include "ext2fsP.h"
|
||||
|
||||
struct ext2fs_struct_generic_bitmap {
|
||||
@ -179,8 +179,8 @@ int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
#ifndef OMIT_COM_ERR
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"test_bitmap(%lu)", (unsigned long) bitno);
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
|
||||
@ -201,8 +201,8 @@ int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
#ifndef OMIT_COM_ERR
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"mark_bitmap(%lu)", (unsigned long) bitno);
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
|
||||
@ -223,8 +223,8 @@ int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
#ifndef OMIT_COM_ERR
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"mark_bitmap(%lu)", (unsigned long) bitno);
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
|
||||
@ -244,8 +244,8 @@ __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
|
||||
#ifndef OMIT_COM_ERR
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"get_bitmap_start");
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bitmap->start;
|
||||
@ -261,8 +261,8 @@ __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
|
||||
#ifndef OMIT_COM_ERR
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"get_bitmap_end");
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return bitmap->end;
|
||||
}
|
||||
@ -278,8 +278,8 @@ void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
|
||||
#ifndef OMIT_COM_ERR
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"clear_generic_bitmap");
|
||||
return;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
memset(bitmap->bitmap, 0,
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -107,12 +108,14 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
|
||||
bitmap->end = end;
|
||||
bitmap->real_end = real_end;
|
||||
bitmap->bitmap_ops = ops;
|
||||
bitmap->cluster_bits = 0;
|
||||
switch (magic) {
|
||||
case EXT2_ET_MAGIC_INODE_BITMAP64:
|
||||
bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
|
||||
break;
|
||||
case EXT2_ET_MAGIC_BLOCK_BITMAP64:
|
||||
bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
|
||||
bitmap->cluster_bits = fs->cluster_ratio_bits;
|
||||
break;
|
||||
default:
|
||||
bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
|
||||
@ -191,6 +194,7 @@ errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
|
||||
new_bmap->real_end = src->real_end;
|
||||
new_bmap->bitmap_ops = src->bitmap_ops;
|
||||
new_bmap->base_error_code = src->base_error_code;
|
||||
new_bmap->cluster_bits = src->cluster_bits;
|
||||
|
||||
descr = src->description;
|
||||
if (descr) {
|
||||
@ -315,6 +319,8 @@ int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
if (!EXT2FS_IS_64_BITMAP(bitmap))
|
||||
return 0;
|
||||
|
||||
arg >>= bitmap->cluster_bits;
|
||||
|
||||
if ((arg < bitmap->start) || (arg > bitmap->end)) {
|
||||
warn_bitmap(bitmap, EXT2FS_MARK_ERROR, arg);
|
||||
return 0;
|
||||
@ -341,6 +347,8 @@ int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
if (!EXT2FS_IS_64_BITMAP(bitmap))
|
||||
return 0;
|
||||
|
||||
arg >>= bitmap->cluster_bits;
|
||||
|
||||
if ((arg < bitmap->start) || (arg > bitmap->end)) {
|
||||
warn_bitmap(bitmap, EXT2FS_UNMARK_ERROR, arg);
|
||||
return 0;
|
||||
@ -367,6 +375,8 @@ int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
if (!EXT2FS_IS_64_BITMAP(bitmap))
|
||||
return 0;
|
||||
|
||||
arg >>= bitmap->cluster_bits;
|
||||
|
||||
if ((arg < bitmap->start) || (arg > bitmap->end)) {
|
||||
warn_bitmap(bitmap, EXT2FS_TEST_ERROR, arg);
|
||||
return 0;
|
||||
@ -383,7 +393,7 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
|
||||
return EINVAL;
|
||||
|
||||
if (EXT2FS_IS_32_BITMAP(bmap)) {
|
||||
if ((start+num) & ~0xffffffffULL) {
|
||||
if ((start+num-1) & ~0xffffffffULL) {
|
||||
ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR,
|
||||
0xffffffff);
|
||||
return EINVAL;
|
||||
@ -406,7 +416,7 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
|
||||
return EINVAL;
|
||||
|
||||
if (EXT2FS_IS_32_BITMAP(bmap)) {
|
||||
if ((start+num) & ~0xffffffffULL) {
|
||||
if ((start+num-1) & ~0xffffffffULL) {
|
||||
ext2fs_warn_bitmap2(bmap,
|
||||
EXT2FS_UNMARK_ERROR, 0xffffffff);
|
||||
return EINVAL;
|
||||
@ -477,7 +487,7 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap,
|
||||
bmap, block);
|
||||
|
||||
if (EXT2FS_IS_32_BITMAP(bmap)) {
|
||||
if ((block+num) & ~0xffffffffULL) {
|
||||
if ((block+num-1) & ~0xffffffffULL) {
|
||||
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
|
||||
EXT2FS_UNMARK_ERROR, 0xffffffff);
|
||||
return EINVAL;
|
||||
@ -499,7 +509,7 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap,
|
||||
return;
|
||||
|
||||
if (EXT2FS_IS_32_BITMAP(bmap)) {
|
||||
if ((block+num) & ~0xffffffffULL) {
|
||||
if ((block+num-1) & ~0xffffffffULL) {
|
||||
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
|
||||
EXT2FS_UNMARK_ERROR, 0xffffffff);
|
||||
return;
|
||||
@ -527,7 +537,7 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
|
||||
return;
|
||||
|
||||
if (EXT2FS_IS_32_BITMAP(bmap)) {
|
||||
if ((block+num) & ~0xffffffffULL) {
|
||||
if ((block+num-1) & ~0xffffffffULL) {
|
||||
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
|
||||
EXT2FS_UNMARK_ERROR, 0xffffffff);
|
||||
return;
|
||||
@ -548,7 +558,7 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
|
||||
bmap->bitmap_ops->unmark_bmap_extent(bmap, block, num);
|
||||
}
|
||||
|
||||
int ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
|
||||
void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
|
||||
{
|
||||
#ifndef OMIT_COM_ERR
|
||||
if (bitmap && bitmap->description)
|
||||
@ -559,5 +569,47 @@ int ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
|
||||
com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP,
|
||||
"called %s with 64-bit bitmap", func);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
|
||||
ext2fs_block_bitmap *bitmap)
|
||||
{
|
||||
ext2fs_block_bitmap cmap, bmap;
|
||||
errcode_t retval;
|
||||
blk64_t i, b_end, c_end;
|
||||
int n, ratio;
|
||||
|
||||
bmap = *bitmap;
|
||||
|
||||
if (fs->cluster_ratio_bits == ext2fs_get_bitmap_granularity(bmap))
|
||||
return 0; /* Nothing to do */
|
||||
|
||||
retval = ext2fs_allocate_block_bitmap(fs, "converted cluster bitmap",
|
||||
&cmap);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
i = bmap->start;
|
||||
b_end = bmap->end;
|
||||
bmap->end = bmap->real_end;
|
||||
c_end = cmap->end;
|
||||
cmap->end = cmap->real_end;
|
||||
n = 0;
|
||||
ratio = 1 << fs->cluster_ratio_bits;
|
||||
while (i < bmap->real_end) {
|
||||
if (ext2fs_test_block_bitmap2(bmap, i)) {
|
||||
ext2fs_mark_block_bitmap2(cmap, i);
|
||||
i += ratio - n;
|
||||
n = 0;
|
||||
continue;
|
||||
}
|
||||
i++; n++;
|
||||
if (n >= ratio)
|
||||
n = 0;
|
||||
}
|
||||
bmap->end = b_end;
|
||||
cmap->end = c_end;
|
||||
ext2fs_free_block_bitmap(bmap);
|
||||
*bitmap = cmap;
|
||||
return 0;
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -13,6 +13,7 @@
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -45,11 +46,7 @@ errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#ifdef HAVE_OPEN64
|
||||
fd = open64(file, O_RDONLY);
|
||||
#else
|
||||
fd = open(file, O_RDONLY);
|
||||
#endif
|
||||
fd = ext2fs_open_file(file, O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
return errno;
|
||||
|
||||
@ -71,11 +68,7 @@ errcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#ifdef HAVE_OPEN64
|
||||
fd = open64(file, O_RDONLY);
|
||||
#else
|
||||
fd = open(file, O_RDONLY);
|
||||
#endif
|
||||
fd = ext2fs_open_file(file, O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
return errno;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define _LARGEFILE_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -142,10 +143,12 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
|
||||
blk64_t *retblocks)
|
||||
{
|
||||
int fd, rc = 0;
|
||||
int valid_blkgetsize64 = 1;
|
||||
#ifdef __linux__
|
||||
struct utsname ut;
|
||||
#endif
|
||||
unsigned long long size64;
|
||||
unsigned long size;
|
||||
ext2_loff_t high, low;
|
||||
#ifdef FDGETPRM
|
||||
struct floppy_struct this_floppy;
|
||||
@ -157,11 +160,7 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
|
||||
char ch;
|
||||
#endif /* HAVE_SYS_DISKLABEL_H */
|
||||
|
||||
#ifdef HAVE_OPEN64
|
||||
fd = open64(file, O_RDONLY);
|
||||
#else
|
||||
fd = open(file, O_RDONLY);
|
||||
#endif
|
||||
fd = ext2fs_open_file(file, O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
return errno;
|
||||
|
||||
@ -233,13 +232,9 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
|
||||
#endif /* HAVE_SYS_DISKLABEL_H */
|
||||
|
||||
{
|
||||
#ifdef HAVE_FSTAT64
|
||||
struct stat64 st;
|
||||
if (fstat64(fd, &st) == 0)
|
||||
#else
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == 0)
|
||||
#endif
|
||||
ext2fs_struct_stat st;
|
||||
|
||||
if (ext2fs_fstat(fd, &st) == 0)
|
||||
if (S_ISREG(st.st_mode)) {
|
||||
*retblocks = st.st_size / blocksize;
|
||||
goto out;
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -38,6 +39,7 @@ errcode_t ext2fs_iblk_add_blocks(ext2_filsys fs, struct ext2_inode *inode,
|
||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
|
||||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
|
||||
num_blocks *= fs->blocksize / 512;
|
||||
num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
|
||||
|
||||
b += num_blocks;
|
||||
|
||||
@ -61,6 +63,7 @@ errcode_t ext2fs_iblk_sub_blocks(ext2_filsys fs, struct ext2_inode *inode,
|
||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
|
||||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
|
||||
num_blocks *= fs->blocksize / 512;
|
||||
num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
|
||||
|
||||
if (num_blocks > b)
|
||||
return EOVERFLOW;
|
||||
@ -79,6 +82,7 @@ errcode_t ext2fs_iblk_set(ext2_filsys fs, struct ext2_inode *inode, blk64_t b)
|
||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
|
||||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
|
||||
b *= fs->blocksize / 512;
|
||||
b *= EXT2FS_CLUSTER_RATIO(fs);
|
||||
|
||||
inode->i_blocks = b & 0xFFFFFFFF;
|
||||
if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -179,6 +180,7 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
|
||||
ext2_icount_t icount;
|
||||
errcode_t retval;
|
||||
char *fn, uuid[40];
|
||||
ext2_ino_t num_inodes;
|
||||
int fd;
|
||||
|
||||
retval = alloc_icount(fs, flags, &icount);
|
||||
@ -192,8 +194,18 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
|
||||
sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
|
||||
fd = mkstemp(fn);
|
||||
|
||||
/*
|
||||
* This is an overestimate of the size that we will need; the
|
||||
* ideal value is the number of used inodes with a count
|
||||
* greater than 1. OTOH the times when we really need this is
|
||||
* with the backup programs that use lots of hard links, in
|
||||
* which case the number of inodes in use approaches the ideal
|
||||
* value.
|
||||
*/
|
||||
num_inodes = fs->super->s_inodes_count - fs->super->s_free_inodes_count;
|
||||
|
||||
icount->tdb_fn = fn;
|
||||
icount->tdb = tdb_open(fn, 0, TDB_CLEAR_IF_FIRST,
|
||||
icount->tdb = tdb_open(fn, num_inodes, TDB_NOLOCK | TDB_NOSYNC,
|
||||
O_RDWR | O_CREAT | O_TRUNC, 0600);
|
||||
if (icount->tdb) {
|
||||
close(fd);
|
||||
@ -363,31 +375,7 @@ static struct ext2_icount_el *get_icount_el(ext2_icount_t icount,
|
||||
low = 0;
|
||||
high = (int) icount->count-1;
|
||||
while (low <= high) {
|
||||
#if 0
|
||||
mid = (low+high)/2;
|
||||
#else
|
||||
if (low == high)
|
||||
mid = low;
|
||||
else {
|
||||
/* Interpolate for efficiency */
|
||||
lowval = icount->list[low].ino;
|
||||
highval = icount->list[high].ino;
|
||||
|
||||
if (ino < lowval)
|
||||
range = 0;
|
||||
else if (ino > highval)
|
||||
range = 1;
|
||||
else {
|
||||
range = ((float) (ino - lowval)) /
|
||||
(highval - lowval);
|
||||
if (range > 0.9)
|
||||
range = 0.9;
|
||||
if (range < 0.1)
|
||||
range = 0.1;
|
||||
}
|
||||
mid = low + ((int) (range * (high-low)));
|
||||
}
|
||||
#endif
|
||||
mid = ((unsigned)low + (unsigned)high) >> 1;
|
||||
if (ino == icount->list[mid].ino) {
|
||||
icount->cursor = mid+1;
|
||||
return &icount->list[mid];
|
@ -13,6 +13,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -91,9 +92,11 @@ errcode_t ext2fs_initialize(const char *name, int flags,
|
||||
unsigned int overhead = 0;
|
||||
unsigned int ipg;
|
||||
dgrp_t i;
|
||||
blk64_t free_blocks;
|
||||
blk_t numblocks;
|
||||
int rsv_gdt;
|
||||
int csum_flag;
|
||||
int bigalloc_flag;
|
||||
int io_flags;
|
||||
char *buf = 0;
|
||||
char c;
|
||||
@ -134,13 +137,26 @@ errcode_t ext2fs_initialize(const char *name, int flags,
|
||||
|
||||
#define set_field(field, default) (super->field = param->field ? \
|
||||
param->field : (default))
|
||||
#define assign_field(field) (super->field = param->field)
|
||||
|
||||
super->s_magic = EXT2_SUPER_MAGIC;
|
||||
super->s_state = EXT2_VALID_FS;
|
||||
|
||||
set_field(s_log_block_size, 0); /* default blocksize: 1024 bytes */
|
||||
set_field(s_log_cluster_size, 0);
|
||||
set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
|
||||
bigalloc_flag = EXT2_HAS_RO_COMPAT_FEATURE(param,
|
||||
EXT4_FEATURE_RO_COMPAT_BIGALLOC);
|
||||
|
||||
assign_field(s_log_block_size);
|
||||
|
||||
if (bigalloc_flag) {
|
||||
set_field(s_log_cluster_size, super->s_log_block_size+4);
|
||||
if (super->s_log_block_size > super->s_log_cluster_size) {
|
||||
retval = EXT2_ET_INVALID_ARGUMENT;
|
||||
goto cleanup;
|
||||
}
|
||||
} else
|
||||
super->s_log_cluster_size = super->s_log_block_size;
|
||||
|
||||
set_field(s_first_data_block, super->s_log_cluster_size ? 0 : 1);
|
||||
set_field(s_max_mnt_count, 0);
|
||||
set_field(s_errors, EXT2_ERRORS_DEFAULT);
|
||||
set_field(s_feature_compat, 0);
|
||||
@ -181,16 +197,39 @@ errcode_t ext2fs_initialize(const char *name, int flags,
|
||||
|
||||
super->s_creator_os = CREATOR_OS;
|
||||
|
||||
fs->blocksize = EXT2_BLOCK_SIZE(super);
|
||||
fs->clustersize = EXT2_CLUSTER_SIZE(super);
|
||||
fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(super);
|
||||
fs->cluster_ratio_bits = super->s_log_cluster_size -
|
||||
super->s_log_block_size;
|
||||
|
||||
/* default: (fs->blocksize*8) blocks/group, up to 2^16 (GDT limit) */
|
||||
set_field(s_blocks_per_group, fs->blocksize * 8);
|
||||
if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
|
||||
super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
|
||||
super->s_clusters_per_group = super->s_blocks_per_group;
|
||||
if (bigalloc_flag) {
|
||||
if (param->s_blocks_per_group &&
|
||||
param->s_clusters_per_group &&
|
||||
((param->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs)) !=
|
||||
param->s_blocks_per_group)) {
|
||||
retval = EXT2_ET_INVALID_ARGUMENT;
|
||||
goto cleanup;
|
||||
}
|
||||
if (param->s_clusters_per_group)
|
||||
assign_field(s_clusters_per_group);
|
||||
else if (param->s_blocks_per_group)
|
||||
super->s_clusters_per_group =
|
||||
param->s_blocks_per_group /
|
||||
EXT2FS_CLUSTER_RATIO(fs);
|
||||
else
|
||||
super->s_clusters_per_group = fs->blocksize * 8;
|
||||
if (super->s_clusters_per_group > EXT2_MAX_CLUSTERS_PER_GROUP(super))
|
||||
super->s_clusters_per_group = EXT2_MAX_CLUSTERS_PER_GROUP(super);
|
||||
super->s_blocks_per_group = EXT2FS_C2B(fs,
|
||||
super->s_clusters_per_group);
|
||||
} else {
|
||||
set_field(s_blocks_per_group, fs->blocksize * 8);
|
||||
if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
|
||||
super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
|
||||
super->s_clusters_per_group = super->s_blocks_per_group;
|
||||
}
|
||||
|
||||
ext2fs_blocks_count_set(super, ext2fs_blocks_count(param));
|
||||
ext2fs_blocks_count_set(super, ext2fs_blocks_count(param) &
|
||||
~((blk64_t) EXT2FS_CLUSTER_MASK(fs)));
|
||||
ext2fs_r_blocks_count_set(super, ext2fs_r_blocks_count(param));
|
||||
if (ext2fs_r_blocks_count(super) >= ext2fs_blocks_count(param)) {
|
||||
retval = EXT2_ET_INVALID_ARGUMENT;
|
||||
@ -209,7 +248,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
|
||||
}
|
||||
|
||||
retry:
|
||||
fs->group_desc_count = (blk_t) ext2fs_div64_ceil(
|
||||
fs->group_desc_count = (dgrp_t) ext2fs_div64_ceil(
|
||||
ext2fs_blocks_count(super) - super->s_first_data_block,
|
||||
EXT2_BLOCKS_PER_GROUP(super));
|
||||
if (fs->group_desc_count == 0) {
|
||||
@ -246,7 +285,7 @@ retry:
|
||||
*/
|
||||
ipg = ext2fs_div_ceil(super->s_inodes_count, fs->group_desc_count);
|
||||
if (ipg > fs->blocksize * 8) {
|
||||
if (super->s_blocks_per_group >= 256) {
|
||||
if (!bigalloc_flag && super->s_blocks_per_group >= 256) {
|
||||
/* Try again with slightly different parameters */
|
||||
super->s_blocks_per_group -= 8;
|
||||
ext2fs_blocks_count_set(super,
|
||||
@ -364,7 +403,7 @@ ipg_retry:
|
||||
|
||||
strcpy(buf, "block bitmap for ");
|
||||
strcat(buf, fs->device_name);
|
||||
retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
|
||||
retval = ext2fs_allocate_subcluster_bitmap(fs, buf, &fs->block_map);
|
||||
if (retval)
|
||||
goto cleanup;
|
||||
|
||||
@ -394,7 +433,7 @@ ipg_retry:
|
||||
* superblock and group descriptors (the inode tables and
|
||||
* bitmaps will be accounted for when allocated).
|
||||
*/
|
||||
ext2fs_free_blocks_count_set(super, 0);
|
||||
free_blocks = 0;
|
||||
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
||||
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
|
||||
for (i = 0; i < fs->group_desc_count; i++) {
|
||||
@ -416,14 +455,14 @@ ipg_retry:
|
||||
if (fs->super->s_log_groups_per_flex)
|
||||
numblocks += 2 + fs->inode_blocks_per_group;
|
||||
|
||||
ext2fs_free_blocks_count_set(super,
|
||||
ext2fs_free_blocks_count(super) +
|
||||
numblocks);
|
||||
free_blocks += numblocks;
|
||||
ext2fs_bg_free_blocks_count_set(fs, i, numblocks);
|
||||
ext2fs_bg_free_inodes_count_set(fs, i, fs->super->s_inodes_per_group);
|
||||
ext2fs_bg_used_dirs_count_set(fs, i, 0);
|
||||
ext2fs_group_desc_csum_set(fs, i);
|
||||
}
|
||||
free_blocks &= ~EXT2FS_CLUSTER_MASK(fs);
|
||||
ext2fs_free_blocks_count_set(super, free_blocks);
|
||||
|
||||
c = (char) 255;
|
||||
if (((int) c) == -1) {
|
72
portlibs/sources/libcustomext2fs/source/inline.c
Normal file
72
portlibs/sources/libcustomext2fs/source/inline.c
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* inline.c --- Includes the inlined functions defined in the header
|
||||
* files as standalone functions, in case the application program
|
||||
* is compiled with inlining turned off.
|
||||
*
|
||||
* Copyright (C) 1993, 1994 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include "ext2_fs.h"
|
||||
#define INCLUDE_INLINE_FUNCS
|
||||
#include "ext2fs.h"
|
||||
|
||||
#include "mem_allocate.h"
|
||||
|
||||
/*
|
||||
* We used to define this as an inline, but since we are now using
|
||||
* autoconf-defined #ifdef's, we need to export this as a
|
||||
* library-provided function exclusively.
|
||||
*/
|
||||
errcode_t ext2fs_get_memalign(unsigned long size,
|
||||
unsigned long align, void *ptr)
|
||||
{
|
||||
errcode_t retval;
|
||||
|
||||
if (align == 0)
|
||||
align = 8;
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
retval = posix_memalign((void **) ptr, align, size);
|
||||
if (retval) {
|
||||
if (retval == ENOMEM)
|
||||
return EXT2_ET_NO_MEMORY;
|
||||
return retval;
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_MEMALIGN
|
||||
void *pp;
|
||||
pp = mem_align(align, size);
|
||||
if (pp == NULL) {
|
||||
if (errno)
|
||||
return errno;
|
||||
else
|
||||
return EXT2_ET_NO_MEMORY;
|
||||
}
|
||||
memcpy(ptr, &pp, sizeof (pp));
|
||||
#else
|
||||
#error memalign or posix_memalign must be defined!
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -522,7 +523,8 @@ errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
|
||||
errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
|
||||
struct ext2_inode * inode, int bufsize)
|
||||
{
|
||||
unsigned long group, block, block_nr, offset;
|
||||
blk64_t block_nr;
|
||||
unsigned long group, block, offset;
|
||||
char *ptr;
|
||||
errcode_t retval;
|
||||
int clen, i, inodes_per_block, length;
|
||||
@ -628,7 +630,8 @@ errcode_t ext2fs_read_inode(ext2_filsys fs, ext2_ino_t ino,
|
||||
errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
|
||||
struct ext2_inode * inode, int bufsize)
|
||||
{
|
||||
unsigned long group, block, block_nr, offset;
|
||||
blk64_t block_nr;
|
||||
unsigned long group, block, offset;
|
||||
errcode_t retval = 0;
|
||||
struct ext2_inode_large temp_inode, *w_inode;
|
||||
char *ptr;
|
||||
@ -669,8 +672,10 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
|
||||
|
||||
if (length > (int) sizeof(struct ext2_inode_large)) {
|
||||
w_inode = malloc(length);
|
||||
if (!w_inode)
|
||||
return ENOMEM;
|
||||
if (!w_inode) {
|
||||
retval = ENOMEM;
|
||||
goto errout;
|
||||
}
|
||||
} else
|
||||
w_inode = &temp_inode;
|
||||
memset(w_inode, 0, length);
|
@ -10,6 +10,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
@ -163,7 +164,7 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel)
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
if (io->name)
|
||||
if (io && io->name)
|
||||
ext2fs_free_mem(&io->name);
|
||||
if (data)
|
||||
ext2fs_free_mem(&data);
|
@ -2,6 +2,7 @@
|
||||
* io_manager.c --- the I/O manager abstraction
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
@ -9,6 +9,7 @@
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user