#include "ext2_fs.h"
#include "ext2fs.h"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#if defined(__linux__) && defined(EXT2_OS_LINUX)
#define CREATOR_OS EXT2_OS_LINUX
#else
int csum_flag;
int bigalloc_flag;
int io_flags;
+ int has_bg;
unsigned reserved_inos;
char *buf = 0;
char c;
double reserved_ratio;
+ char *time_env;
if (!param || !ext2fs_blocks_count(param))
return EXT2_ET_INVALID_ARGUMENT;
#ifdef WORDS_BIGENDIAN
fs->flags |= EXT2_FLAG_SWAP_BYTES;
#endif
+
+ time_env = getenv("E2FSPROGS_FAKE_TIME");
+ if (time_env)
+ fs->now = strtoul(time_env, NULL, 0);
+
io_flags = IO_FLAG_RW;
if (flags & EXT2_FLAG_EXCLUSIVE)
io_flags |= IO_FLAG_EXCLUSIVE;
if (flags & EXT2_FLAG_DIRECT_IO)
io_flags |= IO_FLAG_DIRECT_IO;
+ io_flags |= O_BINARY;
retval = manager->open(name, io_flags, &fs->io);
if (retval)
goto cleanup;
* backup.
*/
overhead = (int) (2 + fs->inode_blocks_per_group);
- if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1))
+ has_bg = 0;
+ if (ext2fs_has_feature_sparse_super2(super)) {
+ /*
+ * We have to do this manually since
+ * super->s_backup_bgs hasn't been set up yet.
+ */
+ if (fs->group_desc_count == 2)
+ has_bg = param->s_backup_bgs[0] != 0;
+ else
+ has_bg = param->s_backup_bgs[1] != 0;
+ } else
+ has_bg = ext2fs_bg_has_super(fs, fs->group_desc_count - 1);
+ if (has_bg)
overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks;
rem = ((ext2fs_blocks_count(super) - super->s_first_data_block) %
super->s_blocks_per_group);