From: Theodore Ts'o Date: Thu, 12 Dec 2013 20:39:14 +0000 (-0500) Subject: Merge branch 'maint' into next X-Git-Tag: v1.43-WIP-2015-05-18~370 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d3df8dc7f5f6970e77ed741e35c88408741a136;p=thirdparty%2Fe2fsprogs.git Merge branch 'maint' into next Conflicts: lib/ext2fs/newdir.c --- 2d3df8dc7f5f6970e77ed741e35c88408741a136 diff --cc e2fsck/pass3.c index fbaadcfc6,d7a243e4b..dc9d7c19e --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@@ -785,8 -801,8 +807,9 @@@ errcode_t e2fsck_expand_directory(e2fsc es.err = 0; es.newblocks = 0; es.ctx = ctx; + es.dir = dir; + before = ext2fs_free_blocks_count(fs->super); retval = ext2fs_block_iterate3(fs, dir, BLOCK_FLAG_APPEND, 0, expand_dir_proc, &es); diff --cc lib/ext2fs/ext2fs.h index 654247abe,c982327ec..0624350d0 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@@ -639,13 -631,13 +639,19 @@@ typedef struct stat ext2fs_struct_stat /* * function prototypes */ +static inline int ext2fs_has_group_desc_csum(ext2_filsys fs) +{ + return EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_GDT_CSUM | + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM); +} + /* The LARGE_FILE feature should be set if we have stored files 2GB+ in size */ + static inline int ext2fs_needs_large_file_feature(unsigned long long file_size) + { + return file_size >= 0x80000000ULL; + } + /* alloc.c */ extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode, ext2fs_inode_bitmap map, ext2_ino_t *ret); diff --cc lib/ext2fs/newdir.c index d134bdf04,3e2c0dbec..44e4ca959 --- a/lib/ext2fs/newdir.c +++ b/lib/ext2fs/newdir.c @@@ -45,13 -43,11 +45,15 @@@ errcode_t ext2fs_new_dir_block(ext2_fil memset(buf, 0, fs->blocksize); dir = (struct ext2_dir_entry *) buf; - retval = ext2fs_set_rec_len(fs, fs->blocksize, dir); + if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) + csum_size = sizeof(struct ext2_dir_entry_tail); + + retval = ext2fs_set_rec_len(fs, fs->blocksize - csum_size, dir); - if (retval) + if (retval) { + ext2fs_free_mem(&buf); return retval; + } if (dir_ino) { if (fs->super->s_feature_incompat & @@@ -72,11 -67,12 +74,13 @@@ */ dir = (struct ext2_dir_entry *) (buf + dir->rec_len); retval = ext2fs_set_rec_len(fs, rec_len, dir); - if (retval) + if (retval) { + ext2fs_free_mem(&buf); return retval; + } dir->inode = parent_ino; - dir->name_len = 2 | filetype; + ext2fs_dirent_set_name_len(dir, 2); + ext2fs_dirent_set_file_type(dir, filetype); dir->name[0] = '.'; dir->name[1] = '.'; diff --cc misc/mke2fs.c index 67c922528,74df43431..c1cbcaafb --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@@ -1756,30 -1726,64 +1773,87 @@@ profile_error &fs_param.s_feature_compat); if (tmp) free(tmp); + /* + * If the user specified features incompatible with the Hurd, complain + */ + if (for_hurd(creator_os)) { + if (fs_param.s_feature_incompat & + EXT2_FEATURE_INCOMPAT_FILETYPE) { + fprintf(stderr, _("The HURD does not support the " + "filetype feature.\n")); + exit(1); + } + if (fs_param.s_feature_ro_compat & + EXT4_FEATURE_RO_COMPAT_HUGE_FILE) { + fprintf(stderr, _("The HURD does not support the " + "huge_file feature.\n")); + exit(1); + } + if (fs_param.s_feature_ro_compat & + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) { + fprintf(stderr, _("The HURD does not support the " + "metadata_csum feature.\n")); + exit(1); + } + } + /* Get the hardware sector sizes, if available */ + retval = ext2fs_get_device_sectsize(device_name, &lsector_size); + if (retval) { + com_err(program_name, retval, + _("while trying to determine hardware sector size")); + exit(1); + } + retval = ext2fs_get_device_phys_sectsize(device_name, &psector_size); + if (retval) { + com_err(program_name, retval, + _("while trying to determine physical sector size")); + exit(1); + } + + tmp = getenv("MKE2FS_DEVICE_SECTSIZE"); + if (tmp != NULL) + lsector_size = atoi(tmp); + tmp = getenv("MKE2FS_DEVICE_PHYS_SECTSIZE"); + if (tmp != NULL) + psector_size = atoi(tmp); + + /* Older kernels may not have physical/logical distinction */ + if (!psector_size) + psector_size = lsector_size; + + if (blocksize <= 0) { + use_bsize = get_int_from_profile(fs_types, "blocksize", 4096); + + if (use_bsize == -1) { + use_bsize = sys_page_size; + if ((linux_version_code < (2*65536 + 6*256)) && + (use_bsize > 4096)) + use_bsize = 4096; + } + if (lsector_size && use_bsize < lsector_size) + use_bsize = lsector_size; + if ((blocksize < 0) && (use_bsize < (-blocksize))) + use_bsize = -blocksize; + blocksize = use_bsize; + fs_blocks_count /= (blocksize / 1024); + } else { + if (blocksize < lsector_size) { /* Impossible */ + com_err(program_name, EINVAL, + _("while setting blocksize; too small " + "for device\n")); + exit(1); + } else if ((blocksize < psector_size) && + (psector_size <= sys_page_size)) { /* Suboptimal */ + fprintf(stderr, _("Warning: specified blocksize %d is " + "less than device physical sectorsize %d\n"), + blocksize, psector_size); + } + } + + fs_param.s_log_block_size = + int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE); + /* * We now need to do a sanity check of fs_blocks_count for * 32-bit vs 64-bit block number support.