1 /* vi: set sw=4 ts=4: */
3 * valid_blk.c --- does the inode have valid blocks?
5 * Copyright 1997 by Theodore Ts'o
8 * This file may be redistributed under the terms of the GNU Public
25 * This function returns 1 if the inode's block entries actually
26 * contain block entries.
28 int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode)
31 * Only directories, regular files, and some symbolic links
32 * have valid block entries.
34 if (!LINUX_S_ISDIR(inode->i_mode) && !LINUX_S_ISREG(inode->i_mode) &&
35 !LINUX_S_ISLNK(inode->i_mode))
39 * If the symbolic link is a "fast symlink", then the symlink
40 * target is stored in the block entries.
42 if (LINUX_S_ISLNK (inode->i_mode)) {
43 if (inode->i_file_acl == 0) {
44 /* With no EA block, we can rely on i_blocks */
45 if (inode->i_blocks == 0)
48 /* With an EA block, life gets more tricky */
49 if (inode->i_size >= EXT2_N_BLOCKS*4)
50 return 1; /* definitely using i_block[] */
51 if (inode->i_size > 4 && inode->i_block[1] == 0)
52 return 1; /* definitely using i_block[] */
53 return 0; /* Probably a fast symlink */