| * newdir.c --- create a new directory block |
| * Copyright (C) 1994, 1995 Theodore Ts'o. |
| * This file may be redistributed under the terms of the GNU Public |
| * Create new directory block |
| errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino, |
| ext2_ino_t parent_ino, char **block) |
| struct ext2_dir_entry *dir = NULL; |
| EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); |
| retval = ext2fs_get_mem(fs->blocksize, &buf); |
| memset(buf, 0, fs->blocksize); |
| dir = (struct ext2_dir_entry *) buf; |
| dir->rec_len = fs->blocksize; |
| if (fs->super->s_feature_incompat & |
| EXT2_FEATURE_INCOMPAT_FILETYPE) |
| filetype = EXT2_FT_DIR << 8; |
| dir->name_len = 1 | filetype; |
| rec_len = dir->rec_len - EXT2_DIR_REC_LEN(1); |
| dir->rec_len = EXT2_DIR_REC_LEN(1); |
| dir = (struct ext2_dir_entry *) (buf + dir->rec_len); |
| dir->name_len = 2 | filetype; |