diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 1999-09-17 08:35:08 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 1999-09-17 08:35:08 +0000 |
commit | 13d9e61a674ba8dbc03f64563e83527606af54cc (patch) | |
tree | 1b6faed5a505156d54deee4bc5dbd639b738a0c4 /sys/compat | |
parent | f35e5d0ef0a10ebda81a076bbd838d12b916dab5 (diff) | |
download | src-test2-13d9e61a674ba8dbc03f64563e83527606af54cc.tar.gz src-test2-13d9e61a674ba8dbc03f64563e83527606af54cc.zip |
Notes
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_file.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index b0e8a367c83a..66e9312ed6b7 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -855,14 +855,27 @@ linux_link(struct proc *p, struct linux_link_args *args) int linux_getcwd(struct proc *p, struct linux_getcwd_args *args) { - struct __getcwd_args bsd; + struct __getcwd_args bsd; + caddr_t sg; + int error, len; #ifdef DEBUG - printf("Linux-emul(%d): getcwd(%p, %ld)\n", - p->p_pid, args->buf, args->bufsize); + printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid, + args->buf, args->bufsize); #endif - bsd.buf = args->buf; - bsd.buflen = args->bufsize; - return __getcwd(p, &bsd); + sg = stackgap_init(); + bsd.buf = stackgap_alloc(&sg, SPARE_USRSPACE); + bsd.buflen = SPARE_USRSPACE; + error = __getcwd(p, &bsd); + if (!error) { + len = strlen(bsd.buf) + 1; + if (len <= args->bufsize) { + p->p_retval[0] = len; + error = copyout(bsd.buf, args->buf, len); + } + else + error = ERANGE; + } + return (error); } |