diff options
author | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-10-02 08:10:31 +0000 |
---|---|---|
committer | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-10-02 08:10:31 +0000 |
commit | aa74b90ebfa7ab809c210f0807f005f84e6421d6 (patch) | |
tree | 25ee18d0e09ba5e39bd8eac91653142b5e35997d /e2fsprogs/util.c | |
parent | 454badc94151ca5285891e08dd4e68b9af0b6801 (diff) | |
download | busybox-w32-aa74b90ebfa7ab809c210f0807f005f84e6421d6.tar.gz busybox-w32-aa74b90ebfa7ab809c210f0807f005f84e6421d6.tar.bz2 busybox-w32-aa74b90ebfa7ab809c210f0807f005f84e6421d6.zip |
excellent shrinkage patch by Tito
git-svn-id: svn://busybox.net/trunk/busybox@11730 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'e2fsprogs/util.c')
-rw-r--r-- | e2fsprogs/util.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/e2fsprogs/util.c b/e2fsprogs/util.c index d4d77b63b..58f9bbb88 100644 --- a/e2fsprogs/util.c +++ b/e2fsprogs/util.c | |||
@@ -29,7 +29,7 @@ void proceed_question(void) | |||
29 | exit(1); | 29 | exit(1); |
30 | } | 30 | } |
31 | 31 | ||
32 | void check_plausibility(const char *device) | 32 | void check_plausibility(const char *device, int force) |
33 | { | 33 | { |
34 | int val; | 34 | int val; |
35 | #ifdef CONFIG_LFS | 35 | #ifdef CONFIG_LFS |
@@ -39,7 +39,8 @@ void check_plausibility(const char *device) | |||
39 | struct stat s; | 39 | struct stat s; |
40 | val = stat(device, &s); | 40 | val = stat(device, &s); |
41 | #endif | 41 | #endif |
42 | 42 | if (force) | |
43 | return; | ||
43 | if(val == -1) | 44 | if(val == -1) |
44 | bb_perror_msg_and_die("Could not stat %s", device); | 45 | bb_perror_msg_and_die("Could not stat %s", device); |
45 | if (!S_ISBLK(s.st_mode)) { | 46 | if (!S_ISBLK(s.st_mode)) { |
@@ -205,3 +206,50 @@ void print_check_message(ext2_filsys fs) | |||
205 | fs->super->s_max_mnt_count, | 206 | fs->super->s_max_mnt_count, |
206 | (double)fs->super->s_checkinterval / (3600 * 24)); | 207 | (double)fs->super->s_checkinterval / (3600 * 24)); |
207 | } | 208 | } |
209 | |||
210 | void make_journal_device(char *journal_device, ext2_filsys fs, int quiet, int force) | ||
211 | { | ||
212 | errcode_t retval; | ||
213 | ext2_filsys jfs; | ||
214 | io_manager io_ptr; | ||
215 | |||
216 | check_plausibility(journal_device, force); | ||
217 | check_mount(journal_device, force, "journal"); | ||
218 | io_ptr = unix_io_manager; | ||
219 | retval = ext2fs_open(journal_device, EXT2_FLAG_RW| | ||
220 | EXT2_FLAG_JOURNAL_DEV_OK, 0, | ||
221 | fs->blocksize, io_ptr, &jfs); | ||
222 | if (retval) | ||
223 | bb_error_msg_and_die("Could not journal device %s", journal_device); | ||
224 | if(!quiet) | ||
225 | printf("Adding journal to device %s: ", journal_device); | ||
226 | fflush(stdout); | ||
227 | retval = ext2fs_add_journal_device(fs, jfs); | ||
228 | if(retval) | ||
229 | bb_error_msg_and_die("\nFailed to add journal to device %s", journal_device); | ||
230 | if(!quiet) | ||
231 | puts("done"); | ||
232 | ext2fs_close(jfs); | ||
233 | } | ||
234 | |||
235 | void make_journal_blocks(ext2_filsys fs, int journal_size, int journal_flags, int quiet) | ||
236 | { | ||
237 | unsigned long journal_blocks; | ||
238 | errcode_t retval; | ||
239 | |||
240 | journal_blocks = figure_journal_size(journal_size, fs); | ||
241 | if (!journal_blocks) { | ||
242 | fs->super->s_feature_compat &= | ||
243 | ~EXT3_FEATURE_COMPAT_HAS_JOURNAL; | ||
244 | return; | ||
245 | } | ||
246 | if(!quiet) | ||
247 | printf("Creating journal (%ld blocks): ", journal_blocks); | ||
248 | fflush(stdout); | ||
249 | retval = ext2fs_add_journal_inode(fs, journal_blocks, | ||
250 | journal_flags); | ||
251 | if(retval) | ||
252 | bb_error_msg_and_die("Could not create journal"); | ||
253 | if(!quiet) | ||
254 | puts("done"); | ||
255 | } | ||