File: bad_inode.c

package info (click to toggle)
kernel-source-2.0.32 2.0.32-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 29,648 kB
  • ctags: 86,850
  • sloc: ansic: 542,141; asm: 26,201; makefile: 3,423; sh: 1,195; perl: 727; tcl: 408; cpp: 277; lisp: 211; awk: 134
file content (77 lines) | stat: -rw-r--r-- 1,791 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 *  linux/fs/bad_inode.c
 *
 *  Copyright (C) 1997, Stephen Tweedie
 *
 *  Provide stub functions for unreadable inodes
 */

#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/sched.h>

static int return_EIO(void)
{
	return -EIO;
}

#define EIO_ERROR ((void *) (return_EIO))

static struct file_operations bad_file_ops =
{
	EIO_ERROR,		/* lseek */
	EIO_ERROR,		/* read */
	EIO_ERROR,		/* write */
	EIO_ERROR,		/* readdir */
	EIO_ERROR,		/* select */
	EIO_ERROR,		/* ioctl */
	EIO_ERROR,		/* mmap */
	EIO_ERROR,		/* open */
	EIO_ERROR,		/* release */
	EIO_ERROR,		/* fsync */
	EIO_ERROR,		/* fasync */
	EIO_ERROR,		/* check_media_change */
	EIO_ERROR		/* revalidate */
};

static struct inode_operations bad_inode_ops =
{
	&bad_file_ops,		/* default file operations */
	EIO_ERROR,		/* create */
	EIO_ERROR,		/* lookup */
	EIO_ERROR,		/* link */
	EIO_ERROR,		/* unlink */
	EIO_ERROR,		/* symlink */
	EIO_ERROR,		/* mkdir */
	EIO_ERROR,		/* rmdir */
	EIO_ERROR,		/* mknod */
	EIO_ERROR,		/* rename */
	EIO_ERROR,		/* readlink */
	EIO_ERROR,		/* follow_link */
	EIO_ERROR,		/* readpage */
	EIO_ERROR,		/* writepage */
	EIO_ERROR,		/* bmap */
	EIO_ERROR,		/* truncate */
	EIO_ERROR,		/* permission */
	EIO_ERROR		/* smap */
};


/* 
 * When a filesystem is unable to read an inode due to an I/O error in
 * its read_inode() function, it can call make_bad_inode() to return a
 * set of stubs which will return EIO errors as required. 
 *
 * We only need to do limited initialisation: all other fields are
 * preinitialised to zero automatically.
 */
void make_bad_inode(struct inode * inode) 
{
	inode->i_mode = S_IFREG;
	inode->i_flags = S_BAD_INODE;
	inode->i_atime = CURRENT_TIME;
	inode->i_mtime = CURRENT_TIME;
	inode->i_ctime = CURRENT_TIME;
	inode->i_op = &bad_inode_ops;	
}