aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs/initialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/ext2fs/initialize.c')
-rw-r--r--e2fsprogs/ext2fs/initialize.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/e2fsprogs/ext2fs/initialize.c b/e2fsprogs/ext2fs/initialize.c
index 82cd9f1da..3d326b577 100644
--- a/e2fsprogs/ext2fs/initialize.c
+++ b/e2fsprogs/ext2fs/initialize.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * initialize.c --- initialize a filesystem handle given superblock 2 * initialize.c --- initialize a filesystem handle given superblock
3 * parameters. Used by mke2fs when initializing a filesystem. 3 * parameters. Used by mke2fs when initializing a filesystem.
4 * 4 *
5 * Copyright (C) 1994, 1995, 1996 Theodore Ts'o. 5 * Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
6 * 6 *
7 * %Begin-Header% 7 * %Begin-Header%
8 * This file may be redistributed under the terms of the GNU Public 8 * This file may be redistributed under the terms of the GNU Public
9 * License. 9 * License.
@@ -36,7 +36,7 @@
36#if defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) 36#if defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD)
37#define CREATOR_OS EXT2_OS_FREEBSD 37#define CREATOR_OS EXT2_OS_FREEBSD
38#else 38#else
39#if defined(LITES) && defined(EXT2_OS_LITES) 39#if defined(LITES) && defined(EXT2_OS_LITES)
40#define CREATOR_OS EXT2_OS_LITES 40#define CREATOR_OS EXT2_OS_LITES
41#else 41#else
42#define CREATOR_OS EXT2_OS_LINUX /* by default */ 42#define CREATOR_OS EXT2_OS_LINUX /* by default */
@@ -44,13 +44,13 @@
44#endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */ 44#endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */
45#endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */ 45#endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */
46#endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */ 46#endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */
47 47
48/* 48/*
49 * Note we override the kernel include file's idea of what the default 49 * Note we override the kernel include file's idea of what the default
50 * check interval (never) should be. It's a good idea to check at 50 * check interval (never) should be. It's a good idea to check at
51 * least *occasionally*, specially since servers will never rarely get 51 * least *occasionally*, specially since servers will never rarely get
52 * to reboot, since Linux is so robust these days. :-) 52 * to reboot, since Linux is so robust these days. :-)
53 * 53 *
54 * 180 days (six months) seems like a good value. 54 * 180 days (six months) seems like a good value.
55 */ 55 */
56#ifdef EXT2_DFL_CHECKINTERVAL 56#ifdef EXT2_DFL_CHECKINTERVAL
@@ -108,11 +108,11 @@ errcode_t ext2fs_initialize(const char *name, int flags,
108 108
109 if (!param || !param->s_blocks_count) 109 if (!param || !param->s_blocks_count)
110 return EXT2_ET_INVALID_ARGUMENT; 110 return EXT2_ET_INVALID_ARGUMENT;
111 111
112 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); 112 retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
113 if (retval) 113 if (retval)
114 return retval; 114 return retval;
115 115
116 memset(fs, 0, sizeof(struct struct_ext2_filsys)); 116 memset(fs, 0, sizeof(struct struct_ext2_filsys));
117 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; 117 fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
118 fs->flags = flags | EXT2_FLAG_RW; 118 fs->flags = flags | EXT2_FLAG_RW;
@@ -181,7 +181,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
181 if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super)) 181 if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
182 super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super); 182 super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
183 super->s_frags_per_group = super->s_blocks_per_group * frags_per_block; 183 super->s_frags_per_group = super->s_blocks_per_group * frags_per_block;
184 184
185 super->s_blocks_count = param->s_blocks_count; 185 super->s_blocks_count = param->s_blocks_count;
186 super->s_r_blocks_count = param->s_r_blocks_count; 186 super->s_r_blocks_count = param->s_r_blocks_count;
187 if (super->s_r_blocks_count >= param->s_blocks_count) { 187 if (super->s_r_blocks_count >= param->s_blocks_count) {
@@ -222,7 +222,7 @@ retry:
222 */ 222 */
223 if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1) 223 if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1)
224 super->s_inodes_count = EXT2_FIRST_INODE(super)+1; 224 super->s_inodes_count = EXT2_FIRST_INODE(super)+1;
225 225
226 /* 226 /*
227 * There should be at least as many inodes as the user 227 * There should be at least as many inodes as the user
228 * requested. Figure out how many inodes per group that 228 * requested. Figure out how many inodes per group that
@@ -332,12 +332,12 @@ retry:
332 retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); 332 retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf);
333 if (retval) 333 if (retval)
334 goto cleanup; 334 goto cleanup;
335 335
336 sprintf(buf, "block bitmap for %s", fs->device_name); 336 sprintf(buf, "block bitmap for %s", fs->device_name);
337 retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); 337 retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
338 if (retval) 338 if (retval)
339 goto cleanup; 339 goto cleanup;
340 340
341 sprintf(buf, "inode bitmap for %s", fs->device_name); 341 sprintf(buf, "inode bitmap for %s", fs->device_name);
342 retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); 342 retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
343 if (retval) 343 if (retval)
@@ -369,14 +369,14 @@ retry:
369 fs->group_desc[i].bg_free_inodes_count = 369 fs->group_desc[i].bg_free_inodes_count =
370 fs->super->s_inodes_per_group; 370 fs->super->s_inodes_per_group;
371 fs->group_desc[i].bg_used_dirs_count = 0; 371 fs->group_desc[i].bg_used_dirs_count = 0;
372 372
373 group_block += super->s_blocks_per_group; 373 group_block += super->s_blocks_per_group;
374 } 374 }
375 375
376 ext2fs_mark_super_dirty(fs); 376 ext2fs_mark_super_dirty(fs);
377 ext2fs_mark_bb_dirty(fs); 377 ext2fs_mark_bb_dirty(fs);
378 ext2fs_mark_ib_dirty(fs); 378 ext2fs_mark_ib_dirty(fs);
379 379
380 io_channel_set_blksize(fs->io, fs->blocksize); 380 io_channel_set_blksize(fs->io, fs->blocksize);
381 381
382 *ret_fs = fs; 382 *ret_fs = fs;