1997-06-08 00:42:58 +04:00
|
|
|
/*
|
|
|
|
* resize2fs.h --- ext2 resizer header file
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 Theodore Ts'o
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* All rights reserved.
|
|
|
|
* %End-Header%
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
1997-10-20 04:44:26 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
1997-06-08 00:42:58 +04:00
|
|
|
#include <sys/types.h>
|
1997-10-20 04:44:26 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
1997-06-08 00:42:58 +04:00
|
|
|
#include <sys/time.h>
|
1997-10-20 04:44:26 +04:00
|
|
|
#endif
|
1997-09-04 04:43:10 +04:00
|
|
|
#if HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
1997-06-08 00:42:58 +04:00
|
|
|
|
|
|
|
#ifdef HAVE_LINUX_FS_H
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#endif
|
|
|
|
|
Many files:
resize2fs.h: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
resize2fs.h: Rename variables named "new" to "new_block",
"new_inode", or "new_loc" to avoid C++ reserved word
clash.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
sim_progress.c: Use ext2fs_get_memory(),
ext2fs_free_memory(), et. al., instead of malloc() and
free().
ext2_block_move.c, ext2_inode_move.c, extent.c: Explicitly cast
all assignments from void * to be compatible with C++.
banalysis.c, banalysis.h, ext2_inode_move.c, ext2_block_move.c:
Change private to priv_data to avoid C++ namespace clash.
ChangeLog, badblocks.8.in:
badblocks.8.in: Add documentation for the -s option.
1998-01-19 17:55:24 +03:00
|
|
|
#if EXT2_FLAT_INCLUDES
|
|
|
|
#include "ext2_fs.h"
|
|
|
|
#include "ext2fs.h"
|
|
|
|
#else
|
|
|
|
#include <linux/ext2_fs.h>
|
1997-06-08 00:42:58 +04:00
|
|
|
#include "ext2fs/ext2fs.h"
|
Many files:
resize2fs.h: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
resize2fs.h: Rename variables named "new" to "new_block",
"new_inode", or "new_loc" to avoid C++ reserved word
clash.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
sim_progress.c: Use ext2fs_get_memory(),
ext2fs_free_memory(), et. al., instead of malloc() and
free().
ext2_block_move.c, ext2_inode_move.c, extent.c: Explicitly cast
all assignments from void * to be compatible with C++.
banalysis.c, banalysis.h, ext2_inode_move.c, ext2_block_move.c:
Change private to priv_data to avoid C++ namespace clash.
ChangeLog, badblocks.8.in:
badblocks.8.in: Add documentation for the -s option.
1998-01-19 17:55:24 +03:00
|
|
|
#endif
|
|
|
|
|
1997-06-08 00:42:58 +04:00
|
|
|
|
1997-06-17 07:52:12 +04:00
|
|
|
/*
|
|
|
|
* For the extent map
|
|
|
|
*/
|
|
|
|
typedef struct _ext2_extent *ext2_extent;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For the simple progress meter
|
|
|
|
*/
|
|
|
|
typedef struct ext2_sim_progress *ext2_sim_progmeter;
|
|
|
|
|
1997-06-14 11:28:44 +04:00
|
|
|
/*
|
|
|
|
* Flags for the resizer; most are debugging flags only
|
|
|
|
*/
|
|
|
|
#define RESIZE_DEBUG_IO 0x0001
|
|
|
|
#define RESIZE_DEBUG_BMOVE 0x0002
|
|
|
|
#define RESIZE_DEBUG_INODEMAP 0x0004
|
|
|
|
#define RESIZE_DEBUG_ITABLEMOVE 0x0008
|
|
|
|
|
|
|
|
#define RESIZE_PERCENT_COMPLETE 0x0100
|
1997-06-17 07:52:12 +04:00
|
|
|
#define RESIZE_VERBOSE 0x0200
|
1997-06-14 11:28:44 +04:00
|
|
|
|
1997-06-08 00:42:58 +04:00
|
|
|
/*
|
|
|
|
* The core state structure for the ext2 resizer
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ext2_resize_struct {
|
|
|
|
ext2_filsys old_fs;
|
|
|
|
ext2_filsys new_fs;
|
1997-06-09 18:51:29 +04:00
|
|
|
ext2fs_block_bitmap reserve_blocks;
|
1997-06-17 07:52:12 +04:00
|
|
|
ext2fs_block_bitmap move_blocks;
|
1997-06-09 18:51:29 +04:00
|
|
|
int needed_blocks;
|
1997-06-14 11:28:44 +04:00
|
|
|
int flags;
|
|
|
|
char *itable_buf;
|
1997-06-08 00:42:58 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct ext2_resize_struct *ext2_resize_t;
|
|
|
|
|
|
|
|
/* prototypes */
|
1997-06-14 11:28:44 +04:00
|
|
|
extern errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags);
|
1997-06-17 07:52:12 +04:00
|
|
|
extern errcode_t ext2fs_inode_move(ext2_resize_t rfs);
|
|
|
|
extern errcode_t ext2fs_block_move(ext2_resize_t rfs);
|
|
|
|
|
|
|
|
/* extent.c */
|
|
|
|
extern errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent,
|
|
|
|
int size);
|
|
|
|
extern void ext2fs_free_extent_table(ext2_extent extent);
|
|
|
|
extern errcode_t ext2fs_add_extent_entry(ext2_extent extent,
|
Many files:
resize2fs.h: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
resize2fs.h: Rename variables named "new" to "new_block",
"new_inode", or "new_loc" to avoid C++ reserved word
clash.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
sim_progress.c: Use ext2fs_get_memory(),
ext2fs_free_memory(), et. al., instead of malloc() and
free().
ext2_block_move.c, ext2_inode_move.c, extent.c: Explicitly cast
all assignments from void * to be compatible with C++.
banalysis.c, banalysis.h, ext2_inode_move.c, ext2_block_move.c:
Change private to priv_data to avoid C++ namespace clash.
ChangeLog, badblocks.8.in:
badblocks.8.in: Add documentation for the -s option.
1998-01-19 17:55:24 +03:00
|
|
|
__u32 old_loc, __u32 new_loc);
|
|
|
|
extern __u32 ext2fs_extent_translate(ext2_extent extent, __u32 old_loc);
|
1997-06-17 07:52:12 +04:00
|
|
|
extern void ext2fs_extent_dump(ext2_extent extent, FILE *out);
|
Many files:
resize2fs.h: If EXT2_FLAT_INCLUDES is defined, then assume all
of the ext2-specific header files are in a flat directory.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
resize2fs.h: Rename variables named "new" to "new_block",
"new_inode", or "new_loc" to avoid C++ reserved word
clash.
ext2_block_move.c, ext2_inode_move.c, extent.c, resize2fs.c,
sim_progress.c: Use ext2fs_get_memory(),
ext2fs_free_memory(), et. al., instead of malloc() and
free().
ext2_block_move.c, ext2_inode_move.c, extent.c: Explicitly cast
all assignments from void * to be compatible with C++.
banalysis.c, banalysis.h, ext2_inode_move.c, ext2_block_move.c:
Change private to priv_data to avoid C++ namespace clash.
ChangeLog, badblocks.8.in:
badblocks.8.in: Add documentation for the -s option.
1998-01-19 17:55:24 +03:00
|
|
|
extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old_loc,
|
|
|
|
__u32 *new_loc, int *size);
|
1997-06-17 07:52:12 +04:00
|
|
|
|
|
|
|
/* sim_progress.c */
|
|
|
|
extern errcode_t ext2fs_progress_init(ext2_sim_progmeter *ret_prog,
|
|
|
|
const char *label,
|
|
|
|
int labelwidth, int barwidth,
|
|
|
|
__u32 maxdone, int flags);
|
|
|
|
extern void ext2fs_progress_update(ext2_sim_progmeter prog,
|
|
|
|
__u32 current);
|
|
|
|
extern void ext2fs_progress_close(ext2_sim_progmeter prog);
|
|
|
|
|
|
|
|
|