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