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 msdos_bmap,
55 NULL,
56 NULL
57 };
58
59 int msdos_readdir(
60 struct inode *inode,
61 struct file *filp,
62 void *dirent,
63 filldir_t filldir)
64 {
65 struct super_block *sb = inode->i_sb;
66 int ino,i,i2,last;
67 char c;
68 struct buffer_head *bh;
69 struct msdos_dir_entry *de;
70 unsigned long oldpos = filp->f_pos;
71
72 if (!inode || !S_ISDIR(inode->i_mode))
73 return -EBADF;
74
75 if (inode->i_ino == MSDOS_ROOT_INO) {
76 while (oldpos < 2) {
77 if (filldir(dirent, "..", oldpos+1, oldpos, MSDOS_ROOT_INO) < 0)
78 return 0;
79 oldpos++;
80 filp->f_pos++;
81 }
82 if (oldpos == 2)
83 filp->f_pos = 0;
84 }
85 if (filp->f_pos & (sizeof(struct msdos_dir_entry)-1))
86 return -ENOENT;
87 bh = NULL;
88 while ((ino = msdos_get_entry(inode,&filp->f_pos,&bh,&de)) > -1) {
89 if (!IS_FREE(de->name) && !(de->attr & ATTR_VOLUME)) {
90 char bufname[13];
91 char *ptname = bufname;
92 int dotoffset = 0;
93 if ((de->attr & ATTR_HIDDEN) && MSDOS_SB(sb)->dotsOK) {
94 bufname[0] = '.';
95 dotoffset = 1;
96 ptname = bufname+1;
97 }
98 for (i = last = 0; i < 8; i++) {
99 if (!(c = de->name[i])) break;
100 if (c >= 'A' && c <= 'Z') c += 32;
101
102 if (c == 0x05) c = 0xE5;
103 if (c != ' ')
104 last = i+1;
105 ptname[i] = c;
106 }
107 i = last;
108 ptname[i] = '.';
109 i++;
110 for (i2 = 0; i2 < 3; i2++) {
111 if (!(c = de->ext[i2])) break;
112 if (c >= 'A' && c <= 'Z') c += 32;
113 if (c != ' ')
114 last = i+1;
115 ptname[i] = c;
116 i++;
117 }
118 if ((i = last) != 0) {
119 if (!strcmp(de->name,MSDOS_DOT))
120 ino = inode->i_ino;
121 else if (!strcmp(de->name,MSDOS_DOTDOT))
122 ino = msdos_parent_ino(inode,0);
123 if (filldir(dirent, bufname, i+dotoffset, oldpos, ino) < 0) {
124 filp->f_pos = oldpos;
125 break;
126 }
127 }
128 }
129 oldpos = filp->f_pos;
130 }
131 if (bh) brelse(bh);
132 return 0;
133 }