aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-09-19 13:48:39 +0000
committervodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-09-19 13:48:39 +0000
commit02b406d6855a80d406a88815315f5d3f107fc5ba (patch)
tree950358988089069ceae599d89faf0d3e1e5833b6
parent1ef7ad38363a265528009f5d567dc54717fb48ff (diff)
downloadbusybox-w32-02b406d6855a80d406a88815315f5d3f107fc5ba.tar.gz
busybox-w32-02b406d6855a80d406a88815315f5d3f107fc5ba.tar.bz2
busybox-w32-02b406d6855a80d406a88815315f5d3f107fc5ba.zip
mke2fs.c can compiled for me, more bb_xstrdup and bb_xasprintf usage, remove 1 exporing, ext2fs_llseek/blkid_llseek->llseek
git-svn-id: svn://busybox.net/trunk/busybox@11502 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--e2fsprogs/Makefile.in22
-rw-r--r--e2fsprogs/blkid/blkidP.h15
-rw-r--r--e2fsprogs/blkid/blkid_getsize.c (renamed from e2fsprogs/blkid/getsize.c)0
-rw-r--r--e2fsprogs/ext2fs/ext2_io.h29
-rw-r--r--e2fsprogs/ext2fs/llseek.c55
-rw-r--r--e2fsprogs/mke2fs.c198
6 files changed, 131 insertions, 188 deletions
diff --git a/e2fsprogs/Makefile.in b/e2fsprogs/Makefile.in
index ed307c1ea..21d45e1cb 100644
--- a/e2fsprogs/Makefile.in
+++ b/e2fsprogs/Makefile.in
@@ -25,29 +25,29 @@ srcdir=$(top_srcdir)/e2fsprogs
25 25
26E2FSPROGS_CFLAGS := -I$(srcdir) -include $(srcdir)/e2fsbb.h 26E2FSPROGS_CFLAGS := -I$(srcdir) -include $(srcdir)/e2fsbb.h
27 27
28BLKID_SRC := cache.c dev.c devname.c devno.c getsize.c llseek.c probe.c \ 28BLKID_SRC := cache.c dev.c devname.c devno.c blkid_getsize.c \
29 read.c resolve.c save.c tag.c resolve.c 29 probe.c read.c resolve.c save.c tag.c resolve.c
30BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC)) 30BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC))
31BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS)) 31BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS))
32 32
33E2P_SRC := fgetsetflags.c fgetsetversion.c pf.c iod.c mntopts.c \ 33E2P_SRC := fgetsetflags.c fgetsetversion.c pf.c iod.c mntopts.c \
34 feature.c ls.c uuid.c pe.c ostype.c ps.c hashstr.c \ 34 feature.c ls.c uuid.c pe.c ostype.c ps.c hashstr.c \
35 parse_num.c 35 parse_num.c
36E2P_SRCS := $(patsubst %,e2p/%, $(E2P_SRC)) 36E2P_SRCS := $(patsubst %,e2p/%, $(E2P_SRC))
37E2P_OBJS := $(patsubst %.c,%.o, $(E2P_SRCS)) 37E2P_OBJS := $(patsubst %.c,%.o, $(E2P_SRCS))
38 38
39EXT2FS_SRC := gen_bitmap.c bitops.c ismounted.c mkjournal.c unix_io.c \ 39EXT2FS_SRC := gen_bitmap.c bitops.c ismounted.c mkjournal.c unix_io.c \
40 llseek.c rw_bitmaps.c initialize.c bitmaps.c block.c \ 40 rw_bitmaps.c initialize.c bitmaps.c block.c \
41 ind_block.c inode.c freefs.c alloc_stats.c closefs.c \ 41 ind_block.c inode.c freefs.c alloc_stats.c closefs.c \
42 openfs.c io_manager.c finddev.c read_bb.c alloc.c badblocks.c \ 42 openfs.c io_manager.c finddev.c read_bb.c alloc.c badblocks.c \
43 getsize.c getsectsize.c alloc_tables.c read_bb_file.c mkdir.c \ 43 getsize.c getsectsize.c alloc_tables.c read_bb_file.c mkdir.c \
44 bb_inode.c newdir.c alloc_sb.c lookup.c dirblock.c expanddir.c \ 44 bb_inode.c newdir.c alloc_sb.c lookup.c dirblock.c expanddir.c \
45 dir_iterate.c link.c res_gdt.c 45 dir_iterate.c link.c res_gdt.c
46EXT2FS_SRCS := $(patsubst %,ext2fs/%, $(EXT2FS_SRC)) 46EXT2FS_SRCS := $(patsubst %,ext2fs/%, $(EXT2FS_SRC))
47EXT2FS_OBJS := $(patsubst %.c,%.o, $(EXT2FS_SRCS)) 47EXT2FS_OBJS := $(patsubst %.c,%.o, $(EXT2FS_SRCS))
48 48
49UUID_SRC := compare.c gen_uuid.c pack.c parse.c unpack.c unparse.c \ 49UUID_SRC := compare.c gen_uuid.c pack.c parse.c unpack.c unparse.c \
50 uuid_time.c 50 uuid_time.c
51UUID_SRCS := $(patsubst %,uuid/%, $(UUID_SRC)) 51UUID_SRCS := $(patsubst %,uuid/%, $(UUID_SRC))
52UUID_OBJS := $(patsubst %.c,%.o, $(UUID_SRCS)) 52UUID_OBJS := $(patsubst %.c,%.o, $(UUID_SRCS))
53 53
diff --git a/e2fsprogs/blkid/blkidP.h b/e2fsprogs/blkid/blkidP.h
index 1bb94907e..43b4f0f53 100644
--- a/e2fsprogs/blkid/blkidP.h
+++ b/e2fsprogs/blkid/blkidP.h
@@ -93,7 +93,7 @@ struct blkid_struct_cache
93 struct list_head bic_devs; /* List head of all devices */ 93 struct list_head bic_devs; /* List head of all devices */
94 struct list_head bic_tags; /* List head of all tag types */ 94 struct list_head bic_tags; /* List head of all tag types */
95 time_t bic_time; /* Last probe time */ 95 time_t bic_time; /* Last probe time */
96 time_t bic_ftime; /* Mod time of the cachefile */ 96 time_t bic_ftime; /* Mod time of the cachefile */
97 unsigned int bic_flags; /* Status flags of the cache */ 97 unsigned int bic_flags; /* Status flags of the cache */
98 char *bic_filename; /* filename of cache */ 98 char *bic_filename; /* filename of cache */
99}; 99};
@@ -141,7 +141,7 @@ extern const char *blkid_devdirs[];
141 141
142#ifdef CONFIG_BLKID_DEBUG 142#ifdef CONFIG_BLKID_DEBUG
143#include <stdio.h> 143#include <stdio.h>
144extern int blkid_debug_mask; 144extern int blkid_debug_mask;
145#define DBG(m,x) if ((m) & blkid_debug_mask) x; 145#define DBG(m,x) if ((m) & blkid_debug_mask) x;
146#else 146#else
147#define DBG(m,x) 147#define DBG(m,x)
@@ -152,7 +152,7 @@ static inline void DEB_DUMP_TAG(int mask, blkid_tag tag)
152{ 152{
153 if (!(mask & blkid_debug_mask)) 153 if (!(mask & blkid_debug_mask))
154 return; 154 return;
155 155
156 if (!tag) { 156 if (!tag) {
157 printf(" tag: NULL\n"); 157 printf(" tag: NULL\n");
158 return; 158 return;
@@ -167,7 +167,7 @@ static inline void DEB_DUMP_DEV(int mask, blkid_dev dev)
167 167
168 if (!(mask & blkid_debug_mask)) 168 if (!(mask & blkid_debug_mask))
169 return; 169 return;
170 170
171 if (!dev) { 171 if (!dev) {
172 printf(" dev: NULL\n"); 172 printf(" dev: NULL\n");
173 return; 173 return;
@@ -210,7 +210,12 @@ static inline void DEB_DUMP_CACHE(int mask, blkid_cache cache)
210#endif 210#endif
211 211
212/* lseek.c */ 212/* lseek.c */
213extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence); 213/* extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence); */
214#ifdef CONFIG_LFS
215# define blkid_llseek lseek64
216#else
217# define blkid_llseek lseek
218#endif
214 219
215/* read.c */ 220/* read.c */
216extern void blkid_read_cache(blkid_cache cache); 221extern void blkid_read_cache(blkid_cache cache);
diff --git a/e2fsprogs/blkid/getsize.c b/e2fsprogs/blkid/blkid_getsize.c
index 9458c08bf..9458c08bf 100644
--- a/e2fsprogs/blkid/getsize.c
+++ b/e2fsprogs/blkid/blkid_getsize.c
diff --git a/e2fsprogs/ext2fs/ext2_io.h b/e2fsprogs/ext2fs/ext2_io.h
index e17886c85..190f6c132 100644
--- a/e2fsprogs/ext2fs/ext2_io.h
+++ b/e2fsprogs/ext2fs/ext2_io.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * io.h --- the I/O manager abstraction 2 * io.h --- the I/O manager abstraction
3 * 3 *
4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. 4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
5 * 5 *
6 * %Begin-Header% 6 * %Begin-Header%
@@ -22,7 +22,12 @@ typedef long ext2_loff_t;
22#endif 22#endif
23 23
24/* llseek.c */ 24/* llseek.c */
25ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int); 25/* ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int); */
26#ifdef CONFIG_LFS
27# define ext2fs_llseek lseek64
28#else
29# define ext2fs_llseek lseek
30#endif
26 31
27typedef struct struct_io_manager *io_manager; 32typedef struct struct_io_manager *io_manager;
28typedef struct struct_io_channel *io_channel; 33typedef struct struct_io_channel *io_channel;
@@ -40,8 +45,8 @@ struct struct_io_channel {
40 void *data, 45 void *data,
41 size_t size, 46 size_t size,
42 int actual_bytes_read, 47 int actual_bytes_read,
43 errcode_t error); 48 errcode_t error);
44 errcode_t (*write_error)(io_channel channel, 49 errcode_t (*write_error)(io_channel channel,
45 unsigned long block, 50 unsigned long block,
46 int count, 51 int count,
47 const void *data, 52 const void *data,
@@ -68,9 +73,9 @@ struct struct_io_manager {
68 errcode_t (*flush)(io_channel channel); 73 errcode_t (*flush)(io_channel channel);
69 errcode_t (*write_byte)(io_channel channel, unsigned long offset, 74 errcode_t (*write_byte)(io_channel channel, unsigned long offset,
70 int count, const void *data); 75 int count, const void *data);
71 errcode_t (*set_option)(io_channel channel, const char *option, 76 errcode_t (*set_option)(io_channel channel, const char *option,
72 const char *arg); 77 const char *arg);
73 int reserved[14]; 78 int reserved[14];
74}; 79};
75 80
76#define IO_FLAG_RW 1 81#define IO_FLAG_RW 1
@@ -78,17 +83,17 @@ struct struct_io_manager {
78/* 83/*
79 * Convenience functions.... 84 * Convenience functions....
80 */ 85 */
81#define io_channel_close(c) ((c)->manager->close((c))) 86#define io_channel_close(c) ((c)->manager->close((c)))
82#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s)) 87#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
83#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d)) 88#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
84#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d)) 89#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
85#define io_channel_flush(c) ((c)->manager->flush((c))) 90#define io_channel_flush(c) ((c)->manager->flush((c)))
86#define io_channel_bumpcount(c) ((c)->refcount++) 91#define io_channel_bumpcount(c) ((c)->refcount++)
87 92
88/* io_manager.c */ 93/* io_manager.c */
89extern errcode_t io_channel_set_options(io_channel channel, 94extern errcode_t io_channel_set_options(io_channel channel,
90 const char *options); 95 const char *options);
91extern errcode_t io_channel_write_byte(io_channel channel, 96extern errcode_t io_channel_write_byte(io_channel channel,
92 unsigned long offset, 97 unsigned long offset,
93 int count, const void *data); 98 int count, const void *data);
94 99
@@ -105,4 +110,4 @@ extern void (*test_io_cb_set_blksize)
105 (int blksize, errcode_t err); 110 (int blksize, errcode_t err);
106 111
107#endif /* _EXT2FS_EXT2_IO_H */ 112#endif /* _EXT2FS_EXT2_IO_H */
108 113
diff --git a/e2fsprogs/ext2fs/llseek.c b/e2fsprogs/ext2fs/llseek.c
deleted file mode 100644
index 6bb84bf09..000000000
--- a/e2fsprogs/ext2fs/llseek.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * llseek.c -- stub calling the llseek system call
3 *
4 * Copyright (C) 1994, 1995, 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the
8 * GNU Lesser General Public License.
9 * %End-Header%
10 */
11
12#if HAVE_SYS_TYPES_H
13#include <sys/types.h>
14#endif
15
16#if HAVE_ERRNO_H
17#include <errno.h>
18#endif
19#if HAVE_UNISTD_H
20#include <unistd.h>
21#endif
22
23#include "ext2fs/ext2_io.h"
24
25#ifdef CONFIG_LFS
26# define my_llseek lseek64
27#else
28# define my_llseek lseek
29#endif
30
31ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
32{
33 ext2_loff_t result;
34 static int do_compat = 0;
35
36 if ((sizeof(off_t) >= sizeof(ext2_loff_t)) ||
37 (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1))))
38 return lseek(fd, (off_t) offset, origin);
39
40 if (do_compat) {
41 errno = EINVAL;
42 return -1;
43 }
44
45 result = my_llseek (fd, offset, origin);
46 if (result == -1 && errno == ENOSYS) {
47 /*
48 * Just in case this code runs on top of an old kernel
49 * which does not support the llseek system call
50 */
51 do_compat++;
52 errno = EINVAL;
53 }
54 return result;
55}
diff --git a/e2fsprogs/mke2fs.c b/e2fsprogs/mke2fs.c
index cd3f2231a..f41857866 100644
--- a/e2fsprogs/mke2fs.c
+++ b/e2fsprogs/mke2fs.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * mke2fs.c - Make a ext2fs filesystem. 2 * mke2fs.c - Make a ext2fs filesystem.
3 * 3 *
4 * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 4 * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5 * 2003, 2004, 2005 by Theodore Ts'o. 5 * 2003, 2004, 2005 by Theodore Ts'o.
6 * 6 *
7 * %Begin-Header% 7 * %Begin-Header%
8 * This file may be redistributed under the terms of the GNU Public 8 * This file may be redistributed under the terms of the GNU Public
@@ -11,9 +11,9 @@
11 */ 11 */
12 12
13/* Usage: mke2fs [options] device 13/* Usage: mke2fs [options] device
14 * 14 *
15 * The device may be a block device or a image of one, but this isn't 15 * The device may be a block device or a image of one, but this isn't
16 * enforced (but it's not much fun on a character device :-). 16 * enforced (but it's not much fun on a character device :-).
17 */ 17 */
18 18
19#include <stdio.h> 19#include <stdio.h>
@@ -52,7 +52,7 @@ static int force;
52static int noaction; 52static int noaction;
53static int journal_size; 53static int journal_size;
54static int journal_flags; 54static int journal_flags;
55static char *bad_blocks_filename; 55static const char *bad_blocks_filename;
56static __u32 fs_stride; 56static __u32 fs_stride;
57 57
58static struct ext2_super_block param; 58static struct ext2_super_block param;
@@ -60,7 +60,7 @@ static char *creator_os;
60static char *volume_label; 60static char *volume_label;
61static char *mount_dir; 61static char *mount_dir;
62static char *journal_device; 62static char *journal_device;
63static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */ 63static int sync_kludge; /* Set using the MKE2FS_SYNC env. option */
64 64
65static int sys_page_size = 4096; 65static int sys_page_size = 4096;
66static int linux_version_code = 0; 66static int linux_version_code = 0;
@@ -95,21 +95,23 @@ static int int_log10(unsigned int arg)
95 * Note that order is important in the table below. 95 * Note that order is important in the table below.
96 */ 96 */
97#define DEF_MAX_BLOCKSIZE -1 97#define DEF_MAX_BLOCKSIZE -1
98static char default_str[] = "default"; 98static const char default_str[] = "default";
99struct mke2fs_defaults { 99struct mke2fs_defaults {
100 const char *type; 100 const char *type;
101 int size; 101 int size;
102 int blocksize; 102 int blocksize;
103 int inode_ratio; 103 int inode_ratio;
104} settings[] = { 104};
105 { default_str, 0, 4096, 8192 }, 105
106static const struct mke2fs_defaults settings[] = {
107 { default_str, 0, 4096, 8192 },
106 { default_str, 512, 1024, 4096 }, 108 { default_str, 512, 1024, 4096 },
107 { default_str, 3, 1024, 8192 }, 109 { default_str, 3, 1024, 8192 },
108 { "journal", 0, 4096, 8192 }, 110 { "journal", 0, 4096, 8192 },
109 { "news", 0, 4096, 4096 }, 111 { "news", 0, 4096, 4096 },
110 { "largefile", 0, 4096, 1024 * 1024 }, 112 { "largefile", 0, 4096, 1024 * 1024 },
111 { "largefile4", 0, 4096, 4096 * 1024 }, 113 { "largefile4", 0, 4096, 4096 * 1024 },
112 { 0, 0, 0, 0}, 114 { 0, 0, 0, 0},
113}; 115};
114 116
115static void set_fs_defaults(const char *fs_type, 117static void set_fs_defaults(const char *fs_type,
@@ -119,7 +121,7 @@ static void set_fs_defaults(const char *fs_type,
119{ 121{
120 int megs; 122 int megs;
121 int ratio = 0; 123 int ratio = 0;
122 struct mke2fs_defaults *p; 124 const struct mke2fs_defaults *p;
123 int use_bsize = 1024; 125 int use_bsize = 1024;
124 126
125 megs = super->s_blocks_count * (EXT2_BLOCK_SIZE(super) / 1024) / 1024; 127 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)
199 quiet ? "" : "-s ", (cflag > 1) ? "-w " : "", 201 quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
200 fs->device_name, fs->super->s_blocks_count); 202 fs->device_name, fs->super->s_blocks_count);
201 if (!quiet) 203 if (!quiet)
202 printf(_("Running command: %s\n"), buf); 204 printf("Running command: %s\n", buf);
203 f = popen(buf, "r"); 205 f = popen(buf, "r");
204 if (!f) { 206 if (!f) {
205 bb_perror_msg_and_die("Could not run '%s'", buf); 207 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)
216{ 218{
217 dgrp_t i; 219 dgrp_t i;
218 blk_t j; 220 blk_t j;
219 unsigned must_be_good; 221 unsigned must_be_good;
220 blk_t blk; 222 blk_t blk;
221 badblocks_iterate bb_iter; 223 badblocks_iterate bb_iter;
222 errcode_t retval; 224 errcode_t retval;
@@ -226,7 +228,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
226 228
227 if (!bb_list) 229 if (!bb_list)
228 return; 230 return;
229 231
230 /* 232 /*
231 * The primary superblock and group descriptors *must* be 233 * The primary superblock and group descriptors *must* be
232 * good; if not, abort. 234 * good; if not, abort.
@@ -248,16 +250,16 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
248 */ 250 */
249 group_block = fs->super->s_first_data_block + 251 group_block = fs->super->s_first_data_block +
250 fs->super->s_blocks_per_group; 252 fs->super->s_blocks_per_group;
251 253
252 for (i = 1; i < fs->group_desc_count; i++) { 254 for (i = 1; i < fs->group_desc_count; i++) {
253 group_bad = 0; 255 group_bad = 0;
254 for (j=0; j < fs->desc_blocks+1; j++) { 256 for (j=0; j < fs->desc_blocks+1; j++) {
255 if (ext2fs_badblocks_list_test(bb_list, 257 if (ext2fs_badblocks_list_test(bb_list,
256 group_block + j)) { 258 group_block + j)) {
257 if (!group_bad) 259 if (!group_bad)
258 bb_error_msg( 260 bb_error_msg(
259 "Warning: the backup superblock/group descriptors at block %d contain\n" 261 "Warning: the backup superblock/group descriptors at block %d contain\n"
260 " bad blocks\n", group_block); 262 " bad blocks\n", group_block);
261 group_bad++; 263 group_bad++;
262 group = ext2fs_group_of_blk(fs, group_block+j); 264 group = ext2fs_group_of_blk(fs, group_block+j);
263 fs->group_desc[group].bg_free_blocks_count++; 265 fs->group_desc[group].bg_free_blocks_count++;
@@ -266,7 +268,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
266 } 268 }
267 group_block += fs->super->s_blocks_per_group; 269 group_block += fs->super->s_blocks_per_group;
268 } 270 }
269 271
270 /* 272 /*
271 * Mark all the bad blocks as used... 273 * Mark all the bad blocks as used...
272 */ 274 */
@@ -274,7 +276,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
274 if (retval) { 276 if (retval) {
275 bb_error_msg_and_die("while marking bad blocks as used"); 277 bb_error_msg_and_die("while marking bad blocks as used");
276 } 278 }
277 while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) 279 while (ext2fs_badblocks_list_iterate(bb_iter, &blk))
278 ext2fs_mark_block_bitmap(fs->block_map, blk); 280 ext2fs_mark_block_bitmap(fs->block_map, blk);
279 ext2fs_badblocks_list_iterate_end(bb_iter); 281 ext2fs_badblocks_list_iterate_end(bb_iter);
280} 282}
@@ -329,7 +331,7 @@ static void progress_close(struct progress_struct *progress)
329{ 331{
330 if (progress->format[0] == 0) 332 if (progress->format[0] == 0)
331 return; 333 return;
332 fputs(_("done \n"), stdout); 334 fputs("done \n", stdout);
333} 335}
334 336
335 337
@@ -361,8 +363,7 @@ static errcode_t zero_blocks(ext2_filsys fs, blk_t blk, int num,
361 } 363 }
362 /* Allocate the zeroizing buffer if necessary */ 364 /* Allocate the zeroizing buffer if necessary */
363 if (!buf) { 365 if (!buf) {
364 buf = xmalloc(fs->blocksize * STRIDE_LENGTH); 366 buf = xcalloc(fs->blocksize, STRIDE_LENGTH);
365 memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
366 } 367 }
367 /* OK, do the write loop */ 368 /* OK, do the write loop */
368 next_update = 0; 369 next_update = 0;
@@ -387,7 +388,7 @@ static errcode_t zero_blocks(ext2_filsys fs, blk_t blk, int num,
387 } 388 }
388 } 389 }
389 return 0; 390 return 0;
390} 391}
391 392
392static void write_inode_tables(ext2_filsys fs) 393static void write_inode_tables(ext2_filsys fs)
393{ 394{
@@ -400,12 +401,12 @@ static void write_inode_tables(ext2_filsys fs)
400 if (quiet) 401 if (quiet)
401 memset(&progress, 0, sizeof(progress)); 402 memset(&progress, 0, sizeof(progress));
402 else 403 else
403 progress_init(&progress, _("Writing inode tables: "), 404 progress_init(&progress, "Writing inode tables: ",
404 fs->group_desc_count); 405 fs->group_desc_count);
405 406
406 for (i = 0; i < fs->group_desc_count; i++) { 407 for (i = 0; i < fs->group_desc_count; i++) {
407 progress_update(&progress, i); 408 progress_update(&progress, i);
408 409
409 blk = fs->group_desc[i].bg_inode_table; 410 blk = fs->group_desc[i].bg_inode_table;
410 num = fs->inode_blocks_per_group; 411 num = fs->inode_blocks_per_group;
411 412
@@ -429,7 +430,7 @@ static void write_inode_tables(ext2_filsys fs)
429 430
430static void create_root_dir(ext2_filsys fs) 431static void create_root_dir(ext2_filsys fs)
431{ 432{
432 errcode_t retval; 433 errcode_t retval;
433 struct ext2_inode inode; 434 struct ext2_inode inode;
434 435
435 retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0); 436 retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
@@ -469,7 +470,7 @@ static void create_lost_and_found(ext2_filsys fs)
469 if (retval) { 470 if (retval) {
470 bb_error_msg_and_die("Could not look up lost+found"); 471 bb_error_msg_and_die("Could not look up lost+found");
471 } 472 }
472 473
473 for (i=1; i < EXT2_NDIR_BLOCKS; i++) { 474 for (i=1; i < EXT2_NDIR_BLOCKS; i++) {
474 if ((lpf_size += fs->blocksize) >= 16*1024) 475 if ((lpf_size += fs->blocksize) >= 16*1024)
475 break; 476 break;
@@ -483,7 +484,7 @@ static void create_lost_and_found(ext2_filsys fs)
483static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list) 484static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list)
484{ 485{
485 errcode_t retval; 486 errcode_t retval;
486 487
487 ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO); 488 ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO);
488 fs->group_desc[0].bg_free_inodes_count--; 489 fs->group_desc[0].bg_free_inodes_count--;
489 fs->super->s_free_inodes_count--; 490 fs->super->s_free_inodes_count--;
@@ -544,7 +545,7 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
544 545
545static void create_journal_dev(ext2_filsys fs) 546static void create_journal_dev(ext2_filsys fs)
546{ 547{
547 struct progress_struct progress; 548 struct progress_struct progress;
548 errcode_t retval; 549 errcode_t retval;
549 char *buf; 550 char *buf;
550 blk_t blk; 551 blk_t blk;
@@ -558,7 +559,7 @@ static void create_journal_dev(ext2_filsys fs)
558 if (quiet) 559 if (quiet)
559 memset(&progress, 0, sizeof(progress)); 560 memset(&progress, 0, sizeof(progress));
560 else 561 else
561 progress_init(&progress, _("Zeroing journal device: "), 562 progress_init(&progress, "Zeroing journal device: ",
562 fs->super->s_blocks_count); 563 fs->super->s_blocks_count);
563 564
564 retval = zero_blocks(fs, 0, fs->super->s_blocks_count, 565 retval = zero_blocks(fs, 0, fs->super->s_blocks_count,
@@ -581,12 +582,12 @@ static void create_journal_dev(ext2_filsys fs)
581static void show_stats(ext2_filsys fs) 582static void show_stats(ext2_filsys fs)
582{ 583{
583 struct ext2_super_block *s = fs->super; 584 struct ext2_super_block *s = fs->super;
584 char buf[80]; 585 char buf[80];
585 char *os; 586 char *os;
586 blk_t group_block; 587 blk_t group_block;
587 dgrp_t i; 588 dgrp_t i;
588 int need, col_left; 589 int need, col_left;
589 590
590 if (param.s_blocks_count != s->s_blocks_count) 591 if (param.s_blocks_count != s->s_blocks_count)
591 bb_error_msg("warning: %d blocks unused\n", 592 bb_error_msg("warning: %d blocks unused\n",
592 param.s_blocks_count - s->s_blocks_count); 593 param.s_blocks_count - s->s_blocks_count);
@@ -594,40 +595,39 @@ static void show_stats(ext2_filsys fs)
594 memset(buf, 0, sizeof(buf)); 595 memset(buf, 0, sizeof(buf));
595 strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name)); 596 strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
596 printf("Filesystem label=%s\n", buf); 597 printf("Filesystem label=%s\n", buf);
597 fputs(_("OS type: "), stdout); 598 fputs("OS type: ", stdout);
598 os = e2p_os2string(fs->super->s_creator_os); 599 os = e2p_os2string(fs->super->s_creator_os);
599 fputs(os, stdout); 600 fputs(os, stdout);
600 free(os); 601 free(os);
601 printf("\n"); 602 printf("\nBlock size=%u (log=%u)\n", fs->blocksize,
602 printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
603 s->s_log_block_size); 603 s->s_log_block_size);
604 printf(_("Fragment size=%u (log=%u)\n"), fs->fragsize, 604 printf("Fragment size=%u (log=%u)\n", fs->fragsize,
605 s->s_log_frag_size); 605 s->s_log_frag_size);
606 printf(_("%u inodes, %u blocks\n"), s->s_inodes_count, 606 printf("%u inodes, %u blocks\n", s->s_inodes_count,
607 s->s_blocks_count); 607 s->s_blocks_count);
608 printf(_("%u blocks (%2.2f%%) reserved for the super user\n"), 608 printf("%u blocks (%2.2f%%) reserved for the super user\n",
609 s->s_r_blocks_count, 609 s->s_r_blocks_count,
610 100.0 * s->s_r_blocks_count / s->s_blocks_count); 610 100.0 * s->s_r_blocks_count / s->s_blocks_count);
611 printf(_("First data block=%u\n"), s->s_first_data_block); 611 printf("First data block=%u\n", s->s_first_data_block);
612 if (s->s_reserved_gdt_blocks) 612 if (s->s_reserved_gdt_blocks)
613 printf(_("Maximum filesystem blocks=%lu\n"), 613 printf("Maximum filesystem blocks=%lu\n",
614 (s->s_reserved_gdt_blocks + fs->desc_blocks) * 614 (s->s_reserved_gdt_blocks + fs->desc_blocks) *
615 (fs->blocksize / sizeof(struct ext2_group_desc)) * 615 (fs->blocksize / sizeof(struct ext2_group_desc)) *
616 s->s_blocks_per_group); 616 s->s_blocks_per_group);
617 if (fs->group_desc_count > 1) 617 if (fs->group_desc_count > 1)
618 printf(_("%u block groups\n"), fs->group_desc_count); 618 printf("%u block groups\n", fs->group_desc_count);
619 else 619 else
620 printf(_("%u block group\n"), fs->group_desc_count); 620 printf("%u block group\n", fs->group_desc_count);
621 printf(_("%u blocks per group, %u fragments per group\n"), 621 printf("%u blocks per group, %u fragments per group\n",
622 s->s_blocks_per_group, s->s_frags_per_group); 622 s->s_blocks_per_group, s->s_frags_per_group);
623 printf(_("%u inodes per group\n"), s->s_inodes_per_group); 623 printf("%u inodes per group\n", s->s_inodes_per_group);
624 624
625 if (fs->group_desc_count == 1) { 625 if (fs->group_desc_count == 1) {
626 printf("\n"); 626 printf("\n");
627 return; 627 return;
628 } 628 }
629 629
630 printf(_("Superblock backups stored on blocks: ")); 630 printf("Superblock backups stored on blocks: ");
631 group_block = s->s_first_data_block; 631 group_block = s->s_first_data_block;
632 col_left = 0; 632 col_left = 0;
633 for (i = 1; i < fs->group_desc_count; i++) { 633 for (i = 1; i < fs->group_desc_count; i++) {
@@ -673,16 +673,13 @@ static int set_os(struct ext2_super_block *sb, char *os)
673 673
674#define PATH_SET "PATH=/sbin" 674#define PATH_SET "PATH=/sbin"
675 675
676static void parse_extended_opts(struct ext2_super_block *sb_param, 676static void parse_extended_opts(struct ext2_super_block *sb_param,
677 const char *opts) 677 const char *opts)
678{ 678{
679 char *buf, *token, *next, *p, *arg; 679 char *buf, *token, *next, *p, *arg;
680 int len;
681 int r_usage = 0; 680 int r_usage = 0;
682 681
683 len = strlen(opts); 682 buf = bb_xstrdup(opts);
684 buf = xmalloc(len+1);
685 strcpy(buf, opts);
686 for (token = buf; token && *token; token = next) { 683 for (token = buf; token && *token; token = next) {
687 p = strchr(token, ','); 684 p = strchr(token, ',');
688 next = 0; 685 next = 0;
@@ -717,7 +714,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
717 continue; 714 continue;
718 } 715 }
719 716
720 resize = parse_num_blocks(arg, 717 resize = parse_num_blocks(arg,
721 sb_param->s_log_block_size); 718 sb_param->s_log_block_size);
722 719
723 if (resize == 0) { 720 if (resize == 0) {
@@ -741,7 +738,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
741 desc_blocks = (group_desc_count + 738 desc_blocks = (group_desc_count +
742 gdpb - 1) / gdpb; 739 gdpb - 1) / gdpb;
743 rsv_groups = (resize + bpg - 1) / bpg; 740 rsv_groups = (resize + bpg - 1) / bpg;
744 rsv_gdb = (rsv_groups + gdpb - 1) / gdpb - 741 rsv_gdb = (rsv_groups + gdpb - 1) / gdpb -
745 desc_blocks; 742 desc_blocks;
746 if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb_param)) 743 if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb_param))
747 rsv_gdb = EXT2_ADDR_PER_BLOCK(sb_param); 744 rsv_gdb = EXT2_ADDR_PER_BLOCK(sb_param);
@@ -765,20 +762,20 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
765 "\tstride=<stride length in blocks>\n" 762 "\tstride=<stride length in blocks>\n"
766 "\tresize=<resize maximum size in blocks>\n"); 763 "\tresize=<resize maximum size in blocks>\n");
767 } 764 }
768} 765}
769 766
770static __u32 ok_features[3] = { 767static __u32 ok_features[3] = {
771 EXT3_FEATURE_COMPAT_HAS_JOURNAL | 768 EXT3_FEATURE_COMPAT_HAS_JOURNAL |
772 EXT2_FEATURE_COMPAT_RESIZE_INODE | 769 EXT2_FEATURE_COMPAT_RESIZE_INODE |
773 EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */ 770 EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */
774 EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */ 771 EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */
775 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV| 772 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
776 EXT2_FEATURE_INCOMPAT_META_BG, 773 EXT2_FEATURE_INCOMPAT_META_BG,
777 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER /* R/O compat */ 774 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER /* R/O compat */
778}; 775};
779 776
780 777
781static void PRS(int argc, char *argv[]) 778static int PRS(int argc, char *argv[])
782{ 779{
783 int b, c; 780 int b, c;
784 int size; 781 int size;
@@ -800,12 +797,8 @@ static void PRS(int argc, char *argv[])
800 /* Update our PATH to include /sbin */ 797 /* Update our PATH to include /sbin */
801 if (oldpath) { 798 if (oldpath) {
802 char *newpath; 799 char *newpath;
803 800
804 newpath = xmalloc(sizeof (PATH_SET) + 1 + strlen (oldpath)); 801 bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath);
805 strcpy (newpath, PATH_SET);
806 strcat (newpath, ":");
807 strcat (newpath, oldpath);
808 putenv (newpath);
809 } else 802 } else
810 putenv (PATH_SET); 803 putenv (PATH_SET);
811 804
@@ -822,7 +815,7 @@ static void PRS(int argc, char *argv[])
822 if (sysval > 0) 815 if (sysval > 0)
823 sys_page_size = sysval; 816 sys_page_size = sysval;
824#endif /* _SC_PAGESIZE */ 817#endif /* _SC_PAGESIZE */
825 818
826 setbuf(stdout, NULL); 819 setbuf(stdout, NULL);
827 setbuf(stderr, NULL); 820 setbuf(stderr, NULL);
828 memset(&param, 0, sizeof(struct ext2_super_block)); 821 memset(&param, 0, sizeof(struct ext2_super_block));
@@ -863,7 +856,7 @@ static void PRS(int argc, char *argv[])
863 bb_error_msg( 856 bb_error_msg(
864 "Warning: blocksize %d not usable on most systems", 857 "Warning: blocksize %d not usable on most systems",
865 blocksize); 858 blocksize);
866 if (blocksize > 0) 859 if (blocksize > 0)
867 param.s_log_block_size = 860 param.s_log_block_size =
868 int_log2(blocksize >> 861 int_log2(blocksize >>
869 EXT2_MIN_BLOCK_LOG_SIZE); 862 EXT2_MIN_BLOCK_LOG_SIZE);
@@ -913,8 +906,7 @@ static void PRS(int argc, char *argv[])
913 journal_size = -1; 906 journal_size = -1;
914 break; 907 break;
915 case 'l': 908 case 'l':
916 bad_blocks_filename = xmalloc(strlen(optarg)+1); 909 bad_blocks_filename = optarg;
917 strcpy(bad_blocks_filename, optarg);
918 break; 910 break;
919 case 'm': 911 case 'm':
920 reserved_ratio = strtoul(optarg, &tmp, 0); 912 reserved_ratio = strtoul(optarg, &tmp, 0);
@@ -940,7 +932,7 @@ static void PRS(int argc, char *argv[])
940 if (atoi(optarg)) 932 if (atoi(optarg))
941 param.s_feature_ro_compat |= 933 param.s_feature_ro_compat |=
942 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; 934 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
943 else 935 else
944 param.s_feature_ro_compat &= 936 param.s_feature_ro_compat &=
945 ~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; 937 ~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
946 break; 938 break;
@@ -1006,11 +998,11 @@ static void PRS(int argc, char *argv[])
1006 device_name = argv[optind++]; 998 device_name = argv[optind++];
1007 999
1008 if (!quiet || show_version_only) 1000 if (!quiet || show_version_only)
1009 bb_error_msg("mke2fs %s (%s)", E2FSPROGS_VERSION, 1001 bb_error_msg("mke2fs %s (%s)", E2FSPROGS_VERSION,
1010 E2FSPROGS_DATE); 1002 E2FSPROGS_DATE);
1011 1003
1012 if (show_version_only) { 1004 if (show_version_only) {
1013 exit(0); 1005 return 0;
1014 } 1006 }
1015 1007
1016 /* 1008 /*
@@ -1018,8 +1010,8 @@ static void PRS(int argc, char *argv[])
1018 * device, use it to figure out the blocksize 1010 * device, use it to figure out the blocksize
1019 */ 1011 */
1020 if (blocksize <= 0 && journal_device) { 1012 if (blocksize <= 0 && journal_device) {
1021 ext2_filsys jfs; 1013 ext2_filsys jfs;
1022 io_manager io_ptr; 1014 io_manager io_ptr;
1023 1015
1024#ifdef CONFIG_TESTIO_DEBUG 1016#ifdef CONFIG_TESTIO_DEBUG
1025 io_ptr = test_io_manager; 1017 io_ptr = test_io_manager;
@@ -1064,7 +1056,7 @@ static void PRS(int argc, char *argv[])
1064 " Use -b 4096 if this is an issue for you\n"); 1056 " Use -b 4096 if this is an issue for you\n");
1065 1057
1066 if (optind < argc) { 1058 if (optind < argc) {
1067 param.s_blocks_count = parse_num_blocks(argv[optind++], 1059 param.s_blocks_count = parse_num_blocks(argv[optind++],
1068 param.s_log_block_size); 1060 param.s_log_block_size);
1069 if (!param.s_blocks_count) { 1061 if (!param.s_blocks_count) {
1070 bb_error_msg_and_die("bad blocks count - %s", argv[optind - 1]); 1062 bb_error_msg_and_die("bad blocks count - %s", argv[optind - 1]);
@@ -1080,15 +1072,15 @@ static void PRS(int argc, char *argv[])
1080 param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV; 1072 param.s_feature_incompat = EXT3_FEATURE_INCOMPAT_JOURNAL_DEV;
1081 param.s_feature_compat = 0; 1073 param.s_feature_compat = 0;
1082 param.s_feature_ro_compat = 0; 1074 param.s_feature_ro_compat = 0;
1083 } 1075 }
1084 if (param.s_rev_level == EXT2_GOOD_OLD_REV && 1076 if (param.s_rev_level == EXT2_GOOD_OLD_REV &&
1085 (param.s_feature_compat || param.s_feature_ro_compat || 1077 (param.s_feature_compat || param.s_feature_ro_compat ||
1086 param.s_feature_incompat)) 1078 param.s_feature_incompat))
1087 param.s_rev_level = 1; /* Create a revision 1 filesystem */ 1079 param.s_rev_level = 1; /* Create a revision 1 filesystem */
1088 1080
1089 if (!force) 1081 if (!force)
1090 check_plausibility(device_name); 1082 check_plausibility(device_name);
1091 check_mount(device_name, force, _("filesystem")); 1083 check_mount(device_name, force, "filesystem");
1092 1084
1093 param.s_log_frag_size = param.s_log_block_size; 1085 param.s_log_frag_size = param.s_log_block_size;
1094 1086
@@ -1101,14 +1093,14 @@ static void PRS(int argc, char *argv[])
1101 EXT2_BLOCK_SIZE(&param), 1093 EXT2_BLOCK_SIZE(&param),
1102 &dev_size); 1094 &dev_size);
1103 if ((retval == EFBIG) && 1095 if ((retval == EFBIG) &&
1104 (blocksize == 0) && 1096 (blocksize == 0) &&
1105 (param.s_log_block_size == 0)) { 1097 (param.s_log_block_size == 0)) {
1106 param.s_log_block_size = 2; 1098 param.s_log_block_size = 2;
1107 blocksize = 4096; 1099 blocksize = 4096;
1108 goto retry; 1100 goto retry;
1109 } 1101 }
1110 } 1102 }
1111 1103
1112 if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) { 1104 if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
1113 bb_error_msg_and_die("Could not determine filesystem size"); 1105 bb_error_msg_and_die("Could not determine filesystem size");
1114 } 1106 }
@@ -1135,7 +1127,7 @@ static void PRS(int argc, char *argv[])
1135 param.s_blocks_count &= ~((sys_page_size / 1127 param.s_blocks_count &= ~((sys_page_size /
1136 EXT2_BLOCK_SIZE(&param))-1); 1128 EXT2_BLOCK_SIZE(&param))-1);
1137 } 1129 }
1138 1130
1139 } else if (!force && (param.s_blocks_count > dev_size)) { 1131 } else if (!force && (param.s_blocks_count > dev_size)) {
1140 bb_error_msg("Filesystem larger than apparent device size"); 1132 bb_error_msg("Filesystem larger than apparent device size");
1141 proceed_question(); 1133 proceed_question();
@@ -1163,10 +1155,10 @@ static void PRS(int argc, char *argv[])
1163 1155
1164 if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL) 1156 if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
1165 sector_size = atoi(tmp); 1157 sector_size = atoi(tmp);
1166 1158
1167 set_fs_defaults(fs_type, &param, blocksize, sector_size, &inode_ratio); 1159 set_fs_defaults(fs_type, &param, blocksize, sector_size, &inode_ratio);
1168 blocksize = EXT2_BLOCK_SIZE(&param); 1160 blocksize = EXT2_BLOCK_SIZE(&param);
1169 1161
1170 if (extended_opts) 1162 if (extended_opts)
1171 parse_extended_opts(&param, extended_opts); 1163 parse_extended_opts(&param, extended_opts);
1172 1164
@@ -1204,7 +1196,7 @@ static void PRS(int argc, char *argv[])
1204 /* 1196 /*
1205 * Calculate number of inodes based on the inode ratio 1197 * Calculate number of inodes based on the inode ratio
1206 */ 1198 */
1207 param.s_inodes_count = num_inodes ? num_inodes : 1199 param.s_inodes_count = num_inodes ? num_inodes :
1208 ((__u64) param.s_blocks_count * blocksize) 1200 ((__u64) param.s_blocks_count * blocksize)
1209 / inode_ratio; 1201 / inode_ratio;
1210 1202
@@ -1212,11 +1204,12 @@ static void PRS(int argc, char *argv[])
1212 * Calculate number of blocks to reserve 1204 * Calculate number of blocks to reserve
1213 */ 1205 */
1214 param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100; 1206 param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100;
1207 return 1;
1215} 1208}
1216 1209
1217int mke2fs_main (int argc, char *argv[]) 1210int mke2fs_main (int argc, char *argv[])
1218{ 1211{
1219 errcode_t retval = 0; 1212 errcode_t retval;
1220 ext2_filsys fs; 1213 ext2_filsys fs;
1221 badblocks_list bb_list = 0; 1214 badblocks_list bb_list = 0;
1222 int journal_blocks; 1215 int journal_blocks;
@@ -1224,13 +1217,8 @@ int mke2fs_main (int argc, char *argv[])
1224 int val; 1217 int val;
1225 io_manager io_ptr; 1218 io_manager io_ptr;
1226 1219
1227#ifdef ENABLE_NLS 1220 if(!PRS(argc, argv))
1228 setlocale(LC_MESSAGES, ""); 1221 return 0;
1229 setlocale(LC_CTYPE, "");
1230 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
1231 textdomain(NLS_CAT_NAME);
1232#endif
1233 PRS(argc, argv);
1234 1222
1235#ifdef CONFIG_TESTIO_DEBUG 1223#ifdef CONFIG_TESTIO_DEBUG
1236 io_ptr = test_io_manager; 1224 io_ptr = test_io_manager;
@@ -1308,17 +1296,17 @@ int mke2fs_main (int argc, char *argv[])
1308 strncpy(fs->super->s_last_mounted, mount_dir, 1296 strncpy(fs->super->s_last_mounted, mount_dir,
1309 sizeof(fs->super->s_last_mounted)); 1297 sizeof(fs->super->s_last_mounted));
1310 } 1298 }
1311 1299
1312 if (!quiet || noaction) 1300 if (!quiet || noaction)
1313 show_stats(fs); 1301 show_stats(fs);
1314 1302
1315 if (noaction) 1303 if (noaction)
1316 exit(0); 1304 return 0;
1317 1305
1318 if (fs->super->s_feature_incompat & 1306 if (fs->super->s_feature_incompat &
1319 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) { 1307 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
1320 create_journal_dev(fs); 1308 create_journal_dev(fs);
1321 exit(ext2fs_close(fs) ? 1 : 0); 1309 return (ext2fs_close(fs) ? 1 : 0);
1322 } 1310 }
1323 1311
1324 if (bad_blocks_filename) 1312 if (bad_blocks_filename)
@@ -1366,7 +1354,7 @@ int mke2fs_main (int argc, char *argv[])
1366 create_lost_and_found(fs); 1354 create_lost_and_found(fs);
1367 reserve_inodes(fs); 1355 reserve_inodes(fs);
1368 create_bad_block_inode(fs, bb_list); 1356 create_bad_block_inode(fs, bb_list);
1369 if (fs->super->s_feature_compat & 1357 if (fs->super->s_feature_compat &
1370 EXT2_FEATURE_COMPAT_RESIZE_INODE) { 1358 EXT2_FEATURE_COMPAT_RESIZE_INODE) {
1371 retval = ext2fs_create_resize_inode(fs); 1359 retval = ext2fs_create_resize_inode(fs);
1372 if (retval) { 1360 if (retval) {
@@ -1376,11 +1364,11 @@ int mke2fs_main (int argc, char *argv[])
1376 } 1364 }
1377 1365
1378 if (journal_device) { 1366 if (journal_device) {
1379 ext2_filsys jfs; 1367 ext2_filsys jfs;
1380 1368
1381 if (!force) 1369 if (!force)
1382 check_plausibility(journal_device); 1370 check_plausibility(journal_device);
1383 check_mount(journal_device, force, _("journal")); 1371 check_mount(journal_device, force, "journal");
1384 1372
1385 retval = ext2fs_open(journal_device, EXT2_FLAG_RW| 1373 retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
1386 EXT2_FLAG_JOURNAL_DEV_OK, 0, 1374 EXT2_FLAG_JOURNAL_DEV_OK, 0,