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