From 51504d9ac4b8dbc614a9879d8aa94225c28801db Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 4 Jul 2007 22:47:37 +0000 Subject: [PATCH] Create new syscalls for mmap(), lseek(), pread(), pwrite(), truncate() and ftruncate(), but without the pad arg. There are several reasons for this. Consider 'mmap()'. On AMD64, the function call (and syscall) ABI allow for 6 register arguments. Additional arguments go on the stack. mmap(2) has 6 arguments. However, the syscall definition has an extra 'int pad' argument. This pushes it to 7 arguments, which means one must spill into the memory stack. Since the kernel API doesn't match userland API, we have a hack in libc - libc/sys/mmap.c. This implements the userland API by calling __syscall() with an extra argument and the pad argument, for a total of 8 args. This is all unnecessary and inconvenient for several things, including the kernel's syscall handler code which now has to handle merging stack arguments with register arguments. It is a big deal for certain 3rd party code. I'm adding libc glue to make the transition totally painless. I had intended to mark the old syscalls as COMPAT6, but the potential to shoot your feet by building a new kernel without COMPAT_FREEBSD6 but with a slighly older userland was too great. For now, they have manual "freebsd6_" prefixes rather than being COMPAT6. They will go back to being marked 'COMPAT6' after 7-stable starts. Approved by: re (kensmith) --- sys/kern/syscalls.master | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index dd9e25f6a706..f9c784956fbb 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -334,9 +334,10 @@ int a4); } ; XXX should be { int shmsys(int which, ...); } 172 AUE_NULL UNIMPL nosys -173 AUE_PREAD STD { ssize_t pread(int fd, void *buf, \ +173 AUE_PREAD STD { ssize_t freebsd6_pread(int fd, void *buf, \ size_t nbyte, int pad, off_t offset); } -174 AUE_PWRITE STD { ssize_t pwrite(int fd, const void *buf, \ +174 AUE_PWRITE STD { ssize_t freebsd6_pwrite(int fd, \ + const void *buf, \ size_t nbyte, int pad, off_t offset); } 175 AUE_NULL UNIMPL nosys 176 AUE_NTP_ADJTIME STD { int ntp_adjtime(struct timex *tp); } @@ -367,16 +368,16 @@ __setrlimit_args int 196 AUE_GETDIRENTRIES STD { int getdirentries(int fd, char *buf, \ u_int count, long *basep); } -197 AUE_MMAP STD { caddr_t mmap(caddr_t addr, size_t len, \ - int prot, int flags, int fd, int pad, \ - off_t pos); } +197 AUE_MMAP STD { caddr_t freebsd6_mmap(caddr_t addr, \ + size_t len, int prot, int flags, int fd, \ + int pad, off_t pos); } 198 AUE_NULL STD { int nosys(void); } __syscall \ __syscall_args int -199 AUE_LSEEK STD { off_t lseek(int fd, int pad, off_t offset, \ - int whence); } -200 AUE_TRUNCATE STD { int truncate(char *path, int pad, \ +199 AUE_LSEEK STD { off_t freebsd6_lseek(int fd, int pad, \ + off_t offset, int whence); } +200 AUE_TRUNCATE STD { int freebsd6_truncate(char *path, int pad, \ off_t length); } -201 AUE_FTRUNCATE STD { int ftruncate(int fd, int pad, \ +201 AUE_FTRUNCATE STD { int freebsd6_ftruncate(int fd, int pad, \ off_t length); } 202 AUE_SYSCTL STD { int __sysctl(int *name, u_int namelen, \ void *old, size_t *oldlenp, void *new, \ @@ -835,5 +836,15 @@ 474 AUE_NULL STD { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ struct sockaddr * from, __socklen_t *fromlenaddr, \ struct sctp_sndrcvinfo *sinfo, int *msg_flags); } +475 AUE_PREAD STD { ssize_t pread(int fd, void *buf, \ + size_t nbyte, off_t offset); } +476 AUE_PWRITE STD { ssize_t pwrite(int fd, const void *buf, \ + size_t nbyte, off_t offset); } +477 AUE_MMAP STD { caddr_t mmap(caddr_t addr, size_t len, \ + int prot, int flags, int fd, off_t pos); } +478 AUE_LSEEK STD { off_t lseek(int fd, off_t offset, \ + int whence); } +479 AUE_TRUNCATE STD { int truncate(char *path, off_t length); } +480 AUE_FTRUNCATE STD { int ftruncate(int fd, off_t length); } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master