Whamcloud - gitweb
Add configure --disable-tdb which disables e2fsck's scratch_files feature
[tools/e2fsprogs.git] / lib / ext2fs / newdir.c
index 44e4ca9..7f47285 100644 (file)
@@ -45,8 +45,7 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
        memset(buf, 0, fs->blocksize);
        dir = (struct ext2_dir_entry *) buf;
 
-       if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
-                                      EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
+       if (ext2fs_has_feature_metadata_csum(fs->super))
                csum_size = sizeof(struct ext2_dir_entry_tail);
 
        retval = ext2fs_set_rec_len(fs, fs->blocksize - csum_size, dir);
@@ -56,8 +55,7 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
        }
 
        if (dir_ino) {
-               if (fs->super->s_feature_incompat &
-                   EXT2_FEATURE_INCOMPAT_FILETYPE)
+               if (ext2fs_has_feature_filetype(fs->super))
                        filetype = EXT2_FT_DIR;
                /*
                 * Set up entry for '.'
@@ -93,3 +91,36 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino,
        *block = buf;
        return 0;
 }
+
+/*
+ * Create new directory on inline data
+ */
+errcode_t ext2fs_new_dir_inline_data(ext2_filsys fs,
+                                    ext2_ino_t dir_ino EXT2FS_ATTR((unused)),
+                                    ext2_ino_t parent_ino, __u32 *iblock)
+{
+       struct ext2_dir_entry   *dir = NULL;
+       errcode_t               retval;
+       int                     rec_len;
+
+       EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
+
+       iblock[0] = ext2fs_cpu_to_le32(parent_ino);
+
+       dir = (struct ext2_dir_entry *)((char *)iblock +
+                                       EXT4_INLINE_DATA_DOTDOT_SIZE);
+       dir->inode = 0;
+       rec_len = EXT4_MIN_INLINE_DATA_SIZE - EXT4_INLINE_DATA_DOTDOT_SIZE;
+       retval = ext2fs_set_rec_len(fs, rec_len, dir);
+       if (retval)
+               goto errout;
+
+#ifdef WORDS_BIGENDIAN
+       retval = ext2fs_dirent_swab_out2(fs, (char *)dir, rec_len, 0);
+       if (retval)
+               goto errout;
+#endif
+
+errout:
+       return retval;
+}