Import 2.3.9pre7
[davej-history.git] / fs / umsdos / file.c
blobd3d8a74e641aac4cb91a8bbf1d02f67eda465165
1 /*
2 * linux/fs/umsdos/file.c
4 * Written 1993 by Jacques Gelinas
5 * inspired from linux/fs/msdos/file.c Werner Almesberger
7 * Extended MS-DOS regular file handling primitives
8 */
10 #include <linux/sched.h>
11 #include <linux/fs.h>
12 #include <linux/msdos_fs.h>
13 #include <linux/errno.h>
14 #include <linux/fcntl.h>
15 #include <linux/stat.h>
16 #include <linux/msdos_fs.h>
17 #include <linux/umsdos_fs.h>
19 #include <asm/uaccess.h>
20 #include <asm/system.h>
23 * Read a file into user space memory
25 static ssize_t UMSDOS_file_read (
26 struct file *filp,
27 char *buf,
28 size_t count,
29 loff_t * ppos
32 struct dentry *dentry = filp->f_dentry;
33 struct inode *inode = dentry->d_inode;
35 int ret = fat_file_read (filp, buf, count, ppos);
37 /* We have to set the access time because msdos don't care */
38 if (!IS_RDONLY (inode)) {
39 inode->i_atime = CURRENT_TIME;
40 mark_inode_dirty(inode);
42 return ret;
47 * Write a file from user space memory
49 static ssize_t UMSDOS_file_write (
50 struct file *filp,
51 const char *buf,
52 size_t count,
53 loff_t * ppos)
55 return fat_file_write (filp, buf, count, ppos);
60 * Truncate a file to 0 length.
62 static void UMSDOS_truncate (struct inode *inode)
64 Printk (("UMSDOS_truncate\n"));
65 if (!IS_RDONLY (inode)) {
66 fat_truncate (inode);
67 inode->i_ctime = inode->i_mtime = CURRENT_TIME;
68 mark_inode_dirty(inode);
72 /* Function for normal file system (512 bytes hardware sector size) */
73 struct file_operations umsdos_file_operations =
75 NULL, /* lseek - default */
76 UMSDOS_file_read, /* read */
77 UMSDOS_file_write, /* write */
78 NULL, /* readdir - bad */
79 NULL, /* poll - default */
80 NULL, /* ioctl - default */
81 generic_file_mmap, /* mmap */
82 NULL, /* no special open is needed */
83 NULL, /* flush */
84 NULL, /* release */
85 file_fsync /* fsync */
88 struct inode_operations umsdos_file_inode_operations =
90 &umsdos_file_operations, /* default file operations */
91 NULL, /* create */
92 NULL, /* lookup */
93 NULL, /* link */
94 NULL, /* unlink */
95 NULL, /* symlink */
96 NULL, /* mkdir */
97 NULL, /* rmdir */
98 NULL, /* mknod */
99 NULL, /* rename */
100 NULL, /* readlink */
101 NULL, /* follow_link */
102 fat_bmap, /* get_block */
103 block_read_full_page, /* readpage */
104 NULL, /* writepage */
105 NULL, /* flushpage */
106 UMSDOS_truncate, /* truncate */
107 NULL, /* permission */
108 fat_smap, /* smap */
109 NULL /* revalidate */
112 /* For other with larger and unaligned file system */
113 struct file_operations umsdos_file_operations_no_bmap =
115 NULL, /* lseek - default */
116 UMSDOS_file_read, /* read */
117 UMSDOS_file_write, /* write */
118 NULL, /* readdir - bad */
119 NULL, /* poll - default */
120 NULL, /* ioctl - default */
121 fat_mmap, /* mmap */
122 NULL, /* no special open is needed */
123 NULL, /* flush */
124 NULL, /* release */
125 file_fsync /* fsync */
128 struct inode_operations umsdos_file_inode_operations_no_bmap =
130 &umsdos_file_operations_no_bmap, /* default file operations */
131 NULL, /* create */
132 NULL, /* lookup */
133 NULL, /* link */
134 NULL, /* unlink */
135 NULL, /* symlink */
136 NULL, /* mkdir */
137 NULL, /* rmdir */
138 NULL, /* mknod */
139 NULL, /* rename */
140 NULL, /* readlink */
141 NULL, /* follow link */
142 NULL, /* get_block */
143 NULL, /* readpage */
144 NULL, /* writepage */
145 NULL, /* flushpage */
146 UMSDOS_truncate, /* truncate */
147 NULL, /* permission */
148 NULL, /* smap */
149 NULL /* revalidate */
152 /* For other with larger and unaligned file system with readpage */
153 struct file_operations umsdos_file_operations_readpage =
155 NULL, /* lseek - default */
156 UMSDOS_file_read, /* read */
157 UMSDOS_file_write, /* write */
158 NULL, /* readdir - bad */
159 NULL, /* poll - default */
160 NULL, /* ioctl - default */
161 generic_file_mmap, /* mmap */
162 NULL, /* no special open is needed */
163 NULL, /* flush */
164 NULL, /* release */
165 file_fsync /* fsync */
168 struct inode_operations umsdos_file_inode_operations_readpage =
170 &umsdos_file_operations_readpage, /* default file operations */
171 NULL, /* create */
172 NULL, /* lookup */
173 NULL, /* link */
174 NULL, /* unlink */
175 NULL, /* symlink */
176 NULL, /* mkdir */
177 NULL, /* rmdir */
178 NULL, /* mknod */
179 NULL, /* rename */
180 NULL, /* readlink */
181 NULL, /* follow link */
182 NULL, /* get_block */
183 fat_readpage, /* readpage */
184 NULL, /* writepage */
185 NULL, /* flushpage */
186 UMSDOS_truncate, /* truncate */
187 NULL, /* permission */
188 NULL, /* smap */
189 NULL /* revalidate */