This source file includes following definitions.
- msdos_dir_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_dir_read(struct inode * inode,struct file * filp, char * buf,int count)
18 {
19 return -EISDIR;
20 }
21
22 static int msdos_readdir(struct inode *inode,struct file *filp,
23 struct dirent *dirent,int count);
24
25 static struct file_operations msdos_dir_operations = {
26 NULL,
27 msdos_dir_read,
28 NULL,
29 msdos_readdir,
30 NULL,
31 NULL,
32 NULL,
33 NULL,
34 NULL,
35 NULL
36 };
37
38 struct inode_operations msdos_dir_inode_operations = {
39 &msdos_dir_operations,
40 msdos_create,
41 msdos_lookup,
42 NULL,
43 msdos_unlink,
44 NULL,
45 msdos_mkdir,
46 msdos_rmdir,
47 NULL,
48 msdos_rename,
49 NULL,
50 NULL,
51 msdos_bmap,
52 NULL,
53 NULL
54 };
55
56 static int msdos_readdir(struct inode *inode,struct file *filp,
57 struct dirent *dirent,int count)
58 {
59 int ino,i,i2,last;
60 char c,*walk;
61 struct buffer_head *bh;
62 struct msdos_dir_entry *de;
63
64 if (!inode || !S_ISDIR(inode->i_mode)) return -EBADF;
65 if (inode->i_ino == MSDOS_ROOT_INO) {
66
67 if (filp->f_pos == 2) filp->f_pos = 0;
68 else if (filp->f_pos < 2) {
69 walk = filp->f_pos++ ? ".." : ".";
70 for (i = 0; *walk; walk++)
71 put_fs_byte(*walk,dirent->d_name+i++);
72 put_fs_long(MSDOS_ROOT_INO,&dirent->d_ino);
73 put_fs_byte(0,dirent->d_name+i);
74 put_fs_word(i,&dirent->d_reclen);
75 return i;
76 }
77 }
78 if (filp->f_pos & (sizeof(struct msdos_dir_entry)-1)) return -ENOENT;
79 bh = NULL;
80 while ((ino = msdos_get_entry(inode,&filp->f_pos,&bh,&de)) > -1) {
81 if (de->name[0] && ((unsigned char *) (de->name))[0] !=
82 DELETED_FLAG && !(de->attr & ATTR_VOLUME)) {
83 for (i = last = 0; i < 8; i++) {
84 if (!(c = de->name[i])) break;
85 if (c >= 'A' && c <= 'Z') c += 32;
86 if (c != ' ') last = i+1;
87 put_fs_byte(c,i+dirent->d_name);
88 }
89 i = last;
90 put_fs_byte('.',i+dirent->d_name);
91 i++;
92 for (i2 = 0; i2 < 3; i2++) {
93 if (!(c = de->ext[i2])) break;
94 if (c >= 'A' && c <= 'Z') c += 32;
95 if (c != ' ') last = i+1;
96 put_fs_byte(c,i+dirent->d_name);
97 i++;
98 }
99 if ((i = last) != 0) {
100 if (!strcmp(de->name,MSDOS_DOT))
101 ino = inode->i_ino;
102 else if (!strcmp(de->name,MSDOS_DOTDOT))
103 ino = msdos_parent_ino(inode,0);
104 put_fs_long(ino,&dirent->d_ino);
105 put_fs_byte(0,i+dirent->d_name);
106 put_fs_word(i,&dirent->d_reclen);
107 brelse(bh);
108 return i;
109 }
110 }
111 }
112 if (bh) brelse(bh);
113 return 0;
114 }