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