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