aboutsummaryrefslogtreecommitdiffstats
path: root/fs/isofs/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/isofs/dir.c')
-rw-r--r--fs/isofs/dir.c87
1 files changed, 47 insertions, 40 deletions
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index 0e94c31cad9b..1ba407c64df1 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -7,34 +7,18 @@
7 * 7 *
8 * Steve Beynon : Missing last directory entries fixed 8 * Steve Beynon : Missing last directory entries fixed
9 * (stephen@askone.demon.co.uk) : 21st June 1996 9 * (stephen@askone.demon.co.uk) : 21st June 1996
10 * 10 *
11 * isofs directory handling functions 11 * isofs directory handling functions
12 */ 12 */
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include "isofs.h" 14#include "isofs.h"
15 15
16static int isofs_readdir(struct file *, void *, filldir_t);
17
18const struct file_operations isofs_dir_operations =
19{
20 .read = generic_read_dir,
21 .readdir = isofs_readdir,
22};
23
24/*
25 * directories can handle most operations...
26 */
27const struct inode_operations isofs_dir_inode_operations =
28{
29 .lookup = isofs_lookup,
30};
31
32int isofs_name_translate(struct iso_directory_record *de, char *new, struct inode *inode) 16int isofs_name_translate(struct iso_directory_record *de, char *new, struct inode *inode)
33{ 17{
34 char * old = de->name; 18 char * old = de->name;
35 int len = de->name_len[0]; 19 int len = de->name_len[0];
36 int i; 20 int i;
37 21
38 for (i = 0; i < len; i++) { 22 for (i = 0; i < len; i++) {
39 unsigned char c = old[i]; 23 unsigned char c = old[i];
40 if (!c) 24 if (!c)
@@ -62,22 +46,27 @@ int isofs_name_translate(struct iso_directory_record *de, char *new, struct inod
62} 46}
63 47
64/* Acorn extensions written by Matthew Wilcox <willy@bofh.ai> 1998 */ 48/* Acorn extensions written by Matthew Wilcox <willy@bofh.ai> 1998 */
65int get_acorn_filename(struct iso_directory_record * de, 49int get_acorn_filename(struct iso_directory_record *de,
66 char * retname, struct inode * inode) 50 char *retname, struct inode *inode)
67{ 51{
68 int std; 52 int std;
69 unsigned char * chr; 53 unsigned char *chr;
70 int retnamlen = isofs_name_translate(de, retname, inode); 54 int retnamlen = isofs_name_translate(de, retname, inode);
71 if (retnamlen == 0) return 0; 55
56 if (retnamlen == 0)
57 return 0;
72 std = sizeof(struct iso_directory_record) + de->name_len[0]; 58 std = sizeof(struct iso_directory_record) + de->name_len[0];
73 if (std & 1) std++; 59 if (std & 1)
74 if ((*((unsigned char *) de) - std) != 32) return retnamlen; 60 std++;
61 if ((*((unsigned char *) de) - std) != 32)
62 return retnamlen;
75 chr = ((unsigned char *) de) + std; 63 chr = ((unsigned char *) de) + std;
76 if (strncmp(chr, "ARCHIMEDES", 10)) return retnamlen; 64 if (strncmp(chr, "ARCHIMEDES", 10))
77 if ((*retname == '_') && ((chr[19] & 1) == 1)) *retname = '!'; 65 return retnamlen;
66 if ((*retname == '_') && ((chr[19] & 1) == 1))
67 *retname = '!';
78 if (((de->flags[0] & 2) == 0) && (chr[13] == 0xff) 68 if (((de->flags[0] & 2) == 0) && (chr[13] == 0xff)
79 && ((chr[12] & 0xf0) == 0xf0)) 69 && ((chr[12] & 0xf0) == 0xf0)) {
80 {
81 retname[retnamlen] = ','; 70 retname[retnamlen] = ',';
82 sprintf(retname+retnamlen+1, "%3.3x", 71 sprintf(retname+retnamlen+1, "%3.3x",
83 ((chr[12] & 0xf) << 8) | chr[11]); 72 ((chr[12] & 0xf) << 8) | chr[11]);
@@ -91,7 +80,7 @@ int get_acorn_filename(struct iso_directory_record * de,
91 */ 80 */
92static int do_isofs_readdir(struct inode *inode, struct file *filp, 81static int do_isofs_readdir(struct inode *inode, struct file *filp,
93 void *dirent, filldir_t filldir, 82 void *dirent, filldir_t filldir,
94 char * tmpname, struct iso_directory_record * tmpde) 83 char *tmpname, struct iso_directory_record *tmpde)
95{ 84{
96 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); 85 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
97 unsigned char bufbits = ISOFS_BUFFER_BITS(inode); 86 unsigned char bufbits = ISOFS_BUFFER_BITS(inode);
@@ -121,9 +110,11 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
121 110
122 de_len = *(unsigned char *) de; 111 de_len = *(unsigned char *) de;
123 112
124 /* If the length byte is zero, we should move on to the next 113 /*
125 CDROM sector. If we are at the end of the directory, we 114 * If the length byte is zero, we should move on to the next
126 kick out of the while loop. */ 115 * CDROM sector. If we are at the end of the directory, we
116 * kick out of the while loop.
117 */
127 118
128 if (de_len == 0) { 119 if (de_len == 0) {
129 brelse(bh); 120 brelse(bh);
@@ -157,11 +148,10 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
157 148
158 if (first_de) { 149 if (first_de) {
159 isofs_normalize_block_and_offset(de, 150 isofs_normalize_block_and_offset(de,
160 &block_saved, 151 &block_saved,
161 &offset_saved); 152 &offset_saved);
162 inode_number = isofs_get_ino(block_saved, 153 inode_number = isofs_get_ino(block_saved,
163 offset_saved, 154 offset_saved, bufbits);
164 bufbits);
165 } 155 }
166 156
167 if (de->flags[-sbi->s_high_sierra] & 0x80) { 157 if (de->flags[-sbi->s_high_sierra] & 0x80) {
@@ -199,7 +189,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
199 */ 189 */
200 if ((sbi->s_hide == 'y' && 190 if ((sbi->s_hide == 'y' &&
201 (de->flags[-sbi->s_high_sierra] & 1)) || 191 (de->flags[-sbi->s_high_sierra] & 1)) ||
202 (sbi->s_showassoc =='n' && 192 (sbi->s_showassoc =='n' &&
203 (de->flags[-sbi->s_high_sierra] & 4))) { 193 (de->flags[-sbi->s_high_sierra] & 4))) {
204 filp->f_pos += de_len; 194 filp->f_pos += de_len;
205 continue; 195 continue;
@@ -240,7 +230,8 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
240 230
241 continue; 231 continue;
242 } 232 }
243 if (bh) brelse(bh); 233 if (bh)
234 brelse(bh);
244 return 0; 235 return 0;
245} 236}
246 237
@@ -253,8 +244,8 @@ static int isofs_readdir(struct file *filp,
253 void *dirent, filldir_t filldir) 244 void *dirent, filldir_t filldir)
254{ 245{
255 int result; 246 int result;
256 char * tmpname; 247 char *tmpname;
257 struct iso_directory_record * tmpde; 248 struct iso_directory_record *tmpde;
258 struct inode *inode = filp->f_path.dentry->d_inode; 249 struct inode *inode = filp->f_path.dentry->d_inode;
259 250
260 tmpname = (char *)__get_free_page(GFP_KERNEL); 251 tmpname = (char *)__get_free_page(GFP_KERNEL);
@@ -270,3 +261,19 @@ static int isofs_readdir(struct file *filp,
270 unlock_kernel(); 261 unlock_kernel();
271 return result; 262 return result;
272} 263}
264
265const struct file_operations isofs_dir_operations =
266{
267 .read = generic_read_dir,
268 .readdir = isofs_readdir,
269};
270
271/*
272 * directories can handle most operations...
273 */
274const struct inode_operations isofs_dir_inode_operations =
275{
276 .lookup = isofs_lookup,
277};
278
279