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