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:
"Vladimir N. Oleynik" 2005-09-19 13:48:39 +00:00
parent 54deebf4e4
commit b71e6024f9
6 changed files with 131 additions and 188 deletions

View File

@ -25,8 +25,8 @@ srcdir=$(top_srcdir)/e2fsprogs
E2FSPROGS_CFLAGS := -I$(srcdir) -include $(srcdir)/e2fsbb.h
BLKID_SRC := cache.c dev.c devname.c devno.c getsize.c llseek.c probe.c \
read.c resolve.c save.c tag.c resolve.c
BLKID_SRC := cache.c dev.c devname.c devno.c blkid_getsize.c \
probe.c read.c resolve.c save.c tag.c resolve.c
BLKID_SRCS := $(patsubst %,blkid/%, $(BLKID_SRC))
BLKID_OBJS := $(patsubst %.c,%.o, $(BLKID_SRCS))
@ -37,7 +37,7 @@ E2P_SRCS := $(patsubst %,e2p/%, $(E2P_SRC))
E2P_OBJS := $(patsubst %.c,%.o, $(E2P_SRCS))
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 \
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 \

View File

@ -210,7 +210,12 @@ static inline void DEB_DUMP_CACHE(int mask, blkid_cache cache)
#endif
/* 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 */
extern void blkid_read_cache(blkid_cache cache);

View File

@ -22,7 +22,12 @@ typedef long ext2_loff_t;
#endif
/* 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_channel *io_channel;

View File

@ -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;
}

View File

@ -52,7 +52,7 @@ static int force;
static int noaction;
static int journal_size;
static int journal_flags;
static char *bad_blocks_filename;
static const char *bad_blocks_filename;
static __u32 fs_stride;
static struct ext2_super_block param;
@ -95,13 +95,15 @@ static int int_log10(unsigned int arg)
* Note that order is important in the table below.
*/
#define DEF_MAX_BLOCKSIZE -1
static char default_str[] = "default";
static const char default_str[] = "default";
struct mke2fs_defaults {
const char *type;
int size;
int blocksize;
int inode_ratio;
} settings[] = {
};
static const struct mke2fs_defaults settings[] = {
{ default_str, 0, 4096, 8192 },
{ default_str, 512, 1024, 4096 },
{ default_str, 3, 1024, 8192 },
@ -119,7 +121,7 @@ static void set_fs_defaults(const char *fs_type,
{
int megs;
int ratio = 0;
struct mke2fs_defaults *p;
const struct mke2fs_defaults *p;
int use_bsize = 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 " : "",
fs->device_name, fs->super->s_blocks_count);
if (!quiet)
printf(_("Running command: %s\n"), buf);
printf("Running command: %s\n", buf);
f = popen(buf, "r");
if (!f) {
bb_perror_msg_and_die("Could not run '%s'", buf);
@ -329,7 +331,7 @@ static void progress_close(struct progress_struct *progress)
{
if (progress->format[0] == 0)
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 */
if (!buf) {
buf = xmalloc(fs->blocksize * STRIDE_LENGTH);
memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
buf = xcalloc(fs->blocksize, STRIDE_LENGTH);
}
/* OK, do the write loop */
next_update = 0;
@ -400,7 +401,7 @@ static void write_inode_tables(ext2_filsys fs)
if (quiet)
memset(&progress, 0, sizeof(progress));
else
progress_init(&progress, _("Writing inode tables: "),
progress_init(&progress, "Writing inode tables: ",
fs->group_desc_count);
for (i = 0; i < fs->group_desc_count; i++) {
@ -558,7 +559,7 @@ static void create_journal_dev(ext2_filsys fs)
if (quiet)
memset(&progress, 0, sizeof(progress));
else
progress_init(&progress, _("Zeroing journal device: "),
progress_init(&progress, "Zeroing journal device: ",
fs->super->s_blocks_count);
retval = zero_blocks(fs, 0, fs->super->s_blocks_count,
@ -594,40 +595,39 @@ static void show_stats(ext2_filsys fs)
memset(buf, 0, sizeof(buf));
strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
printf("Filesystem label=%s\n", buf);
fputs(_("OS type: "), stdout);
fputs("OS type: ", stdout);
os = e2p_os2string(fs->super->s_creator_os);
fputs(os, stdout);
free(os);
printf("\n");
printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
printf("\nBlock size=%u (log=%u)\n", fs->blocksize,
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);
printf(_("%u inodes, %u blocks\n"), s->s_inodes_count,
printf("%u inodes, %u blocks\n", s->s_inodes_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,
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)
printf(_("Maximum filesystem blocks=%lu\n"),
printf("Maximum filesystem blocks=%lu\n",
(s->s_reserved_gdt_blocks + fs->desc_blocks) *
(fs->blocksize / sizeof(struct ext2_group_desc)) *
s->s_blocks_per_group);
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
printf(_("%u block group\n"), fs->group_desc_count);
printf(_("%u blocks per group, %u fragments per group\n"),
printf("%u block group\n", fs->group_desc_count);
printf("%u blocks per group, %u fragments per group\n",
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) {
printf("\n");
return;
}
printf(_("Superblock backups stored on blocks: "));
printf("Superblock backups stored on blocks: ");
group_block = s->s_first_data_block;
col_left = 0;
for (i = 1; i < fs->group_desc_count; i++) {
@ -677,12 +677,9 @@ static void parse_extended_opts(struct ext2_super_block *sb_param,
const char *opts)
{
char *buf, *token, *next, *p, *arg;
int len;
int r_usage = 0;
len = strlen(opts);
buf = xmalloc(len+1);
strcpy(buf, opts);
buf = bb_xstrdup(opts);
for (token = buf; token && *token; token = next) {
p = strchr(token, ',');
next = 0;
@ -778,7 +775,7 @@ static __u32 ok_features[3] = {
};
static void PRS(int argc, char *argv[])
static int PRS(int argc, char *argv[])
{
int b, c;
int size;
@ -801,11 +798,7 @@ static void PRS(int argc, char *argv[])
if (oldpath) {
char *newpath;
newpath = xmalloc(sizeof (PATH_SET) + 1 + strlen (oldpath));
strcpy (newpath, PATH_SET);
strcat (newpath, ":");
strcat (newpath, oldpath);
putenv (newpath);
bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath);
} else
putenv (PATH_SET);
@ -913,8 +906,7 @@ static void PRS(int argc, char *argv[])
journal_size = -1;
break;
case 'l':
bad_blocks_filename = xmalloc(strlen(optarg)+1);
strcpy(bad_blocks_filename, optarg);
bad_blocks_filename = optarg;
break;
case 'm':
reserved_ratio = strtoul(optarg, &tmp, 0);
@ -1010,7 +1002,7 @@ static void PRS(int argc, char *argv[])
E2FSPROGS_DATE);
if (show_version_only) {
exit(0);
return 0;
}
/*
@ -1088,7 +1080,7 @@ static void PRS(int argc, char *argv[])
if (!force)
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;
@ -1212,11 +1204,12 @@ static void PRS(int argc, char *argv[])
* Calculate number of blocks to reserve
*/
param.s_r_blocks_count = (param.s_blocks_count * reserved_ratio) / 100;
return 1;
}
int mke2fs_main (int argc, char *argv[])
{
errcode_t retval = 0;
errcode_t retval;
ext2_filsys fs;
badblocks_list bb_list = 0;
int journal_blocks;
@ -1224,13 +1217,8 @@ int mke2fs_main (int argc, char *argv[])
int val;
io_manager io_ptr;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "");
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
textdomain(NLS_CAT_NAME);
#endif
PRS(argc, argv);
if(!PRS(argc, argv))
return 0;
#ifdef CONFIG_TESTIO_DEBUG
io_ptr = test_io_manager;
@ -1313,12 +1301,12 @@ int mke2fs_main (int argc, char *argv[])
show_stats(fs);
if (noaction)
exit(0);
return 0;
if (fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
create_journal_dev(fs);
exit(ext2fs_close(fs) ? 1 : 0);
return (ext2fs_close(fs) ? 1 : 0);
}
if (bad_blocks_filename)
@ -1380,7 +1368,7 @@ int mke2fs_main (int argc, char *argv[])
if (!force)
check_plausibility(journal_device);
check_mount(journal_device, force, _("journal"));
check_mount(journal_device, force, "journal");
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
EXT2_FLAG_JOURNAL_DEV_OK, 0,