Import 2.1.118
[davej-history.git] / fs / umsdos / file.c
blob99bf747cc09e9ca58a0906a28fe225172b7631ed
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>
22 #define PRINTK(x)
23 #define Printk(x) printk x
27 * Read a file into user space memory
29 static ssize_t UMSDOS_file_read (
30 struct file *filp,
31 char *buf,
32 size_t count,
33 loff_t * ppos
36 struct dentry *dentry = filp->f_dentry;
37 struct inode *inode = dentry->d_inode;
39 /* We have to set the access time because msdos don't care */
40 /* FIXME */
41 int ret = fat_file_read (filp, buf, count, ppos);
43 if (!IS_RDONLY (inode)) {
44 inode->i_atime = CURRENT_TIME;
45 /* FIXME
46 * inode->i_dirt = 1;
49 return ret;
54 * Write a file from user space memory
56 static ssize_t UMSDOS_file_write (
57 struct file *filp,
58 const char *buf,
59 size_t count,
60 loff_t * ppos)
62 return fat_file_write (filp, buf, count, ppos);
67 * Truncate a file to 0 length.
69 static void UMSDOS_truncate (struct inode *inode)
71 Printk (("UMSDOS_truncate\n"));
72 fat_truncate (inode);
73 inode->i_ctime = inode->i_mtime = CURRENT_TIME;
75 /*FIXME inode->i_dirt = 1; */
78 /* Function for normal file system (512 bytes hardware sector size) */
79 struct file_operations umsdos_file_operations =
81 NULL, /* lseek - default */
82 UMSDOS_file_read, /* read */
83 UMSDOS_file_write, /* write */
84 NULL, /* readdir - bad */
85 NULL, /* poll - default */
86 NULL, /* ioctl - default */
87 generic_file_mmap, /* mmap */
88 NULL, /* no special open is needed */
89 NULL, /* flush */
90 NULL, /* release */
91 file_fsync /* fsync */
94 struct inode_operations umsdos_file_inode_operations =
96 &umsdos_file_operations, /* default file operations */
97 NULL, /* create */
98 NULL, /* lookup */
99 NULL, /* link */
100 NULL, /* unlink */
101 NULL, /* symlink */
102 NULL, /* mkdir */
103 NULL, /* rmdir */
104 NULL, /* mknod */
105 NULL, /* rename */
106 NULL, /* readlink */
107 NULL, /* follow_link */
108 generic_readpage, /* readpage */
109 NULL, /* writepage */
110 fat_bmap, /* bmap */
111 UMSDOS_truncate, /* truncate */
112 NULL, /* permission */
113 fat_smap /* smap */
116 /* For other with larger and unaligned file system */
117 struct file_operations umsdos_file_operations_no_bmap =
119 NULL, /* lseek - default */
120 UMSDOS_file_read, /* read */
121 UMSDOS_file_write, /* write */
122 NULL, /* readdir - bad */
123 NULL, /* poll - default */
124 NULL, /* ioctl - default */
125 fat_mmap, /* mmap */
126 NULL, /* no special open is needed */
127 NULL, /* flush */
128 NULL, /* release */
129 file_fsync /* fsync */
132 struct inode_operations umsdos_file_inode_operations_no_bmap =
134 &umsdos_file_operations_no_bmap, /* default file operations */
135 NULL, /* create */
136 NULL, /* lookup */
137 NULL, /* link */
138 NULL, /* unlink */
139 NULL, /* symlink */
140 NULL, /* mkdir */
141 NULL, /* rmdir */
142 NULL, /* mknod */
143 NULL, /* rename */
144 NULL, /* readlink */
145 NULL, /* follow link */
146 NULL, /* readpage */
147 NULL, /* writepage */
148 NULL, /* bmap */
149 UMSDOS_truncate, /* truncate */
150 NULL, /* permission */
151 NULL, /* smap */
154 /* For other with larger and unaligned file system with readpage */
155 struct file_operations umsdos_file_operations_readpage =
157 NULL, /* lseek - default */
158 UMSDOS_file_read, /* read */
159 UMSDOS_file_write, /* write */
160 NULL, /* readdir - bad */
161 NULL, /* poll - default */
162 NULL, /* ioctl - default */
163 generic_file_mmap, /* mmap */
164 NULL, /* no special open is needed */
165 NULL, /* flush */
166 NULL, /* release */
167 file_fsync /* fsync */
170 struct inode_operations umsdos_file_inode_operations_readpage =
172 &umsdos_file_operations_readpage, /* default file operations */
173 NULL, /* create */
174 NULL, /* lookup */
175 NULL, /* link */
176 NULL, /* unlink */
177 NULL, /* symlink */
178 NULL, /* mkdir */
179 NULL, /* rmdir */
180 NULL, /* mknod */
181 NULL, /* rename */
182 NULL, /* readlink */
183 NULL, /* follow link */
184 fat_readpage, /* readpage */
185 NULL, /* writepage */
186 NULL, /* bmap */
187 UMSDOS_truncate, /* truncate */
188 NULL, /* permission */
189 NULL, /* smap */