allocate memory for statvfs instead of using the stack.

This commit is contained in:
christos 2004-05-22 20:46:53 +00:00
parent 880fcd4a6e
commit 9a0b176050
1 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls_20.c,v 1.1 2004/04/21 01:05:36 christos Exp $ */ /* $NetBSD: vfs_syscalls_20.c,v 1.2 2004/05/22 20:46:53 christos Exp $ */
/* /*
* Copyright (c) 1989, 1993 * Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.1 2004/04/21 01:05:36 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.2 2004/05/22 20:46:53 christos Exp $");
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
#include "opt_compat_43.h" #include "opt_compat_43.h"
@ -150,18 +150,25 @@ compat_20_sys_statfs(l, v, retval)
} */ *uap = v; } */ *uap = v;
struct proc *p = l->l_proc; struct proc *p = l->l_proc;
struct mount *mp; struct mount *mp;
struct statvfs sbuf; struct statvfs *sbuf;
int error; int error = 0;
struct nameidata nd; struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
if ((error = namei(&nd)) != 0) if ((error = namei(&nd)) != 0)
return error; return error;
mp = nd.ni_vp->v_mount; mp = nd.ni_vp->v_mount;
vrele(nd.ni_vp); vrele(nd.ni_vp);
sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK);
if ((error = dostatvfs(mp, &sbuf, p, 0, 1)) != 0) if ((error = dostatvfs(mp, &sbuf, p, 0, 1)) != 0)
return error; goto done;
return vfs2fs(SCARG(uap, buf), &sbuf);
error = vfs2fs(SCARG(uap, buf), &sbuf);
done:
free(sbuf, M_TEMP);
return error;
} }
/* /*