Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | |
2 | #include <fs/types.h> |
||
3 | #include <fs/errno.h> |
||
4 | #include <fs/task.h> |
||
5 | #include <fs/maccess.h> |
||
6 | #include <fs/dirent.h> |
||
7 | |||
8 | #include "file.h" |
||
9 | #include "inode.h" |
||
10 | #include "fileop.h" |
||
11 | #include "fs.h" |
||
12 | |||
13 | #include "debug.h" |
||
14 | |||
15 | int k_readdir(int fd, struct dirent *den) |
||
16 | { |
||
17 | __pid_t pid; |
||
18 | int ret; |
||
19 | |||
20 | call_to_fs(); |
||
21 | |||
22 | printk5("k_readdir: START"); |
||
23 | |||
24 | /* don't try to use a bad file descriptor */ |
||
25 | pid=__get_pid(); |
||
26 | if (check_fd(pid,fd)) { |
||
27 | printk(KERN_INFO "k_readdir: using bad file descriptor"); |
||
28 | return_from_fs(-EBADF); |
||
29 | } |
||
30 | |||
31 | /* don't try to read a regular file */ |
||
32 | if (!file_ptr(pid,fd)->f_flag_isdir) return_from_fs(-EBADF); |
||
33 | |||
34 | /* don't try to read into not user memory */ |
||
35 | if (!__verify_write(den,sizeof(struct dirent))) return_from_fs(-EVERIFY); |
||
36 | |||
37 | printk5("k_readdir: parameters check pass... calling specific readdir"); |
||
38 | |||
39 | ret=file_ptr(pid,fd)->f_op->readdir(file_ptr(pid,fd),den); |
||
40 | |||
41 | printk5("k_readdir: END"); |
||
42 | |||
43 | return_from_fs(ret); |
||
44 | } |