mirror of
https://github.com/sheumann/hush.git
synced 2024-08-21 11:28:57 +00:00
mke2fs.c can compiled for me, more bb_xstrdup and bb_xasprintf usage, remove 1 exporing, ext2fs_llseek/blkid_llseek->llseek
This commit is contained in:
parent
54deebf4e4
commit
b71e6024f9
@ -25,29 +25,29 @@ srcdir=$(top_srcdir)/e2fsprogs
|
|||||||
|
|
||||||
E2FSPROGS_CFLAGS := -I$(srcdir) -include $(srcdir)/e2fsbb.h
|
E2FSPROGS_CFLAGS := -I$(srcdir) -include $(srcdir)/e2fsbb.h
|
||||||
|
|
||||||
BLKID_SRC := cache.c dev.c devname.c devno.c getsize.c llseek.c probe.c \
|
BLKID_SRC := cache.c dev.c devname.c devno.c blkid_getsize.c \
|
||||||
read.c resolve.c save.c tag.c resolve.c
|
probe.c read.c resolve.c save.c tag.c resolve.c
|
||||||
BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC))
|
BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC))
|
||||||
BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS))
|
BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS))
|
||||||
|
|
||||||
E2P_SRC := fgetsetflags.c fgetsetversion.c pf.c iod.c mntopts.c \
|
E2P_SRC := fgetsetflags.c fgetsetversion.c pf.c iod.c mntopts.c \
|
||||||
feature.c ls.c uuid.c pe.c ostype.c ps.c hashstr.c \
|
feature.c ls.c uuid.c pe.c ostype.c ps.c hashstr.c \
|
||||||
parse_num.c
|
parse_num.c
|
||||||
E2P_SRCS := $(patsubst %,e2p/%, $(E2P_SRC))
|
E2P_SRCS := $(patsubst %,e2p/%, $(E2P_SRC))
|
||||||
E2P_OBJS := $(patsubst %.c,%.o, $(E2P_SRCS))
|
E2P_OBJS := $(patsubst %.c,%.o, $(E2P_SRCS))
|
||||||
|
|
||||||
EXT2FS_SRC := gen_bitmap.c bitops.c ismounted.c mkjournal.c unix_io.c \
|
EXT2FS_SRC := gen_bitmap.c bitops.c ismounted.c mkjournal.c unix_io.c \
|
||||||
llseek.c rw_bitmaps.c initialize.c bitmaps.c block.c \
|
rw_bitmaps.c initialize.c bitmaps.c block.c \
|
||||||
ind_block.c inode.c freefs.c alloc_stats.c closefs.c \
|
ind_block.c inode.c freefs.c alloc_stats.c closefs.c \
|
||||||
openfs.c io_manager.c finddev.c read_bb.c alloc.c badblocks.c \
|
openfs.c io_manager.c finddev.c read_bb.c alloc.c badblocks.c \
|
||||||
getsize.c getsectsize.c alloc_tables.c read_bb_file.c mkdir.c \
|
getsize.c getsectsize.c alloc_tables.c read_bb_file.c mkdir.c \
|
||||||
bb_inode.c newdir.c alloc_sb.c lookup.c dirblock.c expanddir.c \
|
bb_inode.c newdir.c alloc_sb.c lookup.c dirblock.c expanddir.c \
|
||||||
dir_iterate.c link.c res_gdt.c
|
dir_iterate.c link.c res_gdt.c
|
||||||
EXT2FS_SRCS := $(patsubst %,ext2fs/%, $(EXT2FS_SRC))
|
EXT2FS_SRCS := $(patsubst %,ext2fs/%, $(EXT2FS_SRC))
|
||||||
EXT2FS_OBJS := $(patsubst %.c,%.o, $(EXT2FS_SRCS))
|
EXT2FS_OBJS := $(patsubst %.c,%.o, $(EXT2FS_SRCS))
|
||||||
|
|
||||||
UUID_SRC := compare.c gen_uuid.c pack.c parse.c unpack.c unparse.c \
|
UUID_SRC := compare.c gen_uuid.c pack.c parse.c unpack.c unparse.c \
|
||||||
uuid_time.c
|
uuid_time.c
|
||||||
UUID_SRCS := $(patsubst %,uuid/%, $(UUID_SRC))
|
UUID_SRCS := $(patsubst %,uuid/%, $(UUID_SRC))
|
||||||
UUID_OBJS := $(patsubst %.c,%.o, $(UUID_SRCS))
|
UUID_OBJS := $(patsubst %.c,%.o, $(UUID_SRCS))
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ struct blkid_struct_cache
|
|||||||
struct list_head bic_devs; /* List head of all devices */
|
struct list_head bic_devs; /* List head of all devices */
|
||||||
struct list_head bic_tags; /* List head of all tag types */
|
struct list_head bic_tags; /* List head of all tag types */
|
||||||
time_t bic_time; /* Last probe time */
|
time_t bic_time; /* Last probe time */
|
||||||
time_t bic_ftime; /* Mod time of the cachefile */
|
time_t bic_ftime; /* Mod time of the cachefile */
|
||||||
unsigned int bic_flags; /* Status flags of the cache */
|
unsigned int bic_flags; /* Status flags of the cache */
|
||||||
char *bic_filename; /* filename of cache */
|
char *bic_filename; /* filename of cache */
|
||||||
};
|
};
|
||||||
@ -141,7 +141,7 @@ extern const char *blkid_devdirs[];
|
|||||||
|
|
||||||
#ifdef CONFIG_BLKID_DEBUG
|
#ifdef CONFIG_BLKID_DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
extern int blkid_debug_mask;
|
extern int blkid_debug_mask;
|
||||||
#define DBG(m,x) if ((m) & blkid_debug_mask) x;
|
#define DBG(m,x) if ((m) & blkid_debug_mask) x;
|
||||||
#else
|
#else
|
||||||
#define DBG(m,x)
|
#define DBG(m,x)
|
||||||
@ -152,7 +152,7 @@ static inline void DEB_DUMP_TAG(int mask, blkid_tag tag)
|
|||||||
{
|
{
|
||||||
if (!(mask & blkid_debug_mask))
|
if (!(mask & blkid_debug_mask))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
printf(" tag: NULL\n");
|
printf(" tag: NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -167,7 +167,7 @@ static inline void DEB_DUMP_DEV(int mask, blkid_dev dev)
|
|||||||
|
|
||||||
if (!(mask & blkid_debug_mask))
|
if (!(mask & blkid_debug_mask))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
printf(" dev: NULL\n");
|
printf(" dev: NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -210,7 +210,12 @@ static inline void DEB_DUMP_CACHE(int mask, blkid_cache cache)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* lseek.c */
|
/* lseek.c */
|
||||||
extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence);
|
/* extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence); */
|
||||||
|
#ifdef CONFIG_LFS
|
||||||
|
# define blkid_llseek lseek64
|
||||||
|
#else
|
||||||
|
# define blkid_llseek lseek
|
||||||
|
#endif
|
||||||
|
|
||||||
/* read.c */
|
/* read.c */
|
||||||
extern void blkid_read_cache(blkid_cache cache);
|
extern void blkid_read_cache(blkid_cache cache);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* io.h --- the I/O manager abstraction
|
* io.h --- the I/O manager abstraction
|
||||||
*
|
*
|
||||||
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
@ -22,7 +22,12 @@ typedef long ext2_loff_t;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* llseek.c */
|
/* llseek.c */
|
||||||
ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
|
/* ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int); */
|
||||||
|
#ifdef CONFIG_LFS
|
||||||
|
# define ext2fs_llseek lseek64
|
||||||
|
#else
|
||||||
|
# define ext2fs_llseek lseek
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct struct_io_manager *io_manager;
|
typedef struct struct_io_manager *io_manager;
|
||||||
typedef struct struct_io_channel *io_channel;
|
typedef struct struct_io_channel *io_channel;
|
||||||
@ -40,8 +45,8 @@ struct struct_io_channel {
|
|||||||
void *data,
|
void *data,
|
||||||
size_t size,
|
size_t size,
|
||||||
int actual_bytes_read,
|
int actual_bytes_read,
|
||||||
errcode_t error);
|
errcode_t error);
|
||||||
errcode_t (*write_error)(io_channel channel,
|
errcode_t (*write_error)(io_channel channel,
|
||||||
unsigned long block,
|
unsigned long block,
|
||||||
int count,
|
int count,
|
||||||
const void *data,
|
const void *data,
|
||||||
@ -68,9 +73,9 @@ struct struct_io_manager {
|
|||||||
errcode_t (*flush)(io_channel channel);
|
errcode_t (*flush)(io_channel channel);
|
||||||
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
|
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
|
||||||
int count, const void *data);
|
int count, const void *data);
|
||||||
errcode_t (*set_option)(io_channel channel, const char *option,
|
errcode_t (*set_option)(io_channel channel, const char *option,
|
||||||
const char *arg);
|
const char *arg);
|
||||||
int reserved[14];
|
int reserved[14];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IO_FLAG_RW 1
|
#define IO_FLAG_RW 1
|
||||||
@ -78,17 +83,17 @@ struct struct_io_manager {
|
|||||||
/*
|
/*
|
||||||
* Convenience functions....
|
* Convenience functions....
|
||||||
*/
|
*/
|
||||||
#define io_channel_close(c) ((c)->manager->close((c)))
|
#define io_channel_close(c) ((c)->manager->close((c)))
|
||||||
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
|
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
|
||||||
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
|
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
|
||||||
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
|
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
|
||||||
#define io_channel_flush(c) ((c)->manager->flush((c)))
|
#define io_channel_flush(c) ((c)->manager->flush((c)))
|
||||||
#define io_channel_bumpcount(c) ((c)->refcount++)
|
#define io_channel_bumpcount(c) ((c)->refcount++)
|
||||||
|
|
||||||
/* io_manager.c */
|
/* io_manager.c */
|
||||||
extern errcode_t io_channel_set_options(io_channel channel,
|
extern errcode_t io_channel_set_options(io_channel channel,
|
||||||
const char *options);
|
const char *options);
|
||||||
extern errcode_t io_channel_write_byte(io_channel channel,
|
extern errcode_t io_channel_write_byte(io_channel channel,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
int count, const void *data);
|
int count, const void *data);
|
||||||
|
|
||||||
@ -105,4 +110,4 @@ extern void (*test_io_cb_set_blksize)
|
|||||||
(int blksize, errcode_t err);
|
(int blksize, errcode_t err);
|
||||||
|
|
||||||
#endif /* _EXT2FS_EXT2_IO_H */
|
#endif /* _EXT2FS_EXT2_IO_H */
|
||||||
|
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* llseek.c -- stub calling the llseek system call
|
|
||||||
*
|
|
||||||
* Copyright (C) 1994, 1995, 1996, 1997 Theodore Ts'o.
|
|
||||||
*
|
|
||||||
* %Begin-Header%
|
|
||||||
* This file may be redistributed under the terms of the
|
|
||||||
* GNU Lesser General Public License.
|
|
||||||
* %End-Header%
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ext2fs/ext2_io.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_LFS
|
|
||||||
# define my_llseek lseek64
|
|
||||||
#else
|
|
||||||
# define my_llseek lseek
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
|
|
||||||
{
|
|
||||||
ext2_loff_t result;
|
|
||||||
static int do_compat = 0;
|
|
||||||
|
|
||||||
if ((sizeof(off_t) >= sizeof(ext2_loff_t)) ||
|
|
||||||
(offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1))))
|
|
||||||
return lseek(fd, (off_t) offset, origin);
|
|
||||||
|
|
||||||
if (do_compat) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = my_llseek (fd, offset, origin);
|
|
||||||
if (result == -1 && errno == ENOSYS) {
|
|
||||||
/*
|
|
||||||
* Just in case this code runs on top of an old kernel
|
|
||||||
* which does not support the llseek system call
|
|
||||||
*/
|
|
||||||
do_compat++;
|
|
||||||
errno = EINVAL;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* mke2fs.c - Make a ext2fs filesystem.
|
* mke2fs.c - Make a ext2fs filesystem.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
* Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
* 2003, 2004, 2005 by Theodore Ts'o.
|
* 2003, 2004, 2005 by Theodore Ts'o.
|
||||||
*
|
*
|
||||||
* %Begin-Header%
|
* %Begin-Header%
|
||||||
* This file may be redistributed under the terms of the GNU Public
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
@ -11,9 +11,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Usage: mke2fs [options] device
|
/* Usage: mke2fs [options] device
|
||||||
*
|
*
|
||||||
* The device may be a block device or a image of one, but this isn't
|
* The device may be a block device or a image of one, but this isn't
|
||||||
* enforced (but it's not much fun on a character device :-).
|
* enforced (but it's not much fun on a character device :-).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -52,7 +52,7 @@ static int force;
|
|||||||
static int noaction;
|
static int noaction;
|
||||||
static int journal_size;
|
static int journal_size;
|
||||||
static int journal_flags;
|
static int journal_flags;
|
||||||
static char *bad_blocks_filename;
|
static const char *bad_blocks_filename;
|
||||||
static __u32 fs_stride;
|
static __u32 fs_stride;
|
||||||
|
|
||||||
static struct ext2_super_block param;
|
static struct ext2_super_block param;
|
||||||
@ -60,7 +60,7 @@ static char *creator_os;
|
|||||||
static char *volume_label;
|
static char *volume_label;
|
||||||
static char *mount_dir;
|
static char *mount_dir;
|
||||||
static char *journal_device;
|
static char *journal_device;
|
||||||
static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
|
static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
|
||||||
|
|
||||||
static int sys_page_size = 4096;
|
static int sys_page_size = 4096;
|
||||||
static int linux_version_code = 0;
|
static int linux_version_code = 0;
|
||||||
@ -95,21 +95,23 @@ static int int_log10(unsigned int arg)
|
|||||||
* Note that order is important in the table below.
|
* Note that order is important in the table below.
|
||||||
*/
|
*/
|
||||||
#define DEF_MAX_BLOCKSIZE -1
|
#define DEF_MAX_BLOCKSIZE -1
|
||||||
static char default_str[] = "default";
|
static const char default_str[] = "default";
|
||||||
struct mke2fs_defaults {
|
struct mke2fs_defaults {
|
||||||
const char *type;
|
const char *type;
|
||||||
int size;
|
int size;
|
||||||
int blocksize;
|
int blocksize;
|
||||||
int inode_ratio;
|
int inode_ratio;
|
||||||
} settings[] = {
|
};
|
||||||
{ default_str, 0, 4096, 8192 },
|
|
||||||
|
static const struct mke2fs_defaults settings[] = {
|
||||||
|
{ default_str, 0, 4096, 8192 },
|
||||||
{ default_str, 512, 1024, 4096 },
|
{ default_str, 512, 1024, 4096 },
|
||||||
{ default_str, 3, 1024, 8192 },
|
{ default_str, 3, 1024, 8192 },
|
||||||
{ "journal", 0, 4096, 8192 },
|
{ "journal", 0, 4096, 8192 },
|
||||||
{ "news", 0, 4096, 4096 },
|
{ "news", 0, 4096, 4096 },
|
||||||
{ "largefile", 0, 4096, 1024 * 1024 },
|
{ "largefile", 0, 4096, 1024 * 1024 },
|
||||||
{ "largefile4", 0, 4096, 4096 * 1024 },
|
{ "largefile4", 0, 4096, 4096 * 1024 },
|
||||||
{ 0, 0, 0, 0},
|
{ 0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_fs_defaults(const char *fs_type,
|
static void set_fs_defaults(const char *fs_type,
|
||||||
@ -119,7 +121,7 @@ static void set_fs_defaults(const char *fs_type,
|
|||||||
{
|
{
|
||||||
int megs;
|
int megs;
|
||||||
int ratio = 0;
|
int ratio = 0;
|
||||||
struct mke2fs_defaults *p;
|
const struct mke2fs_defaults *p;
|
||||||
int use_bsize = 1024;
|
int use_bsize = 1024;
|
||||||
|
|
||||||
megs = super->s_blocks_count * (EXT2_BLOCK_SIZE(super) / 1024) / 1024;
|
megs = super->s_blocks_count * (EXT2_BLOCK_SIZE(super) / 1024) / 1024;
|
||||||
@ -199,7 +201,7 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
|
|||||||
quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
|
quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
|
||||||
fs->device_name, fs->super->s_blocks_count);
|
fs->device_name, fs->super->s_blocks_count);
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
printf(_("Running command: %s\n"), buf);
|
printf("Running command: %s\n", buf);
|
||||||
f = popen(buf, "r");
|
f = popen(buf, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
bb_perror_msg_and_die("Could not run '%s'", buf);
|
bb_perror_msg_and_die("Could not run '%s'", buf);
|
||||||
@ -216,7 +218,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
|
|||||||
{
|
{
|
||||||
dgrp_t i;
|
dgrp_t i;
|
||||||
blk_t j;
|
blk_t j;
|
||||||
unsigned must_be_good;
|
unsigned must_be_good;
|
||||||
blk_t blk;
|
blk_t blk;
|
||||||
badblocks_iterate bb_iter;
|
badblocks_iterate bb_iter;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
@ -226,7 +228,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
|
|||||||
|
|
||||||
if (!bb_list)
|
if (!bb_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The primary superblock and group descriptors *must* be
|
* The primary superblock and group descriptors *must* be
|
||||||
* good; if not, abort.
|
* good; if not, abort.
|
||||||
@ -248,16 +250,16 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
|
|||||||
*/
|
*/
|
||||||
group_block = fs->super->s_first_data_block +
|
group_block = fs->super->s_first_data_block +
|
||||||
fs->super->s_blocks_per_group;
|
fs->super->s_blocks_per_group;
|
||||||
|
|
||||||
for (i = 1; i < fs->group_desc_count; i++) {
|
for (i = 1; i < fs->group_desc_count; i++) {
|
||||||
group_bad = 0;
|
group_bad = 0;
|
||||||
for (j=0; j < fs->desc_blocks+1; j++) {
|
for (j=0; j < fs->desc_blocks+1; j++) {
|
||||||
if (ext2fs_badblocks_list_test(bb_list,
|
if (ext2fs_badblocks_list_test(bb_list,
|
||||||
group_block + j)) {
|
group_block + j)) {
|
||||||
if (!group_bad)
|
if (!group_bad)
|
||||||
bb_error_msg(
|
bb_error_msg(
|
||||||
"Warning: the backup superblock/group descriptors at block %d contain\n"
|
"Warning: the backup superblock/group descriptors at block %d contain\n"
|
||||||
" bad blocks\n", group_block);
|
" bad blocks\n", group_block);
|
||||||
group_bad++;
|
group_bad++;
|
||||||
group = ext2fs_group_of_blk(fs, group_block+j);
|
group = ext2fs_group_of_blk(fs, group_block+j);
|
||||||
fs->group_desc[group].bg_free_blocks_count++;
|
fs->group_desc[group].bg_free_blocks_count++;
|
||||||
@ -266,7 +268,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
|
|||||||
}
|
}
|
||||||
group_block += fs->super->s_blocks_per_group;
|
group_block += fs->super->s_blocks_per_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark all the bad blocks as used...
|
* Mark all the bad blocks as used...
|
||||||
*/
|
*/
|
||||||
@ -274,7 +276,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
|
|||||||
if (retval) {
|
if (retval) {
|
||||||
bb_error_msg_and_die("while marking bad blocks as used");
|
bb_error_msg_and_die("while marking bad blocks as used");
|
||||||
}
|
}
|
||||||
while (ext2fs_badblocks_list_iterate(bb_iter, &blk))
|
while (ext2fs_badblocks_list_iterate(bb_iter, &blk))
|
||||||
ext2fs_mark_block_bitmap(fs->block_map, blk);
|
ext2fs_mark_block_bitmap(fs->block_map, blk);
|
||||||
ext2fs_badblocks_list_iterate_end(bb_iter);
|
ext2fs_badblocks_list_iterate_end(bb_iter);
|
||||||
}
|
}
|
||||||
@ -329,7 +331,7 @@ static void progress_close(struct progress_struct *progress)
|
|||||||
{
|
{
|
||||||
if (progress->format[0] == 0)
|
if (progress->format[0] == 0)
|
||||||
return;
|
return;
|
||||||
fputs(_("done \n"), stdout);
|
fputs("done \n", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -361,8 +363,7 @@ static errcode_t zero_blocks(ext2_filsys fs, blk_t blk, int num,
|
|||||||
}
|
}
|
||||||
/* Allocate the zeroizing buffer if necessary */
|
/* Allocate the zeroizing buffer if necessary */
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
buf = xmalloc(fs->blocksize * STRIDE_LENGTH);
|
buf = xcalloc(fs->blocksize, STRIDE_LENGTH);
|
||||||
memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
|
|
||||||
}
|
}
|
||||||
/* OK, do the write loop */
|
/* OK, do the write loop */
|
||||||
next_update = 0;
|
next_update = 0;
|
||||||
@ -387,7 +388,7 @@ static errcode_t zero_blocks(ext2_filsys fs, blk_t blk, int num,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_inode_tables(ext2_filsys fs)
|
static void write_inode_tables(ext2_filsys fs)
|
||||||
{
|
{
|
||||||
@ -400,12 +401,12 @@ static void write_inode_tables(ext2_filsys fs)
|
|||||||
if (quiet)
|
if (quiet)
|
||||||
memset(&progress, 0, sizeof(progress));
|
memset(&progress, 0, sizeof(progress));
|
||||||
else
|
else
|
||||||
progress_init(&progress, _("Writing inode tables: "),
|
progress_init(&progress, "Writing inode tables: ",
|
||||||
fs->group_desc_count);
|
fs->group_desc_count);
|
||||||
|
|
||||||
for (i = 0; i < fs->group_desc_count; i++) {
|
for (i = 0; i < fs->group_desc_count; i++) {
|
||||||
progress_update(&progress, i);
|
progress_update(&progress, i);
|
||||||
|
|
||||||
blk = fs->group_desc[i].bg_inode_table;
|
blk = fs->group_desc[i].bg_inode_table;
|
||||||
num = fs->inode_blocks_per_group;
|
num = fs->inode_blocks_per_group;
|
||||||
|
|
||||||
@ -429,7 +430,7 @@ static void write_inode_tables(ext2_filsys fs)
|
|||||||
|
|
||||||
static void create_root_dir(ext2_filsys fs)
|
static void create_root_dir(ext2_filsys fs)
|
||||||
{
|
{
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
struct ext2_inode inode;
|
struct ext2_inode inode;
|
||||||
|
|
||||||
retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
|
retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
|
||||||
@ -469,7 +470,7 @@ static void create_lost_and_found(ext2_filsys fs)
|
|||||||
if (retval) {
|
if (retval) {
|
||||||
bb_error_msg_and_die("Could not look up lost+found");
|
bb_error_msg_and_die("Could not look up lost+found");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=1; i < EXT2_NDIR_BLOCKS; i++) {
|
for (i=1; i < EXT2_NDIR_BLOCKS; i++) {
|
||||||
if ((lpf_size += fs->blocksize) >= 16*1024)
|
if ((lpf_size += fs->blocksize) >= 16*1024)
|
||||||
break;
|
break;
|
||||||
@ -483,7 +484,7 @@ static void create_lost_and_found(ext2_filsys fs)
|
|||||||
static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list)
|
static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list)
|
||||||
{
|
{
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO);
|
ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO);
|
||||||
fs->group_desc[0].bg_free_inodes_count--;
|
fs->group_desc[0].bg_free_inodes_count--;
|
||||||
fs->super->s_free_inodes_count--;
|
fs->super->s_free_inodes_count--;
|
||||||
@ -544,7 +545,7 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
|
|||||||
|
|
||||||
static void create_journal_dev(ext2_filsys fs)
|
static void create_journal_dev(ext2_filsys fs)
|
||||||
{
|
{
|
||||||
struct progress_struct progress;
|
struct progress_struct progress;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
char *buf;
|
char *buf;
|
||||||
blk_t blk;
|
blk_t blk;
|
||||||
@ -558,7 +559,7 @@ static void create_journal_dev(ext2_filsys fs)
|
|||||||
if (quiet)
|
if (quiet)
|
||||||
memset(&progress, 0, sizeof(progress));
|
memset(&progress, 0, sizeof(progress));
|
||||||
else
|
else
|
||||||
progress_init(&progress, _("Zeroing journal device: "),
|
progress_init(&progress, "Zeroing journal device: ",
|
||||||
fs->super->s_blocks_count);
|
fs->super->s_blocks_count);
|
||||||
|
|
||||||
retval = zero_blocks(fs, 0, fs->super->s_blocks_count,
|
retval = zero_blocks(fs, 0, fs->super->s_blocks_count,
|
||||||
@ -581,12 +582,12 @@ static void create_journal_dev(ext2_filsys fs)
|
|||||||
static void show_stats(ext2_filsys fs)
|
static void show_stats(ext2_filsys fs)
|
||||||
{
|
{
|
||||||
struct ext2_super_block *s = fs->super;
|
struct ext2_super_block *s = fs->super;
|
||||||
char buf[80];
|
char buf[80];
|
||||||
char *os;
|
char *os;
|
||||||
blk_t group_block;
|
blk_t group_block;
|
||||||
dgrp_t i;
|
dgrp_t i;
|
||||||
int need, col_left;
|
int need, col_left;
|
||||||
|
|
||||||
if (param.s_blocks_count != s->s_blocks_count)
|
if (param.s_blocks_count != s->s_blocks_count)
|
||||||
bb_error_msg("warning: %d blocks unused\n",
|
bb_error_msg("warning: %d blocks unused\n",
|
||||||
param.s_blocks_count - s->s_blocks_count);
|
param.s_blocks_count - s->s_blocks_count);
|
||||||
@ -594,40 +595,39 @@ static void show_stats(ext2_filsys fs)
|
|||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
|
strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
|
||||||
printf("Filesystem label=%s\n", buf);
|
printf("Filesystem label=%s\n", buf);
|
||||||
fputs(_("OS type: "), stdout);
|
fputs("OS type: ", stdout);
|
||||||
os = e2p_os2string(fs->super->s_creator_os);
|
os = e2p_os2string(fs->super->s_creator_os);
|
||||||
fputs(os, stdout);
|
fputs(os, stdout);
|
||||||
free(os);
|
free(os);
|
||||||
printf("\n");
|
printf("\nBlock size=%u (log=%u)\n", fs->blocksize,
|
||||||
printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
|
|
||||||
s->s_log_block_size);
|
s->s_log_block_size);
|
||||||
printf(_("Fragment size=%u (log=%u)\n"), fs->fragsize,
|
printf("Fragment size=%u (log=%u)\n", fs->fragsize,
|
||||||
s->s_log_frag_size);
|
s->s_log_frag_size);
|
||||||
printf(_("%u inodes, %u blocks\n"), s->s_inodes_count,
|
printf("%u inodes, %u blocks\n", s->s_inodes_count,
|
||||||
s->s_blocks_count);
|
s->s_blocks_count);
|
||||||
printf(_("%u blocks (%2.2f%%) reserved for the super user\n"),
|
printf("%u blocks (%2.2f%%) reserved for the super user\n",
|
||||||
s->s_r_blocks_count,
|
s->s_r_blocks_count,
|
||||||
100.0 * s->s_r_blocks_count / s->s_blocks_count);
|
100.0 * s->s_r_blocks_count / s->s_blocks_count);
|
||||||
printf(_("First data block=%u\n"), s->s_first_data_block);
|
printf("First data block=%u\n", s->s_first_data_block);
|
||||||
if (s->s_reserved_gdt_blocks)
|
if (s->s_reserved_gdt_blocks)
|
||||||
printf(_("Maximum filesystem blocks=%lu\n"),
|
printf("Maximum filesystem blocks=%lu\n",
|
||||||
(s->s_reserved_gdt_blocks + fs->desc_blocks) *
|
(s->s_reserved_gdt_blocks + fs->desc_blocks) *
|
||||||
(fs->blocksize / sizeof(struct ext2_group_desc)) *
|
(fs->blocksize / sizeof(struct ext2_group_desc)) *
|
||||||
s->s_blocks_per_group);
|
s->s_blocks_per_group);
|
||||||
if (fs->group_desc_count > 1)
|
if (fs->group_desc_count > 1)
|
||||||
printf(_("%u block groups\n"), fs->group_desc_count);
|
printf("%u block groups\n", fs->group_desc_count);
|
||||||
else
|
else
|
||||||
printf(_("%u block group\n"), fs->group_desc_count);
|
printf("%u block group\n", fs->group_desc_count);
|
||||||
printf(_("%u blocks per group, %u fragments per group\n"),
|
printf("%u blocks per group, %u fragments per group\n",
|
||||||
s->s_blocks_per_group, s->s_frags_per_group);
|
s->s_blocks_per_group, s->s_frags_per_group);
|
||||||
printf(_("%u inodes per group\n"), s->s_inodes_per_group);
|
printf("%u inodes per group\n", s->s_inodes_per_group);
|
||||||
|
|
||||||
if (fs->group_desc_count == 1) {
|
if (fs->group_desc_count == 1) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(_("Superblock backups stored on blocks: "));
|
printf("Superblock backups stored on blocks: ");
|
||||||
group_block = s->s_first_data_block;
|
group_block = s->s_first_data_block;
|
||||||
col_left = 0;
|
col_left = 0;
|
||||||
for (i = 1; i < fs->group_desc_count; i++) {
|
for (i = 1; i < fs->group_desc_count; i++) {
|
||||||
@ -673,16 +673,13 @@ static int set_os(struct ext2_super_block *sb, char *os)
|
|||||||
|
|
||||||
#define PATH_SET "PATH=/sbin"
|
#define PATH_SET "PATH=/sbin"
|
||||||
|
|
||||||
static void parse_extended_opts(struct ext2_super_block *sb_param,
|
static void parse_extended_opts(struct ext2_super_block *sb_param,
|
||||||
const char *opts)
|
const char *opts)
|
||||||
{
|
{
|
||||||
char *buf, *token, *next, *p, *arg;
|
char *buf, *token, *next, *p, *arg;
|
||||||
int len;
|
|
||||||
int r_usage = 0;
|
int r_usage = 0;
|
||||||
|
|
||||||
len = strlen(opts);
|
buf = bb_xstrdup(opts);
|
||||||
buf = xmalloc(len+1);
|
|
||||||
strcpy(buf, opts);
|
|
||||||
for (token = buf; token && *token; token = next) {
|
for (token = buf; token && *token; token = next) {
|
||||||
p = strchr(token, ',');
|
p = strchr(token, ',');
|
||||||
next = 0;
|
next = 0;
|
||||||
@ -717,7 +714,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
resize = parse_num_blocks(arg,
|
resize = parse_num_blocks(arg,
|
||||||
sb_param->s_log_block_size);
|
sb_param->s_log_block_size);
|
||||||
|
|
||||||
if (resize == 0) {
|
if (resize == 0) {
|
||||||
@ -741,7 +738,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
|
|||||||
desc_blocks = (group_desc_count +
|
desc_blocks = (group_desc_count +
|
||||||
gdpb - 1) / gdpb;
|
gdpb - 1) / gdpb;
|
||||||
rsv_groups = (resize + bpg - 1) / bpg;
|
rsv_groups = (resize + bpg - 1) / bpg;
|
||||||
rsv_gdb = (rsv_groups + gdpb - 1) / gdpb -
|
rsv_gdb = (rsv_groups + gdpb - 1) / gdpb -
|
||||||
desc_blocks;
|
desc_blocks;
|
||||||
if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb_param))
|
if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb_param))
|
||||||
rsv_gdb = EXT2_ADDR_PER_BLOCK(sb_param);
|
rsv_gdb = EXT2_ADDR_PER_BLOCK(sb_param);
|
||||||
@ -765,20 +762,20 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
|
|||||||
"\tstride=<stride length in blocks>\n"
|
"\tstride=<stride length in blocks>\n"
|
||||||
"\tresize=<resize maximum size in blocks>\n");
|
"\tresize=<resize maximum size in blocks>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __u32 ok_features[3] = {
|
static __u32 ok_features[3] = {
|
||||||
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
|
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
|
||||||
EXT2_FEATURE_COMPAT_RESIZE_INODE |
|
EXT2_FEATURE_COMPAT_RESIZE_INODE |
|
||||||
EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */
|
EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */
|
||||||
EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */
|
EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */
|
||||||
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
|
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
|
||||||
EXT2_FEATURE_INCOMPAT_META_BG,
|
EXT2_FEATURE_INCOMPAT_META_BG,
|
||||||
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER /* R/O compat */
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER /* R/O compat */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void PRS(int argc, char *argv[])
|
static int PRS(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int b, c;
|
int b, c;
|
||||||
int size;
|
int size;
|
||||||
@ -800,12 +797,8 @@ static void PRS(int argc, char *argv[])
|
|||||||
/* Update our PATH to include /sbin */
|
/* Update our PATH to include /sbin */
|
||||||
if (oldpath) {
|
if (oldpath) {
|
||||||
char *newpath;
|
char *newpath;
|
||||||
|
|
||||||
newpath = xmalloc(sizeof (PATH_SET) + 1 + strlen (oldpath));
|
bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath);
|
||||||
strcpy (newpath, PATH_SET);
|
|
||||||
strcat (newpath, ":");
|
|
||||||
strcat (newpath, oldpath);
|
|
||||||
putenv (newpath);
|
|
||||||
} else
|
} else
|
||||||
putenv (PATH_SET);
|
putenv (PATH_SET);
|
||||||
|
|
||||||
@ -822,7 +815,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
if (sysval > 0)
|
if (sysval > 0)
|
||||||
sys_page_size = sysval;
|
sys_page_size = sysval;
|
||||||
#endif /* _SC_PAGESIZE */
|
#endif /* _SC_PAGESIZE */
|
||||||
|
|
||||||
setbuf(stdout, NULL);
|
setbuf(stdout, NULL);
|
||||||
setbuf(stderr, NULL);
|
setbuf(stderr, NULL);
|
||||||
memset(¶m, 0, sizeof(struct ext2_super_block));
|
memset(¶m, 0, sizeof(struct ext2_super_block));
|
||||||
@ -863,7 +856,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
bb_error_msg(
|
bb_error_msg(
|
||||||
"Warning: blocksize %d not usable on most systems",
|
"Warning: blocksize %d not usable on most systems",
|
||||||
blocksize);
|
blocksize);
|
||||||
if (blocksize > 0)
|
if (blocksize > 0)
|
||||||
param.s_log_block_size =
|
param.s_log_block_size =
|
||||||
int_log2(blocksize >>
|
int_log2(blocksize >>
|
||||||
EXT2_MIN_BLOCK_LOG_SIZE);
|
EXT2_MIN_BLOCK_LOG_SIZE);
|
||||||
@ -913,8 +906,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
journal_size = -1;
|
journal_size = -1;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
bad_blocks_filename = xmalloc(strlen(optarg)+1);
|
bad_blocks_filename = optarg;
|
||||||
strcpy(bad_blocks_filename, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
reserved_ratio = strtoul(optarg, &tmp, 0);
|
reserved_ratio = strtoul(optarg, &tmp, 0);
|
||||||
@ -940,7 +932,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
if (atoi(optarg))
|
if (atoi(optarg))
|
||||||
param.s_feature_ro_compat |=
|
param.s_feature_ro_compat |=
|
||||||
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
|
||||||
else
|
else
|
||||||
param.s_feature_ro_compat &=
|
param.s_feature_ro_compat &=
|
||||||
~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
|
~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
|
||||||
break;
|
break;
|
||||||
@ -1006,11 +998,11 @@ static void PRS(int argc, char *argv[])
|
|||||||
device_name = argv[optind++];
|
device_name = argv[optind++];
|
||||||
|
|
||||||
if (!quiet || show_version_only)
|
if (!quiet || show_version_only)
|
||||||
bb_error_msg("mke2fs %s (%s)", E2FSPROGS_VERSION,
|
bb_error_msg("mke2fs %s (%s)", E2FSPROGS_VERSION,
|
||||||
E2FSPROGS_DATE);
|
E2FSPROGS_DATE);
|
||||||
|
|
||||||
if (show_version_only) {
|
if (show_version_only) {
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1018,8 +1010,8 @@ static void PRS(int argc, char *argv[])
|
|||||||
* device, use it to figure out the blocksize
|
* device, use it to figure out the blocksize
|
||||||
*/
|
*/
|
||||||
if (blocksize <= 0 && journal_device) {
|
if (blocksize <= 0 && journal_device) {
|
||||||
ext2_filsys jfs;
|
ext2_filsys jfs;
|
||||||
io_manager io_ptr;
|
io_manager io_ptr;
|
||||||
|
|
||||||
#ifdef CONFIG_TESTIO_DEBUG
|
#ifdef CONFIG_TESTIO_DEBUG
|
||||||
io_ptr = test_io_manager;
|
io_ptr = test_io_manager;
|
||||||
@ -1064,7 +1056,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
" Use -b 4096 if this is an issue for you\n");
|
" Use -b 4096 if this is an issue for you\n");
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
param.s_blocks_count = parse_num_blocks(argv[optind++],
|
param.s_blocks_count = parse_num_blocks(argv[optind++],
|
||||||
param.s_log_block_size);
|
param.s_log_block_size);
|
||||||
if (!param.s_blocks_count) {
|
if (!param.s_blocks_count) {
|
||||||
bb_error_msg_and_die("bad blocks count - %s", argv[optind - 1]);
|
bb_error_msg_and_die("bad blocks count - %s", argv[optind - 1]);
|
||||||
@ -1080,15 +1072,15 @@ static void PRS(int argc, char *argv[])
|
|||||||
param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
|
param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
|
||||||
param.s_feature_compat = 0;
|
param.s_feature_compat = 0;
|
||||||
param.s_feature_ro_compat = 0;
|
param.s_feature_ro_compat = 0;
|
||||||
}
|
}
|
||||||
if (param.s_rev_level == EXT2_GOOD_OLD_REV &&
|
if (param.s_rev_level == EXT2_GOOD_OLD_REV &&
|
||||||
(param.s_feature_compat || param.s_feature_ro_compat ||
|
(param.s_feature_compat || param.s_feature_ro_compat ||
|
||||||
param.s_feature_incompat))
|
param.s_feature_incompat))
|
||||||
param.s_rev_level = 1; /* Create a revision 1 filesystem */
|
param.s_rev_level = 1; /* Create a revision 1 filesystem */
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
check_plausibility(device_name);
|
check_plausibility(device_name);
|
||||||
check_mount(device_name, force, _("filesystem"));
|
check_mount(device_name, force, "filesystem");
|
||||||
|
|
||||||
param.s_log_frag_size = param.s_log_block_size;
|
param.s_log_frag_size = param.s_log_block_size;
|
||||||
|
|
||||||
@ -1101,14 +1093,14 @@ static void PRS(int argc, char *argv[])
|
|||||||
EXT2_BLOCK_SIZE(¶m),
|
EXT2_BLOCK_SIZE(¶m),
|
||||||
&dev_size);
|
&dev_size);
|
||||||
if ((retval == EFBIG) &&
|
if ((retval == EFBIG) &&
|
||||||
(blocksize == 0) &&
|
(blocksize == 0) &&
|
||||||
(param.s_log_block_size == 0)) {
|
(param.s_log_block_size == 0)) {
|
||||||
param.s_log_block_size = 2;
|
param.s_log_block_size = 2;
|
||||||
blocksize = 4096;
|
blocksize = 4096;
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
|
if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
|
||||||
bb_error_msg_and_die("Could not determine filesystem size");
|
bb_error_msg_and_die("Could not determine filesystem size");
|
||||||
}
|
}
|
||||||
@ -1135,7 +1127,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
param.s_blocks_count &= ~((sys_page_size /
|
param.s_blocks_count &= ~((sys_page_size /
|
||||||
EXT2_BLOCK_SIZE(¶m))-1);
|
EXT2_BLOCK_SIZE(¶m))-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!force && (param.s_blocks_count > dev_size)) {
|
} else if (!force && (param.s_blocks_count > dev_size)) {
|
||||||
bb_error_msg("Filesystem larger than apparent device size");
|
bb_error_msg("Filesystem larger than apparent device size");
|
||||||
proceed_question();
|
proceed_question();
|
||||||
@ -1163,10 +1155,10 @@ static void PRS(int argc, char *argv[])
|
|||||||
|
|
||||||
if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
|
if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
|
||||||
sector_size = atoi(tmp);
|
sector_size = atoi(tmp);
|
||||||
|
|
||||||
set_fs_defaults(fs_type, ¶m, blocksize, sector_size, &inode_ratio);
|
set_fs_defaults(fs_type, ¶m, blocksize, sector_size, &inode_ratio);
|
||||||
blocksize = EXT2_BLOCK_SIZE(¶m);
|
blocksize = EXT2_BLOCK_SIZE(¶m);
|
||||||
|
|
||||||
if (extended_opts)
|
if (extended_opts)
|
||||||
parse_extended_opts(¶m, extended_opts);
|
parse_extended_opts(¶m, extended_opts);
|
||||||
|
|
||||||
@ -1204,7 +1196,7 @@ static void PRS(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Calculate number of inodes based on the inode ratio
|
* Calculate number of inodes based on the inode ratio
|
||||||
*/
|
*/
|
||||||
param.s_inodes_count = num_inodes ? num_inodes :
|
param.s_inodes_count = num_inodes ? num_inodes :
|
||||||
((__u64) param.s_blocks_count * blocksize)
|
((__u64) param.s_blocks_count * blocksize)
|
||||||
/ inode_ratio;
|
/ inode_ratio;
|
||||||
|
|
||||||
@ -1212,11 +1204,12 @@ static void PRS(int argc, char *argv[])
|
|||||||
* Calculate number of blocks to reserve
|
* Calculate number of blocks to reserve
|
||||||
*/
|
*/
|
||||||
param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100;
|
param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mke2fs_main (int argc, char *argv[])
|
int mke2fs_main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
errcode_t retval = 0;
|
errcode_t retval;
|
||||||
ext2_filsys fs;
|
ext2_filsys fs;
|
||||||
badblocks_list bb_list = 0;
|
badblocks_list bb_list = 0;
|
||||||
int journal_blocks;
|
int journal_blocks;
|
||||||
@ -1224,13 +1217,8 @@ int mke2fs_main (int argc, char *argv[])
|
|||||||
int val;
|
int val;
|
||||||
io_manager io_ptr;
|
io_manager io_ptr;
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
if(!PRS(argc, argv))
|
||||||
setlocale(LC_MESSAGES, "");
|
return 0;
|
||||||
setlocale(LC_CTYPE, "");
|
|
||||||
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
||||||
textdomain(NLS_CAT_NAME);
|
|
||||||
#endif
|
|
||||||
PRS(argc, argv);
|
|
||||||
|
|
||||||
#ifdef CONFIG_TESTIO_DEBUG
|
#ifdef CONFIG_TESTIO_DEBUG
|
||||||
io_ptr = test_io_manager;
|
io_ptr = test_io_manager;
|
||||||
@ -1308,17 +1296,17 @@ int mke2fs_main (int argc, char *argv[])
|
|||||||
strncpy(fs->super->s_last_mounted, mount_dir,
|
strncpy(fs->super->s_last_mounted, mount_dir,
|
||||||
sizeof(fs->super->s_last_mounted));
|
sizeof(fs->super->s_last_mounted));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet || noaction)
|
if (!quiet || noaction)
|
||||||
show_stats(fs);
|
show_stats(fs);
|
||||||
|
|
||||||
if (noaction)
|
if (noaction)
|
||||||
exit(0);
|
return 0;
|
||||||
|
|
||||||
if (fs->super->s_feature_incompat &
|
if (fs->super->s_feature_incompat &
|
||||||
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
|
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
|
||||||
create_journal_dev(fs);
|
create_journal_dev(fs);
|
||||||
exit(ext2fs_close(fs) ? 1 : 0);
|
return (ext2fs_close(fs) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad_blocks_filename)
|
if (bad_blocks_filename)
|
||||||
@ -1366,7 +1354,7 @@ int mke2fs_main (int argc, char *argv[])
|
|||||||
create_lost_and_found(fs);
|
create_lost_and_found(fs);
|
||||||
reserve_inodes(fs);
|
reserve_inodes(fs);
|
||||||
create_bad_block_inode(fs, bb_list);
|
create_bad_block_inode(fs, bb_list);
|
||||||
if (fs->super->s_feature_compat &
|
if (fs->super->s_feature_compat &
|
||||||
EXT2_FEATURE_COMPAT_RESIZE_INODE) {
|
EXT2_FEATURE_COMPAT_RESIZE_INODE) {
|
||||||
retval = ext2fs_create_resize_inode(fs);
|
retval = ext2fs_create_resize_inode(fs);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
@ -1376,11 +1364,11 @@ int mke2fs_main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (journal_device) {
|
if (journal_device) {
|
||||||
ext2_filsys jfs;
|
ext2_filsys jfs;
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
check_plausibility(journal_device);
|
check_plausibility(journal_device);
|
||||||
check_mount(journal_device, force, _("journal"));
|
check_mount(journal_device, force, "journal");
|
||||||
|
|
||||||
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
|
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
|
||||||
EXT2_FLAG_JOURNAL_DEV_OK, 0,
|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user