Add a 32bit syscall wrapper for modstat

Obtained from:	Yahoo!
This commit is contained in:
Paul Saab 2005-01-19 17:53:06 +00:00
parent 7fdf2c856f
commit 0e214fad37
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140482
6 changed files with 94 additions and 8 deletions

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.44 2005/01/04 18:53:32 jhb Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.45 2005/01/19 17:44:59 ps Exp
*/
#ifndef _FREEBSD32_SYSPROTO_H_
@ -183,6 +183,10 @@ struct freebsd32_nanosleep_args {
char rqtp_l_[PADL_(const struct timespec *)]; const struct timespec * rqtp; char rqtp_r_[PADR_(const struct timespec *)];
char rmtp_l_[PADL_(struct timespec *)]; struct timespec * rmtp; char rmtp_r_[PADR_(struct timespec *)];
};
struct freebsd32_modstat_args {
char modid_l_[PADL_(int)]; int modid; char modid_r_[PADR_(int)];
char stat_l_[PADL_(struct module_stat32 *)]; struct module_stat32 * stat; char stat_r_[PADR_(struct module_stat32 *)];
};
struct freebsd32_kevent_args {
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
char changelist_l_[PADL_(const struct kevent *)]; const struct kevent * changelist; char changelist_r_[PADR_(const struct kevent *)];
@ -236,6 +240,7 @@ int freebsd32_truncate(struct thread *, struct freebsd32_truncate_args *);
int freebsd32_ftruncate(struct thread *, struct freebsd32_ftruncate_args *);
int freebsd32_sysctl(struct thread *, struct freebsd32_sysctl_args *);
int freebsd32_nanosleep(struct thread *, struct freebsd32_nanosleep_args *);
int freebsd32_modstat(struct thread *, struct freebsd32_modstat_args *);
int freebsd32_kevent(struct thread *, struct freebsd32_kevent_args *);
int freebsd32_sendfile(struct thread *, struct freebsd32_sendfile_args *);
int freebsd32_sigaction(struct thread *, struct freebsd32_sigaction_args *);

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.44 2005/01/04 18:53:32 jhb Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.45 2005/01/19 17:44:59 ps Exp
*/
#define FREEBSD32_SYS_syscall 0
@ -219,7 +219,7 @@
#define FREEBSD32_SYS_fhopen 298
#define FREEBSD32_SYS_fhstat 299
#define FREEBSD32_SYS_modnext 300
#define FREEBSD32_SYS_modstat 301
#define FREEBSD32_SYS_freebsd32_modstat 301
#define FREEBSD32_SYS_modfnext 302
#define FREEBSD32_SYS_modfind 303
#define FREEBSD32_SYS_kldload 304

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.44 2005/01/04 18:53:32 jhb Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.45 2005/01/19 17:44:59 ps Exp
*/
const char *freebsd32_syscallnames[] = {
@ -308,7 +308,7 @@ const char *freebsd32_syscallnames[] = {
"fhopen", /* 298 = fhopen */
"fhstat", /* 299 = fhstat */
"modnext", /* 300 = modnext */
"modstat", /* 301 = modstat */
"freebsd32_modstat", /* 301 = freebsd32_modstat */
"modfnext", /* 302 = modfnext */
"modfind", /* 303 = modfind */
"kldload", /* 304 = kldload */

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.44 2005/01/04 18:53:32 jhb Exp
* created from FreeBSD: src/sys/compat/freebsd32/syscalls.master,v 1.45 2005/01/19 17:44:59 ps Exp
*/
#include "opt_compat.h"
@ -326,7 +326,7 @@ struct sysent freebsd32_sysent[] = {
{ AS(fhopen_args), (sy_call_t *)fhopen }, /* 298 = fhopen */
{ AS(fhstat_args), (sy_call_t *)fhstat }, /* 299 = fhstat */
{ SYF_MPSAFE | AS(modnext_args), (sy_call_t *)modnext }, /* 300 = modnext */
{ SYF_MPSAFE | AS(modstat_args), (sy_call_t *)modstat }, /* 301 = modstat */
{ SYF_MPSAFE | AS(freebsd32_modstat_args), (sy_call_t *)freebsd32_modstat }, /* 301 = freebsd32_modstat */
{ SYF_MPSAFE | AS(modfnext_args), (sy_call_t *)modfnext }, /* 302 = modfnext */
{ SYF_MPSAFE | AS(modfind_args), (sy_call_t *)modfind }, /* 303 = modfind */
{ SYF_MPSAFE | AS(kldload_args), (sy_call_t *)kldload }, /* 304 = kldload */

View File

@ -421,7 +421,7 @@
299 NOPROTO { int fhstat(const struct fhandle *u_fhp, struct stat *sb); }
; syscall numbers for FreeBSD
300 MNOPROTO { int modnext(int modid); }
301 MNOPROTO { int modstat(int modid, struct module_stat* stat); }
301 MSTD { int freebsd32_modstat(int modid, struct module_stat32* stat); }
302 MNOPROTO { int modfnext(int modid); }
303 MNOPROTO { int modfind(const char *name); }
304 MNOPROTO { int kldload(const char *file); }

View File

@ -24,6 +24,8 @@
* SUCH DAMAGE.
*/
#include "opt_compat.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -410,3 +412,82 @@ modfind(struct thread *td, struct modfind_args *uap)
MOD_SUNLOCK;
return (error);
}
#ifdef COMPAT_IA32
#include <sys/mount.h>
#include <compat/freebsd32/freebsd32_util.h>
#include <compat/freebsd32/freebsd32.h>
#include <compat/freebsd32/freebsd32_proto.h>
typedef union modspecific32 {
int intval;
u_int32_t uintval;
int longval;
u_int32_t ulongval;
} modspecific32_t;
struct module_stat32 {
int version;
char name[MAXMODNAME];
int refs;
int id;
modspecific32_t data;
};
/*
* MPSAFE
*/
int
freebsd32_modstat(struct thread *td, struct freebsd32_modstat_args *uap)
{
module_t mod;
modspecific32_t data32;
int error = 0;
int id, namelen, refs, version;
struct module_stat32 *stat32;
char *name;
MOD_SLOCK;
mod = module_lookupbyid(uap->modid);
if (mod == NULL) {
MOD_SUNLOCK;
return (ENOENT);
}
id = mod->id;
refs = mod->refs;
name = mod->name;
CP(data32, mod->data, intval);
CP(data32, mod->data, uintval);
CP(data32, mod->data, longval);
CP(data32, mod->data, ulongval);
MOD_SUNLOCK;
stat32 = uap->stat;
if ((error = copyin(&stat32->version, &version, sizeof(version))) != 0)
return (error);
if (version != sizeof(struct module_stat_v1)
&& version != sizeof(struct module_stat32))
return (EINVAL);
namelen = strlen(mod->name) + 1;
if (namelen > MAXMODNAME)
namelen = MAXMODNAME;
if ((error = copyout(name, &stat32->name[0], namelen)) != 0)
return (error);
if ((error = copyout(&refs, &stat32->refs, sizeof(int))) != 0)
return (error);
if ((error = copyout(&id, &stat32->id, sizeof(int))) != 0)
return (error);
/*
* >v1 stat includes module data.
*/
if (version == sizeof(struct module_stat32))
if ((error = copyout(&data32, &stat32->data,
sizeof(data32))) != 0)
return (error);
td->td_retval[0] = 0;
return (error);
}
#endif