summaryrefslogtreecommitdiffstats
path: root/fs/bfs/file.c
blob: 856ed33cd16d1027d61288ceff1ab65d7f9b4e3a (plain)
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
/*
 *	fs/bfs/file.c
 *	BFS file operations.
 *	Copyright (C) 1999 Tigran Aivazian <tigran@ocston.org>
 */

#include <linux/fs.h>
#include <linux/bfs_fs.h>
#include "bfs_defs.h"

#undef DEBUG

#ifdef DEBUG
#define DBG(x...)	printk(x)
#else
#define DBG(x...)
#endif

static ssize_t bfs_file_write(struct file * f, const char * buf, size_t count, loff_t *ppos)
{
	return generic_file_write(f, buf, count, ppos, block_write_partial_page);
}

static struct file_operations bfs_file_operations = {
	llseek:			NULL,
	read:			generic_file_read,
	write:			bfs_file_write,
	readdir:		NULL,
	poll:			NULL,
	ioctl:			NULL,
	mmap:			generic_file_mmap,
	open:			NULL,
	flush:			NULL,
	release:		NULL,
	fsync:			NULL,
	fasync:			NULL,
	check_media_change:	NULL,
	revalidate:		NULL,
};

static int bfs_get_block(struct inode * inode, long block, 
	struct buffer_head * bh_result, int create)
{
	long phys = inode->iu_sblock + block;
	if (!create || phys <= inode->iu_eblock) {
		bh_result->b_dev = inode->i_dev;
		bh_result->b_blocknr = phys;
		bh_result->b_state |= (1UL << BH_Mapped);
		return 0;
	} 
	/* no support for file migration, working on it */
	return -EIO;
}

struct inode_operations bfs_file_inops = {
	default_file_ops:	&bfs_file_operations,
	create:			NULL,
	lookup:			NULL,
	link:			NULL,
	unlink:			NULL,
	symlink:		NULL,
	mkdir:			NULL,
	rmdir:			NULL,
	mknod:			NULL,
	rename:			NULL,
	readlink:		NULL,
	follow_link:		NULL,
	get_block:		bfs_get_block,	
	readpage:		block_read_full_page,
	writepage:		block_write_full_page,
	truncate:		NULL,
	permission:		NULL,
	revalidate:		NULL
};