Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * resize2fs.h --- ext2 resizer header file |
| 3 | * |
| 4 | * Copyright (C) 1997 Theodore Ts'o |
| 5 | * |
| 6 | * %Begin-Header% |
| 7 | * All rights reserved. |
| 8 | * %End-Header% |
| 9 | */ |
| 10 | |
| 11 | #include <stdio.h> |
| 12 | #include <string.h> |
| 13 | #include <unistd.h> |
| 14 | #include <stdlib.h> |
Theodore Ts'o | d40259f | 1997-10-20 00:44:26 +0000 | [diff] [blame] | 15 | #ifdef HAVE_SYS_TYPES_H |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 16 | #include <sys/types.h> |
Theodore Ts'o | d40259f | 1997-10-20 00:44:26 +0000 | [diff] [blame] | 17 | #endif |
| 18 | #ifdef HAVE_SYS_TIME_H |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 19 | #include <sys/time.h> |
Theodore Ts'o | d40259f | 1997-10-20 00:44:26 +0000 | [diff] [blame] | 20 | #endif |
Theodore Ts'o | bc75f2a | 1997-09-04 00:43:10 +0000 | [diff] [blame] | 21 | #if HAVE_ERRNO_H |
| 22 | #include <errno.h> |
| 23 | #endif |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 24 | |
| 25 | #ifdef HAVE_LINUX_FS_H |
| 26 | #include <linux/fs.h> |
| 27 | #endif |
| 28 | #include <linux/ext2_fs.h> |
| 29 | |
| 30 | #include "ext2fs/ext2fs.h" |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 31 | |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 32 | /* |
Theodore Ts'o | c762c8e | 1997-06-17 03:52:12 +0000 | [diff] [blame] | 33 | * For the extent map |
| 34 | */ |
| 35 | typedef struct _ext2_extent *ext2_extent; |
| 36 | |
| 37 | /* |
| 38 | * For the simple progress meter |
| 39 | */ |
| 40 | typedef struct ext2_sim_progress *ext2_sim_progmeter; |
| 41 | |
| 42 | /* |
Theodore Ts'o | 05e112a | 1997-06-14 07:28:44 +0000 | [diff] [blame] | 43 | * Flags for the resizer; most are debugging flags only |
| 44 | */ |
| 45 | #define RESIZE_DEBUG_IO 0x0001 |
| 46 | #define RESIZE_DEBUG_BMOVE 0x0002 |
| 47 | #define RESIZE_DEBUG_INODEMAP 0x0004 |
| 48 | #define RESIZE_DEBUG_ITABLEMOVE 0x0008 |
| 49 | |
| 50 | #define RESIZE_PERCENT_COMPLETE 0x0100 |
Theodore Ts'o | c762c8e | 1997-06-17 03:52:12 +0000 | [diff] [blame] | 51 | #define RESIZE_VERBOSE 0x0200 |
Theodore Ts'o | 05e112a | 1997-06-14 07:28:44 +0000 | [diff] [blame] | 52 | |
| 53 | /* |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 54 | * The core state structure for the ext2 resizer |
| 55 | */ |
| 56 | |
| 57 | struct ext2_resize_struct { |
| 58 | ext2_filsys old_fs; |
| 59 | ext2_filsys new_fs; |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 60 | ext2fs_block_bitmap reserve_blocks; |
Theodore Ts'o | c762c8e | 1997-06-17 03:52:12 +0000 | [diff] [blame] | 61 | ext2fs_block_bitmap move_blocks; |
Theodore Ts'o | 1e1da29 | 1997-06-09 14:51:29 +0000 | [diff] [blame] | 62 | int needed_blocks; |
Theodore Ts'o | 05e112a | 1997-06-14 07:28:44 +0000 | [diff] [blame] | 63 | int flags; |
| 64 | char *itable_buf; |
Theodore Ts'o | 24b2c7a | 1997-06-07 20:42:58 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | typedef struct ext2_resize_struct *ext2_resize_t; |
| 68 | |
| 69 | /* prototypes */ |
Theodore Ts'o | 05e112a | 1997-06-14 07:28:44 +0000 | [diff] [blame] | 70 | extern errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags); |
Theodore Ts'o | c762c8e | 1997-06-17 03:52:12 +0000 | [diff] [blame] | 71 | extern errcode_t ext2fs_inode_move(ext2_resize_t rfs); |
| 72 | extern errcode_t ext2fs_block_move(ext2_resize_t rfs); |
| 73 | |
| 74 | /* extent.c */ |
| 75 | extern errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent, |
| 76 | int size); |
| 77 | extern void ext2fs_free_extent_table(ext2_extent extent); |
| 78 | extern errcode_t ext2fs_add_extent_entry(ext2_extent extent, |
| 79 | __u32 old, __u32 new); |
| 80 | extern __u32 ext2fs_extent_translate(ext2_extent extent, __u32 old); |
| 81 | extern void ext2fs_extent_dump(ext2_extent extent, FILE *out); |
| 82 | extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old, |
| 83 | __u32 *new, int *size); |
| 84 | |
| 85 | /* sim_progress.c */ |
| 86 | extern errcode_t ext2fs_progress_init(ext2_sim_progmeter *ret_prog, |
| 87 | const char *label, |
| 88 | int labelwidth, int barwidth, |
| 89 | __u32 maxdone, int flags); |
| 90 | extern void ext2fs_progress_update(ext2_sim_progmeter prog, |
| 91 | __u32 current); |
| 92 | extern void ext2fs_progress_close(ext2_sim_progmeter prog); |
| 93 | |
| 94 | |