/*
* 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);
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 &
*/
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] = '.';
&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.