blob: 9e50ed5aedaf46724370e23dc70026bead85b1b8 [file] [log] [blame]
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00001/*
2 * valid_blk.c --- does the inode have valid blocks?
3 *
4 * Copyright 1997 by Theodore Ts'o
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 *
11 */
12
13#include <stdio.h>
Theodore Ts'o4cbe8af1997-08-10 23:07:40 +000014#if HAVE_UNISTD_H
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000015#include <unistd.h>
Theodore Ts'o4cbe8af1997-08-10 23:07:40 +000016#endif
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000017#include <string.h>
18#include <time.h>
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000019
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +000020#include "ext2_fs.h"
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000021#include "ext2fs.h"
22
23/*
24 * This function returns 1 if the inode's block entries actually
25 * contain block entries.
26 */
27int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode)
28{
29 /*
30 * Only directories, regular files, and some symbolic links
31 * have valid block entries.
32 */
33 if (!LINUX_S_ISDIR(inode->i_mode) && !LINUX_S_ISREG(inode->i_mode) &&
34 !LINUX_S_ISLNK(inode->i_mode))
35 return 0;
36
37 /*
38 * If the symbolic link is a "fast symlink", then the symlink
39 * target is stored in the block entries.
40 */
Theodore Ts'of36d14f2001-06-02 04:13:16 +000041 if (LINUX_S_ISLNK (inode->i_mode) && inode->i_blocks == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000042 return 0;
43
44 return 1;
45}