This source file includes following definitions.
- msdos_dummy_read
- msdos_readdir
1
2
3
4
5
6
7
8
9 #include <asm/segment.h>
10
11 #include <linux/sched.h>
12 #include <linux/fs.h>
13 #include <linux/msdos_fs.h>
14 #include <linux/errno.h>
15 #include <linux/stat.h>
16
17 static int msdos_dummy_read(struct inode *inode,struct file *filp,char *buf,
18 int count);
19 static int msdos_readdir(struct inode *inode,struct file *filp,
20 struct dirent *dirent,int count);
21
22
23 static struct file_operations msdos_dir_operations = {
24 NULL,
25 msdos_dummy_read,
26 NULL,
27 msdos_readdir,
28 NULL,
29 NULL,
30 NULL,
31 NULL
32 };
33
34 struct inode_operations msdos_dir_inode_operations = {
35 &msdos_dir_operations,
36 msdos_create,
37 msdos_lookup,
38 NULL,
39 msdos_unlink,
40 NULL,
41 msdos_mkdir,
42 msdos_rmdir,
43 NULL,
44 msdos_rename,
45 NULL,
46 NULL,
47 msdos_bmap,
48 NULL
49 };
50
51
52
53
54 static int msdos_dummy_read(struct inode *inode,struct file *filp,char *buf,
55 int count)
56 {
57 static long last_warning = 0;
58
59 if (CURRENT_TIME-last_warning >= 10) {
60 printk("COMPATIBILITY WARNING: reading a directory\r\n");
61 last_warning = CURRENT_TIME;
62 }
63 return 0;
64 }
65
66
67 static int msdos_readdir(struct inode *inode,struct file *filp,
68 struct dirent *dirent,int count)
69 {
70 int ino,i,i2,last;
71 char c,*walk;
72 struct buffer_head *bh;
73 struct msdos_dir_entry *de;
74
75 if (!inode || !S_ISDIR(inode->i_mode)) return -EBADF;
76 if (inode->i_ino == MSDOS_ROOT_INO) {
77
78 if (filp->f_pos == 2) filp->f_pos = 0;
79 else if (filp->f_pos < 2) {
80 walk = filp->f_pos++ ? ".." : ".";
81 for (i = 0; *walk; walk++)
82 put_fs_byte(*walk,dirent->d_name+i++);
83 put_fs_long(MSDOS_ROOT_INO,&dirent->d_ino);
84 put_fs_byte(0,dirent->d_name+i);
85 put_fs_word(i,&dirent->d_reclen);
86 return i;
87 }
88 }
89 if (filp->f_pos & (sizeof(struct msdos_dir_entry)-1)) return -ENOENT;
90 bh = NULL;
91 while ((ino = msdos_get_entry(inode,&filp->f_pos,&bh,&de)) > -1) {
92 if (de->name[0] && ((unsigned char *) (de->name))[0] !=
93 DELETED_FLAG && !(de->attr & ATTR_VOLUME)) {
94 for (i = last = 0; i < 8; i++) {
95 if (!(c = de->name[i])) break;
96 if (c >= 'A' && c <= 'Z') c += 32;
97 if (c != ' ') last = i+1;
98 put_fs_byte(c,i+dirent->d_name);
99 }
100 i = last;
101 if (de->ext[0] && de->ext[0] != ' ') {
102 put_fs_byte('.',i+dirent->d_name);
103 i++;
104 for (i2 = 0; i2 < 3; i2++) {
105 if (!(c = de->ext[i2])) break;
106 if (c >= 'A' && c <= 'Z') c += 32;
107 put_fs_byte(c,i+dirent->d_name);
108 i++;
109 if (c != ' ') last = i;
110 }
111 }
112 if (i = last) {
113 if (!strcmp(de->name,MSDOS_DOT))
114 ino = inode->i_ino;
115 else if (!strcmp(de->name,MSDOS_DOTDOT))
116 ino = msdos_parent_ino(inode,0);
117 put_fs_long(ino,&dirent->d_ino);
118 put_fs_byte(0,i+dirent->d_name);
119 put_fs_word(i,&dirent->d_reclen);
120 brelse(bh);
121 return i;
122 }
123 }
124 }
125 if (bh) brelse(bh);
126 return 0;
127 }