From 1aba32d9b48ebb987a5c2bcbcdaf0f16ba63e08d Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 26 Sep 2009 00:04:30 +0000 Subject: [PATCH 01/16] - Don't depend on value returned by gfs_*_inactive(), it doesn't work well with forced unmounts when GFS vnodes are referenced. - Make other preparations to GFS for forced unmounts. PR: kern/139062 Reported by: trasz MFC after: 3 days --- .../contrib/opensolaris/uts/common/fs/gfs.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c b/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c index cd522bfebbf0..269c3ebe75d8 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c @@ -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); } From a99aaff64500e19e2704af159fb1a2eb98903a64 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 26 Sep 2009 00:07:14 +0000 Subject: [PATCH 02/16] Use traverse() function to find and return mount point's vnode instead of covered vnode when snapshot is already mounted. MFC after: 3 days --- .../contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c index 0b034f627ceb..cdc3774026e2 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c @@ -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); } /* From a0b238644a6fd799fbd9fb4140ade9a788ed795b Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 26 Sep 2009 00:08:44 +0000 Subject: [PATCH 03/16] On lookup error VFS expects *vpp to be set to NULL, be sure to do that. MFC after: 3 days --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c index cdc3774026e2..65b32629c0ae 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c @@ -898,6 +898,8 @@ zfsctl_snapdir_lookup(ap) } mutex_exit(&sdp->sd_lock); ZFS_EXIT(zfsvfs); + if (err != 0) + *vpp = NULL; return (err); } From ab711589df4cf53441b77a098244f5b8968ff294 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 26 Sep 2009 00:10:45 +0000 Subject: [PATCH 04/16] Handle cases where virtual (GFS) vnodes are referenced when doing forced unmount. In that case we cannot depend on the proper order of invalidating vnodes, so we have to free resources when we have a chance. PR: kern/139062 Reported by: trasz MFC after: 3 days --- .../uts/common/fs/zfs/zfs_ctldir.c | 32 ++++++++++++------- .../uts/common/fs/zfs/zfs_vfsops.c | 3 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c index 65b32629c0ae..7820293f68a3 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c @@ -1007,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); } @@ -1073,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); @@ -1080,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); @@ -1104,6 +1111,7 @@ zfsctl_snapshot_inactive(ap) if (!locked) mutex_exit(&sdp->sd_lock); VN_RELE(dvp); +end: VFS_RELE(vp->v_vfsp); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index b9a4b2fd8938..08996ee2a5bf 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -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); From 4507f02e0ea22f2cc59d673f11d2a95fedef2127 Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Sat, 26 Sep 2009 12:45:28 +0000 Subject: [PATCH 05/16] lindev(4) [1] is supposed to be a collection of linux-specific pseudo devices that we also support, just not by default (thus only LINT or module builds by default). While currently there is only "/dev/full" [2], we are planning to see more in the future. We may decide to change the module/dependency logic in the future should the list grow too long. This is not part of linux.ko as also non-linux binaries like kFreeBSD userland or ports can make use of this as well. Suggested by: rwatson [1] (name) Submitted by: ed [2] Discussed with: markm, ed, rwatson, kib (weeks ago) Reviewed by: rwatson, brueffer (prev. version) PR: kern/68961 MFC after: 6 weeks --- share/man/man4/Makefile | 4 ++ share/man/man4/lindev.4 | 73 +++++++++++++++++++++++++ sys/amd64/conf/NOTES | 3 ++ sys/boot/forth/loader.conf | 1 + sys/conf/files.amd64 | 2 + sys/conf/files.i386 | 2 + sys/conf/files.pc98 | 2 + sys/dev/lindev/full.c | 103 ++++++++++++++++++++++++++++++++++++ sys/dev/lindev/lindev.c | 73 +++++++++++++++++++++++++ sys/dev/lindev/lindev.h | 34 ++++++++++++ sys/i386/conf/NOTES | 3 ++ sys/modules/Makefile | 3 ++ sys/modules/lindev/Makefile | 8 +++ sys/pc98/conf/NOTES | 3 ++ 14 files changed, 314 insertions(+) create mode 100644 share/man/man4/lindev.4 create mode 100644 sys/dev/lindev/full.c create mode 100644 sys/dev/lindev/lindev.c create mode 100644 sys/dev/lindev/lindev.h create mode 100644 sys/modules/lindev/Makefile diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index dca2775deadc..74d0c3d8b1d1 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -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}) diff --git a/share/man/man4/lindev.4 b/share/man/man4/lindev.4 new file mode 100644 index 000000000000..b2dc60efc80b --- /dev/null +++ b/share/man/man4/lindev.4 @@ -0,0 +1,73 @@ +.\"- +.\" Copyright (c) 2009 "Bjoern A. Zeeb" +.\" 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 . diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index f3619cfa717b..d213643e58f8 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -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 diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf index 862e86ffa214..44eef5fb9b1e 100644 --- a/sys/boot/forth/loader.conf +++ b/sys/boot/forth/loader.conf @@ -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 diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 0721ea4ec3bc..30d6e5ac1332 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -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 diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index ef6d590b5f2e..7f6cadd4293b 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -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 diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98 index 7aedb38517a3..7f2afc5059cb 100644 --- a/sys/conf/files.pc98 +++ b/sys/conf/files.pc98 @@ -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 diff --git a/sys/dev/lindev/full.c b/sys/dev/lindev/full.c new file mode 100644 index 000000000000..294094c075d3 --- /dev/null +++ b/sys/dev/lindev/full.c @@ -0,0 +1,103 @@ +/*- + * Copyright (c) 2009 Ed Schouten + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +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: \n"); + break; + + case MOD_UNLOAD: + destroy_dev(full_dev); + free(zbuf, M_TEMP); + break; + + case MOD_SHUTDOWN: + break; + + default: + return (EOPNOTSUPP); + } + + return (0); +} + diff --git a/sys/dev/lindev/lindev.c b/sys/dev/lindev/lindev.c new file mode 100644 index 000000000000..cf876042ae95 --- /dev/null +++ b/sys/dev/lindev/lindev.c @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2009 "Bjoern A. Zeeb" + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include + +/* 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); diff --git a/sys/dev/lindev/lindev.h b/sys/dev/lindev/lindev.h new file mode 100644 index 000000000000..9b0be8250a02 --- /dev/null +++ b/sys/dev/lindev/lindev.h @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2009 "Bjoern A. Zeeb" + * 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 */ diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 594c43a5669c..d85e3f6abc77 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -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 diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 49d88600d1a6..88d02997814d 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -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 diff --git a/sys/modules/lindev/Makefile b/sys/modules/lindev/Makefile new file mode 100644 index 000000000000..704cac331dce --- /dev/null +++ b/sys/modules/lindev/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/lindev + +KMOD= lindev +SRCS= full.c lindev.c + +.include diff --git a/sys/pc98/conf/NOTES b/sys/pc98/conf/NOTES index 9ab70b9e5d1c..990fc94a2ea0 100644 --- a/sys/pc98/conf/NOTES +++ b/sys/pc98/conf/NOTES @@ -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 From a78f7fafc0285ea157ddfb433982c4210d735cc7 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 26 Sep 2009 15:00:42 +0000 Subject: [PATCH 06/16] Make the fuzzer a bit more useful by forcing 7-bit data into it. Getting valid UTF-8 sequences is quite unlikely, so we'd better just convert data to 7 bits and make it extra likely for escape sequences to occur. --- sys/teken/teken_stress.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/teken/teken_stress.c b/sys/teken/teken_stress.c index 40d09bf903b0..1f1c57253f09 100644 --- a/sys/teken/teken_stress.c +++ b/sys/teken/teken_stress.c @@ -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++; From cd531e74e92a2a0462043eaf6ef420b6c20b53ed Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 26 Sep 2009 15:03:42 +0000 Subject: [PATCH 07/16] Get rid of now deprecated SCS wrappers. We always build SCS, even when processing 8-bit data. There is no reason why we should be able to disable it now. --- sys/teken/teken.c | 4 ++-- sys/teken/teken_scs.h | 30 +----------------------------- sys/teken/teken_subr.h | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/sys/teken/teken.c b/sys/teken/teken.c index c928510b86d9..f44969dcbb7e 100644 --- a/sys/teken/teken.c +++ b/sys/teken/teken.c @@ -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); diff --git a/sys/teken/teken_scs.h b/sys/teken/teken_scs.h index 5f42aa41c052..815e1d7f6680 100644 --- a/sys/teken/teken_scs.h +++ b/sys/teken/teken_scs.h @@ -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) { diff --git a/sys/teken/teken_subr.h b/sys/teken/teken_subr.h index 7d8cd0cbe935..0332770d34a1 100644 --- a/sys/teken/teken_subr.h +++ b/sys/teken/teken_subr.h @@ -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,8 @@ 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); teken_funcs_cursor(t); } @@ -1010,7 +1010,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 From f311d56014e13cd09bd1112802bb542ab90897d8 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 26 Sep 2009 15:07:11 +0000 Subject: [PATCH 08/16] Properly get out of origin mode if the cursor has to move outside of it. In some cases events may occur that move the cursor outside the scrolling region while in origin mode, which is normally not possible. Events like these include: - Alignment test. - Restore cursor. Properly switch off origin mode in these cases. MFC after: 1 month --- sys/teken/teken_subr.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/teken/teken_subr.h b/sys/teken/teken_subr.h index 0332770d34a1..4c3106589887 100644 --- a/sys/teken/teken_subr.h +++ b/sys/teken/teken_subr.h @@ -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; @@ -988,6 +988,15 @@ teken_subr_restore_cursor(teken_t *t) t->t_curattr = t->t_saved_curattr; t->t_scs[t->t_curscs] = t->t_saved_curscs; t->t_stateflags &= ~TS_WRAPPED; + + /* 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); } From 56a4365bde5f98c59de97124795d2d88188a002c Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 26 Sep 2009 15:26:32 +0000 Subject: [PATCH 09/16] Add 256 color support. It is quite inconvenient that if an application for xterm uses 256 color mode, text suddenly starts to blink (because of ;5; in the middle). We'd better just implement 256 color mode and add a conversion routine from 256 to 8 color mode, which doesn't seem to be too bad in practice. Remapping colors is done quite simple. If one of the channels is most actively represented, primary colors are used. If two channels are most actively represented, secondary colors are used. If all three channels are equal (gray), it picks between black and white. Reported by: Paul B. Mahol --- sys/dev/syscons/scterm-teken.c | 8 +++--- sys/teken/teken.c | 51 ++++++++++++++++++++++++++++++++++ sys/teken/teken.h | 3 ++ sys/teken/teken_demo.c | 3 +- sys/teken/teken_subr.h | 32 +++++++++++++++++++++ sys/teken/teken_subr_compat.h | 4 +-- 6 files changed, 94 insertions(+), 7 deletions(-) diff --git a/sys/dev/syscons/scterm-teken.c b/sys/dev/syscons/scterm-teken.c index 3c8a57a981c8..4782beb99747 100644 --- a/sys/dev/syscons/scterm-teken.c +++ b/sys/dev/syscons/scterm-teken.c @@ -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]; diff --git a/sys/teken/teken.c b/sys/teken/teken.c index f44969dcbb7e..c8d6b09cc33a 100644 --- a/sys/teken/teken.c +++ b/sys/teken/teken.c @@ -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" diff --git a/sys/teken/teken.h b/sys/teken/teken.h index 4e73f7b1c8c3..aab037f2526e 100644 --- a/sys/teken/teken.h +++ b/sys/teken/teken.h @@ -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_ */ diff --git a/sys/teken/teken_demo.c b/sys/teken/teken_demo.c index 4f8a0d5e5614..49397a6c2653 100644 --- a/sys/teken/teken_demo.c +++ b/sys/teken/teken_demo.c @@ -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); diff --git a/sys/teken/teken_subr.h b/sys/teken/teken_subr.h index 4c3106589887..32cae4dcc49d 100644 --- a/sys/teken/teken_subr.h +++ b/sys/teken/teken_subr.h @@ -1150,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; @@ -1163,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); } diff --git a/sys/teken/teken_subr_compat.h b/sys/teken/teken_subr_compat.h index 088f378af588..e93729832869 100644 --- a/sys/teken/teken_subr_compat.h +++ b/sys/teken/teken_subr_compat.h @@ -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 From 98c53ad360827b37847a2acb8500d67ff2c35243 Mon Sep 17 00:00:00 2001 From: Rui Paulo Date: Sat, 26 Sep 2009 16:37:23 +0000 Subject: [PATCH 10/16] Promote the cpu_class local variable to global and expose it in md_var.h Reviewed by: freebsd-arm --- sys/arm/arm/identcpu.c | 22 ++-------------------- sys/arm/include/md_var.h | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/sys/arm/arm/identcpu.c b/sys/arm/arm/identcpu.c index df67a8a022ae..294d5a99dbbc 100644 --- a/sys/arm/arm/identcpu.c +++ b/sys/arm/arm/identcpu.c @@ -54,30 +54,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include 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(); diff --git a/sys/arm/include/md_var.h b/sys/arm/include/md_var.h index 6d47a91189dc..1f622e2471c9 100644 --- a/sys/arm/include/md_var.h +++ b/sys/arm/include/md_var.h @@ -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); From b8947edcb691809b3be06bf383573d0e7c5cf7c5 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 26 Sep 2009 18:20:40 +0000 Subject: [PATCH 11/16] Make malloc(3) superpage aware. Specifically, if getpagesizes(3) returns a large page size that is greater than malloc(3)'s default chunk size but less than or equal to 4 MB, then increase the chunk size to match the large page size. Most often, using a chunk size that is less than the large page size is not a problem. However, consider a long-running application that allocates and frees significant amounts of memory. In particular, it frees enough memory at times that some of that memory is munmap()ed. Up until the first munmap(), a 1MB chunk size is just fine; it's not a problem for the virtual memory system. Two adjacent 1MB chunks that are aligned on a 2MB boundary will be promoted automatically to a superpage even though they were allocated at different times. The trouble begins with the munmap(), releasing a 1MB chunk will trigger the demotion of the containing superpage, leaving behind a half-used 2MB reservation. Now comes the real problem. Unfortunately, when the application needs to allocate more memory, and it recycles the previously munmap()ed address range, the implementation of mmap() won't be able to reuse the reservation. Basically, the coalescing rules in the virtual memory system don't allow this new range to combine with its neighbor. The effect being that superpage promotion will not reoccur for this range of addresses until both 1MB chunks are freed at some point in the future. Reviewed by: jasone MFC after: 3 weeks --- lib/libc/stdlib/malloc.3 | 6 ++++-- lib/libc/stdlib/malloc.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3 index a621a245b406..308ba7b3e123 100644 --- a/lib/libc/stdlib/malloc.3 +++ b/lib/libc/stdlib/malloc.3 @@ -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 diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index b56b0030bedf..bdc26b657dcb 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -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; From 5ff124a95315df2f138c033f7bdabeb590de95e1 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 26 Sep 2009 18:23:16 +0000 Subject: [PATCH 12/16] Ensure that tv_sec is between INT32_MIN and INT32_MAX, so ZFS won't object. This completes the fix from r185586. PR: kern/139059 Reported by: Daniel Braniss Submitted by: Jaakko Heinonen Tested by: Daniel Braniss MFC after: 3 days --- sys/nfsserver/nfs_serv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 7b4eacfd8db9..3bb9a6a2880a 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -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; From 2e77c5abfb68a17c1b11c8a378b9f7b74f1a564b Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 26 Sep 2009 18:59:00 +0000 Subject: [PATCH 13/16] Fix several logic bugs in the previous IPv6 variable change and re-add $ipv6_enable support for backward compatibility. From UPDATING: 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/or "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). --- UPDATING | 51 +++++++++++++++++++++++ etc/network.subr | 70 ++++++++++++++++++++++++++------ etc/rc.d/ip6addrctl | 2 + etc/rc.d/netif | 2 +- sbin/ifconfig/ifconfig.8 | 12 ++++-- share/man/man5/rc.conf.5 | 87 +++++++++++++++++++++++++++++++++------- 6 files changed, 193 insertions(+), 31 deletions(-) diff --git a/UPDATING b/UPDATING index e7b2fd4ee2af..16a9185956cf 100644 --- a/UPDATING +++ b/UPDATING @@ -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. diff --git a/etc/network.subr b/etc/network.subr index f9c10e8253c1..83141ec3879f 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -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 diff --git a/etc/rc.d/ip6addrctl b/etc/rc.d/ip6addrctl index 518ac2569741..66f1952a65b0 100755 --- a/etc/rc.d/ip6addrctl +++ b/etc/rc.d/ip6addrctl @@ -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 diff --git a/etc/rc.d/netif b/etc/rc.d/netif index ac2cc581d521..3c8e5dc5d200 100755 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -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() { diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index de241e7d4780..220bd9f415ce 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -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 . diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 4a491f7be943..bacd362a3c35 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -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 From 27fa984efdc333f4fcc1c8b352623aae54fab9c5 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 26 Sep 2009 19:00:20 +0000 Subject: [PATCH 14/16] Move rc.d/{stf,faith} to just before rc.d/routing. Pointed out by: tegge --- etc/rc.d/defaultroute | 2 +- etc/rc.d/routing | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/defaultroute b/etc/rc.d/defaultroute index 20e9025e18c4..cade406b796b 100755 --- a/etc/rc.d/defaultroute +++ b/etc/rc.d/defaultroute @@ -6,7 +6,7 @@ # # PROVIDE: defaultroute -# REQUIRE: devd netif +# REQUIRE: devd faith netif stf # KEYWORD: nojail . /etc/rc.subr diff --git a/etc/rc.d/routing b/etc/rc.d/routing index 787eaa1bc048..05f6013635a1 100755 --- a/etc/rc.d/routing +++ b/etc/rc.d/routing @@ -6,7 +6,7 @@ # # PROVIDE: routing -# REQUIRE: netif ppp +# REQUIRE: faith netif ppp stf # KEYWORD: nojail . /etc/rc.subr From 97c8942c918e3f8b32ef94d297bebfc18ebd87f7 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Sat, 26 Sep 2009 19:00:47 +0000 Subject: [PATCH 15/16] Use ipv6if() when $rtadvd_interfaces="AUTO". --- etc/rc.d/rtadvd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/rtadvd b/etc/rc.d/rtadvd index dbf4be257b73..99b700d2c826 100755 --- a/etc/rc.d/rtadvd +++ b/etc/rc.d/rtadvd @@ -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 From 2db2319de57dbecd4ca2e047f482f1f66ee7c9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sat, 26 Sep 2009 23:05:01 +0000 Subject: [PATCH 16/16] printerr_reply() has never been used for as long as we've had this code in our tree (13+ years). This is an excellent argument for aggressive use of "static". --- libexec/rpc.rquotad/rquotad.c | 43 ++++++++++------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/libexec/rpc.rquotad/rquotad.c b/libexec/rpc.rquotad/rquotad.c index 7c666af3170e..8b623da675a7 100644 --- a/libexec/rpc.rquotad/rquotad.c +++ b/libexec/rpc.rquotad/rquotad.c @@ -31,12 +31,11 @@ __FBSDID("$FreeBSD$"); #include #include -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 @@ -48,9 +47,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) @@ -111,7 +110,7 @@ main(void) exit(1); } -void +static void rquota_service(struct svc_req *request, SVCXPRT *transp) { @@ -134,7 +133,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; @@ -183,26 +182,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; @@ -240,7 +221,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 stat st_path; @@ -295,7 +276,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];