summaryrefslogtreecommitdiffstats
path: root/fs/umsdos/file.c
blob: 339d828011f2043a26bd62473b04a6a42070ba9c (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 *  linux/fs/umsdos/file.c
 *
 *  Written 1993 by Jacques Gelinas
 *      inspired from linux/fs/msdos/file.c Werner Almesberger
 *
 *  Extended MS-DOS regular file handling primitives
 */

#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/msdos_fs.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/stat.h>
#include <linux/msdos_fs.h>
#include <linux/umsdos_fs.h>

#include <asm/uaccess.h>
#include <asm/system.h>

/*
 * Read a file into user space memory
 */
static ssize_t UMSDOS_file_read (
					struct file *filp,
					char *buf,
					size_t count,
					loff_t * ppos
)
{
	struct dentry *dentry = filp->f_dentry;
	struct inode *inode = dentry->d_inode;

	int ret = fat_file_read (filp, buf, count, ppos);

	/* We have to set the access time because msdos don't care */
	if (!IS_RDONLY (inode)) {
		inode->i_atime = CURRENT_TIME;
		mark_inode_dirty(inode);
	}
	return ret;
}


/*
 * Write a file from user space memory
 */
static ssize_t UMSDOS_file_write (
					 struct file *filp,
					 const char *buf,
					 size_t count,
					 loff_t * ppos)
{
	return fat_file_write (filp, buf, count, ppos);
}


/*
 * Truncate a file to 0 length.
 */
static void UMSDOS_truncate (struct inode *inode)
{
	Printk (("UMSDOS_truncate\n"));
	if (!IS_RDONLY (inode)) {
		fat_truncate (inode);
		inode->i_ctime = inode->i_mtime = CURRENT_TIME;
		mark_inode_dirty(inode);
	}
}

/* Function for normal file system (512 bytes hardware sector size) */
struct file_operations umsdos_file_operations =
{
	NULL,			/* lseek - default */
	UMSDOS_file_read,	/* read */
	UMSDOS_file_write,	/* write */
	NULL,			/* readdir - bad */
	NULL,			/* poll - default */
	NULL,			/* ioctl - default */
	generic_file_mmap,	/* mmap */
	NULL,			/* no special open is needed */
	NULL,			/* flush */
	NULL,			/* release */
	file_fsync		/* fsync */
};

struct inode_operations umsdos_file_inode_operations =
{
	&umsdos_file_operations,	/* default file operations */
	NULL,			/* create */
	NULL,			/* lookup */
	NULL,			/* link */
	NULL,			/* unlink */
	NULL,			/* symlink */
	NULL,			/* mkdir */
	NULL,			/* rmdir */
	NULL,			/* mknod */
	NULL,			/* rename */
	NULL,			/* readlink */
	NULL,			/* follow_link */
	generic_readpage,	/* readpage */
	NULL,			/* writepage */
	fat_bmap,		/* bmap */
	UMSDOS_truncate,	/* truncate */
	NULL,			/* permission */
	fat_smap		/* smap */
};

/* For other with larger and unaligned file system */
struct file_operations umsdos_file_operations_no_bmap =
{
	NULL,			/* lseek - default */
	UMSDOS_file_read,	/* read */
	UMSDOS_file_write,	/* write */
	NULL,			/* readdir - bad */
	NULL,			/* poll - default */
	NULL,			/* ioctl - default */
	fat_mmap,		/* mmap */
	NULL,			/* no special open is needed */
	NULL,			/* flush */
	NULL,			/* release */
	file_fsync		/* fsync */
};

struct inode_operations umsdos_file_inode_operations_no_bmap =
{
	&umsdos_file_operations_no_bmap,	/* default file operations */
	NULL,			/* create */
	NULL,			/* lookup */
	NULL,			/* link */
	NULL,			/* unlink */
	NULL,			/* symlink */
	NULL,			/* mkdir */
	NULL,			/* rmdir */
	NULL,			/* mknod */
	NULL,			/* rename */
	NULL,			/* readlink */
	NULL,			/* follow link */
	NULL,			/* readpage */
	NULL,			/* writepage */
	NULL,			/* bmap */
	UMSDOS_truncate,	/* truncate */
	NULL,			/* permission */
	NULL,			/* smap */
};

/* For other with larger and unaligned file system with readpage */
struct file_operations umsdos_file_operations_readpage =
{
	NULL,			/* lseek - default */
	UMSDOS_file_read,	/* read */
	UMSDOS_file_write,	/* write */
	NULL,			/* readdir - bad */
	NULL,			/* poll - default */
	NULL,			/* ioctl - default */
	generic_file_mmap,	/* mmap */
	NULL,			/* no special open is needed */
	NULL,			/* flush */
	NULL,			/* release */
	file_fsync		/* fsync */
};

struct inode_operations umsdos_file_inode_operations_readpage =
{
	&umsdos_file_operations_readpage,	/* default file operations */
	NULL,			/* create */
	NULL,			/* lookup */
	NULL,			/* link */
	NULL,			/* unlink */
	NULL,			/* symlink */
	NULL,			/* mkdir */
	NULL,			/* rmdir */
	NULL,			/* mknod */
	NULL,			/* rename */
	NULL,			/* readlink */
	NULL,			/* follow link */
	fat_readpage,		/* readpage */
	NULL,			/* writepage */
	NULL,			/* bmap */
	UMSDOS_truncate,	/* truncate */
	NULL,			/* permission */
	NULL,			/* smap */
};