2 * dirblock.c --- directory block routines.
4 * Copyright (C) 1995, 1996 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
23 errcode_t ext2fs_read_dir_block4(ext2_filsys fs, blk64_t block,
24 void *buf, int flags EXT2FS_ATTR((unused)),
30 retval = io_channel_read_blk64(fs->io, block, 1, buf);
34 if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
35 !ext2fs_dir_block_csum_verify(fs, ino,
36 (struct ext2_dir_entry *)buf))
39 #ifdef WORDS_BIGENDIAN
40 retval = ext2fs_dirent_swab_in(fs, buf, flags);
42 if (!retval && corrupt)
43 retval = EXT2_ET_DIR_CSUM_INVALID;
47 errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block,
48 void *buf, int flags EXT2FS_ATTR((unused)))
50 return ext2fs_read_dir_block4(fs, block, buf, flags, 0);
53 errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
54 void *buf, int flags EXT2FS_ATTR((unused)))
56 return ext2fs_read_dir_block3(fs, block, buf, flags);
59 errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
62 return ext2fs_read_dir_block3(fs, block, buf, 0);
66 errcode_t ext2fs_write_dir_block4(ext2_filsys fs, blk64_t block,
67 void *inbuf, int flags EXT2FS_ATTR((unused)),
73 #ifdef WORDS_BIGENDIAN
74 retval = ext2fs_get_mem(fs->blocksize, &buf);
77 memcpy(buf, inbuf, fs->blocksize);
78 retval = ext2fs_dirent_swab_out(fs, buf, flags);
82 retval = ext2fs_dir_block_csum_set(fs, ino,
83 (struct ext2_dir_entry *)buf);
87 retval = io_channel_write_blk64(fs->io, block, 1, buf);
90 #ifdef WORDS_BIGENDIAN
91 ext2fs_free_mem(&buf);
96 errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block,
97 void *inbuf, int flags EXT2FS_ATTR((unused)))
99 return ext2fs_write_dir_block4(fs, block, inbuf, flags, 0);
102 errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
103 void *inbuf, int flags EXT2FS_ATTR((unused)))
105 return ext2fs_write_dir_block3(fs, block, inbuf, flags);
108 errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block,
111 return ext2fs_write_dir_block3(fs, block, inbuf, 0);