1997-06-08 04:42:58 +08: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>
|
1998-08-01 12:33:31 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-06-08 04:42:58 +08:00
|
|
|
#include <unistd.h>
|
1998-08-01 12:33:31 +08:00
|
|
|
#endif
|
1997-06-08 04:42:58 +08:00
|
|
|
#include <stdlib.h>
|
1997-10-20 08:44:26 +08:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
1997-06-08 04:42:58 +08:00
|
|
|
#include <sys/types.h>
|
1997-10-20 08:44:26 +08:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
1997-06-08 04:42:58 +08:00
|
|
|
#include <sys/time.h>
|
1997-10-20 08:44:26 +08:00
|
|
|
#endif
|
1997-09-04 08:43:10 +08:00
|
|
|
#if HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
1997-06-08 04:42:58 +08:00
|
|
|
|
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 22:55:24 +08:00
|
|
|
#if EXT2_FLAT_INCLUDES
|
|
|
|
#include "ext2_fs.h"
|
|
|
|
#include "ext2fs.h"
|
|
|
|
#else
|
|
|
|
#include <linux/ext2_fs.h>
|
1997-06-08 04:42:58 +08: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 22:55:24 +08:00
|
|
|
#endif
|
|
|
|
|
1997-06-08 04:42:58 +08:00
|
|
|
|
1997-06-17 11:52:12 +08: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 15:28:44 +08: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 11:52:12 +08:00
|
|
|
#define RESIZE_VERBOSE 0x0200
|
1997-06-14 15:28:44 +08:00
|
|
|
|
1997-06-08 04:42:58 +08:00
|
|
|
/*
|
|
|
|
* The core state structure for the ext2 resizer
|
|
|
|
*/
|
1998-02-14 06:58:18 +08:00
|
|
|
typedef struct ext2_resize_struct *ext2_resize_t;
|
1997-06-08 04:42:58 +08:00
|
|
|
|
|
|
|
struct ext2_resize_struct {
|
|
|
|
ext2_filsys old_fs;
|
|
|
|
ext2_filsys new_fs;
|
1997-06-09 22:51:29 +08:00
|
|
|
ext2fs_block_bitmap reserve_blocks;
|
1997-06-17 11:52:12 +08:00
|
|
|
ext2fs_block_bitmap move_blocks;
|
1998-02-17 06:16:20 +08:00
|
|
|
ext2_extent bmap;
|
|
|
|
ext2_extent imap;
|
1997-06-09 22:51:29 +08:00
|
|
|
int needed_blocks;
|
1997-06-14 15:28:44 +08:00
|
|
|
int flags;
|
|
|
|
char *itable_buf;
|
1998-02-17 06:16:20 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For the block allocator
|
|
|
|
*/
|
|
|
|
blk_t new_blk;
|
|
|
|
int alloc_state;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For the progress meter
|
|
|
|
*/
|
1998-02-25 04:24:49 +08:00
|
|
|
errcode_t (*progress)(ext2_resize_t rfs, int pass,
|
1998-02-14 06:58:18 +08:00
|
|
|
unsigned long cur,
|
|
|
|
unsigned long max);
|
|
|
|
void *prog_data;
|
1997-06-08 04:42:58 +08:00
|
|
|
};
|
|
|
|
|
1998-02-14 06:58:18 +08:00
|
|
|
/*
|
|
|
|
* Progress pass numbers...
|
|
|
|
*/
|
1998-02-17 06:16:20 +08:00
|
|
|
#define E2_RSZ_EXTEND_ITABLE_PASS 1
|
1998-02-14 06:58:18 +08:00
|
|
|
#define E2_RSZ_BLOCK_RELOC_PASS 2
|
1998-02-17 06:16:20 +08:00
|
|
|
#define E2_RSZ_INODE_SCAN_PASS 3
|
|
|
|
#define E2_RSZ_INODE_REF_UPD_PASS 4
|
|
|
|
#define E2_RSZ_MOVE_ITABLE_PASS 5
|
1998-02-14 06:58:18 +08:00
|
|
|
|
1997-06-08 04:42:58 +08:00
|
|
|
|
|
|
|
/* prototypes */
|
1998-02-14 06:58:18 +08:00
|
|
|
extern errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags,
|
1998-02-25 04:24:49 +08:00
|
|
|
errcode_t (*progress)(ext2_resize_t rfs,
|
|
|
|
int pass, unsigned long cur,
|
1998-02-14 06:58:18 +08:00
|
|
|
unsigned long max));
|
|
|
|
|
1997-06-17 11:52:12 +08:00
|
|
|
/* 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 22:55:24 +08:00
|
|
|
__u32 old_loc, __u32 new_loc);
|
|
|
|
extern __u32 ext2fs_extent_translate(ext2_extent extent, __u32 old_loc);
|
1997-06-17 11:52:12 +08: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 22:55:24 +08:00
|
|
|
extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old_loc,
|
|
|
|
__u32 *new_loc, int *size);
|
1997-06-17 11:52:12 +08: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);
|
|
|
|
|
|
|
|
|