Port NetBSD libc functions to Minix.

This patch contains changes to NetBSD libc code base to make it
compile and work on Minix. Some of them are due to actual NetBSD
libc bugs, as we're compiling it in non-reentrant mode and with
a.out support, something not exactly frequent in NetBSD.
Others are proper fixes to port it to Minix (mostly sa_len
parameter missing in socket and a few mmap from files).
This commit is contained in:
Gianluca Guida 2011-02-15 12:19:40 +00:00
parent 58153774b1
commit ad4dda469f
62 changed files with 730 additions and 72 deletions

View file

@ -17,6 +17,7 @@
# The Hesiod functions are always in libc. To choose that getpwent() and friends # The Hesiod functions are always in libc. To choose that getpwent() and friends
# actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below. # actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below.
.include "minix-config.inc"
.include "Makefile.inc" .include "Makefile.inc"
LIB= c LIB= c
@ -44,14 +45,14 @@ assym.h: ${ARCHDIR}/genassym.cf
# The following controls how to build compatibility code for old NetBSD # The following controls how to build compatibility code for old NetBSD
# binaries. If BUILDCOLD is yes, then we build a separate library; otherwise # binaries. If BUILDCOLD is yes, then we build a separate library; otherwise
# we include the code in libc. # we include the code in libc.
BUILDCOLD?= no #BUILDCOLD?= no
.if "${BUILDCOLD}" == "yes" #.if "${BUILDCOLD}" == "yes"
SUBDIR=compat #SUBDIR=compat
.include <bsd.subdir.mk> #.include <bsd.subdir.mk>
.else #.else
COMPATDIR=${.CURDIR}/compat #COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/compat/Makefile.inc" #.include "${.CURDIR}/compat/Makefile.inc"
.endif #.endif
.include "${.CURDIR}/../../common/lib/libc/Makefile.inc" .include "${.CURDIR}/../../common/lib/libc/Makefile.inc"
.include "${.CURDIR}/atomic/Makefile.inc" .include "${.CURDIR}/atomic/Makefile.inc"
@ -61,10 +62,11 @@ COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/citrus/Makefile.inc" .include "${.CURDIR}/citrus/Makefile.inc"
.endif .endif
.include "${.CURDIR}/compat-43/Makefile.inc" .include "${.CURDIR}/compat-43/Makefile.inc"
.include "${.CURDIR}/dlfcn/Makefile.inc" #.include "${.CURDIR}/dlfcn/Makefile.inc"
.include "${.CURDIR}/gdtoa/Makefile.inc" .include "${.CURDIR}/gdtoa/Makefile.inc"
.include "${.CURDIR}/gen/Makefile.inc" .include "${.CURDIR}/gen/Makefile.inc"
.include "${.CURDIR}/gmon/Makefile.inc" # gmon needs profil()
#.include "${.CURDIR}/gmon/Makefile.inc"
.include "${.CURDIR}/hash/Makefile.inc" .include "${.CURDIR}/hash/Makefile.inc"
.include "${.CURDIR}/iconv/Makefile.inc" .include "${.CURDIR}/iconv/Makefile.inc"
.include "${.CURDIR}/inet/Makefile.inc" .include "${.CURDIR}/inet/Makefile.inc"
@ -84,7 +86,8 @@ COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/regex/Makefile.inc" .include "${.CURDIR}/regex/Makefile.inc"
.endif .endif
.include "${.CURDIR}/resolv/Makefile.inc" .include "${.CURDIR}/resolv/Makefile.inc"
.include "${.CURDIR}/rpc/Makefile.inc" # RPC needs pollts and a reserved port allocator.
#.include "${.CURDIR}/rpc/Makefile.inc"
.include "${.CURDIR}/ssp/Makefile.inc" .include "${.CURDIR}/ssp/Makefile.inc"
.include "${.CURDIR}/stdio/Makefile.inc" .include "${.CURDIR}/stdio/Makefile.inc"
.include "${.CURDIR}/stdlib/Makefile.inc" .include "${.CURDIR}/stdlib/Makefile.inc"
@ -92,7 +95,7 @@ COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/termios/Makefile.inc" .include "${.CURDIR}/termios/Makefile.inc"
.include "${.CURDIR}/thread-stub/Makefile.inc" .include "${.CURDIR}/thread-stub/Makefile.inc"
.include "${.CURDIR}/time/Makefile.inc" .include "${.CURDIR}/time/Makefile.inc"
.include "${.CURDIR}/sys/Makefile.inc" .include "${.CURDIR}/sys-minix/Makefile.inc"
.include "${.CURDIR}/uuid/Makefile.inc" .include "${.CURDIR}/uuid/Makefile.inc"
.if (${MKYP} != "no") .if (${MKYP} != "no")
.include "${.CURDIR}/yp/Makefile.inc" .include "${.CURDIR}/yp/Makefile.inc"

View file

@ -19,14 +19,17 @@
USE_FORT?= yes USE_FORT?= yes
USE_SHLIBDIR= yes USE_SHLIBDIR= no
CITRUS?= yes CITRUS?= yes
USE_LIBTRE= no
NETBSDSRCDIR= ${MINIXSRCDIR}
.include <bsd.own.mk> .include <bsd.own.mk>
WARNS=4 WARNS=4
CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS #-D_REENTRANT
.if (${USE_HESIOD} != "no") .if (${USE_HESIOD} != "no")
CPPFLAGS+= -DHESIOD CPPFLAGS+= -DHESIOD

View file

@ -1,3 +1,3 @@
# $NetBSD: Makefile.inc,v 1.20 2006/06/17 18:04:23 uwe Exp $ # $NetBSD: Makefile.inc,v 1.20 2006/06/17 18:04:23 uwe Exp $
SRCS+= __sigaction14_sigtramp.c __sigtramp2.S #SRCS+= __sigaction14_sigtramp.c __sigtramp2.S

View file

@ -7,10 +7,13 @@ SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S \
SRCS+= setjmp.S _setjmp.S sigsetjmp.S SRCS+= setjmp.S _setjmp.S sigsetjmp.S
SRCS+= resumecontext.S swapcontext.S # Already defined in sys-minix /* __minix */
#SRCS+= resumecontext.S swapcontext.S
# objects built from C sources # objects built from C sources
SRCS+= bswap64.c _lwp.c makecontext.c #SRCS+= bswap64.c _lwp.c makecontext.c
# __minix
SRCS+= bswap64.c
# Common ieee754 constants and functions # Common ieee754 constants and functions
SRCS+= infinityf_ieee754.c infinity_ieee754.c SRCS+= infinityf_ieee754.c infinity_ieee754.c

View file

@ -122,7 +122,22 @@ cdbr_open(const char *path, int flags)
cdbr->index_size = 4; cdbr->index_size = 4;
cdbr->mmap_size = (size_t)sb.st_size; cdbr->mmap_size = (size_t)sb.st_size;
#ifdef __minix
cdbr->mmap_base = mmap(NULL, cdbr->mmap_size, PROT_READ, MAP_ANON, -1, (off_t)0);
if (cdbr->mmap_base == MAP_FAILED) {
free(cdbr);
return NULL;
}
if (read(fd, cdbr->mmap_base, cdbr->mmap_size) != cdbr->mmap_size)
{
munmap(cdbr->mmap_base, cdbr->mmap_size);
free(cdbr);
return NULL;
}
#else /* !__minix */
cdbr->mmap_base = mmap(NULL, cdbr->mmap_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0); cdbr->mmap_base = mmap(NULL, cdbr->mmap_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0);
#endif /* __minix */
close(fd); close(fd);
if (cdbr->mmap_base == MAP_FAILED) { if (cdbr->mmap_base == MAP_FAILED) {

View file

@ -74,12 +74,25 @@ _citrus_map_file(struct _citrus_region * __restrict r,
goto error; goto error;
} }
#ifdef __minix
head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_ANON, -1, (off_t)0);
if (head == MAP_FAILED) {
ret = errno;
goto error;
}
if (read(fd, head, st.st_size) != st.st_size) {
ret = errno;
goto error;
}
#else /* !__minix */
head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE,
fd, (off_t)0); fd, (off_t)0);
if (head == MAP_FAILED) { if (head == MAP_FAILED) {
ret = errno; ret = errno;
goto error; goto error;
} }
#endif /* !__minix */
_region_init(r, head, (size_t)st.st_size); _region_init(r, head, (size_t)st.st_size);
error: error:

View file

@ -4,9 +4,12 @@
# compat-43 sources # compat-43 sources
.PATH: ${ARCHDIR}/compat-43 ${.CURDIR}/compat-43 .PATH: ${ARCHDIR}/compat-43 ${.CURDIR}/compat-43
SRCS+= creat.c getdtablesize.c gethostid.c \ # unsupported by Minix
killpg.c sethostid.c setpgrp.c \ # gethostid.c sethostid.c setpgrp.c setrgid.c setruid.c sigcompat.c
setrgid.c setruid.c sigcompat.c
SRCS+= creat.c getdtablesize.c \
killpg.c \
.if !defined(AUDIT) .if !defined(AUDIT)
SRCS+= getwd.c SRCS+= getwd.c
.endif .endif

View file

@ -57,9 +57,15 @@ dbopen(const char *fname, int flags, mode_t mode, DBTYPE type,
{ {
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) #define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
#ifdef __minix
#define USE_OPEN_FLAGS \
(O_CREAT | O_EXCL | O_NONBLOCK | O_RDONLY | \
O_RDWR | O_TRUNC)
#else /* !__minix */
#define USE_OPEN_FLAGS \ #define USE_OPEN_FLAGS \
(O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \ (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \
O_RDWR | O_SHLOCK | O_TRUNC) O_RDWR | O_SHLOCK | O_TRUNC)
#endif /* __minix */
if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
switch (type) { switch (type) {

View file

@ -7,4 +7,6 @@
#include "gdtoaimp.h" #include "gdtoaimp.h"
#ifdef _REENTRANT /* !__minix */
mutex_t __gdtoa_locks[2] = { MUTEX_INITIALIZER, MUTEX_INITIALIZER }; mutex_t __gdtoa_locks[2] = { MUTEX_INITIALIZER, MUTEX_INITIALIZER };
#endif /* _REENTRANT */

View file

@ -2,36 +2,51 @@
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources # gen sources
.PATH: ${ARCHDIR}/gen ${.CURDIR}/gen .PATH: ${.CURDIR}/gen/minix ${ARCHDIR}/gen ${.CURDIR}/gen
# Unsupported by Minix.
# closefrom.c confstr.c extattr.c getdevmajor.c getmntinfo.c \
# pthread_atfork.c setdomainname.c sethostname.c setproctitle.c \
# sysctl.c sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c \
# devname.c wait3.c
# To be ported
# nlist.c nlist_aout.c nlist_coff.c nlist_ecoff.c nlist_elf32.c nlist_elf64.c
#
# Not useful but portable
# disklabel.c
#
# Already in getprogname
# setprogname.c
SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \ SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \
closedir.c closefrom.c confstr.c ctermid.c ctype_.c daemon.c \ closedir.c ctermid.c ctype_.c daemon.c \
dehumanize_number.c devname.c dirname.c disklabel.c err.c errx.c \ dehumanize_number.c dirname.c err.c errx.c \
errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \ errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
extattr.c fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \ fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \
fts.c ftw.c getbsize.c getcap.c getcwd.c \ fts.c ftw.c getbsize.c getcap.c getcwd.c \
getdevmajor.c getdomainname.c getgrent.c \ getdomainname.c getgrent.c \
getgrouplist.c getgroupmembership.c gethostname.c \ getgrouplist.c getgroupmembership.c gethostname.c \
getloadavg.c getlogin.c getmntinfo.c \ getloadavg.c getlogin.c \
getnetgrent.c getpagesize.c \ getnetgrent.c getpagesize.c \
getpass.c getprogname.c getpwent.c getttyent.c \ getpass.c getprogname.c getpwent.c getttyent.c \
getusershell.c glob.c humanize_number.c initdir.c initgroups.c \ getusershell.c glob.c humanize_number.c initdir.c initgroups.c \
isascii.c isatty.c isctype.c lockf.c nftw.c \ isascii.c isatty.c isctype.c lockf.c nftw.c \
nice.c nlist.c nlist_aout.c \ nice.c \
nlist_coff.c nlist_ecoff.c nlist_elf32.c nlist_elf64.c opendir.c \ opendir.c \
pause.c popen.c psignal.c pthread_atfork.c ptree.c pwcache.c \ pause.c popen.c psignal.c ptree.c pwcache.c \
pw_scan.c raise.c randomid.c rb.c readdir.c rewinddir.c \ pw_scan.c raise.c randomid.c rb.c readdir.c rewinddir.c \
scandir.c seekdir.c setdomainname.c \ scandir.c seekdir.c \
sethostname.c setjmperr.c setmode.c setproctitle.c setprogname.c \ setjmperr.c setmode.c \
shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \ shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \
siglist.c signal.c signame.c sigrelse.c \ siglist.c signal.c signame.c sigrelse.c \
sigset.c sigsetops.c sleep.c \ sigset.c sigsetops.c sleep.c \
stringlist.c sysconf.c sysctl.c sysctlbyname.c sysctlgetmibinfo.c \ stringlist.c sysconf.c \
sysctlnametomib.c syslog.c telldir.c time.c \ syslog.c telldir.c time.c \
times.c toascii.c tolower_.c ttyname.c ttyslot.c \ times.c toascii.c tolower_.c ttyname.c ttyslot.c \
toupper_.c ualarm.c ulimit.c uname.c unvis.c usleep.c utime.c utmp.c \ toupper_.c ualarm.c ulimit.c uname.c unvis.c usleep.c utime.c utmp.c \
utmpx.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c \ utmpx.c valloc.c vis.c warn.c warnx.c \
vwarn.c vwarnx.c verr.c verrx.c wordexp.c vwarn.c vwarnx.c verr.c verrx.c wait.c waitpid.c wordexp.c
# indirect reference stubs, to be removed soon. # indirect reference stubs, to be removed soon.
SRCS+= _err.c _errx.c \ SRCS+= _err.c _errx.c \
@ -163,7 +178,7 @@ CPPFLAGS.isctype.c+= -I${LIBCDIR}/locale
CPPFLAGS.tolower_.c+= -I${LIBCDIR}/locale CPPFLAGS.tolower_.c+= -I${LIBCDIR}/locale
CPPFLAGS.toupper_.c+= -I${LIBCDIR}/locale CPPFLAGS.toupper_.c+= -I${LIBCDIR}/locale
errlist.c: errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h errlist.c: errlist-minix.awk ${NETBSDSRCDIR}/nbsd_include/sys/errno.h
${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}
CLEANFILES+= errlist.c CLEANFILES+= errlist.c

View file

@ -13,6 +13,7 @@ __RCSID("$NetBSD: _verr.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
#if defined(__indr_reference) #if defined(__indr_reference)
__indr_reference(_verr, verr) __indr_reference(_verr, verr)
#else #else
#include <sys/ansi.h>
__dead void _verr(int, const char *, _BSD_VA_LIST_); __dead void _verr(int, const char *, _BSD_VA_LIST_);

View file

@ -13,6 +13,7 @@ __RCSID("$NetBSD: _verrx.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
#if defined(__indr_reference) #if defined(__indr_reference)
__indr_reference(_verrx, verrx) __indr_reference(_verrx, verrx)
#else #else
#include <sys/ansi.h>
__dead void _verrx(int, const char *, _BSD_VA_LIST_); __dead void _verrx(int, const char *, _BSD_VA_LIST_);

View file

@ -13,6 +13,7 @@ __RCSID("$NetBSD: _vwarn.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
#if defined(__indr_reference) #if defined(__indr_reference)
__indr_reference(_vwarn, vwarn) __indr_reference(_vwarn, vwarn)
#else #else
#include <stdarg.h>
void _vwarn(const char *, _BSD_VA_LIST_); void _vwarn(const char *, _BSD_VA_LIST_);

View file

@ -13,6 +13,7 @@ __RCSID("$NetBSD: _vwarnx.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
#if defined(__indr_reference) #if defined(__indr_reference)
__indr_reference(_vwarnx, vwarnx) __indr_reference(_vwarnx, vwarnx)
#else #else
#include <stdarg.h>
void _vwarnx(const char *, _BSD_VA_LIST_); void _vwarnx(const char *, _BSD_VA_LIST_);

View file

@ -13,7 +13,6 @@ __RCSID("$NetBSD: _warn.c,v 1.10 2005/09/13 01:44:09 christos Exp $");
#if defined(__indr_reference) #if defined(__indr_reference)
__indr_reference(_warn, warn) __indr_reference(_warn, warn)
#else #else
#include <stdarg.h> #include <stdarg.h>
void _vwarn(const char *, _BSD_VA_LIST_); void _vwarn(const char *, _BSD_VA_LIST_);
@ -24,7 +23,7 @@ warn(const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
_vwarn(eval, fmt, ap); _vwarn(fmt, ap);
va_end(ap); va_end(ap);
} }
#endif #endif

View file

@ -24,7 +24,7 @@ warnx(const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
_vwarnx(eval, fmt, ap); _vwarnx(fmt, ap);
va_end(ap); va_end(ap);
} }

View file

@ -38,6 +38,11 @@ __RCSID("$NetBSD: closedir.c,v 1.16 2010/09/26 02:26:59 yamt Exp $");
#endif #endif
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#ifdef __minix
/* NetBSD BUG: reentrant.h defines includes. */
#include <sys/types.h>
#endif /* !__minix */
#include "namespace.h" #include "namespace.h"
#include "reentrant.h" #include "reentrant.h"
#include "extern.h" #include "extern.h"

View file

@ -0,0 +1,113 @@
#! /usr/bin/awk -f
# $NetBSD: errlist.awk,v 1.4 2010/12/16 22:52:32 joerg Exp $
#
# Copyright (c) 2010 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Christos Zoulas.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
function tabs(desc) {
l = length(desc) + 3;
if (concat)
l++
if (l < 16)
return "\t\t\t\t";
else if (l < 24)
return "\t\t\t";
else if (l < 32)
return "\t\t";
else if (l < 40)
return "\t";
else
return "";
}
function perror(name, number, desc)
{
if (!concat) {
printf("\t[%d] = \"%s\",%s/* %d - %s */\n", number, desc, tabs(desc), number, name);
} else {
offsets[number] = offset;
offset += length(desc) + 1;
printf("\t[%d] = \"%s\\0\"%s/* %d - %s */\n", number, desc, tabs(desc), number, name);
}
}
BEGIN {
printf("/* Automatically generated file; do not edit */\n");
printf("#include <sys/cdefs.h>\n");
printf("__RCSID(\"$NetBSD: errlist.awk,v 1.4 2010/12/16 22:52:32 joerg Exp $\");\n");
printf("#include <errno.h>\n");
if (!concat) {
printf("static const char *const errlist[] = {\n");
} else {
printf("static const char concat_errlist[] = {\n");
offset = 0;
}
perror("ENOERROR", 0, "Undefined error: 0");
errno = 1;
}
/^#define/ {
name = $2;
if (name == "ELAST")
next;
number = $4;
if (number < 0 || number == "EAGAIN")
next;
desc = $0;
i1 = index(desc, "/*") + 3;
l = length(desc);
desc = substr(desc, i1, l - i1 - 2);
# if (number != errno) {
# printf("error number mismatch %d != %d\n", number, errno) > "/dev/stderr";
# exit(1);
# }
perror(name, number, desc);
errno=number;
}
END {
printf("};\n\n");
if (!concat) {
printf("const int sys_nerr = sizeof(errlist) / sizeof(errlist[0]);\n");
printf("const char * const *sys_errlist = errlist;\n");
} else {
printf("static const int concat_nerr = %d;\n", errno);
printf("static const unsigned short concat_offset[] = {\n");
offsets[errno++] = offset;
for (j = 0; j < errno; j++) {
printf("\t%d,\n", offsets[j]);
}
printf("};\n");
if (offset > 65535) {
printf("Total errlist size doesn't fit into 16bit\n") > "/dev/stderr";
exit(1);
}
}
}

View file

@ -56,8 +56,10 @@ __RCSID("$NetBSD: fts.c,v 1.40 2009/11/02 17:17:34 stacktic Exp $");
#include <unistd.h> #include <unistd.h>
#if ! HAVE_NBTOOL_CONFIG_H #if ! HAVE_NBTOOL_CONFIG_H
#ifndef __minix
#define HAVE_STRUCT_DIRENT_D_NAMLEN #define HAVE_STRUCT_DIRENT_D_NAMLEN
#endif #endif
#endif
static FTSENT *fts_alloc(FTS *, const char *, size_t); static FTSENT *fts_alloc(FTS *, const char *, size_t);
static FTSENT *fts_build(FTS *, int); static FTSENT *fts_build(FTS *, int);

View file

@ -481,7 +481,11 @@ static int
_files_getgrgid(void *nsrv, void *nscb, va_list ap) _files_getgrgid(void *nsrv, void *nscb, va_list ap)
{ {
struct group **retval = va_arg(ap, struct group **); struct group **retval = va_arg(ap, struct group **);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
int rv, rerror; int rv, rerror;
@ -506,7 +510,11 @@ static int
_files_getgrgid_r(void *nsrv, void *nscb, va_list ap) _files_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
struct group *grp = va_arg(ap, struct group *); struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -801,8 +809,11 @@ static int
_dns_getgrgid(void *nsrv, void *nscb, va_list ap) _dns_getgrgid(void *nsrv, void *nscb, va_list ap)
{ {
struct group **retval = va_arg(ap, struct group **); struct group **retval = va_arg(ap, struct group **);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
int rv, rerror; int rv, rerror;
_DIAGASSERT(retval != NULL); _DIAGASSERT(retval != NULL);
@ -825,7 +836,11 @@ static int
_dns_getgrgid_r(void *nsrv, void *nscb, va_list ap) _dns_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
struct group *grp = va_arg(ap, struct group *); struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -1148,8 +1163,11 @@ static int
_nis_getgrgid(void *nsrv, void *nscb, va_list ap) _nis_getgrgid(void *nsrv, void *nscb, va_list ap)
{ {
struct group **retval = va_arg(ap, struct group **); struct group **retval = va_arg(ap, struct group **);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
int rv, rerror; int rv, rerror;
_DIAGASSERT(retval != NULL); _DIAGASSERT(retval != NULL);
@ -1172,7 +1190,11 @@ static int
_nis_getgrgid_r(void *nsrv, void *nscb, va_list ap) _nis_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
struct group *grp = va_arg(ap, struct group *); struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -1408,7 +1430,7 @@ __grscan_compat(int *retval, struct group *grp, char *buffer, size_t buflen,
crv = nsdispatch(NULL, compatgiddtab, crv = nsdispatch(NULL, compatgiddtab,
NSDB_GROUP_COMPAT, "getgrgid_r", NSDB_GROUP_COMPAT, "getgrgid_r",
__nsdefaultnis, __nsdefaultnis,
&cretval, gid, &cretval, (int)gid,
&cgrp, filebuf, sizeof(filebuf), &cgrpres); &cgrp, filebuf, sizeof(filebuf), &cgrpres);
} }
if (crv != NS_SUCCESS) { /* not found */ if (crv != NS_SUCCESS) { /* not found */
@ -1610,7 +1632,7 @@ static int
_compat_getgrgid(void *nsrv, void *nscb, va_list ap) _compat_getgrgid(void *nsrv, void *nscb, va_list ap)
{ {
struct group **retval = va_arg(ap, struct group **); struct group **retval = va_arg(ap, struct group **);
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, int);
int rv, rerror; int rv, rerror;
@ -1635,7 +1657,11 @@ static int
_compat_getgrgid_r(void *nsrv, void *nscb, va_list ap) _compat_getgrgid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
gid_t gid = (gid_t)va_arg(ap, int);
#else
gid_t gid = va_arg(ap, gid_t); gid_t gid = va_arg(ap, gid_t);
#endif
struct group *grp = va_arg(ap, struct group *); struct group *grp = va_arg(ap, struct group *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -1733,7 +1759,6 @@ getgrent(void)
NS_COMPAT_CB(_compat_getgrent, NULL) NS_COMPAT_CB(_compat_getgrent, NULL)
NS_NULL_CB NS_NULL_CB
}; };
mutex_lock(&__grmutex); mutex_lock(&__grmutex);
rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent", __nsdefaultcompat, rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent", __nsdefaultcompat,
&retval); &retval);
@ -1785,7 +1810,7 @@ getgrgid(gid_t gid)
mutex_lock(&__grmutex); mutex_lock(&__grmutex);
rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid", __nsdefaultcompat, rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid", __nsdefaultcompat,
&retval, gid); &retval, (int)gid);
mutex_unlock(&__grmutex); mutex_unlock(&__grmutex);
return (rv == NS_SUCCESS) ? retval : NULL; return (rv == NS_SUCCESS) ? retval : NULL;
} }
@ -1812,7 +1837,7 @@ getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t buflen,
retval = 0; retval = 0;
mutex_lock(&__grmutex); mutex_lock(&__grmutex);
rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", __nsdefaultcompat, rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", __nsdefaultcompat,
&retval, gid, grp, buffer, buflen, result); &retval, (int)gid, grp, buffer, buflen, result);
mutex_unlock(&__grmutex); mutex_unlock(&__grmutex);
switch (rv) { switch (rv) {
case NS_SUCCESS: case NS_SUCCESS:

View file

@ -101,7 +101,11 @@ _files_getgroupmembership(void *retval, void *cb_data, va_list ap)
{ {
int *result = va_arg(ap, int *); int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *); const char *uname = va_arg(ap, const char *);
#ifdef __minix
gid_t agroup = (gid_t)va_arg(ap, int);
#else
gid_t agroup = va_arg(ap, gid_t); gid_t agroup = va_arg(ap, gid_t);
#endif
gid_t *groups = va_arg(ap, gid_t *); gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int); int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *); int *groupc = va_arg(ap, int *);
@ -144,7 +148,11 @@ _dns_getgroupmembership(void *retval, void *cb_data, va_list ap)
{ {
int *result = va_arg(ap, int *); int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *); const char *uname = va_arg(ap, const char *);
#ifdef __minix
gid_t agroup = (gid_t)va_arg(ap, int);
#else
gid_t agroup = va_arg(ap, gid_t); gid_t agroup = va_arg(ap, gid_t);
#endif
gid_t *groups = va_arg(ap, gid_t *); gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int); int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *); int *groupc = va_arg(ap, int *);
@ -237,7 +245,11 @@ _nis_getgroupmembership(void *retval, void *cb_data, va_list ap)
{ {
int *result = va_arg(ap, int *); int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *); const char *uname = va_arg(ap, const char *);
#ifdef __minix
gid_t agroup = (gid_t)va_arg(ap, int);
#else
gid_t agroup = va_arg(ap, gid_t); gid_t agroup = va_arg(ap, gid_t);
#endif
gid_t *groups = va_arg(ap, gid_t *); gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int); int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *); int *groupc = va_arg(ap, int *);
@ -305,8 +317,12 @@ _compat_ggm_search(void *cookie, struct group **groupres)
crv = nsdispatch(NULL, dtab, crv = nsdispatch(NULL, dtab,
NSDB_GROUP_COMPAT, "getgroupmembership", NSDB_GROUP_COMPAT, "getgroupmembership",
__nsdefaultnis, __nsdefaultnis,
#ifdef __minix
&rerror, cp->uname, (int)cp->agroup, cp->groups, cp->maxgrp, cp->groupc);
#else
&rerror, cp->uname, cp->agroup, cp->groups, cp->maxgrp, cp->groupc); &rerror, cp->uname, cp->agroup, cp->groups, cp->maxgrp, cp->groupc);
#endif
if (crv == NS_SUCCESS) if (crv == NS_SUCCESS)
crv = NS_NOTFOUND; /* indicate "no more +: entries" */ crv = NS_NOTFOUND; /* indicate "no more +: entries" */
@ -319,7 +335,11 @@ _compat_getgroupmembership(void *retval, void *cb_data, va_list ap)
{ {
int *result = va_arg(ap, int *); int *result = va_arg(ap, int *);
const char *uname = va_arg(ap, const char *); const char *uname = va_arg(ap, const char *);
#ifdef __minix
gid_t agroup = (gid_t)va_arg(ap, int);
#else
gid_t agroup = va_arg(ap, gid_t); gid_t agroup = va_arg(ap, gid_t);
#endif
gid_t *groups = va_arg(ap, gid_t *); gid_t *groups = va_arg(ap, gid_t *);
int maxgrp = va_arg(ap, int); int maxgrp = va_arg(ap, int);
int *groupc = va_arg(ap, int *); int *groupc = va_arg(ap, int *);
@ -395,7 +415,11 @@ getgroupmembership(const char *uname, gid_t agroup,
*/ */
(void) nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership", (void) nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership",
__nsdefaultcompat, __nsdefaultcompat,
#ifdef __minix
&rerror, uname, (int)agroup, groups, maxgrp, groupc);
#else
&rerror, uname, agroup, groups, maxgrp, groupc); &rerror, uname, agroup, groups, maxgrp, groupc);
#endif
mutex_unlock(&__grmutex); mutex_unlock(&__grmutex);
if (*groupc > maxgrp) /* too many groups found */ if (*groupc > maxgrp) /* too many groups found */

View file

@ -78,7 +78,9 @@ __RCSID("$NetBSD: getlogin.c,v 1.15 2009/01/11 02:46:27 christos Exp $");
#ifdef __weak_alias #ifdef __weak_alias
__weak_alias(getlogin,_getlogin) __weak_alias(getlogin,_getlogin)
__weak_alias(getlogin_r,_getlogin_r) __weak_alias(getlogin_r,_getlogin_r)
#ifndef __minix
__weak_alias(setlogin,_setlogin) __weak_alias(setlogin,_setlogin)
#endif /* !__minix */
#endif #endif
int __logname_valid; /* known to setlogin() */ int __logname_valid; /* known to setlogin() */
@ -134,6 +136,7 @@ getlogin_r(char *name, size_t namelen)
return (rv); return (rv);
} }
#ifndef __minix
int int
setlogin(const char *name) setlogin(const char *name)
{ {
@ -144,3 +147,4 @@ setlogin(const char *name)
return (retval); return (retval);
} }
#endif

View file

@ -671,7 +671,11 @@ static int
_files_getpwuid(void *nsrv, void *nscb, va_list ap) _files_getpwuid(void *nsrv, void *nscb, va_list ap)
{ {
struct passwd **retval = va_arg(ap, struct passwd **); struct passwd **retval = va_arg(ap, struct passwd **);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
int rv, rerror; int rv, rerror;
@ -696,7 +700,11 @@ static int
_files_getpwuid_r(void *nsrv, void *nscb, va_list ap) _files_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
struct passwd *pw = va_arg(ap, struct passwd *); struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -992,7 +1000,11 @@ static int
_dns_getpwuid(void *nsrv, void *nscb, va_list ap) _dns_getpwuid(void *nsrv, void *nscb, va_list ap)
{ {
struct passwd **retval = va_arg(ap, struct passwd **); struct passwd **retval = va_arg(ap, struct passwd **);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
int rv, rerror; int rv, rerror;
@ -1019,7 +1031,11 @@ static int
_dns_getpwuid_r(void *nsrv, void *nscb, va_list ap) _dns_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
struct passwd *pw = va_arg(ap, struct passwd *); struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -1508,7 +1524,11 @@ static int
_nis_getpwuid(void *nsrv, void *nscb, va_list ap) _nis_getpwuid(void *nsrv, void *nscb, va_list ap)
{ {
struct passwd **retval = va_arg(ap, struct passwd **); struct passwd **retval = va_arg(ap, struct passwd **);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
int rv, rerror; int rv, rerror;
@ -1534,7 +1554,11 @@ static int
_nis_getpwuid_r(void *nsrv, void *nscb, va_list ap) _nis_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
struct passwd *pw = va_arg(ap, struct passwd *); struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -1896,9 +1920,16 @@ _passwdcompat_pwscan(struct passwd *pw, char *buffer, size_t buflen,
&crv, name, pw, buffer, buflen, &cpw); &crv, name, pw, buffer, buflen, &cpw);
break; break;
case _PW_KEYBYUID: case _PW_KEYBYUID:
#ifdef __minix
rv = nsdispatch(NULL, compatuiddtab,
NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis,
&crv, (int)uid, pw, buffer, buflen, &cpw);
#else
rv = nsdispatch(NULL, compatuiddtab, rv = nsdispatch(NULL, compatuiddtab,
NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis, NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis,
&crv, uid, pw, buffer, buflen, &cpw); &crv, uid, pw, buffer, buflen, &cpw);
#endif
break; break;
default: default:
abort(); abort();
@ -2301,7 +2332,11 @@ static int
_compat_getpwuid(void *nsrv, void *nscb, va_list ap) _compat_getpwuid(void *nsrv, void *nscb, va_list ap)
{ {
struct passwd **retval = va_arg(ap, struct passwd **); struct passwd **retval = va_arg(ap, struct passwd **);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
int rv, rerror; int rv, rerror;
@ -2326,7 +2361,11 @@ static int
_compat_getpwuid_r(void *nsrv, void *nscb, va_list ap) _compat_getpwuid_r(void *nsrv, void *nscb, va_list ap)
{ {
int *retval = va_arg(ap, int *); int *retval = va_arg(ap, int *);
#ifdef __minix
uid_t uid = (uid_t)va_arg(ap, int);
#else
uid_t uid = va_arg(ap, uid_t); uid_t uid = va_arg(ap, uid_t);
#endif
struct passwd *pw = va_arg(ap, struct passwd *); struct passwd *pw = va_arg(ap, struct passwd *);
char *buffer = va_arg(ap, char *); char *buffer = va_arg(ap, char *);
size_t buflen = va_arg(ap, size_t); size_t buflen = va_arg(ap, size_t);
@ -2482,8 +2521,13 @@ getpwuid(uid_t uid)
}; };
mutex_lock(&_pwmutex); mutex_lock(&_pwmutex);
#ifdef __minix
rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat,
&retval, (int)uid);
#else
rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat, rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat,
&retval, uid); &retval, uid);
#endif
mutex_unlock(&_pwmutex); mutex_unlock(&_pwmutex);
return (rv == NS_SUCCESS) ? retval : NULL; return (rv == NS_SUCCESS) ? retval : NULL;
} }
@ -2509,8 +2553,14 @@ getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t buflen,
*result = NULL; *result = NULL;
retval = 0; retval = 0;
mutex_lock(&_pwmutex); mutex_lock(&_pwmutex);
#ifdef __minix
r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat,
&retval, (int)uid, pwd, buffer, buflen, result);
#else
r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat, r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat,
&retval, uid, pwd, buffer, buflen, result); &retval, uid, pwd, buffer, buflen, result);
#endif
mutex_unlock(&_pwmutex); mutex_unlock(&_pwmutex);
switch (r) { switch (r) {
case NS_SUCCESS: case NS_SUCCESS:

View file

@ -39,13 +39,13 @@
#define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */ #define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */
#ifndef __minix /* should be _REENTRANT */
/* /*
* mutex to serialize the public group(5) functions use of the * mutex to serialize the public group(5) functions use of the
* back-end implementations, which may not be reentrant. * back-end implementations, which may not be reentrant.
*/ */
extern mutex_t __grmutex; extern mutex_t __grmutex;
#endif
/* /*
* files methods * files methods
*/ */

View file

@ -34,7 +34,16 @@
__RCSID("$NetBSD: initdir.c,v 1.1 2010/09/26 02:26:59 yamt Exp $"); __RCSID("$NetBSD: initdir.c,v 1.1 2010/09/26 02:26:59 yamt Exp $");
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include "namespace.h" #include "namespace.h"
#ifdef __minix
/* NetBSD BUG on !_REENTRANT */
#include <sys/cdefs.h>
#include <sys/types.h>
#endif
#include "reentrant.h" #include "reentrant.h"
#include "extern.h" #include "extern.h"
@ -221,9 +230,11 @@ retry:
xp = dp; xp = dp;
else else
dp->d_fileno = 0; dp->d_fileno = 0;
#ifndef __minix
if (dp->d_type == DT_WHT && if (dp->d_type == DT_WHT &&
(flags & DTF_HIDEW)) (flags & DTF_HIDEW))
dp->d_fileno = 0; dp->d_fileno = 0;
#endif
} }
free(dpv); free(dpv);

View file

@ -40,6 +40,12 @@ __RCSID("$NetBSD: opendir.c,v 1.37 2010/09/26 02:26:59 yamt Exp $");
#include "namespace.h" #include "namespace.h"
#include "reentrant.h" #include "reentrant.h"
#ifdef __minix
#include <sys/cdefs.h>
#include <sys/types.h>
#endif
#include "extern.h" #include "extern.h"
#include <sys/param.h> #include <sys/param.h>
@ -122,6 +128,12 @@ __opendir_common(int fd, const char *name, int flags)
* Tweak flags for the underlying filesystem. * Tweak flags for the underlying filesystem.
*/ */
#ifdef __minix
if (fstatvfs(fd, &sfb) < 0)
goto error;
/* MOUNT_UNION and MOUNT_NFS not supported */
flags &= ~DTF_NODUP;
#else
if (fstatvfs1(fd, &sfb, ST_NOWAIT) < 0) if (fstatvfs1(fd, &sfb, ST_NOWAIT) < 0)
goto error; goto error;
if ((flags & DTF_NODUP) != 0) { if ((flags & DTF_NODUP) != 0) {
@ -136,6 +148,7 @@ __opendir_common(int fd, const char *name, int flags)
if (!strncmp(sfb.f_fstypename, MOUNT_NFS, sizeof(sfb.f_fstypename))) { if (!strncmp(sfb.f_fstypename, MOUNT_NFS, sizeof(sfb.f_fstypename))) {
flags |= __DTF_READALL | __DTF_RETRY_ON_BADCOOKIE; flags |= __DTF_READALL | __DTF_RETRY_ON_BADCOOKIE;
} }
#endif
dirp->dd_flags = flags; dirp->dd_flags = flags;
error = _initdir(dirp, fd, name); error = _initdir(dirp, fd, name);

View file

@ -40,7 +40,14 @@ __RCSID("$NetBSD: readdir.c,v 1.25 2010/09/16 02:38:50 yamt Exp $");
#include "namespace.h" #include "namespace.h"
#include "reentrant.h" #include "reentrant.h"
#ifdef __minix
#include <sys/cdefs.h>
#include <sys/types.h>
#endif
#include "extern.h" #include "extern.h"
#include <sys/param.h> #include <sys/param.h>
#include <dirent.h> #include <dirent.h>
@ -81,8 +88,10 @@ _readdir_unlocked(DIR *dirp, int skipdeleted)
dirp->dd_loc += dp->d_reclen; dirp->dd_loc += dp->d_reclen;
if (dp->d_ino == 0 && skipdeleted) if (dp->d_ino == 0 && skipdeleted)
continue; continue;
#ifndef __minix
if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW)) if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW))
continue; continue;
#endif
return (dp); return (dp);
} }
} }

View file

@ -40,6 +40,11 @@ __RCSID("$NetBSD: rewinddir.c,v 1.13 2010/09/26 02:26:59 yamt Exp $");
#include "namespace.h" #include "namespace.h"
#include "reentrant.h" #include "reentrant.h"
#ifdef __minix
#include <sys/types.h>
#endif
#include "extern.h" #include "extern.h"
#include <sys/types.h> #include <sys/types.h>

View file

@ -130,9 +130,13 @@ scandir(const char *dirname, struct dirent ***namelist,
goto bad2; goto bad2;
p->d_fileno = d->d_fileno; p->d_fileno = d->d_fileno;
p->d_reclen = d->d_reclen; p->d_reclen = d->d_reclen;
#ifndef __minix
p->d_type = d->d_type; p->d_type = d->d_type;
p->d_namlen = d->d_namlen; p->d_namlen = d->d_namlen;
(void)memmove(p->d_name, d->d_name, (size_t)(p->d_namlen + 1)); (void)memmove(p->d_name, d->d_name, (size_t)(p->d_namlen + 1));
#else
(void)memmove(p->d_name, d->d_name, (size_t)(strlen(d->d_name) + 1));
#endif
names[nitems++] = p; names[nitems++] = p;
} }
(void)closedir(dirp); (void)closedir(dirp);

View file

@ -40,6 +40,9 @@ __RCSID("$NetBSD: seekdir.c,v 1.14 2006/05/17 20:36:50 christos Exp $");
#include "namespace.h" #include "namespace.h"
#include "reentrant.h" #include "reentrant.h"
#ifdef __minix
#include <sys/types.h>
#endif
#include "extern.h" #include "extern.h"
#include <sys/param.h> #include <sys/param.h>

View file

@ -492,7 +492,9 @@ connectlog_r(struct syslog_data *data)
/* AF_UNIX address of local logger */ /* AF_UNIX address of local logger */
static const struct sockaddr_un sun = { static const struct sockaddr_un sun = {
.sun_family = AF_LOCAL, .sun_family = AF_LOCAL,
#ifndef __minix
.sun_len = sizeof(sun), .sun_len = sizeof(sun),
#endif
.sun_path = _PATH_LOG, .sun_path = _PATH_LOG,
}; };

View file

@ -40,6 +40,11 @@ __RCSID("$NetBSD: telldir.c,v 1.19 2008/05/04 18:53:26 tonnerre Exp $");
#include "namespace.h" #include "namespace.h"
#include "reentrant.h" #include "reentrant.h"
#ifdef __minix
#include <sys/types.h>
#endif
#include "extern.h" #include "extern.h"
#include <sys/param.h> #include <sys/param.h>

View file

@ -72,7 +72,9 @@ ttyname_r(int fd, char *buf, size_t len)
mode_t type; mode_t type;
dev_t dev; dev_t dev;
} bkey; } bkey;
#ifndef __minix
struct ptmget ptm; struct ptmget ptm;
#endif
#define DEVSZ (sizeof(_PATH_DEV) - 1) #define DEVSZ (sizeof(_PATH_DEV) - 1)
_DIAGASSERT(fd != -1); _DIAGASSERT(fd != -1);
@ -80,7 +82,7 @@ ttyname_r(int fd, char *buf, size_t len)
if (len <= DEVSZ) { if (len <= DEVSZ) {
return ERANGE; return ERANGE;
} }
#ifndef __minix
/* If it is a pty, deal with it quickly */ /* If it is a pty, deal with it quickly */
if (ioctl(fd, TIOCPTSNAME, &ptm) != -1) { if (ioctl(fd, TIOCPTSNAME, &ptm) != -1) {
if (strlcpy(buf, ptm.sn, len) >= len) { if (strlcpy(buf, ptm.sn, len) >= len) {
@ -88,6 +90,8 @@ ttyname_r(int fd, char *buf, size_t len)
} }
return 0; return 0;
} }
#endif
/* Must be a terminal. */ /* Must be a terminal. */
if (tcgetattr(fd, &ttyb) == -1) if (tcgetattr(fd, &ttyb) == -1)
return errno; return errno;
@ -136,7 +140,11 @@ oldttyname(const struct stat *sb, char *buf, size_t len)
while ((dirp = readdir(dp)) != NULL) { while ((dirp = readdir(dp)) != NULL) {
if (dirp->d_fileno != sb->st_ino) if (dirp->d_fileno != sb->st_ino)
continue; continue;
#ifdef __minix
dlen = strlen(dirp->d_name);
#else
dlen = dirp->d_namlen + 1; dlen = dirp->d_namlen + 1;
#endif
if (len - DEVSZ <= dlen) { if (len - DEVSZ <= dlen) {
/* /*
* XXX: we return an error if *any* entry does not * XXX: we return an error if *any* entry does not

View file

@ -59,14 +59,20 @@ ttyslot(void)
char *p; char *p;
int cnt; int cnt;
char *name; char *name;
#ifndef __minix
struct ptmget ptm; struct ptmget ptm;
#endif
setttyent(); setttyent();
for (cnt = 0; cnt < 3; ++cnt) { for (cnt = 0; cnt < 3; ++cnt) {
#ifndef __minix
if (ioctl(cnt, TIOCPTSNAME, &ptm) != -1) { if (ioctl(cnt, TIOCPTSNAME, &ptm) != -1) {
ispty = 1; ispty = 1;
name = ptm.sn; name = ptm.sn;
} else if ((name = ttyname(cnt)) != NULL) { } else if ((name = ttyname(cnt)) != NULL) {
#else
if ((name = ttyname(cnt)) != NULL) {
#endif
ispty = 0; ispty = 0;
} else } else
continue; continue;

View file

@ -54,12 +54,14 @@ ulimit(int cmd, ...)
if (getrlimit(RLIMIT_FSIZE, &rlimit) == 0) if (getrlimit(RLIMIT_FSIZE, &rlimit) == 0)
result = (long int)(rlimit.rlim_cur / 512); result = (long int)(rlimit.rlim_cur / 512);
break; break;
#ifndef __minix
case UL_SETFSIZE: case UL_SETFSIZE:
new_limit = va_arg(ap, long int); new_limit = va_arg(ap, long int);
rlimit.rlim_cur = rlimit.rlim_max = (rlim_t)new_limit * 512; rlimit.rlim_cur = rlimit.rlim_max = (rlim_t)new_limit * 512;
if (setrlimit(RLIMIT_FSIZE, &rlimit) == 0) if (setrlimit(RLIMIT_FSIZE, &rlimit) == 0)
result = new_limit; result = new_limit;
break; break;
#endif
default: default:
errno = EINVAL; errno = EINVAL;
} }

View file

@ -336,16 +336,32 @@ updwtmpx(const char *file, const struct utmpx *utx)
_DIAGASSERT(file != NULL); _DIAGASSERT(file != NULL);
_DIAGASSERT(utx != NULL); _DIAGASSERT(utx != NULL);
#ifndef __minix
fd = open(file, O_WRONLY|O_APPEND|O_SHLOCK); fd = open(file, O_WRONLY|O_APPEND|O_SHLOCK);
#else
fd = open(file, O_WRONLY|O_APPEND);
#endif
if (fd == -1) { if (fd == -1) {
#ifndef __minix
if ((fd = open(file, O_CREAT|O_WRONLY|O_EXLOCK, 0644)) == -1) if ((fd = open(file, O_CREAT|O_WRONLY|O_EXLOCK, 0644)) == -1)
return -1; return -1;
#else
if ((fd = open(file, O_CREAT|O_WRONLY, 0644)) < 0)
return -1;
if (flock(fd, LOCK_EX) < 0)
return -1;
#endif
(void)memset(&ut, 0, sizeof(ut)); (void)memset(&ut, 0, sizeof(ut));
ut.ut_type = SIGNATURE; ut.ut_type = SIGNATURE;
(void)memcpy(ut.ut_user, vers, sizeof(vers)); (void)memcpy(ut.ut_user, vers, sizeof(vers));
if (write(fd, &ut, sizeof(ut)) == -1) if (write(fd, &ut, sizeof(ut)) == -1)
goto failed; goto failed;
} else {
#ifdef __minix
if (flock(fd, LOCK_SH) < 0 )
return -1;
#endif
} }
if (write(fd, utx, sizeof(*utx)) == -1) if (write(fd, utx, sizeof(*utx)) == -1)
goto failed; goto failed;
@ -360,7 +376,6 @@ updwtmpx(const char *file, const struct utmpx *utx)
return -1; return -1;
} }
int int
utmpxname(const char *fname) utmpxname(const char *fname)
{ {
@ -425,10 +440,18 @@ getlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
_DIAGASSERT(fname != NULL); _DIAGASSERT(fname != NULL);
_DIAGASSERT(ll != NULL); _DIAGASSERT(ll != NULL);
#ifdef __minix
db = dbopen(fname, O_RDONLY, 0, DB_HASH, NULL);
#else
db = dbopen(fname, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL); db = dbopen(fname, O_RDONLY|O_SHLOCK, 0, DB_HASH, NULL);
#endif
if (db == NULL) if (db == NULL)
return NULL; return NULL;
#ifdef __minix
if (flock(db->fd(db), LOCK_SH) < 0)
return NULL;
#endif
key.data = &uid; key.data = &uid;
key.size = sizeof(uid); key.size = sizeof(uid);
@ -464,11 +487,20 @@ updlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
_DIAGASSERT(fname != NULL); _DIAGASSERT(fname != NULL);
_DIAGASSERT(ll != NULL); _DIAGASSERT(ll != NULL);
#ifndef __minix
db = dbopen(fname, O_RDWR|O_CREAT|O_EXLOCK, 0644, DB_HASH, NULL); db = dbopen(fname, O_RDWR|O_CREAT|O_EXLOCK, 0644, DB_HASH, NULL);
#else
db = dbopen(fname, O_RDWR|O_CREAT, 0644, DB_HASH, NULL);
#endif
if (db == NULL) if (db == NULL)
return -1; return -1;
#ifdef __minix
if (flock(db->fd(db), LOCK_EX) < 0)
return -1;
#endif
key.data = &uid; key.data = &uid;
key.size = sizeof(uid); key.size = sizeof(uid);
data.data = ll; data.data = ll;

View file

@ -373,8 +373,10 @@ _mcleanup(void)
struct gmonparam *p = &_gmonparam; struct gmonparam *p = &_gmonparam;
struct gmonhdr gmonhdr, *hdr; struct gmonhdr gmonhdr, *hdr;
struct clockinfo clockinfo; struct clockinfo clockinfo;
#ifndef __minix
int mib[2]; int mib[2];
size_t size; size_t size;
#endif
char *profdir; char *profdir;
const char *proffile; const char *proffile;
char buf[PATH_MAX]; char buf[PATH_MAX];
@ -396,7 +398,9 @@ _mcleanup(void)
if (p->state == GMON_PROF_ERROR) if (p->state == GMON_PROF_ERROR)
warnx("%s: tos overflow", __func__); warnx("%s: tos overflow", __func__);
#ifdef __minix
clockinfo.profhz = sysconf(_SC_CLK_TCK);
#else /* !__minix */
size = sizeof(clockinfo); size = sizeof(clockinfo);
mib[0] = CTL_KERN; mib[0] = CTL_KERN;
mib[1] = KERN_CLOCKRATE; mib[1] = KERN_CLOCKRATE;
@ -411,6 +415,7 @@ _mcleanup(void)
else else
clockinfo.profhz = hertz(); clockinfo.profhz = hertz();
} }
#endif /* !__minix */
moncontrol(0); moncontrol(0);
@ -509,6 +514,7 @@ moncontrol(int mode)
} }
} }
#ifndef __minix
/* /*
* discover the tick frequency of the machine * discover the tick frequency of the machine
* if something goes wrong, we return 0, an impossible hertz. * if something goes wrong, we return 0, an impossible hertz.
@ -542,3 +548,4 @@ out:
(void)timer_delete(t); (void)timer_delete(t);
return rv; return rv;
} }
#endif /* !__minix */

View file

@ -56,7 +56,7 @@ __writelockenv(void)
} }
static __inline bool static __inline bool
__unlocklockenv(void) __unlockenv(void)
{ {
return true; return true;
} }

View file

@ -4,7 +4,7 @@
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc. * Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, ith or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
@ -47,7 +47,9 @@
#define fork _fork #define fork _fork
#define fseeko _fseeko #define fseeko _fseeko
#define ftello _ftello #define ftello _ftello
#ifndef __minix
#define getcontext _getcontext #define getcontext _getcontext
#endif /* !__minix */
#define getenv_r _getenv_r #define getenv_r _getenv_r
#define imaxabs _imaxabs #define imaxabs _imaxabs
#define imaxdiv _imaxdiv #define imaxdiv _imaxdiv
@ -530,7 +532,13 @@
#define seed48 _seed48 #define seed48 _seed48
#define seekdir _seekdir #define seekdir _seekdir
#define select _select #define select _select
#ifdef __minix
/* '_send' unfortunately collides with Minix IPC's _send function.
* This solution is fragile, a proper renaming of Minix IPCs should
* be done insted. */
#else /* !__minix */
#define send _send #define send _send
#endif /* !__minix */
#define setdomainname _setdomainname #define setdomainname _setdomainname
#define setenv _setenv #define setenv _setenv
#define setfsent _setfsent #define setfsent _setfsent
@ -845,6 +853,80 @@
#define xprtlist_lock __rpc_xprtlist_lock #define xprtlist_lock __rpc_xprtlist_lock
#define __learn_tree ___learn_tree #define __learn_tree ___learn_tree
#ifdef __minix
#define _exit __exit
#define access _access
#define bind _bind
#define chdir _chdir
#define chmod _chmod
#define chown _chown
#define chroot _chroot
#define close _close
#define dup _dup
#define dup2 _dup2
#define execve _execve
#define fchdir _fchdir
#define fchmod _fchmod
#define fchown _fchown
#define fcntl _fcntl
#define flock _flock
#define fstat _fstat
#define fsync _fsync
#define fpathconf _fpathconf
#define getegid _getegid
#define geteuid _geteuid
#define getgroups _getgroups
#define getpid _getpid
#define getpgrp _getpgrp
#define getppid _getppid
#define gettimeofday _gettimeofday
#define getgid _getgid
#define getuid _getuid
#define ioctl _ioctl
#define link _link
#define lstat _lstat
#define mount _mount
#define mkdir _mkdir
#define mkfifo _mkfifo
#define mknod _mknod
#define munmap _munmap
#define munmap_text _munmap_text
#define open _open
#define pathconf _pathconf
#define ptrace _ptrace
#define readv _readv
#define rmdir _rmdir
#define setegid _setegid
#define seteuid _seteuid
#define setgid _setgid
#define setgroups _setgroups
#define setprogname _setprogname
#define setsid _setsid
#define setuid _setuid
#define shmat _shmat
#define shmdt _shmdt
#define shmget _shmget
#define sigreturn _sigreturn
#define socket _socket
#define socketpair _socketpair
#define symlink _symlink
#define sync _sync
#define stat(a, b) _stat(a, b)
#define stime _stime
#define umask _umask
#define umount _umount
#define umount2 _umount2
#define unlink _unlink
#define vm_remap _vm_remap
#define vm_unmap _vm_unmap
#define vm_getphys _vm_getphys
#define vm_getrefcount _vm_getrefcount
#define truncate _truncate
#define write _write
#define writev _writev
#endif /* __minix */
#endif /* __weak_alias */ #endif /* __weak_alias */
#endif /* !__lint__ */ #endif /* !__lint__ */

View file

@ -4,11 +4,11 @@
# inside libc's include tree. # inside libc's include tree.
.if defined(LIBC_MACHINE_ARCH) && \ .if defined(LIBC_MACHINE_ARCH) && \
exists(${NETBSDSRCDIR}/lib/libc/arch/${LIBC_MACHINE_ARCH}/SYS.h) exists(${MINIXSRCDIR}/lib/nbsd_libc/arch/${LIBC_MACHINE_ARCH}/SYS.h)
ARCHSUBDIR= ${LIBC_MACHINE_ARCH} ARCHSUBDIR= ${LIBC_MACHINE_ARCH}
.elif exists(${NETBSDSRCDIR}/lib/libc/arch/${MACHINE_ARCH}/SYS.h) .elif exists(${MINIXSRCDIR}/lib/nbsd_libc/arch/${MACHINE_ARCH}/SYS.h)
ARCHSUBDIR= ${MACHINE_ARCH} ARCHSUBDIR= ${MACHINE_ARCH}
.elif exists(${NETBSDSRCDIR}/lib/libc/arch/${MACHINE_CPU}/SYS.h) .elif exists(${MINIXSRCDIR}/lib/nbsd_libc/arch/${MACHINE_CPU}/SYS.h)
ARCHSUBDIR= ${MACHINE_CPU} ARCHSUBDIR= ${MACHINE_CPU}
.else .else
.BEGIN: .BEGIN:
@ -16,4 +16,4 @@ ARCHSUBDIR= ${MACHINE_CPU}
@false @false
.endif .endif
ARCHDIR= ${NETBSDSRCDIR}/lib/libc/arch/${ARCHSUBDIR} ARCHDIR= ${MINIXSRCCDIR}/lib/nbsd_libc/arch/${ARCHSUBDIR}

View file

@ -61,6 +61,38 @@ extern const _locale_category_t _localeio_LC_TIME_desc;
extern const _locale_category_t _localeio_LC_MESSAGES_desc; extern const _locale_category_t _localeio_LC_MESSAGES_desc;
#endif #endif
#ifdef __minix
/* GNU binutils 2.x a.out support is rotten and link sets are not
supported. Workaround this by explicitely creating the structure
the linker was supposed to create. */
struct {
int __ls_length;
_locale_category_t *__ls_items[7];
} __link_set_all_categories = {
.__ls_length = 7,
.__ls_items = {
[0] = &_generic_LC_ALL_desc,
[1] = &_dummy_LC_COLLATE_desc,
#ifdef WITH_RUNE
[2] = &_citrus_LC_CTYPE_desc,
[3] = &_citrus_LC_MONETARY_desc,
[4] = &_citrus_LC_NUMERIC_desc,
[5] = &_citrus_LC_TIME_desc,
[6] = &_citrus_LC_MESSAGES_desc,
#else
[2] = &_localeio_LC_CTYPE_desc,
[3] = &_localeio_LC_MONETARY_desc,
[4] = &_localeio_LC_NUMERIC_desc,
[5] = &_localeio_LC_TIME_desc,
[6] = &_localeio_LC_MESSAGES_desc,
#endif
},
};
#endif /* __minix */
__link_set_add_data(all_categories, _generic_LC_ALL_desc); __link_set_add_data(all_categories, _generic_LC_ALL_desc);
__link_set_add_data(all_categories, _dummy_LC_COLLATE_desc); __link_set_add_data(all_categories, _dummy_LC_COLLATE_desc);
#ifdef WITH_RUNE #ifdef WITH_RUNE
@ -130,6 +162,7 @@ __setlocale(int category, const char *name)
return NULL; return NULL;
} }
char * char *
setlocale(int category, const char *locale) setlocale(int category, const char *locale)
{ {

View file

@ -0,0 +1,15 @@
NETBSDSRCDIR= ${MINIXSRCDIR}
NETBSDINCLUDES= /usr/netbsd/include/
MACHINE_ARCH?= i386
LIBDIR= /usr/netbsd/lib
CPPFLAGS+= -nostdinc -O -D__minix -D_POSIX_SOURCE -I${NETBSDINCLUDES} -D_NETBSD_SOURCE -D__NBSD_LIBC
AFLAGS+= -nostdinc -D__minix -I${NETBSDINCLUDES}
CITRUS=yes
USE_INET6=no
MKYP=no #requires RPC
USE_JEMALLOC=no
USE_FORT=no

View file

@ -55,8 +55,10 @@ __libc_init(void)
/* Atomic operations */ /* Atomic operations */
__libc_atomic_init(); __libc_atomic_init();
#ifdef _REENTRANT
/* Threads */ /* Threads */
__libc_thr_init(); __libc_thr_init();
#endif
/* Initialize the atexit mutexes */ /* Initialize the atexit mutexes */
__libc_atexit_init(); __libc_atexit_init();

View file

@ -56,24 +56,29 @@ void __guard_setup(void);
void void
__guard_setup(void) __guard_setup(void)
{ {
#ifndef __minix
int mib[2]; int mib[2];
#endif
size_t len; size_t len;
if (__stack_chk_guard[0] != 0) if (__stack_chk_guard[0] != 0)
return; return;
#ifndef __minix
mib[0] = CTL_KERN; mib[0] = CTL_KERN;
mib[1] = KERN_ARND; mib[1] = KERN_ARND;
len = sizeof(__stack_chk_guard); len = sizeof(__stack_chk_guard);
if (__sysctl(mib, 2, __stack_chk_guard, &len, NULL, 0) == -1 || if (__sysctl(mib, 2, __stack_chk_guard, &len, NULL, 0) == -1 ||
len != sizeof(__stack_chk_guard)) { len != sizeof(__stack_chk_guard)) {
#endif
/* If sysctl was unsuccessful, use the "terminator canary". */ /* If sysctl was unsuccessful, use the "terminator canary". */
((unsigned char *)(void *)__stack_chk_guard)[0] = 0; ((unsigned char *)(void *)__stack_chk_guard)[0] = 0;
((unsigned char *)(void *)__stack_chk_guard)[1] = 0; ((unsigned char *)(void *)__stack_chk_guard)[1] = 0;
((unsigned char *)(void *)__stack_chk_guard)[2] = '\n'; ((unsigned char *)(void *)__stack_chk_guard)[2] = '\n';
((unsigned char *)(void *)__stack_chk_guard)[3] = 255; ((unsigned char *)(void *)__stack_chk_guard)[3] = 255;
#ifndef __minix
} }
#endif
} }
/*ARGSUSED*/ /*ARGSUSED*/

View file

@ -2,7 +2,7 @@
# @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 # @(#)Makefile.inc 8.2 (Berkeley) 9/5/93
# net sources # net sources
.PATH: ${ARCHDIR}/net ${.CURDIR}/net .PATH: ${ARCHDIR}/net ${.CURDIR}/net/minix ${.CURDIR}/net
SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \ SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \
getnetnamadr.c getnetent.c getpeereid.c \ getnetnamadr.c getnetent.c getpeereid.c \
@ -10,10 +10,12 @@ SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \
getprotobyname_r.c getprotobynumber_r.c getprotoent_r.c \ getprotobyname_r.c getprotobynumber_r.c getprotoent_r.c \
getservbyname.c getservbyport.c getservent.c \ getservbyname.c getservbyport.c getservent.c \
getservbyname_r.c getservbyport_r.c getservent_r.c \ getservbyname_r.c getservbyport_r.c getservent_r.c \
iso_addr.c linkaddr.c \
nsdispatch.c nslexer.l nsparser.y nsap_addr.c \ nsdispatch.c nslexer.l nsparser.y nsap_addr.c \
rcmd.c recv.c send.c sethostent.c \ rcmd.c recv.c send.c sethostent.c
sockatmark.c
# Not supported by Minix:
# sockatmark.c
.if (${MKHESIOD} != "no") .if (${MKHESIOD} != "no")
SRCS+= hesiod.c SRCS+= hesiod.c
@ -23,7 +25,9 @@ SRCS+= getaddrinfo.c getnameinfo.c
.if (${USE_INET6} != "no") .if (${USE_INET6} != "no")
SRCS+= ip6opt.c rthdr.c vars6.c SRCS+= ip6opt.c rthdr.c vars6.c
.endif .endif
SRCS+= if_indextoname.c if_nameindex.c if_nametoindex.c # Not supported by minix
#SRCS+= if_indextoname.c if_nameindex.c if_nametoindex.c
# iso_addr.c linkaddr.c \
LPREFIX=_nsyy LPREFIX=_nsyy
YPREFIX=_nsyy YPREFIX=_nsyy

View file

@ -855,7 +855,12 @@ allocaddrinfo(socklen_t addrlen)
ai = calloc(sizeof(struct addrinfo) + addrlen, 1); ai = calloc(sizeof(struct addrinfo) + addrlen, 1);
if (ai) { if (ai) {
ai->ai_addr = (void *)(ai+1); ai->ai_addr = (void *)(ai+1);
#ifndef __minix
ai->ai_addrlen = ai->ai_addr->sa_len = addrlen; ai->ai_addrlen = ai->ai_addr->sa_len = addrlen;
#else /* __minix */
ai->ai_addrlen = addrlen;
#endif
} }
return ai; return ai;

View file

@ -54,10 +54,12 @@ __RCSID("$NetBSD: getnameinfo.c,v 1.50 2010/06/29 14:44:19 seanb Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <net/if.h> #include <net/if.h>
#ifndef __minix
#include <net/if_dl.h> #include <net/if_dl.h>
#include <net/if_ieee1394.h> #include <net/if_ieee1394.h>
#include <net/if_types.h> #include <net/if_types.h>
#include <netatalk/at.h> #include <netatalk/at.h>
#endif /* !__minix */
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <arpa/nameser.h> #include <arpa/nameser.h>
@ -103,11 +105,13 @@ static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t,
int)); int));
#endif #endif
#ifndef __minix
static int getnameinfo_atalk __P((const struct sockaddr *, socklen_t, char *, static int getnameinfo_atalk __P((const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int)); socklen_t, char *, socklen_t, int));
static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *, static int getnameinfo_link __P((const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int)); socklen_t, char *, socklen_t, int));
#endif /* __minix */
static int hexname __P((const u_int8_t *, size_t, char *, socklen_t)); static int hexname __P((const u_int8_t *, size_t, char *, socklen_t));
/* /*
@ -124,21 +128,26 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
{ {
switch (sa->sa_family) { switch (sa->sa_family) {
#ifndef __minix
case AF_APPLETALK: case AF_APPLETALK:
return getnameinfo_atalk(sa, salen, host, hostlen, return getnameinfo_atalk(sa, salen, host, hostlen,
serv, servlen, flags); serv, servlen, flags);
#endif /* !__minix */
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
return getnameinfo_inet(sa, salen, host, hostlen, return getnameinfo_inet(sa, salen, host, hostlen,
serv, servlen, flags); serv, servlen, flags);
#ifndef __minix
case AF_LINK: case AF_LINK:
return getnameinfo_link(sa, salen, host, hostlen, return getnameinfo_link(sa, salen, host, hostlen,
serv, servlen, flags); serv, servlen, flags);
#endif /* !__minix */
default: default:
return EAI_FAMILY; return EAI_FAMILY;
} }
} }
#ifndef __minix
/* /*
* getnameinfo_atalk(): * getnameinfo_atalk():
* Format an AppleTalk address into a printable format. * Format an AppleTalk address into a printable format.
@ -198,6 +207,7 @@ errout:
return EAI_MEMORY; return EAI_MEMORY;
} }
#endif /* !__minix */
/* /*
* getnameinfo_inet(): * getnameinfo_inet():
@ -490,7 +500,7 @@ ip6_sa2str(sa6, buf, bufsiz, flags)
} }
#endif /* INET6 */ #endif /* INET6 */
#ifndef __minix
/* /*
* getnameinfo_link(): * getnameinfo_link():
* Format a link-layer address into a printable format, paying attention to * Format a link-layer address into a printable format, paying attention to
@ -568,6 +578,7 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
(size_t)sdl->sdl_alen, host, hostlen); (size_t)sdl->sdl_alen, host, hostlen);
} }
} }
#endif /* !__minix */
static int static int
hexname(cp, len, host, hostlen) hexname(cp, len, host, hostlen)

View file

@ -201,6 +201,7 @@ orcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
return (error); return (error);
} }
/*ARGSUSED*/ /*ARGSUSED*/
static int static int
resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p) resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
@ -213,7 +214,11 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
struct addrinfo *r; struct addrinfo *r;
struct sockaddr_storage from; struct sockaddr_storage from;
struct pollfd reads[2]; struct pollfd reads[2];
#ifdef __minix
/* No support for OOB data in Minix. */
#else
sigset_t nmask, omask; sigset_t nmask, omask;
#endif /* !__minix */
pid_t pid; pid_t pid;
int s, lport, timo; int s, lport, timo;
int pollr; int pollr;
@ -230,10 +235,14 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
r = res; r = res;
refused = 0; refused = 0;
pid = getpid(); pid = getpid();
#ifndef __minix
/* Minix has no support for OOB data,
no need to block SIGURG. */
sigemptyset(&nmask); sigemptyset(&nmask);
sigaddset(&nmask, SIGURG); sigaddset(&nmask, SIGURG);
if (sigprocmask(SIG_BLOCK, &nmask, &omask) == -1) if (sigprocmask(SIG_BLOCK, &nmask, &omask) == -1)
return -1; return -1;
#endif /* !__minix */
for (timo = 1, lport = IPPORT_RESERVED - 1;;) { for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport_af(&lport, r->ai_family); s = rresvport_af(&lport, r->ai_family);
if (s < 0) { if (s < 0) {
@ -245,11 +254,16 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
r = r->ai_next; r = r->ai_next;
continue; continue;
} else { } else {
#ifndef __minix
(void)sigprocmask(SIG_SETMASK, &omask, NULL); (void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* !__minix */
return (-1); return (-1);
} }
} }
#ifndef __minix
/* No OOB support in Minix. */
fcntl(s, F_SETOWN, pid); fcntl(s, F_SETOWN, pid);
#endif /* !__minix */
if (connect(s, r->ai_addr, r->ai_addrlen) >= 0) if (connect(s, r->ai_addr, r->ai_addrlen) >= 0)
break; break;
(void)close(s); (void)close(s);
@ -286,7 +300,10 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
} }
(void)fprintf(stderr, "%s: %s\n", res->ai_canonname, (void)fprintf(stderr, "%s: %s\n", res->ai_canonname,
strerror(errno)); strerror(errno));
#ifndef __minix
/* No OOB support in Minix. */
(void)sigprocmask(SIG_SETMASK, &omask, NULL); (void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* !__minix */
return (-1); return (-1);
} }
lport--; lport--;
@ -363,14 +380,18 @@ resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p)
} }
goto bad2; goto bad2;
} }
#ifndef __minix
(void)sigprocmask(SIG_SETMASK, &omask, NULL); (void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* __minix */
return (s); return (s);
bad2: bad2:
if (lport) if (lport)
(void)close(*fd2p); (void)close(*fd2p);
bad: bad:
(void)close(s); (void)close(s);
#ifndef __minix
(void)sigprocmask(SIG_SETMASK, &omask, NULL); (void)sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* __minix */
return (-1); return (-1);
} }
@ -522,7 +543,7 @@ rresvport_af(alport, family)
sa = (struct sockaddr *)(void *)&ss; sa = (struct sockaddr *)(void *)&ss;
switch (family) { switch (family) {
case AF_INET: case AF_INET:
#ifdef BSD4_4 #if defined(BSD4_4) && !defined(__minix)
sa->sa_len = sa->sa_len =
#endif #endif
salen = sizeof(struct sockaddr_in); salen = sizeof(struct sockaddr_in);
@ -530,7 +551,7 @@ rresvport_af(alport, family)
break; break;
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
#ifdef BSD4_4 #if defined(BSD4_4) && !defined(__minix)
sa->sa_len = sa->sa_len =
#endif #endif
salen = sizeof(struct sockaddr_in6); salen = sizeof(struct sockaddr_in6);
@ -633,7 +654,7 @@ iruserok(raddr, superuser, ruser, luser)
memset(&irsin, 0, sizeof(irsin)); memset(&irsin, 0, sizeof(irsin));
irsin.sin_family = AF_INET; irsin.sin_family = AF_INET;
#ifdef BSD4_4 #if defined(BSD4_4) && !defined(__minix)
irsin.sin_len = sizeof(struct sockaddr_in); irsin.sin_len = sizeof(struct sockaddr_in);
#endif #endif
memcpy(&irsin.sin_addr, &raddr, sizeof(irsin.sin_addr)); memcpy(&irsin.sin_addr, &raddr, sizeof(irsin.sin_addr));
@ -753,7 +774,7 @@ __ivaliduser(hostf, raddr, luser, ruser)
memset(&ivusin, 0, sizeof(ivusin)); memset(&ivusin, 0, sizeof(ivusin));
ivusin.sin_family = AF_INET; ivusin.sin_family = AF_INET;
#ifdef BSD4_4 #if defined(BSD4_4) && !defined(__minix)
ivusin.sin_len = sizeof(struct sockaddr_in); ivusin.sin_len = sizeof(struct sockaddr_in);
#endif #endif
memcpy(&ivusin.sin_addr, &raddr, sizeof(ivusin.sin_addr)); memcpy(&ivusin.sin_addr, &raddr, sizeof(ivusin.sin_addr));

View file

@ -44,9 +44,15 @@ __RCSID("$NetBSD: send.c,v 1.9 2003/08/07 16:43:15 agc Exp $");
#include <stddef.h> #include <stddef.h>
#ifdef __minix
/* UGLY: name clash with minix ipc.
* Better solution: redefine minix ipc.
*/
#else /* !__minix */
#ifdef __weak_alias #ifdef __weak_alias
__weak_alias(send, _send) __weak_alias(send, _send)
#endif #endif
#endif /* !__minix */
ssize_t ssize_t
send(s, msg, len, flags) send(s, msg, len, flags)

View file

@ -169,6 +169,19 @@ load_msgcat(path)
return (nl_catd)-1; return (nl_catd)-1;
} }
#ifdef __minix
data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_ANON, -1, (off_t)0);
if (data == MAP_FAILED) {
return (nl_catd)-1;
}
if (read(fd, data, st.st_size) != st.st_size)
{
munmap(data, (size_t)st.st_size);
return (nl_catd)-1;
}
close (fd);
#else /* !__minix */
data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd,
(off_t)0); (off_t)0);
close (fd); close (fd);
@ -176,6 +189,7 @@ load_msgcat(path)
if (data == MAP_FAILED) { if (data == MAP_FAILED) {
return (nl_catd)-1; return (nl_catd)-1;
} }
#endif /* __minix */
if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) != if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) !=
_NLS_MAGIC) { _NLS_MAGIC) {

View file

@ -88,7 +88,9 @@ __RCSID("$NetBSD: res_init.c,v 1.22 2009/10/24 17:24:01 christos Exp $");
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#ifndef __minix
#include <sys/event.h> #include <sys/event.h>
#endif /* !__minix */
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
@ -348,7 +350,9 @@ __res_vinit(res_state statp, int preinit) {
nserv = 0; nserv = 0;
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
struct stat st; struct stat st;
#ifndef __minix
struct kevent kc; struct kevent kc;
#endif /* !__minix */
/* read the config file */ /* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) { while (fgets(buf, sizeof(buf), fp) != NULL) {
@ -465,7 +469,7 @@ __res_vinit(res_state statp, int preinit) {
*cp++ = n; *cp++ = n;
net = cp; net = cp;
while (*cp && *cp != ';' && while (*cp && *cp != ';' &&
isascii(*cp) && isascii(*cp) &&
!isspace((unsigned char)*cp)) !isspace((unsigned char)*cp))
cp++; cp++;
n = *cp; n = *cp;
@ -502,6 +506,7 @@ __res_vinit(res_state statp, int preinit) {
if (fstat(statp->_u._ext.ext->resfd, &st) != -1) if (fstat(statp->_u._ext.ext->resfd, &st) != -1)
__res_conf_time = statp->_u._ext.ext->res_conf_time = __res_conf_time = statp->_u._ext.ext->res_conf_time =
st.st_mtimespec; st.st_mtimespec;
#ifndef __minix
statp->_u._ext.ext->kq = kqueue(); statp->_u._ext.ext->kq = kqueue();
(void)fcntl(statp->_u._ext.ext->kq, F_SETFD, FD_CLOEXEC); (void)fcntl(statp->_u._ext.ext->kq, F_SETFD, FD_CLOEXEC);
(void)fcntl(statp->_u._ext.ext->resfd, F_SETFD, FD_CLOEXEC); (void)fcntl(statp->_u._ext.ext->resfd, F_SETFD, FD_CLOEXEC);
@ -509,6 +514,9 @@ __res_vinit(res_state statp, int preinit) {
EV_ADD|EV_ENABLE|EV_CLEAR, NOTE_DELETE|NOTE_WRITE| NOTE_EXTEND| EV_ADD|EV_ENABLE|EV_CLEAR, NOTE_DELETE|NOTE_WRITE| NOTE_EXTEND|
NOTE_ATTRIB|NOTE_LINK|NOTE_RENAME|NOTE_REVOKE, 0, 0); NOTE_ATTRIB|NOTE_LINK|NOTE_RENAME|NOTE_REVOKE, 0, 0);
(void)kevent(statp->_u._ext.ext->kq, &kc, 1, NULL, 0, &ts); (void)kevent(statp->_u._ext.ext->kq, &kc, 1, NULL, 0, &ts);
#else /* __minix */
statp->_u._ext.ext->kq = -1;
#endif /* !__minix */
} else { } else {
statp->_u._ext.ext->kq = -1; statp->_u._ext.ext->kq = -1;
statp->_u._ext.ext->resfd = -1; statp->_u._ext.ext->resfd = -1;
@ -565,6 +573,12 @@ __res_vinit(res_state statp, int preinit) {
int int
res_check(res_state statp, struct timespec *mtime) res_check(res_state statp, struct timespec *mtime)
{ {
#ifdef __minix
/*
* XXX: No update on change.
*/
return 0;
#else /* !__minix */
/* /*
* If the times are equal, then we check if there * If the times are equal, then we check if there
* was a kevent related to resolv.conf and reload. * was a kevent related to resolv.conf and reload.
@ -589,10 +603,12 @@ out:
break; break;
} }
} }
(void)__res_vinit(statp, 0); (void)__res_vinit(statp, 0);
if (mtime) if (mtime)
*mtime = __res_conf_time; *mtime = __res_conf_time;
return 1; return 1;
#endif /* !__minix */
} }
static void static void

View file

@ -10,7 +10,7 @@ SRCS+= _env.c _rand48.c \
getenv.c getopt.c getopt_long.c getsubopt.c \ getenv.c getopt.c getopt_long.c getsubopt.c \
hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \ hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \
lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \ lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \
nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \ nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c \
radixsort.c rand.c rand_r.c random.c remque.c \ radixsort.c rand.c rand_r.c random.c remque.c \
seed48.c setenv.c srand48.c strsuftoll.c \ seed48.c setenv.c srand48.c strsuftoll.c \
strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \ strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \

View file

@ -120,10 +120,12 @@ atexit_handler_alloc(void *dso)
void void
__libc_atexit_init(void) __libc_atexit_init(void)
{ {
#ifdef _REENTRANT /* !__minix */
mutexattr_t atexit_mutex_attr; mutexattr_t atexit_mutex_attr;
mutexattr_init(&atexit_mutex_attr); mutexattr_init(&atexit_mutex_attr);
mutexattr_settype(&atexit_mutex_attr, PTHREAD_MUTEX_RECURSIVE); mutexattr_settype(&atexit_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
mutex_init(&atexit_mutex, &atexit_mutex_attr); mutex_init(&atexit_mutex, &atexit_mutex_attr);
#endif /* _REENTRANT */
} }
/* /*

View file

@ -65,8 +65,10 @@
# define malloc_pageshift 12U # define malloc_pageshift 12U
# define malloc_minsize 16U # define malloc_minsize 16U
# endif # endif
#ifndef __minix
# define HAS_UTRACE # define HAS_UTRACE
# define UTRACE_LABEL # define UTRACE_LABEL
#endif /* __minix */
#include <sys/cdefs.h> #include <sys/cdefs.h>
void utrace(struct ut *, int); void utrace(struct ut *, int);
@ -210,9 +212,11 @@ static size_t malloc_pagemask;
#define INIT_MMAP() #define INIT_MMAP()
#endif #endif
#ifndef __minix
#ifndef MADV_FREE #ifndef MADV_FREE
#define MADV_FREE MADV_DONTNEED #define MADV_FREE MADV_DONTNEED
#endif #endif
#endif /* !__minix */
/* Number of free pages we cache */ /* Number of free pages we cache */
static size_t malloc_cache = 16; static size_t malloc_cache = 16;
@ -485,8 +489,10 @@ malloc_init(void)
case '<': malloc_cache >>= 1; break; case '<': malloc_cache >>= 1; break;
case 'a': malloc_abort = 0; break; case 'a': malloc_abort = 0; break;
case 'A': malloc_abort = 1; break; case 'A': malloc_abort = 1; break;
#ifndef __minix
case 'h': malloc_hint = 0; break; case 'h': malloc_hint = 0; break;
case 'H': malloc_hint = 1; break; case 'H': malloc_hint = 1; break;
#endif /* !__minix */
case 'r': malloc_realloc = 0; break; case 'r': malloc_realloc = 0; break;
case 'R': malloc_realloc = 1; break; case 'R': malloc_realloc = 1; break;
case 'j': malloc_junk = 0; break; case 'j': malloc_junk = 0; break;
@ -932,8 +938,10 @@ free_pages(void *ptr, size_t idx, struct pginfo *info)
if (malloc_junk) if (malloc_junk)
memset(ptr, SOME_JUNK, l); memset(ptr, SOME_JUNK, l);
#ifndef __minix
if (malloc_hint) if (malloc_hint)
madvise(ptr, l, MADV_FREE); madvise(ptr, l, MADV_FREE);
#endif /* !__minix */
tail = (char *)ptr+l; tail = (char *)ptr+l;

View file

@ -91,7 +91,11 @@ system(command)
} }
(void)__readlockenv(); (void)__readlockenv();
#ifdef __minix
switch(pid = fork() ) {
#else /* !__minix */
switch(pid = vfork()) { switch(pid = vfork()) {
#endif /* !__minix */
case -1: /* error */ case -1: /* error */
(void)__unlockenv(); (void)__unlockenv();
sigaction(SIGINT, &intsa, NULL); sigaction(SIGINT, &intsa, NULL);

View file

@ -4,9 +4,12 @@
SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \ SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \ cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c tcsendbreak.c tcsetattr.c tcsetpgrp.c
MAN+= tcgetpgrp.3 tcgetsid.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 # Not supported by Minix
# tcgetsid.c
MAN+= tcgetpgrp.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3
MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 \ MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 \
tcsendbreak.3 tcflush.3 tcsendbreak.3 tcflush.3

View file

@ -59,7 +59,11 @@ cfmakeraw(t)
_DIAGASSERT(t != NULL); _DIAGASSERT(t != NULL);
#ifdef __minix
t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
#else /* !__minix */
t->c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); t->c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
#endif /* !__minix */
t->c_oflag &= ~OPOST; t->c_oflag &= ~OPOST;
t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
t->c_cflag &= ~(CSIZE|PARENB); t->c_cflag &= ~(CSIZE|PARENB);

View file

@ -54,6 +54,10 @@ int
tcflow(fd, action) tcflow(fd, action)
int fd, action; int fd, action;
{ {
#ifdef __minix
_DIAGASSERT(fd != -1);
return ioctl(fd, TCFLOW, &action);
#else /* !__minix */
struct termios term; struct termios term;
u_char c; u_char c;
@ -77,4 +81,5 @@ tcflow(fd, action)
return (-1); return (-1);
} }
/* NOTREACHED */ /* NOTREACHED */
#endif /* !__minix */
} }

View file

@ -54,6 +54,10 @@ int
tcflush(fd, which) tcflush(fd, which)
int fd, which; int fd, which;
{ {
#ifdef __minix
_DIAGASSERT(fd != -1);
return ioctl(fd, TCFLSH, &which);
#else /* !__minix */
int com; int com;
_DIAGASSERT(fd != -1); _DIAGASSERT(fd != -1);
@ -73,4 +77,5 @@ tcflush(fd, which)
return (-1); return (-1);
} }
return (ioctl(fd, TIOCFLUSH, &com)); return (ioctl(fd, TIOCFLUSH, &com));
#endif /* !__minix */
} }

View file

@ -41,7 +41,9 @@ __RCSID("$NetBSD: tcsendbreak.c,v 1.9 2003/08/07 16:44:14 agc Exp $");
#include "namespace.h" #include "namespace.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifndef __minix
#include <sys/time.h> #include <sys/time.h>
#endif /* !__minix */
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
@ -57,6 +59,10 @@ int
tcsendbreak(fd, len) tcsendbreak(fd, len)
int fd, len; int fd, len;
{ {
#ifdef __minix
_DIAGASSERT(fd != -1);
return ioctl(fd, TCSBRK, &len);
#else /* !__minix */
static const struct timespec sleepytime = { 0, 400000000 }; static const struct timespec sleepytime = { 0, 400000000 };
_DIAGASSERT(fd != -1); _DIAGASSERT(fd != -1);
@ -67,4 +73,5 @@ tcsendbreak(fd, len)
if (ioctl(fd, TIOCCBRK, 0) == -1) if (ioctl(fd, TIOCCBRK, 0) == -1)
return (-1); return (-1);
return (0); return (0);
#endif /* !__minix */
} }

View file

@ -60,11 +60,15 @@ tcsetattr(fd, opt, t)
_DIAGASSERT(fd != -1); _DIAGASSERT(fd != -1);
_DIAGASSERT(t != NULL); _DIAGASSERT(t != NULL);
#ifndef __minix
if (opt & TCSASOFT) { if (opt & TCSASOFT) {
localterm = *t; localterm = *t;
localterm.c_cflag |= CIGNORE; localterm.c_cflag |= CIGNORE;
t = &localterm; t = &localterm;
} }
#else /* __minix */
#define TCSASOFT 0
#endif /* __minix */
switch (opt & ~TCSASOFT) { switch (opt & ~TCSASOFT) {
case TCSANOW: case TCSANOW:
return (ioctl(fd, TIOCSETA, t)); return (ioctl(fd, TIOCSETA, t));

View file

@ -172,8 +172,10 @@ again:
} }
(void)memset(&ysd->dom_server_addr, 0, (void)memset(&ysd->dom_server_addr, 0,
sizeof ysd->dom_server_addr); sizeof ysd->dom_server_addr);
#ifndef __minix
ysd->dom_server_addr.sin_len = ysd->dom_server_addr.sin_len =
sizeof(struct sockaddr_in); sizeof(struct sockaddr_in);
#endif /* !__minix */
ysd->dom_server_addr.sin_family = AF_INET; ysd->dom_server_addr.sin_family = AF_INET;
bn = &ybr.ypbind_respbody.ypbind_bindinfo; bn = &ybr.ypbind_respbody.ypbind_bindinfo;
ysd->dom_server_addr.sin_port = ysd->dom_server_addr.sin_port =
@ -197,7 +199,9 @@ trynet:
if (ysd->dom_vers == -1 || ysd->dom_vers == 0) { if (ysd->dom_vers == -1 || ysd->dom_vers == 0) {
struct ypbind_binding *bn; struct ypbind_binding *bn;
(void)memset(&clnt_sin, 0, sizeof clnt_sin); (void)memset(&clnt_sin, 0, sizeof clnt_sin);
#ifndef __minix
clnt_sin.sin_len = sizeof(struct sockaddr_in); clnt_sin.sin_len = sizeof(struct sockaddr_in);
#endif /* !__minix */
clnt_sin.sin_family = AF_INET; clnt_sin.sin_family = AF_INET;
clnt_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); clnt_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
@ -228,7 +232,9 @@ trynet:
(void)memset(&ysd->dom_server_addr, 0, (void)memset(&ysd->dom_server_addr, 0,
sizeof ysd->dom_server_addr); sizeof ysd->dom_server_addr);
#ifndef __minix
ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in); ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in);
#endif /* !__minix */
ysd->dom_server_addr.sin_family = AF_INET; ysd->dom_server_addr.sin_family = AF_INET;
bn = &ypbr.ypbind_respbody.ypbind_bindinfo; bn = &ypbr.ypbind_respbody.ypbind_bindinfo;
ysd->dom_server_addr.sin_port = ysd->dom_server_addr.sin_port =