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