Sync from head.

This commit is contained in:
Dag-Erling Smørgrav 2009-09-26 23:25:22 +00:00
commit 3f89d457bf
40 changed files with 733 additions and 172 deletions

View File

@ -22,10 +22,61 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW:
machines to maximize performance. (To disable malloc debugging, run
ln -s aj /etc/malloc.conf.)
20090926:
The rc.d/network_ipv6, IPv6 configuration script has been integrated
into rc.d/netif. The changes are the following:
1. To use IPv6, simply define $ifconfig_IF_ipv6 like $ifconfig_IF
for IPv4. For aliases, $ifconfig_IF_aliasN should be used.
Note that both variables need the "inet6" keyword at the head.
Do not set $ipv6_network_interfaces manually if you do not
understand what you are doing. It is not needed in most cases.
$ipv6_ifconfig_IF and $ipv6_ifconfig_IF_aliasN still work, but
they are obsolete.
2. $ipv6_enable is obsolete. Use $ipv6_prefer and
"inet6 accept_rtadv" keyword in ifconfig(8) instead.
If you define $ipv6_enable=YES, it means $ipv6_prefer=YES and
all configured interfaces have "inet6 accept_rtadv" in the
$ifconfig_IF_ipv6. These are for backward compatibility.
3. A new variable $ipv6_prefer has been added. If NO, IPv6
functionality of interfaces with no corresponding
$ifconfig_IF_ipv6 is disabled by using "inet6 ifdisabled" flag,
and the default address selection policy of ip6addrctl(8)
is the IPv4-preferred one (see rc.d/ip6addrctl for more details).
Note that if you want to configure IPv6 functionality on the
disabled interfaces after boot, first you need to clear the flag by
using ifconfig(8) like:
ifconfig em0 inet6 -ifdisabled
If YES, the default address selection policy is set as
IPv6-preferred.
The default value of $ipv6_prefer is NO.
4. If your system need to receive Router Advertisement messages,
define "inet6 accept_rtadv" in $ifconfig_IF_ipv6. The rc(8)
scripts automatically invoke rtsol(8) when the interface becomes
UP. The Router Advertisement messages are used for SLAAC
(State-Less Address AutoConfiguration).
20090922:
802.11s D3.03 support was committed. This is incompatible with the
previous code, which was based on D3.0.
20090912:
A sysctl variable net.inet6.ip6.accept_rtadv now sets the default value
of a per-interface flag ND6_IFF_ACCEPT_RTADV, not a global knob to
control whether accepting Router Advertisement messages or not.
Also, a per-interface flag ND6_IFF_AUTO_LINKLOCAL has been added and
a sysctl variable net.inet6.ip6.auto_linklocal is its default value.
The ifconfig(8) utility now supports these flags.
20090910:
ZFS snapshots are now mounted with MNT_IGNORE flag. Use -v option for
mount(8) and -a option for df(1) to see them.

View File

@ -97,15 +97,26 @@ ifconfig_up()
if afexists inet6; then
if ipv6if $1; then
if checkyesno ipv6_gateway_enable; then
_ipv6_opts="-accept_rtadv auto_linklocal"
else
_ipv6_opts="auto_linklocal"
_ipv6_opts="-accept_rtadv"
fi
else
_ipv6_opts="-auto_linklocal ifdisabled"
if checkyesno ipv6_prefer; then
_ipv6_opts="-ifdisabled"
else
_ipv6_opts="ifdisabled"
fi
# backward compatibility: $ipv6_enable
case $ipv6_enable in
[Yy][Ee][Ss])
_ipv6_opts="${_ipv6_opts} accept_rtadv"
;;
esac
fi
ifconfig $1 inet6 ${_ipv6_opts}
if [ -n "${_ipv6_opts}" ]; then
ifconfig $1 inet6 ${_ipv6_opts}
fi
# ifconfig_IF_ipv6
ifconfig_args=`ifconfig_getargs $1 ipv6`
@ -382,7 +393,7 @@ noafif()
# 1 otherwise.
ipv6if()
{
local _if i
local _if _tmpargs i
_if=$1
if ! afexists inet6; then
@ -396,6 +407,18 @@ ipv6if()
;;
esac
# True if $ifconfig_IF_ipv6 is defined.
_tmpargs=`_ifconfig_getargs $_if ipv6`
if [ -n "${_tmpargs}" ]; then
return 0
fi
# backward compatibility: True if $ipv6_ifconfig_IF is defined.
_tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
if [ -n "${_tmpargs}" ]; then
return 0
fi
case "${ipv6_network_interfaces}" in
[Aa][Uu][Tt][Oo])
return 0
@ -431,17 +454,30 @@ ipv6_autoconfif()
if checkyesno ipv6_gateway_enable; then
return 1
fi
_tmpargs=`get_if_var $_if ipv6_prefix_IF`
if [ -n "${_tmpargs}" ]; then
return 1
fi
case $_if in
lo0|\
stf[0-9]*|\
faith[0-9]*|\
lp[0-9]*|\
sl[0-9]*)
sl[0-9]*|\
pflog[0-9]*|\
pfsync[0-9]*)
return 1
;;
esac
# backward compatibility: $ipv6_enable
case $ipv6_enable in
[Yy][Ee][Ss])
return 0
;;
esac
_tmpargs=`_ifconfig_getargs $_if ipv6`
for _arg in $_tmpargs; do
case $_arg in
@ -451,6 +487,16 @@ ipv6_autoconfif()
esac
done
# backward compatibility: $ipv6_ifconfig_IF
_tmpargs=`get_if_var $_if ipv6_ifconfig_IF`
for _arg in $_tmpargs; do
case $_arg in
accept_rtadv)
return 0
;;
esac
done
return 1
}
@ -691,7 +737,7 @@ ifalias_ipv6_up()
;;
*)
ifconfig $1 inet6 ${ifconfig_args} alias && _ret=0
warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete."
warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
" Use ifconfig_$1_aliasN instead."
;;
esac
@ -773,6 +819,7 @@ ifalias_ipv6_down()
done
# backward compatibility: ipv6_ifconfig_IF_aliasN.
alias=0
while : ; do
ifconfig_args=`get_if_var $1 ipv6_ifconfig_IF_alias${alias}`
case "${ifconfig_args}" in
@ -780,13 +827,12 @@ ifalias_ipv6_down()
break
;;
*)
ifconfig $1 inet6 ${ifconfig_args} -alias
alias=$((${alias} + 1))
warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete."
ifconfig $1 inet6 ${ifconfig_args} -alias && _ret=0
warn "\$ipv6_ifconfig_$1_alias${alias} is obsolete." \
" Use ifconfig_$1_aliasN instead."
_ret=0
;;
esac
alias=$((${alias} + 1))
done
return $_ret

View File

@ -6,7 +6,7 @@
#
# PROVIDE: defaultroute
# REQUIRE: devd netif
# REQUIRE: devd faith netif stf
# KEYWORD: nojail
. /etc/rc.subr

View File

@ -19,6 +19,8 @@ status_cmd="ip6addrctl"
prefer_ipv6_cmd="ip6addrctl_prefer_ipv6"
prefer_ipv4_cmd="ip6addrctl_prefer_ipv4"
set_rcvar_obsolete ipv6_enable ipv6_prefer
ip6addrctl_prefer_ipv6()
{
ip6addrctl flush >/dev/null 2>&1

View File

@ -41,7 +41,7 @@ clonedown_cmd="clone_down"
extra_commands="cloneup clonedown"
cmdifn=
set_rcvar_obsolete ipv6_enable
set_rcvar_obsolete ipv6_enable ipv6_prefer
network_start()
{

View File

@ -6,7 +6,7 @@
#
# PROVIDE: routing
# REQUIRE: netif ppp
# REQUIRE: faith netif ppp stf
# KEYWORD: nojail
. /etc/rc.subr

View File

@ -43,7 +43,10 @@ rtadvd_precmd()
case ${rtadvd_interfaces} in
[Aa][Uu][Tt][Oo]|'')
for i in `ifconfig -l` ; do
if is_wired_interface $1; then
case $i in
lo0) continue ;;
esac
if ipv6if $i; then
rtadvd_interfaces="${rtadvd_interfaces} ${i}"
fi
done

View File

@ -32,7 +32,7 @@
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
.Dd August 26, 2008
.Dd September 26, 2009
.Dt MALLOC 3
.Os
.Sh NAME
@ -245,7 +245,8 @@ will be initialized to 0x5a.
This is intended for debugging and will impact performance negatively.
.It K
Double/halve the virtual memory chunk size.
The default chunk size is 1 MB.
The default chunk size is the maximum of 1 MB and the largest
page size that is less than or equal to 4 MB.
.It M
Use
.Xr mmap 2
@ -561,6 +562,7 @@ _malloc_options = "X";
.Xr alloca 3 ,
.Xr atexit 3 ,
.Xr getpagesize 3 ,
.Xr getpagesizes 3 ,
.Xr memory 3 ,
.Xr posix_memalign 3
.Sh STANDARDS

View File

@ -4795,6 +4795,21 @@ malloc_init_hard(void)
}
}
/*
* Increase the chunk size to the largest page size that is greater
* than the default chunk size and less than or equal to 4MB.
*/
{
size_t pagesizes[MAXPAGESIZES];
int k, nsizes;
nsizes = getpagesizes(pagesizes, MAXPAGESIZES);
for (k = 0; k < nsizes; k++)
if (pagesizes[k] <= (1LU << 22))
while ((1LU << opt_chunk_2pow) < pagesizes[k])
opt_chunk_2pow++;
}
for (i = 0; i < 3; i++) {
unsigned j;

View File

@ -32,12 +32,11 @@ __FBSDID("$FreeBSD$");
#include <syslog.h>
#include <unistd.h>
void rquota_service(struct svc_req *request, SVCXPRT *transp);
void sendquota(struct svc_req *request, SVCXPRT *transp);
void printerr_reply(SVCXPRT *transp);
void initfs(void);
int getfsquota(long id, char *path, struct dqblk *dqblk);
int hasquota(struct fstab *fs, char **qfnamep);
static void rquota_service(struct svc_req *request, SVCXPRT *transp);
static void sendquota(struct svc_req *request, SVCXPRT *transp);
static void initfs(void);
static int getfsquota(long id, char *path, struct dqblk *dqblk);
static int hasquota(struct fstab *fs, char **qfnamep);
/*
* structure containing informations about ufs filesystems
@ -49,9 +48,9 @@ struct fs_stat {
char *qfpathname; /* pathname of the quota file */
dev_t st_dev; /* device of the filesystem */
} fs_stat;
struct fs_stat *fs_begin = NULL;
static struct fs_stat *fs_begin = NULL;
int from_inetd = 1;
static int from_inetd = 1;
static void
cleanup(int sig)
@ -112,7 +111,7 @@ main(void)
exit(1);
}
void
static void
rquota_service(struct svc_req *request, SVCXPRT *transp)
{
@ -135,7 +134,7 @@ rquota_service(struct svc_req *request, SVCXPRT *transp)
}
/* read quota for the specified id, and send it */
void
static void
sendquota(struct svc_req *request, SVCXPRT *transp)
{
struct getquota_args getq_args;
@ -184,26 +183,8 @@ sendquota(struct svc_req *request, SVCXPRT *transp)
}
}
void
printerr_reply(SVCXPRT *transp) /* when a reply to a request failed */
{
char name[INET6_ADDRSTRLEN];
struct sockaddr *caller;
int save_errno;
save_errno = errno;
caller = (struct sockaddr *)svc_getrpccaller(transp)->buf;
getnameinfo(caller, caller->sa_len, name, sizeof (name),
NULL, 0, NI_NUMERICHOST);
errno = save_errno;
if (errno == 0)
syslog(LOG_ERR, "couldn't send reply to %s", name);
else
syslog(LOG_ERR, "couldn't send reply to %s: %m", name);
}
/* initialise the fs_tab list from entries in /etc/fstab */
void
static void
initfs(void)
{
struct fs_stat *fs_current = NULL;
@ -241,7 +222,7 @@ initfs(void)
* gets the quotas for id, filesystem path.
* Return 0 if fail, 1 otherwise
*/
int
static int
getfsquota(long id, char *path, struct dqblk *dqblk)
{
struct quotafile *qf;
@ -281,7 +262,7 @@ getfsquota(long id, char *path, struct dqblk *dqblk)
* Check to see if a particular quota is to be enabled.
* Comes from quota.c, NetBSD 0.9
*/
int
static int
hasquota(struct fstab *fs, char **qfnamep)
{
static char initname, usrname[100];

View File

@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
.Dd September 2, 2009
.Dd September 23, 2009
.Dt IFCONFIG 8
.Os
.Sh NAME
@ -598,7 +598,10 @@ If the interface was reset when previously marked down,
the hardware will be re-initialized.
.El
.Pp
The following parameters are for ICMPv6 Neightbor Discovery Protocol:
The following parameters are for ICMPv6 Neightbor Discovery Protocol.
Note that the address family keyword
.Dq Li inet6
is needed for them:
.Bl -tag -width indent
.It Cm accept_rtadv
Set a flag to enable accepting ICMPv6 Router Advertisement messages.
@ -619,7 +622,10 @@ Clear a flag
.Cm defaultif .
.It Cm ifdisabled
Set a flag to disable all of IPv6 network communications on the
specified interface.
specified interface. Note that if there are already configured IPv6
addresses on that interface, all of them are marked as
.Dq tentative
and DAD will be performed when this flag is cleared.
.It Cm -ifdisabled
Clear a flag
.Cm ifdisabled .

View File

@ -173,6 +173,7 @@ MAN= aac.4 \
le.4 \
led.4 \
lge.4 \
${_lindev.4} \
${_linux.4} \
lmc.4 \
lo.4 \
@ -625,6 +626,7 @@ _if_urtw.4= if_urtw.4
_if_wpi.4= if_wpi.4
_ipmi.4= ipmi.4
_io.4= io.4
_lindev.4= lindev.4
_linux.4= linux.4
_ndis.4= ndis.4
_nfe.4= nfe.4
@ -636,6 +638,8 @@ _speaker.4= speaker.4
_spkr.4= spkr.4
_urtw.4= urtw.4
_wpi.4= wpi.4
MLINKS+=lindev.4 full.4
.endif
.if exists(${.CURDIR}/man4.${MACHINE_ARCH})

73
share/man/man4/lindev.4 Normal file
View File

@ -0,0 +1,73 @@
.\"-
.\" Copyright (c) 2009 "Bjoern A. Zeeb" <bz@FreeBSD.org>
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
.\"
.\" $FreeBSD$
.\"
.Dd September 26, 2009
.Dt LINDEV 4
.Os
.Sh NAME
.Nm lindev
.Nd the lindev module
.Sh SYNOPSIS
To compile this collection of linux-specific pseudo devices into the kernel,
place the following line in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "device lindev"
.Ed
.Pp
Alternatively, to load the driver as a module at boot time,
place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
lindev_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
module provides a collection of linux-specific pseudo devices.
.Sh DEVICES
.Bl -tag -width /dev/full
.It Pa /dev/full
The
.Xr full
device always returns
.Er ENOSPC
on write attempts.
For reads it emulates
.Xr zero 4 .
.El
.Sh FILES
.Bl -tag -width /dev/full
.It Pa /dev/full
.El
.Sh SEE ALSO
.Xr null 4 ,
.Xr zero 4
.Sh HISTORY
The
.Nm
module first appeared in
.Fx 9.0 .

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 17, 2009
.Dd September 23, 2009
.Dt RC.CONF 5
.Os
.Sh NAME
@ -1246,28 +1246,85 @@ It is also possible to rename interface by doing:
ifconfig_ed0_name="net0"
ifconfig_net0="inet 192.0.2.1 netmask 0xffffff00"
.Ed
.It Va ipv6_enable
.Pq Vt bool
If the variable is
.Dq Li YES ,
.Dq Li inet6 accept_rtadv
is added to all of
.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6
and the
.Va ipv6_prefer
is defined as
.Dq Li YES .
.Pp
This variable is deprecated. Use
.Va ipv6_prefer
and
.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 .
.It Va ipv6_prefer
.Pq Vt bool
This variable does the following:
.Pp
If the variable is
.Dq Li YES ,
the default policy of the source address selection set by
.Xr ip6addrctl 8
will be IPv6-preferred.
.Pp
If the variable is
.Dq Li NO ,
the default policy of the source address selection set by
.Xr ip6addrctl 8
will be IPv4-preferred, and all of interfaces which does not have the
corrsponding
.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6
variable will be marked as
.Dq Li IFDISABLED .
This means only IPv6 functionality on that interface is completely
disabled. For more details of
.Dq Li IFDISABLED
flag and keywords
.Dq Li inet6 ifdisabled ,
see
.Xr ifconfig 8 .
.Pp
.It Va ipv6_network_interfaces
.Pq Vt str
This is the IPv6 equivalent of
.Va network_interfaces .
Instead of setting the ifconfig variables as
.Va ifconfig_ Ns Aq Ar interface
they should be set as
.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6.
Aliases should be set as
.Va ifconfig_ Ns Ao Ar interface Ac Ns Va _alias Ns Aq Ar n .
.Va ipv6_prefix_ Ns Aq Ar interface
does something.
Interfaces that have a
.Fl accept_rtadv
flag in
Normally manual configuration of this variable is not needed.
.Pp
IPv6 functionality on an interface should be configured by
.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6 ,
instead of setting ifconfig parameters in
.Va ifconfig_ Ns Aq Ar interface .
Aliases should be set by
.Va ifconfig_ Ns Ao Ar interface Ac Ns Va _alias Ns Aq Ar n
with
.Dq Li inet6
keyword. For example:
.Bd -literal
ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64"
ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64"
.Ed
.Pp
Interfaces that have an
.Dq Li inet6 accept_rtadv
keyword in
.Va ifconfig_ Ns Ao Ar interface Ac Ns _ipv6
setting will be automatically configured by
.Xr rtsol 8
if the
.Xr rtsol 8 .
Note that this automatic configuration is disabled if the
.Va ipv6_gateway_enable
is set to
.Dq Li NO .
.Dq Li YES .
.It Va ipv6_prefix_ Ns Aq Ar interface
.Pq Vt str
If one or more prefixes are defined in
.Va ipv6_prefix_ Ns Aq Ar interface
addresses based on each prefix and the EUI-64 interface index will be
configured on that interface.
.It Va ipv6_default_interface
.Pq Vt str
If not set to

View File

@ -517,3 +517,6 @@ options VM_KMEM_SIZE_SCALE
# Enable NDIS binary driver support
options NDISAPI
device ndis
# Linux-specific pseudo devices support
device lindev

View File

@ -54,30 +54,12 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/cpuconf.h>
#include <machine/md_var.h>
char machine[] = "arm";
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
machine, 0, "Machine class");
enum cpu_class {
CPU_CLASS_NONE,
CPU_CLASS_ARM2,
CPU_CLASS_ARM2AS,
CPU_CLASS_ARM3,
CPU_CLASS_ARM6,
CPU_CLASS_ARM7,
CPU_CLASS_ARM7TDMI,
CPU_CLASS_ARM8,
CPU_CLASS_ARM9TDMI,
CPU_CLASS_ARM9ES,
CPU_CLASS_ARM9EJS,
CPU_CLASS_ARM10E,
CPU_CLASS_ARM10EJ,
CPU_CLASS_SA1,
CPU_CLASS_XSCALE,
CPU_CLASS_ARM11J,
CPU_CLASS_MARVELL
};
static const char * const generic_steppings[16] = {
"rev 0", "rev 1", "rev 2", "rev 3",
@ -372,11 +354,11 @@ static const char * const wtnames[] = {
extern int ctrl;
enum cpu_class cpu_class = CPU_CLASS_NONE;
void
identify_arm_cpu(void)
{
u_int cpuid;
enum cpu_class cpu_class = CPU_CLASS_NONE;
int i;
cpuid = cpu_id();

View File

@ -48,6 +48,27 @@ extern int _min_bzero_size;
#define SRC_IS_USER 0x2
#define IS_PHYSICAL 0x4
enum cpu_class {
CPU_CLASS_NONE,
CPU_CLASS_ARM2,
CPU_CLASS_ARM2AS,
CPU_CLASS_ARM3,
CPU_CLASS_ARM6,
CPU_CLASS_ARM7,
CPU_CLASS_ARM7TDMI,
CPU_CLASS_ARM8,
CPU_CLASS_ARM9TDMI,
CPU_CLASS_ARM9ES,
CPU_CLASS_ARM9EJS,
CPU_CLASS_ARM10E,
CPU_CLASS_ARM10EJ,
CPU_CLASS_SA1,
CPU_CLASS_XSCALE,
CPU_CLASS_ARM11J,
CPU_CLASS_MARVELL
};
extern enum cpu_class cpu_class;
struct dumperinfo;
extern int busdma_swi_pending;
void busdma_swi(void);

View File

@ -179,6 +179,7 @@ screensave_name="green_saver" # Set to the name of the screensaver module
ibcs2_load="NO" # IBCS2 (SCO) emulation
ibcs2_coff_load="NO"
linux_load="NO" # Linux emulation
lindev_load="NO" # Linux-specific pseudo devices (see lindev(4))
svr4_load="NO" # SystemV R4 emulation
streams_load="NO" # System V streams module

View File

@ -595,7 +595,6 @@ gfs_file_inactive(vnode_t *vp)
if (vp->v_flag & V_XATTRDIR)
VI_LOCK(fp->gfs_parent);
VI_LOCK(vp);
ASSERT(vp->v_count < 2);
/*
* Really remove this vnode
*/
@ -607,12 +606,7 @@ gfs_file_inactive(vnode_t *vp)
*/
ge->gfse_vnode = NULL;
}
if (vp->v_count == 1) {
vp->v_usecount--;
vdropl(vp);
} else {
VI_UNLOCK(vp);
}
VI_UNLOCK(vp);
/*
* Free vnode and release parent
@ -1084,18 +1078,16 @@ gfs_vop_inactive(ap)
{
vnode_t *vp = ap->a_vp;
gfs_file_t *fp = vp->v_data;
void *data;
if (fp->gfs_type == GFS_DIR)
data = gfs_dir_inactive(vp);
gfs_dir_inactive(vp);
else
data = gfs_file_inactive(vp);
if (data != NULL)
kmem_free(data, fp->gfs_size);
gfs_file_inactive(vp);
VI_LOCK(vp);
vp->v_data = NULL;
VI_UNLOCK(vp);
kmem_free(fp, fp->gfs_size);
return (0);
}

View File

@ -818,7 +818,11 @@ zfsctl_snapdir_lookup(ap)
if ((sep = avl_find(&sdp->sd_snaps, &search, &where)) != NULL) {
*vpp = sep->se_root;
VN_HOLD(*vpp);
if ((*vpp)->v_mountedhere == NULL) {
err = traverse(vpp, LK_EXCLUSIVE | LK_RETRY);
if (err) {
VN_RELE(*vpp);
*vpp = NULL;
} else if (*vpp == sep->se_root) {
/*
* The snapshot was unmounted behind our backs,
* try to remount it.
@ -832,10 +836,9 @@ zfsctl_snapdir_lookup(ap)
*/
(*vpp)->v_flag &= ~VROOT;
}
vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
mutex_exit(&sdp->sd_lock);
ZFS_EXIT(zfsvfs);
return (0);
return (err);
}
/*
@ -895,6 +898,8 @@ zfsctl_snapdir_lookup(ap)
}
mutex_exit(&sdp->sd_lock);
ZFS_EXIT(zfsvfs);
if (err != 0)
*vpp = NULL;
return (err);
}
@ -1002,15 +1007,24 @@ zfsctl_snapdir_inactive(ap)
{
vnode_t *vp = ap->a_vp;
zfsctl_snapdir_t *sdp = vp->v_data;
void *private;
zfs_snapentry_t *sep;
private = gfs_dir_inactive(vp);
if (private != NULL) {
ASSERT(avl_numnodes(&sdp->sd_snaps) == 0);
mutex_destroy(&sdp->sd_lock);
avl_destroy(&sdp->sd_snaps);
kmem_free(private, sizeof (zfsctl_snapdir_t));
/*
* On forced unmount we have to free snapshots from here.
*/
mutex_enter(&sdp->sd_lock);
while ((sep = avl_first(&sdp->sd_snaps)) != NULL) {
avl_remove(&sdp->sd_snaps, sep);
kmem_free(sep->se_name, strlen(sep->se_name) + 1);
kmem_free(sep, sizeof (zfs_snapentry_t));
}
mutex_exit(&sdp->sd_lock);
gfs_dir_inactive(vp);
ASSERT(avl_numnodes(&sdp->sd_snaps) == 0);
mutex_destroy(&sdp->sd_lock);
avl_destroy(&sdp->sd_snaps);
kmem_free(sdp, sizeof (zfsctl_snapdir_t));
return (0);
}
@ -1068,6 +1082,9 @@ zfsctl_snapshot_inactive(ap)
int locked;
vnode_t *dvp;
if (vp->v_count > 0)
goto end;
VERIFY(gfs_dir_lookup(vp, "..", &dvp, cr, 0, NULL, NULL) == 0);
sdp = dvp->v_data;
VOP_UNLOCK(dvp, 0);
@ -1075,11 +1092,6 @@ zfsctl_snapshot_inactive(ap)
if (!(locked = MUTEX_HELD(&sdp->sd_lock)))
mutex_enter(&sdp->sd_lock);
if (vp->v_count > 1) {
if (!locked)
mutex_exit(&sdp->sd_lock);
return (0);
}
ASSERT(!vn_ismntpt(vp));
sep = avl_first(&sdp->sd_snaps);
@ -1099,6 +1111,7 @@ zfsctl_snapshot_inactive(ap)
if (!locked)
mutex_exit(&sdp->sd_lock);
VN_RELE(dvp);
end:
VFS_RELE(vp->v_vfsp);
/*

View File

@ -1107,8 +1107,7 @@ zfs_umount(vfs_t *vfsp, int fflag)
if (zfsvfs->z_issnap) {
vnode_t *svp = vfsp->mnt_vnodecovered;
ASSERT(svp->v_count == 2 || svp->v_count == 1);
if (svp->v_count == 2)
if (svp->v_count >= 2)
VN_RELE(svp);
}
zfs_freevfs(vfsp);

View File

@ -208,6 +208,8 @@ dev/hwpmc/hwpmc_piv.c optional hwpmc
dev/hwpmc/hwpmc_tsc.c optional hwpmc
dev/hwpmc/hwpmc_x86.c optional hwpmc
dev/kbd/kbd.c optional atkbd | sc | ukbd | usb2_input_kbd
dev/lindev/full.c optional lindev
dev/lindev/lindev.c optional lindev
dev/mem/memutil.c optional mem
dev/nfe/if_nfe.c optional nfe pci
dev/nve/if_nve.c optional nve pci

View File

@ -201,6 +201,8 @@ dev/ipmi/ipmi_pci.c optional ipmi pci
dev/ipmi/ipmi_linux.c optional ipmi compat_linux
dev/kbd/kbd.c optional atkbd | sc | ukbd | usb2_input_kbd
dev/le/if_le_isa.c optional le isa
dev/lindev/full.c optional lindev
dev/lindev/lindev.c optional lindev
dev/mem/memutil.c optional mem
dev/mse/mse.c optional mse
dev/mse/mse_isa.c optional mse isa

View File

@ -107,6 +107,8 @@ dev/hwpmc/hwpmc_x86.c optional hwpmc
dev/io/iodev.c optional io
dev/kbd/kbd.c optional pckbd | sc | ukbd | usb2_input_kbd
dev/le/if_le_cbus.c optional le isa
dev/lindev/full.c optional lindev
dev/lindev/lindev.c optional lindev
dev/mem/memutil.c optional mem
dev/mse/mse.c optional mse
dev/mse/mse_cbus.c optional mse isa

103
sys/dev/lindev/full.c Normal file
View File

@ -0,0 +1,103 @@
/*-
* Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <dev/lindev/lindev.h>
static struct cdev *full_dev;
static d_read_t full_read;
static d_write_t full_write;
static struct cdevsw full_cdevsw = {
.d_version = D_VERSION,
.d_read = full_read,
.d_write = full_write,
.d_name = "full",
};
static void *zbuf;
/* ARGSUSED */
static int
full_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
{
int error = 0;
while (uio->uio_resid > 0 && error == 0)
error = uiomove(zbuf, MIN(uio->uio_resid, PAGE_SIZE), uio);
return (error);
}
/* ARGSUSED */
static int
full_write(struct cdev *dev __unused, struct uio *uio __unused,
int flags __unused)
{
return (ENOSPC);
}
/* ARGSUSED */
int
lindev_modevent_full(module_t mod __unused, int type, void *data __unused)
{
switch(type) {
case MOD_LOAD:
zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO);
full_dev = make_dev(&full_cdevsw, 0, UID_ROOT, GID_WHEEL,
0666, "full");
if (bootverbose)
printf("full: <full device>\n");
break;
case MOD_UNLOAD:
destroy_dev(full_dev);
free(zbuf, M_TEMP);
break;
case MOD_SHUTDOWN:
break;
default:
return (EOPNOTSUPP);
}
return (0);
}

73
sys/dev/lindev/lindev.c Normal file
View File

@ -0,0 +1,73 @@
/*-
* Copyright (c) 2009 "Bjoern A. Zeeb" <bz@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
/*
* "lindev" is supposed to be a collection of linux-specific devices
* that we also support, just not by default.
* While currently there is only "/dev/full", we are planning to see
* more in the future.
* This file is only the container to load/unload all supported devices;
* the implementation of each should go into its own file.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <dev/lindev/lindev.h>
/* ARGSUSED */
static int
lindev_modevent(module_t mod, int type, void *data)
{
int error;
switch(type) {
case MOD_LOAD:
error = lindev_modevent_full(mod, type, data);
break;
case MOD_UNLOAD:
error = lindev_modevent_full(mod, type, data);
break;
case MOD_SHUTDOWN:
error = lindev_modevent_full(mod, type, data);
break;
default:
return (EOPNOTSUPP);
}
return (error);
}
DEV_MODULE(lindev, lindev_modevent, NULL);
MODULE_VERSION(lindev, 1);

34
sys/dev/lindev/lindev.h Normal file
View File

@ -0,0 +1,34 @@
/*-
* Copyright (c) 2009 "Bjoern A. Zeeb" <bz@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
#ifndef _DEV_LINDEV_LINDEV_H
#define _DEV_LINDEV_LINDEV_H
int lindev_modevent_full(module_t, int, void *);
#endif /* _DEV_LINDEV_LINDEV_H */

View File

@ -313,11 +313,11 @@ scteken_attr(const teken_attr_t *a)
teken_color_t fg, bg;
if (a->ta_format & TF_REVERSE) {
fg = a->ta_bgcolor;
bg = a->ta_fgcolor;
fg = teken_256to8(a->ta_bgcolor);
bg = teken_256to8(a->ta_fgcolor);
} else {
fg = a->ta_fgcolor;
bg = a->ta_bgcolor;
fg = teken_256to8(a->ta_fgcolor);
bg = teken_256to8(a->ta_bgcolor);
}
if (a->ta_format & TF_BOLD)
attr |= fgcolors_bold[fg];

View File

@ -880,6 +880,9 @@ device streams # STREAMS network driver (required for svr4).
options NDISAPI
device ndis
# Linux-specific pseudo devices support
device lindev
#####################################################################
# VM OPTIONS

View File

@ -151,6 +151,7 @@ SUBDIR= ${_3dfx} \
libiconv \
libmbpool \
libmchain \
${_lindev} \
${_linprocfs} \
${_linsysfs} \
${_linux} \
@ -373,6 +374,7 @@ _ie= ie
_if_ndis= if_ndis
_igb= igb
_io= io
_lindev= lindev
_linprocfs= linprocfs
_linsysfs= linsysfs
_linux= linux
@ -510,6 +512,7 @@ _ipwfw= ipwfw
_iwn= iwn
_iwnfw= iwnfw
_ixgb= ixgb
_lindev= lindev
_linprocfs= linprocfs
_linsysfs= linsysfs
_linux= linux

View File

@ -0,0 +1,8 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/lindev
KMOD= lindev
SRCS= full.c lindev.c
.include <bsd.kmod.mk>

View File

@ -1332,7 +1332,7 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
tl = nfsm_dissect_nonblock(u_int32_t *,
NFSX_V3CREATEVERF);
/* Unique bytes, endianness is not important. */
cverf.tv_sec = tl[0];
cverf.tv_sec = (int32_t)tl[0];
cverf.tv_nsec = tl[1];
exclusive_flag = 1;
break;

View File

@ -565,6 +565,9 @@ options COMPAT_SVR4 # build emulator statically
options DEBUG_SVR4 # enable verbose debugging
device streams # STREAMS network driver (required for svr4).
# Linux-specific pseudo devices support
device lindev
#####################################################################
# VM OPTIONS

View File

@ -196,13 +196,13 @@ teken_input_char(teken_t *t, teken_char_t c)
if (t->t_stateflags & TS_CONS25)
t->t_nextstate(t, c);
else
teken_scs_switch(t, 1);
t->t_curscs = 1;
break;
case '\x0F':
if (t->t_stateflags & TS_CONS25)
t->t_nextstate(t, c);
else
teken_scs_switch(t, 0);
t->t_curscs = 0;
break;
case '\r':
teken_subr_carriage_return(t);
@ -409,4 +409,55 @@ teken_state_numbers(teken_t *t, teken_char_t c)
return (0);
}
teken_color_t
teken_256to8(teken_color_t c)
{
unsigned int r, g, b;
if (c < 16) {
/* Traditional color indices. */
return (c % 8);
} else if (c >= 244) {
/* Upper grayscale colors. */
return (TC_WHITE);
} else if (c >= 232) {
/* Lower grayscale colors. */
return (TC_BLACK);
}
/* Convert to RGB. */
c -= 16;
b = c % 6;
g = (c / 6) % 6;
r = c / 36;
if (r < g) {
/* Possibly green. */
if (g < b)
return (TC_BLUE);
else if (g > b)
return (TC_GREEN);
else
return (TC_CYAN);
} else if (r > g) {
/* Possibly red. */
if (r < b)
return (TC_BLUE);
else if (r > b)
return (TC_RED);
else
return (TC_MAGENTA);
} else {
/* Possibly brown. */
if (g < b)
return (TC_BLUE);
else if (g > b)
return (TC_BROWN);
else if (r < 3)
return (TC_BLACK);
else
return (TC_WHITE);
}
}
#include "teken_state.h"

View File

@ -171,4 +171,7 @@ void teken_set_winsize(teken_t *, const teken_pos_t *);
void teken_set_8bit(teken_t *);
void teken_set_cons25(teken_t *);
/* Color conversion. */
teken_color_t teken_256to8(teken_color_t);
#endif /* !_TEKEN_H_ */

View File

@ -116,7 +116,8 @@ printchar(const teken_pos_t *p)
if (px->a.ta_format & TF_REVERSE)
attr |= A_REVERSE;
bkgdset(attr | COLOR_PAIR(px->a.ta_fgcolor + 8 * px->a.ta_bgcolor));
bkgdset(attr | COLOR_PAIR(teken_256to8(px->a.ta_fgcolor) +
8 * teken_256to8(px->a.ta_bgcolor)));
mvaddstr(p->tp_row, p->tp_col, str);
move(y, x);

View File

@ -26,35 +26,7 @@
* $FreeBSD$
*/
static void
teken_scs_set(teken_t *t, unsigned int g, teken_scs_t *ts)
{
t->t_scs[g] = ts;
}
static void
teken_scs_switch(teken_t *t, unsigned int g)
{
t->t_curscs = g;
}
static void
teken_scs_restore(teken_t *t)
{
t->t_scs[t->t_curscs] = t->t_saved_curscs;
}
static void
teken_scs_save(teken_t *t)
{
t->t_saved_curscs = t->t_scs[t->t_curscs];
}
static teken_char_t
static inline teken_char_t
teken_scs_process(teken_t *t, teken_char_t c)
{

View File

@ -92,13 +92,16 @@ stress_respond(void *s __unused, const void *buf __unused, size_t len __unused)
{
}
static const char replacement[] =
{ 0x1b, '[', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';' };
int
main(int argc __unused, char *argv[] __unused)
{
teken_t t;
int rnd;
unsigned int iteration = 0;
char buf[2048];
unsigned int i, iteration = 0;
unsigned char buf[2048];
rnd = open("/dev/urandom", O_RDONLY);
if (rnd < 0) {
@ -114,6 +117,12 @@ main(int argc __unused, char *argv[] __unused)
exit(1);
}
for (i = 0; i < sizeof buf; i++) {
if (buf[i] >= 0x80)
buf[i] =
replacement[buf[i] % sizeof replacement];
}
teken_input(&t, buf, sizeof buf);
iteration++;

View File

@ -185,11 +185,11 @@ teken_subr_alignment_test(teken_t *t)
{
teken_rect_t tr;
t->t_cursor.tp_row = t->t_cursor.tp_col = 0;
t->t_scrollreg.ts_begin = 0;
t->t_scrollreg.ts_end = t->t_winsize.tp_row;
t->t_cursor.tp_row = t->t_cursor.tp_col = 0;
t->t_stateflags &= ~TS_WRAPPED;
t->t_originreg = t->t_scrollreg;
t->t_stateflags &= ~(TS_WRAPPED|TS_ORIGIN);
teken_funcs_cursor(t);
tr.tr_begin.tp_row = 0;
@ -540,42 +540,42 @@ static void
teken_subr_g0_scs_special_graphics(teken_t *t __unused)
{
teken_scs_set(t, 0, teken_scs_special_graphics);
t->t_scs[0] = teken_scs_special_graphics;
}
static void
teken_subr_g0_scs_uk_national(teken_t *t __unused)
{
teken_scs_set(t, 0, teken_scs_uk_national);
t->t_scs[0] = teken_scs_uk_national;
}
static void
teken_subr_g0_scs_us_ascii(teken_t *t __unused)
{
teken_scs_set(t, 0, teken_scs_us_ascii);
t->t_scs[0] = teken_scs_us_ascii;
}
static void
teken_subr_g1_scs_special_graphics(teken_t *t __unused)
{
teken_scs_set(t, 1, teken_scs_special_graphics);
t->t_scs[1] = teken_scs_special_graphics;
}
static void
teken_subr_g1_scs_uk_national(teken_t *t __unused)
{
teken_scs_set(t, 1, teken_scs_uk_national);
t->t_scs[1] = teken_scs_uk_national;
}
static void
teken_subr_g1_scs_us_ascii(teken_t *t __unused)
{
teken_scs_set(t, 1, teken_scs_us_ascii);
t->t_scs[1] = teken_scs_us_ascii;
}
static void
@ -962,9 +962,9 @@ teken_subr_do_reset(teken_t *t)
t->t_stateflags &= TS_8BIT|TS_CONS25;
t->t_stateflags |= TS_AUTOWRAP;
teken_scs_set(t, 0, teken_scs_us_ascii);
teken_scs_set(t, 1, teken_scs_us_ascii);
teken_scs_switch(t, 0);
t->t_scs[0] = teken_scs_us_ascii;
t->t_scs[1] = teken_scs_us_ascii;
t->t_curscs = 0;
teken_subr_save_cursor(t);
teken_tab_default(t);
@ -986,8 +986,17 @@ teken_subr_restore_cursor(teken_t *t)
t->t_cursor = t->t_saved_cursor;
t->t_curattr = t->t_saved_curattr;
t->t_scs[t->t_curscs] = t->t_saved_curscs;
t->t_stateflags &= ~TS_WRAPPED;
teken_scs_restore(t);
/* Get out of origin mode when the cursor is moved outside. */
if (t->t_cursor.tp_row < t->t_originreg.ts_begin ||
t->t_cursor.tp_row >= t->t_originreg.ts_end) {
t->t_stateflags &= ~TS_ORIGIN;
t->t_originreg.ts_begin = 0;
t->t_originreg.ts_end = t->t_winsize.tp_row;
}
teken_funcs_cursor(t);
}
@ -1010,7 +1019,7 @@ teken_subr_save_cursor(teken_t *t)
t->t_saved_cursor = t->t_cursor;
t->t_saved_curattr = t->t_curattr;
teken_scs_save(t);
t->t_saved_curscs = t->t_scs[t->t_curscs];
}
static void
@ -1141,6 +1150,12 @@ teken_subr_set_graphic_rendition(teken_t *t, unsigned int ncmds,
case 37: /* Set foreground color: white */
t->t_curattr.ta_fgcolor = n - 30;
break;
case 38: /* Set foreground color: 256 color mode */
if (i + 2 >= ncmds || cmds[i + 1] != 5)
continue;
t->t_curattr.ta_fgcolor = cmds[i + 2];
i += 2;
break;
case 39: /* Set default foreground color. */
t->t_curattr.ta_fgcolor = t->t_defattr.ta_fgcolor;
break;
@ -1154,9 +1169,35 @@ teken_subr_set_graphic_rendition(teken_t *t, unsigned int ncmds,
case 47: /* Set background color: white */
t->t_curattr.ta_bgcolor = n - 40;
break;
case 48: /* Set background color: 256 color mode */
if (i + 2 >= ncmds || cmds[i + 1] != 5)
continue;
t->t_curattr.ta_bgcolor = cmds[i + 2];
i += 2;
break;
case 49: /* Set default background color. */
t->t_curattr.ta_bgcolor = t->t_defattr.ta_bgcolor;
break;
case 90: /* Set bright foreground color: black */
case 91: /* Set bright foreground color: red */
case 92: /* Set bright foreground color: green */
case 93: /* Set bright foreground color: brown */
case 94: /* Set bright foreground color: blue */
case 95: /* Set bright foreground color: magenta */
case 96: /* Set bright foreground color: cyan */
case 97: /* Set bright foreground color: white */
t->t_curattr.ta_fgcolor = n - 90 + 8;
break;
case 100: /* Set bright background color: black */
case 101: /* Set bright background color: red */
case 102: /* Set bright background color: green */
case 103: /* Set bright background color: brown */
case 104: /* Set bright background color: blue */
case 105: /* Set bright background color: magenta */
case 106: /* Set bright background color: cyan */
case 107: /* Set bright background color: white */
t->t_curattr.ta_bgcolor = n - 100 + 8;
break;
default:
teken_printf("unsupported attribute %u\n", n);
}

View File

@ -65,10 +65,10 @@ void
teken_get_defattr_cons25(teken_t *t, int *fg, int *bg)
{
*fg = cons25_revcolors[t->t_defattr.ta_fgcolor];
*fg = cons25_revcolors[teken_256to8(t->t_defattr.ta_fgcolor)];
if (t->t_defattr.ta_format & TF_BOLD)
*fg += 8;
*bg = cons25_revcolors[t->t_defattr.ta_bgcolor];
*bg = cons25_revcolors[teken_256to8(t->t_defattr.ta_bgcolor)];
}
static void