Rev 3 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <fs/types.h>
#include <fs/errno.h>
#include <fs/task.h>
#include <fs/util.h>
#include <fs/maccess.h>
#include "file.h"
#include "fs.h"
int k_getcwd
(char *buf
, size_t sz
)
{
char *cwd
;
int len
;
__pid_t pid
;
call_to_fs
();
pid
=__get_pid
();
lock_desctable
(pid
);
cwd
=cwd_ptr
(pid
);
if (buf
==NULL
||strlen(cwd
)>=sz
) {
unlock_desctable
(pid
);
return_from_fs
(-ERANGE
);
}
len
=strlen(cwd
)+1;
if (!__verify_write
(buf
,len
)) {
unlock_desctable
(pid
);
return_from_fs
(-EVERIFY
);
}
__copy_to_user
(buf
,cwd
,len
);
unlock_desctable
(pid
);
return_from_fs
(EOK
);
}