code:
/*	$OpenBSD: linux_termios.c,v 1.18 2015/04/30 09:20:51 mpi Exp $	*/
/*	$NetBSD: linux_termios.c,v 1.3 1996/04/05 00:01:54 christos Exp $	*/

/*
 * Copyright (c) 1995 Frank van der Linden
 * All rights reserved.
 *
 * 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 for the NetBSD Project
 *      by Frank van der Linden
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
 */

#include <sys/param.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/termios.h>

#include <sys/syscallargs.h>

#include <compat/linux/linux_types.h>
#include <compat/linux/linux_ioctl.h>
#include <compat/linux/linux_signal.h>
#include <compat/linux/linux_syscallargs.h>
#include <compat/linux/linux_util.h>
#include <compat/linux/linux_termios.h>

static speed_t linux_speeds[] = {
	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
	9600, 19200, 38400, 57600, 115200, 230400
};

static const int linux_spmasks[] = {
	LINUX_B0, LINUX_B50, LINUX_B75, LINUX_B110, LINUX_B134, LINUX_B150,
	LINUX_B200, LINUX_B300, LINUX_B600, LINUX_B1200, LINUX_B1800,
	LINUX_B2400, LINUX_B4800, LINUX_B9600, LINUX_B19200, LINUX_B38400,
	LINUX_B57600, LINUX_B115200, LINUX_B230400
};

static void linux_termio_to_bsd_termios(struct linux_termio *,
    struct termios *);
static void bsd_termios_to_linux_termio(struct termios *,
    struct linux_termio *);
static void linux_termios_to_bsd_termios(struct linux_termios *,
    struct termios *);
static void bsd_termios_to_linux_termios(struct termios *,
    struct linux_termios *);

/*
 * Deal with termio ioctl cruft. This doesn't look very good..
 * XXX too much code duplication, obviously..
 *
 * The conversion routines between Linux and BSD structures assume
 * that the fields are already filled with the current values,
 * so that fields present in BSD but not in Linux keep their current
 * values.
 */

static void
linux_termio_to_bsd_termios(lt, bts)
	struct linux_termio *lt;
	struct termios *bts;
{
	int index;

	bts->c_iflag = 0;
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNBRK, IGNBRK);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_BRKINT, BRKINT);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNPAR, IGNPAR);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_INPCK, INPCK);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_ISTRIP, ISTRIP);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_INLCR, INLCR);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNCR, IGNCR);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_ICRNL, ICRNL);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXON, IXON);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXANY, IXANY);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXOFF, IXOFF);
	bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IMAXBEL, IMAXBEL);

	bts->c_oflag = 0;
	bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_OPOST, OPOST);
	bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_ONLCR, ONLCR);
	bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_XTABS, OXTABS);

	/*
	 * This could have been:
	 * bts->c_cflag = (lt->c_flag & LINUX_CSIZE) << 4
	 * But who knows, those values might perhaps change one day.
	 */
	switch (lt->c_cflag & LINUX_CSIZE) {
	case LINUX_CS5:
		bts->c_cflag = CS5;
		break;
	case LINUX_CS6:
		bts->c_cflag = CS6;
		break;
	case LINUX_CS7:
		bts->c_cflag = CS7;
		break;
	case LINUX_CS8:
		bts->c_cflag = CS8;
		break;
	}
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CSTOPB, CSTOPB);
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CREAD, CREAD);
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_PARENB, PARENB);
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_PARODD, PARODD);
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_HUPCL, HUPCL);
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CLOCAL, CLOCAL);
	bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CRTSCTS, CRTSCTS);

	bts->c_lflag = 0;
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ISIG, ISIG);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ICANON, ICANON);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHO, ECHO);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOE, ECHOE);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOK, ECHOK);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHONL, ECHONL);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_NOFLSH, NOFLSH);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_TOSTOP, TOSTOP);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOCTL, ECHOCTL);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOPRT, ECHOPRT);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOKE, ECHOKE);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_FLUSHO, FLUSHO);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_PENDIN, PENDIN);
	bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_IEXTEN, IEXTEN);

	index = lt->c_cflag & LINUX_CBAUD;
	if (index & LINUX_CBAUDEX)
		index = (index & ~LINUX_CBAUDEX) + LINUX_NSPEEDS - 1;
	bts->c_ispeed = bts->c_ospeed = linux_speeds[index];

	bts->c_cc[VINTR] = lt->c_cc[LINUX_VINTR];
	bts->c_cc[VQUIT] = lt->c_cc[LINUX_VQUIT];
	bts->c_cc[VERASE] = lt->c_cc[LINUX_VERASE];
	bts->c_cc[VKILL] = lt->c_cc[LINUX_VKILL];
	bts->c_cc[VEOF] = lt->c_cc[LINUX_VEOF];
	bts->c_cc[VTIME] = lt->c_cc[LINUX_VTIME];
	bts->c_cc[VMIN] = lt->c_cc[LINUX_VMIN];
}

static void
bsd_termios_to_linux_termio(bts, lt)
	struct termios *bts;
	struct linux_termio *lt;
{
	int i, mask;

	lt->c_iflag = 0;
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNPAR, LINUX_IGNPAR);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, INPCK, LINUX_INPCK);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, ISTRIP, LINUX_ISTRIP);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, INLCR, LINUX_INLCR);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNCR, LINUX_IGNCR);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, ICRNL, LINUX_ICRNL);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXON, LINUX_IXON);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXANY, LINUX_IXANY);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXOFF, LINUX_IXOFF);
	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IMAXBEL, LINUX_IMAXBEL);

	lt->c_oflag = 0;
	lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, OPOST, LINUX_OPOST);
	lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, ONLCR, LINUX_ONLCR);
	lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, OXTABS, LINUX_XTABS);

	switch (bts->c_cflag & CSIZE) {
	case CS5:
		lt->c_cflag = LINUX_CS5;
		break;
	case CS6:
		lt->c_cflag = LINUX_CS6;
		break;
	case CS7:
		lt->c_cflag = LINUX_CS7;
		break;
	case CS8:
		lt->c_cflag = LINUX_CS8;
		break;
	}
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CSTOPB, LINUX_CSTOPB);
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CREAD, LINUX_CREAD);
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARENB, LINUX_PARENB);
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARODD, LINUX_PARODD);
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, HUPCL, LINUX_HUPCL);
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CLOCAL, LINUX_CLOCAL);
	lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CRTSCTS, LINUX_CRTSCTS);

	lt->c_lflag = 0;
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ISIG, LINUX_ISIG);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ICANON, LINUX_ICANON);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHO, LINUX_ECHO);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOE, LINUX_ECHOE);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOK, LINUX_ECHOK);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHONL, LINUX_ECHONL);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, NOFLSH, LINUX_NOFLSH);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, TOSTOP, LINUX_TOSTOP);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOCTL, LINUX_ECHOCTL);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOPRT, LINUX_ECHOPRT);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOKE, LINUX_ECHOKE);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, FLUSHO, LINUX_FLUSHO);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, PENDIN, LINUX_PENDIN);
	lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, IEXTEN, LINUX_IEXTEN);

	mask = LINUX_B9600;	/* XXX default value should this be 0? */
	for (i = 0; i < sizeof (linux_speeds) / sizeof (speed_t); i++) {
		if (bts->c_ospeed == linux_speeds[i]) {
			mask = linux_spmasks[i];
			break;
		}
	}
	lt->c_cflag |= mask;

	lt->c_cc[LINUX_VINTR] = bts->c_cc[VINTR];
	lt->c_cc[LINUX_VQUIT] = bts->c_cc[VQUIT];
	lt->c_cc[LINUX_VERASE] = bts->c_cc[VERASE];
	lt->c_cc[LINUX_VKILL] = bts->c_cc[VKILL];
	lt->c_cc[LINUX_VEOF] = bts->c_cc[VEOF];
	lt->c_cc[LINUX_VTIME] = bts->c_cc[VTIME];
	lt->c_cc[LINUX_VMIN] = bts->c_cc[VMIN];
	lt->c_cc[LINUX_VSWTC] = 0;

	/* XXX should be fixed someday */
	lt->c_line = 0;
}

static void
linux_termios_to_bsd_termios(lts, bts)
	struct linux_termios *lts;
	struct termios *bts;
{
	int index;

	bts->c_iflag = 0;
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNBRK, IGNBRK);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_BRKINT, BRKINT);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNPAR, IGNPAR);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_INPCK, INPCK);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_ISTRIP, ISTRIP);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_INLCR, INLCR);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNCR, IGNCR);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_ICRNL, ICRNL);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXON, IXON);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXANY, IXANY);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXOFF, IXOFF);
	bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IMAXBEL, IMAXBEL);

	bts->c_oflag = 0;
	bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_OPOST, OPOST);
	bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_ONLCR, ONLCR);
	bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_XTABS, OXTABS);

	bts->c_cflag = 0;
	switch (lts->c_cflag & LINUX_CSIZE) {
	case LINUX_CS5:
		bts->c_cflag = CS5;
		break;
	case LINUX_CS6:
		bts->c_cflag = CS6;
		break;
	case LINUX_CS7:
		bts->c_cflag = CS7;
		break;
	case LINUX_CS8:
		bts->c_cflag = CS8;
		break;
	}
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CSTOPB, CSTOPB);
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CREAD, CREAD);
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_PARENB, PARENB);
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_PARODD, PARODD);
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_HUPCL, HUPCL);
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CLOCAL, CLOCAL);
	bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CRTSCTS, CRTSCTS);

	bts->c_lflag = 0;
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ISIG, ISIG);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ICANON, ICANON);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHO, ECHO);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOE, ECHOE);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOK, ECHOK);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHONL, ECHONL);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_NOFLSH, NOFLSH);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_TOSTOP, TOSTOP);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOCTL, ECHOCTL);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOPRT, ECHOPRT);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOKE, ECHOKE);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_FLUSHO, FLUSHO);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_PENDIN, PENDIN);
	bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_IEXTEN, IEXTEN);

	index = lts->c_cflag & LINUX_CBAUD;
	if (index & LINUX_CBAUDEX)
		index = (index & ~LINUX_CBAUDEX) + LINUX_NSPEEDS - 1;
	bts->c_ispeed = bts->c_ospeed = linux_speeds[index];

	bts->c_cc[VINTR] = lts->c_cc[LINUX_VINTR];
	bts->c_cc[VQUIT] = lts->c_cc[LINUX_VQUIT];
	bts->c_cc[VERASE] = lts->c_cc[LINUX_VERASE];
	bts->c_cc[VKILL] = lts->c_cc[LINUX_VKILL];
	bts->c_cc[VEOF] = lts->c_cc[LINUX_VEOF];
	bts->c_cc[VTIME] = lts->c_cc[LINUX_VTIME];
	bts->c_cc[VMIN] = lts->c_cc[LINUX_VMIN];
	bts->c_cc[VEOL] = lts->c_cc[LINUX_VEOL];
	bts->c_cc[VEOL2] = lts->c_cc[LINUX_VEOL2];
	bts->c_cc[VWERASE] = lts->c_cc[LINUX_VWERASE];
	bts->c_cc[VSUSP] = lts->c_cc[LINUX_VSUSP];
	bts->c_cc[VSTART] = lts->c_cc[LINUX_VSTART];
	bts->c_cc[VSTOP] = lts->c_cc[LINUX_VSTOP];
	bts->c_cc[VLNEXT] = lts->c_cc[LINUX_VLNEXT];
	bts->c_cc[VDISCARD] = lts->c_cc[LINUX_VDISCARD];
	bts->c_cc[VREPRINT] = lts->c_cc[LINUX_VREPRINT];
}

static void
bsd_termios_to_linux_termios(bts, lts)
	struct termios *bts;
	struct linux_termios *lts;
{
	int i, mask;

	lts->c_iflag = 0;
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNPAR, LINUX_IGNPAR);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, INPCK, LINUX_INPCK);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, ISTRIP, LINUX_ISTRIP);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, INLCR, LINUX_INLCR);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNCR, LINUX_IGNCR);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, ICRNL, LINUX_ICRNL);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXON, LINUX_IXON);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXANY, LINUX_IXANY);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXOFF, LINUX_IXOFF);
	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IMAXBEL, LINUX_IMAXBEL);

	lts->c_oflag = 0;
	lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, OPOST, LINUX_OPOST);
	lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, ONLCR, LINUX_ONLCR);
	lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, OXTABS, LINUX_XTABS);

	switch (bts->c_cflag & CSIZE) {
	case CS5:
		lts->c_cflag = LINUX_CS5;
		break;
	case CS6:
		lts->c_cflag = LINUX_CS6;
		break;
	case CS7:
		lts->c_cflag = LINUX_CS7;
		break;
	case CS8:
		lts->c_cflag = LINUX_CS8;
		break;
	}
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS5, LINUX_CS5);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS6, LINUX_CS6);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS7, LINUX_CS7);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS8, LINUX_CS8);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CSTOPB, LINUX_CSTOPB);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CREAD, LINUX_CREAD);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARENB, LINUX_PARENB);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARODD, LINUX_PARODD);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, HUPCL, LINUX_HUPCL);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CLOCAL, LINUX_CLOCAL);
	lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CRTSCTS, LINUX_CRTSCTS);

	lts->c_lflag = 0;
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ISIG, LINUX_ISIG);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ICANON, LINUX_ICANON);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHO, LINUX_ECHO);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOE, LINUX_ECHOE);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOK, LINUX_ECHOK);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHONL, LINUX_ECHONL);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, NOFLSH, LINUX_NOFLSH);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, TOSTOP, LINUX_TOSTOP);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOCTL, LINUX_ECHOCTL);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOPRT, LINUX_ECHOPRT);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOKE, LINUX_ECHOKE);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, FLUSHO, LINUX_FLUSHO);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, PENDIN, LINUX_PENDIN);
	lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, IEXTEN, LINUX_IEXTEN);

	mask = LINUX_B9600;	/* XXX default value */
	for (i = 0; i < sizeof (linux_speeds) / sizeof (speed_t); i++) {
		if (bts->c_ospeed == linux_speeds[i]) {
			mask = linux_spmasks[i];
			break;
		}
	}
	lts->c_cflag |= mask;

	lts->c_cc[LINUX_VINTR] = bts->c_cc[VINTR];
	lts->c_cc[LINUX_VQUIT] = bts->c_cc[VQUIT];
	lts->c_cc[LINUX_VERASE] = bts->c_cc[VERASE];
	lts->c_cc[LINUX_VKILL] = bts->c_cc[VKILL];
	lts->c_cc[LINUX_VEOF] = bts->c_cc[VEOF];
	lts->c_cc[LINUX_VTIME] = bts->c_cc[VTIME];
	lts->c_cc[LINUX_VMIN] = bts->c_cc[VMIN];
	lts->c_cc[LINUX_VEOL] = bts->c_cc[VEOL];
	lts->c_cc[LINUX_VEOL2] = bts->c_cc[VEOL2];
	lts->c_cc[LINUX_VWERASE] = bts->c_cc[VWERASE];
	lts->c_cc[LINUX_VSUSP] = bts->c_cc[VSUSP];
	lts->c_cc[LINUX_VSTART] = bts->c_cc[VSTART];
	lts->c_cc[LINUX_VSTOP] = bts->c_cc[VSTOP];
	lts->c_cc[LINUX_VLNEXT] = bts->c_cc[VLNEXT];
	lts->c_cc[LINUX_VDISCARD] = bts->c_cc[VDISCARD];
	lts->c_cc[LINUX_VREPRINT] = bts->c_cc[VREPRINT];
	lts->c_cc[LINUX_VSWTC] = 0;

	/* XXX should be fixed someday */
	lts->c_line = 0;
}

int
linux_ioctl_termios(p, v, retval)
	struct proc *p;
	void *v;
	register_t *retval;
{
	struct linux_sys_ioctl_args /* {
		syscallarg(int) fd;
		syscallarg(u_long) com;
		syscallarg(caddr_t) data;
	} */ *uap = v;
	struct file *fp;
	struct filedesc *fdp;
	u_long com;
	struct linux_termio tmplt;
	struct linux_termios tmplts;
	struct termios tmpbts;
	caddr_t sg;
	int idat;
	struct sys_ioctl_args ia;
	char tioclinux;
	int error = 0;

	fdp = p->p_fd;
	if ((fp = fd_getfile_mode(fdp, SCARG(uap, fd), FREAD|FWRITE)) == NULL)
		return (EBADF);
	FREF(fp);

	com = SCARG(uap, com);
	retval[0] = 0;

	switch (com) {
	case LINUX_TCGETS:
		error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts,
		    p);
		if (error)
			goto out;
		bsd_termios_to_linux_termios(&tmpbts, &tmplts);
		error = copyout(&tmplts, SCARG(uap, data), sizeof tmplts);
		goto out;
	case LINUX_TCSETS:
	case LINUX_TCSETSW:
	case LINUX_TCSETSF:
		/*
		 * First fill in all fields, so that we keep the current
		 * values for fields that Linux doesn't know about.
		 */
		error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts,
		    p);
		if (error)
			goto out;
		error = copyin(SCARG(uap, data), &tmplts, sizeof tmplts);
		if (error)
			goto out;
		linux_termios_to_bsd_termios(&tmplts, &tmpbts);
		switch (com) {
		case LINUX_TCSETS:
			com = TIOCSETA;
			break;
		case LINUX_TCSETSW:
			com = TIOCSETAW;
			break;
		case LINUX_TCSETSF:
			com = TIOCSETAF;
			break;
		}
		error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&tmpbts, p);
		goto out;
	case LINUX_TCGETA:
		error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts,
		    p);
		if (error)
			goto out;
		bsd_termios_to_linux_termio(&tmpbts, &tmplt);
		error = copyout(&tmplt, SCARG(uap, data), sizeof tmplt);
		goto out;
	case LINUX_TCSETA:
	case LINUX_TCSETAW:
	case LINUX_TCSETAF:
		/*
		 * First fill in all fields, so that we keep the current
		 * values for fields that Linux doesn't know about.
		 */
		error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts,
		    p);
		if (error)
			goto out;
		error = copyin(SCARG(uap, data), &tmplt, sizeof tmplt);
		if (error)
			goto out;
		linux_termio_to_bsd_termios(&tmplt, &tmpbts);
		switch (com) {
		case LINUX_TCSETA:
			com = TIOCSETA;
			break;
		case LINUX_TCSETAW:
			com = TIOCSETAW;
			break;
		case LINUX_TCSETAF:
			com = TIOCSETAF;
			break;
		}
		error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&tmpbts, p);
		goto out;
	case LINUX_TIOCGETD:
		error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETD, (caddr_t)&idat, p);
		if (error)
			goto out;
		switch (idat) {
		case TTYDISC:
			idat = LINUX_N_TTY;
			break;
		case SLIPDISC:
			idat = LINUX_N_SLIP;
			break;
		case PPPDISC:
			idat = LINUX_N_PPP;
			break;
		/*
		 * Linux does not have the tablet line discipline.
		 */
		case TABLDISC:
		default:
			idat = -1;	/* XXX What should this be? */
			break;
		}
		error = copyout(&idat, SCARG(uap, data), sizeof idat);
		goto out;
	case LINUX_TIOCSETD:
		error = copyin(SCARG(uap, data), &idat, sizeof idat);
		if (error)
			goto out;
		switch (idat) {
		case LINUX_N_TTY:
			idat = TTYDISC;
			break;
		case LINUX_N_SLIP:
			idat = SLIPDISC;
			break;
		case LINUX_N_PPP:
			idat = PPPDISC;
			break;
		/*
		 * We can't handle the mouse line discipline Linux has.
		 */
		case LINUX_N_MOUSE:
		default:
			error = EINVAL;
			goto out;
		}
		error = (*fp->f_ops->fo_ioctl)(fp, TIOCSETD, (caddr_t)&idat, p);
		goto out;
	case LINUX_TIOCLINUX:
		error = copyin(SCARG(uap, data), &tioclinux, sizeof tioclinux);
		if (error != 0)
			goto out;
		switch (tioclinux) {
		case LINUX_TIOCLINUX_KERNMSG:
			/*
			 * XXX needed to not fail for some things. Could
			 * try to use TIOCCONS, but the char argument
			 * specifies the VT #, not an fd.
			 */
			goto out;
		case LINUX_TIOCLINUX_COPY:
		case LINUX_TIOCLINUX_PASTE:
		case LINUX_TIOCLINUX_UNBLANK:
		case LINUX_TIOCLINUX_LOADLUT:
		case LINUX_TIOCLINUX_READSHIFT:
		case LINUX_TIOCLINUX_READMOUSE:
		case LINUX_TIOCLINUX_VESABLANK:
		case LINUX_TIOCLINUX_CURCONS:	/* could use VT_GETACTIVE */
			error = EINVAL;
			goto out;
		}
		break;
	case LINUX_TIOCGWINSZ:
		SCARG(&ia, com) = TIOCGWINSZ;
		break;
	case LINUX_TIOCSWINSZ:
		SCARG(&ia, com) = TIOCSWINSZ;
		break;
	case LINUX_TIOCMGET:
		SCARG(&ia, com) = TIOCMGET;
		break;
	case LINUX_TIOCMBIS:
		SCARG(&ia, com) = TIOCMBIS;
		break;
	case LINUX_TIOCMBIC:
		SCARG(&ia, com) = TIOCMBIC;
		break;
	case LINUX_TIOCMSET:
		SCARG(&ia, com) = TIOCMSET;
		break;
	case LINUX_TIOCGPGRP:
		SCARG(&ia, com) = TIOCGPGRP;
		break;
	case LINUX_TIOCSPGRP:
		SCARG(&ia, com) = TIOCSPGRP;
		break;
	case LINUX_FIONREAD:
		SCARG(&ia, com) = FIONREAD;
		break;
	case LINUX_FIONBIO:
		SCARG(&ia, com) = FIONBIO;
		break;
	case LINUX_FIOASYNC:
		SCARG(&ia, com) = FIOASYNC;
		break;
	case LINUX_TIOCEXCL:
		SCARG(&ia, com) = TIOCEXCL;
		break;
	case LINUX_TIOCNXCL:
		SCARG(&ia, com) = TIOCNXCL;
		break;
	case LINUX_TIOCSCTTY:
		SCARG(&ia, com) = TIOCSCTTY;
		break;
	case LINUX_TIOCCONS:
		SCARG(&ia, com) = TIOCCONS;
		break;
	case LINUX_TIOCNOTTY:
		SCARG(&ia, com) = TIOCNOTTY;
		break;
	case LINUX_TCSBRK:
		SCARG(&ia, com) = SCARG(uap, data) ? TIOCDRAIN : TIOCSBRK;
		break;
	case LINUX_TCXONC:
		switch ((int)SCARG(uap, data)) {
		case LINUX_TCOOFF:
			SCARG(&ia, com) = TIOCSTOP;
			break;
		case LINUX_TCOON:
			SCARG(&ia, com) = TIOCSTART;
			break;
		case LINUX_TCIOFF:
		case LINUX_TCION: {
			u_char c, *cp;
			struct sys_write_args wa;

			error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA,
			    (caddr_t)&tmpbts, p);
			if (error)
				goto out;
			if ((int)SCARG(uap, data) == LINUX_TCIOFF)
				c = tmpbts.c_cc[VSTOP];
			else
				c = tmpbts.c_cc[VSTART];
			if (c == _POSIX_VDISABLE)
				goto out;

			sg = stackgap_init(p);
			cp = (char *) stackgap_alloc(&sg, 1);
			if ((error = copyout(&c, cp, 1)))
				goto out;

			SCARG(&wa, fd) = SCARG(uap, fd);
			SCARG(&wa, buf) = cp;
			SCARG(&wa, nbyte) = 1;
			error = sys_write(p, &wa, retval);
			goto out;
		    }
		default:
			error = EINVAL;
			goto out;
		}
		SCARG(uap, data) = 0;
		break;
	default:
		error = EINVAL;
		goto out;
	}

	SCARG(&ia, fd) = SCARG(uap, fd);
	SCARG(&ia, data) = SCARG(uap, data);
	error = sys_ioctl(p, &ia, retval);

out:
	FRELE(fp, p);
	return (error);
}


code:
/*	$OpenBSD: linux_termios.h,v 1.4 2002/05/07 20:23:42 jasoni Exp $	*/

#define LINUX_TCGETS		_LINUX_IO('T', 1)
#define LINUX_TCSETS		_LINUX_IO('T', 2)
#define LINUX_TCSETSW		_LINUX_IO('T', 3)
#define LINUX_TCSETSF		_LINUX_IO('T', 4)
#define LINUX_TCGETA		_LINUX_IO('T', 5)
#define LINUX_TCSETA		_LINUX_IO('T', 6)
#define LINUX_TCSETAW		_LINUX_IO('T', 7)
#define LINUX_TCSETAF		_LINUX_IO('T', 8)
#define LINUX_TCSBRK		_LINUX_IO('T', 9)
#define LINUX_TCXONC		_LINUX_IO('T', 10)
#define LINUX_TCFLSH		_LINUX_IO('T', 11)
#define LINUX_TIOCEXCL		_LINUX_IO('T', 12)
#define LINUX_TIOCNXCL		_LINUX_IO('T', 13)
#define LINUX_TIOCSCTTY		_LINUX_IO('T', 14)
#define LINUX_TIOCGPGRP		_LINUX_IO('T', 15)
#define LINUX_TIOCSPGRP		_LINUX_IO('T', 16)
#define LINUX_TIOCOUTQ		_LINUX_IO('T', 17)
#define LINUX_TIOCSTI		_LINUX_IO('T', 18)
#define LINUX_TIOCGWINSZ	_LINUX_IO('T', 19)
#define LINUX_TIOCSWINSZ	_LINUX_IO('T', 20)
#define LINUX_TIOCMGET		_LINUX_IO('T', 21)
#define LINUX_TIOCMBIS		_LINUX_IO('T', 22)
#define LINUX_TIOCMBIC		_LINUX_IO('T', 23)
#define LINUX_TIOCMSET		_LINUX_IO('T', 24)
#define LINUX_TIOCGSOFTCAR	_LINUX_IO('T', 25)
#define LINUX_TIOCSSOFTCAR	_LINUX_IO('T', 26)
#define LINUX_FIONREAD		_LINUX_IO('T', 27)
#define LINUX_TIOCINQ		LINUX_FIONREAD
#define LINUX_TIOCLINUX		_LINUX_IO('T', 28)
#define LINUX_TIOCCONS		_LINUX_IO('T', 29)
#define LINUX_TIOCGSERIAL	_LINUX_IO('T', 30)
#define LINUX_TIOCSSERIAL	_LINUX_IO('T', 31)
#define LINUX_TIOCPKT		_LINUX_IO('T', 32)
#define LINUX_FIONBIO		_LINUX_IO('T', 33)
#define LINUX_TIOCNOTTY		_LINUX_IO('T', 34)
#define LINUX_TIOCSETD		_LINUX_IO('T', 35)
#define LINUX_TIOCGETD		_LINUX_IO('T', 36)
#define LINUX_TCSBRKP		_LINUX_IO('T', 37)
#define LINUX_TIOCTTYGSTRUCT	_LINUX_IO('T', 38)

#define LINUX_FIONCLEX		_LINUX_IO('T', 80)
#define LINUX_FIOCLEX		_LINUX_IO('T', 81)
#define LINUX_FIOASYNC		_LINUX_IO('T', 82)
#define LINUX_TIOCSERCONFIG	_LINUX_IO('T', 83)
#define LINUX_TIOCSERGWILD	_LINUX_IO('T', 84)
#define LINUX_TIOCSERSWILD	_LINUX_IO('T', 85)
#define LINUX_TIOCGLCKTRMIOS	_LINUX_IO('T', 86)
#define LINUX_TIOCSLCKTRMIOS	_LINUX_IO('T', 87)
#define LINUX_TIOCSERGSTRUCT	_LINUX_IO('T', 88)
#define LINUX_TIOCSERGETLSR	_LINUX_IO('T', 89)

#define LINUX_NCC 8
struct linux_termio {
	unsigned short c_iflag;
	unsigned short c_oflag;
	unsigned short c_cflag;
	unsigned short c_lflag;
	unsigned char c_line;
	unsigned char c_cc[LINUX_NCC];
};

typedef unsigned char linux_cc_t;
typedef unsigned long linux_tcflag_t;

#define LINUX_NCCS 19
struct linux_termios {
	linux_tcflag_t c_iflag;
	linux_tcflag_t c_oflag;
	linux_tcflag_t c_cflag;
	linux_tcflag_t c_lflag;
	linux_cc_t c_line;
	linux_cc_t c_cc[LINUX_NCCS];
};

/* Just in old style linux_termio struct */
#define LINUX_VINTR 0
#define LINUX_VQUIT 1
#define LINUX_VERASE 2
#define LINUX_VKILL 3
#define LINUX_VEOF 4
#define LINUX_VTIME 5
#define LINUX_VMIN 6
#define LINUX_VSWTC 7

/* In the termios struct too */
#define LINUX_VSTART 8
#define LINUX_VSTOP 9
#define LINUX_VSUSP 10
#define LINUX_VEOL 11
#define LINUX_VREPRINT 12
#define LINUX_VDISCARD 13
#define LINUX_VWERASE 14
#define LINUX_VLNEXT 15
#define LINUX_VEOL2 16

/* Linux c_iflag masks */
#define LINUX_IGNBRK	0x0000001
#define LINUX_BRKINT	0x0000002
#define LINUX_IGNPAR	0x0000004
#define LINUX_PARMRK	0x0000008
#define LINUX_INPCK	0x0000010
#define LINUX_ISTRIP	0x0000020
#define LINUX_INLCR	0x0000040
#define LINUX_IGNCR	0x0000080
#define LINUX_ICRNL	0x0000100
#define LINUX_IUCLC	0x0000200
#define LINUX_IXON	0x0000400
#define LINUX_IXANY	0x0000800
#define LINUX_IXOFF	0x0001000
#define LINUX_IMAXBEL	0x0002000

/* Linux c_oflag masks */
#define LINUX_OPOST	0x0000001
#define LINUX_OLCUC	0x0000002
#define LINUX_ONLCR	0x0000004
#define LINUX_OCRNL	0x0000008
#define LINUX_ONOCR	0x0000010
#define LINUX_ONLRET	0x0000020
#define LINUX_OFILL	0x0000040
#define LINUX_OFDEL	0x0000080
#define LINUX_NLDLY	0x0000100

#define LINUX_NL0	0x0000000
#define LINUX_NL1	0x0000100
#define LINUX_CRDLY	0x0000600
#define LINUX_CR0	0x0000000
#define LINUX_CR1	0x0000200
#define LINUX_CR2	0x0000400
#define LINUX_CR3	0x0000600
#define LINUX_TABDLY	0x0001800
#define LINUX_TAB0	0x0000000
#define LINUX_TAB1	0x0000800
#define LINUX_TAB2	0x0001000
#define LINUX_TAB3	0x0001800
#define LINUX_XTABS	0x0001800
#define LINUX_BSDLY	0x0002000
#define LINUX_BS0	0x0000000
#define LINUX_BS1	0x0002000
#define LINUX_VTDLY	0x0004000
#define LINUX_VT0	0x0000000
#define LINUX_VT1	0x0004000
#define LINUX_FFDLY	0x0008000
#define LINUX_FF0	0x0000000
#define LINUX_FF1	0x0008000

/* Linux c_cflag bit masks */

#define LINUX_NSPEEDS   16
#define LINUX_NXSPEEDS   2

#define LINUX_CBAUD	0x0000100f

#define LINUX_B0	0x00000000
#define LINUX_B50	0x00000001
#define LINUX_B75	0x00000002
#define LINUX_B110	0x00000003
#define LINUX_B134	0x00000004
#define LINUX_B150	0x00000005
#define LINUX_B200	0x00000006
#define LINUX_B300	0x00000007
#define LINUX_B600	0x00000008
#define LINUX_B1200	0x00000009
#define LINUX_B1800	0x0000000a
#define LINUX_B2400	0x0000000b
#define LINUX_B4800	0x0000000c
#define LINUX_B9600	0x0000000d
#define LINUX_B19200	0x0000000e
#define LINUX_B38400	0x0000000f
#define LINUX_EXTA	LINUX_B19200
#define LINUX_EXTB	LINUX_B38400
#define LINUX_CBAUDEX	0x00001000
#define LINUX_B57600	0x00001001
#define LINUX_B115200	0x00001002
#define LINUX_B230400	0x00001003

#define LINUX_CSIZE	0x00000030
#define LINUX_CS5	0x00000000
#define LINUX_CS6	0x00000010
#define LINUX_CS7	0x00000020
#define LINUX_CS8	0x00000030
#define LINUX_CSTOPB	0x00000040
#define LINUX_CREAD	0x00000080
#define LINUX_PARENB	0x00000100
#define LINUX_PARODD	0x00000200
#define LINUX_HUPCL	0x00000400
#define LINUX_CLOCAL	0x00000800

#define LINUX_CRTSCTS	0x80000000

/* Linux c_lflag masks */
#define LINUX_ISIG	0x00000001
#define LINUX_ICANON	0x00000002
#define LINUX_XCASE	0x00000004
#define LINUX_ECHO	0x00000008
#define LINUX_ECHOE	0x00000010
#define LINUX_ECHOK	0x00000020
#define LINUX_ECHONL	0x00000040
#define LINUX_NOFLSH	0x00000080
#define LINUX_TOSTOP	0x00000100
#define LINUX_ECHOCTL	0x00000200
#define LINUX_ECHOPRT	0x00000400
#define LINUX_ECHOKE	0x00000800
#define LINUX_FLUSHO	0x00001000
#define LINUX_PENDIN	0x00002000
#define LINUX_IEXTEN	0x00008000

/* Linux modem line defines.. not sure if they'll be used */
#define LINUX_TIOCM_LE		0x0001
#define LINUX_TIOCM_DTR		0x0002
#define LINUX_TIOCM_RTS		0x0004
#define LINUX_TIOCM_ST		0x0008
#define LINUX_TIOCM_SR		0x0010
#define LINUX_TIOCM_CTS		0x0020
#define LINUX_TIOCM_CAR		0x0040
#define LINUX_TIOCM_RNG		0x0080
#define LINUX_TIOCM_DSR		0x0100
#define LINUX_TIOCM_CD		LINUX_TIOCM_CAR
#define LINUX_TIOCM_RI 		LINUX_TIOCM_RNG

#define	LINUX_TCIFLUSH		0
#define	LINUX_TCOFLUSH		1
#define	LINUX_TCIOFLUSH		2

#define	LINUX_TCOOFF		0
#define	LINUX_TCOON		1
#define	LINUX_TCIOFF		2
#define	LINUX_TCION		3

#define	LINUX_TCSANOW		0
#define	LINUX_TCSADRAIN		1
#define	LINUX_TCSAFLUSH		2

/* Linux line disciplines */
#define LINUX_N_TTY		0
#define LINUX_N_SLIP		1
#define LINUX_N_MOUSE		2
#define LINUX_N_PPP		3

/* values passed to TIOCLINUX ioctl */
#define LINUX_TIOCLINUX_COPY		 2
#define LINUX_TIOCLINUX_PASTE		 3
#define LINUX_TIOCLINUX_UNBLANK		 4
#define LINUX_TIOCLINUX_LOADLUT		 5
#define LINUX_TIOCLINUX_READSHIFT	 6
#define LINUX_TIOCLINUX_READMOUSE	 7
#define LINUX_TIOCLINUX_VESABLANK	10
#define LINUX_TIOCLINUX_KERNMSG		11
#define LINUX_TIOCLINUX_CURCONS		12

license: unknown


code:
/*	$OpenBSD: linux_time.c,v 1.5 2013/10/25 04:51:39 guenther Exp $	*/
/*
 * Copyright (c) 2010, 2011 Paul Irofti <pirofti@openbsd.org>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#include <sys/signal.h>
#include <sys/stdint.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kernel.h>

#include <sys/syscallargs.h>

#include <compat/linux/linux_types.h>
#include <compat/linux/linux_fcntl.h>
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_mmap.h>
#include <compat/linux/linux_sched.h>
#include <compat/linux/linux_signal.h>
#include <compat/linux/linux_syscallargs.h>
#include <compat/linux/linux_util.h>
#include <compat/linux/linux_dirent.h>
#include <compat/linux/linux_emuldata.h>

#include <compat/linux/linux_time.h>

#define LINUX_CLOCK_REALTIME            0
#define LINUX_CLOCK_MONOTONIC           1
#define LINUX_CLOCK_PROCESS_CPUTIME_ID  2
#define LINUX_CLOCK_THREAD_CPUTIME_ID   3

int
bsd_to_linux_timespec(struct linux_timespec *ltp, const struct timespec *ntp)
{
	if (ntp->tv_sec > LINUX_TIME_MAX)
		return EOVERFLOW;
	ltp->tv_sec = ntp->tv_sec;
	ltp->tv_nsec = ntp->tv_nsec;
	return 0;
}

void
linux_to_bsd_timespec(struct timespec *ntp, const struct linux_timespec *ltp)
{
	ntp->tv_sec = ltp->tv_sec;
	ntp->tv_nsec = ltp->tv_nsec;
}

int
bsd_to_linux_itimerval(struct linux_itimerval *ltp,
    const struct itimerval *ntp)
{
	int error;

	error = bsd_to_linux_timeval(&ltp->it_interval, &ntp->it_interval);
	if (error)
		return (error);
	return (bsd_to_linux_timeval(&ltp->it_value, &ntp->it_value));
}

void
linux_to_bsd_itimerval(struct itimerval *ntp,
    const struct linux_itimerval *ltp)
{
	linux_to_bsd_timeval(&ntp->it_interval, &ltp->it_interval);
	linux_to_bsd_timeval(&ntp->it_value,    &ltp->it_value);
}

int
linux_to_bsd_clockid(clockid_t *n, clockid_t l)
{
	switch (l) {
	case LINUX_CLOCK_REALTIME:
		*n = CLOCK_REALTIME;
		break;
	case LINUX_CLOCK_MONOTONIC:
		*n = CLOCK_MONOTONIC;
		break;
	case LINUX_CLOCK_PROCESS_CPUTIME_ID:
		*n = CLOCK_PROCESS_CPUTIME_ID;
		break;
	case LINUX_CLOCK_THREAD_CPUTIME_ID:
		*n = CLOCK_THREAD_CPUTIME_ID;
		break;
	default:
		return (EINVAL);
		break;
	}

	return (0);
}

int
linux_sys_clock_getres(struct proc *p, void *v, register_t *retval)
{
	struct linux_sys_clock_getres_args *uap = v;
	struct linux_timespec ltp;
	clockid_t clockid;
	int error;

	if (SCARG(uap, tp) == NULL)
	  	return 0;

	error = linux_to_bsd_clockid(&clockid, SCARG(uap, which));
	if (error != 0)
		return error;

	/* ahhh, just give a good guess */
	ltp.tv_sec = 0;
	ltp.tv_nsec = 1000000000 / hz;

	return (copyout(&ltp, SCARG(uap, tp), sizeof ltp));
}

int
linux_sys_clock_gettime(struct proc *p, void *v, register_t *retval)
{
	struct linux_sys_clock_gettime_args *uap = v;
	struct timespec tp;
	struct linux_timespec ltp;
	clockid_t clockid;
	int error;

	error = linux_to_bsd_clockid(&clockid, SCARG(uap, which));
	if (error != 0)
		return error;

	error = clock_gettime(p, clockid, &tp);
	if (error != 0)
		return error;

	error = bsd_to_linux_timespec(&ltp, &tp);
	if (error != 0)
		return error;

	return (copyout(&ltp, SCARG(uap, tp), sizeof ltp));
}

int
linux_sys_nanosleep(struct proc *p, void *v, register_t *retval)
{
	static int nanowait;
	struct linux_sys_nanosleep_args /* {
		syscallarg(const struct linux_timespec *) rqtp;
		syscallarg(struct linux_timespec *) rmtp;
	} */ *uap = v;
	struct linux_timespec lts;
	struct timespec rqt, rmt;
	struct timespec sts, ets;
	struct linux_timespec *rmtp;
	struct timeval tv;
	int error, error1;

	rmtp = SCARG(uap, rmtp);
	error = copyin(SCARG(uap, rqtp), &lts, sizeof(lts));
	if (error)
		return (error);
	linux_to_bsd_timespec(&rqt, &lts);

	TIMESPEC_TO_TIMEVAL(&tv, &rqt);
	if (itimerfix(&tv))
		return (EINVAL);

	if (rmtp)
		getnanouptime(&sts);

	error = tsleep(&nanowait, PWAIT | PCATCH, "nanosleep",
	    MAX(1, tvtohz(&tv)));
	if (error == ERESTART)
		error = EINTR;
	if (error == EWOULDBLOCK)
		error = 0;

	if (rmtp) {
		getnanouptime(&ets);

		timespecsub(&ets, &sts, &sts);
		timespecsub(&rqt, &sts, &rmt);

		if (rmt.tv_sec < 0)
			timespecclear(&rmt);

		if ((error1 = bsd_to_linux_timespec(&lts, &rmt)) ||
		    (error1 = copyout(&lts, rmtp, sizeof(lts))))
			error = error1;
	}

	return error;
}

int
linux_sys_gettimeofday(struct proc *p, void *v, register_t *retval)
{
	struct linux_sys_gettimeofday_args /* {
		syscallarg(struct linux_timeval *) tp;
		syscallarg(struct timezone *) tzp;
	} */ *uap = v;
	struct timeval atv;
	struct linux_timeval latv;
	struct linux_timeval *tp;
	struct timezone *tzp;
	int error = 0;

	tp = SCARG(uap, tp);
	tzp = SCARG(uap, tzp);

	if (tp) {
		microtime(&atv);
		if ((error = bsd_to_linux_timeval(&latv, &atv)) ||
		    (error = copyout(&latv, tp, sizeof (latv))))
			return (error);
	}
	if (tzp)
		error = copyout(&tz, tzp, sizeof (tz));
	return (error);
}

int
linux_sys_getitimer(struct proc *p, void *v, register_t *retval)
{
	struct linux_sys_getitimer_args /* {
		syscallarg(int) which;
		syscallarg(struct linux_itimerval *) itv;
	} */ *uap = v;
	struct itimerval aitv;
	struct linux_itimerval laitv;
	int s, which, error;

	which = SCARG(uap, which);

	if (which < ITIMER_REAL || which > ITIMER_PROF)
		return (EINVAL);
	s = splclock();
	aitv = p->p_p->ps_timer[which];

	if (which == ITIMER_REAL) {
		struct timeval now;

		getmicrouptime(&now);
		/*
		 * Convert from absolute to relative time in .it_value
		 * part of real time timer.  If time for real time timer
		 * has passed return 0, else return difference between
		 * current time and time for the timer to go off.
		 */
		if (timerisset(&aitv.it_value)) {
			if (timercmp(&aitv.it_value, &now, <))
				timerclear(&aitv.it_value);
			else
				timersub(&aitv.it_value, &now,
				    &aitv.it_value);
		}
	}
	splx(s);
	if ((error = bsd_to_linux_itimerval(&laitv, &aitv)))
		return error;
	return (copyout(&laitv, SCARG(uap, itv), sizeof(laitv)));
}

int
linux_sys_setitimer(struct proc *p, void *v, register_t *retval)
{
	struct linux_sys_setitimer_args /* {
		syscallarg(int) which;
		syscallarg(const struct linux_itimerval *) itv;
		syscallarg(struct linux_itimerval *) oitv;
	} */ *uap = v;
	struct linux_sys_getitimer_args getargs;
	struct itimerval aitv;
	struct linux_itimerval laitv;
	const struct linux_itimerval *itvp;
	struct linux_itimerval *oitv;
	struct process *pr = p->p_p;
	int error;
	int timo;
	int which;

	which = SCARG(uap, which);
	itvp = SCARG(uap, itv);
	oitv = SCARG(uap, oitv);

	if (which < ITIMER_REAL || which > ITIMER_PROF)
		return (EINVAL);
	if (itvp && (error = copyin(itvp, &laitv, sizeof(laitv))))
		return (error);
	if (oitv != NULL) {
		SCARG(&getargs, which) = which;
		SCARG(&getargs, itv) = oitv;
		if ((error = linux_sys_getitimer(p, &getargs, retval)))
			return (error);
	}
	if (itvp == 0)
		return (0);
	linux_to_bsd_itimerval(&aitv, &laitv);
	if (itimerfix(&aitv.it_value) || itimerfix(&aitv.it_interval))
		return (EINVAL);
	if (which == ITIMER_REAL) {
		struct timeval ctv;

		timeout_del(&pr->ps_realit_to);
		getmicrouptime(&ctv);
		if (timerisset(&aitv.it_value)) {
			timo = tvtohz(&aitv.it_value);
			timeout_add(&pr->ps_realit_to, timo);
			timeradd(&aitv.it_value, &ctv, &aitv.it_value);
		}
		pr->ps_timer[ITIMER_REAL] = aitv;
	} else {
		int s;

		itimerround(&aitv.it_interval);
		s = splclock();
		pr->ps_timer[which] = aitv;
		splx(s);
	}

	return (0);
}


code:
/*	$OpenBSD: linux_time.h,v 1.4 2013/10/25 04:51:39 guenther Exp $	*/
/*
 * Copyright (c) 2011 Paul Irofti <pirofti@openbsd.org>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _LINUX_TIME_H_
#define _LINUX_TIME_H_

/* BSD to linux can fail with EOVERFLOW */
int	bsd_to_linux_timespec(struct linux_timespec *,
	    const struct timespec *);
int	bsd_to_linux_itimerval(struct linux_itimerval *,
	    const struct itimerval *);

/* linux to BSD can't fail for time_t-based stuff, but can for clockid_t */
void	linux_to_bsd_timespec(struct timespec *,
	    const struct linux_timespec *);
void	linux_to_bsd_itimerval(struct itimerval *,
	    const struct linux_itimerval *);
int	linux_to_bsd_clockid(clockid_t *, clockid_t);

/* the timespec conversion functions also handle timeval */
static inline int
bsd_to_linux_timeval(struct linux_timeval *ltp, const struct timeval *ntp)
{
	return (bsd_to_linux_timespec((void *)ltp, (const void *)ntp));
}
static inline void
linux_to_bsd_timeval(struct timeval *ntp, const struct linux_timeval *ltp)
{
	linux_to_bsd_timespec((void *)ntp, (const void *)ltp);
}

#endif


code:
/*	$OpenBSD: linux_types.h,v 1.14 2014/09/08 01:47:06 guenther Exp $	*/
/*	$NetBSD: linux_types.h,v 1.5 1996/05/20 01:59:28 fvdl Exp $	*/

/*
 * Copyright (c) 1995 Frank van der Linden
 * All rights reserved.
 *
 * 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 for the NetBSD Project
 *      by Frank van der Linden
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
 */

#ifndef _LINUX_TYPES_H_
#define _LINUX_TYPES_H_

typedef struct {
	long	val[2];
} linux_fsid_t;

typedef unsigned short linux_uid_t;
typedef unsigned short linux_gid_t;
typedef unsigned short linux_dev_t;
typedef unsigned long long linux_ino64_t;
typedef unsigned long linux_ino_t;
typedef unsigned short linux_mode_t;
typedef unsigned short linux_nlink_t;
typedef long linux_time_t;
typedef long linux_clock_t;
typedef long long linux_off64_t;
typedef long linux_off_t;
typedef u_int64_t linux_loff_t;
typedef int linux_pid_t;

#define LINUX_TIME_MAX	LONG_MAX
#define LINUX_INO_MAX	ULONG_MAX
#define LINUX_INO64_MAX	ULLONG_MAX

#define LINUX_FSTYPE_FFS	0x11954
#define LINUX_FSTYPE_NFS	0x6969
#define LINUX_FSTYPE_MSDOS	0x4d44
#define LINUX_FSTYPE_EXT2FS	0xef53
#define LINUX_FSTYPE_CD9660	0x9660
#define LINUX_FSTYPE_NCPFS	0x6969
#define LINUX_FSTYPE_NTFS	0x5346544e	/* "NTFS" */
#define LINUX_FSTYPE_UDF	0x15013346
#define LINUX_FSTYPE_AFS	0x5346414f

/*
 * Linux version of time-based structures, passed to many system calls
 */
struct linux_timespec {
	linux_time_t	tv_sec;
	long		tv_nsec;
};

struct linux_timeval {
	linux_time_t	tv_sec;
	long		tv_usec;
};

struct linux_itimerval {
	struct linux_timeval	it_interval;
	struct linux_timeval	it_value;
};

/*
 * Passed to the statfs(2) system call family
 */
struct linux_statfs {
	long		l_ftype;
	long		l_fbsize;
	long		l_fblocks;
	long		l_fbfree;
	long		l_fbavail;
	long		l_ffiles;
	long		l_fffree;
	linux_fsid_t	l_ffsid;
	long		l_fnamelen;
	long		l_fspare[6];
};

struct linux_statfs64 {
        int		l_ftype;
        int		l_fbsize;
        uint64_t	l_fblocks;
        uint64_t	l_fbfree;
        uint64_t	l_fbavail;
        uint64_t	l_ffiles;
        uint64_t	l_fffree;
        linux_fsid_t	l_ffsid;
        int		l_fnamelen;
        int		l_fspare[6];
};

/*
 * Passed to the uname(2) system call
 */
struct linux_utsname {
	char l_sysname[65];
	char l_nodename[65];
	char l_release[65];
	char l_version[65];
	char l_machine[65];
	char l_domainname[65];
};

struct linux_oldutsname {
	char l_sysname[65];
	char l_nodename[65];
	char l_release[65];
	char l_version[65];
	char l_machine[65];
};

struct linux_oldoldutsname {
	char l_sysname[9];
	char l_nodename[9];
	char l_release[9];
	char l_version[9];
	char l_machine[9];
};

/*
 * Passed to the mmap() system call
 */
struct linux_mmap {
	caddr_t lm_addr;
	int lm_len;
	int lm_prot;
	int lm_flags;
	int lm_fd;
	int lm_pos;
};

/*
 * Passed to the select() system call
 */
struct linux_select {
	int nfds;
	fd_set *readfds;
	fd_set *writefds;
	fd_set *exceptfds;
	struct linux_timeval *timeout;
};

struct linux_stat {
	linux_dev_t		lst_dev;
	unsigned short		pad1;
	linux_ino_t		lst_ino;
	linux_mode_t		lst_mode;
	linux_nlink_t		lst_nlink;
	linux_uid_t		lst_uid;
	linux_gid_t		lst_gid;
	linux_dev_t		lst_rdev;
	unsigned short		pad2;
	linux_off_t		lst_size;
	unsigned long		lst_blksize;
	unsigned long		lst_blocks;
	linux_time_t		lst_atime;
	unsigned long		unused1;
	linux_time_t		lst_mtime;
	unsigned long		unused2;
	linux_time_t		lst_ctime;
	unsigned long		unused3;
	unsigned long		unused4;
	unsigned long		unused5;
};

struct linux_tms {
	linux_clock_t ltms_utime;
	linux_clock_t ltms_stime;
	linux_clock_t ltms_cutime;
	linux_clock_t ltms_cstime;
};

struct linux_utimbuf {
	linux_time_t l_actime;
	linux_time_t l_modtime;
};

struct linux___sysctl {
	int          *name;
	int           namelen;
	void         *old;
	size_t       *oldlenp;
	void         *new;
	size_t        newlen;
	unsigned long __unused0[4];
};

/* This matches struct stat64 in glibc2.1, hence the absolutely
 * insane amounts of padding around dev_t's.
 */
struct linux_stat64 {
	unsigned long long lst_dev;
	unsigned int	__pad1;

#define LINUX_STAT64_HAS_BROKEN_ST_INO	1
	linux_ino_t	__lst_ino;
	unsigned int	lst_mode;
	unsigned int	lst_nlink;

	unsigned int	lst_uid;
	unsigned int	lst_gid;

	unsigned long long lst_rdev;
	unsigned int	__pad2;

	long long	lst_size;
	unsigned int	lst_blksize;

	unsigned long long lst_blocks;	/* Number 512-byte blocks allocated. */

	unsigned int	lst_atime;
	unsigned int	__unused1;

	unsigned int	lst_mtime;
	unsigned int	__unused2;

	unsigned int	lst_ctime;
	unsigned int	__unused3;	/* will be high 32 bits of ctime someday */

	linux_ino64_t	lst_ino;
};

#endif /* !_LINUX_TYPES_H_ */


code:
/*	$OpenBSD: linux_util.h,v 1.2 1996/04/17 05:24:11 mickey Exp $	*/
/*	$NetBSD: linux_util.h,v 1.5 1995/06/24 20:20:42 christos Exp $	*/

/*
 * Copyright (c) 1994 Christos Zoulas
 * Copyright (c) 1995 Frank van der Linden
 * All rights reserved.
 *
 * 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. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
 *
 */

#ifndef	_LINUX_UTIL_H_
#define	_LINUX_UTIL_H_

#include <compat/common/compat_util.h>

#define cvtto_linux_mask(flags,bmask,lmask) (((flags) & bmask) ? lmask : 0)
#define cvtto_bsd_mask(flags,lmask,bmask) (((flags) & lmask) ? bmask : 0)

extern const char linux_emul_path[];

#define LINUX_CHECK_ALT_EXIST(p, sgp, path) \
    CHECK_ALT_EXIST(p, sgp, linux_emul_path, path)

#define LINUX_CHECK_ALT_CREAT(p, sgp, path) \
    CHECK_ALT_CREAT(p, sgp, linux_emul_path, path)

#endif /* !_LINUX_UTIL_H_ */


code:
#	$OpenBSD: syscalls.conf,v 1.2 1996/04/17 05:24:12 mickey Exp $
#	$NetBSD: syscalls.conf,v 1.1 1995/02/28 23:26:24 fvdl Exp $

sysnames="linux_syscalls.c"
sysnumhdr="linux_syscall.h"
syssw="linux_sysent.c"
sysarghdr="linux_syscallargs.h"
compatopts=""
libcompatopts=""

switchname="linux_sysent"
namesname="linux_syscallnames"
constprefix="LINUX_SYS_"


code:
	$OpenBSD: syscalls.master,v 1.76 2014/09/01 05:09:53 doug Exp $
;	$NetBSD: syscalls.master,v 1.15 1995/12/18 14:35:10 fvdl Exp $

;	@(#)syscalls.master	8.1 (Berkeley) 7/19/93

; OpenBSD COMPAT_LINUX system call name/number "master" file.
; (See syscalls.conf to see what it is processed into.)
;
; Fields: number type [type-dependent ...]
;	number	system call number, must be in order
;	type	one of STD, OBSOL, UNIMPL, NODEF, NOARGS, or one of
;		the compatibility options defined in syscalls.conf.
;
; types:
;	STD	always included
;	OBSOL	obsolete, not included in system
;	UNIMPL	unimplemented, not included in system
;	NODEF	included, but don't define the syscall number
;	NOARGS	included, but don't define the syscall args structure
;
; The compat options are defined in the syscalls.conf file, and the
; compat option name is prefixed to the syscall name.  Other than
; that, they're like NODEF (for 'compat' options), or STD (for
; 'libcompat' options).
;
; The type-dependent arguments are as follows:
; For STD, NODEF, NOARGS, and compat syscalls:
;	{ pseudo-proto } [alias]
; For other syscalls:
;	[comment]
;
; #ifdef's, etc. may be included, and are copied to the output files.
; #include's are copied to the syscall switch definition file only.

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signal.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>

#include <compat/linux/linux_types.h>
#include <compat/linux/linux_signal.h>
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_syscallargs.h>

#include <machine/linux_machdep.h>

0	NOARGS		{ int sys_nosys(void); } syscall
1	NOARGS		{ int sys_exit(int rval); }
2	NOARGS		{ int sys_fork(void); }
3	NOARGS		{ int sys_read(int fd, char *buf, u_int nbyte); }
4	NOARGS		{ int sys_write(int fd, char *buf, u_int nbyte); }
5	STD		{ int linux_sys_open(char *path, int flags, int mode); }
6	NOARGS		{ int sys_close(int fd); }
7	STD		{ int linux_sys_waitpid(int pid, int *status, \
			    int options);}
8	STD		{ int linux_sys_creat(char *path, int mode); }
9	NOARGS		{ int sys_link(char *path, char *link); }
10	STD		{ int linux_sys_unlink(char *path); }
11	STD		{ int linux_sys_execve(char *path, char **argp, \
			    char **envp); }
12	STD		{ int linux_sys_chdir(char *path); }
13	STD		{ int linux_sys_time(linux_time_t *t); }
14	STD		{ int linux_sys_mknod(char *path, int mode, int dev); }
15	STD		{ int linux_sys_chmod(char *path, int mode); }
16	STD		{ int linux_sys_lchown16(char *path, int uid, \
			    int gid); }
17	STD		{ int linux_sys_break(char *nsize); }
18	STD		{ int linux_sys_ostat(void); }
19	STD		{ long linux_sys_lseek(int fd, long offset, \
			    int whence); }
20	STD		{ pid_t linux_sys_getpid(void); }
21	STD		{ int linux_sys_mount(char *specialfile, char *dir, \
			    char *filesystemtype, long rwflag, void *data); }
22	STD		{ int linux_sys_umount(char *specialfile); }
23	NOARGS		linux_setuid16 { int sys_setuid(uid_t uid); }
24	STD		linux_getuid16 { uid_t linux_sys_getuid(void); }
25	UNIMPL		stime
#ifdef PTRACE
26	STD		{ int linux_sys_ptrace(void); }
#else
26	UNIMPL		ptrace
#endif
27	STD		{ int linux_sys_alarm(unsigned int secs); }
28	STD		{ int linux_sys_ofstat(void); }
29	STD		{ int linux_sys_pause(void); }
30	STD		{ int linux_sys_utime(char *path, \
			    struct linux_utimbuf *times); }
31	STD		{ int linux_sys_stty(void); }
32	STD		{ int linux_sys_gtty(void); }
33	STD		{ int linux_sys_access(char *path, int flags); }
34	STD		{ int linux_sys_nice(int incr); }
35	STD		{ int linux_sys_ftime(void); }
36	NOARGS		{ int sys_sync(void); }
37	STD		{ int linux_sys_kill(int pid, int signum); }
38	STD		{ int linux_sys_rename(char *from, char *to); }
39	STD		{ int linux_sys_mkdir(char *path, int mode); }
40	STD		{ int linux_sys_rmdir(char *path); }
41	NOARGS		{ int sys_dup(u_int fd); }
42	NOARGS		{ int sys_pipe(int *fdp); }
43	STD		{ int linux_sys_times(struct linux_tms *tms); }
44	STD		{ int linux_sys_prof(void); }
45	STD		{ int linux_sys_brk(char *nsize); }
46	NOARGS		linux_setgid16 { int sys_setgid(gid_t gid); }
47	STD		linux_getgid16 { gid_t linux_sys_getgid(void); }
48	STD		{ int linux_sys_signal(int sig, \
			    linux_handler_t handler); }
49	NOARGS		linux_geteuid16 { uid_t sys_geteuid(void); }
50	NOARGS		linux_getegid16 { gid_t sys_getegid(void); }
#ifdef ACCOUNTING
51	NOARGS		{ int sys_acct(char *path); }
#else
51	UNIMPL		acct
#endif
52	STD		{ int linux_sys_phys(void); }
53	STD		{ int linux_sys_lock(void); }
54	STD		{ int linux_sys_ioctl(int fd, u_long com, \
			    caddr_t data); }
55	STD		{ int linux_sys_fcntl(int fd, int cmd, void *arg); }
56	STD		{ int linux_sys_mpx(void); }
57	NOARGS		{ int sys_setpgid(int pid, int pgid); }
58	STD		{ int linux_sys_ulimit(void); }
59	STD		{ int linux_sys_oldolduname(struct linux_oldold_utsname *up); }
60	NOARGS		{ int sys_umask(int newmask); }
61	NOARGS		{ int sys_chroot(char *path); }
62	STD		{ int linux_sys_ustat(void); }
63	NOARGS		{ int sys_dup2(u_int from, u_int to); }
64	NOARGS		{ pid_t sys_getppid(void); }
65	NOARGS		{ int sys_getpgrp(void); }
66	NOARGS		{ int sys_setsid(void); }
67	STD		{ int linux_sys_sigaction(int signum, \
			    struct linux_old_sigaction *nsa, \
			    struct linux_old_sigaction *osa); }
68	STD		{ int linux_sys_siggetmask(void); }
69	STD		{ int linux_sys_sigsetmask(linux_old_sigset_t mask); }
70	STD		{ int linux_sys_setreuid16(int ruid, int euid); }
71	STD		{ int linux_sys_setregid16(int rgid, int egid); }
72	STD		{ int linux_sys_sigsuspend(caddr_t restart, \
			    int oldmask, int mask); }
73	STD		{ int linux_sys_sigpending(linux_old_sigset_t *mask); }
74	STD		{ int linux_sys_sethostname(char *hostname, u_int len);}
75	STD		{ int linux_sys_setrlimit(u_int which, \
			    struct linux_rlimit *rlp); }
76	STD		{ int linux_sys_getrlimit(u_int which, \
			    struct linux_rlimit *rlp); }
77	STD		{ int linux_sys_getrusage(int who, \
			    struct linux_rusage *rusage); }
78	STD		{ int linux_sys_gettimeofday(struct linux_timeval *tp, \
			    struct timezone *tzp); }
79	UNIMPL		settimeofday
80	NOARGS		linux_getgroups { int sys_getgroups(u_int gidsetsize, \
			    gid_t *gidset); }
81	NOARGS		linux_setgroups { int sys_setgroups(u_int gidsetsize, \
			    gid_t *gidset); }
82	STD		{ int linux_sys_oldselect(struct linux_select *lsp); }
83	STD		{ int linux_sys_symlink(char *path, char *to); }
84	NOARGS		{ int linux_sys_lstat(char *path, \
			    struct linux_stat *up); } olstat
85	STD		{ ssize_t linux_sys_readlink(char *name, \
			    char *buf, int count); }
86	UNIMPL		linux_sys_uselib
87	STD		{ int linux_sys_swapon(char *name); }
88	NOARGS		{ int sys_reboot(int opt); }
89	STD		{ int linux_sys_readdir(int fd, caddr_t dent, \
			    unsigned int count); }
90	STD		{ int linux_sys_mmap(struct linux_mmap *lmp); }
91	NOARGS		{ int sys_munmap(caddr_t addr, int len); }
92	STD		{ int linux_sys_truncate(char *path, long length); }
93	STD		{ int linux_sys_ftruncate(int fd, long length); }
94	NOARGS		{ int sys_fchmod(int fd, int mode); }
95	STD		{ int linux_sys_fchown16(int fd, int uid, int gid); }
96	NOARGS		{ int sys_getpriority(int which, int who); }
97	NOARGS		{ int sys_setpriority(int which, int who, int prio); }
98	NOARGS		{ int sys_profil(caddr_t samples, u_int size, \
			    u_int offset, u_int scale); }
99	STD		{ int linux_sys_statfs(char *path, \
			    struct linux_statfs *sp); }
100	STD		{ int linux_sys_fstatfs(int fd, \
			    struct linux_statfs *sp); }
#ifdef __i386__
101	STD		{ int linux_sys_ioperm(unsigned int lo, \
			    unsigned int hi, int val); }
#else
101	STD		{ int linux_sys_ioperm(void); }
#endif
102	STD		{ int linux_sys_socketcall(int what, void *args); }
103	STD		{ int linux_sys_klog(void); }
104	STD		{ int linux_sys_setitimer(u_int which, \
			    struct linux_itimerval *itv, \
			    struct linux_itimerval *oitv); }
105	STD		{ int linux_sys_getitimer(u_int which, \
			    struct linux_itimerval *itv); }
106	STD		{ int linux_sys_stat(char *path, \
			    struct linux_stat *sp); }
107	STD		{ int linux_sys_lstat(char *path, \
			    struct linux_stat *sp); }
108	STD		{ int linux_sys_fstat(int fd, struct linux_stat *sp); }
109	STD		{ int linux_sys_olduname(struct linux_old_utsname *up); }
#ifdef __i386__
110	STD		{ int linux_sys_iopl(int level); }
#else
110	STD		{ int linux_sys_iopl(void); }
#endif
111	STD		{ int linux_sys_vhangup(void); }
112	STD		{ int linux_sys_idle(void); }
113	STD		{ int linux_sys_vm86old(void); }
114	STD		{ int linux_sys_wait4(int pid, int *status, \
			    int options, struct linux_rusage *rusage); }
115	STD		{ int linux_sys_swapoff(void); }
116	STD		{ int linux_sys_sysinfo(struct linux_sysinfo *sysinfo); }
117	STD		{ int linux_sys_ipc(int what, int a1, int a2, int a3, \
			    caddr_t ptr); }
118	NOARGS		{ int sys_fsync(int fd); }
119	STD		{ int linux_sys_sigreturn(struct linux_sigcontext *scp); }
120	STD		{ int linux_sys_clone(int flags, void *stack, \
			    void *parent_tidptr, void *tls, void *child_tidptr); }
121	STD		{ int linux_sys_setdomainname(char *name, int len); }
122	STD		{ int linux_sys_uname(struct linux_utsname *up); }
#ifdef __i386__
123	STD		{ int linux_sys_modify_ldt(int func, void *ptr, \
			    size_t bytecount); }
#else
123	STD		{ int linux_sys_modify_ldt(void); }
#endif
124	STD		{ int linux_sys_adjtimex(void); }
125	STD		{ int linux_sys_mprotect(caddr_t addr, int len, int prot); }
126	STD		{ int linux_sys_sigprocmask(int how, \
			    linux_old_sigset_t *set, linux_old_sigset_t *oset); }
127	STD		{ int linux_sys_create_module(void); }
128	STD		{ int linux_sys_init_module(void); }
129	STD		{ int linux_sys_delete_module(void); }
130	STD		{ int linux_sys_get_kernel_syms(void); }
131	STD		{ int linux_sys_quotactl(void); }
132	STD		{ int linux_sys_getpgid(int pid); }
133	NOARGS		{ int sys_fchdir(int fd); }
134	STD		{ int linux_sys_bdflush(void); }
135	STD		{ int linux_sys_sysfs(void); }
136	STD		{ int linux_sys_personality(int per); }
137	STD		{ int linux_sys_afs_syscall(void); }
138	NOARGS		linux_setfsuid16 { int linux_sys_setfsuid(uid_t uid); }
139	NOARGS		linux_getfsuid16 { int linux_sys_getfsuid(void); }
140	STD		{ int linux_sys_llseek(int fd, u_int32_t ohigh, \
			    u_int32_t olow, caddr_t res, int whence); }
141	STD		{ int linux_sys_getdents(int fd, void *dirent, \
			    unsigned count); }
142	STD		{ int linux_sys_select(int nfds, fd_set *readfds, \
			    fd_set *writefds, fd_set *exceptfds, \
			    struct linux_timeval *timeout); }
143	NOARGS		{ int sys_flock(int fd, int how); }
144	NOARGS		{ int sys_msync(void *addr, int len, int fl); }
145	NOARGS		{ int sys_readv(int fd, struct iovec *iovp, \
				u_int iovcnt); }
146	NOARGS		{ int sys_writev(int fd, struct iovec *iovp, \
				u_int iovcnt); }
147	NOARGS		{ int sys_getsid(pid_t pid); }
148	STD		{ int linux_sys_fdatasync(int fd); }
149	STD		{ int linux_sys___sysctl(struct linux___sysctl *lsp); }
150	NOARGS		{ int sys_mlock(caddr_t addr, size_t len); }
151	NOARGS		{ int sys_munlock(caddr_t addr, size_t len); }
152	STD		{ int linux_sys_mlockall(void); }
153	STD		{ int linux_sys_munlockall(void); }
154	STD		{ int linux_sys_sched_setparam(linux_pid_t pid, \
			    const struct linux_sched_param *sp); }
155	STD		{ int linux_sys_sched_getparam(linux_pid_t pid, \
			    struct linux_sched_param *sp); }
156	STD		{ int linux_sys_sched_setscheduler(linux_pid_t pid, \
			    int policy, const struct linux_sched_param *sp); }
157	STD		{ int linux_sys_sched_getscheduler(linux_pid_t pid); }
158	STD		{ int linux_sys_sched_yield(void); }
159	STD		{ int linux_sys_sched_get_priority_max(int policy); }
160	STD		{ int linux_sys_sched_get_priority_min(int policy); }
161	STD		{ int linux_sys_sched_rr_get_interval(void); }
162	STD		{ int linux_sys_nanosleep( \
				const struct linux_timespec *rqtp, \
				struct linux_timespec *rmtp); }
163	STD		{ int linux_sys_mremap(void *old_address, \
			    size_t old_size, size_t new_size, long flags); }
164	STD		{ int linux_sys_setresuid16(u_int16_t ruid, \
			    u_int16_t euid, u_int16_t suid); }
165	STD		{ int linux_sys_getresuid16(u_int16_t *ruid, \
			    u_int16_t *euid, u_int16_t *suid); }
166	STD		{ int linux_sys_vm86(void); }
167	STD		{ int linux_sys_query_module(void); }
168	NOARGS		{ int sys_poll(struct pollfd *fds, u_int nfds, \
			    int timeout); }
169	STD		{ int linux_sys_nfsservctl(void); }
170	STD		{ int linux_sys_setresgid16(u_int16_t rgid, \
			    u_int16_t egid, u_int16_t sgid); }
171	STD		{ int linux_sys_getresgid16(u_int16_t *rgid, \
			    u_int16_t *egid, u_int16_t *sgid); }
172	STD		{ int linux_sys_prctl(int option, unsigned long arg2, \
			    unsigned long arg3, unsigned long arg4, \
			    unsigned long arg5); }
173	STD     	{ int linux_sys_rt_sigreturn( \
	                    struct linux_rt_sigframe *sfp); }
174	STD		{ int linux_sys_rt_sigaction(int signum, \
			    struct linux_sigaction *nsa, \
			    struct linux_sigaction *osa, \
		            size_t sigsetsize); }
175	STD		{ int linux_sys_rt_sigprocmask(int how, \
			    const linux_sigset_t *set, \
			    linux_sigset_t *oset, size_t sigsetsize); }
176	STD		{ int linux_sys_rt_sigpending(linux_sigset_t *set, \
			    size_t sigsetsize); }
177	STD		{ int linux_sys_rt_sigtimedwait(void); }
178	STD		{ int linux_sys_rt_queueinfo(void); }
179	STD		{ int linux_sys_rt_sigsuspend(linux_sigset_t *unewset, \
			    size_t sigsetsize); }
180	STD		{ int linux_sys_pread(int fd, char *buf, \
			    size_t nbyte, linux_off_t offset); }
181	STD		{ int linux_sys_pwrite(int fd, char *buf, \
			    size_t nbyte, linux_off_t offset); }
182	STD		{ int linux_sys_chown16(char *path, int uid, \
			    int gid); }
183	NOARGS		{ int sys___getcwd(char *bufp, size_t length); }
184	STD		{ int linux_sys_capget(void); }
185	STD		{ int linux_sys_capset(void); }
186	STD		{ int linux_sys_sigaltstack( \
			    const struct linux_sigaltstack *nss, \
			    struct linux_sigaltstack *oss); }
187	STD		{ int linux_sys_sendfile(void); }
188	STD		{ int linux_sys_getpmsg(void); }
189	STD		{ int linux_sys_putpmsg(void); }
190	STD		{ int sys_vfork(void); }
191	STD		{ int linux_sys_ugetrlimit(u_int which, \
			    struct linux_rlimit *rlp); }
192	STD		{ linux_off_t linux_sys_mmap2(unsigned long addr, \
			   size_t len, int prot, int flags, int fd, \
			   linux_off_t offset); }
193	STD		{ int linux_sys_truncate64(char *path, off_t length); }
194	STD		{ int linux_sys_ftruncate64(int fd, off_t length); }
195	STD        	{ int linux_sys_stat64(char *path, \
			    struct linux_stat64 *sp); }
196	STD        	{ int linux_sys_lstat64(char *path, \
			    struct linux_stat64 *sp); }
197	STD        	{ int linux_sys_fstat64(int fd, \
			    struct linux_stat64 *sp); }
198	NOARGS		{ int linux_sys_lchown(void); }
199	STD		{ uid_t linux_sys_getuid(void); }
200	STD		{ gid_t linux_sys_getgid(void); }
201	NOARGS		{ uid_t sys_geteuid(void); }
202	NOARGS		{ gid_t sys_getegid(void); }
203	NOARGS		{ int sys_setreuid(int ruid, int euid); }
204	NOARGS		{ int sys_setregid(int rgid, int egid); }
205	NOARGS		{ int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
206	NOARGS		{ int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
207	NOARGS		{ int linux_sys_fchown(void); }
208	NOARGS		{ int sys_setresuid(uid_t ruid, uid_t euid, \
			    uid_t suid); }
209	NOARGS		{ int sys_getresuid(uid_t *ruid, uid_t *euid, \
			    uid_t *suid); }
210	NOARGS		{ int sys_setresgid(gid_t rgid, gid_t egid, \
			    gid_t sgid); }
211	NOARGS		{ int sys_getresgid(gid_t *rgid, gid_t *egid, \
			    gid_t *sgid); }
212	STD		{ int linux_sys_chown(char *path, uid_t uid, \
			    gid_t gid); }
213	NOARGS		{ int sys_setuid(uid_t uid); }
214	NOARGS		{ int sys_setgid(gid_t gid); }
215	STD		{ int linux_sys_setfsuid(uid_t uid); }
216	NOARGS		{ int linux_sys_setfsgid(void); }
217	NOARGS		{ int linux_sys_pivot_root(void); }
218	NOARGS		{ int linux_sys_mincore(void); }
219	NOARGS		{ int sys_madvise(void *addr, size_t len, int behav); }
220	STD		{ int linux_sys_getdents64(int fd, void *dirent, \
			    unsigned count); }
221	STD		{ int linux_sys_fcntl64(u_int fd, u_int cmd, \
			    void *arg); }
222	UNIMPL
223	UNIMPL
224	STD		{ linux_pid_t linux_sys_gettid(void); }
225	UNIMPL		linux_sys_readahead
226	NOARGS		{ int linux_sys_setxattr(void); }
227	NOARGS		{ int linux_sys_lsetxattr(void); }
228	NOARGS		{ int linux_sys_fsetxattr(void); }
229	NOARGS		{ int linux_sys_getxattr(void); }
230	NOARGS		{ int linux_sys_lgetxattr(void); }
231	NOARGS		{ int linux_sys_fgetxattr(void); }
232	NOARGS		{ int linux_sys_listxattr(void); }
233	NOARGS		{ int linux_sys_llistxattr(void); }
234	NOARGS		{ int linux_sys_flistxattr(void); }
235	NOARGS		{ int linux_sys_removexattr(void); }
236	NOARGS		{ int linux_sys_lremovexattr(void); }
237	NOARGS		{ int linux_sys_fremovexattr(void); }
238	UNIMPL		linux_sys_tkill
239	UNIMPL		linux_sys_sendfile64
240	STD		{ int linux_sys_futex(int *uaddr, int op, int val, \
			    const struct linux_timespec *timeout, \
			    int *uaddr2, int val3); }
241	UNIMPL		linux_sys_sched_setaffinity
242	UNIMPL		linux_sys_sched_getaffinity
243	STD		{ int linux_sys_set_thread_area(	\
			    struct l_segment_descriptor *desc); }
244	STD		{ int linux_sys_get_thread_area(	\
			    struct l_segment_descriptor *desc); }
245	UNIMPL		linux_sys_io_setup
246	UNIMPL		linux_sys_io_destroy
247	UNIMPL		linux_sys_io_getevents
248	UNIMPL		linux_sys_io_submit
249	UNIMPL		linux_sys_io_cancel
250	NOARGS		{ int linux_sys_fadvise64(void); }
251	UNIMPL
252	NOARGS		linux_exit_group { int sys_exit(int rval); }
253	UNIMPL		linux_sys_lookup_dcookie
254	NOARGS		{ int linux_sys_epoll_create(void); }
255	NOARGS		{ int linux_sys_epoll_ctl(void); }
256	NOARGS		{ int linux_sys_epoll_wait(void); }
257	UNIMPL		linux_sys_remap_file_pages
258	STD		{ int linux_sys_set_tid_address(void *tidptr); }
259	UNIMPL		linux_sys_timer_create
260	UNIMPL		linux_sys_timer_settime
261	UNIMPL		linux_sys_timer_gettime
262	UNIMPL		linux_sys_timer_getoverrun
263	UNIMPL		linux_sys_timer_delete
264	UNIMPL		linux_sys_clock_settime
265	STD		{ int linux_sys_clock_gettime(clockid_t which, \
			    struct linux_timespec *tp); }
266	STD		{ int linux_sys_clock_getres(clockid_t which, \
			    struct linux_timespec *tp); }
267	UNIMPL		linux_sys_clock_nanosleep
268	STD		{ int linux_sys_statfs64(char *path, \
			    struct linux_statfs64 *sp); }
269	STD		{ int linux_sys_fstatfs64(int fd, \
			    struct linux_statfs64 *sp); }
270	STD		{ int linux_sys_tgkill(int tgid, int tid, int sig); }
271	UNIMPL		linux_sys_utimes
272	UNIMPL		linux_sys_fadvise64_64
273	UNIMPL		linux_sys_vserver
274	UNIMPL		linux_sys_mbind
275	UNIMPL		linux_sys_get_mempolicy
276	UNIMPL		linux_sys_set_mempolicy
277	UNIMPL		linux_sys_mq_open
278	UNIMPL		linux_sys_mq_unlink
279	UNIMPL		linux_sys_mq_timedsend
280	UNIMPL		linux_sys_mq_timedreceive
281	UNIMPL		linux_sys_mq_notify
282	UNIMPL		linux_sys_mq_getsetattr
283	UNIMPL		linux_sys_sys_kexec_load
284	UNIMPL		linux_sys_waitid
285	UNIMPL		/* unused */
286	UNIMPL		linux_sys_add_key
287	UNIMPL		linux_sys_request_key
288	UNIMPL		linux_sys_keyctl
289	UNIMPL		linux_sys_ioprio_set
290	UNIMPL		linux_sys_ioprio_get
291	UNIMPL		linux_sys_inotify_init
292	UNIMPL		linux_sys_inotify_add_watch
293	UNIMPL		linux_sys_inotify_rm_watch
294	UNIMPL		linux_sys_migrate_pages
295	UNIMPL		linux_sys_openalinux_sys_t
296	UNIMPL		linux_sys_mkdirat
297	UNIMPL		linux_sys_mknodat
298	UNIMPL		linux_sys_fchownat
299	UNIMPL		linux_sys_futimesat
300	UNIMPL		linux_sys_fstatat64
301	UNIMPL		linux_sys_unlinkat
302	UNIMPL		linux_sys_renameat
303	UNIMPL		linux_sys_linkat
304	UNIMPL		linux_sys_symlinkat
305	UNIMPL		linux_sys_readlinkat
306	UNIMPL		linux_sys_fchmodat
307	UNIMPL		linux_sys_faccessat
308	UNIMPL		linux_sys_pselect6
309	UNIMPL		linux_sys_ppoll
310	UNIMPL		linux_sys_unshare
311	STD		{ int linux_sys_set_robust_list( \
			    struct linux_robust_list_head *head, size_t len); }
312	STD		{ int linux_sys_get_robust_list(int pid, \
			    struct linux_robust_list_head **head, \
			    size_t *len); }
313	UNIMPL		splice
314	UNIMPL		sync_file_range
315	UNIMPL		tee
316	UNIMPL		vmsplice
317	UNIMPL		move_pages
318	UNIMPL		getcpu
319	NOARGS		{ int linux_sys_epoll_pwait(void); }
320	UNIMPL		utimensat
321	UNIMPL		signalfd
322	UNIMPL		timerfd_create
323	NOARGS		{ int linux_sys_eventfd(void); }
324	UNIMPL		fallocate
325	UNIMPL		timerfd_settime
326	UNIMPL		timerfd_gettime
327	UNIMPL		signalfd4
328	NOARGS		{ int linux_sys_eventfd2(void); }
329	NOARGS		{ int linux_sys_epoll_create1(void); }
330	UNIMPL		dup3
331	STD		{ int linux_sys_pipe2(int *fdp, int flags); }
332	UNIMPL		inotify_init1
333	UNIMPL		preadv
334	UNIMPL		pwritev
335	UNIMPL		rt_tgsigqueueinfo
336	UNIMPL		perf_counter_open
337	UNIMPL		recvmmsg


code: src/sys/conf

path: sys/conf/CVS/Repository


code:
#	$OpenBSD: GENERIC,v 1.219 2015/07/31 00:16:53 benno Exp $
#
#	Machine-independent option; used by all architectures for their
#	GENERIC kernel

#option		INSECURE	# default to secure

option		DDB		# in-kernel debugger
#option		DDB_SAFE_CONSOLE # allow break into ddb during boot
#makeoptions	DEBUG="-g"	# compile full symbol table
#makeoptions	PROF="-pg"	# build profiled kernel
#option		GPROF		# kernel profiling, kgmon(8)
option		DIAGNOSTIC	# internal consistency checks
option		KTRACE		# system call tracing, a la ktrace(1)
option		ACCOUNTING	# acct(2) process accounting
option		KMEMSTATS	# collect malloc(9) statistics
option		PTRACE		# ptrace(2) system call

#option		KVA_GUARDPAGES	# slow virtual address recycling (+ guarding)
#option		POOL_DEBUG	# pool corruption detection
#option		VFSLCKDEBUG	# VFS locking checks

option		CRYPTO		# Cryptographic framework

option		SYSVMSG		# System V-like message queues
option		SYSVSEM		# System V-like semaphores
option		SYSVSHM		# System V-like memory sharing

option		UVM_SWAP_ENCRYPT# support encryption of pages going to swap

option		FFS		# UFS
option		FFS2		# UFS2
option		FFS_SOFTUPDATES	# Soft updates
option		UFS_DIRHASH	# hash large directories
option		QUOTA		# UFS quotas
option		EXT2FS		# Second Extended Filesystem
option		MFS		# memory file system
option		NFSCLIENT	# Network File System client
option		NFSSERVER	# Network File System server
option		CD9660		# ISO 9660 + Rock Ridge file system
option		UDF		# UDF (DVD) file system
option		MSDOSFS		# MS-DOS file system
option		FIFO		# FIFOs; RECOMMENDED
option		TMPFS		# efficient memory file system
option		FUSE		# FUSE

option		SOCKET_SPLICE	# Socket Splicing for TCP and UDP
option		TCP_SACK	# Selective Acknowledgements for TCP
option		TCP_ECN		# Explicit Congestion Notification for TCP
option		TCP_SIGNATURE	# TCP MD5 Signatures, for BGP routing sessions
#option		TCP_FACK	# Forward Acknowledgements for TCP

option		INET6		# IPv6
option		IPSEC		# IPsec
#option		KEY		# PF_KEY (implied by IPSEC)
option		PPP_BSDCOMP	# PPP BSD compression
option		PPP_DEFLATE
option		PIPEX		# Ppp IP EXtension, for npppd
option		MROUTING	# Multicast router
#option		PIM		# Protocol Independent Multicast
option		MPLS		# Multi-Protocol Label Switching

#mpath0		at root		# SCSI Multipathing
#scsibus*	at mpath?
#emc*		at scsibus?
#hds*		at scsibus?
#rdac*		at scsibus?
#sym*		at scsibus?

softraid0	at root		# Software RAID
scsibus*	at softraid?

vscsi0		at root		# Userland backed Virtual SCSI
scsibus*	at vscsi?

pseudo-device	pf		# packet filter
pseudo-device	pflog		# pf log if
pseudo-device	pfsync		# pf sync if
pseudo-device	pflow		# pflow export if
pseudo-device	enc		# option IPSEC needs the encapsulation interface

pseudo-device	pty	16	# initial number of pseudo-terminals
pseudo-device	nmea	1	# NMEA 0183 line discipline
pseudo-device	msts	1	# MSTS line discipline
pseudo-device	endrun	1	# EndRun line discipline
pseudo-device	vnd	4	# vnode disk devices
pseudo-device	ksyms	1	# kernel symbols device
pseudo-device	systrace 1	# system call tracing device

# clonable devices
pseudo-device	bpfilter	# packet filter
pseudo-device	bridge		# network bridging support
pseudo-device	carp		# CARP protocol support
pseudo-device	gif		# IPv[46] over IPv[46] tunnel (RFC1933)
pseudo-device	gre		# GRE encapsulation interface
pseudo-device	loop		# network loopback
pseudo-device	mpe		# MPLS PE interface
pseudo-device	mpw		# MPLS pseudowire support
pseudo-device	ppp		# PPP
pseudo-device	pppoe		# PPP over Ethernet (RFC 2516)
pseudo-device	pppx		# PPP multiplexer
pseudo-device	sppp	1	# Sync PPP/HDLC
pseudo-device	trunk		# Trunking support
pseudo-device	tun		# network tunneling over tty
pseudo-device	vether		# Virtual ethernet
pseudo-device	vxlan		# Virtual extensible LAN
pseudo-device	vlan		# IEEE 802.1Q VLAN

pseudo-device	bio	1	# ioctl multiplexing device

pseudo-device	fuse		# fuse device

option		BOOT_CONFIG	# add support for boot -c

path: sys/conf/GENERIC