Rev 3 | Go to most recent revision | Details | 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/major.h> |
||
7 | |||
8 | #include "file.h" |
||
9 | #include "inode.h" |
||
10 | #include "dentry.h" |
||
11 | #include "fs.h" |
||
12 | |||
13 | #include "debug.h" |
||
14 | |||
15 | int k_fstat(int fd, struct stat *buf) |
||
16 | { |
||
17 | struct inode *in=NULL; |
||
18 | __pid_t pid; |
||
19 | |||
20 | call_to_fs(); |
||
21 | |||
22 | /* to do better: for console i/o */ |
||
23 | if (fd>=0&&fd<=2) { |
||
24 | struct stat st; |
||
25 | |||
26 | /* !!! */ |
||
27 | return_from_fs(-EBADF); |
||
28 | |||
29 | st.st_dev=NULLDEV; |
||
30 | st.st_ino=0; |
||
31 | st.st_mode=((fd==0)? |
||
32 | __S_IRUSR|__S_IRGRP|__S_IROTH: |
||
33 | __S_IWUSR|__S_IWGRP|__S_IWOTH); |
||
34 | st.st_nlink=1; |
||
35 | st.st_uid=0; |
||
36 | st.st_gid=0; |
||
37 | st.st_size=0; |
||
38 | st.st_atime=0; |
||
39 | st.st_mtime=0; |
||
40 | st.st_ctime=0; |
||
41 | |||
42 | if (!__verify_write(buf,sizeof(struct stat))) return_from_fs(-EVERIFY); |
||
43 | __copy_to_user(buf,&(in->i_st),sizeof(struct stat)); |
||
44 | return_from_fs(EOK); |
||
45 | } |
||
46 | |||
47 | /* don't try to use bad file descriptor */ |
||
48 | pid=__get_pid(); |
||
49 | if (check_fd(pid,fd)) { |
||
50 | printk(KERN_INFO "k_fstat: using a bad file descriptor"); |
||
51 | return_from_fs(-EBADF); |
||
52 | } |
||
53 | |||
54 | if (!__verify_write(buf,sizeof(struct stat))) return_from_fs(-EVERIFY); |
||
55 | |||
56 | in=file_ptr(pid,fd)->f_dentry->d_inode; |
||
57 | __copy_to_user(buf,&(in->i_st),sizeof(struct stat)); |
||
58 | |||
59 | return_from_fs(EOK); |
||
60 | } |