1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* initialize.c --- initialize a filesystem handle given superblock
|
|
|
|
* parameters. Used by mke2fs when initializing a filesystem.
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-04-29 18:53:37 +04:00
|
|
|
* Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-04-29 20:17:09 +04:00
|
|
|
* %Begin-Header%
|
2010-05-18 05:31:56 +04:00
|
|
|
* This file may be redistributed under the terms of the GNU Library
|
|
|
|
* General Public License, version 2.
|
1997-04-29 20:17:09 +04:00
|
|
|
* %End-Header%
|
1997-04-26 17:21:57 +04:00
|
|
|
*/
|
|
|
|
|
2011-09-19 01:34:37 +04:00
|
|
|
#include "config.h"
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1997-08-11 03:07:40 +04:00
|
|
|
#if HAVE_UNISTD_H
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <unistd.h>
|
1997-08-11 03:07:40 +04:00
|
|
|
#endif
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <time.h>
|
1997-10-20 03:00:21 +04:00
|
|
|
#if HAVE_SYS_STAT_H
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <sys/stat.h>
|
1997-10-20 03:00:21 +04:00
|
|
|
#endif
|
|
|
|
#if HAVE_SYS_TYPES_H
|
1997-04-26 17:21:57 +04:00
|
|
|
#include <sys/types.h>
|
1997-10-20 03:00:21 +04:00
|
|
|
#endif
|
1997-04-26 17:21:57 +04:00
|
|
|
|
Many files:
inode.c (ext2fs_open_inode_scan): Initialize the group variables
so that we don't need to call get_next_blockgroup() the first
time around. Saves a bit of time, and prevents us from
needing to assign -1 to current_group (which is an unsigned
value).
icount.c (insert_icount_el): Cast the estimated number of inodes
from a float to an ino_t.
alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c,
bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c,
check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c,
dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c,
ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c,
icount.c, initialize.c, inline.c, inode.c, irel_ma.c,
ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c,
newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c,
rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c,
tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c,
version.c: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast
all assignments from void * to be compatible with C++.
closefs.c (ext2fs_flush): Add a call to io_channel_flush() to
make sure the contents of the disk are flushed to disk.
dblist.c (ext2fs_add_dir_block): Change new to be new_entry to
avoid C++ namespace clash.
bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to
avoid C++ namespace clash.
ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c,
irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c,
ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c,
unlink.c: Change private to be priv_data (to avoid C++
namespace clash)
1998-01-19 17:47:53 +03:00
|
|
|
#include "ext2_fs.h"
|
1997-04-26 17:21:57 +04:00
|
|
|
#include "ext2fs.h"
|
|
|
|
|
2003-07-06 08:36:48 +04:00
|
|
|
#if defined(__linux__) && defined(EXT2_OS_LINUX)
|
1997-04-26 17:58:21 +04:00
|
|
|
#define CREATOR_OS EXT2_OS_LINUX
|
2003-07-06 08:36:48 +04:00
|
|
|
#else
|
|
|
|
#if defined(__GNU__) && defined(EXT2_OS_HURD)
|
1997-04-26 17:58:21 +04:00
|
|
|
#define CREATOR_OS EXT2_OS_HURD
|
2003-07-06 08:36:48 +04:00
|
|
|
#else
|
|
|
|
#if defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD)
|
1997-04-26 17:58:21 +04:00
|
|
|
#define CREATOR_OS EXT2_OS_FREEBSD
|
2003-07-06 08:36:48 +04:00
|
|
|
#else
|
|
|
|
#if defined(LITES) && defined(EXT2_OS_LITES)
|
1997-04-26 17:58:21 +04:00
|
|
|
#define CREATOR_OS EXT2_OS_LITES
|
|
|
|
#else
|
|
|
|
#define CREATOR_OS EXT2_OS_LINUX /* by default */
|
2003-07-06 08:36:48 +04:00
|
|
|
#endif /* defined(LITES) && defined(EXT2_OS_LITES) */
|
|
|
|
#endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */
|
|
|
|
#endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */
|
|
|
|
#endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2004-12-15 22:39:16 +03:00
|
|
|
/*
|
|
|
|
* Calculate the number of GDT blocks to reserve for online filesystem growth.
|
|
|
|
* The absolute maximum number of GDT blocks we can reserve is determined by
|
|
|
|
* the number of block pointers that can fit into a single block.
|
|
|
|
*/
|
2006-03-18 04:39:52 +03:00
|
|
|
static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs)
|
2004-12-15 22:39:16 +03:00
|
|
|
{
|
|
|
|
struct ext2_super_block *sb = fs->super;
|
|
|
|
unsigned long bpg = sb->s_blocks_per_group;
|
2007-08-30 19:38:13 +04:00
|
|
|
unsigned int gdpb = EXT2_DESC_PER_BLOCK(sb);
|
2004-12-15 22:39:16 +03:00
|
|
|
unsigned long max_blocks = 0xffffffff;
|
|
|
|
unsigned long rsv_groups;
|
2006-03-18 04:39:52 +03:00
|
|
|
unsigned int rsv_gdb;
|
2004-12-15 22:39:16 +03:00
|
|
|
|
|
|
|
/* We set it at 1024x the current filesystem size, or
|
|
|
|
* the upper block count limit (2^32), whichever is lower.
|
|
|
|
*/
|
2009-09-08 04:46:34 +04:00
|
|
|
if (ext2fs_blocks_count(sb) < max_blocks / 1024)
|
|
|
|
max_blocks = ext2fs_blocks_count(sb) * 1024;
|
2010-06-13 17:00:00 +04:00
|
|
|
/*
|
|
|
|
* ext2fs_div64_ceil() is unnecessary because max_blocks is
|
|
|
|
* max _GDT_ blocks, which is limited to 32 bits.
|
|
|
|
*/
|
2006-08-30 09:57:00 +04:00
|
|
|
rsv_groups = ext2fs_div_ceil(max_blocks - sb->s_first_data_block, bpg);
|
|
|
|
rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - fs->desc_blocks;
|
2006-03-18 04:39:52 +03:00
|
|
|
if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb))
|
2004-12-15 22:39:16 +03:00
|
|
|
rsv_gdb = EXT2_ADDR_PER_BLOCK(sb);
|
2004-12-23 15:45:04 +03:00
|
|
|
#ifdef RES_GDT_DEBUG
|
2006-03-18 04:39:52 +03:00
|
|
|
printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %u\n",
|
2004-12-15 22:39:16 +03:00
|
|
|
max_blocks, rsv_groups, rsv_gdb);
|
2004-12-23 15:45:04 +03:00
|
|
|
#endif
|
2004-12-15 22:39:16 +03:00
|
|
|
|
|
|
|
return rsv_gdb;
|
|
|
|
}
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
errcode_t ext2fs_initialize(const char *name, int flags,
|
|
|
|
struct ext2_super_block *param,
|
|
|
|
io_manager manager, ext2_filsys *ret_fs)
|
|
|
|
{
|
|
|
|
ext2_filsys fs;
|
|
|
|
errcode_t retval;
|
|
|
|
struct ext2_super_block *super;
|
2003-12-07 09:28:50 +03:00
|
|
|
unsigned int rem;
|
|
|
|
unsigned int overhead = 0;
|
|
|
|
unsigned int ipg;
|
|
|
|
dgrp_t i;
|
2011-06-16 09:38:43 +04:00
|
|
|
blk64_t free_blocks;
|
Many files:
dosio.c: New file to do DOS/BIOS disk accesses.
namei.c (open_namei): Make pathlen be of type size_t.
llseek.c: Always #include stdlib.h since it's need to define
size_t.
io.h: Use errcode_t for magic numbers.
icount.c (get_icount_el), dupfs.c (ext2fs_dup_handle), dblist.c
(dir_block_cmp): Use size_t where appropriate.
read_bb.c (ext2fs_read_bb_inode), cmp_bitmaps.c
(ext2fs_compare_inode_bitmap): Use blk_t, ino_t and size_t
where appropriate.
closefs.c (ext2fs_flush): Use dgrp_t instead of int where
appropriate.
openfs.c (ext2fs_open), check_desc.c (ext2fs_check_desc): Use blk_t
instead of int where appropriate.
rw_bitmaps.c (read_bitmaps), irel_ma.c, inode.c (ext2fs_write_inode),
initialize.c (ext2fs_initialize): brel_ma.c: Fix to make be
16-bit safe.
link.c (ext2fs_link), unlink.c (ext2fs_unlink), lookup.c (lookup_proc),
ismounted.c (ext2fs_check_if_mounted), block.c (xlate_func):
Add #pragma argsused for Turbo C.
1997-08-12 00:29:22 +04:00
|
|
|
blk_t numblocks;
|
2004-12-15 22:39:16 +03:00
|
|
|
int rsv_gdt;
|
2008-04-21 09:29:01 +04:00
|
|
|
int csum_flag;
|
2011-06-11 02:57:22 +04:00
|
|
|
int bigalloc_flag;
|
2006-03-19 03:16:10 +03:00
|
|
|
int io_flags;
|
2012-07-29 21:34:01 +04:00
|
|
|
unsigned reserved_inos;
|
2008-07-11 22:42:57 +04:00
|
|
|
char *buf = 0;
|
2006-11-12 06:32:35 +03:00
|
|
|
char c;
|
2012-08-30 15:16:01 +04:00
|
|
|
double reserved_ratio;
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2009-09-08 04:46:34 +04:00
|
|
|
if (!param || !ext2fs_blocks_count(param))
|
1997-10-31 09:07:47 +03:00
|
|
|
return EXT2_ET_INVALID_ARGUMENT;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
memset(fs, 0, sizeof(struct struct_ext2_filsys));
|
1997-04-26 17:34:30 +04:00
|
|
|
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
|
ChangeLog, Makefile.in, swapfs.c, unix.c:
Makefile.in: Add message.c and swapfs.c to the list of source files to
build the make depend.
swapfs.c, unix.c: Only support the -s and -S options to e2fsck if
ENABLE_SWAPFS is defined.
Many files:
ext2fs.h, bitops.h, block.c, bmap.c, closefs.c, dirblock.c, inode.c,
native.c, openfs.c, rw_bitmaps.c, swapfs.c: Only include the
byte-swapping logic if ENABLE_SWAPFS is turned on or if we're on a
big-endian machine.
initialize.c (ext2fs_initialize):Use WORDS_BIGENDIAN directly to set
EXT2_FLAG_SWAP_BYTES, instead of using ext2fs_native_flag.
native.c (ext2fs_native_flag): Use WORDS_BIGENDIAN provided by
autoconf to determine whether or not return EXT2_FLAG_SWAP_BYTES.
2001-06-11 11:00:04 +04:00
|
|
|
fs->flags = flags | EXT2_FLAG_RW;
|
2001-12-24 17:40:00 +03:00
|
|
|
fs->umask = 022;
|
2011-12-16 20:26:00 +04:00
|
|
|
fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
|
ChangeLog, Makefile.in, swapfs.c, unix.c:
Makefile.in: Add message.c and swapfs.c to the list of source files to
build the make depend.
swapfs.c, unix.c: Only support the -s and -S options to e2fsck if
ENABLE_SWAPFS is defined.
Many files:
ext2fs.h, bitops.h, block.c, bmap.c, closefs.c, dirblock.c, inode.c,
native.c, openfs.c, rw_bitmaps.c, swapfs.c: Only include the
byte-swapping logic if ENABLE_SWAPFS is turned on or if we're on a
big-endian machine.
initialize.c (ext2fs_initialize):Use WORDS_BIGENDIAN directly to set
EXT2_FLAG_SWAP_BYTES, instead of using ext2fs_native_flag.
native.c (ext2fs_native_flag): Use WORDS_BIGENDIAN provided by
autoconf to determine whether or not return EXT2_FLAG_SWAP_BYTES.
2001-06-11 11:00:04 +04:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
fs->flags |= EXT2_FLAG_SWAP_BYTES;
|
|
|
|
#endif
|
2006-03-19 03:16:10 +03:00
|
|
|
io_flags = IO_FLAG_RW;
|
|
|
|
if (flags & EXT2_FLAG_EXCLUSIVE)
|
|
|
|
io_flags |= IO_FLAG_EXCLUSIVE;
|
2012-03-23 00:00:49 +04:00
|
|
|
if (flags & EXT2_FLAG_DIRECT_IO)
|
|
|
|
io_flags |= IO_FLAG_DIRECT_IO;
|
2006-03-19 03:16:10 +03:00
|
|
|
retval = manager->open(name, io_flags, &fs->io);
|
1997-04-26 17:21:57 +04:00
|
|
|
if (retval)
|
|
|
|
goto cleanup;
|
2004-07-29 05:11:48 +04:00
|
|
|
fs->image_io = fs->io;
|
1997-08-24 06:57:55 +04:00
|
|
|
fs->io->app_data = fs;
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
1997-04-26 17:21:57 +04:00
|
|
|
goto cleanup;
|
1997-10-26 06:41:24 +03:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
strcpy(fs->device_name, name);
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
1997-04-26 17:21:57 +04:00
|
|
|
goto cleanup;
|
1997-10-26 06:41:24 +03:00
|
|
|
fs->super = super;
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
memset(super, 0, SUPERBLOCK_SIZE);
|
|
|
|
|
|
|
|
#define set_field(field, default) (super->field = param->field ? \
|
|
|
|
param->field : (default))
|
2011-06-11 02:57:22 +04:00
|
|
|
#define assign_field(field) (super->field = param->field)
|
1997-04-26 17:21:57 +04:00
|
|
|
|
|
|
|
super->s_magic = EXT2_SUPER_MAGIC;
|
|
|
|
super->s_state = EXT2_VALID_FS;
|
|
|
|
|
2011-06-11 02:57:22 +04:00
|
|
|
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);
|
2011-02-18 00:55:15 +03:00
|
|
|
set_field(s_max_mnt_count, 0);
|
1997-04-26 17:21:57 +04:00
|
|
|
set_field(s_errors, EXT2_ERRORS_DEFAULT);
|
1997-04-30 01:26:48 +04:00
|
|
|
set_field(s_feature_compat, 0);
|
|
|
|
set_field(s_feature_incompat, 0);
|
|
|
|
set_field(s_feature_ro_compat, 0);
|
2011-02-18 00:56:17 +03:00
|
|
|
set_field(s_default_mount_opts, 0);
|
2002-10-20 08:38:57 +04:00
|
|
|
set_field(s_first_meta_bg, 0);
|
2008-02-19 06:56:25 +03:00
|
|
|
set_field(s_raid_stride, 0); /* default stride size: 0 */
|
|
|
|
set_field(s_raid_stripe_width, 0); /* default stripe width: 0 */
|
2008-04-22 16:27:01 +04:00
|
|
|
set_field(s_log_groups_per_flex, 0);
|
2008-01-27 03:06:35 +03:00
|
|
|
set_field(s_flags, 0);
|
2004-12-15 22:39:16 +03:00
|
|
|
if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
|
|
|
|
retval = EXT2_ET_UNSUPP_FEATURE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (super->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
|
|
|
|
retval = EXT2_ET_RO_UNSUPP_FEATURE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
1997-04-26 18:48:50 +04:00
|
|
|
|
|
|
|
set_field(s_rev_level, EXT2_GOOD_OLD_REV);
|
|
|
|
if (super->s_rev_level >= EXT2_DYNAMIC_REV) {
|
|
|
|
set_field(s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
|
|
|
|
set_field(s_inode_size, EXT2_GOOD_OLD_INODE_SIZE);
|
2008-04-21 00:02:13 +04:00
|
|
|
if (super->s_inode_size >= sizeof(struct ext2_inode_large)) {
|
|
|
|
int extra_isize = sizeof(struct ext2_inode_large) -
|
|
|
|
EXT2_GOOD_OLD_INODE_SIZE;
|
|
|
|
set_field(s_min_extra_isize, extra_isize);
|
|
|
|
set_field(s_want_extra_isize, extra_isize);
|
|
|
|
}
|
2008-04-23 07:18:37 +04:00
|
|
|
} else {
|
|
|
|
super->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
|
|
|
|
super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
|
1997-04-26 18:48:50 +04:00
|
|
|
}
|
|
|
|
|
2011-02-18 00:55:15 +03:00
|
|
|
set_field(s_checkinterval, 0);
|
2005-09-25 04:14:51 +04:00
|
|
|
super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
|
1997-04-26 17:21:57 +04:00
|
|
|
|
1997-04-26 17:58:21 +04:00
|
|
|
super->s_creator_os = CREATOR_OS;
|
1997-04-26 17:34:30 +04:00
|
|
|
|
2011-09-15 23:44:56 +04:00
|
|
|
fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(super);
|
2011-06-04 18:20:47 +04:00
|
|
|
fs->cluster_ratio_bits = super->s_log_cluster_size -
|
|
|
|
super->s_log_block_size;
|
2002-06-10 21:05:56 +04:00
|
|
|
|
2011-06-11 02:57:22 +04:00
|
|
|
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))
|
2011-10-04 07:11:25 +04:00
|
|
|
super->s_clusters_per_group = EXT2_MAX_CLUSTERS_PER_GROUP(super);
|
2011-06-11 02:57:22 +04:00
|
|
|
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;
|
|
|
|
}
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2011-06-11 02:57:22 +04:00
|
|
|
ext2fs_blocks_count_set(super, ext2fs_blocks_count(param) &
|
|
|
|
~((blk64_t) EXT2FS_CLUSTER_MASK(fs)));
|
2009-09-08 04:46:34 +04:00
|
|
|
ext2fs_r_blocks_count_set(super, ext2fs_r_blocks_count(param));
|
|
|
|
if (ext2fs_r_blocks_count(super) >= ext2fs_blocks_count(param)) {
|
1997-10-31 09:07:47 +03:00
|
|
|
retval = EXT2_ET_INVALID_ARGUMENT;
|
1997-04-26 17:34:30 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2012-10-17 18:57:32 +04:00
|
|
|
set_field(s_mmp_update_interval, 0);
|
|
|
|
|
ChangeLog, ext2_err.et.in, ext2fs.h, initialize.c, mkjournal.c, openfs.c:
initialize.c (ext2fs_initialize): Add support for initializing the
ext2 superblock for external journal devices. This basically means we
don't bother to allocate any block group descriptors.
openfs.c (ext2fs_open): Only open external journal devices if the new
flag EXT2_FLAG_JOURNAL_DEV_OK is passed to ext2fs_open. When opening
such devices, don't try to read the block group descriptors, since
they're not there.
ext2_err.et.in (EXT2_NO_JOURNAL_SB): Add new error code
mkjournal.c: Export a new function,
ext2fs_create_journal_superblock(), which allocates and returns a
buffer containing a journal superblock. This is needed by mke2fs to
create an external journal. Rewrote ext2fs_add_journal_device() so
that it no longer creates the external journal, but rather adds a
filesystem to an existing external journal. It handles all of the
UUID manipulation.
ext2fs.h: List the EXT3_FEATURE_JOURNAL_DEV as a flag supported by the
library. Define the EXT2_FLAG_JOURNAL_DEV_OK. Changed function
prototype for ext2fs_add_journal_device().
2001-01-16 09:56:14 +03:00
|
|
|
/*
|
|
|
|
* If we're creating an external journal device, we don't need
|
|
|
|
* to bother with the rest.
|
|
|
|
*/
|
2004-12-15 22:39:16 +03:00
|
|
|
if (super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
|
ChangeLog, ext2_err.et.in, ext2fs.h, initialize.c, mkjournal.c, openfs.c:
initialize.c (ext2fs_initialize): Add support for initializing the
ext2 superblock for external journal devices. This basically means we
don't bother to allocate any block group descriptors.
openfs.c (ext2fs_open): Only open external journal devices if the new
flag EXT2_FLAG_JOURNAL_DEV_OK is passed to ext2fs_open. When opening
such devices, don't try to read the block group descriptors, since
they're not there.
ext2_err.et.in (EXT2_NO_JOURNAL_SB): Add new error code
mkjournal.c: Export a new function,
ext2fs_create_journal_superblock(), which allocates and returns a
buffer containing a journal superblock. This is needed by mke2fs to
create an external journal. Rewrote ext2fs_add_journal_device() so
that it no longer creates the external journal, but rather adds a
filesystem to an existing external journal. It handles all of the
UUID manipulation.
ext2fs.h: List the EXT3_FEATURE_JOURNAL_DEV as a flag supported by the
library. Define the EXT2_FLAG_JOURNAL_DEV_OK. Changed function
prototype for ext2fs_add_journal_device().
2001-01-16 09:56:14 +03:00
|
|
|
fs->group_desc_count = 0;
|
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
*ret_fs = fs;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
retry:
|
2011-10-04 07:47:19 +04:00
|
|
|
fs->group_desc_count = (dgrp_t) ext2fs_div64_ceil(
|
2009-09-08 04:46:34 +04:00
|
|
|
ext2fs_blocks_count(super) - super->s_first_data_block,
|
|
|
|
EXT2_BLOCKS_PER_GROUP(super));
|
2004-12-15 22:39:16 +03:00
|
|
|
if (fs->group_desc_count == 0) {
|
|
|
|
retval = EXT2_ET_TOOSMALL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-06-13 17:00:00 +04:00
|
|
|
|
|
|
|
if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
|
|
|
|
super->s_desc_size = EXT2_MIN_DESC_SIZE_64BIT;
|
|
|
|
|
2006-08-30 09:57:00 +04:00
|
|
|
fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
|
|
|
|
EXT2_DESC_PER_BLOCK(super));
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2002-05-16 13:20:07 +04:00
|
|
|
i = fs->blocksize >= 4096 ? 1 : 4096 / fs->blocksize;
|
2010-06-13 17:00:00 +04:00
|
|
|
|
|
|
|
if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT &&
|
|
|
|
(ext2fs_blocks_count(super) / i) > (1ULL << 32))
|
|
|
|
set_field(s_inodes_count, ~0U);
|
|
|
|
else
|
|
|
|
set_field(s_inodes_count, ext2fs_blocks_count(super) / i);
|
1997-04-26 17:21:57 +04:00
|
|
|
|
1998-09-23 04:27:26 +04:00
|
|
|
/*
|
|
|
|
* Make sure we have at least EXT2_FIRST_INO + 1 inodes, so
|
|
|
|
* that we have enough inodes for the filesystem(!)
|
|
|
|
*/
|
1999-01-04 11:50:59 +03:00
|
|
|
if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1)
|
|
|
|
super->s_inodes_count = EXT2_FIRST_INODE(super)+1;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* There should be at least as many inodes as the user
|
|
|
|
* requested. Figure out how many inodes per group that
|
1997-04-26 17:58:21 +04:00
|
|
|
* should be. But make sure that we don't allocate more than
|
2002-06-10 21:05:56 +04:00
|
|
|
* one bitmap's worth of inodes each group.
|
1997-04-26 17:21:57 +04:00
|
|
|
*/
|
2006-08-30 09:57:00 +04:00
|
|
|
ipg = ext2fs_div_ceil(super->s_inodes_count, fs->group_desc_count);
|
2003-01-20 05:01:22 +03:00
|
|
|
if (ipg > fs->blocksize * 8) {
|
2011-06-11 02:57:22 +04:00
|
|
|
if (!bigalloc_flag && super->s_blocks_per_group >= 256) {
|
2003-01-20 05:01:22 +03:00
|
|
|
/* Try again with slightly different parameters */
|
|
|
|
super->s_blocks_per_group -= 8;
|
2009-09-08 04:46:34 +04:00
|
|
|
ext2fs_blocks_count_set(super,
|
|
|
|
ext2fs_blocks_count(param));
|
2011-02-26 05:43:54 +03:00
|
|
|
super->s_clusters_per_group = super->s_blocks_per_group;
|
2003-01-20 05:01:22 +03:00
|
|
|
goto retry;
|
2008-08-23 15:41:07 +04:00
|
|
|
} else {
|
|
|
|
retval = EXT2_ET_TOO_MANY_INODES;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2003-01-20 05:01:22 +03:00
|
|
|
}
|
2002-06-10 21:05:56 +04:00
|
|
|
|
2003-12-07 09:28:50 +03:00
|
|
|
if (ipg > (unsigned) EXT2_MAX_INODES_PER_GROUP(super))
|
2002-06-10 21:05:56 +04:00
|
|
|
ipg = EXT2_MAX_INODES_PER_GROUP(super);
|
|
|
|
|
2006-09-12 22:56:17 +04:00
|
|
|
ipg_retry:
|
2002-06-10 21:05:56 +04:00
|
|
|
super->s_inodes_per_group = ipg;
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* Make sure the number of inodes per group completely fills
|
|
|
|
* the inode table blocks in the descriptor. If not, add some
|
|
|
|
* additional inodes/group. Waste not, want not...
|
|
|
|
*/
|
1997-04-26 18:48:50 +04:00
|
|
|
fs->inode_blocks_per_group = (((super->s_inodes_per_group *
|
|
|
|
EXT2_INODE_SIZE(super)) +
|
|
|
|
EXT2_BLOCK_SIZE(super) - 1) /
|
|
|
|
EXT2_BLOCK_SIZE(super));
|
|
|
|
super->s_inodes_per_group = ((fs->inode_blocks_per_group *
|
|
|
|
EXT2_BLOCK_SIZE(super)) /
|
|
|
|
EXT2_INODE_SIZE(super));
|
|
|
|
/*
|
|
|
|
* Finally, make sure the number of inodes per group is a
|
|
|
|
* multiple of 8. This is needed to simplify the bitmap
|
|
|
|
* splicing code.
|
|
|
|
*/
|
2011-05-09 19:38:42 +04:00
|
|
|
if (super->s_inodes_per_group < 8)
|
|
|
|
super->s_inodes_per_group = 8;
|
1997-04-26 18:48:50 +04:00
|
|
|
super->s_inodes_per_group &= ~7;
|
|
|
|
fs->inode_blocks_per_group = (((super->s_inodes_per_group *
|
|
|
|
EXT2_INODE_SIZE(super)) +
|
|
|
|
EXT2_BLOCK_SIZE(super) - 1) /
|
|
|
|
EXT2_BLOCK_SIZE(super));
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* adjust inode count to reflect the adjusted inodes_per_group
|
|
|
|
*/
|
2006-09-12 22:56:17 +04:00
|
|
|
if ((__u64)super->s_inodes_per_group * fs->group_desc_count > ~0U) {
|
|
|
|
ipg--;
|
|
|
|
goto ipg_retry;
|
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
super->s_inodes_count = super->s_inodes_per_group *
|
|
|
|
fs->group_desc_count;
|
|
|
|
super->s_free_inodes_count = super->s_inodes_count;
|
|
|
|
|
2004-12-15 22:39:16 +03:00
|
|
|
/*
|
|
|
|
* check the number of reserved group descriptor table blocks
|
|
|
|
*/
|
|
|
|
if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)
|
|
|
|
rsv_gdt = calc_reserved_gdt_blocks(fs);
|
|
|
|
else
|
|
|
|
rsv_gdt = 0;
|
|
|
|
set_field(s_reserved_gdt_blocks, rsv_gdt);
|
|
|
|
if (super->s_reserved_gdt_blocks > EXT2_ADDR_PER_BLOCK(super)) {
|
|
|
|
retval = EXT2_ET_RES_GDT_BLOCKS;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
1997-04-29 21:57:00 +04:00
|
|
|
/*
|
2007-07-22 23:07:13 +04:00
|
|
|
* Calculate the maximum number of bookkeeping blocks per
|
|
|
|
* group. It includes the superblock, the block group
|
|
|
|
* descriptors, the block bitmap, the inode bitmap, the inode
|
|
|
|
* table, and the reserved gdt blocks.
|
1997-04-29 21:57:00 +04:00
|
|
|
*/
|
2007-07-22 23:07:13 +04:00
|
|
|
overhead = (int) (3 + fs->inode_blocks_per_group +
|
|
|
|
fs->desc_blocks + super->s_reserved_gdt_blocks);
|
2003-01-20 05:01:22 +03:00
|
|
|
|
|
|
|
/* This can only happen if the user requested too many inodes */
|
2008-08-23 15:41:07 +04:00
|
|
|
if (overhead > super->s_blocks_per_group) {
|
|
|
|
retval = EXT2_ET_TOO_MANY_INODES;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2003-01-20 05:01:22 +03:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* See if the last group is big enough to support the
|
|
|
|
* necessary data structures. If not, we need to get rid of
|
2007-07-22 23:07:13 +04:00
|
|
|
* it. We need to recalculate the overhead for the last block
|
|
|
|
* group, since it might or might not have a superblock
|
|
|
|
* backup.
|
1997-04-26 17:21:57 +04:00
|
|
|
*/
|
2007-07-22 23:07:13 +04:00
|
|
|
overhead = (int) (2 + fs->inode_blocks_per_group);
|
|
|
|
if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1))
|
|
|
|
overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks;
|
2009-09-08 04:46:34 +04:00
|
|
|
rem = ((ext2fs_blocks_count(super) - super->s_first_data_block) %
|
2003-12-07 09:28:50 +03:00
|
|
|
super->s_blocks_per_group);
|
2008-08-23 15:41:07 +04:00
|
|
|
if ((fs->group_desc_count == 1) && rem && (rem < overhead)) {
|
|
|
|
retval = EXT2_ET_TOOSMALL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
1997-04-26 17:21:57 +04:00
|
|
|
if (rem && (rem < overhead+50)) {
|
2009-09-08 04:46:34 +04:00
|
|
|
ext2fs_blocks_count_set(super, ext2fs_blocks_count(super) -
|
|
|
|
rem);
|
2012-08-30 15:16:01 +04:00
|
|
|
/*
|
|
|
|
* If blocks count is changed, we need to recalculate
|
|
|
|
* reserved blocks count not to exceed 50%.
|
|
|
|
*/
|
|
|
|
reserved_ratio = 100.0 * ext2fs_r_blocks_count(param) /
|
|
|
|
ext2fs_blocks_count(param);
|
|
|
|
ext2fs_r_blocks_count_set(super, reserved_ratio *
|
|
|
|
ext2fs_blocks_count(super) / 100.0);
|
2009-09-08 04:46:34 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point we know how big the filesystem will be. So
|
|
|
|
* we can do any and all allocations that depend on the block
|
|
|
|
* count.
|
|
|
|
*/
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
1997-04-26 17:34:30 +04:00
|
|
|
goto cleanup;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2008-08-22 18:37:18 +04:00
|
|
|
strcpy(buf, "block bitmap for ");
|
|
|
|
strcat(buf, fs->device_name);
|
2011-06-11 02:57:22 +04:00
|
|
|
retval = ext2fs_allocate_subcluster_bitmap(fs, buf, &fs->block_map);
|
1997-04-26 17:21:57 +04:00
|
|
|
if (retval)
|
|
|
|
goto cleanup;
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2008-08-22 18:37:18 +04:00
|
|
|
strcpy(buf, "inode bitmap for ");
|
|
|
|
strcat(buf, fs->device_name);
|
1997-04-29 19:29:49 +04:00
|
|
|
retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
|
1997-04-26 17:21:57 +04:00
|
|
|
if (retval)
|
|
|
|
goto cleanup;
|
|
|
|
|
2003-08-01 17:41:07 +04:00
|
|
|
ext2fs_free_mem(&buf);
|
1997-04-26 17:34:30 +04:00
|
|
|
|
2007-11-10 03:01:06 +03:00
|
|
|
retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
|
2003-08-01 17:41:07 +04:00
|
|
|
&fs->group_desc);
|
1997-10-26 06:41:24 +03:00
|
|
|
if (retval)
|
1997-04-26 17:21:57 +04:00
|
|
|
goto cleanup;
|
1997-10-26 06:41:24 +03:00
|
|
|
|
Many files:
dosio.c: New file to do DOS/BIOS disk accesses.
namei.c (open_namei): Make pathlen be of type size_t.
llseek.c: Always #include stdlib.h since it's need to define
size_t.
io.h: Use errcode_t for magic numbers.
icount.c (get_icount_el), dupfs.c (ext2fs_dup_handle), dblist.c
(dir_block_cmp): Use size_t where appropriate.
read_bb.c (ext2fs_read_bb_inode), cmp_bitmaps.c
(ext2fs_compare_inode_bitmap): Use blk_t, ino_t and size_t
where appropriate.
closefs.c (ext2fs_flush): Use dgrp_t instead of int where
appropriate.
openfs.c (ext2fs_open), check_desc.c (ext2fs_check_desc): Use blk_t
instead of int where appropriate.
rw_bitmaps.c (read_bitmaps), irel_ma.c, inode.c (ext2fs_write_inode),
initialize.c (ext2fs_initialize): brel_ma.c: Fix to make be
16-bit safe.
link.c (ext2fs_link), unlink.c (ext2fs_unlink), lookup.c (lookup_proc),
ismounted.c (ext2fs_check_if_mounted), block.c (xlate_func):
Add #pragma argsused for Turbo C.
1997-08-12 00:29:22 +04:00
|
|
|
memset(fs->group_desc, 0, (size_t) fs->desc_blocks * fs->blocksize);
|
1997-04-26 17:21:57 +04:00
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
/*
|
|
|
|
* Reserve the superblock and group descriptors for each
|
|
|
|
* group, and fill in the correct group statistics for group.
|
|
|
|
* Note that although the block bitmap, inode bitmap, and
|
|
|
|
* inode table have not been allocated (and in fact won't be
|
|
|
|
* by this routine), they are accounted for nevertheless.
|
2008-04-22 16:27:01 +04:00
|
|
|
*
|
|
|
|
* If FLEX_BG meta-data grouping is used, only account for the
|
|
|
|
* superblock and group descriptors (the inode tables and
|
|
|
|
* bitmaps will be accounted for when allocated).
|
1997-04-26 17:34:30 +04:00
|
|
|
*/
|
2011-06-16 09:38:43 +04:00
|
|
|
free_blocks = 0;
|
2008-04-21 09:29:01 +04:00
|
|
|
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
|
|
|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
|
2012-07-29 21:34:01 +04:00
|
|
|
reserved_inos = super->s_first_ino;
|
1997-04-26 17:21:57 +04:00
|
|
|
for (i = 0; i < fs->group_desc_count; i++) {
|
2008-04-21 09:29:01 +04:00
|
|
|
/*
|
|
|
|
* Don't set the BLOCK_UNINIT group for the last group
|
|
|
|
* because the block bitmap needs to be padded.
|
|
|
|
*/
|
|
|
|
if (csum_flag) {
|
|
|
|
if (i != fs->group_desc_count - 1)
|
libext2fs: clean up ext2fs_bg_flags_ interfaces
The ext2fs_bg_flag* functions were confusing.
Currently we have this:
void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);
(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)
and these, which can twiddle individual bits in bg_flags:
void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
A better interface, after the patch below, is just:
ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */
and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:41:32 +03:00
|
|
|
ext2fs_bg_flags_set(fs, i,
|
|
|
|
EXT2_BG_BLOCK_UNINIT);
|
|
|
|
ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
|
2008-04-23 07:18:37 +04:00
|
|
|
numblocks = super->s_inodes_per_group;
|
2012-07-29 21:34:01 +04:00
|
|
|
if (reserved_inos) {
|
|
|
|
if (numblocks > reserved_inos) {
|
|
|
|
numblocks -= reserved_inos;
|
|
|
|
reserved_inos = 0;
|
|
|
|
} else {
|
|
|
|
reserved_inos -= numblocks;
|
|
|
|
numblocks = 0;
|
|
|
|
}
|
|
|
|
}
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
ext2fs_bg_itable_unused_set(fs, i, numblocks);
|
2008-04-21 09:29:01 +04:00
|
|
|
}
|
2003-11-21 17:02:21 +03:00
|
|
|
numblocks = ext2fs_reserve_super_and_bgd(fs, i, fs->block_map);
|
2008-04-22 16:27:01 +04:00
|
|
|
if (fs->super->s_log_groups_per_flex)
|
|
|
|
numblocks += 2 + fs->inode_blocks_per_group;
|
2003-11-21 17:02:21 +03:00
|
|
|
|
2011-06-16 09:38:43 +04:00
|
|
|
free_blocks += numblocks;
|
Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-26 04:43:47 +03:00
|
|
|
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);
|
2007-10-22 06:03:25 +04:00
|
|
|
ext2fs_group_desc_csum_set(fs, i);
|
1997-04-26 17:21:57 +04:00
|
|
|
}
|
2011-06-16 09:38:43 +04:00
|
|
|
free_blocks &= ~EXT2FS_CLUSTER_MASK(fs);
|
|
|
|
ext2fs_free_blocks_count_set(super, free_blocks);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2006-11-12 06:32:35 +03:00
|
|
|
c = (char) 255;
|
|
|
|
if (((int) c) == -1) {
|
|
|
|
super->s_flags |= EXT2_FLAGS_SIGNED_HASH;
|
|
|
|
} else {
|
|
|
|
super->s_flags |= EXT2_FLAGS_UNSIGNED_HASH;
|
|
|
|
}
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
ext2fs_mark_super_dirty(fs);
|
|
|
|
ext2fs_mark_bb_dirty(fs);
|
|
|
|
ext2fs_mark_ib_dirty(fs);
|
2008-08-28 07:07:54 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
io_channel_set_blksize(fs->io, fs->blocksize);
|
|
|
|
|
|
|
|
*ret_fs = fs;
|
|
|
|
return 0;
|
|
|
|
cleanup:
|
2009-02-23 20:07:50 +03:00
|
|
|
free(buf);
|
1997-04-26 17:21:57 +04:00
|
|
|
ext2fs_free(fs);
|
|
|
|
return retval;
|
|
|
|
}
|