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/util.h> |
||
6 | #include <fs/maccess.h> |
||
7 | |||
8 | #include "file.h" |
||
9 | #include "fs.h" |
||
10 | |||
11 | int k_getcwd(char *buf, size_t sz) |
||
12 | { |
||
13 | char *cwd; |
||
14 | int len; |
||
15 | __pid_t pid; |
||
16 | |||
17 | call_to_fs(); |
||
18 | |||
19 | pid=__get_pid(); |
||
20 | lock_desctable(pid); |
||
21 | cwd=cwd_ptr(pid); |
||
22 | if (buf==NULL||strlen(cwd)>=sz) { |
||
23 | unlock_desctable(pid); |
||
24 | return_from_fs(-ERANGE); |
||
25 | } |
||
26 | len=strlen(cwd)+1; |
||
27 | if (!__verify_write(buf,len)) { |
||
28 | unlock_desctable(pid); |
||
29 | return_from_fs(-EVERIFY); |
||
30 | } |
||
31 | __copy_to_user(buf,cwd,len); |
||
32 | unlock_desctable(pid); |
||
33 | return_from_fs(EOK); |
||
34 | } |