mirror of https://github.com/vitalif/e2fsprogs
mke2fs.c (PRS, set_fs_defaults): If the sector size of the
device is larger than the default block size, then use the sector size of the device as the default block size. getsectsize.c (ext2fs_get_device_sectsize): New function which returns the hardware sector size (if it is available).bitmap-optimize
parent
5c70a50b28
commit
93d5c38791
|
@ -1,3 +1,8 @@
|
||||||
|
2003-05-21 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
|
* getsectsize.c (ext2fs_get_device_sectsize): New function which
|
||||||
|
returns the hardware sector size (if it is available).
|
||||||
|
|
||||||
2003-05-13 Theodore Ts'o <tytso@mit.edu>
|
2003-05-13 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
* unix_io.c: Add #ifdef NO_IO_CACHE which disables all userspace
|
* unix_io.c: Add #ifdef NO_IO_CACHE which disables all userspace
|
||||||
|
|
|
@ -40,6 +40,7 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_OBJS) $(E2IMAGE_LIB_OBJS) \
|
||||||
gen_bitmap.o \
|
gen_bitmap.o \
|
||||||
get_pathname.o \
|
get_pathname.o \
|
||||||
getsize.o \
|
getsize.o \
|
||||||
|
getsectsize.o \
|
||||||
icount.o \
|
icount.o \
|
||||||
initialize.o \
|
initialize.o \
|
||||||
inline.o \
|
inline.o \
|
||||||
|
@ -91,6 +92,7 @@ SRCS= ext2_err.c \
|
||||||
$(srcdir)/gen_bitmap.c \
|
$(srcdir)/gen_bitmap.c \
|
||||||
$(srcdir)/get_pathname.c \
|
$(srcdir)/get_pathname.c \
|
||||||
$(srcdir)/getsize.c \
|
$(srcdir)/getsize.c \
|
||||||
|
$(srcdir)/getsectsize.c \
|
||||||
$(srcdir)/icount.c \
|
$(srcdir)/icount.c \
|
||||||
$(srcdir)/imager.c \
|
$(srcdir)/imager.c \
|
||||||
$(srcdir)/initialize.c \
|
$(srcdir)/initialize.c \
|
||||||
|
@ -203,6 +205,10 @@ tst_bitops: tst_bitops.o inline.o $(STATIC_LIBEXT2FS)
|
||||||
$(CC) -o tst_bitops tst_bitops.o inline.o \
|
$(CC) -o tst_bitops tst_bitops.o inline.o \
|
||||||
$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
|
$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
|
||||||
|
|
||||||
|
tst_getsectsize: tst_getsectsize.o getsectsize.o $(STATIC_LIBEXT2FS)
|
||||||
|
$(CC) -o tst_sectgetsize tst_getsectsize.o getsectsize.o \
|
||||||
|
-DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
|
||||||
|
|
||||||
mkjournal: mkjournal.c $(STATIC_LIBEXT2FS)
|
mkjournal: mkjournal.c $(STATIC_LIBEXT2FS)
|
||||||
$(CC) -o mkjournal $(srcdir)/mkjournal.c -DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(ALL_CFLAGS)
|
$(CC) -o mkjournal $(srcdir)/mkjournal.c -DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(ALL_CFLAGS)
|
||||||
|
|
||||||
|
|
|
@ -720,6 +720,9 @@ extern void ext2fs_u32_list_free(ext2_u32_list bb);
|
||||||
extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
||||||
blk_t *retblocks);
|
blk_t *retblocks);
|
||||||
|
|
||||||
|
/* getsectsize.c */
|
||||||
|
errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize);
|
||||||
|
|
||||||
/* imager.c */
|
/* imager.c */
|
||||||
extern errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags);
|
extern errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags);
|
||||||
extern errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags);
|
extern errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags);
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* getsectsize.c --- get the sector size of a device.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1995, 1995 Theodore Ts'o.
|
||||||
|
* Copyright (C) 2003 VMware, Inc.
|
||||||
|
*
|
||||||
|
* %Begin-Header%
|
||||||
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
|
* License.
|
||||||
|
* %End-Header%
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _LARGEFILE_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#if HAVE_ERRNO_H
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifdef HAVE_LINUX_FD_H
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <linux/fd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
|
||||||
|
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ext2_fs.h"
|
||||||
|
#include "ext2fs.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the number of blocks in a partition
|
||||||
|
*/
|
||||||
|
errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
#ifdef HAVE_OPEN64
|
||||||
|
fd = open64(file, O_RDONLY);
|
||||||
|
#else
|
||||||
|
fd = open(file, O_RDONLY);
|
||||||
|
#endif
|
||||||
|
if (fd < 0)
|
||||||
|
return errno;
|
||||||
|
|
||||||
|
#ifdef BLKSSZGET
|
||||||
|
if (ioctl(fd, BLKSSZGET, sectsize) >= 0) {
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*sectsize = 0;
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* tst_getsize.c --- this function tests the getsize function
|
||||||
|
*
|
||||||
|
* Copyright (C) 1997 by Theodore Ts'o.
|
||||||
|
*
|
||||||
|
* %Begin-Header%
|
||||||
|
* This file may be redistributed under the terms of the GNU Public
|
||||||
|
* License.
|
||||||
|
* %End-Header%
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#if HAVE_ERRNO_H
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ext2_fs.h"
|
||||||
|
#include "ext2fs.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int sectsize;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "Usage: %s device\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = ext2fs_get_device_sectsize(argv[1], §size);
|
||||||
|
if (retval) {
|
||||||
|
com_err(argv[0], retval,
|
||||||
|
"while calling ext2fs_get_device_sectsize");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
printf("Device %s has a hardware sector size of %d.\n",
|
||||||
|
argv[1], sectsize);
|
||||||
|
exit(0);
|
||||||
|
}
|
|
@ -1,3 +1,9 @@
|
||||||
|
2003-05-21 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
|
* mke2fs.c (PRS, set_fs_defaults): If the sector size of the
|
||||||
|
device is larger than the default block size, then use the
|
||||||
|
sector size of the device as the default block size.
|
||||||
|
|
||||||
2003-05-18 Theodore Ts'o <tytso@mit.edu>
|
2003-05-18 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
* badblocks.c: Use an unsigned integer to support 4-byte test
|
* badblocks.c: Use an unsigned integer to support 4-byte test
|
||||||
|
|
|
@ -147,7 +147,8 @@ struct mke2fs_defaults {
|
||||||
|
|
||||||
static void set_fs_defaults(const char *fs_type,
|
static void set_fs_defaults(const char *fs_type,
|
||||||
struct ext2_super_block *super,
|
struct ext2_super_block *super,
|
||||||
int blocksize, int *inode_ratio)
|
int blocksize, int sector_size,
|
||||||
|
int *inode_ratio)
|
||||||
{
|
{
|
||||||
int megs;
|
int megs;
|
||||||
int ratio = 0;
|
int ratio = 0;
|
||||||
|
@ -170,6 +171,8 @@ static void set_fs_defaults(const char *fs_type,
|
||||||
blocksize : p->inode_ratio;
|
blocksize : p->inode_ratio;
|
||||||
use_bsize = p->blocksize;
|
use_bsize = p->blocksize;
|
||||||
}
|
}
|
||||||
|
if (use_bsize < sector_size)
|
||||||
|
use_bsize = sector_size;
|
||||||
if (blocksize <= 0) {
|
if (blocksize <= 0) {
|
||||||
if (use_bsize == DEF_MAX_BLOCKSIZE)
|
if (use_bsize == DEF_MAX_BLOCKSIZE)
|
||||||
use_bsize = sys_page_size;
|
use_bsize = sys_page_size;
|
||||||
|
@ -799,6 +802,7 @@ static void PRS(int argc, char *argv[])
|
||||||
int inode_ratio = 0;
|
int inode_ratio = 0;
|
||||||
int inode_size = 0;
|
int inode_size = 0;
|
||||||
int reserved_ratio = 5;
|
int reserved_ratio = 5;
|
||||||
|
int sector_size = 0;
|
||||||
ext2_ino_t num_inodes = 0;
|
ext2_ino_t num_inodes = 0;
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
char * oldpath = getenv("PATH");
|
char * oldpath = getenv("PATH");
|
||||||
|
@ -1187,7 +1191,15 @@ static void PRS(int argc, char *argv[])
|
||||||
((tmp = getenv("MKE2FS_FIRST_META_BG"))))
|
((tmp = getenv("MKE2FS_FIRST_META_BG"))))
|
||||||
param.s_first_meta_bg = atoi(tmp);
|
param.s_first_meta_bg = atoi(tmp);
|
||||||
|
|
||||||
set_fs_defaults(fs_type, ¶m, blocksize, &inode_ratio);
|
/* Get the hardware sector size, if available */
|
||||||
|
retval = ext2fs_get_device_sectsize(device_name, §or_size);
|
||||||
|
if (retval) {
|
||||||
|
com_err(program_name, retval,
|
||||||
|
_("while trying to determine hardware sector size"));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_fs_defaults(fs_type, ¶m, blocksize, sector_size, &inode_ratio);
|
||||||
blocksize = EXT2_BLOCK_SIZE(¶m);
|
blocksize = EXT2_BLOCK_SIZE(¶m);
|
||||||
|
|
||||||
if (param.s_blocks_per_group) {
|
if (param.s_blocks_per_group) {
|
||||||
|
|
Loading…
Reference in New Issue