freebsd32: signed long corrections
Syscalls that take signed longs need to treat the 32-bit versions as signed int so that sign extension happens correctly. Improve decleration quality and add a few minimal syscall implementations. Reviewed by: kevans
This commit is contained in:
parent
d257e57d18
commit
f19e3fd206
@ -1913,6 +1913,14 @@ freebsd32_truncate(struct thread *td, struct freebsd32_truncate_args *uap)
|
||||
PAIR32TO64(off_t, uap->length)));
|
||||
}
|
||||
|
||||
#ifdef COMPAT_43
|
||||
int
|
||||
ofreebsd32_truncate(struct thread *td, struct ofreebsd32_truncate_args *uap)
|
||||
{
|
||||
return (kern_truncate(td, uap->path, UIO_USERSPACE, uap->length));
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
freebsd32_ftruncate(struct thread *td, struct freebsd32_ftruncate_args *uap)
|
||||
{
|
||||
@ -1921,6 +1929,12 @@ freebsd32_ftruncate(struct thread *td, struct freebsd32_ftruncate_args *uap)
|
||||
}
|
||||
|
||||
#ifdef COMPAT_43
|
||||
int
|
||||
ofreebsd32_ftruncate(struct thread *td, struct ofreebsd32_ftruncate_args *uap)
|
||||
{
|
||||
return (kern_ftruncate(td, uap->fd, uap->length));
|
||||
}
|
||||
|
||||
int
|
||||
ofreebsd32_getdirentries(struct thread *td,
|
||||
struct ofreebsd32_getdirentries_args *uap)
|
||||
@ -3842,6 +3856,19 @@ freebsd32_ffclock_getestimate(struct thread *td,
|
||||
}
|
||||
#endif /* FFCLOCK */
|
||||
|
||||
#ifdef COMPAT_43
|
||||
int
|
||||
ofreebsd32_sethostid(struct thread *td, struct ofreebsd32_sethostid_args *uap)
|
||||
{
|
||||
int name[] = { CTL_KERN, KERN_HOSTID };
|
||||
long hostid;
|
||||
|
||||
hostid = uap->hostid;
|
||||
return (kernel_sysctl(td, name, nitems(name), NULL, NULL, &hostid,
|
||||
sizeof(hostid), NULL, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
freebsd32_fspacectl(struct thread *td, struct freebsd32_fspacectl_args *uap)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ struct freebsd32_msgrcv_args {
|
||||
char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)];
|
||||
char msgp_l_[PADL_(void *)]; void * msgp; char msgp_r_[PADR_(void *)];
|
||||
char msgsz_l_[PADL_(size_t)]; size_t msgsz; char msgsz_r_[PADR_(size_t)];
|
||||
char msgtyp_l_[PADL_(long)]; long msgtyp; char msgtyp_r_[PADR_(long)];
|
||||
char msgtyp_l_[PADL_(int32_t)]; int32_t msgtyp; char msgtyp_r_[PADR_(int32_t)];
|
||||
char msgflg_l_[PADL_(int)]; int msgflg; char msgflg_r_[PADR_(int)];
|
||||
};
|
||||
struct freebsd32_clock_gettime_args {
|
||||
@ -932,7 +932,7 @@ int freebsd32_fspacectl(struct thread *, struct freebsd32_fspacectl_args *);
|
||||
#endif
|
||||
struct ofreebsd32_lseek_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char offset_l_[PADL_(int)]; int offset; char offset_r_[PADR_(int)];
|
||||
char offset_l_[PADL_(int32_t)]; int32_t offset; char offset_r_[PADR_(int32_t)];
|
||||
char whence_l_[PADL_(int)]; int whence; char whence_r_[PADR_(int)];
|
||||
};
|
||||
struct ofreebsd32_stat_args {
|
||||
@ -982,11 +982,22 @@ struct ofreebsd32_sendmsg_args {
|
||||
char msg_l_[PADL_(const struct omsghdr32 *)]; const struct omsghdr32 * msg; char msg_r_[PADR_(const struct omsghdr32 *)];
|
||||
char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
|
||||
};
|
||||
struct ofreebsd32_truncate_args {
|
||||
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
|
||||
char length_l_[PADL_(int32_t)]; int32_t length; char length_r_[PADR_(int32_t)];
|
||||
};
|
||||
struct ofreebsd32_ftruncate_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char length_l_[PADL_(int32_t)]; int32_t length; char length_r_[PADR_(int32_t)];
|
||||
};
|
||||
struct ofreebsd32_sethostid_args {
|
||||
char hostid_l_[PADL_(int32_t)]; int32_t hostid; char hostid_r_[PADR_(int32_t)];
|
||||
};
|
||||
struct ofreebsd32_getdirentries_args {
|
||||
char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
|
||||
char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
|
||||
char count_l_[PADL_(u_int)]; u_int count; char count_r_[PADR_(u_int)];
|
||||
char basep_l_[PADL_(uint32_t *)]; uint32_t * basep; char basep_r_[PADR_(uint32_t *)];
|
||||
char basep_l_[PADL_(int32_t *)]; int32_t * basep; char basep_r_[PADR_(int32_t *)];
|
||||
};
|
||||
#ifdef PAD64_REQUIRED
|
||||
#else
|
||||
@ -1017,6 +1028,9 @@ int ofreebsd32_sigvec(struct thread *, struct ofreebsd32_sigvec_args *);
|
||||
int ofreebsd32_sigstack(struct thread *, struct ofreebsd32_sigstack_args *);
|
||||
int ofreebsd32_recvmsg(struct thread *, struct ofreebsd32_recvmsg_args *);
|
||||
int ofreebsd32_sendmsg(struct thread *, struct ofreebsd32_sendmsg_args *);
|
||||
int ofreebsd32_truncate(struct thread *, struct ofreebsd32_truncate_args *);
|
||||
int ofreebsd32_ftruncate(struct thread *, struct ofreebsd32_ftruncate_args *);
|
||||
int ofreebsd32_sethostid(struct thread *, struct ofreebsd32_sethostid_args *);
|
||||
int ofreebsd32_getdirentries(struct thread *, struct ofreebsd32_getdirentries_args *);
|
||||
|
||||
#endif /* COMPAT_43 */
|
||||
@ -1029,7 +1043,7 @@ int ofreebsd32_getdirentries(struct thread *, struct ofreebsd32_getdirentries_ar
|
||||
#endif
|
||||
struct freebsd4_freebsd32_getfsstat_args {
|
||||
char buf_l_[PADL_(struct ostatfs32 *)]; struct ostatfs32 * buf; char buf_r_[PADR_(struct ostatfs32 *)];
|
||||
char bufsize_l_[PADL_(long)]; long bufsize; char bufsize_r_[PADR_(long)];
|
||||
char bufsize_l_[PADL_(int32_t)]; int32_t bufsize; char bufsize_r_[PADR_(int32_t)];
|
||||
char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
|
||||
};
|
||||
struct freebsd4_freebsd32_statfs_args {
|
||||
@ -1390,8 +1404,11 @@ int freebsd11_freebsd32_fstatat(struct thread *, struct freebsd11_freebsd32_fsta
|
||||
#define FREEBSD32_SYS_AUE_freebsd32_readv AUE_READV
|
||||
#define FREEBSD32_SYS_AUE_freebsd32_writev AUE_WRITEV
|
||||
#define FREEBSD32_SYS_AUE_freebsd32_settimeofday AUE_SETTIMEOFDAY
|
||||
#define FREEBSD32_SYS_AUE_ofreebsd32_truncate AUE_TRUNCATE
|
||||
#define FREEBSD32_SYS_AUE_ofreebsd32_ftruncate AUE_FTRUNCATE
|
||||
#define FREEBSD32_SYS_AUE_freebsd32_utimes AUE_UTIMES
|
||||
#define FREEBSD32_SYS_AUE_freebsd32_adjtime AUE_ADJTIME
|
||||
#define FREEBSD32_SYS_AUE_ofreebsd32_sethostid AUE_SYSCTL
|
||||
#define FREEBSD32_SYS_AUE_ofreebsd32_getdirentries AUE_GETDIRENTRIES
|
||||
#define FREEBSD32_SYS_AUE_freebsd4_freebsd32_statfs AUE_STATFS
|
||||
#define FREEBSD32_SYS_AUE_freebsd4_freebsd32_fstatfs AUE_FSTATFS
|
||||
|
@ -131,8 +131,8 @@
|
||||
#define FREEBSD32_SYS_setreuid 126
|
||||
#define FREEBSD32_SYS_setregid 127
|
||||
#define FREEBSD32_SYS_rename 128
|
||||
/* 129 is old truncate */
|
||||
/* 130 is old ftruncate */
|
||||
/* 129 is old freebsd32_truncate */
|
||||
/* 130 is old freebsd32_ftruncate */
|
||||
#define FREEBSD32_SYS_flock 131
|
||||
#define FREEBSD32_SYS_mkfifo 132
|
||||
#define FREEBSD32_SYS_sendto 133
|
||||
@ -145,7 +145,7 @@
|
||||
#define FREEBSD32_SYS_freebsd32_adjtime 140
|
||||
/* 141 is old getpeername */
|
||||
/* 142 is old gethostid */
|
||||
/* 143 is obsolete sethostid */
|
||||
/* 143 is old freebsd32_sethostid */
|
||||
/* 144 is old getrlimit */
|
||||
/* 145 is old setrlimit */
|
||||
/* 146 is old killpg */
|
||||
|
@ -138,8 +138,8 @@ const char *freebsd32_syscallnames[] = {
|
||||
"setreuid", /* 126 = setreuid */
|
||||
"setregid", /* 127 = setregid */
|
||||
"rename", /* 128 = rename */
|
||||
"compat.truncate", /* 129 = old truncate */
|
||||
"compat.ftruncate", /* 130 = old ftruncate */
|
||||
"compat.freebsd32_truncate", /* 129 = old freebsd32_truncate */
|
||||
"compat.freebsd32_ftruncate", /* 130 = old freebsd32_ftruncate */
|
||||
"flock", /* 131 = flock */
|
||||
"mkfifo", /* 132 = mkfifo */
|
||||
"sendto", /* 133 = sendto */
|
||||
@ -152,7 +152,7 @@ const char *freebsd32_syscallnames[] = {
|
||||
"freebsd32_adjtime", /* 140 = freebsd32_adjtime */
|
||||
"compat.getpeername", /* 141 = old getpeername */
|
||||
"compat.gethostid", /* 142 = old gethostid */
|
||||
"obs_sethostid", /* 143 = obsolete sethostid */
|
||||
"compat.freebsd32_sethostid", /* 143 = old freebsd32_sethostid */
|
||||
"compat.getrlimit", /* 144 = old getrlimit */
|
||||
"compat.setrlimit", /* 145 = old setrlimit */
|
||||
"compat.killpg", /* 146 = old killpg */
|
||||
|
@ -191,8 +191,8 @@ struct sysent freebsd32_sysent[] = {
|
||||
{ .sy_narg = AS(setreuid_args), .sy_call = (sy_call_t *)sys_setreuid, .sy_auevent = AUE_SETREUID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 126 = setreuid */
|
||||
{ .sy_narg = AS(setregid_args), .sy_call = (sy_call_t *)sys_setregid, .sy_auevent = AUE_SETREGID, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 127 = setregid */
|
||||
{ .sy_narg = AS(rename_args), .sy_call = (sy_call_t *)sys_rename, .sy_auevent = AUE_RENAME, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 128 = rename */
|
||||
{ compat(AS(otruncate_args),truncate), .sy_auevent = AUE_TRUNCATE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 129 = old truncate */
|
||||
{ compat(AS(oftruncate_args),ftruncate), .sy_auevent = AUE_FTRUNCATE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 130 = old ftruncate */
|
||||
{ compat(AS(ofreebsd32_truncate_args),freebsd32_truncate), .sy_auevent = AUE_TRUNCATE, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 129 = old freebsd32_truncate */
|
||||
{ compat(AS(ofreebsd32_ftruncate_args),freebsd32_ftruncate), .sy_auevent = AUE_FTRUNCATE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 130 = old freebsd32_ftruncate */
|
||||
{ .sy_narg = AS(flock_args), .sy_call = (sy_call_t *)sys_flock, .sy_auevent = AUE_FLOCK, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 131 = flock */
|
||||
{ .sy_narg = AS(mkfifo_args), .sy_call = (sy_call_t *)sys_mkfifo, .sy_auevent = AUE_MKFIFO, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 132 = mkfifo */
|
||||
{ .sy_narg = AS(sendto_args), .sy_call = (sy_call_t *)sys_sendto, .sy_auevent = AUE_SENDTO, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 133 = sendto */
|
||||
@ -205,7 +205,7 @@ struct sysent freebsd32_sysent[] = {
|
||||
{ .sy_narg = AS(freebsd32_adjtime_args), .sy_call = (sy_call_t *)freebsd32_adjtime, .sy_auevent = AUE_ADJTIME, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 140 = freebsd32_adjtime */
|
||||
{ compat(AS(ogetpeername_args),getpeername), .sy_auevent = AUE_GETPEERNAME, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 141 = old getpeername */
|
||||
{ compat(0,gethostid), .sy_auevent = AUE_SYSCTL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 142 = old gethostid */
|
||||
{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 143 = obsolete sethostid */
|
||||
{ compat(AS(ofreebsd32_sethostid_args),freebsd32_sethostid), .sy_auevent = AUE_SYSCTL, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 143 = old freebsd32_sethostid */
|
||||
{ compat(AS(ogetrlimit_args),getrlimit), .sy_auevent = AUE_GETRLIMIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 144 = old getrlimit */
|
||||
{ compat(AS(osetrlimit_args),setrlimit), .sy_auevent = AUE_SETRLIMIT, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 145 = old setrlimit */
|
||||
{ compat(AS(okillpg_args),killpg), .sy_auevent = AUE_KILLPG, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 146 = old killpg */
|
||||
|
@ -1093,7 +1093,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
|
||||
iarg[0] = p->msqid; /* int */
|
||||
uarg[1] = (intptr_t)p->msgp; /* void * */
|
||||
uarg[2] = p->msgsz; /* size_t */
|
||||
iarg[3] = p->msgtyp; /* long */
|
||||
iarg[3] = p->msgtyp; /* int32_t */
|
||||
iarg[4] = p->msgflg; /* int */
|
||||
*n_args = 5;
|
||||
break;
|
||||
@ -3211,7 +3211,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
|
||||
case 557: {
|
||||
struct getfsstat_args *p = params;
|
||||
uarg[0] = (intptr_t)p->buf; /* struct statfs * */
|
||||
iarg[1] = p->bufsize; /* long */
|
||||
iarg[1] = p->bufsize; /* int32_t */
|
||||
iarg[2] = p->mode; /* int */
|
||||
*n_args = 3;
|
||||
break;
|
||||
@ -5176,7 +5176,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
|
||||
p = "size_t";
|
||||
break;
|
||||
case 3:
|
||||
p = "long";
|
||||
p = "int32_t";
|
||||
break;
|
||||
case 4:
|
||||
p = "int";
|
||||
@ -8865,7 +8865,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
|
||||
p = "userland struct statfs *";
|
||||
break;
|
||||
case 1:
|
||||
p = "long";
|
||||
p = "int32_t";
|
||||
break;
|
||||
case 2:
|
||||
p = "int";
|
||||
|
@ -92,9 +92,9 @@
|
||||
16 AUE_CHOWN NOPROTO { int chown(const char *path, int uid, int gid); }
|
||||
17 AUE_NULL NOPROTO { void *break(char *nsize); }
|
||||
18 AUE_GETFSSTAT COMPAT4 { int freebsd32_getfsstat( \
|
||||
struct ostatfs32 *buf, long bufsize, \
|
||||
struct ostatfs32 *buf, int32_t bufsize, \
|
||||
int mode); }
|
||||
19 AUE_LSEEK COMPAT { int freebsd32_lseek(int fd, int offset, \
|
||||
19 AUE_LSEEK COMPAT { int freebsd32_lseek(int fd, int32_t offset, \
|
||||
int whence); }
|
||||
20 AUE_GETPID NOPROTO { pid_t getpid(void); }
|
||||
21 AUE_MOUNT NOPROTO { int mount(const char *type, \
|
||||
@ -274,9 +274,10 @@
|
||||
127 AUE_SETREGID NOPROTO { int setregid(int rgid, int egid); }
|
||||
128 AUE_RENAME NOPROTO { int rename(const char *from, \
|
||||
const char *to); }
|
||||
129 AUE_TRUNCATE COMPAT|NOPROTO { int truncate(const char *path, \
|
||||
int length); }
|
||||
130 AUE_FTRUNCATE COMPAT|NOPROTO { int ftruncate(int fd, int length); }
|
||||
129 AUE_TRUNCATE COMPAT { int freebsd32_truncate(const char *path, \
|
||||
int32_t length); }
|
||||
130 AUE_FTRUNCATE COMPAT { int freebsd32_ftruncate(int fd, \
|
||||
int32_t length); }
|
||||
131 AUE_FLOCK NOPROTO { int flock(int fd, int how); }
|
||||
132 AUE_MKFIFO NOPROTO { int mkfifo(const char *path, mode_t mode); }
|
||||
133 AUE_SENDTO NOPROTO { int sendto(int s, const void *buf, \
|
||||
@ -298,7 +299,7 @@
|
||||
struct sockaddr *asa, \
|
||||
__socklen_t *alen); }
|
||||
142 AUE_SYSCTL COMPAT|NOPROTO { long gethostid(void); }
|
||||
143 AUE_SYSCTL OBSOL sethostid
|
||||
143 AUE_SYSCTL COMPAT { int freebsd32_sethostid(int32_t hostid); }
|
||||
144 AUE_GETRLIMIT COMPAT|NOPROTO { int getrlimit(u_int which, \
|
||||
struct orlimit *rlp); }
|
||||
145 AUE_SETRLIMIT COMPAT|NOPROTO { int setrlimit(u_int which, \
|
||||
@ -323,7 +324,7 @@
|
||||
; XXX this is a problem!!!
|
||||
155 AUE_NFS_SVC UNIMPL nfssvc
|
||||
156 AUE_GETDIRENTRIES COMPAT { int freebsd32_getdirentries(int fd, \
|
||||
char *buf, u_int count, uint32_t *basep); }
|
||||
char *buf, u_int count, int32_t *basep); }
|
||||
157 AUE_STATFS COMPAT4 { int freebsd32_statfs(const char *path, \
|
||||
struct ostatfs32 *buf); }
|
||||
158 AUE_FSTATFS COMPAT4 { int freebsd32_fstatfs(int fd, \
|
||||
@ -446,7 +447,7 @@
|
||||
226 AUE_MSGSND NOSTD { int freebsd32_msgsnd(int msqid, const void *msgp, \
|
||||
size_t msgsz, int msgflg); }
|
||||
227 AUE_MSGRCV NOSTD { int freebsd32_msgrcv(int msqid, void *msgp, \
|
||||
size_t msgsz, long msgtyp, int msgflg); }
|
||||
size_t msgsz, int32_t msgtyp, int msgflg); }
|
||||
228 AUE_SHMAT NOSTD|NOPROTO { void *shmat(int shmid, const void *shmaddr, \
|
||||
int shmflg); }
|
||||
229 AUE_SHMCTL COMPAT7|NOSTD { int freebsd32_shmctl( \
|
||||
@ -747,7 +748,7 @@
|
||||
394 AUE_NULL UNIMPL mac_syscall
|
||||
395 AUE_GETFSSTAT COMPAT11|NOPROTO { int getfsstat( \
|
||||
struct freebsd11_statfs *buf, \
|
||||
long bufsize, int mode); }
|
||||
int32_t bufsize, int mode); }
|
||||
396 AUE_STATFS COMPAT11|NOPROTO { int statfs(const char *path, \
|
||||
struct statfs *buf); }
|
||||
397 AUE_FSTATFS COMPAT11|NOPROTO { int fstatfs(int fd, \
|
||||
@ -1140,7 +1141,7 @@
|
||||
struct statfs *buf); }
|
||||
556 AUE_FSTATFS NOPROTO { int fstatfs(int fd, struct statfs *buf); }
|
||||
557 AUE_GETFSSTAT NOPROTO { int getfsstat(struct statfs *buf, \
|
||||
long bufsize, int mode); }
|
||||
int32_t bufsize, int mode); }
|
||||
558 AUE_FHSTATFS NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \
|
||||
struct statfs *buf); }
|
||||
#ifdef PAD64_REQUIRED
|
||||
|
Loading…
x
Reference in New Issue
Block a user