From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 02:52:25 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 681EACD4; Sun, 6 Jan 2013 02:52:25 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 418CEEEB; Sun, 6 Jan 2013 02:52:25 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r062qPdQ066851; Sun, 6 Jan 2013 02:52:25 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r062qOto066845; Sun, 6 Jan 2013 02:52:24 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301060252.r062qOto066845@svn.freebsd.org> From: Hiroki Sato Date: Sun, 6 Jan 2013 02:52:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245092 - user/hrs/releng/usr.sbin/makevd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 02:52:25 -0000 Author: hrs Date: Sun Jan 6 02:52:23 2013 New Revision: 245092 URL: http://svnweb.freebsd.org/changeset/base/245092 Log: Add Microsoft Virtual Hard Disk (VHD) Image Format support. At this moment, it generates a Fixed Hard Disk Image with CreatorVersion=0x00050000. Added: user/hrs/releng/usr.sbin/makevd/vhd.c (contents, props changed) user/hrs/releng/usr.sbin/makevd/vhd.h (contents, props changed) Modified: user/hrs/releng/usr.sbin/makevd/Makefile user/hrs/releng/usr.sbin/makevd/makevd.8 user/hrs/releng/usr.sbin/makevd/makevd.c user/hrs/releng/usr.sbin/makevd/makevd.h Modified: user/hrs/releng/usr.sbin/makevd/Makefile ============================================================================== --- user/hrs/releng/usr.sbin/makevd/Makefile Sun Jan 6 02:50:38 2013 (r245091) +++ user/hrs/releng/usr.sbin/makevd/Makefile Sun Jan 6 02:52:23 2013 (r245092) @@ -4,6 +4,7 @@ PROG= makevd MAN= makevd.8 SRCS= makevd.c \ raw.c \ + vhd.c \ vmdk.c WARNS?= 6 CFLAGS+= -I${.CURDIR} Modified: user/hrs/releng/usr.sbin/makevd/makevd.8 ============================================================================== --- user/hrs/releng/usr.sbin/makevd/makevd.8 Sun Jan 6 02:50:38 2013 (r245091) +++ user/hrs/releng/usr.sbin/makevd/makevd.8 Sun Jan 6 02:52:23 2013 (r245092) @@ -74,6 +74,8 @@ Create an virtual disk image. The following image types are supported: .Bl -tag -width cd9660 -offset indent +.It Sy vhd +Microsoft Virtual Hard Disk (VHD) Image Format. .It Sy vmdk VMWare Virtual Machine DisK (VMDK) Format. .It Sy raw @@ -82,6 +84,19 @@ No conversion (default). .El .\" .\" +.Ss VHD-specific options +.Sy vhd +images have VHD-specific parameters that may be provided. +Some are optional, and some are mandatory. +Each of the options consists of a keyword, an equal sign +.Pq Ql = , +and a value. +The following keywords are supported: +.Pp +.Bl -tag -width optimization -offset indent -compact +.It Fl o Sy uuid +UUID for the image. Mandatory. +.El .Ss VMDK-specific options .Sy vmdk images have VMDK-specific parameters that may be provided. Modified: user/hrs/releng/usr.sbin/makevd/makevd.c ============================================================================== --- user/hrs/releng/usr.sbin/makevd/makevd.c Sun Jan 6 02:50:38 2013 (r245091) +++ user/hrs/releng/usr.sbin/makevd/makevd.c Sun Jan 6 02:52:23 2013 (r245092) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include "makevd.h" #include "vmdk.h" +#include "vhd.h" static LIST_HEAD(optlisthead_t, optlist) oplhead; @@ -50,6 +51,7 @@ static struct imtype { const char *imt_type; int (*imt_makeim)(struct iminfo *); } imtypes[] = { + { "vhd", vhd_makeim }, { "vmdk", vmdk_makeim }, { "none", raw_makeim }, { "raw", raw_makeim }, Modified: user/hrs/releng/usr.sbin/makevd/makevd.h ============================================================================== --- user/hrs/releng/usr.sbin/makevd/makevd.h Sun Jan 6 02:50:38 2013 (r245091) +++ user/hrs/releng/usr.sbin/makevd/makevd.h Sun Jan 6 02:52:23 2013 (r245092) @@ -49,6 +49,7 @@ struct optlist { char *opl_val; }; +int vhd_makeim(struct iminfo *); int vmdk_makeim(struct iminfo *); int raw_makeim(struct iminfo *); Added: user/hrs/releng/usr.sbin/makevd/vhd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/vhd.c Sun Jan 6 02:52:23 2013 (r245092) @@ -0,0 +1,184 @@ +/*- + * Copyright (c) 2011-2013 + * Hiroki Sato 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 REGENTS 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 REGENTS 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$ + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "makevd.h" +#include "vhd.h" + +static uint32_t vhd_checksum(struct HardDiskFooter *); + +int +vhd_makeim(struct iminfo *imi) +{ + struct HardDiskFooter DHF, *imh; + uint64_t sectors, heads, cylinders, imagesize; + uint8_t uuid[16]; + char vhdfile[PATH_MAX + 10]; + char buf[BUFSIZ]; + char *p, *q; + ssize_t len0, len = 0; + int ifd, ofd; + + imh = &DHF; + ifd = imi->imi_fd; + imagesize = imi->imi_size; + + memset(imh, 0, sizeof(*imh)); + if (imi->imi_uuid == NULL) + errx(EX_USAGE, "-o uuid option must be specified."); + + p = imi->imi_uuid; +#if _BYTE_ORDER == _BIG_ENDIAN + q = (uint8_t *)&uuid + 16; +#else + q = (uint8_t *)&uuid; +#endif + while (len < 16 && strlen(p) > 1) { + long digit; + char *endptr; + + if (*p == '-') { + p++; + continue; + } + buf[0] = p[0]; + buf[1] = p[1]; + buf[2] = '\0'; + errno = 0; + digit = strtol(buf, &endptr, 16); + if (errno == 0 && *endptr != '\0') + errno = EINVAL; + if (errno) + errx(EX_DATAERR, "invalid UUID"); +#if _BYTE_ORDER == _BIG_ENDIAN + *q-- = digit; +#else + *q++ = digit; +#endif + len++; + p += 2; + } +#if 0 + { + int i; + + printf("uuid = "); + for (i = 0; i < 16; i++) + printf("%02x", uuid[i]); + printf("\n"); + } +#endif + snprintf(vhdfile, sizeof(vhdfile), "%s.vhd", imi->imi_imagename); + ofd = open(vhdfile, O_WRONLY|O_CREAT|O_TRUNC, + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + if (ofd < 0) + err(EX_CANTCREAT, "%s", vhdfile); + + /* All of the fields are in BE byte order. */ + imh->Cookie = htobe64(HDF_COOKIE); + imh->Features = htobe32(HDF_FEATURES_RES); + imh->FileFormatVersion = htobe32(HDF_FILEFORMATVERSION_DEFAULT); + imh->DataOffset = htobe32(HDF_DATAOFFSET_FIXEDHDD); + imh->TimeStamp = 0; /* XXX */ + imh->CreatorApplication = htobe32(HDF_CREATORAPP_VPC); + imh->CreatorVersion = htobe32(HDF_CREATORVERSION_VPC2004); + imh->CreatorHostOS = htobe32(HDF_CREATORHOSTOS_WIN); + imh->OriginalSize = htobe64(imagesize); + imh->CurrentSize = htobe64(imagesize); + + sectors = 63; + heads = 16; + cylinders = imagesize / (sectors * heads * 512); + while (cylinders > 1024) { + cylinders >>= 1; + heads <<= 1; + } + imh->DiskGeometry.cylinder = htobe16(cylinders); + imh->DiskGeometry.heads = heads; + imh->DiskGeometry.sectcyl = sectors; + + imh->DiskType = htobe32(HDF_DISKTYPE_FIXEDHDD); + memcpy((char *)imh->UniqueId, (char *)&uuid, sizeof(imh->UniqueId)); + imh->SavedState = 0; + + imh->Checksum = htobe32(vhd_checksum(imh)); + + for (;;) { + len0 = read(ifd, buf, sizeof(buf)); + if (len0 == 0) + break; + if (len0 < 0) { + warn("read error"); + return (1); + } + len = write(ofd, buf, len0); + if (len < 0) { + warn("write error"); + return (1); + } + } + len0 = write(ofd, imh, sizeof(*imh)); + if (len0 != sizeof(*imh)) { + warn("write error"); + return (1); + } + + return (0); +} + +static uint32_t +vhd_checksum(struct HardDiskFooter *imh) +{ + uint32_t sum; + size_t len; + + sum = 0; + for (len = 0; len < sizeof(*imh); len++) + sum += ((uint8_t *)imh)[0]; + + return (~sum); +} Added: user/hrs/releng/usr.sbin/makevd/vhd.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/vhd.h Sun Jan 6 02:52:23 2013 (r245092) @@ -0,0 +1,100 @@ +/*- + * Copyright (c) 2011-2013 + * Hiroki Sato 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 REGENTS 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 REGENTS 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 _VHD_H +#define _VHD_H + +#include +#include + +/* All of the fields are in BE byte order. */ +struct HardDiskFooter { + uint64_t Cookie; +#define HDF_COOKIE (0x636f6e6563746978) /* "conectix" */ + uint32_t Features; +#define HDF_FEATURES_TEMP (0x00000001) +#define HDF_FEATURES_RES (0x00000002) + uint32_t FileFormatVersion; +#define HDF_FILEFORMATVERSION_DEFAULT (0x00010000) + uint64_t DataOffset; +#define HDF_DATAOFFSET_FIXEDHDD (0xFFFFFFFF) + uint32_t TimeStamp; + uint32_t CreatorApplication; +#define HDF_CREATORAPP_VPC (0x76707320) /* "vpc " */ +#define HDF_CREATORAPP_VS (0x76732020) /* "vs " */ + uint32_t CreatorVersion; +#define HDF_CREATORVERSION_VS2004 (0x00010000) +#define HDF_CREATORVERSION_VPC2004 (0x00050000) + uint32_t CreatorHostOS; +#define HDF_CREATORHOSTOS_WIN (0x5769326b) /* "Wi2k" */ +#define HDF_CREATORHOSTOS_MAC (0x4d616320) /* "Mac " */ + uint64_t OriginalSize; + uint64_t CurrentSize; + struct { + uint16_t cylinder; + uint8_t heads; + uint8_t sectcyl; + } DiskGeometry; + uint32_t DiskType; +#define HDF_DISKTYPE_FIXEDHDD (2) +#define HDF_DISKTYPE_DYNAMICHDD (3) +#define HDF_DISKTYPE_DIFFHDD (4) + uint32_t Checksum; + uint8_t UniqueId[16]; + uint8_t SavedState; + char Reserved[427]; +} __attribute__((__packed__)); + +struct DynamicDiskHeader { + uint64_t Cookie; +#define DDH_COOKIE (0x6378737061727365) /* "cxsparse" */ + uint64_t DataOffset; +#define DDH_DATAOFFSET (0xffffffff) + uint64_t TableOffset; + uint32_t HeaderVersion; +#define DDH_HEADERVERSION (0x00010000) + uint32_t MaxTableEntries; + uint32_t BlockSize; +#define DDH_BLOCKSIZE_DEFAULT (0x00200000) + uint32_t Checksum; + uint8_t ParentUniqueID[16]; + uint32_t ParentTimeStamp; + uint32_t Reserved1; + uint8_t ParentUnicodeName[512]; + uint8_t ParentLocatorEntry1[24]; + uint8_t ParentLocatorEntry2[24]; + uint8_t ParentLocatorEntry3[24]; + uint8_t ParentLocatorEntry4[24]; + uint8_t ParentLocatorEntry5[24]; + uint8_t ParentLocatorEntry6[24]; + uint8_t ParentLocatorEntry7[24]; + uint8_t ParentLocatorEntry8[24]; + uint8_t Reserved2[256]; +} __attribute__((__packed__)); + +#endif /* _VHD_H */ From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 03:24:47 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 85AE63C6; Sun, 6 Jan 2013 03:24:47 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6245499; Sun, 6 Jan 2013 03:24:47 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r063OlWd076892; Sun, 6 Jan 2013 03:24:47 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r063OlC4076891; Sun, 6 Jan 2013 03:24:47 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301060324.r063OlC4076891@svn.freebsd.org> From: Hiroki Sato Date: Sun, 6 Jan 2013 03:24:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245094 - user/hrs/releng/usr.sbin/makevd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 03:24:47 -0000 Author: hrs Date: Sun Jan 6 03:24:46 2013 New Revision: 245094 URL: http://svnweb.freebsd.org/changeset/base/245094 Log: Add a HOWTO document. Added: user/hrs/releng/usr.sbin/makevd/README (contents, props changed) Added: user/hrs/releng/usr.sbin/makevd/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/README Sun Jan 6 03:24:46 2013 (r245094) @@ -0,0 +1,23 @@ +$FreeBSD$ + +How to test: + +1. Put world into $PWD/root/ directory. + +2. Type the following commands: + +# makefs -t ffs -b 20% boot.fs root +# size=$$(stat -f %z boot.fs) +# ssize=$$(( 50 + ($$size + (1024*1024-1)) / (1024*1024) )) +# dd if=/dev/zero of=boot.img bs=1024x1024 count=1 seek=$$ssize conv=notrunc,noerror,sparse +# mdconfig -a -t vnode -f boot.img -u 11 +# fdisk -IB /dev/md11 +# gpart create -s BSD md11s1 +# gpart add -t freebsd-ufs md11s1 +# dd if=boot.fs of=/dev/md11s1a bs=1m conv=sync,notrunc,noerror,sparse +# gpart bootcode -b /boot/boot md11s1 +# mdconfig -d -u 11 +# makevd -t vmdk -o uuid=`uuidgen` -o imagename=boot boot.img +# makevd -t vhd -o uuid=`uuidgen` -o imagename=boot boot.img + +3. You can use boot.vmdk or boot.vhd as a virtual disk file. From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 03:31:45 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D3A8C5D8; Sun, 6 Jan 2013 03:31:45 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AF4D5BA; Sun, 6 Jan 2013 03:31:45 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r063VjcD079492; Sun, 6 Jan 2013 03:31:45 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r063Vjfm079491; Sun, 6 Jan 2013 03:31:45 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301060331.r063Vjfm079491@svn.freebsd.org> From: Hiroki Sato Date: Sun, 6 Jan 2013 03:31:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245095 - user/hrs/releng/usr.sbin/makevd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 03:31:45 -0000 Author: hrs Date: Sun Jan 6 03:31:45 2013 New Revision: 245095 URL: http://svnweb.freebsd.org/changeset/base/245095 Log: Fix typos (s/$$/$/). Modified: user/hrs/releng/usr.sbin/makevd/README Modified: user/hrs/releng/usr.sbin/makevd/README ============================================================================== --- user/hrs/releng/usr.sbin/makevd/README Sun Jan 6 03:24:46 2013 (r245094) +++ user/hrs/releng/usr.sbin/makevd/README Sun Jan 6 03:31:45 2013 (r245095) @@ -7,9 +7,9 @@ How to test: 2. Type the following commands: # makefs -t ffs -b 20% boot.fs root -# size=$$(stat -f %z boot.fs) -# ssize=$$(( 50 + ($$size + (1024*1024-1)) / (1024*1024) )) -# dd if=/dev/zero of=boot.img bs=1024x1024 count=1 seek=$$ssize conv=notrunc,noerror,sparse +# size=$(stat -f %z boot.fs) +# ssize=$(( 50 + ($size + (1024*1024-1)) / (1024*1024) )) +# dd if=/dev/zero of=boot.img bs=1024x1024 count=1 seek=$ssize conv=notrunc,noerror,sparse # mdconfig -a -t vnode -f boot.img -u 11 # fdisk -IB /dev/md11 # gpart create -s BSD md11s1 From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 03:51:45 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E59DF7AA; Sun, 6 Jan 2013 03:51:45 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A799110A; Sun, 6 Jan 2013 03:51:45 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r063pjsJ085162; Sun, 6 Jan 2013 03:51:45 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r063pjwa085160; Sun, 6 Jan 2013 03:51:45 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301060351.r063pjwa085160@svn.freebsd.org> From: Hiroki Sato Date: Sun, 6 Jan 2013 03:51:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245096 - user/hrs/releng/usr.sbin/makevd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 03:51:46 -0000 Author: hrs Date: Sun Jan 6 03:51:44 2013 New Revision: 245096 URL: http://svnweb.freebsd.org/changeset/base/245096 Log: Always use LE byte order in VMDK. Modified: user/hrs/releng/usr.sbin/makevd/vmdk.c user/hrs/releng/usr.sbin/makevd/vmdk.h Modified: user/hrs/releng/usr.sbin/makevd/vmdk.c ============================================================================== --- user/hrs/releng/usr.sbin/makevd/vmdk.c Sun Jan 6 03:31:45 2013 (r245095) +++ user/hrs/releng/usr.sbin/makevd/vmdk.c Sun Jan 6 03:51:44 2013 (r245096) @@ -78,22 +78,23 @@ vmdk_makeim(struct iminfo *imi) if (vmdkfilebase == '\0') vmdkfilebase = vmdkfile; - imh->magicNumber = SPARSE_MAGICNUMBER; - imh->version = SPARSE_VERSION_DEFAULT; - imh->flags = 1; - imh->capacity = 0; - imh->grainSize = 16; - imh->descriptorOffset = (sizeof(*imh) + 511) / 512; - imh->descriptorSize = (sizeof(desc) + 511) / 512; - imh->numGTEsPerGT = 512; - imh->rgdOffset = 0; - imh->gdOffset = 0; - imh->overHead = imh->descriptorOffset + imh->descriptorSize; - imh->uncleanShutdown = 0; - imh->singleEndLineChar = '\n'; - imh->nonEndLineChar = ' '; - imh->doubleEndLineChar1 = '\r'; - imh->doubleEndLineChar2 = '\n'; + /* All of the fields are in LE byte order. */ + imh->magicNumber = htole32(SEH_MAGICNUMBER); + imh->version = htole32(SEH_VERSION_DEFAULT); + imh->flags = htole32(1); + imh->capacity = htole64(0); + imh->grainSize = htole64(16); + imh->descriptorOffset = htole64((sizeof(*imh) + 511) / 512); + imh->descriptorSize = htole64((sizeof(desc) + 511) / 512); + imh->numGTEsPerGT = htole32(512); + imh->rgdOffset = htole64(0); + imh->gdOffset = htole64(0); + imh->overHead = htole64(imh->descriptorOffset + imh->descriptorSize); + imh->uncleanShutdown = 0; + imh->singleEndLineChar = '\n'; + imh->nonEndLineChar = ' '; + imh->doubleEndLineChar1 = '\r'; + imh->doubleEndLineChar2 = '\n'; sectors = 63; heads = 16; Modified: user/hrs/releng/usr.sbin/makevd/vmdk.h ============================================================================== --- user/hrs/releng/usr.sbin/makevd/vmdk.h Sun Jan 6 03:31:45 2013 (r245095) +++ user/hrs/releng/usr.sbin/makevd/vmdk.h Sun Jan 6 03:51:44 2013 (r245096) @@ -38,9 +38,12 @@ typedef uint16_t uint16; typedef uint8_t uint8; typedef uint8_t Bool; +/* All of the fields are in LE byte order. */ struct SparseExtentHeader { uint32 magicNumber; +#define SEH_MAGICNUMBER (0x564d444b) /* "VMDK" */ uint32 version; +#define SEH_VERSION_DEFAULT (2) uint32 flags; SectorType capacity; SectorType grainSize; @@ -59,12 +62,4 @@ struct SparseExtentHeader { uint8 pad[433]; } __attribute__((__packed__)); -#if _BYTE_ORDER == _BIG_ENDIAN -#define SPARSE_MAGICNUMBER (0x4b444d56) /* 'K' 'D' 'M' 'V' */ -#else -#define SPARSE_MAGICNUMBER (0x564d444b) /* 'V' 'M' 'D' 'K' */ -#endif - -#define SPARSE_VERSION_DEFAULT 2 - #endif /* _VMDK_H */ From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 05:20:45 2013 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id EE50A9B; Sun, 6 Jan 2013 05:20:45 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from adsum.doit.wisc.edu (adsum.doit.wisc.edu [144.92.197.210]) by mx1.freebsd.org (Postfix) with ESMTP id C8572260; Sun, 6 Jan 2013 05:20:45 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from avs-daemon.smtpauth1.wiscmail.wisc.edu by smtpauth1.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0MG600J00UUKZV00@smtpauth1.wiscmail.wisc.edu>; Sat, 05 Jan 2013 23:20:44 -0600 (CST) Received: from wanderer.tachypleus.net (dhcp107-17-54-205.hil-sfofhhh.sfo.wayport.net [107.17.54.205]) by smtpauth1.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0MG600CJRUUIGE40@smtpauth1.wiscmail.wisc.edu>; Sat, 05 Jan 2013 23:20:43 -0600 (CST) Date: Sun, 06 Jan 2013 00:20:41 -0500 From: Nathan Whitehorn Subject: Re: svn commit: r245061 - user/hrs/releng/release/sparc64 In-reply-to: <20130106.023817.477940685460339224.hrs@allbsd.org> Sender: whitehorn@wisc.edu To: Hiroki Sato Message-id: <50E909A9.2080102@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=107.17.54.205 X-Spam-PmxInfo: Server=avs-15, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2013.1.6.51219, SenderIP=107.17.54.205 References: <201301051623.r05GNIwK079250@svn.freebsd.org> <50E85612.1020903@freebsd.org> <20130106.023817.477940685460339224.hrs@allbsd.org> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 05:20:46 -0000 On 01/05/13 12:38, Hiroki Sato wrote: > Nathan Whitehorn wrote > in <50E85612.1020903@freebsd.org>: > > nw> With these changes, if you add -B big to the makefs flags for the boot > nw> fs and find a way to do sunlabel on not-sparc64 (this is the same as > nw> geom_part_vtoc8, right?), you should be able to cross-build sparc64 > nw> media (as you can already do with all other platforms). > > Thank you! I will add -B to makefs. So, is a powerpc build on LE > platforms also affected? > > For sunlabel replacement I am trying gpart since g_part_vtoc8 is > available as a kernel module even for non-sparc64 platforms. > However, it is difficult to set CHS parameters manually. In the ISO > image generation script, I just concatenated an ISO image and a UFS > image then wrote a VTOC8 label over it. While this needs the offset > parameter of the UFS image and it must be in cylinders, the > sectors/cylinder parameter is dynamically determined by the media > size. > > -- Hiroki > PPC ISO generation already has all the correct flags (and uses g_part_apm), and so already can be cross-built. I haven't tried IA64 but it looks like it should work. -Nathan From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 06:35:47 2013 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5827C69A; Sun, 6 Jan 2013 06:35:47 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) by mx1.freebsd.org (Postfix) with ESMTP id 4EFC93D2; Sun, 6 Jan 2013 06:35:46 +0000 (UTC) Received: from alph.allbsd.org (p1137-ipbf1505funabasi.chiba.ocn.ne.jp [118.7.212.137]) (authenticated bits=128) by mail.allbsd.org (8.14.5/8.14.5) with ESMTP id r066ZS9h074868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 6 Jan 2013 15:35:38 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) (authenticated bits=0) by alph.allbsd.org (8.14.5/8.14.5) with ESMTP id r066ZQS3030558; Sun, 6 Jan 2013 15:35:28 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Sun, 06 Jan 2013 15:35:17 +0900 (JST) Message-Id: <20130106.153517.109897343418704824.hrs@allbsd.org> To: nwhitehorn@FreeBSD.org Subject: Re: svn commit: r245061 - user/hrs/releng/release/sparc64 From: Hiroki Sato In-Reply-To: <50E909A9.2080102@freebsd.org> References: <50E85612.1020903@freebsd.org> <20130106.023817.477940685460339224.hrs@allbsd.org> <50E909A9.2080102@freebsd.org> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.5 on Emacs 23.4 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart(Sun_Jan__6_15_35_17_2013_824)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.97.4 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (mail.allbsd.org [133.31.130.32]); Sun, 06 Jan 2013 15:35:38 +0900 (JST) X-Spam-Status: No, score=-98.1 required=13.0 tests=CONTENT_TYPE_PRESENT, ONLY1HOPDIRECT,SAMEHELOBY2HOP,USER_IN_WHITELIST autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on gatekeeper.allbsd.org Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 06:35:47 -0000 ----Security_Multipart(Sun_Jan__6_15_35_17_2013_824)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Nathan Whitehorn wrote in <50E909A9.2080102@freebsd.org>: nw> On 01/05/13 12:38, Hiroki Sato wrote: nw> > Nathan Whitehorn wrote nw> > in <50E85612.1020903@freebsd.org>: nw> > nw> > nw> With these changes, if you add -B big to the makefs flags for the boot nw> > nw> fs and find a way to do sunlabel on not-sparc64 (this is the same as nw> > nw> geom_part_vtoc8, right?), you should be able to cross-build sparc64 nw> > nw> media (as you can already do with all other platforms). nw> > nw> > Thank you! I will add -B to makefs. So, is a powerpc build on LE nw> > platforms also affected? nw> > nw> > For sunlabel replacement I am trying gpart since g_part_vtoc8 is nw> > available as a kernel module even for non-sparc64 platforms. nw> > However, it is difficult to set CHS parameters manually. In the ISO nw> > image generation script, I just concatenated an ISO image and a UFS nw> > image then wrote a VTOC8 label over it. While this needs the offset nw> > parameter of the UFS image and it must be in cylinders, the nw> > sectors/cylinder parameter is dynamically determined by the media nw> > size. nw> > nw> > -- Hiroki nw> > nw> nw> PPC ISO generation already has all the correct flags (and uses nw> g_part_apm), and so already can be cross-built. I haven't tried IA64 but nw> it looks like it should work. nw> -Nathan Ah, I see. I thought the -B option was also necessary for cd9660 image. -- Hiroki ----Security_Multipart(Sun_Jan__6_15_35_17_2013_824)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEABECAAYFAlDpGyUACgkQTyzT2CeTzy1aFwCfaKdRkQHSrFXYGnYIHFmxZ435 I2gAoKy9IfSnz+hFHo1Ggdh3rJ0Lf2OT =4/bd -----END PGP SIGNATURE----- ----Security_Multipart(Sun_Jan__6_15_35_17_2013_824)---- From owner-svn-src-user@FreeBSD.ORG Sun Jan 6 17:50:58 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 66662305; Sun, 6 Jan 2013 17:50:58 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6BA47106F; Sun, 6 Jan 2013 17:50:58 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r06How2R094824; Sun, 6 Jan 2013 17:50:58 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r06HovAp094820; Sun, 6 Jan 2013 17:50:57 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301061750.r06HovAp094820@svn.freebsd.org> From: Hiroki Sato Date: Sun, 6 Jan 2013 17:50:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245105 - user/hrs/releng/usr.sbin/makevd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jan 2013 17:50:58 -0000 Author: hrs Date: Sun Jan 6 17:50:57 2013 New Revision: 245105 URL: http://svnweb.freebsd.org/changeset/base/245105 Log: Fix a copy-and-paste error in the license boilerplate. Spotted by: joel Modified: user/hrs/releng/usr.sbin/makevd/makevd.8 user/hrs/releng/usr.sbin/makevd/makevd.c user/hrs/releng/usr.sbin/makevd/makevd.h Modified: user/hrs/releng/usr.sbin/makevd/makevd.8 ============================================================================== --- user/hrs/releng/usr.sbin/makevd/makevd.8 Sun Jan 6 15:10:10 2013 (r245104) +++ user/hrs/releng/usr.sbin/makevd/makevd.8 Sun Jan 6 17:50:57 2013 (r245105) @@ -11,10 +11,10 @@ .\" 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 WASABI SYSTEMS, INC. ``AS IS'' AND ANY +.\" 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 WASABI SYSTEMS, INC BE +.\" 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 Modified: user/hrs/releng/usr.sbin/makevd/makevd.c ============================================================================== --- user/hrs/releng/usr.sbin/makevd/makevd.c Sun Jan 6 15:10:10 2013 (r245104) +++ user/hrs/releng/usr.sbin/makevd/makevd.c Sun Jan 6 17:50:57 2013 (r245105) @@ -11,10 +11,10 @@ * 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 WASABI SYSTEMS, INC. ``AS IS'' AND ANY + * 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 WASABI SYSTEMS, INC BE + * 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 Modified: user/hrs/releng/usr.sbin/makevd/makevd.h ============================================================================== --- user/hrs/releng/usr.sbin/makevd/makevd.h Sun Jan 6 15:10:10 2013 (r245104) +++ user/hrs/releng/usr.sbin/makevd/makevd.h Sun Jan 6 17:50:57 2013 (r245105) @@ -11,10 +11,10 @@ * 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 WASABI SYSTEMS, INC. ``AS IS'' AND ANY + * 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 WASABI SYSTEMS, INC BE + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND 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 From owner-svn-src-user@FreeBSD.ORG Mon Jan 7 07:30:43 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6CDF14A7 for ; Mon, 7 Jan 2013 07:30:43 +0000 (UTC) (envelope-from hrs@svn.freebsd.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5018BF4B for ; Mon, 7 Jan 2013 07:30:43 +0000 (UTC) Received: from hrs (uid 837) (envelope-from hrs@svn.freebsd.org) id 1957 by svn.freebsd.org (DragonFly Mail Agent v0.7); Mon, 07 Jan 2013 07:30:41 +0000 From: Hiroki Sato Date: Mon, 7 Jan 2013 07:30:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245126 - user/hrs/releng/usr.sbin/makevd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <50ea79a1.1957.5e0cec35@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jan 2013 07:30:43 -0000 Author: hrs Date: Mon Jan 7 07:30:41 2013 New Revision: 245126 URL: http://svnweb.freebsd.org/changeset/base/245126 Log: - Use linked-list for chunks to support multiple formats in a consistent fashion. - Define VMDK_SEH_HOSTEDSPARSE_INIT and VHD_HDF_FIXEDHDD_INIT for some fixed parameters. - Fix license boilerplate. Added: user/hrs/releng/usr.sbin/makevd/common.c (contents, props changed) user/hrs/releng/usr.sbin/makevd/common.h (contents, props changed) Modified: user/hrs/releng/usr.sbin/makevd/Makefile user/hrs/releng/usr.sbin/makevd/raw.c user/hrs/releng/usr.sbin/makevd/vhd.c user/hrs/releng/usr.sbin/makevd/vhd.h user/hrs/releng/usr.sbin/makevd/vmdk.c user/hrs/releng/usr.sbin/makevd/vmdk.h Modified: user/hrs/releng/usr.sbin/makevd/Makefile ============================================================================== --- user/hrs/releng/usr.sbin/makevd/Makefile Mon Jan 7 07:05:57 2013 (r245125) +++ user/hrs/releng/usr.sbin/makevd/Makefile Mon Jan 7 07:30:41 2013 (r245126) @@ -3,6 +3,7 @@ PROG= makevd MAN= makevd.8 SRCS= makevd.c \ + common.c \ raw.c \ vhd.c \ vmdk.c Added: user/hrs/releng/usr.sbin/makevd/common.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/common.c Mon Jan 7 07:30:41 2013 (r245126) @@ -0,0 +1,108 @@ +/*- + * Copyright (c) 2013 + * Hiroki Sato 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$ + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include + +#include "common.h" + +static int rawcopy(int, int); +static int writebuf(int, void *, ssize_t); + +int +dispatch_bl(int ofd, struct blhead_t *blhead) +{ + struct blist *bl; + int error; + + TAILQ_FOREACH(bl, blhead, bl_next) { + printf("processing section: %s\n", bl->bl_name); + switch (bl->bl_type) { + case BL_RAWCOPY: + error = rawcopy(ofd, bl->bl_tf.blf_fd); + break; + case BL_RAWDATA: + error = writebuf(ofd, bl->bl_tr.blr_data, + bl->bl_tr.blr_len); + break; + default: + error = 1; + break; + } + if (error) + return (error); + } + return (0); +} + +static int +rawcopy(int ofd, int ifd) +{ + ssize_t len0, len = 0; + char buf[BUFSIZ]; + + for (;;) { + len0 = read(ifd, buf, sizeof(buf)); + if (len0 == 0) + break; + if (len0 < 0) { + warn("read error"); + return (1); + } + len = write(ofd, buf, len0); + if (len < 0) { + warn("write error"); + return (1); + } + } + return (0); +} + +static int +writebuf(int ofd, void *buf, ssize_t len) +{ + ssize_t len0; + u_char *p; + + p = (u_char *)buf; + len0 = write(ofd, p, len); + if (len0 != len) { + warn("write error"); + return (1); + } + + return (0); +} Added: user/hrs/releng/usr.sbin/makevd/common.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/common.h Mon Jan 7 07:30:41 2013 (r245126) @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 2013 + * Hiroki Sato 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 _COMMON_H +#define _COMMON_H + +#include + +struct blist_raw { + size_t blr_len; + void *blr_data; +}; + +struct blist_fd { + int blf_fd; +}; + +struct blist { + TAILQ_ENTRY(blist) bl_next; + + int bl_type; +#define BL_UNKNOWN 0 +#define BL_RAWDATA 1 +#define BL_RAWCOPY 2 + const char *bl_name; + const char *bl_desc; + union { + struct blist_fd tf; + struct blist_raw tr; + } t; +#define bl_tf t.tf +#define bl_tr t.tr +}; + +TAILQ_HEAD(blhead_t, blist); + +int dispatch_bl(int, struct blhead_t *); + +#endif /* _COMMON_H */ Modified: user/hrs/releng/usr.sbin/makevd/raw.c ============================================================================== --- user/hrs/releng/usr.sbin/makevd/raw.c Mon Jan 7 07:05:57 2013 (r245125) +++ user/hrs/releng/usr.sbin/makevd/raw.c Mon Jan 7 07:30:41 2013 (r245126) @@ -11,10 +11,10 @@ * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND + * 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 REGENTS OR CONTRIBUTORS + * 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 @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -38,19 +39,23 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include "makevd.h" +#include "common.h" int raw_makeim(struct iminfo *imi) { - char buf[BUFSIZ], rawfile[PATH_MAX + 10]; - ssize_t len0, len = 0; + struct blhead_t blhead; + struct blist *bl; + char rawfile[PATH_MAX + 10]; int ifd, ofd; + TAILQ_INIT(&blhead); ifd = imi->imi_fd; if (strcmp(imi->imi_imagename, "-") == 0) @@ -64,20 +69,14 @@ raw_makeim(struct iminfo *imi) err(EX_CANTCREAT, "%s", rawfile); } - for (;;) { - len0 = read(ifd, buf, sizeof(buf)); - if (len0 == 0) - break; - if (len0 < 0) { - warn("read error"); - return (1); - } - len = write(ofd, buf, len0); - if (len < 0) { - warn("write error"); - return (1); - } - } + bl = calloc(1, sizeof(*bl)); + if (bl == NULL) + err(EX_OSERR, NULL); + bl->bl_type = BL_RAWCOPY; + bl->bl_name = "rawcopy"; + bl->bl_tf.blf_fd = ifd; + + TAILQ_INSERT_TAIL(&blhead, bl, bl_next); - return (0); + return (dispatch_bl(ofd, &blhead)); } Modified: user/hrs/releng/usr.sbin/makevd/vhd.c ============================================================================== --- user/hrs/releng/usr.sbin/makevd/vhd.c Mon Jan 7 07:05:57 2013 (r245125) +++ user/hrs/releng/usr.sbin/makevd/vhd.c Mon Jan 7 07:30:41 2013 (r245126) @@ -11,10 +11,10 @@ * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND + * 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 REGENTS OR CONTRIBUTORS + * 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 @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -47,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include "makevd.h" +#include "common.h" #include "vhd.h" static uint32_t vhd_checksum(struct HardDiskFooter *); @@ -54,16 +56,20 @@ static uint32_t vhd_checksum(struct Hard int vhd_makeim(struct iminfo *imi) { - struct HardDiskFooter DHF, *imh; + struct HardDiskFooter HDF = VHD_HDF_FIXEDHDD_INIT; + struct HardDiskFooter *imh; + struct blhead_t blhead; + struct blist *bl; uint64_t sectors, heads, cylinders, imagesize; uint8_t uuid[16]; char vhdfile[PATH_MAX + 10]; char buf[BUFSIZ]; char *p, *q; - ssize_t len0, len = 0; + ssize_t len = 0; int ifd, ofd; - imh = &DHF; + TAILQ_INIT(&blhead); + imh = &HDF; ifd = imi->imi_fd; imagesize = imi->imi_size; @@ -119,14 +125,7 @@ vhd_makeim(struct iminfo *imi) err(EX_CANTCREAT, "%s", vhdfile); /* All of the fields are in BE byte order. */ - imh->Cookie = htobe64(HDF_COOKIE); - imh->Features = htobe32(HDF_FEATURES_RES); - imh->FileFormatVersion = htobe32(HDF_FILEFORMATVERSION_DEFAULT); - imh->DataOffset = htobe32(HDF_DATAOFFSET_FIXEDHDD); imh->TimeStamp = 0; /* XXX */ - imh->CreatorApplication = htobe32(HDF_CREATORAPP_VPC); - imh->CreatorVersion = htobe32(HDF_CREATORVERSION_VPC2004); - imh->CreatorHostOS = htobe32(HDF_CREATORHOSTOS_WIN); imh->OriginalSize = htobe64(imagesize); imh->CurrentSize = htobe64(imagesize); @@ -141,33 +140,28 @@ vhd_makeim(struct iminfo *imi) imh->DiskGeometry.heads = heads; imh->DiskGeometry.sectcyl = sectors; - imh->DiskType = htobe32(HDF_DISKTYPE_FIXEDHDD); memcpy((char *)imh->UniqueId, (char *)&uuid, sizeof(imh->UniqueId)); - imh->SavedState = 0; imh->Checksum = htobe32(vhd_checksum(imh)); - for (;;) { - len0 = read(ifd, buf, sizeof(buf)); - if (len0 == 0) - break; - if (len0 < 0) { - warn("read error"); - return (1); - } - len = write(ofd, buf, len0); - if (len < 0) { - warn("write error"); - return (1); - } - } - len0 = write(ofd, imh, sizeof(*imh)); - if (len0 != sizeof(*imh)) { - warn("write error"); - return (1); - } + bl = calloc(1, sizeof(*bl)); + if (bl == NULL) + err(EX_OSERR, NULL); + bl->bl_type = BL_RAWCOPY; + bl->bl_name = "Rawcopy"; + bl->bl_tf.blf_fd = ifd; + TAILQ_INSERT_TAIL(&blhead, bl, bl_next); + + bl = calloc(1, sizeof(*bl)); + if (bl == NULL) + err(EX_OSERR, NULL); + bl->bl_type = BL_RAWDATA; + bl->bl_name = "Hard Disk Footer"; + bl->bl_tr.blr_data = imh; + bl->bl_tr.blr_len = sizeof(*imh); + TAILQ_INSERT_TAIL(&blhead, bl, bl_next); - return (0); + return (dispatch_bl(ofd, &blhead)); } static uint32_t Modified: user/hrs/releng/usr.sbin/makevd/vhd.h ============================================================================== --- user/hrs/releng/usr.sbin/makevd/vhd.h Mon Jan 7 07:05:57 2013 (r245125) +++ user/hrs/releng/usr.sbin/makevd/vhd.h Mon Jan 7 07:30:41 2013 (r245126) @@ -11,10 +11,10 @@ * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND + * 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 REGENTS OR CONTRIBUTORS BE LIABLE + * 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) @@ -70,6 +70,18 @@ struct HardDiskFooter { char Reserved[427]; } __attribute__((__packed__)); +#define VHD_HDF_FIXEDHDD_INIT { \ + .Cookie = htobe64(HDF_COOKIE), \ + .Features = htobe32(HDF_FEATURES_RES), \ + .FileFormatVersion = htobe32(HDF_FILEFORMATVERSION_DEFAULT), \ + .DataOffset = htobe32(HDF_DATAOFFSET_FIXEDHDD), \ + .CreatorApplication = htobe32(HDF_CREATORAPP_VPC), \ + .CreatorVersion = htobe32(HDF_CREATORVERSION_VPC2004), \ + .CreatorHostOS = htobe32(HDF_CREATORHOSTOS_WIN), \ + .DiskType = htobe32(HDF_DISKTYPE_FIXEDHDD), \ + .SavedState = 0, \ + } + struct DynamicDiskHeader { uint64_t Cookie; #define DDH_COOKIE (0x6378737061727365) /* "cxsparse" */ Modified: user/hrs/releng/usr.sbin/makevd/vmdk.c ============================================================================== --- user/hrs/releng/usr.sbin/makevd/vmdk.c Mon Jan 7 07:05:57 2013 (r245125) +++ user/hrs/releng/usr.sbin/makevd/vmdk.c Mon Jan 7 07:30:41 2013 (r245126) @@ -11,10 +11,10 @@ * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND + * 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 REGENTS OR CONTRIBUTORS + * 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 @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -39,27 +40,30 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include #include "makevd.h" +#include "common.h" #include "vmdk.h" int vmdk_makeim(struct iminfo *imi) { - struct SparseExtentHeader SEH, *imh; + struct SparseExtentHeader SEH = VMDK_SEH_HOSTEDSPARSE_INIT; + struct SparseExtentHeader *imh; + struct blhead_t blhead; + struct blist *bl; uint64_t sectors, heads, cylinders, imagesize; char vmdkfile[PATH_MAX + 10], *vmdkfilebase; - char buf[BUFSIZ]; char desc[1024]; - ssize_t len0, len = 0; - int ifd, ofd; + int ofd; + TAILQ_INIT(&blhead); imh = &SEH; - ifd = imi->imi_fd; imagesize = imi->imi_size; memset(imh, 0, sizeof(*imh)); @@ -79,22 +83,9 @@ vmdk_makeim(struct iminfo *imi) vmdkfilebase = vmdkfile; /* All of the fields are in LE byte order. */ - imh->magicNumber = htole32(SEH_MAGICNUMBER); - imh->version = htole32(SEH_VERSION_DEFAULT); - imh->flags = htole32(1); - imh->capacity = htole64(0); - imh->grainSize = htole64(16); imh->descriptorOffset = htole64((sizeof(*imh) + 511) / 512); imh->descriptorSize = htole64((sizeof(desc) + 511) / 512); - imh->numGTEsPerGT = htole32(512); - imh->rgdOffset = htole64(0); - imh->gdOffset = htole64(0); imh->overHead = htole64(imh->descriptorOffset + imh->descriptorSize); - imh->uncleanShutdown = 0; - imh->singleEndLineChar = '\n'; - imh->nonEndLineChar = ' '; - imh->doubleEndLineChar1 = '\r'; - imh->doubleEndLineChar2 = '\n'; sectors = 63; heads = 16; @@ -128,30 +119,31 @@ vmdk_makeim(struct iminfo *imi) cylinders, imi->imi_uuid); - len0 = write(ofd, imh, sizeof(*imh)); - if (len0 != sizeof(*imh)) { - warn("write error"); - return (1); - } - len0 = write(ofd, desc, sizeof(desc)); - if (len0 != sizeof(desc)) { - warn("write error"); - return (1); - } - for (;;) { - len0 = read(ifd, buf, sizeof(buf)); - if (len0 == 0) - break; - if (len0 < 0) { - warn("read error"); - return (1); - } - len = write(ofd, buf, len0); - if (len < 0) { - warn("write error"); - return (1); - } - } + bl = calloc(1, sizeof(*bl)); + if (bl == NULL) + err(EX_OSERR, NULL); + bl->bl_type = BL_RAWDATA; + bl->bl_name = "Sparse Extent Header"; + bl->bl_tr.blr_data = imh; + bl->bl_tr.blr_len = sizeof(*imh); + TAILQ_INSERT_TAIL(&blhead, bl, bl_next); + + bl = calloc(1, sizeof(*bl)); + if (bl == NULL) + err(EX_OSERR, NULL); + bl->bl_type = BL_RAWDATA; + bl->bl_name = "Embedded descriptor"; + bl->bl_tr.blr_data = &desc; + bl->bl_tr.blr_len = sizeof(desc); + TAILQ_INSERT_TAIL(&blhead, bl, bl_next); + + bl = calloc(1, sizeof(*bl)); + if (bl == NULL) + err(EX_OSERR, NULL); + bl->bl_type = BL_RAWCOPY; + bl->bl_name = "Rawcopy"; + bl->bl_tf.blf_fd = imi->imi_fd; + TAILQ_INSERT_TAIL(&blhead, bl, bl_next); - return (0); + return (dispatch_bl(ofd, &blhead)); } Modified: user/hrs/releng/usr.sbin/makevd/vmdk.h ============================================================================== --- user/hrs/releng/usr.sbin/makevd/vmdk.h Mon Jan 7 07:05:57 2013 (r245125) +++ user/hrs/releng/usr.sbin/makevd/vmdk.h Mon Jan 7 07:30:41 2013 (r245126) @@ -11,10 +11,10 @@ * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND + * 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 REGENTS OR CONTRIBUTORS BE LIABLE + * 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) @@ -62,4 +62,20 @@ struct SparseExtentHeader { uint8 pad[433]; } __attribute__((__packed__)); +#define VMDK_SEH_HOSTEDSPARSE_INIT { \ + .magicNumber = htole32(SEH_MAGICNUMBER), \ + .version = htole32(SEH_VERSION_DEFAULT), \ + .flags = htole32(1), \ + .capacity = htole64(0), \ + .grainSize = htole64(16), \ + .numGTEsPerGT = htole32(512), \ + .rgdOffset = htole64(0), \ + .gdOffset = htole64(0), \ + .uncleanShutdown = 0, \ + .singleEndLineChar = '\n', \ + .nonEndLineChar = ' ', \ + .doubleEndLineChar1 = '\r', \ + .doubleEndLineChar2 = '\n', \ + } + #endif /* _VMDK_H */ From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 06:59:30 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0570BF26; Tue, 8 Jan 2013 06:59:29 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 693A3E3B; Tue, 8 Jan 2013 06:59:29 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r086xT6t057449; Tue, 8 Jan 2013 06:59:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r086xSgl057440; Tue, 8 Jan 2013 06:59:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301080659.r086xSgl057440@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 06:59:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245157 - in user/adrian/ath_radar_stuff: lib/libradarpkt src/pktlog X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 06:59:30 -0000 Author: adrian Date: Tue Jan 8 06:59:27 2013 New Revision: 245157 URL: http://svnweb.freebsd.org/changeset/base/245157 Log: * Migrate the radiotap and chan code out into libradarpkt so it can be reused. * Update radiotap to use the net80211 radiotap fields. I'll add those to FreeBSD shortly. Added: user/adrian/ath_radar_stuff/lib/libradarpkt/chan.c user/adrian/ath_radar_stuff/lib/libradarpkt/chan.h user/adrian/ath_radar_stuff/lib/libradarpkt/radiotap_iter.c user/adrian/ath_radar_stuff/lib/libradarpkt/radiotap_iter.h Deleted: user/adrian/ath_radar_stuff/src/pktlog/chan.c user/adrian/ath_radar_stuff/src/pktlog/chan.h user/adrian/ath_radar_stuff/src/pktlog/platform.h user/adrian/ath_radar_stuff/src/pktlog/radiotap.c user/adrian/ath_radar_stuff/src/pktlog/radiotap.h user/adrian/ath_radar_stuff/src/pktlog/radiotap_iter.h Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile user/adrian/ath_radar_stuff/src/pktlog/Makefile Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile Tue Jan 8 06:59:21 2013 (r245156) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile Tue Jan 8 06:59:27 2013 (r245157) @@ -1,6 +1,7 @@ LIB= radarpkt SRCS= ar5212_radar.c ar9280_radar.c ar5416_radar.c +SRCS+= radiotap_iter.c chan.c # Define 'ATH_ENABLE_RADIOTAP_VENDOR_EXT' as it's not enabled by default # in the configuration file. Ideally this would just fake an "opt_ath.h" Added: user/adrian/ath_radar_stuff/lib/libradarpkt/chan.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/chan.c Tue Jan 8 06:59:27 2013 (r245157) @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +#include "net80211/ieee80211_radiotap.h" + +#include "radiotap_iter.h" + +#include "chan.h" + +int +pkt_lookup_chan(const char *buf, int len, struct xchan *x) +{ + struct ieee80211_radiotap_iterator iter; + int err; + + bzero(&iter, sizeof(iter)); + + err = ieee80211_radiotap_iterator_init(&iter, (void *) buf, len, NULL); + if (err < 0) { + printf("%s: ieee80211_radiotap_iterator_init: failed; err=%d\n", + __func__, + err); + return (-1); + } + + /* Iterate over, looping for the xchannel struct */ + while (!(err = ieee80211_radiotap_iterator_next(&iter))) { + if (iter.is_radiotap_ns) { + if (iter.this_arg_index == IEEE80211_RADIOTAP_XCHANNEL) { + /* XXX endian! */ + memcpy(x, iter.this_arg, 8); + return (0); + } + } + } + return (-1); +} Added: user/adrian/ath_radar_stuff/lib/libradarpkt/chan.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/chan.h Tue Jan 8 06:59:27 2013 (r245157) @@ -0,0 +1,17 @@ +#ifndef __CHAN_H__ +#define __CHAN_H__ + + +struct xchan { + /* DWORD 0 */ + uint32_t flags; + /* DWORD 1 */ + uint16_t freq; + uint8_t chan; + uint8_t txpow; +}; + + +extern int pkt_lookup_chan(const char *buf, int len, struct xchan *x); + +#endif Added: user/adrian/ath_radar_stuff/lib/libradarpkt/radiotap_iter.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/radiotap_iter.c Tue Jan 8 06:59:27 2013 (r245157) @@ -0,0 +1,387 @@ +/* + * Radiotap parser + * + * Copyright 2007 Andy Green + * Copyright 2009 Johannes Berg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See COPYING for more details. + */ +#include "radiotap_iter.h" +#include "platform.h" + +#include "net80211/ieee80211_radiotap.h" + +/* function prototypes and related defs are in radiotap_iter.h */ + +static const struct radiotap_align_size rtap_namespace_sizes[] = { + [IEEE80211_RADIOTAP_TSFT] = { .align = 8, .size = 8, }, + [IEEE80211_RADIOTAP_FLAGS] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_RATE] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_CHANNEL] = { .align = 2, .size = 4, }, + [IEEE80211_RADIOTAP_FHSS] = { .align = 2, .size = 2, }, + [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_DBM_ANTNOISE] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_LOCK_QUALITY] = { .align = 2, .size = 2, }, + [IEEE80211_RADIOTAP_TX_ATTENUATION] = { .align = 2, .size = 2, }, + [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = { .align = 2, .size = 2, }, + [IEEE80211_RADIOTAP_DBM_TX_POWER] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_ANTENNA] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_DB_ANTNOISE] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_RX_FLAGS] = { .align = 2, .size = 2, }, + [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, }, + [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, }, + [IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, }, + [IEEE80211_RADIOTAP_XCHANNEL] = { .align = 8, .size = 8 }, + [IEEE80211_RADIOTAP_AMPDU_STATUS] = { .align = 4, .size = 8, }, + /* + * add more here as they are defined in radiotap.h + */ +}; + +static const struct ieee80211_radiotap_namespace radiotap_ns = { + .n_bits = sizeof(rtap_namespace_sizes) / sizeof(rtap_namespace_sizes[0]), + .align_size = rtap_namespace_sizes, +}; + +/** + * ieee80211_radiotap_iterator_init - radiotap parser iterator initialization + * @iterator: radiotap_iterator to initialize + * @radiotap_header: radiotap header to parse + * @max_length: total length we can parse into (eg, whole packet length) + * + * Returns: 0 or a negative error code if there is a problem. + * + * This function initializes an opaque iterator struct which can then + * be passed to ieee80211_radiotap_iterator_next() to visit every radiotap + * argument which is present in the header. It knows about extended + * present headers and handles them. + * + * How to use: + * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator + * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) + * checking for a good 0 return code. Then loop calling + * __ieee80211_radiotap_iterator_next()... it returns either 0, + * -ENOENT if there are no more args to parse, or -EINVAL if there is a problem. + * The iterator's @this_arg member points to the start of the argument + * associated with the current argument index that is present, which can be + * found in the iterator's @this_arg_index member. This arg index corresponds + * to the IEEE80211_RADIOTAP_... defines. + * + * Radiotap header length: + * You can find the CPU-endian total radiotap header length in + * iterator->max_length after executing ieee80211_radiotap_iterator_init() + * successfully. + * + * Alignment Gotcha: + * You must take care when dereferencing iterator.this_arg + * for multibyte types... the pointer is not aligned. Use + * get_unaligned((type *)iterator.this_arg) to dereference + * iterator.this_arg for type "type" safely on all arches. + * + * Example code: parse.c + */ + +int ieee80211_radiotap_iterator_init( + struct ieee80211_radiotap_iterator *iterator, + struct ieee80211_radiotap_header *radiotap_header, + int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns) +{ + /* Linux only supports version 0 radiotap format */ + if (radiotap_header->it_version) + return -EINVAL; + + /* sanity check for allowed length and radiotap length field */ + if (max_length < get_unaligned_le16(&radiotap_header->it_len)) + return -EINVAL; + + iterator->_rtheader = radiotap_header; + iterator->_max_length = get_unaligned_le16(&radiotap_header->it_len); + iterator->_arg_index = 0; + iterator->_bitmap_shifter = get_unaligned_le32(&radiotap_header->it_present); + iterator->_arg = (uint8_t *)radiotap_header + sizeof(*radiotap_header); + iterator->_reset_on_ext = 0; + iterator->_next_bitmap = &radiotap_header->it_present; + iterator->_next_bitmap++; + iterator->_vns = vns; + iterator->current_namespace = &radiotap_ns; + iterator->is_radiotap_ns = 1; +#ifdef RADIOTAP_SUPPORT_OVERRIDES + iterator->n_overrides = 0; + iterator->overrides = NULL; +#endif + + /* find payload start allowing for extended bitmap(s) */ + + if (iterator->_bitmap_shifter & (1<_arg) & + (1 << IEEE80211_RADIOTAP_EXT)) { + iterator->_arg += sizeof(uint32_t); + + /* + * check for insanity where the present bitmaps + * keep claiming to extend up to or even beyond the + * stated radiotap header length + */ + + if ((unsigned long)iterator->_arg - + (unsigned long)iterator->_rtheader > + (unsigned long)iterator->_max_length) + return -EINVAL; + } + + iterator->_arg += sizeof(uint32_t); + + /* + * no need to check again for blowing past stated radiotap + * header length, because ieee80211_radiotap_iterator_next + * checks it before it is dereferenced + */ + } + + iterator->this_arg = iterator->_arg; + + /* we are all initialized happily */ + + return 0; +} + +static void find_ns(struct ieee80211_radiotap_iterator *iterator, + uint32_t oui, uint8_t subns) +{ + int i; + + iterator->current_namespace = NULL; + + if (!iterator->_vns) + return; + + for (i = 0; i < iterator->_vns->n_ns; i++) { + if (iterator->_vns->ns[i].oui != oui) + continue; + if (iterator->_vns->ns[i].subns != subns) + continue; + + iterator->current_namespace = &iterator->_vns->ns[i]; + break; + } +} + +#ifdef RADIOTAP_SUPPORT_OVERRIDES +static int find_override(struct ieee80211_radiotap_iterator *iterator, + int *align, int *size) +{ + int i; + + if (!iterator->overrides) + return 0; + + for (i = 0; i < iterator->n_overrides; i++) { + if (iterator->_arg_index == iterator->overrides[i].field) { + *align = iterator->overrides[i].align; + *size = iterator->overrides[i].size; + if (!*align) /* erroneous override */ + return 0; + return 1; + } + } + + return 0; +} +#endif + + +/** + * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg + * @iterator: radiotap_iterator to move to next arg (if any) + * + * Returns: 0 if there is an argument to handle, + * -ENOENT if there are no more args or -EINVAL + * if there is something else wrong. + * + * This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*) + * in @this_arg_index and sets @this_arg to point to the + * payload for the field. It takes care of alignment handling and extended + * present fields. @this_arg can be changed by the caller (eg, + * incremented to move inside a compound argument like + * IEEE80211_RADIOTAP_CHANNEL). The args pointed to are in + * little-endian format whatever the endianess of your CPU. + * + * Alignment Gotcha: + * You must take care when dereferencing iterator.this_arg + * for multibyte types... the pointer is not aligned. Use + * get_unaligned((type *)iterator.this_arg) to dereference + * iterator.this_arg for type "type" safely on all arches. + */ + +int ieee80211_radiotap_iterator_next( + struct ieee80211_radiotap_iterator *iterator) +{ + while (1) { + int hit = 0; + int pad, align, size, subns; + uint32_t oui; + + /* if no more EXT bits, that's it */ + if ((iterator->_arg_index % 32) == IEEE80211_RADIOTAP_EXT && + !(iterator->_bitmap_shifter & 1)) + return -ENOENT; + + if (!(iterator->_bitmap_shifter & 1)) + goto next_entry; /* arg not present */ + + /* get alignment/size of data */ + switch (iterator->_arg_index % 32) { + case IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE: + case IEEE80211_RADIOTAP_EXT: + align = 1; + size = 0; + break; + case IEEE80211_RADIOTAP_VENDOREXT: + align = 2; + size = 6; + break; + default: +#ifdef RADIOTAP_SUPPORT_OVERRIDES + if (find_override(iterator, &align, &size)) { + /* all set */ + } else +#endif + if (!iterator->current_namespace || + iterator->_arg_index >= iterator->current_namespace->n_bits) { + if (iterator->current_namespace == &radiotap_ns) + return -ENOENT; + align = 0; + } else { + align = iterator->current_namespace->align_size[iterator->_arg_index].align; + size = iterator->current_namespace->align_size[iterator->_arg_index].size; + } + if (!align) { + /* skip all subsequent data */ + iterator->_arg = iterator->_next_ns_data; + /* give up on this namespace */ + iterator->current_namespace = NULL; + goto next_entry; + } + break; + } + + /* + * arg is present, account for alignment padding + * + * Note that these alignments are relative to the start + * of the radiotap header. There is no guarantee + * that the radiotap header itself is aligned on any + * kind of boundary. + * + * The above is why get_unaligned() is used to dereference + * multibyte elements from the radiotap area. + */ + + pad = ((unsigned long)iterator->_arg - + (unsigned long)iterator->_rtheader) & (align - 1); + + if (pad) + iterator->_arg += align - pad; + + if (iterator->_arg_index % 32 == IEEE80211_RADIOTAP_VENDOREXT) { + int vnslen; + + if ((unsigned long)iterator->_arg + size - + (unsigned long)iterator->_rtheader > + (unsigned long)iterator->_max_length) + return -EINVAL; + + oui = (*iterator->_arg << 16) | + (*(iterator->_arg + 1) << 8) | + *(iterator->_arg + 2); + subns = *(iterator->_arg + 3); + + find_ns(iterator, oui, subns); + + vnslen = get_unaligned_le16(iterator->_arg + 4); + iterator->_next_ns_data = iterator->_arg + size + vnslen; + if (!iterator->current_namespace) + size += vnslen; + } + + /* + * this is what we will return to user, but we need to + * move on first so next call has something fresh to test + */ + iterator->this_arg_index = iterator->_arg_index; + iterator->this_arg = iterator->_arg; + iterator->this_arg_size = size; + + /* internally move on the size of this arg */ + iterator->_arg += size; + + /* + * check for insanity where we are given a bitmap that + * claims to have more arg content than the length of the + * radiotap section. We will normally end up equalling this + * max_length on the last arg, never exceeding it. + */ + + if ((unsigned long)iterator->_arg - + (unsigned long)iterator->_rtheader > + (unsigned long)iterator->_max_length) + return -EINVAL; + + /* these special ones are valid in each bitmap word */ + switch (iterator->_arg_index % 32) { + case IEEE80211_RADIOTAP_VENDOREXT: + iterator->_reset_on_ext = 1; + + iterator->is_radiotap_ns = 0; + /* + * If parser didn't register this vendor + * namespace with us, allow it to show it + * as 'raw. Do do that, set argument index + * to vendor namespace. + */ + iterator->this_arg_index = + IEEE80211_RADIOTAP_VENDOREXT; + if (!iterator->current_namespace) + hit = 1; + goto next_entry; + case IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE: + iterator->_reset_on_ext = 1; + iterator->current_namespace = &radiotap_ns; + iterator->is_radiotap_ns = 1; + goto next_entry; + case IEEE80211_RADIOTAP_EXT: + /* + * bit 31 was set, there is more + * -- move to next u32 bitmap + */ + iterator->_bitmap_shifter = + get_unaligned_le32(iterator->_next_bitmap); + iterator->_next_bitmap++; + if (iterator->_reset_on_ext) + iterator->_arg_index = 0; + else + iterator->_arg_index++; + iterator->_reset_on_ext = 0; + break; + default: + /* we've got a hit! */ + hit = 1; + next_entry: + iterator->_bitmap_shifter >>= 1; + iterator->_arg_index++; + } + + /* if we found a valid arg earlier, return it now */ + if (hit) + return 0; + } +} Added: user/adrian/ath_radar_stuff/lib/libradarpkt/radiotap_iter.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/radiotap_iter.h Tue Jan 8 06:59:27 2013 (r245157) @@ -0,0 +1,95 @@ +#ifndef __RADIOTAP_ITER_H +#define __RADIOTAP_ITER_H + +#include + +/* Radiotap header iteration + * implemented in radiotap.c + */ + +struct radiotap_override { + uint8_t field; + uint8_t align:4, size:4; +}; + +struct radiotap_align_size { + uint8_t align:4, size:4; +}; + +struct ieee80211_radiotap_namespace { + const struct radiotap_align_size *align_size; + int n_bits; + uint32_t oui; + uint8_t subns; +}; + +struct ieee80211_radiotap_vendor_namespaces { + const struct ieee80211_radiotap_namespace *ns; + int n_ns; +}; + +/** + * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args + * @this_arg_index: index of current arg, valid after each successful call + * to ieee80211_radiotap_iterator_next() + * @this_arg: pointer to current radiotap arg; it is valid after each + * call to ieee80211_radiotap_iterator_next() but also after + * ieee80211_radiotap_iterator_init() where it will point to + * the beginning of the actual data portion + * @this_arg_size: length of the current arg, for convenience + * @current_namespace: pointer to the current namespace definition + * (or internally %NULL if the current namespace is unknown) + * @is_radiotap_ns: indicates whether the current namespace is the default + * radiotap namespace or not + * + * @overrides: override standard radiotap fields + * @n_overrides: number of overrides + * + * @_rtheader: pointer to the radiotap header we are walking through + * @_max_length: length of radiotap header in cpu byte ordering + * @_arg_index: next argument index + * @_arg: next argument pointer + * @_next_bitmap: internal pointer to next present u32 + * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present + * @_vns: vendor namespace definitions + * @_next_ns_data: beginning of the next namespace's data + * @_reset_on_ext: internal; reset the arg index to 0 when going to the + * next bitmap word + * + * Describes the radiotap parser state. Fields prefixed with an underscore + * must not be used by users of the parser, only by the parser internally. + */ + +struct ieee80211_radiotap_iterator { + struct ieee80211_radiotap_header *_rtheader; + const struct ieee80211_radiotap_vendor_namespaces *_vns; + const struct ieee80211_radiotap_namespace *current_namespace; + + unsigned char *_arg, *_next_ns_data; + uint32_t *_next_bitmap; + + unsigned char *this_arg; +#ifdef RADIOTAP_SUPPORT_OVERRIDES + const struct radiotap_override *overrides; + int n_overrides; +#endif + int this_arg_index; + int this_arg_size; + + int is_radiotap_ns; + + int _max_length; + int _arg_index; + uint32_t _bitmap_shifter; + int _reset_on_ext; +}; + +extern int ieee80211_radiotap_iterator_init( + struct ieee80211_radiotap_iterator *iterator, + struct ieee80211_radiotap_header *radiotap_header, + int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns); + +extern int ieee80211_radiotap_iterator_next( + struct ieee80211_radiotap_iterator *iterator); + +#endif /* __RADIOTAP_ITER_H */ Modified: user/adrian/ath_radar_stuff/src/pktlog/Makefile ============================================================================== --- user/adrian/ath_radar_stuff/src/pktlog/Makefile Tue Jan 8 06:59:21 2013 (r245156) +++ user/adrian/ath_radar_stuff/src/pktlog/Makefile Tue Jan 8 06:59:27 2013 (r245157) @@ -3,7 +3,7 @@ PROG= main X_INCS= -I../../lib/ X_LIBS= -L../../lib/libradarpkt/ -SRCS= main.c chan.c radiotap.c +SRCS= main.c CFLAGS+= -I/home/adrian/work/freebsd/ath/head/src/sys $(X_INCS) -g -ggdb \ -DATH_ENABLE_RADIOTAP_VENDOR_EXT LDADD+= $(X_LIBS) -lpcap -lradarpkt From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 17:42:04 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 15F1E2FB; Tue, 8 Jan 2013 17:42:04 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 089F5F69; Tue, 8 Jan 2013 17:42:04 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08Hg3FM048089; Tue, 8 Jan 2013 17:42:03 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08Hg3Hc048085; Tue, 8 Jan 2013 17:42:03 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301081742.r08Hg3Hc048085@svn.freebsd.org> From: Sean Bruno Date: Tue, 8 Jan 2013 17:42:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245170 - in user/sbruno/pxe_http: . project project/i386_mod project/libi386_mod project/libstand_mod project/loader_mod X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 17:42:04 -0000 Author: sbruno Date: Tue Jan 8 17:42:03 2013 New Revision: 245170 URL: http://svnweb.freebsd.org/changeset/base/245170 Log: put this code in a user branch so I can find the thing. Populate with code from Google Summer of Code 2007 project http://code.google.com/p/google-summer-of-code-2007-freebsd/downloads/detail?name=Alexey_Tarasov.tar.gz&can=2&q= Added: user/sbruno/pxe_http/ user/sbruno/pxe_http/INFO user/sbruno/pxe_http/project/ user/sbruno/pxe_http/project/Makefile user/sbruno/pxe_http/project/README user/sbruno/pxe_http/project/httpfs.c user/sbruno/pxe_http/project/httpfs.h user/sbruno/pxe_http/project/i386_mod/ user/sbruno/pxe_http/project/i386_mod/Makefile user/sbruno/pxe_http/project/libi386_mod/ user/sbruno/pxe_http/project/libi386_mod/Makefile user/sbruno/pxe_http/project/libi386_mod/pxe.c user/sbruno/pxe_http/project/libi386_mod/pxe.h user/sbruno/pxe_http/project/libstand_mod/ user/sbruno/pxe_http/project/libstand_mod/printf.c user/sbruno/pxe_http/project/libstand_mod/stand.h user/sbruno/pxe_http/project/loader_mod/ user/sbruno/pxe_http/project/loader_mod/Makefile user/sbruno/pxe_http/project/loader_mod/conf.c user/sbruno/pxe_http/project/loader_mod/loader.rc user/sbruno/pxe_http/project/loader_mod/main.c user/sbruno/pxe_http/project/pxe_arp.c user/sbruno/pxe_http/project/pxe_arp.h user/sbruno/pxe_http/project/pxe_await.c user/sbruno/pxe_http/project/pxe_await.h user/sbruno/pxe_http/project/pxe_buffer.c user/sbruno/pxe_http/project/pxe_buffer.h user/sbruno/pxe_http/project/pxe_connection.c user/sbruno/pxe_http/project/pxe_connection.h user/sbruno/pxe_http/project/pxe_core.c user/sbruno/pxe_http/project/pxe_core.h user/sbruno/pxe_http/project/pxe_dhcp.c user/sbruno/pxe_http/project/pxe_dhcp.h user/sbruno/pxe_http/project/pxe_dns.c user/sbruno/pxe_http/project/pxe_dns.h user/sbruno/pxe_http/project/pxe_filter.c user/sbruno/pxe_http/project/pxe_filter.h user/sbruno/pxe_http/project/pxe_http.c user/sbruno/pxe_http/project/pxe_http.h user/sbruno/pxe_http/project/pxe_icmp.c user/sbruno/pxe_http/project/pxe_icmp.h user/sbruno/pxe_http/project/pxe_ip.c user/sbruno/pxe_http/project/pxe_ip.h user/sbruno/pxe_http/project/pxe_isr.S user/sbruno/pxe_http/project/pxe_isr.h user/sbruno/pxe_http/project/pxe_mem.c user/sbruno/pxe_http/project/pxe_mem.h user/sbruno/pxe_http/project/pxe_segment.c user/sbruno/pxe_http/project/pxe_segment.h user/sbruno/pxe_http/project/pxe_sock.c user/sbruno/pxe_http/project/pxe_sock.h user/sbruno/pxe_http/project/pxe_tcp.c user/sbruno/pxe_http/project/pxe_tcp.h user/sbruno/pxe_http/project/pxe_udp.c user/sbruno/pxe_http/project/pxe_udp.h Added: user/sbruno/pxe_http/INFO ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxe_http/INFO Tue Jan 8 17:42:03 2013 (r245170) @@ -0,0 +1,30 @@ +Here is 'http support for PXE' project snapshot at 19th of August +(last submit during GSoC). + +There was post GSoC submit and may be will be ready next changes at time you are +reading this sentence, so repository contents differs from this tarball. Also, +deleted at the end phase of project files (e.g. pxe_mutex module) and unused +after all (btx_mod directory) are not included to this tarball. + +Other related (may be even useful) info may be found at: + + * blog.freebsdish.org/taleks + - project related blog + + * wiki.freebsd.org/http_support_for_PXE + - wiki project page + + * perforce.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/projects/soc2007/taleks%2dpxe%5fhttp&HIDEDEL=NO + - web interface to perforce repository with project + + +Directories structure: + + pxe_http library, main developed code: + /project/*.* + + also, there were made changes to already existed code: + /project/libstand_mod - modified files of libs/libstand library + /project/loader_mod - modified files of i386/loader code + /project/libi386_mod - modified files of i386/libi386 + /project/i386_mod - modified Makefile of i386 folder Added: user/sbruno/pxe_http/project/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxe_http/project/Makefile Tue Jan 8 17:42:03 2013 (r245170) @@ -0,0 +1,46 @@ +# pxe_http project +# +LIB= pxe_http +INTERNALLIB= + +SRCS= pxe_isr.S pxe_mem.c pxe_buffer.c pxe_await.c pxe_arp.c pxe_ip.c \ + pxe_core.c pxe_icmp.c pxe_udp.c pxe_filter.c pxe_dns.c \ + pxe_dhcp.c pxe_segment.c pxe_tcp.c pxe_sock.c \ + pxe_connection.c pxe_http.c httpfs.c + +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \ + -I${.CURDIR}/../../../contrib/dev/acpica \ + -I${.CURDIR}/../../.. -I. -I$(.CURDIR)/.. -I${.CURDIR}/../libi386/ +# the location of libstand +CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ + +#debug flag +#CFLAGS+= -DPXE_DEBUG +#CFLAGS+= -DPXE_DEBUG_HELL + +# core module debug +#CFLAGS+= -DPXE_CORE_DEBUG_HELL +#CFLAGS+= -DPXE_CORE_DEBUG +# TCP module debug +#CFLAGS+= -DPXE_TCP_DEBUG +#CFLAGS+= -DPXE_TCP_DEBUG_HELL +# IP module debug +#CFLAGS+= -DPXE_IP_DEBUG +#CFLAGS+= -DPXE_IP_DEBUG_HELL +# ARP module debug +#CFLAGS+= -DPXE_ARP_DEBUG +#CFLAGS+= -DPXE_ARP_DEBUG_HELL +# httpfs module +#CFLAGS+= -DPXE_HTTP_DEBUG +#CFLAGS+= -DPXE_HTTP_DEBUG_HELL + +# define to get more PXE related code and testing functions +#CFLAGS+= -DPXE_MORE + +# define to get some speed up by bigger requests +CFLAGS+= -DPXE_HTTPFS_CACHING + +# define to send packets freqently to speed up connection +#CFLAGS+= -DPXE_TCP_AGRESSIVE + +.include Added: user/sbruno/pxe_http/project/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxe_http/project/README Tue Jan 8 17:42:03 2013 (r245170) @@ -0,0 +1,1253 @@ +Contents +---------- + +1. Introduction + + 1.2. Setting up + + 1.2.1. DHCP configuration + 1.2.2. TFTP configuration + 1.2.3. Web-server configuration + 1.2.4. loader.rc configuratuion + +2. Project organisation + + 2.1. Code modules + 2.2. Naming conventions + 2.3. Understanding logical structure of code + +3. API usage + + 3.1. Base information + 3.2. PXE sockets API overview + + 3.2.1. PXE API socket details + + 3.3. Quick Reference to API, available for user code + + 3.3.1. pxe_arp module + 3.3.2. pxe_await module + 3.3.3. pxe_buffer module + 3.3.4. pxe_connection module + 3.3.5. pxe_core module + 3.3.6. pxe_dhcp module + 3.3.7. pxe_dns module + 3.3.8. pxe_filter module + 3.3.9. pxe_http module + 3.3.10. httpfs module + 3.3.11. pxe_icmp module + 3.3.12. pxe_ip module + 3.3.13. pxe_isr module + 3.3.14. pxe_mem module + 3.3.15. pxe_sock module + 3.3.16. pxe_segment module + 3.3.17. pxe_tcp module + 3.3.18. pxe_udp module + +4. Debugging, testing and tuning pxe_http library. + + 4.1. Using 'pxe' loader's command + 4.2. Defining debug macroses + 4.3. Tuning + 4.4. NFS loading with pxe_http + +1. Introduction +---------------- + + pxe_http library is user space implementation of simplified + TCP/IP4 stack with support of sockets. Socket implementation is similar + to common sockets, but differs, so I call this variant of sockets - + "PXE sockets" + + features (read: simpliest ever implementation of): + * supports TCP/UDP PXE sockets + * DHCP client + * DNS client + * http based filesystem + * ICMP echo + +1.1. Requirements +------------------ + + To use pxeboot with extensions from pxe_http library + you need: + * DHCP server + - any DHCP server with support of some options + (see below). In example of configuration files + ISC DHCP v.3.0.5 was used. + * TFTP server + * Web server - I've used Apache 1.3.34 + + +1.2. Setting it up +------------------- + + In most cases, it's the same as for usual pxeboot. Main + difference is in configuration file of DHCP server and in usage of + Web-server. + + +1.2.1. DHCP configuration +------------------------- + + Here is example of configuration: + + # /etc/dhcpd.conf example + # + ddns-update-style none; + server-name "DHCPserver"; + server-identifier 192.168.0.4; + default-lease-time 7200; + max-lease-time 7200; + + # + # significant options for correct working of pxeboot + # + + # your LAN subnet mask + option subnet-mask 255.255.255.0; + + # default gateway to use + option routers 192.168.0.1; + + # name of file to download via TFTP + filename "pxeboot"; + + # name server, used for resolving of domain names + option domain-name-servers 192.168.0.1; + + # ip address of web server + option www-server 192.168.0.2; + + # path, where nessesary files are stored on web server + option root-path "th.lan:/path/to/root"; + + subnet 192.168.0.0 netmask 255.255.255.0 { + next-server 192.168.0.4; + range 192.168.0.10 192.168.0.20; + } + + /* end of example */ + + NOTES: + 1. www-server option is used only if root-path is absent in + DHCP reply. In that case assumed, that /boot directory is + placed in DocumentRoot of web-server. + 2. format of root-path has such format: "server:/path". It's + possible use both IP's and domain names for server. /path is + relative to DocumentRoot of web-server. In example above + files are stored at /usr/local/www/data/path/to/root, + assuming that /usr/local/www/data - is DocumentRoot. + 3. DHCP options are not greater then 255 bytes. So, root-path + must satisfy this requirement. + + +1.2.2. TFTP configuration +-------------------------- + + Same as usually. pxe_http doesn't directly use this protocol. + + +1.2.3. Web-server configuration +-------------------------------- + + Just copy all from "/boot" directory to + /DocumentRoot/path/to/root. + + NOTES: + 1. Need to be sure, that partial downloading and keep-alive + connections are supported by server. e.g. for Apache 1.x, + check this options: + + KeepAlive On + MaxKeepAliveRequests 10 # well, choose best for + # server + KeepAliveTimeout 15 # more then 2 seconds + # is good enough + + 2. loader checks gzipped versions of files first, it's good + idea to compress every needed file. e.g. + beastie.4th.gz + device.hints + frames.4th.gz + loader.4th.gz + loader.conf + loader.help.gz + loader.rc + mfsroot.gz + screen.4th.gz + support.4th.gz + /kernel/kernel.gz + +1.2.4. loader.rc configuratuion +-------------------------------- + + HTTP downloading of kernel is not all need to startup system + correctly. The main question is where will be root filesystem after + booting of kernel. The simpliest way - is to use RAM drive with + installation tools or ready to work system. + Here is example of changes to loader.rc, that instructs loader + to download RAM-drive image (in this example, common mfsroot.gz found + in boot.flp floppy image file) + + + \ Includes additional commands + include /boot/loader.4th + + \ Reads and processes loader.conf variables + start + + \ Tests for password -- executes autoboot first if a password was defined + check-password + + \ Load in the boot menu + include /boot/beastie.4th + + \ pxe_http changes: + echo "loading RAM-drive image" + load -t mfs_root /boot/mfsroot + set vfs.root.mountfrom="ufs:/dev/md0c" + \ + + \ Start the boot menu + beastie-start + + /* end of example */ + + Of course, it's possible to set any other filesystem to work + as root, e,g, NFS and not use RAM drive. + +2. Project organisation +------------------------ + +2.1. Code modules +------------------ + + All project code is divided into following modules: + pxe_arp - ARP protocol (3.3.1) + pxe_await - provides functions for awaiting (3.3.2) + pxe_buffer - implements cyclic buffers (3.3.3) + pxe_connection - TCP connection related functions (3.3.4) + pxe_core - provides calls to PXE API (3.3.5) + pxe_dhcp - DHCP client (3.3.6) + pxe_dns - DNS client (3.3.7) + pxe_filter - incoming packet filters (3.3.8) + pxe_http - HTTP related functions (3.3.9) + httpfs - http based file system (3.3.10) + pxe_icmp - ICMP protocol (3.3.11) + pxe_ip - IP protocol (3.3.12) + pxe_isr - assembler side support for PXE API + calling (3.3.13) + pxe_mem - memory work routines (3.3.14) + pxe_sock - simple sockets (3.3.15) + pxe_segment - TCP segments (3.3.16) + pxe_tcp - TCP protocol (3.3.17) + pxe_udp - UDP protocol (3.3.18) + +2.2. Naming conventions +------------------------ + + Most of functions, that may be called directly by user API uses + pxe_ prefix. + Functions related to some module have subprefix of this module, + e.g. pxe_dhcp_query() - function related to DHCP module. + All structures, that are used have typedef equivalent with + naming in upper case. e.g. struct pxe_ipaddr has equivalent PXE_IPADDR. + This is done to have similar to existing pxe.h declarations from libi386. + + +2.3. Understanding logical structure of code +--------------------------------------------- + + Logicallly all modules may be divided to parts. + + Part 1: PXE API related modules (pxe_isr, pxe_core) + Part 2: base protocols related (pxe_ip, pxe_udp) + Part 3: sockets related (pxe_sock) + Part 4: other protocols (pxe_dns, pxe_dhcp) + Part 5: utility (pxe_mem, pxe_buffer) + + Some modules may be used independently, other depend on some + lower level modules. + + In run-time, many calls to sockets functions start packet + recieving or packet sending functions. Sending is more simplier and may + be assumed in many cases just as wrappers to PXE API. But receiving is + a little bit more complicated. Receiving functions start + pxe_core_recv_packets() function in cycle to get packets. + After receiving of packet, it's handling depends on it's type: + ARP, IP or other. ARP packets directly provided to handler + pxe_arp_protocol(), IP packets are provided to registered handler of IP + stack protocol, other packets are ignored. + Registration of handler (except ARP) is performed during + initialisation time of module with usage of pxe_core_register() function, + which register handler for IP stack protocol number. + So, packet is provided to handler, but it may be fragmented, + thus before processing it must be recieved completely. But in some cases + packet may be not interesting for protocol (unexpected packet, dublicated + or something else) and it's possible to determiny if this packet useful + just by examining of packet header. + If packet is fragmented - it firstly provided to handler with + flag PXE_CORE_FRAG. Handler returns appropriate value if is interested in + whole packet, packet is read completely from input queue of fragments and + provided again with flag PXE_CORE_HANDLE. Otherwise packet is dropped + in core by reading of all it's fragments from incoming queue. + Packet structure provides just buffer with received packet and + size of packet. All pxe_core module send/recieve functions work with + PXE_PACKET structure. + TCP and UDP protocols are checking filters in theirs handlers. + This helps to filter out packets that are not interesting for protocol + (e.g. to port that is not listening) + Socket and filter structures are separated. Socket provides + buffers for incoming and outcoming data. Filters may be used without + sockets, e.g. for TCP connections in TIME_WAIT state. For active + connection filter is used to determiny in which receiving buffer (in + which socket) must be placed incoming data. + + +3. API usage +------------- + + Here much attention paid to sockets, other pxe_http API + may be used less frequently. + +3.1. Base information +----------------------- + + User code must perform initialisation of pxe_core module (which + is performed currently in loader during pxe_enable() call). After this + sockets related functions become available. + + pxe_core_init() performs initialisation of pxe_core module and starts + initialisation routines of other modules. It inits TCP, UDP, ARP and + etc modules, however in most of cases it's possible skip theirs + initialisation if module's functions are unused. + Work is finished by pxe_core_shutdown() function. + + +3.2. PXE sockets API overview +------------------------------- + + PXE sockets API differs from common sockets. It's more simplier + and has some limitations due user space implementations. All socket + related functions are declared in pxe_sock.h header + + Socket is created by pxe_socket() call. After usage socket must + be closed by pxe_close() call. Result of pxe_socket() is integer + descriptor associated with socket. After creating socket is unbinded + and not connected. + pxe_sendto(), pxe_connect(), pxe_bind() functions performs + binding and connecting. After successful calling of one of them - socket + is in active state. It's possible to perform reading and sending from/to + socket. Cause socket API may use buffers to optimize packet sending + process, user code must call pxe_flush() functions to be sure, that + data is really processed to sending module. + While receiving need to keep in memory, that if UDP datagram is + not readed completely by one call of pxe_recv() in this implementation + rest of datagram is omited and lost for user code. + All incoming and outcoming data is written to socket buffers, + that have default sizes 16Kb and 4Kb. If buffers are full, next calls + related to writing or reading data will fail. + + +3.2.1. PXE API socket details +------------------------------ + + /* Here is simple example of API usage. */ + + int socket = pxe_socket(); + /* if result is not -1, then socket variable contains value, + * assosiated with socket structure. Call differs from common sockets, + * there are no domain, type and protocol parameters. + * Cause domain is always AF_INET now. others are use in pxe_connect() + * call. + */ + + int result = pxe_connect(socket, &hh->addr, 80, PXE_TCP_PROTOCOL); + /* This call creates filter, associates it with socket and establishes + * communication if needed. + * Parameters are socket, remote ip address (PXE_IPADDR)m remote port + * and one of PXE_UDP_PROTOCOL and PXE_TCP_PROTOCOL protocols. + */ + + if (result == -1) { + pxe_close(socket); + /* any socket must be closed, even if it was not really used + * or conencted. pxe_close() call releases used internal + * structures. After this call any other operations with + * 'socket' descriptor are invalid. + */ + return (0); + } + + /* pxe_send() function sends data to socket. As usual, there is no + * guarantee, that whole buffer is transmited. And actually for TCP + * protocol, this call just places data to buffer. User code have no + * knowledge if data is really sent to network. if current segment is + * not fullly used, data may stay in buffer infinitely. + */ + if (len != pxe_send(socket, hh->buf, len)) { + /* failed to send data, at least whole buffer */ + pxe_close(socket); + return (0); + } + + /* if user code need guarantee, that data is sent to remote host, it + * must call pxe_flush(). It forces sending of any data, that must be + * sent. + */ + if (pxe_flush(socket) == -1) { + /* failed to flush socket */ + pxe_close(socket); + return (0); + } + + /* perform reading cycle */ + + while (count < maxsize) { + /* pxe_recv() is similar to recv() call for common sockets, + * but have no flags parameter + */ + result = pxe_recv(socket, &data[count], maxsize - count); + + if (result == -1) { /* failed to recv */ + break; + } + + if (result == 0) /* nothing received yet */ + continue; + + count += result; + } + + pxe_close(socket); + + + /* End of example */ + + +3.3 Quick Reference to API, available for user code +---------------------------------------------------- + + This overview covers functions and macro definitions that + may be usefull for user code. + + +3.3.1 pxe_arp module +--------------------- + + This module is used mainly by internal code while sending IP + packets. + +macro definitions: + +MAX_ARP_ENTRIES - how much may be ARP table in size. If ARP table full + and new MAC must be placed, then one of older entry is + replaced by new. Default number is 4. + +PXE_MAX_ARP_TRY - how much trys will be peformed when sending ARP + requests, before say MAC search failed. Default: 3 + +PXE_TIME_TO_DIE - how much time to wait ARP reply in milliseconds. + Default: 5000 ms. + +PXE_ARP_SNIFF - sometimes it's usefull to get senders MACs from + incoming requests (this may save time, MAC may be found + in table without requesting it by ARP module itself). + But if network is big enough - ARP table will be + updated too often. By default this option is defined. + + +functions: + +void pxe_arp_init() + - inits pxe_arp module. Usually this call is performed from + pxe_core_init() + +const MAC_ADDR *pxe_arp_ip4mac(const PXE_IPADDR *addr) + - returns MAC address for requested IP address + +void pxe_arp_stats() + - shows ARP table. Available if defined PXE_MORE macro. + + +3.3.2 pxe_await module +----------------------- + + Implements awaiting mechanism. Many operations are performed + similar in protocol implementations. Usually, packet is sended and + application awaits for reply. pxe_await() function helps to simplify + code in such case. + It starts await callback function with some flags and counts + timeouts, try count. + + Here is example of awaiting: + + /* we start awaiting, with dns_await() calllback function, maximum 4 + * trys, each try 20 seconds and waiting data static_wait_data. + * Waiting data - is some data associated with current awaiting, it's + * used by await callback function. + */ + if (!pxe_await(dns_await, 4, 20000, &static_wait_data)) + return (NULL); + + /* pxe_await() returns 1 if awaiting was successfull (await function + * returned PXE_AWAIT_COMPLETED flag) + */ + + /* it's an awaiting function. pxe_await() provides current function, + * current try number, time exceeded from start of try, pointer to + * associated wait data. + */ + int + dns_await(uint8_t function, uint16_t try_number, uint32_t timeout, + void *data) + { + /* cast to our type of wait data */ + PXE_DNS_WAIT_DATA *wait_data = (PXE_DNS_WAIT_DATA *)data; + + switch(function) { + + case PXE_AWAIT_STARTTRY: + /* is called at start of each try + * Here must be performed any await initialisation + * (e.g. request packet sending ) + */ + if (!dns_request(wait_data)) { + /* if initialisation of try failed, try more */ + return (PXE_AWAIT_NEXTTRY); + } + /* otherwise return success result of await function */ + break; + + case PXE_AWAIT_FINISHTRY: + /* this function is called at the end of any try (even + * if try was successful). Here cleanup must be + * performed. + */ + if (wait_data->socket != -1) + pxe_close(wait_data->socket); + + wait_data->id += 1; + break; + + case PXE_AWAIT_NEWPACKETS: + /* while waiting this function called if new packets + * were received by pxe_core_recv_packets(). Actually + * it may be not packets we are waiting for, may be + * even not packets with out protocol. Here we must + * check for new usefull for us packets, receive + * new data if any. + */ + size = pxe_recv(wait_data->socket, wait_data->data, + wait_data->size); + + parse_dns_reply(wait_data); + + if (wait_data->result.ip != 0) { + /* return success of awaiting. This may be + * returned from any function + */ + return (PXE_AWAIT_COMPLETED); + } + + /* if await was not completed, continue waiting */ + return (PXE_AWAIT_CONTINUE); + break; + + case PXE_AWAIT_END: + /* this called if await is ended without any result */ + default: + break; + } + + return (PXE_AWAIT_OK); + } + + /* end of example */ + + So, wait data used for providing and receiving data while + awaiting. pxe_await() performs unified working with code, needed for + waiting of incoming packets. + +macro definitions: + +TIME_DELTA_MS - delay between iterations during awaitng. At each + iteration are checked: + * receiving of new packet. If received - awaiting + function with PXE_AWAIT_NEWPACKETS function is called. + * try timeout. if timeout exceeds maximum timeout - + awaiting function with PXE_AWAIT_FINISHTRY and + PXE_AWAIT_STARTTRY flags sequentially are called. + * try count. if try count exceeds maximum - awaiting + function with PXE_AWAIT_ENDED flag is called. This + means that await failed. + Default: 1 + +TIME_DELTA - default: 1000, same as TIME_DELTA_MS, but in ticks + for delay. + + +3.3.3 pxe_buffer module +------------------------ + + This module provides reading and writing of cyclic buffers. + It's not used directly by user code. + +macro definitions: + +PXE_POOL_SLOTS - if defined, then statical allocation of buffers is + used. Otherwise buffers are allocated at run-time from + heap with pxe_alloc() function. Current statical + allocation algorithm is simple and square, there are + two big buffers data storages divided in slots (by + default 2). + Each slot has size equal to + PXE_DEFAULT_RECV_BUFSIZE or PXE_DEFAULT_SEND_BUFSIZE. + Depending on requested size in pxe_buffer_alloc() + function data allocated from one of stoarge and + related slot marked busy. When pxe_buffer_free() called, + slot marked as free. + Default: undefined + +PXE_DEFAULT_RECV_BUFSIZE - size of receiving buffer. Default: 16392 + +PXE_DEFAULT_SEND_BUFSIZE - size of sending buffer. Default: 4096 + + +3.3.4 pxe_connection module +---------------------------- + + This module is one of TCP related modules. It implements + connection entity. TCP connection is logical structure, that have + needed by TCP protocol counters and states. + User code is not directly works with this module. + +macro definitions: + +PXE_MAX_TCP_CONNECTIONS - how much simultaneous connections may be. + + +functions: + +void pxe_connection_stats() + - returns connections statistics. Available if PXE_MORE macro is + defined. + + +3.3.5 pxe_core module +---------------------- + + This module performs lowlevel work with PXE API: initialisation, + receiving/sending of packets, provides information functions. + In most cases, user code doesn't uses this module directly. + +macro definitions: + +PXE_BUFFER_SIZE - size of core buffers, used in PXE API calling, + Default: 4096 + +PXE_CORE_STATIC_BUFFERS - if defined, core buffers are allocated statically. + Otherwise they are allocated in heap. Default: defined + +functions: + +int pxe_core_recv_packets() + - recieves all packets waiting in incoming queue of NIC, and calls + appropriate protocols if needed + + +void pxe_core_register(uint8_t ip_proto, pxe_protocol_call proc) + - registers IP stack protocol, associates protocol number and handler. + +const MAC_ADDR *pxe_get_mymac() + - returns MAC of NIC, for which PXE API is used. + +const PXE_IPADDR *pxe_get_ip(uint8_t id) + - returns of stored IP, for provided id. + id may be: + PXE_IP_MY - NIC IP address + PXE_IP_NET - network adrress + PXE_IP_NETMASK - network mask + PXE_IP_NAMESERVER - nameserver to use in name resolving + PXE_IP_GATEWAY - default gateway + PXE_IP_BROADCAST - broadcast address + PXE_IP_SERVER - server from which loading of pxeboot + was performed + PXE_IP_WWW - IP address of http-server + PXE_IP_ROOT - IP adddress of server, where root + file system is situated. Currently + it's synonym for PXE_IP_WWW + +void pxe_set_ip(uint8_t id, const PXE_IPADDR *ip) + - sets value by it's id. + +time_t pxe_get_secs() + - returns time in seconds. Used in timeout and resend checking. + +types: + +typedef int (*pxe_protocol_call)(PXE_PACKET *pack, uint8_t function) + - protocol callback function type + + +3.3.6. pxe_dhcp module +----------------------- + + This module implements simple DHCP client, used to obtain + gateway, nameserver and other information. + + +macro definitions: + +PXE_BOOTP_USE_LIBSTAND - use bootp() function provided by libstand instead + of own DHCP client. NOTE: bootp() doesn't set nameip (nameserver ip + structure), thus DNS resolving will be impossible. Default: undefined + + NOTE: to use bootp(), also UDP_DEFAULT_SOCKET macro must be defined. + + +functions: + +void pxe_dhcp_query(uint32_t xid) + - sends DHCPDISCOVER packet and sets core_ips, if gets reply. + + +3.3.6. pxe_dns module +---------------------- + + This module provides domain name resolving. Actually + A and CNAME resource records are supported. + +macro definitions: + +PXE_MAX_DNS_TIMEOUT - max time to wait DNS reply in milliseconds. + Default: 10 seconds + +PXE_MAX_DNS_TRYS - how many times to try to resend request, + if there is no reply. Default: 3 + +PXE_DNS_MAX_PACKET_SIZE - maximum UDP packet size in bytes. Default: 512. + This DNS client doesn't support TCP for resolving. + +functions: + +const PXE_IPADDR *pxe_gethostbyname(char *name) + - returns IP, if resolved, for provided domain name. + +uint32_t pxe_convert_ipstr(char *str) + - converts string value of ipv4 to uint32_t value. + + +3.3.8. pxe_filter module +------------------------- + + This module is not supposed to be used by user code directly. + It implements filtering of incoming IP packets. It's used by UDP and + TCP modules for sorting packets in appropriate socket. + Module provides functions for adding and removing filters. + Each filter contains source/destination ip:port definition and masks + for all of them. Usage of masks gives opportunity to recieve data + from subnet, or subset of ports. + +functions: + +void pxe_filter_init() + - inits filter module structures such as list of free filter entries. + +void pxe_filter_stats() + - show active filters information. Used for debugging. Available if + PXE_MORE macro defined. + + +3.3.9. pxe_http module +----------------------- + + pxe_http implements functions for getting files via HTTP. + Most of it's functions are used only by httpfs module. + At opening file pxe_exists() function is called, which + gets filesize (if possible) by HEAD method of request and opens + connection to file. Result of pxe_exists() call is keep-alive + connection to file. + pxe_get() function gets needed data and reestablishes + connection if needed. + if PXE_MORE defined - pxe_get_close() function becomes + available. It opens connection, gets portion of data and closes + connection. It's rather not optimal usage of http connections, + but some times it may be needed (e.g. for servers, where keep + alive connections are prohibited). + +macro definitions: + +PXE_MAX_HTTP_HDRLEN - buffer size for generating/getting http header. + Default: 1024 bytes. + +functions: + +int pxe_fetch(char *server, char *filename, off_t from, size_t size) + - testing function, gets file from server ()may be partially) and + outputs received data to screen. Available if PXE_MORE defined. + + +3.3.10. httpfs module +---------------------- + + httpfs is filesystem, available via HTTP. It is read-only + filesystem, mainly with sequential access to files. It exports + file operations structure and is not used directly by user code. + httpfs module may support some kind of caching: it requests + more data per request then it's needed at http_read() call and + reads this data later. Such approach speed ups connections speed + and reduces server load. + This opportunity is available if PXE_HTTPFS_CACHING macro + is defined. + + +3.3.11. pxe_icmp module +------------------------ + + pxe_icmp module provides some basic functionality of ICMP + protocol: echo requesting/replying. + Module is unavailable, if PXE_MORE undefined. + + +macro definitions: + +PXE_ICMP_TIMEOUT - timeout in milliseconds when waiting echo reply. + Default: 5000 ms. + + +functions: + +int pxe_ping(const PXE_IPADDR *ip, int count, int flags) + - works similar to usual ping, sends echo request and shows timeout + before echo reply. + +int pxe_icmp_init() + - inits module + + +3.3.12. pxe_ip module +---------------------- + + This module implemets IP protocol functions, also it works + with routing table. It also declares PXE_IPADDR, that is used widely. + +macro definitions: + +PXE_MAX_ROUTES - route table size. Default: 4, usually used 2 entries. + + +functions: + +uint16_t pxe_ip_checksum(const void *data, size_t size) + - calculates checksum for provided block of data. + + +void pxe_ip_route_init(const PXE_IPADDR *def_gw) + - inits routing table, sets default gateway + + +int pxe_ip_route_add(const PXE_IPADDR *net, uint32_t mask, + const PXE_IPADDR *gw) + - adds route to routing table + +int pxe_ip_route_del(const PXE_IPADDR *net, uint32_t mask, + const PXE_IPADDR *gw) + - dels route from routing table + +uint32_t pxe_ip_get_netmask(const PXE_IPADDR *ip) + - returns class based netmask for ip. + +int pxe_ip_route_default(const PXE_IPADDR *gw) + - adds default gateway + +int pxe_ip_send(void *data, const PXE_IPADDR *dst, uint8_t protocol, + uint16_t size) + - sends ip packet with provided data. There must be space for + IP header in buffer, pointed by data. + +void pxe_ip_route_stat() + - show route table. Available if PXE_MORE defined + + +3.3.13. pxe_isr module +----------------------- + + Contains assembler side functions, used in pxe_core. + User code has no direct access to them. + There supported: installation/removing of interrupt handler, + interrupt handler and wrapper for PXE API calls. + + +3.3.14. pxe_mem module +----------------------- + + Actually this module just a wrapper to bcopy(), alloc() and free() + functions. That's done to make pxe_http library more portable. + But in fact, pxe_http depends much on other libstand functions, + such as printf(), strcpy() and etc. So this module is not very usefull and + will be probably removed in future. + + +3.3.15. pxe_sock module +------------------------ + + Most used by user code module. Contains implementation of + pxe_http sockets API. + + +macro definitions: + +PXE_DEFAULT_SOCKETS - count of sockets used at the same time. If all + socket structures are used, next socket creating calls + and API that depends on it, will fail. Default: 4 + + +PXE_SOCKET_TIMEOUT - how long pxe_recv() will be wiating incoming data per + call before return error. Default: 30000 ms + +PXE_SOCKET_CHECK_TIMEOUT - If pxe_recv() waits incoming data and have big free + space in buffer, and in case of TCP protocol it may notice + remote server about this by sending empty packet (with + no data) acking current state, so remote host updates + knowledge about receiving window of client and sends new + data. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 18:47:30 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 554BC96E; Tue, 8 Jan 2013 18:47:30 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3941D35F; Tue, 8 Jan 2013 18:47:30 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08IlUVu065188; Tue, 8 Jan 2013 18:47:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08IlUv2065187; Tue, 8 Jan 2013 18:47:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301081847.r08IlUv2065187@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 18:47:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245172 - user/adrian/ath_radar_stuff/lib/libradarpkt X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 18:47:30 -0000 Author: adrian Date: Tue Jan 8 18:47:29 2013 New Revision: 245172 URL: http://svnweb.freebsd.org/changeset/base/245172 Log: * Disable printing debugging output for now; * Move the channel frequency population into this function Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Tue Jan 8 18:37:12 2013 (r245171) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Tue Jan 8 18:47:29 2013 (r245172) @@ -45,6 +45,13 @@ #include "pkt.h" #include "ar9280_radar.h" +/* Decode the channel */ +#include "chan.h" + +/* from _ieee80211.h */ +#define IEEE80211_CHAN_HT40U 0x00020000 /* HT 40 channel w/ ext above */ +#define IEEE80211_CHAN_HT40D 0x00040000 /* HT 40 channel w/ ext below */ + /* Relevant on Merlin and later */ #define CH_SPECTRAL_EVENT 0x10 /* Relevant for Sowl and later */ @@ -208,7 +215,7 @@ ar9280_radar_spectral_decode(struct ieee if (ar9280_radar_spectral_decode_ht20(rh, fr, fr_len, re, i) != 0) { break; } - ar9280_radar_spectral_print(&re->re_spectral_entries[i]); +// ar9280_radar_spectral_print(&re->re_spectral_entries[i]); fr_len -= AR9280_SPECTRAL_SAMPLE_SIZE_HT20; fr += AR9280_SPECTRAL_SAMPLE_SIZE_HT20; if (fr_len < 0) @@ -232,6 +239,7 @@ ar9280_radar_decode(struct ieee80211_rad int8_t comb_rssi, pri_rssi, ext_rssi, nf; struct ath_rx_radiotap_header *rx = (struct ath_rx_radiotap_header *) rh; + struct xchan x; /* XXX we should really be implementing a real radiotap parser */ tsf = le64toh(rx->wr_tsf); @@ -260,7 +268,7 @@ ar9280_radar_decode(struct ieee80211_rad * HAL/DFS code, so they can all be plotted as appropriate. */ -#if 1 +#if 0 printf("tsf: %lld", tsf); printf(" len: %d", len); printf(" rssi %d/%d", comb_rssi, nf); @@ -300,10 +308,37 @@ ar9280_radar_decode(struct ieee80211_rad //re->re_rssi = pri_rssi; /* XXX extension rssi? */ re->re_rssi = comb_rssi; /* XXX comb for spectral scan? or not? */ re->re_dur = pkt[len - 3]; /* XXX extension duration? */ - re->re_freq = 0; re->re_num_spectral_entries = 0; /* XXX flags? */ + /* + * Update the channel frequency information before we decode + * the spectral or radar FFT payload. + */ + re->re_freq = 0; + /* XXX endian convert len */ + if (pkt_lookup_chan((char *) rh, rh->it_len, &x) == 0) { + /* Update the channel/frequency information */ + re->re_freq = x.freq; + + if (x.flags & IEEE80211_CHAN_QUARTER) { + re->re_freq_sec = 0; + re->re_freqwidth = 5; + } else if (x.flags & IEEE80211_CHAN_HALF) { + re->re_freq_sec = 0; + re->re_freqwidth = 10; + } else if (x.flags & IEEE80211_CHAN_HT40U) { + re->re_freq_sec = re->re_freq + 20; + re->re_freqwidth = 40; + } else if (x.flags & IEEE80211_CHAN_HT40D) { + re->re_freq_sec = re->re_freq - 20; + re->re_freqwidth = 40; + } else { + re->re_freq_sec = 0; + re->re_freqwidth = 20; + } + } + if (pkt[len - 1] & CH_SPECTRAL_EVENT) { (void) ar9280_radar_spectral_decode(rh, pkt, len - 3, re); } From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 19:16:09 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 41509164; Tue, 8 Jan 2013 19:16:09 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 33ECA6E5; Tue, 8 Jan 2013 19:16:09 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08JG9oe073727; Tue, 8 Jan 2013 19:16:09 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08JG89j073724; Tue, 8 Jan 2013 19:16:08 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301081916.r08JG89j073724@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 19:16:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245173 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 19:16:09 -0000 Author: adrian Date: Tue Jan 8 19:16:08 2013 New Revision: 245173 URL: http://svnweb.freebsd.org/changeset/base/245173 Log: Convert this code over to use the dBm value rather than calculating it in the draw loop. This breaks the Linux decoder for now. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 18:47:29 2013 (r245172) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 19:16:08 2013 (r245173) @@ -212,32 +212,21 @@ int draw_picture(int highlight, int star rnum = 0; - for (result = result_list; result ; result = result->next) { - int datamax = 0, datamin = 65536; - int datasquaresum = 0; + for (result = result_list; result ; result = result->next, rnum++) { - for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) { - int data; - - data = result->sample.data[i] * result->sample.data[i]; - datasquaresum += data; - if (data > datamax) datamax = data; - if (data < datamin) datamin = data; - } + if (rnum != highlight) + continue; if (rnum == highlight) { /* prints some statistical data about the currently selected * data sample and auxiliary data. */ - printf("result[%03d]: freq %04d rssi %03d, noise %03d, max_magnitude %04d max_index %03d bitmap_weight %03d tsf %llu | ", + printf("result[%03d]: freq %04d rssi %03d, noise %03d, max_magnitude %04d max_index %03d bitmap_weight %03d tsf %llu\n", rnum, result->sample.freq, result->sample.rssi, result->sample.noise, result->sample.max_magnitude, result->sample.max_index, result->sample.bitmap_weight, result->sample.tsf); - printf("datamax = %d, datamin = %d, datasquaresum = %d\n", datamax, datamin, datasquaresum); - highlight_freq = result->sample.freq; } - for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) { float freq; float signal; @@ -249,10 +238,10 @@ int draw_picture(int highlight, int star /* This is where the "magic" happens: interpret the signal * to output some kind of data which looks useful. */ - data = result->sample.data[i]; - if (data == 0) - data = 1; - signal = result->sample.noise + result->sample.rssi + 20 * log10f(data) - log10f(datasquaresum) * 10; + signal = result->sample.data[i]; + printf(" signal[%d]: %f\n", i, signal); + if (signal == 0) + signal = 1; y = 400 - (400.0 + Y_SCALE * signal); @@ -268,7 +257,6 @@ int draw_picture(int highlight, int star continue; } - rnum++; } SDL_BlitSurface(surface, NULL, screen, NULL); Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h Tue Jan 8 18:47:29 2013 (r245172) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h Tue Jan 8 19:16:08 2013 (r245173) @@ -5,6 +5,7 @@ typedef int8_t s8; typedef uint8_t u8; typedef uint16_t u16; typedef uint64_t u64; +typedef int16_t s16; /* taken from ath9k.h */ #define SPECTRAL_HT20_NUM_BINS 56 @@ -34,7 +35,7 @@ struct fft_sample_ht20 { u64 tsf; - u16 data[SPECTRAL_HT20_NUM_BINS]; + s16 data[SPECTRAL_HT20_NUM_BINS]; } __attribute__((packed)); Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Tue Jan 8 18:47:29 2013 (r245172) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Tue Jan 8 19:16:08 2013 (r245173) @@ -70,7 +70,7 @@ pkt_handle_single(struct radar_entry *re result->sample.tsf = re->re_timestamp; /* XXX 56 = numspectralbins */ for (j = 0; j < 56; j++) { - result->sample.data[j] = re->re_spectral_entries[i].pri.bins[j].raw_mag; + result->sample.data[j] = re->re_spectral_entries[i].pri.bins[j].dBm; } /* add it to the list */ @@ -150,7 +150,7 @@ pkt_handle(int chip, const char *pkt, in /* XXX do something about it */ if (r) { - pkt_print(&re); + //pkt_print(&re); pkt_handle_single(&re); } } From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 19:16:29 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 219D027B; Tue, 8 Jan 2013 19:16:29 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0F2976E9; Tue, 8 Jan 2013 19:16:29 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08JGSjg073792; Tue, 8 Jan 2013 19:16:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08JGSnl073791; Tue, 8 Jan 2013 19:16:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301081916.r08JGSnl073791@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 19:16:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245174 - user/adrian/ath_radar_stuff/lib/libradarpkt X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 19:16:29 -0000 Author: adrian Date: Tue Jan 8 19:16:28 2013 New Revision: 245174 URL: http://svnweb.freebsd.org/changeset/base/245174 Log: Process the HT20 data into dBm values. Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Tue Jan 8 19:16:08 2013 (r245173) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Tue Jan 8 19:16:28 2013 (r245174) @@ -33,6 +33,7 @@ #include #include #include /* for memcpy() */ +#include #include #include @@ -66,56 +67,64 @@ * GPLed snippet from Zefir on the linux-wireless list; rewrite this * soon! */ -#if 0 +#if 1 /* * In my system the post-processed FFT raw data is transferred via a netlink * interface to a spectral_proxy, that forwards it to a connected host for real-time * inspection and visualization. - + * * The interpretation of the data is as follows: the reported values are given as * magnitudes, which need to be scaled and converted to absolute power values based * on the packets noise floor and RSSI values as follows: * bin_sum = 10*log(sum[i=1..56](b(i)^2) * power(i) = noise_floor + RSSI + 10*log(b(i)^2) - bin_sum - + * * The code fragment to convert magnitude to absolute power values looks like this * (assuming you transferred the FFT and magnitude data to user space): -*/ -bool -convert_data(struct spectral_ht20_msg *msg) + */ +int +convert_data_ht20(struct radar_entry *re, struct radar_fft_entry *fe) { - uint8_t *bin_pwr = msg->bin; - uint8_t *dc_pwr = msg->bin + SPECTRAL_NUM_BINS / 2; - int pwr_count = SPECTRAL_NUM_BINS; - int8_t rssi = msg->rssi; - int8_t max_scale = 1 << msg->max_exp; - int16_t max_mag = msg->max_magnitude; - int i; - int nf0 = msg->noise_floor; - - float bsum = 0.0; - - // DC value is invalid -> interpolate - *dc_pwr = (dc_pwr[-1] + dc_pwr[1]) / 2; - - for (i = 0; i < pwr_count; i++) - bsum += (bin_pwr[i] * max_scale) * (bin_pwr[i] * max_scale); - bsum = log10f(bsum) * 10; - - for (i = 0; i < pwr_count; i++) { - float pwr_val; - int16_t val = bin_pwr[i]; - - if (val == 0) - val = 1; - - pwr_val = 20 * log10f((float) val * max_scale); - pwr_val += nf0 + rssi - bsum; - - val = pwr_val; - bin_pwr[i] = val; - } - return true; + int dc_pwr_idx = AR9280_SPECTRAL_SAMPLE_SIZE_HT20 / 2; + int pwr_count = AR9280_SPECTRAL_SAMPLE_SIZE_HT20; + int i; + int nf0 = -96; /* XXX populate re with this first! */ + float bsum = 0.0; + + /* DC value is invalid -> interpolate */ + fe->pri.bins[dc_pwr_idx].raw_mag = + (fe->pri.bins[dc_pwr_idx - 1].raw_mag + fe->pri.bins[dc_pwr_idx + 1].raw_mag) / 2; + /* XXX adj mag? */ + fe->pri.bins[dc_pwr_idx].adj_mag = + fe->pri.bins[dc_pwr_idx].raw_mag << fe->max_exp; + + /* Calculate the total power - use pre-adjusted magnitudes */ + for (i = 0; i < pwr_count; i++) + bsum += (float) (fe->pri.bins[i].adj_mag) * (float) (fe->pri.bins[i].adj_mag); + bsum = log10f(bsum) * 10.0; + + /* + * Given the current NF/RSSI value, calculate an absolute dBm, then + * break each part up into its consitutent component. + */ + for (i = 0; i < pwr_count; i++) { + float pwr_val; + int16_t val = fe->pri.bins[i].adj_mag; + + if (val == 0) + val = 1; + + pwr_val = 20.0 * log10f((float) val); + pwr_val += (float) nf0 + (float) re->re_rssi - bsum; + + fe->pri.bins[i].dBm = pwr_val; +#if 0 + printf(" [%d] %d -> %d, ", i, fe->pri.bins[i].adj_mag, + fe->pri.bins[i].dBm); +#endif + } +// printf("\n"); + return (1); } #endif @@ -182,6 +191,9 @@ ar9280_radar_spectral_decode_ht20(struct fe->pri.bins[i].adj_mag = fe->pri.bins[i].raw_mag << fe->max_exp; } + /* Convert to dBm */ + (void) convert_data_ht20(re, fe); + /* Return OK */ return (0); } From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 21:27:10 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 64E29C7C; Tue, 8 Jan 2013 21:27:10 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 56CD6CBE; Tue, 8 Jan 2013 21:27:10 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08LRAQf010595; Tue, 8 Jan 2013 21:27:10 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08LRA66010594; Tue, 8 Jan 2013 21:27:10 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301082127.r08LRA66010594@svn.freebsd.org> From: Hiroki Sato Date: Tue, 8 Jan 2013 21:27:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245178 - user/hrs/releng/release/sparc64 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 21:27:10 -0000 Author: hrs Date: Tue Jan 8 21:27:09 2013 New Revision: 245178 URL: http://svnweb.freebsd.org/changeset/base/245178 Log: ISO 9660 specification allows only "d-characters" and "a-characters" in the Volume Descriptor (section 7.4). In short, upper-case alphanumeric + some symbols only. Modified: user/hrs/releng/release/sparc64/mkisoimages.sh Modified: user/hrs/releng/release/sparc64/mkisoimages.sh ============================================================================== --- user/hrs/releng/release/sparc64/mkisoimages.sh Tue Jan 8 21:13:58 2013 (r245177) +++ user/hrs/releng/release/sparc64/mkisoimages.sh Tue Jan 8 21:27:09 2013 (r245178) @@ -30,7 +30,7 @@ fi case $1 in -b) BOPT=$1; shift ;; esac -LABEL=$1; shift +LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift NAME=$1; shift # Create an ISO image From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 21:37:14 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D5DA56C; Tue, 8 Jan 2013 21:37:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C8A38D38; Tue, 8 Jan 2013 21:37:14 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08LbET0013448; Tue, 8 Jan 2013 21:37:14 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08LbEDk013447; Tue, 8 Jan 2013 21:37:14 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082137.r08LbEDk013447@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 21:37:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245179 - user/adrian/ath_radar_stuff/lib/libradarpkt X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 21:37:14 -0000 Author: adrian Date: Tue Jan 8 21:37:14 2013 New Revision: 245179 URL: http://svnweb.freebsd.org/changeset/base/245179 Log: pthread-ise? Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile Tue Jan 8 21:27:09 2013 (r245178) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile Tue Jan 8 21:37:14 2013 (r245179) @@ -8,7 +8,7 @@ SRCS+= radiotap_iter.c chan.c # and include it, but I digress.. CFLAGS+= -I/home/adrian/work/freebsd/ath/head/src/sys -g -ggdb \ - -DATH_ENABLE_RADIOTAP_VENDOR_EXT -g -ggdb + -DATH_ENABLE_RADIOTAP_VENDOR_EXT -g -ggdb -pthread NO_MAN= 1 From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 21:37:32 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9194A1AB; Tue, 8 Jan 2013 21:37:32 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 84B2FD3F; Tue, 8 Jan 2013 21:37:32 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08LbW0q013520; Tue, 8 Jan 2013 21:37:32 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08LbW1M013519; Tue, 8 Jan 2013 21:37:32 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082137.r08LbW1M013519@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 21:37:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245180 - user/adrian/ath_radar_stuff/lib/libradarpkt X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 21:37:32 -0000 Author: adrian Date: Tue Jan 8 21:37:31 2013 New Revision: 245180 URL: http://svnweb.freebsd.org/changeset/base/245180 Log: Use the right number of HT20 samples when calculating stuff. Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Tue Jan 8 21:37:14 2013 (r245179) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Tue Jan 8 21:37:31 2013 (r245180) @@ -63,6 +63,8 @@ #define AR9280_SPECTRAL_SAMPLE_SIZE_HT20 60 #define AR9280_SPECTRAL_SAMPLE_SIZE_HT40 135 +#define NUM_SPECTRAL_ENTRIES_HT20 56 + /* * GPLed snippet from Zefir on the linux-wireless list; rewrite this * soon! @@ -85,8 +87,8 @@ int convert_data_ht20(struct radar_entry *re, struct radar_fft_entry *fe) { - int dc_pwr_idx = AR9280_SPECTRAL_SAMPLE_SIZE_HT20 / 2; - int pwr_count = AR9280_SPECTRAL_SAMPLE_SIZE_HT20; + int dc_pwr_idx = NUM_SPECTRAL_ENTRIES_HT20 / 2; + int pwr_count = NUM_SPECTRAL_ENTRIES_HT20; int i; int nf0 = -96; /* XXX populate re with this first! */ float bsum = 0.0; From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 21:40:22 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 059E8380; Tue, 8 Jan 2013 21:40:22 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EC2E5D78; Tue, 8 Jan 2013 21:40:21 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08LeLwY014061; Tue, 8 Jan 2013 21:40:21 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08LeLMj014059; Tue, 8 Jan 2013 21:40:21 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082140.r08LeLMj014059@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 21:40:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245181 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 21:40:22 -0000 Author: adrian Date: Tue Jan 8 21:40:21 2013 New Revision: 245181 URL: http://svnweb.freebsd.org/changeset/base/245181 Log: Add a very simple initial histogram data type, to populate and fetch histogram entries. Added: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Added: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 21:40:21 2013 (r245181) @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include /* for ntohl etc */ + +#include + +#include "net80211/ieee80211.h" +#include "net80211/ieee80211_radiotap.h" + +#include "libradarpkt/pkt.h" +#include "libradarpkt/ar5212_radar.h" +#include "libradarpkt/ar5416_radar.h" +#include "libradarpkt/ar9280_radar.h" + +#include "fft_eval.h" +#include "fft_freebsd.h" + +#include "fft_histogram.h" + +struct fft_histogram_data fdata; + +/* XXX ew */ +#define SPECTRAL_HT20_NUM_BINS 56 + +void +fft_histogram_init(void) +{ + bzero(&fdata, sizeof(fdata)); +} + +int +freq2fidx(int freqKhz) +{ + int freqMhz = freqKhz / 1000; + int fidx; + + if (freqMhz < FFT_HISTOGRAM_START_FREQ || + freqMhz >= FFT_HISTOGRAM_END_FREQ) { + return (-1); + } + + /* Calculate index */ + fidx = (freqKhz - FFT_HISTOGRAM_START_FREQ * 1000) + / (1000 / FFT_HISTOGRAM_RESOLUTION); + + if (fidx < 0 || fidx >= FFT_HISTOGRAM_SIZE) { + return (-1); + } + + return (fidx); +} + +void +fft_add_sample(struct radar_entry *re, struct radar_fft_entry *fe) +{ + float ffreq; + int i; + int fidx; + + for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) { + /* Calculate frequency of the given event */ + ffreq = (float) re->re_freq - 10.0 + + ((20.0 * i) / SPECTRAL_HT20_NUM_BINS); + + /* If it doesn't fit in the array, toss */ + fidx = freq2fidx((int) (ffreq * 1000.0)); + if (fidx < 0) + continue; + + /* XXX until i figure out what's going on */ + if (fe->pri.bins[i].dBm == 0 || fe->pri.bins[i].dBm < -185) + continue; + + /* Store the current dBm value */ + fdata.pts[fidx] = fe->pri.bins[i].dBm; + } +} + +int +fft_fetch_freq(int freqKhz) +{ + int fidx; + + fidx = freq2fidx(freqKhz); + if (fidx < 0) + return -150; /* XXX */ + +#if 0 + printf("%s: khz=%d, fidx=%d, val=%d\n", + __func__, + freqKhz, + fidx, + fdata.pts[fidx]); +#endif + + return fdata.pts[fidx]; +} Added: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 21:40:21 2013 (r245181) @@ -0,0 +1,21 @@ +#ifndef __FFT_HISTOGRAM_H__ +#define __FFT_HISTOGRAM_H__ + +#define FFT_HISTOGRAM_START_FREQ 2300 +#define FFT_HISTOGRAM_END_FREQ 6000 + +#define FFT_HISTOGRAM_RESOLUTION 4 /* 250Khz increments */ + +#define FFT_HISTOGRAM_SIZE \ + ((6000-2300)*FFT_HISTOGRAM_RESOLUTION) + +struct fft_histogram_data { + int pts[FFT_HISTOGRAM_SIZE]; +}; + +extern void fft_histogram_init(void); +extern void fft_add_sample(struct radar_entry *re, + struct radar_fft_entry *fe); +extern int fft_fetch_freq(int freqKhz); + +#endif From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 21:42:32 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 12EFA4B6; Tue, 8 Jan 2013 21:42:32 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 03405D8C; Tue, 8 Jan 2013 21:42:32 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08LgV2I015777; Tue, 8 Jan 2013 21:42:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08LgVYL015772; Tue, 8 Jan 2013 21:42:31 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082142.r08LgVYL015772@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 21:42:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245182 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 21:42:32 -0000 Author: adrian Date: Tue Jan 8 21:42:30 2013 New Revision: 245182 URL: http://svnweb.freebsd.org/changeset/base/245182 Log: Biiig fft eval commit: * Hard-code the fft source to an AR9280 on wlan0 for now, sorry! * Change the pcap code to be: + a data source; + that runs in a thread; + and calls a cb on each radar entry decoded; * Modify the rendering code to use the fft histogram, rather than a list of frames to render; * Populate the histogram via a cb, with relevant locking; * never wait/delay, always just poll for events. I'm not doing correct locking or conditional wakeups _at all_ in the rendering loop as this is quite honestly a terrible piece of code. But it's good enough to do initial test rendering with. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/Makefile user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.h Modified: user/adrian/ath_radar_stuff/src/spectral_fft/Makefile ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/Makefile Tue Jan 8 21:40:21 2013 (r245181) +++ user/adrian/ath_radar_stuff/src/spectral_fft/Makefile Tue Jan 8 21:42:30 2013 (r245182) @@ -1,10 +1,10 @@ PROG= fft_eval -SRCS= fft_eval.c fft_linux.c fft_freebsd.c +SRCS= fft_eval.c fft_freebsd.c fft_histogram.c -CFLAGS+= -I/usr/local/include -L/usr/local/lib -I../../lib/ -L../../lib/libradarpkt +CFLAGS+= -I/usr/local/include -L/usr/local/lib -I../../lib/ -L../../lib/libradarpkt -pthread -LDADD+= -lSDL -lSDL_ttf -lradarpkt -lpcap +LDADD+= -lSDL -lSDL_ttf -lradarpkt -lpcap -pthread NO_MAN= 1 Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 21:40:21 2013 (r245181) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 21:42:30 2013 (r245182) @@ -27,18 +27,32 @@ #include #include #include +#include +#include +#include + #include #include #include "fft_eval.h" -#include "fft_linux.h" + +#include "net80211/ieee80211.h" +#include "net80211/ieee80211_radiotap.h" + +#include "libradarpkt/pkt.h" +#include "libradarpkt/ar5212_radar.h" +#include "libradarpkt/ar5416_radar.h" +#include "libradarpkt/ar9280_radar.h" + +#include "fft_eval.h" #include "fft_freebsd.h" +#include "fft_histogram.h" #define WIDTH 1600 #define HEIGHT 650 #define BPP 32 -#define X_SCALE 10 +#define X_SCALE 5 #define Y_SCALE 4 #define RMASK 0x000000ff @@ -49,11 +63,12 @@ #define BBITS 16 #define AMASK 0xff000000 +/* XXX ew globals */ +pthread_mutex_t mtx_histogram; +int g_do_update = 0; SDL_Surface *screen = NULL; TTF_Font *font = NULL; -struct scanresult *result_list; -int scanresults_n = 0; int graphics_init_sdl(void) { @@ -116,7 +131,7 @@ int pixel(Uint32 *pixels, int x, int y, } -#define SIZE 3 +#define SIZE 2 /* this function blends a 2*SIZE x 2*SIZE blob at the given position with * the defined opacity. */ int bigpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) @@ -186,7 +201,7 @@ int draw_picture(int highlight, int star pixels[x + y * WIDTH] = AMASK; /* vertical lines (frequency) */ - for (i = 2300; i < 6000; i += 10) { + for (i = 2300; i < 6000; i += 20) { x = (X_SCALE * (i - startfreq)); if (x < 0 || x > WIDTH) @@ -210,53 +225,26 @@ int draw_picture(int highlight, int star render_text(surface, text, 5, y - 15); } + /* Render 2300 -> 6000 in 1MHz increments, but using KHz math */ + /* .. as right now the canvas is .. quite large. */ + for (i = 2300*1000; i < 6000*1000; i+= 250) { + float signal; + int freqKhz = i; - rnum = 0; - for (result = result_list; result ; result = result->next, rnum++) { + /* Fetch dBm value at the given frequency in KHz */ + signal = (float) fft_fetch_freq(freqKhz); + x = X_SCALE * (freqKhz - (startfreq * 1000)) / 1000; - if (rnum != highlight) - continue; + y = 400 - (400.0 + Y_SCALE * signal); - if (rnum == highlight) { - /* prints some statistical data about the currently selected - * data sample and auxiliary data. */ - printf("result[%03d]: freq %04d rssi %03d, noise %03d, max_magnitude %04d max_index %03d bitmap_weight %03d tsf %llu\n", - rnum, result->sample.freq, result->sample.rssi, result->sample.noise, - result->sample.max_magnitude, result->sample.max_index, result->sample.bitmap_weight, - result->sample.tsf); - highlight_freq = result->sample.freq; - } + color = RMASK | AMASK; + opacity = 255; - for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) { - float freq; - float signal; - int data; - freq = result->sample.freq - 10.0 + ((20.0 * i) / SPECTRAL_HT20_NUM_BINS); - - x = (X_SCALE * (freq - startfreq)); - - /* This is where the "magic" happens: interpret the signal - * to output some kind of data which looks useful. */ - - signal = result->sample.data[i]; - printf(" signal[%d]: %f\n", i, signal); - if (signal == 0) - signal = 1; - - y = 400 - (400.0 + Y_SCALE * signal); - - if (rnum == highlight) { - color = RMASK | AMASK; - opacity = 255; - } else { - color = BMASK | AMASK; - opacity = 30; - } +// printf(" (%d) %d,%d\n", freqKhz, x, y); - if (bigpixel(pixels, x, y, color, opacity) < 0) - continue; + if (bigpixel(pixels, x, y, color, opacity) < 0) + continue; - } } SDL_BlitSurface(surface, NULL, screen, NULL); @@ -285,6 +273,13 @@ void graphics_main(void) } SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); while (!quit) { + pthread_mutex_lock(&mtx_histogram); + if (g_do_update == 1) { + change = 1; /* XXX always render */ + g_do_update = 0; + } + pthread_mutex_unlock(&mtx_histogram); + if (change) { highlight_freq = draw_picture(highlight, startfreq); change = 0; @@ -305,10 +300,10 @@ void graphics_main(void) accel = 100; } - if (accel) +// if (accel) SDL_PollEvent(&event); - else - SDL_WaitEvent(&event); +// else +// SDL_WaitEvent(&event); switch (event.type) { case SDL_QUIT: @@ -316,6 +311,7 @@ void graphics_main(void) break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { +#if 0 case SDLK_LEFT: if (highlight > 0) { highlight--; @@ -330,6 +326,7 @@ void graphics_main(void) change = 1; } break; +#endif case SDLK_PAGEUP: accel-= 2; scroll = 1; @@ -375,8 +372,25 @@ void usage(int argc, char *argv[]) } +static void +fft_eval_cb(struct radar_entry *re, void *cbdata) +{ + struct radar_fft_entry *fe; + int i; + + pthread_mutex_lock(&mtx_histogram); + for (i = 0; i < re->re_num_spectral_entries; i++) { + fft_add_sample(re, &re->re_spectral_entries[i]); + } + g_do_update = 1; + pthread_mutex_unlock(&mtx_histogram); + +} + int main(int argc, char *argv[]) { + int ret; + if (argc < 2) { usage(argc, argv); return -1; @@ -384,8 +398,15 @@ int main(int argc, char *argv[]) fprintf(stderr, "WARNING: Experimental Software! Don't trust anything you see. :)\n"); fprintf(stderr, "\n"); - scanresults_n = read_scandata_freebsd(argv[1], &result_list); - if (scanresults_n < 0) { + + /* Setup radar entry callback */ + pthread_mutex_init(&mtx_histogram, NULL); + set_scandata_callback(fft_eval_cb, NULL); + + /* Fetch data */ + ret = read_scandata_freebsd(argv[1], NULL); + + if (ret < 0) { fprintf(stderr, "Couldn't read scanfile ...\n"); usage(argc, argv); return -1; Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Tue Jan 8 21:40:21 2013 (r245181) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Tue Jan 8 21:42:30 2013 (r245182) @@ -1,8 +1,10 @@ #include #include #include +#include #include #include /* for ntohl etc */ +#include #include @@ -17,12 +19,18 @@ #include "fft_eval.h" #include "fft_freebsd.h" -/* - * XXX ew, static variables - */ -int n_spectral_samples = 0; -struct scanresult **result_head; -struct scanresult *result_tail; +static scandata_cb cb_cb = NULL; +static void * cb_cbdata = NULL; +pthread_t main_pthread; +pcap_t * g_p; +int g_chip = 0; + +void +set_scandata_callback(scandata_cb cb, void *cbdata) +{ + cb_cb = cb; + cb_cbdata = cbdata; +} /* * Compile up a rule that's bound to be useful - it only matches on @@ -31,7 +39,6 @@ struct scanresult *result_tail; * tcpdump -ni wlan0 -y IEEE802_11_RADIO -x -X -s0 -v -ve \ * 'radio[73] == 0x2 && (radio[72] == 5 || radio[72] == 24) */ - #define PKTRULE "radio[73] == 0x2 && (radio[72] == 5 || radio[72] == 24)" static int @@ -45,42 +52,14 @@ pkt_compile(pcap_t *p, struct bpf_progra static void pkt_handle_single(struct radar_entry *re) { - int i, j; - struct scanresult *result; + /* Call our callback w/ the radar entry */ + if (cb_cb) + cb_cb(re, cb_cbdata); - for (i = 0; i < re->re_num_spectral_entries; i++) { - result = malloc(sizeof(*result)); - if (result == NULL) { - /* Skip on malloc failure */ - warn("%s: malloc", __func__); - continue; - } - - /* Fill out the result, assuming HT20 for now */ - result->sample.tlv.type = ATH_FFT_SAMPLE_HT20; - result->sample.tlv.length = sizeof(result->sample); /* XXX right? */ - - result->sample.freq = re->re_freq; - result->sample.rssi = re->re_rssi; - result->sample.noise = -95; /* XXX extract from header */ - result->sample.max_magnitude = re->re_spectral_entries[i].pri.max_magnitude; - result->sample.max_index = re->re_spectral_entries[i].pri.max_index; - result->sample.bitmap_weight = re->re_spectral_entries[i].pri.bitmap_weight; - /* XXX no max_exp? */ - result->sample.tsf = re->re_timestamp; - /* XXX 56 = numspectralbins */ - for (j = 0; j < 56; j++) { - result->sample.data[j] = re->re_spectral_entries[i].pri.bins[j].dBm; - } - - /* add it to the list */ - if (result_tail) - result_tail->next = result; - else - (*result_head) = result; - result_tail = result; - n_spectral_samples++; - } +#if 0 + /* Sleep for a bit */ + usleep(100 * 1000); /* 100ms */ +#endif } static void @@ -211,23 +190,44 @@ usage(const char *progname) progname); } -int -open_device(const char *dev_str, const char *chip_str, const char *mode) +static void * +fft_pcap_thread_main(void *arg) { - char *dev; - pcap_t * p; - const char *fname; const unsigned char *pkt; struct pcap_pkthdr *hdr; int len, r; - int chip = 0; + /* + * Iterate over frames, looking for radiotap frames + * which have PHY errors. + * + * XXX We should compile a filter for this, but the + * XXX access method is a non-standard hack atm. + */ + while ((r = pcap_next_ex(g_p, &hdr, &pkt)) >= 0) { +#if 0 + printf("capture: len=%d, caplen=%d\n", + hdr->len, hdr->caplen); +#endif + if (r > 0) + pkt_handle(g_chip, pkt, hdr->caplen); + } + + return (NULL); +} + + +int +open_device(const char *dev_str, const char *chip_str, const char *mode) +{ + char *dev; + const char *fname; if (strcmp(chip_str, "ar5212") == 0) { - chip = CHIP_AR5212; + g_chip = CHIP_AR5212; } else if (strcmp(chip_str, "ar5416") == 0) { - chip = CHIP_AR5416; + g_chip = CHIP_AR5416; } else if (strcmp(chip_str, "ar9280") == 0) { - chip = CHIP_AR9280; + g_chip = CHIP_AR9280; } else { usage("main"); exit(255); @@ -237,35 +237,24 @@ open_device(const char *dev_str, const c fname = dev_str; if (strcmp(mode, "file") == 0) { - p = open_offline(fname); + g_p = open_offline(fname); } else if (strcmp(mode, "if") == 0) { - p = open_online(fname); + g_p = open_online(fname); } else { usage("main"); exit(255); } - if (p == NULL) + if (g_p == NULL) exit(255); - /* - * Iterate over frames, looking for radiotap frames - * which have PHY errors. - * - * XXX We should compile a filter for this, but the - * XXX access method is a non-standard hack atm. - */ - while ((r = pcap_next_ex(p, &hdr, &pkt)) >= 0) { -#if 0 - printf("capture: len=%d, caplen=%d\n", - hdr->len, hdr->caplen); -#endif - if (r > 0) - pkt_handle(chip, pkt, hdr->caplen); + /* Create data source thread */ + if (pthread_create(&main_pthread, NULL, + fft_pcap_thread_main, NULL) != 0) { + warnx("pthread_create"); + return(-1); } - pcap_close(p); - /* XXX for now */ return (0); } @@ -274,13 +263,6 @@ int read_scandata_freebsd(char *fname, struct scanresult **result) { - /* XXX for now, return/do nothing */ - - n_spectral_samples = 0; - result_head = result; - result_tail = (*result); - - (void) open_device(fname, "ar9280", "file"); - - return n_spectral_samples; + (void) open_device("wlan0", "ar9280", "if"); + return (0); } Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.h Tue Jan 8 21:40:21 2013 (r245181) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.h Tue Jan 8 21:42:30 2013 (r245182) @@ -1,6 +1,9 @@ #ifndef __FFT_FREEBSD_H__ #define __FFT_FREEBSD_H__ +typedef void (* scandata_cb)(struct radar_entry *re, void *cbdata); + +extern void set_scandata_callback(scandata_cb cb, void *cbdata); extern int read_scandata_freebsd(char *fname, struct scanresult **result); #endif From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 22:23:14 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 04A973B7; Tue, 8 Jan 2013 22:23:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EB689F3F; Tue, 8 Jan 2013 22:23:13 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08MNDq7027837; Tue, 8 Jan 2013 22:23:13 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08MNDff027834; Tue, 8 Jan 2013 22:23:13 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082223.r08MNDff027834@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 22:23:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245188 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 22:23:14 -0000 Author: adrian Date: Tue Jan 8 22:23:12 2013 New Revision: 245188 URL: http://svnweb.freebsd.org/changeset/base/245188 Log: Add in a very hacky and mostly incorrect rolling average and slightly decaying max-hold implementation. Plot the max in red, and the current average-ish in blue. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 22:23:09 2013 (r245187) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 22:23:12 2013 (r245188) @@ -231,20 +231,23 @@ int draw_picture(int highlight, int star float signal; int freqKhz = i; - /* Fetch dBm value at the given frequency in KHz */ - signal = (float) fft_fetch_freq(freqKhz); x = X_SCALE * (freqKhz - (startfreq * 1000)) / 1000; + /* Fetch dBm value at the given frequency in KHz */ + signal = (float) fft_fetch_freq_avg(freqKhz); + color = BMASK | AMASK; + opacity = 64; y = 400 - (400.0 + Y_SCALE * signal); + if (bigpixel(pixels, x, y, color, opacity) < 0) + continue; + /* .. and the max */ + signal = (float) fft_fetch_freq_max(freqKhz); color = RMASK | AMASK; opacity = 255; - -// printf(" (%d) %d,%d\n", freqKhz, x, y); - + y = 400 - (400.0 + Y_SCALE * signal); if (bigpixel(pixels, x, y, color, opacity) < 0) continue; - } SDL_BlitSurface(surface, NULL, screen, NULL); Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 22:23:09 2013 (r245187) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 22:23:12 2013 (r245188) @@ -70,30 +70,40 @@ fft_add_sample(struct radar_entry *re, s continue; /* XXX until i figure out what's going on */ - if (fe->pri.bins[i].dBm == 0 || fe->pri.bins[i].dBm < -185) + if (fe->pri.bins[i].dBm == 0 || fe->pri.bins[i].dBm < -185) // || fe->pri.bins[i].dBm > -10) continue; - /* Store the current dBm value */ - fdata.pts[fidx] = fe->pri.bins[i].dBm; + /* Rolling/decaying average */ + fdata.avg_pts[fidx] = (((fdata.avg_pts[fidx] * 100) / 90) + fe->pri.bins[i].dBm) / 2; + + /* Max */ + if (fdata.max_pts[fidx] == 0 || fe->pri.bins[i].dBm > fdata.max_pts[fidx]) { + fdata.max_pts[fidx] = fe->pri.bins[i].dBm; + } else { + fdata.max_pts[fidx] = ((fdata.max_pts[fidx] * 997) + (fe->pri.bins[i].dBm * 3)) / 1000; + } } } int -fft_fetch_freq(int freqKhz) +fft_fetch_freq_avg(int freqKhz) { int fidx; fidx = freq2fidx(freqKhz); if (fidx < 0) - return -150; /* XXX */ + return -180; /* XXX */ + + return fdata.avg_pts[fidx]; +} +int +fft_fetch_freq_max(int freqKhz) +{ + int fidx; -#if 0 - printf("%s: khz=%d, fidx=%d, val=%d\n", - __func__, - freqKhz, - fidx, - fdata.pts[fidx]); -#endif + fidx = freq2fidx(freqKhz); + if (fidx < 0) + return -180; /* XXX */ - return fdata.pts[fidx]; + return fdata.max_pts[fidx]; } Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 22:23:09 2013 (r245187) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 22:23:12 2013 (r245188) @@ -10,12 +10,14 @@ ((6000-2300)*FFT_HISTOGRAM_RESOLUTION) struct fft_histogram_data { - int pts[FFT_HISTOGRAM_SIZE]; + int avg_pts[FFT_HISTOGRAM_SIZE]; + int max_pts[FFT_HISTOGRAM_SIZE]; }; extern void fft_histogram_init(void); extern void fft_add_sample(struct radar_entry *re, struct radar_fft_entry *fe); -extern int fft_fetch_freq(int freqKhz); +extern int fft_fetch_freq_avg(int freqKhz); +extern int fft_fetch_freq_max(int freqKhz); #endif From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 22:30:12 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D2C3D741; Tue, 8 Jan 2013 22:30:12 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BB47FF8C; Tue, 8 Jan 2013 22:30:12 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08MUCUB028781; Tue, 8 Jan 2013 22:30:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08MUCwl028780; Tue, 8 Jan 2013 22:30:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082230.r08MUCwl028780@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 22:30:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245189 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 22:30:12 -0000 Author: adrian Date: Tue Jan 8 22:30:12 2013 New Revision: 245189 URL: http://svnweb.freebsd.org/changeset/base/245189 Log: Fiddle wiht the decay rate a bit more. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 22:23:12 2013 (r245188) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 22:30:12 2013 (r245189) @@ -80,7 +80,7 @@ fft_add_sample(struct radar_entry *re, s if (fdata.max_pts[fidx] == 0 || fe->pri.bins[i].dBm > fdata.max_pts[fidx]) { fdata.max_pts[fidx] = fe->pri.bins[i].dBm; } else { - fdata.max_pts[fidx] = ((fdata.max_pts[fidx] * 997) + (fe->pri.bins[i].dBm * 3)) / 1000; + fdata.max_pts[fidx] = ((fdata.max_pts[fidx] * 975) + (fe->pri.bins[i].dBm * 25)) / 1000; } } } From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 23:25:03 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2C6D8EE1; Tue, 8 Jan 2013 23:25:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 104C226F; Tue, 8 Jan 2013 23:25:03 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08NP2Vt045806; Tue, 8 Jan 2013 23:25:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08NP2kO045802; Tue, 8 Jan 2013 23:25:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082325.r08NP2kO045802@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 23:25:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245193 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 23:25:03 -0000 Author: adrian Date: Tue Jan 8 23:25:02 2013 New Revision: 245193 URL: http://svnweb.freebsd.org/changeset/base/245193 Log: * Add home/end to skip between 2 and 5ghz * Add a history buffer to the current readings, so i can get a better idea of what's going on graphically (and yes it's pretty) * change the default alpha for the max to not be 255 ,so there's some .. prettiness too. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 22:55:39 2013 (r245192) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 23:25:02 2013 (r245193) @@ -130,17 +130,26 @@ int pixel(Uint32 *pixels, int x, int y, return 0; } - #define SIZE 2 + +/* Is this pixel in the viewport? */ +static int +is_in_viewport(int x, int y) +{ + if (x - SIZE < 0 || x + SIZE >= WIDTH) + return 0; + if (y - SIZE < 0 || y + SIZE >= HEIGHT) + return 0; + return (1); +} + /* this function blends a 2*SIZE x 2*SIZE blob at the given position with * the defined opacity. */ int bigpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) { int x1, y1; - if (x - SIZE < 0 || x + SIZE >= WIDTH) - return -1; - if (y - SIZE < 0 || y + SIZE >= HEIGHT) + if (! is_in_viewport(x, y)) return -1; for (x1 = x - SIZE; x1 < x + SIZE; x1++) @@ -188,7 +197,7 @@ int render_text(SDL_Surface *surface, ch int draw_picture(int highlight, int startfreq) { Uint32 *pixels, color, opacity; - int x, y, i, rnum; + int x, y, i, rnum, j; int highlight_freq = startfreq + 20; char text[1024]; struct scanresult *result; @@ -227,24 +236,38 @@ int draw_picture(int highlight, int star /* Render 2300 -> 6000 in 1MHz increments, but using KHz math */ /* .. as right now the canvas is .. quite large. */ + /* XXX should just do it based on the current viewport! */ for (i = 2300*1000; i < 6000*1000; i+= 250) { float signal; int freqKhz = i; + int16_t *s; x = X_SCALE * (freqKhz - (startfreq * 1000)) / 1000; + if (x < 0 || x > WIDTH) + continue; + /* Fetch dBm value at the given frequency in KHz */ - signal = (float) fft_fetch_freq_avg(freqKhz); - color = BMASK | AMASK; - opacity = 64; - y = 400 - (400.0 + Y_SCALE * signal); - if (bigpixel(pixels, x, y, color, opacity) < 0) + s = fft_fetch_freq_avg(freqKhz); + if (s == NULL) continue; + for (j = 0; j < FFT_HISTOGRAM_HISTORY_DEPTH; j++) { + if (s[j] == 0) + continue; + signal = (float) s[j]; + color = BMASK | AMASK; + opacity = 64; + y = 400 - (400.0 + Y_SCALE * signal); + if (bigpixel(pixels, x, y, color, opacity) < 0) + continue; + } + + /* .. and the max */ signal = (float) fft_fetch_freq_max(freqKhz); color = RMASK | AMASK; - opacity = 255; + opacity = 128; y = 400 - (400.0 + Y_SCALE * signal); if (bigpixel(pixels, x, y, color, opacity) < 0) continue; @@ -337,6 +360,15 @@ void graphics_main(void) case SDLK_PAGEDOWN: accel+= 2; scroll = 1; + break; + case SDLK_HOME: + startfreq = 2300; + accel = 0; + break; + case SDLK_END: + startfreq = 5100; + accel = 0; + break; default: break; } Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 22:55:39 2013 (r245192) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Tue Jan 8 23:25:02 2013 (r245193) @@ -58,6 +58,7 @@ fft_add_sample(struct radar_entry *re, s float ffreq; int i; int fidx; + int cur; for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) { /* Calculate frequency of the given event */ @@ -74,7 +75,13 @@ fft_add_sample(struct radar_entry *re, s continue; /* Rolling/decaying average */ - fdata.avg_pts[fidx] = (((fdata.avg_pts[fidx] * 100) / 90) + fe->pri.bins[i].dBm) / 2; + cur = fdata.avg_pts_cur[fidx]; + if (fdata.avg_pts[fidx][cur] == 0) { + fdata.avg_pts[fidx][cur] = fe->pri.bins[i].dBm; + } else { + fdata.avg_pts[fidx][cur] = (((fdata.avg_pts[fidx][cur] * 100) / 90) + fe->pri.bins[i].dBm) / 2; + } + fdata.avg_pts_cur[fidx] = (fdata.avg_pts_cur[fidx] + 1) % FFT_HISTOGRAM_HISTORY_DEPTH; /* Max */ if (fdata.max_pts[fidx] == 0 || fe->pri.bins[i].dBm > fdata.max_pts[fidx]) { @@ -85,18 +92,19 @@ fft_add_sample(struct radar_entry *re, s } } -int +int16_t * fft_fetch_freq_avg(int freqKhz) { int fidx; fidx = freq2fidx(freqKhz); if (fidx < 0) - return -180; /* XXX */ + return NULL; return fdata.avg_pts[fidx]; } -int + +int16_t fft_fetch_freq_max(int freqKhz) { int fidx; Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 22:55:39 2013 (r245192) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 23:25:02 2013 (r245193) @@ -8,16 +8,20 @@ #define FFT_HISTOGRAM_SIZE \ ((6000-2300)*FFT_HISTOGRAM_RESOLUTION) +#define FFT_HISTOGRAM_HISTORY_DEPTH 10 struct fft_histogram_data { - int avg_pts[FFT_HISTOGRAM_SIZE]; - int max_pts[FFT_HISTOGRAM_SIZE]; + /* XXX should struct-ize these! */ + int16_t avg_pts[FFT_HISTOGRAM_SIZE][FFT_HISTOGRAM_HISTORY_DEPTH]; + int16_t avg_pts_cur[FFT_HISTOGRAM_SIZE]; + + int16_t max_pts[FFT_HISTOGRAM_SIZE]; }; extern void fft_histogram_init(void); extern void fft_add_sample(struct radar_entry *re, struct radar_fft_entry *fe); -extern int fft_fetch_freq_avg(int freqKhz); -extern int fft_fetch_freq_max(int freqKhz); +extern int16_t * fft_fetch_freq_avg(int freqKhz); +extern int16_t fft_fetch_freq_max(int freqKhz); #endif From owner-svn-src-user@FreeBSD.ORG Tue Jan 8 23:32:29 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9BA69121; Tue, 8 Jan 2013 23:32:29 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8A0B02B3; Tue, 8 Jan 2013 23:32:29 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r08NWTCN048172; Tue, 8 Jan 2013 23:32:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r08NWTm9048171; Tue, 8 Jan 2013 23:32:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301082332.r08NWTm9048171@svn.freebsd.org> From: Adrian Chadd Date: Tue, 8 Jan 2013 23:32:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245194 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2013 23:32:29 -0000 Author: adrian Date: Tue Jan 8 23:32:28 2013 New Revision: 245194 URL: http://svnweb.freebsd.org/changeset/base/245194 Log: .. history depth is fun. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 23:25:02 2013 (r245193) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Tue Jan 8 23:32:28 2013 (r245194) @@ -8,7 +8,7 @@ #define FFT_HISTOGRAM_SIZE \ ((6000-2300)*FFT_HISTOGRAM_RESOLUTION) -#define FFT_HISTOGRAM_HISTORY_DEPTH 10 +#define FFT_HISTOGRAM_HISTORY_DEPTH 20 struct fft_histogram_data { /* XXX should struct-ize these! */ From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 00:01:27 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 782751A9; Wed, 9 Jan 2013 00:01:27 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5BF616A6; Wed, 9 Jan 2013 00:01:27 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0901RhX055942; Wed, 9 Jan 2013 00:01:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0901RlD055941; Wed, 9 Jan 2013 00:01:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301090001.r0901RlD055941@svn.freebsd.org> From: Adrian Chadd Date: Wed, 9 Jan 2013 00:01:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245197 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 00:01:27 -0000 Author: adrian Date: Wed Jan 9 00:01:26 2013 New Revision: 245197 URL: http://svnweb.freebsd.org/changeset/base/245197 Log: Implement a separate pixel set function for the average points, to implement a really stupidly simple heatmap (blue -> blue+green) for points that saturate the blue opacity. This makes the "very frequent" points very obvious. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 00:00:34 2013 (r245196) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 00:01:26 2013 (r245197) @@ -156,14 +156,58 @@ int bigpixel(Uint32 *pixels, int x, int for (y1 = y - SIZE; y1 < y + SIZE; y1++) { Uint32 r, g, b; - r = ((pixels[x1 + y1 * WIDTH] & RMASK) >> RBITS) + ((((color & RMASK) >> RBITS) * opacity) / 255); + r = ((pixels[x1 + y1 * WIDTH] & RMASK) >> RBITS) + + ((((color & RMASK) >> RBITS) * opacity) / 255); if (r > 255) r = 255; - g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + ((((color & GMASK) >> GBITS) * opacity) / 255); + + g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + + ((((color & GMASK) >> GBITS) * opacity) / 255); if (g > 255) g = 255; - b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS) + ((((color & BMASK) >> BBITS) * opacity) / 255); + + b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS) + + ((((color & BMASK) >> BBITS) * opacity) / 255); if (b > 255) b = 255; - pixels[x1 + y1 * WIDTH] = r << RBITS | g << GBITS | b << BBITS | (color & AMASK); + pixels[x1 + y1 * WIDTH] = r << RBITS | + g << GBITS | b << BBITS | (color & AMASK); + } + return 0; +} + +int bighotpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) +{ + int x1, y1; + + if (! is_in_viewport(x, y)) + return -1; + + for (x1 = x - SIZE; x1 < x + SIZE; x1++) + for (y1 = y - SIZE; y1 < y + SIZE; y1++) { + Uint32 r, g, b; + + r = ((pixels[x1 + y1 * WIDTH] & RMASK) >> RBITS) + + ((((color & RMASK) >> RBITS) * opacity) / 255); + if (r > 255) r = 255; + + g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + + ((((color & GMASK) >> GBITS) * opacity) / 255); + if (g > 255) g = 255; + + /* If we've capped out blue, increment red */ + b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS); + if (b > 248) { + /* green bumped by bluemask */ + g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + + ((((color & BMASK) >> BBITS) * (opacity/2)) / 255); + if (g > 255) g = 255; + } else { + b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS) + + ((((color & BMASK) >> BBITS) * opacity) / 255); + if (b > 255) b = 255; + } + + pixels[x1 + y1 * WIDTH] = r << RBITS | + g << GBITS | b << BBITS | (color & AMASK); } return 0; } @@ -259,7 +303,7 @@ int draw_picture(int highlight, int star color = BMASK | AMASK; opacity = 64; y = 400 - (400.0 + Y_SCALE * signal); - if (bigpixel(pixels, x, y, color, opacity) < 0) + if (bighotpixel(pixels, x, y, color, opacity) < 0) continue; } From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 11:58:50 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9617F96D; Wed, 9 Jan 2013 11:58:50 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 75EB286B; Wed, 9 Jan 2013 11:58:50 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r09BwodR062180; Wed, 9 Jan 2013 11:58:50 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r09BwlJr062165; Wed, 9 Jan 2013 11:58:47 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201301091158.r09BwlJr062165@svn.freebsd.org> From: Attilio Rao Date: Wed, 9 Jan 2013 11:58:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245224 - in user/attilio/vmcontention: . bin/ln bin/ls bin/test cddl/contrib/opensolaris/cmd/zpool contrib/dialog contrib/dialog/package contrib/dialog/package/debian contrib/dialog/po... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 11:58:50 -0000 Author: attilio Date: Wed Jan 9 11:58:47 2013 New Revision: 245224 URL: http://svnweb.freebsd.org/changeset/base/245224 Log: MFC Added: user/attilio/vmcontention/contrib/dialog/samples/dselect - copied unchanged from r245223, head/contrib/dialog/samples/dselect user/attilio/vmcontention/contrib/dialog/samples/valgrind.log - copied unchanged from r245223, head/contrib/dialog/samples/valgrind.log user/attilio/vmcontention/lib/libc/nls/zh_CN.GB18030.msg - copied unchanged from r245223, head/lib/libc/nls/zh_CN.GB18030.msg user/attilio/vmcontention/lib/libc/nls/zh_CN.GB2312.msg - copied unchanged from r245223, head/lib/libc/nls/zh_CN.GB2312.msg user/attilio/vmcontention/lib/libc/nls/zh_CN.UTF-8.msg - copied unchanged from r245223, head/lib/libc/nls/zh_CN.UTF-8.msg user/attilio/vmcontention/sys/dev/ath/ath_hal/ar5416/ar5416_spectral.c - copied unchanged from r245223, head/sys/dev/ath/ath_hal/ar5416/ar5416_spectral.c user/attilio/vmcontention/sys/dev/ath/if_ath_spectral.c - copied unchanged from r245223, head/sys/dev/ath/if_ath_spectral.c user/attilio/vmcontention/sys/dev/ath/if_ath_spectral.h - copied unchanged from r245223, head/sys/dev/ath/if_ath_spectral.h user/attilio/vmcontention/tools/build/options/WITHOUT_LZMA_SUPPORT - copied unchanged from r245223, head/tools/build/options/WITHOUT_LZMA_SUPPORT user/attilio/vmcontention/tools/tools/ath/athspectral/ - copied from r245223, head/tools/tools/ath/athspectral/ user/attilio/vmcontention/usr.sbin/bsdconfig/share/script.subr - copied unchanged from r245223, head/usr.sbin/bsdconfig/share/script.subr user/attilio/vmcontention/usr.sbin/bsdconfig/share/variable.subr - copied unchanged from r245223, head/usr.sbin/bsdconfig/share/variable.subr user/attilio/vmcontention/usr.sbin/bsdinstall/partedit/sade.8 - copied unchanged from r245223, head/usr.sbin/bsdinstall/partedit/sade.8 Deleted: user/attilio/vmcontention/contrib/dialog/samples/dft-cancel user/attilio/vmcontention/contrib/dialog/samples/dft-extra user/attilio/vmcontention/contrib/dialog/samples/dft-help user/attilio/vmcontention/contrib/dialog/samples/dft-no user/attilio/vmcontention/contrib/dialog/samples/fselect0 user/attilio/vmcontention/contrib/dialog/samples/with-dquotes user/attilio/vmcontention/contrib/dialog/samples/with-squotes user/attilio/vmcontention/lib/libdisk/ user/attilio/vmcontention/share/examples/cvsup/gnats-supfile user/attilio/vmcontention/sys/dev/xen/evtchn/ user/attilio/vmcontention/sys/dev/xen/xenpci/machine_reboot.c user/attilio/vmcontention/usr.sbin/sade/ Modified: user/attilio/vmcontention/COPYRIGHT user/attilio/vmcontention/LOCKS user/attilio/vmcontention/ObsoleteFiles.inc user/attilio/vmcontention/bin/ln/ln.1 user/attilio/vmcontention/bin/ls/util.c user/attilio/vmcontention/bin/test/test.1 user/attilio/vmcontention/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c user/attilio/vmcontention/contrib/dialog/CHANGES user/attilio/vmcontention/contrib/dialog/VERSION user/attilio/vmcontention/contrib/dialog/aclocal.m4 user/attilio/vmcontention/contrib/dialog/arrows.c user/attilio/vmcontention/contrib/dialog/buttons.c user/attilio/vmcontention/contrib/dialog/calendar.c user/attilio/vmcontention/contrib/dialog/checklist.c user/attilio/vmcontention/contrib/dialog/columns.c user/attilio/vmcontention/contrib/dialog/configure user/attilio/vmcontention/contrib/dialog/configure.in user/attilio/vmcontention/contrib/dialog/dialog.1 user/attilio/vmcontention/contrib/dialog/dialog.3 user/attilio/vmcontention/contrib/dialog/dialog.c user/attilio/vmcontention/contrib/dialog/dialog.h user/attilio/vmcontention/contrib/dialog/dlg_colors.h user/attilio/vmcontention/contrib/dialog/dlg_keys.c user/attilio/vmcontention/contrib/dialog/dlg_keys.h user/attilio/vmcontention/contrib/dialog/editbox.c user/attilio/vmcontention/contrib/dialog/formbox.c user/attilio/vmcontention/contrib/dialog/fselect.c user/attilio/vmcontention/contrib/dialog/guage.c user/attilio/vmcontention/contrib/dialog/headers-sh.in user/attilio/vmcontention/contrib/dialog/inputbox.c user/attilio/vmcontention/contrib/dialog/inputstr.c user/attilio/vmcontention/contrib/dialog/makefile.in user/attilio/vmcontention/contrib/dialog/menubox.c user/attilio/vmcontention/contrib/dialog/mixedform.c user/attilio/vmcontention/contrib/dialog/mixedgauge.c user/attilio/vmcontention/contrib/dialog/msgbox.c user/attilio/vmcontention/contrib/dialog/package/debian/changelog user/attilio/vmcontention/contrib/dialog/package/dialog.spec user/attilio/vmcontention/contrib/dialog/pause.c user/attilio/vmcontention/contrib/dialog/po/cs.po user/attilio/vmcontention/contrib/dialog/po/el.po user/attilio/vmcontention/contrib/dialog/po/hr.po user/attilio/vmcontention/contrib/dialog/po/sr.po user/attilio/vmcontention/contrib/dialog/prgbox.c user/attilio/vmcontention/contrib/dialog/progressbox.c user/attilio/vmcontention/contrib/dialog/rc.c user/attilio/vmcontention/contrib/dialog/samples/copifuncs/admin.funcs user/attilio/vmcontention/contrib/dialog/samples/copifuncs/common.funcs user/attilio/vmcontention/contrib/dialog/samples/copifuncs/copi.funcs user/attilio/vmcontention/contrib/dialog/samples/copifuncs/copi.ifman2 user/attilio/vmcontention/contrib/dialog/samples/copifuncs/copi.ifpoll2 user/attilio/vmcontention/contrib/dialog/samples/copifuncs/copi.ifreq2 user/attilio/vmcontention/contrib/dialog/samples/copifuncs/copi.sendifm1 user/attilio/vmcontention/contrib/dialog/samples/copifuncs/copi.wheel user/attilio/vmcontention/contrib/dialog/samples/copismall user/attilio/vmcontention/contrib/dialog/samples/debian.rc user/attilio/vmcontention/contrib/dialog/samples/dialog.py user/attilio/vmcontention/contrib/dialog/samples/form1 user/attilio/vmcontention/contrib/dialog/samples/inputmenu user/attilio/vmcontention/contrib/dialog/samples/inputmenu-stdout user/attilio/vmcontention/contrib/dialog/samples/inputmenu1 user/attilio/vmcontention/contrib/dialog/samples/inputmenu2 user/attilio/vmcontention/contrib/dialog/samples/inputmenu3 user/attilio/vmcontention/contrib/dialog/samples/inputmenu4 user/attilio/vmcontention/contrib/dialog/samples/killall user/attilio/vmcontention/contrib/dialog/samples/prgbox user/attilio/vmcontention/contrib/dialog/samples/prgbox2 user/attilio/vmcontention/contrib/dialog/samples/report-button user/attilio/vmcontention/contrib/dialog/samples/report-edit user/attilio/vmcontention/contrib/dialog/samples/report-string user/attilio/vmcontention/contrib/dialog/samples/report-tempfile user/attilio/vmcontention/contrib/dialog/samples/report-yesno user/attilio/vmcontention/contrib/dialog/samples/setup-edit user/attilio/vmcontention/contrib/dialog/samples/setup-tempfile user/attilio/vmcontention/contrib/dialog/samples/setup-utf8 user/attilio/vmcontention/contrib/dialog/samples/setup-vars user/attilio/vmcontention/contrib/dialog/samples/slackware.rc user/attilio/vmcontention/contrib/dialog/samples/sourcemage.rc user/attilio/vmcontention/contrib/dialog/samples/suse.rc user/attilio/vmcontention/contrib/dialog/samples/tailboxbg user/attilio/vmcontention/contrib/dialog/samples/tailboxbg1 user/attilio/vmcontention/contrib/dialog/samples/tailboxbg2 user/attilio/vmcontention/contrib/dialog/samples/testdata-8bit user/attilio/vmcontention/contrib/dialog/samples/wheel user/attilio/vmcontention/contrib/dialog/samples/whiptail.rc user/attilio/vmcontention/contrib/dialog/tailbox.c user/attilio/vmcontention/contrib/dialog/textbox.c user/attilio/vmcontention/contrib/dialog/timebox.c user/attilio/vmcontention/contrib/dialog/trace.c user/attilio/vmcontention/contrib/dialog/ui_getc.c user/attilio/vmcontention/contrib/dialog/util.c user/attilio/vmcontention/contrib/dialog/yesno.c user/attilio/vmcontention/contrib/gcc/dwarf2out.c user/attilio/vmcontention/contrib/one-true-awk/FIXES user/attilio/vmcontention/contrib/one-true-awk/main.c user/attilio/vmcontention/contrib/one-true-awk/makefile user/attilio/vmcontention/contrib/one-true-awk/proto.h user/attilio/vmcontention/contrib/one-true-awk/run.c user/attilio/vmcontention/contrib/one-true-awk/tran.c user/attilio/vmcontention/contrib/sendmail/FREEBSD-upgrade user/attilio/vmcontention/contrib/sendmail/LICENSE user/attilio/vmcontention/contrib/sendmail/PGPKEYS user/attilio/vmcontention/contrib/sendmail/RELEASE_NOTES user/attilio/vmcontention/contrib/sendmail/cf/README user/attilio/vmcontention/contrib/sendmail/cf/cf/submit.cf user/attilio/vmcontention/contrib/sendmail/cf/feature/ldap_routing.m4 user/attilio/vmcontention/contrib/sendmail/cf/m4/proto.m4 user/attilio/vmcontention/contrib/sendmail/cf/m4/version.m4 user/attilio/vmcontention/contrib/sendmail/doc/op/op.me user/attilio/vmcontention/contrib/sendmail/include/libmilter/mfapi.h user/attilio/vmcontention/contrib/sendmail/include/sm/clock.h user/attilio/vmcontention/contrib/sendmail/include/sm/tailq.h user/attilio/vmcontention/contrib/sendmail/libmilter/Makefile.m4 user/attilio/vmcontention/contrib/sendmail/libmilter/docs/api.html user/attilio/vmcontention/contrib/sendmail/libmilter/docs/smfi_setsymlist.html user/attilio/vmcontention/contrib/sendmail/libmilter/docs/smfi_settimeout.html user/attilio/vmcontention/contrib/sendmail/libmilter/worker.c user/attilio/vmcontention/contrib/sendmail/src/Makefile.m4 user/attilio/vmcontention/contrib/sendmail/src/TRACEFLAGS user/attilio/vmcontention/contrib/sendmail/src/collect.c user/attilio/vmcontention/contrib/sendmail/src/conf.c user/attilio/vmcontention/contrib/sendmail/src/daemon.c user/attilio/vmcontention/contrib/sendmail/src/deliver.c user/attilio/vmcontention/contrib/sendmail/src/headers.c user/attilio/vmcontention/contrib/sendmail/src/main.c user/attilio/vmcontention/contrib/sendmail/src/map.c user/attilio/vmcontention/contrib/sendmail/src/milter.c user/attilio/vmcontention/contrib/sendmail/src/parseaddr.c user/attilio/vmcontention/contrib/sendmail/src/queue.c user/attilio/vmcontention/contrib/sendmail/src/sasl.c user/attilio/vmcontention/contrib/sendmail/src/savemail.c user/attilio/vmcontention/contrib/sendmail/src/sendmail.h user/attilio/vmcontention/contrib/sendmail/src/srvrsmtp.c user/attilio/vmcontention/contrib/sendmail/src/stab.c user/attilio/vmcontention/contrib/sendmail/src/util.c user/attilio/vmcontention/contrib/sendmail/src/version.c user/attilio/vmcontention/crypto/openssl/crypto/bn/bn_word.c user/attilio/vmcontention/crypto/openssl/crypto/opensslv.h user/attilio/vmcontention/etc/mtree/BSD.var.dist user/attilio/vmcontention/etc/namedb/named.root user/attilio/vmcontention/etc/sendmail/freebsd.mc user/attilio/vmcontention/etc/sendmail/freebsd.submit.mc user/attilio/vmcontention/etc/sendmail/freefall.mc user/attilio/vmcontention/gnu/lib/libdialog/dlg_config.h user/attilio/vmcontention/gnu/usr.bin/binutils/ld/armelf_fbsd.sh user/attilio/vmcontention/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh user/attilio/vmcontention/gnu/usr.bin/dialog/Makefile user/attilio/vmcontention/lib/Makefile user/attilio/vmcontention/lib/csu/amd64/crt1.c user/attilio/vmcontention/lib/csu/arm/crt1.c user/attilio/vmcontention/lib/csu/common/ignore_init.c user/attilio/vmcontention/lib/csu/i386-elf/crt1_c.c user/attilio/vmcontention/lib/csu/mips/crt1.c user/attilio/vmcontention/lib/csu/powerpc/crt1.c user/attilio/vmcontention/lib/csu/powerpc64/crt1.c user/attilio/vmcontention/lib/csu/sparc64/crt1.c user/attilio/vmcontention/lib/libbsnmp/libbsnmp/Makefile user/attilio/vmcontention/lib/libc/arm/softfloat/arm-gcc.h user/attilio/vmcontention/lib/libc/nls/Makefile.inc user/attilio/vmcontention/lib/libedit/map.c user/attilio/vmcontention/lib/libutil/gr_util.c user/attilio/vmcontention/lib/libutil/libutil.h user/attilio/vmcontention/lib/libutil/pw_util.c user/attilio/vmcontention/release/amd64/mkisoimages.sh user/attilio/vmcontention/release/i386/mkisoimages.sh user/attilio/vmcontention/release/ia64/mkisoimages.sh user/attilio/vmcontention/release/pc98/mkisoimages.sh user/attilio/vmcontention/release/powerpc/mkisoimages.sh user/attilio/vmcontention/release/sparc64/mkisoimages.sh user/attilio/vmcontention/sbin/geom/class/journal/geom_journal_ufs.c user/attilio/vmcontention/sbin/geom/class/part/gpart.8 user/attilio/vmcontention/sbin/mount_nullfs/mount_nullfs.c user/attilio/vmcontention/sbin/pflogd/Makefile user/attilio/vmcontention/sbin/route/route.c user/attilio/vmcontention/share/examples/Makefile user/attilio/vmcontention/share/examples/cvsup/README user/attilio/vmcontention/share/examples/cvsup/cvs-supfile user/attilio/vmcontention/share/examples/cvsup/ports-supfile user/attilio/vmcontention/share/examples/cvsup/stable-supfile user/attilio/vmcontention/share/examples/cvsup/standard-supfile user/attilio/vmcontention/share/man/man4/mps.4 user/attilio/vmcontention/share/man/man4/ng_ubt.4 user/attilio/vmcontention/share/man/man4/stf.4 user/attilio/vmcontention/share/man/man4/wbwd.4 user/attilio/vmcontention/share/man/man9/sleep.9 user/attilio/vmcontention/share/misc/committers-ports.dot user/attilio/vmcontention/share/mk/bsd.cpu.mk user/attilio/vmcontention/share/mk/bsd.lib.mk user/attilio/vmcontention/share/mk/bsd.libnames.mk user/attilio/vmcontention/share/mk/bsd.prog.mk user/attilio/vmcontention/sys/amd64/amd64/vm_machdep.c user/attilio/vmcontention/sys/amd64/conf/GENERIC user/attilio/vmcontention/sys/arm/arm/busdma_machdep-v6.c user/attilio/vmcontention/sys/arm/arm/machdep.c user/attilio/vmcontention/sys/arm/arm/pl310.c user/attilio/vmcontention/sys/arm/arm/pmap-v6.c user/attilio/vmcontention/sys/arm/broadcom/bcm2835/bcm2835_fb.c user/attilio/vmcontention/sys/arm/broadcom/bcm2835/bcm2835_machdep.c user/attilio/vmcontention/sys/arm/broadcom/bcm2835/bcm2835_systimer.c user/attilio/vmcontention/sys/arm/conf/BEAGLEBONE user/attilio/vmcontention/sys/arm/include/atomic.h user/attilio/vmcontention/sys/arm/include/machdep.h user/attilio/vmcontention/sys/arm/include/pcpu.h user/attilio/vmcontention/sys/arm/include/pl310.h user/attilio/vmcontention/sys/arm/include/pmap.h user/attilio/vmcontention/sys/arm/ti/cpsw/if_cpsw.c user/attilio/vmcontention/sys/arm/ti/cpsw/if_cpswreg.h user/attilio/vmcontention/sys/arm/ti/cpsw/if_cpswvar.h user/attilio/vmcontention/sys/arm/ti/omap4/omap4_l2cache.c user/attilio/vmcontention/sys/arm/ti/omap4/omap4_smc.h user/attilio/vmcontention/sys/arm/ti/omap4/std.omap4 user/attilio/vmcontention/sys/arm/ti/ti_cpuid.c user/attilio/vmcontention/sys/arm/ti/ti_cpuid.h user/attilio/vmcontention/sys/arm/versatile/versatile_clcd.c user/attilio/vmcontention/sys/boot/common/interp_forth.c user/attilio/vmcontention/sys/boot/fdt/dts/pandaboard.dts user/attilio/vmcontention/sys/boot/userboot/userboot/Makefile user/attilio/vmcontention/sys/boot/userboot/userboot/main.c user/attilio/vmcontention/sys/conf/files user/attilio/vmcontention/sys/conf/options.mips user/attilio/vmcontention/sys/contrib/octeon-sdk/cvmx-app-init.h user/attilio/vmcontention/sys/contrib/octeon-sdk/cvmx-helper-board.c user/attilio/vmcontention/sys/dev/agp/agp_ali.c user/attilio/vmcontention/sys/dev/agp/agp_amd.c user/attilio/vmcontention/sys/dev/agp/agp_amd64.c user/attilio/vmcontention/sys/dev/agp/agp_ati.c user/attilio/vmcontention/sys/dev/agp/agp_intel.c user/attilio/vmcontention/sys/dev/agp/agp_sis.c user/attilio/vmcontention/sys/dev/agp/agp_via.c user/attilio/vmcontention/sys/dev/ahci/ahci.c user/attilio/vmcontention/sys/dev/ata/ata-pci.h user/attilio/vmcontention/sys/dev/ata/chipsets/ata-intel.c user/attilio/vmcontention/sys/dev/ath/ath_dfs/null/dfs_null.c user/attilio/vmcontention/sys/dev/ath/ath_hal/ah.c user/attilio/vmcontention/sys/dev/ath/ath_hal/ah.h user/attilio/vmcontention/sys/dev/ath/ath_hal/ah_internal.h user/attilio/vmcontention/sys/dev/ath/ath_hal/ar5416/ar5416.h user/attilio/vmcontention/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c user/attilio/vmcontention/sys/dev/ath/ath_hal/ar5416/ar5416phy.h user/attilio/vmcontention/sys/dev/ath/ath_hal/ar5416/ar5416reg.h user/attilio/vmcontention/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c user/attilio/vmcontention/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c user/attilio/vmcontention/sys/dev/ath/ath_hal/ar9002/ar9287_attach.c user/attilio/vmcontention/sys/dev/ath/if_ath.c user/attilio/vmcontention/sys/dev/ath/if_ath_rx.c user/attilio/vmcontention/sys/dev/ath/if_athdfs.h user/attilio/vmcontention/sys/dev/ath/if_athioctl.h user/attilio/vmcontention/sys/dev/ath/if_athvar.h user/attilio/vmcontention/sys/dev/fdt/fdtbus.c user/attilio/vmcontention/sys/dev/ichsmb/ichsmb_pci.c user/attilio/vmcontention/sys/dev/ichwd/ichwd.c user/attilio/vmcontention/sys/dev/ichwd/ichwd.h user/attilio/vmcontention/sys/dev/nvme/nvme_test.c user/attilio/vmcontention/sys/dev/pci/pci.c user/attilio/vmcontention/sys/dev/pci/pci_user.c user/attilio/vmcontention/sys/dev/sound/pci/hda/hdac.c user/attilio/vmcontention/sys/dev/sound/pci/hda/hdac.h user/attilio/vmcontention/sys/dev/usb/controller/xhci.c user/attilio/vmcontention/sys/dev/usb/quirk/usb_quirk.c user/attilio/vmcontention/sys/dev/usb/serial/u3g.c user/attilio/vmcontention/sys/dev/usb/usbdevs user/attilio/vmcontention/sys/dev/usb/wlan/if_run.c user/attilio/vmcontention/sys/dev/wbwd/wbwd.c user/attilio/vmcontention/sys/dev/xen/control/control.c user/attilio/vmcontention/sys/dev/xen/netfront/netfront.c user/attilio/vmcontention/sys/fs/ext2fs/ext2_dinode.h user/attilio/vmcontention/sys/fs/fuse/fuse_io.c user/attilio/vmcontention/sys/fs/nandfs/nandfs_segment.c user/attilio/vmcontention/sys/fs/nullfs/null.h user/attilio/vmcontention/sys/fs/nullfs/null_subr.c user/attilio/vmcontention/sys/fs/nullfs/null_vfsops.c user/attilio/vmcontention/sys/fs/nullfs/null_vnops.c user/attilio/vmcontention/sys/fs/tmpfs/tmpfs.h user/attilio/vmcontention/sys/fs/tmpfs/tmpfs_subr.c user/attilio/vmcontention/sys/fs/tmpfs/tmpfs_vfsops.c user/attilio/vmcontention/sys/fs/tmpfs/tmpfs_vnops.c user/attilio/vmcontention/sys/geom/geom_io.c user/attilio/vmcontention/sys/i386/conf/GENERIC user/attilio/vmcontention/sys/i386/xen/xen_machdep.c user/attilio/vmcontention/sys/ia64/conf/GENERIC user/attilio/vmcontention/sys/kern/kern_exit.c user/attilio/vmcontention/sys/kern/kern_lock.c user/attilio/vmcontention/sys/kern/kern_synch.c user/attilio/vmcontention/sys/kern/subr_param.c user/attilio/vmcontention/sys/kern/subr_syscall.c user/attilio/vmcontention/sys/kern/vfs_mount.c user/attilio/vmcontention/sys/kern/vfs_subr.c user/attilio/vmcontention/sys/kern/vfs_vnops.c user/attilio/vmcontention/sys/mips/atheros/ar71xx_pci.c user/attilio/vmcontention/sys/mips/beri/beri_machdep.c user/attilio/vmcontention/sys/mips/conf/OCTEON1 user/attilio/vmcontention/sys/modules/ath/Makefile user/attilio/vmcontention/sys/net/if_pfsync.h user/attilio/vmcontention/sys/net/if_stf.c user/attilio/vmcontention/sys/net/zlib.c user/attilio/vmcontention/sys/net/zlib.h user/attilio/vmcontention/sys/net80211/ieee80211_hostap.c user/attilio/vmcontention/sys/net80211/ieee80211_hwmp.c user/attilio/vmcontention/sys/net80211/ieee80211_radiotap.h user/attilio/vmcontention/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c user/attilio/vmcontention/sys/netinet/in.c user/attilio/vmcontention/sys/netinet/sctp_pcb.c user/attilio/vmcontention/sys/netinet/sctp_usrreq.c user/attilio/vmcontention/sys/netinet/sctputil.c user/attilio/vmcontention/sys/netinet6/in6.c user/attilio/vmcontention/sys/netinet6/scope6.c user/attilio/vmcontention/sys/netpfil/pf/if_pflog.c user/attilio/vmcontention/sys/netpfil/pf/if_pfsync.c user/attilio/vmcontention/sys/netpfil/pf/pf.c user/attilio/vmcontention/sys/netpfil/pf/pf_if.c user/attilio/vmcontention/sys/netpfil/pf/pf_ioctl.c user/attilio/vmcontention/sys/netpfil/pf/pf_lb.c user/attilio/vmcontention/sys/netpfil/pf/pf_norm.c user/attilio/vmcontention/sys/netpfil/pf/pf_osfp.c user/attilio/vmcontention/sys/netpfil/pf/pf_ruleset.c user/attilio/vmcontention/sys/netpfil/pf/pf_table.c user/attilio/vmcontention/sys/pc98/conf/GENERIC user/attilio/vmcontention/sys/powerpc/conf/GENERIC user/attilio/vmcontention/sys/powerpc/conf/GENERIC64 user/attilio/vmcontention/sys/sparc64/conf/GENERIC user/attilio/vmcontention/sys/sparc64/sparc64/interrupt.S user/attilio/vmcontention/sys/sys/buf_ring.h user/attilio/vmcontention/sys/sys/copyright.h user/attilio/vmcontention/sys/sys/mbuf.h user/attilio/vmcontention/sys/sys/mount.h user/attilio/vmcontention/sys/sys/vnode.h user/attilio/vmcontention/sys/tools/vnode_if.awk user/attilio/vmcontention/sys/ufs/ffs/ffs_snapshot.c user/attilio/vmcontention/sys/x86/include/specialreg.h user/attilio/vmcontention/tools/build/make_check/Makefile user/attilio/vmcontention/tools/tools/ath/Makefile user/attilio/vmcontention/tools/tools/ath/arcode/arcode.c user/attilio/vmcontention/tools/tools/ath/ath_prom_read/ath_prom_read.c user/attilio/vmcontention/tools/tools/ath/athdebug/athdebug.c user/attilio/vmcontention/tools/tools/ath/athdecode/main.c user/attilio/vmcontention/tools/tools/ath/athkey/athkey.c user/attilio/vmcontention/tools/tools/ath/athprom/athprom.c user/attilio/vmcontention/tools/tools/ath/athratestats/main.c user/attilio/vmcontention/tools/tools/ath/athstats/Makefile user/attilio/vmcontention/tools/tools/ath/athstats/athstats.c user/attilio/vmcontention/tools/tools/ath/athsurvey/athsurvey.c user/attilio/vmcontention/tools/tools/netrate/netsend/netsend.c user/attilio/vmcontention/usr.bin/apply/apply.c user/attilio/vmcontention/usr.bin/dc/bcode.c user/attilio/vmcontention/usr.bin/dc/bcode.h user/attilio/vmcontention/usr.bin/dc/inout.c user/attilio/vmcontention/usr.bin/grep/Makefile user/attilio/vmcontention/usr.bin/grep/file.c user/attilio/vmcontention/usr.bin/grep/grep.c user/attilio/vmcontention/usr.bin/grep/regex/tre-fastmatch.c user/attilio/vmcontention/usr.bin/m4/Makefile user/attilio/vmcontention/usr.bin/tail/read.c user/attilio/vmcontention/usr.bin/ul/ul.c user/attilio/vmcontention/usr.bin/xargs/strnsubst.c user/attilio/vmcontention/usr.sbin/Makefile.amd64 user/attilio/vmcontention/usr.sbin/Makefile.i386 user/attilio/vmcontention/usr.sbin/Makefile.sparc64 user/attilio/vmcontention/usr.sbin/bsdconfig/USAGE user/attilio/vmcontention/usr.sbin/bsdconfig/bsdconfig user/attilio/vmcontention/usr.sbin/bsdconfig/bsdconfig.8 user/attilio/vmcontention/usr.sbin/bsdconfig/include/messages.subr user/attilio/vmcontention/usr.sbin/bsdconfig/networking/share/hostname.subr user/attilio/vmcontention/usr.sbin/bsdconfig/networking/share/ipaddr.subr user/attilio/vmcontention/usr.sbin/bsdconfig/share/Makefile user/attilio/vmcontention/usr.sbin/bsdconfig/share/common.subr user/attilio/vmcontention/usr.sbin/bsdconfig/share/dialog.subr user/attilio/vmcontention/usr.sbin/bsdconfig/startup/share/rcvar.subr user/attilio/vmcontention/usr.sbin/bsdinstall/partedit/Makefile user/attilio/vmcontention/usr.sbin/bsdinstall/partedit/partedit.c user/attilio/vmcontention/usr.sbin/daemon/daemon.c user/attilio/vmcontention/usr.sbin/gssd/Makefile user/attilio/vmcontention/usr.sbin/gssd/gssd.8 user/attilio/vmcontention/usr.sbin/gssd/gssd.c user/attilio/vmcontention/usr.sbin/ifmcstat/ifmcstat.c user/attilio/vmcontention/usr.sbin/newsyslog/newsyslog.8 user/attilio/vmcontention/usr.sbin/newsyslog/newsyslog.c user/attilio/vmcontention/usr.sbin/pw/pw_group.c user/attilio/vmcontention/usr.sbin/pw/pw_user.c user/attilio/vmcontention/usr.sbin/pw/pw_vpw.c user/attilio/vmcontention/usr.sbin/pw/pwupd.c Directory Properties: user/attilio/vmcontention/ (props changed) user/attilio/vmcontention/cddl/contrib/opensolaris/ (props changed) user/attilio/vmcontention/contrib/dialog/ (props changed) user/attilio/vmcontention/contrib/gcc/ (props changed) user/attilio/vmcontention/contrib/one-true-awk/ (props changed) user/attilio/vmcontention/contrib/sendmail/ (props changed) user/attilio/vmcontention/crypto/openssl/ (props changed) user/attilio/vmcontention/gnu/lib/ (props changed) user/attilio/vmcontention/gnu/usr.bin/binutils/ (props changed) user/attilio/vmcontention/lib/libc/ (props changed) user/attilio/vmcontention/lib/libutil/ (props changed) user/attilio/vmcontention/sbin/ (props changed) user/attilio/vmcontention/share/man/man4/ (props changed) user/attilio/vmcontention/sys/ (props changed) user/attilio/vmcontention/sys/boot/ (props changed) user/attilio/vmcontention/sys/conf/ (props changed) user/attilio/vmcontention/sys/contrib/octeon-sdk/ (props changed) user/attilio/vmcontention/tools/regression/bin/sh/errors/write-error1.0 (props changed) Modified: user/attilio/vmcontention/COPYRIGHT ============================================================================== --- user/attilio/vmcontention/COPYRIGHT Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/COPYRIGHT Wed Jan 9 11:58:47 2013 (r245224) @@ -4,7 +4,7 @@ The compilation of software known as FreeBSD is distributed under the following terms: -Copyright (c) 1992-2012 The FreeBSD Project. All rights reserved. +Copyright (c) 1992-2013 The FreeBSD Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions Modified: user/attilio/vmcontention/LOCKS ============================================================================== --- user/attilio/vmcontention/LOCKS Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/LOCKS Wed Jan 9 11:58:47 2013 (r245224) @@ -11,3 +11,4 @@ releng/4.* Requires Security Officer app releng/5.* Requires Security Officer approval. releng/6.* Requires Security Officer approval. releng/7.* Requires Security Officer approval. +releng/8.* Requires Security Officer approval. Modified: user/attilio/vmcontention/ObsoleteFiles.inc ============================================================================== --- user/attilio/vmcontention/ObsoleteFiles.inc Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/ObsoleteFiles.inc Wed Jan 9 11:58:47 2013 (r245224) @@ -38,6 +38,12 @@ # xargs -n1 | sort | uniq -d; # done +# 20121230: libdisk removed +OLD_FILES+=usr/share/man/man3/libdisk.3.gz usr/include/libdisk.h +OLD_FILES+=usr/lib/libdisk.a usr/lib32/libdisk.a +# 20121230: remove wrongly created directories for auditdistd +OLD_DIRS+=var/dist +OLD_DIRS+=var/remote # 20121114: zpool-features manual page moved from section 5 to 7 OLD_FILES+=usr/share/man/man5/zpool-features.5.gz # 20121022: remove harp, hfa and idt man page Modified: user/attilio/vmcontention/bin/ln/ln.1 ============================================================================== --- user/attilio/vmcontention/bin/ln/ln.1 Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/bin/ln/ln.1 Wed Jan 9 11:58:47 2013 (r245224) @@ -291,7 +291,7 @@ implementations. .Pp The .Fl F -option is +option is a .Fx extension and should not be used in portable scripts. .Sh SEE ALSO Modified: user/attilio/vmcontention/bin/ls/util.c ============================================================================== --- user/attilio/vmcontention/bin/ls/util.c Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/bin/ls/util.c Wed Jan 9 11:58:47 2013 (r245224) @@ -184,7 +184,10 @@ prn_octal(const char *s) for (i = 0; i < (int)clen; i++) putchar((unsigned char)s[i]); len += wcwidth(wc); - } else if (goodchar && f_octal_escape && wc >= 0 && + } else if (goodchar && f_octal_escape && +#if WCHAR_MIN < 0 + wc >= 0 && +#endif wc <= (wchar_t)UCHAR_MAX && (p = strchr(esc, (char)wc)) != NULL) { putchar('\\'); Modified: user/attilio/vmcontention/bin/test/test.1 ============================================================================== --- user/attilio/vmcontention/bin/test/test.1 Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/bin/test/test.1 Wed Jan 9 11:58:47 2013 (r245224) @@ -32,7 +32,7 @@ .\" @(#)test.1 8.1 (Berkeley) 5/31/93 .\" $FreeBSD$ .\" -.Dd September 10, 2010 +.Dd December 27, 2012 .Dt TEST 1 .Os .Sh NAME @@ -331,6 +331,13 @@ missing. .It >1 An error occurred. .El +.Sh COMPATIBILITY +For compatibility with some other implementations, +the +.Cm = +primary can be substituted with +.Cm == +with the same meaning. .Sh SEE ALSO .Xr builtin 1 , .Xr expr 1 , Modified: user/attilio/vmcontention/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Wed Jan 9 11:58:47 2013 (r245224) @@ -906,10 +906,11 @@ zpool_do_create(int argc, char **argv) /* * Check the validity of the mountpoint and direct the user to use the * '-m' mountpoint option if it looks like its in use. + * Ignore the checks if the '-f' option is given. */ - if (mountpoint == NULL || + if (!force && (mountpoint == NULL || (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) != 0 && - strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) != 0)) { + strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) != 0))) { char buf[MAXPATHLEN]; DIR *dirp; Modified: user/attilio/vmcontention/contrib/dialog/CHANGES ============================================================================== --- user/attilio/vmcontention/contrib/dialog/CHANGES Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/contrib/dialog/CHANGES Wed Jan 9 11:58:47 2013 (r245224) @@ -1,172 +1,9 @@ --- $Id: CHANGES,v 1.419 2012/07/06 18:18:48 tom Exp $ +-- $Id: CHANGES,v 1.360 2011/07/07 23:35:10 tom Exp $ -- Thomas E. Dickey This version of dialog was originally from a Debian snapshot. I've done this to it: -2012/07/06 - + modify samples/setup-tempfile to work with Tru64's shell. - + modify inputmenu sample scripts to make them more portable: - + use "id" rather than "$GROUPS", use sed to work with Solaris. - + use sed to split-up the rename results to work with HPUX. - + fix regression in msgbox (ArchLinux #30574) - -2012/07/03 - + modify prgbox widget to work with --extra-button, etc. - + add case values to several widgets to allow for mouse-clicks with - "--extra-button" and "--help-button" additions. - + correct timebox widget's exit code for "--extra-button" when handing - the "enter" key. - + modify msgbox widget to honor "--extra-button". - + corrected processing of "--trace" option, which did not update the - index into command-line to point past its value. - + add a check in dialog program for valid characters used in option, - e.g., to generate an error if a script attempts to add option value - using "=" rather than with whitespace. - + add new command-line option --default-button and library function - dlg_default_button() to retrieve the value set by the option - to provide a way to set the default button directly rather than - by combining --nook, etc. (patch by Zoltan Kelemen). - + amend include of unctrl.h to apply only to the case where curses.h - is included, to avoid conflict of ncurses' unctrl.h with a system - implementation (report by Martin Roedlach) - + add limit-check to dlg_toupper() in non-wide curses mode to work - when non-character values such as arrow-key codes are passed to - it (patch by Zoltan Kelemen). - + override timeout value, e.g., as set via --timeout command-line - option in pause widget because that interferes with pause's behavior - (report by Jan Spitalnik). - + modify samples/inputmenu* to allow ":" in renamed text (report by - Andreas Stoewing). - + modify double-quoting to make it more consistent, i.e., checklist - output is quoted only when needed. This fixes the case where - single-quotes were used whether or not needed, but also modifies - older checklist behavior for double-quoting which always added those - (Debian #663664). - + correct exit-code used in inputmenu for "rename" button (Debian - #673041, forwarded from Ubuntu #333909, patch by Lebedev Vadim). - + update el.po and hr.po from - http://translationproject.org/latest/dialog/ - + use checkbashisms to clean up sample scripts. - -2012/02/15 - + modify menubox.c to use the same improvement as in checklist.c - + improve auto width computation for checklist widget by using - dlg_calc_list_width as in the non-auto case (Edho Arief). - + eliminate some bashisms in the sample scripts (Pedro Giffuni). - + makefile fixes from FreeBSD ports (Li-Wen Hsu): - + make --with-package option of configure script work. - + get LIBTOOL_VERSION from configure script, needed by - ${LIBTOOL_VERSION} in LIBTOOL_CREATE (LIB_CREATE in configure and - aclocal.m4) - + update cs.po and sr.po from - http://translationproject.org/latest/dialog/ - + updated configure script macros, improving CF_XOPEN_SOURCE among - other fixes. - -2011/10/20 - + fix --analyze warnings for clang versions 2.8, 2.9. - + add configure check for lint program. - + add check in dlg_getc() in case its window is freed as a side effect - of removing callbacks. - + fix logic in freeing subwindows (report by xDog Walker). - + fix a regression in logic distinguishing between inputmenu and menu - widgets (report by xDog Walker). - + minor fixes to library manpage. - -2011/10/18 - + modify header-sh.in to work around limit on sed script length on - HPUX. - + add a special case of parameter parsing for "--trace" to the - initialization done before calling init_dialog(), to allow users to - capture the initial state of the parameter list before any options - are processed and removed. This is only done if "--trace" is the - first option, otherwise it is handled in the common options as before - (report by xDog Walker). - + modify samples/testdata-8bit, discarding $1 from the parameter list - if it was used, so that the source'ing scripts can consistently use - "$@" to insert parameters before the widget, e.g., as an alternative - to using $DIALOGOPTS (report by xDog Walker). - + modify treatment of function pointers in menubox.c, make - dlg_renamed_menutext() and dlg_dummy_menutext() visible to library - users (request by xDog Walker). - + add dlg_count_real_columns(), use to modify centering for "--hline" - text to account for "\Z"s (report by xDog Walker). - + improve check in dlg_draw_arrows2() for conflict between the window - title and up-arrow marker to take into account that the given window - may not be the top-level window of the widget. - + change width of page up/down mouse areas in fselect panes to use the - full width of the panes rather than only the portion from the left - margin to the up/down arrow. - + add/use dlg_draw_box2() and dlg_draw_bottom_box2() to use the - secondary borders. - + modify rc-file read/write to accept/generate color values that refer - to previously-processed items in the color table. This reduces the - number of distinct colors that must be specified to set up a color - scheme. - + add color table entries for secondary borders, i.e., the ones that - are normally drawn with the dialog's text-colors (Debian #641168). - + modify fselect.c to scan the current directory if the input field - happens to be empty (Debian #640905). - + repeated the discussion of environment variables that can override - the exit-status values in the manpage's return-codes section - (Debian #642105). - + add an example to the manpage showing how to override the form - widget's keys used for field/button traversal (Debian #642108). - + modify call to dlg_register_window() in formbox.c so that the editing - bindings are attached to the form sub-window rather than the - top-level dialog window. Also change the name by which the editing - bindings are bound for editbox.c, fselect.c and inputbox.c, so that - the editing and navigation bindings can be different. - + correct logic in dlg_lookup_key() so that it matches the widget name - before using a binding from .dialogrc, allowing the inner/outer - windows of form and other editing widgets to have different bindings. - + modify dlg_register_window() to call dlg_dump_window_keys() after - its updates, via the --trace output, to supplement the manpage - description of key bindings (Debian #642108). - + add DLGK_FORM_PREV and DLGK_FORM_NEXT key-bindings to form.c, to - allow binding a single key to traverse both form-fields and buttons - (Debian #642108). - + modify dlg_parse_rc() to check for error return from - dlg_parse_bindkey(). - + add function dlg_dump_window_keys(), to help with debugging widgets. - + add CR, LF, TAB, FF and ESC to table of curses names to help make - key bindings more readable. - + update table of dialog key-names so that helpfile and trace are - dumped properly. - + correct dlg_dump_keys(), which was showing only the first item in - the matched binding table. - + save/restore window current position in dlg_update_mixedgauge(). - + pass return-code from pause_for_ok() from dlg_progressbox() when - pauseopt is set, rather than only DLG_OK. - + call setlocale() in init_dialog() rather than relying on on-demand - use within inputstr.c, since there are paths in textbox widget which - do not exercise the latter (report by xDog Walker). - + fix some places where checks for "\Z" were done without also checking - dialog_vars.colors (report by Moray Henderson). - + correct logic for DIALOGOPTS parsing so that the parse happens only - once unless memory leak checking is enabled (report by xDog Walker). - + remove an incorrect free() call in dlg_free_gauge() (report by xDog - Walker). - + modify dlg_trace_win() to log wide-characters (report by xDog Walker). - + make traces shorter by skipping repeated ERR's, but showing the - number skipped (report by xDog Walker). - + improve description in manpage to distinguish program box and - progress box from tailboxes (adapted from email by xDog Walker). - + modify dlg_trace_win() so that it looks for the topmost window in a - dialog. Because subwindows share space with the top window, tracing - the latter shows the whole widget (report by xDog Walker). - + expand tracing so that each window is traced before soliciting input, - making the ^T feature to print a window on demand partly redundant - (suggested by xDog Walker). - + cosmetic change in dialog.h to avoid "*/*" strings from comments next - to "*" (report by xDog Walker). - + ensure result from dlg_align_columns() has trailing null on each - string. Analysis was hindered by libc6's continuance of libc5's - early-1990s misfeature of clearing the result from malloc, noting - that libc6's documentation incorrectly claims that it does not do - this (report by xDog Walker). - 2011/07/07 + modify util.c to work better with old versions of ncurses: + suppress use of wchgat() before fix in 20060715 which is needed @@ -250,7 +87,7 @@ to it: + CF_XOPEN_SOURCE, workaround for cygwin to get ncurses' configure script to define _XOPEN_SOURCE_EXTENDED (cygwin's features.h doesn't do anything, so it needs a crutch). - + update config.guess, config.sub + + updated config.guess, config.sub 2011/03/02 + add --prgbox and --programbox (adapted from patch by David Boyd). @@ -318,7 +155,7 @@ to it: CF_ADD_LIBDIR for the curses-directory here, from CF_NCURSES_CPPFLAGS and CF_NCURSES_LDFLAGS, so it will work even with the default checking, e.g., no --with-ncurses, etc. - + update config.guess, config.sub + + updated config.guess, config.sub 2010/04/28 + several improvements to configure script: @@ -413,7 +250,7 @@ to it: libutf8 and libiconv. + update da.po, ru.po from http://translationproject.org/latest/dialog/ - + update config.guess, config.sub + + updated config.guess, config.sub 2008/08/19 + amend changes to quoting; by default, the checklist widget quotes its @@ -496,7 +333,7 @@ to it: ESC to be returned, quitting dialog (report by Reiner Huober). + add extern "C" declarations to dlg_keys.h so the corresponding function declarations are exported to C++ as C symbols. - + update config.guess, config.sub + + updated config.guess, config.sub 2007/06/04 + fix a memory leak in editbox.c @@ -599,7 +436,7 @@ to it: CF_CURSES_LIBS, CF_INCLUDE_DIRS, CF_LARGEFILE, CF_MAKEFLAGS, CF_PATH_SYNTAX, CF_SUBDIR_PATH, CF_SUBST, CF_WITH_DBMALLOC, CF_WITH_DMALLOC, CF_WITH_LIBTOOL and CF_XOPEN_SOURCE. - + update config.guess, config.sub + + updated config.guess, config.sub > adapted fixes from SuSE package (Werner Fink): + add some limit-checks in dlg_draw_shadow(). + make shadows resizable, using new dlg_move_window() in msgbox.c Modified: user/attilio/vmcontention/contrib/dialog/VERSION ============================================================================== --- user/attilio/vmcontention/contrib/dialog/VERSION Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/contrib/dialog/VERSION Wed Jan 9 11:58:47 2013 (r245224) @@ -1 +1 @@ -10:4:0 1.1 20120706 +10:0:0 1.1 20110707 Modified: user/attilio/vmcontention/contrib/dialog/aclocal.m4 ============================================================================== --- user/attilio/vmcontention/contrib/dialog/aclocal.m4 Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/contrib/dialog/aclocal.m4 Wed Jan 9 11:58:47 2013 (r245224) @@ -1,7 +1,7 @@ dnl macros used for DIALOG configure script -dnl $Id: aclocal.m4,v 1.87 2012/02/16 02:11:26 tom Exp $ +dnl $Id: aclocal.m4,v 1.82 2011/06/28 22:48:31 tom Exp $ dnl --------------------------------------------------------------------------- -dnl Copyright 1999-2011,2012 -- Thomas E. Dickey +dnl Copyright 1999-2010,2011 -- Thomas E. Dickey dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the @@ -592,31 +592,6 @@ changequote([,])dnl AC_SUBST(GENCAT) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_ACVERSION_CHECK version: 2 updated: 2011/05/08 11:22:03 -dnl ------------------ -dnl Conditionally generate script according to whether we're using a given autoconf. -dnl -dnl $1 = version to compare against -dnl $2 = code to use if AC_ACVERSION is at least as high as $1. -dnl $3 = code to use if AC_ACVERSION is older than $1. -define(CF_ACVERSION_CHECK, -[ -ifdef([m4_version_compare], -[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])], -[CF_ACVERSION_COMPARE( -AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), -AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl -dnl --------------------------------------------------------------------------- -dnl CF_ACVERSION_COMPARE version: 2 updated: 2011/04/14 20:56:50 -dnl -------------------- -dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1, -dnl MAJOR2, MINOR2, TERNARY2, -dnl PRINTABLE2, not FOUND, FOUND) -define(CF_ACVERSION_COMPARE, -[ifelse(builtin([eval], [$2 < $5]), 1, -[ifelse([$8], , ,[$8])], -[ifelse([$9], , ,[$9])])])dnl -dnl --------------------------------------------------------------------------- dnl CF_AC_PREREQ version: 2 updated: 1997/09/06 13:24:56 dnl ------------ dnl Conditionally generate script according to whether we're using the release @@ -1252,7 +1227,7 @@ fi AC_CHECK_HEADERS($cf_cv_ncurses_header) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_CURSES_LIBS version: 35 updated: 2011/08/09 21:06:37 +dnl CF_CURSES_LIBS version: 34 updated: 2011/04/09 14:51:08 dnl -------------- dnl Look for the curses libraries. Older curses implementations may require dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first. @@ -1332,7 +1307,7 @@ if test ".$ac_cv_func_initscr" != .yes ; # Check for library containing tgoto. Do this before curses library # because it may be needed to link the test-case for initscr. AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[ - for cf_term_lib in $cf_check_list otermcap termcap termlib unknown + for cf_term_lib in $cf_check_list termcap termlib unknown do AC_CHECK_LIB($cf_term_lib,tgoto,[break]) done @@ -1558,30 +1533,6 @@ fi test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_CURSES_WGETPARENT version: 2 updated: 2011/10/17 20:12:04 -dnl -------------------- -dnl Check for curses support for directly determining the parent of a given -dnl window. Some implementations make this difficult, so we provide for -dnl defining an application-specific function that gives this functionality. -dnl -dnl $1 = name of function to use if the feature is missing -AC_DEFUN([CF_CURSES_WGETPARENT],[ -CF_CURSES_FUNCS(wgetparent) -if test "x$cf_cv_func_wgetparent" != xyes -then - AC_MSG_CHECKING(if WINDOW has _parent member) - AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>], - [WINDOW *p = stdscr->_parent], - [cf_window__parent=yes], - [cf_window__parent=no]) - AC_MSG_RESULT($cf_window__parent) - if test "$cf_window__parent" = yes - then - AC_DEFINE(HAVE_WINDOW__PARENT) - fi -fi -])dnl -dnl --------------------------------------------------------------------------- dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52 dnl ---------- dnl "dirname" is not portable, so we fake it with a shell script. @@ -2386,7 +2337,7 @@ ifdef([AC_FUNC_FSEEKO],[ ]) ]) dnl --------------------------------------------------------------------------- -dnl CF_LD_RPATH_OPT version: 5 updated: 2011/07/17 14:48:41 +dnl CF_LD_RPATH_OPT version: 4 updated: 2011/06/04 20:09:13 dnl --------------- dnl For the given system and compiler, find the compiler flags to pass to the dnl loader to use the "rpath" feature. @@ -2410,7 +2361,7 @@ linux*|gnu*|k*bsd*-gnu) #(vi openbsd[[2-9]].*|mirbsd*) #(vi LD_RPATH_OPT="-Wl,-rpath," ;; -dragonfly*|freebsd*) #(vi +freebsd*) #(vi LD_RPATH_OPT="-rpath " ;; netbsd*) #(vi @@ -2469,11 +2420,11 @@ CF_SUBDIR_PATH($1,$2,lib) $1="$cf_library_path_list [$]$1" ])dnl dnl --------------------------------------------------------------------------- -dnl CF_LIB_PREFIX version: 9 updated: 2012/01/21 19:28:10 +dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16 dnl ------------- dnl Compute the library-prefix for the given host system dnl $1 = variable to set -define([CF_LIB_PREFIX], +AC_DEFUN([CF_LIB_PREFIX], [ case $cf_cv_system_name in #(vi OS/2*|os2*) #(vi @@ -2694,7 +2645,7 @@ printf("old\n"); ,[$1=no]) ])dnl dnl --------------------------------------------------------------------------- -dnl CF_NCURSES_CONFIG version: 9 updated: 2011/11/26 15:42:05 +dnl CF_NCURSES_CONFIG version: 8 updated: 2010/07/08 05:17:30 dnl ----------------- dnl Tie together the configure-script macros for ncurses. dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis. @@ -2706,10 +2657,7 @@ AC_DEFUN([CF_NCURSES_CONFIG], cf_ncuconfig_root=ifelse($1,,ncurses,$1) echo "Looking for ${cf_ncuconfig_root}-config" - -CF_ACVERSION_CHECK(2.52, - [AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)], - [AC_PATH_PROGS(NCURSES_CONFIG, ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)]) +AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none) if test "$NCURSES_CONFIG" != none ; then @@ -3223,14 +3171,6 @@ AC_SUBST(PROG_EXT) test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT") ])dnl dnl --------------------------------------------------------------------------- -dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14 -dnl ------------ -AC_DEFUN([CF_PROG_LINT], -[ -AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint) -AC_SUBST(LINT_OPTS) -])dnl -dnl --------------------------------------------------------------------------- dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50 dnl ---------------- dnl Remove all -U and -D options that refer to the given symbol from a list @@ -3478,45 +3418,6 @@ ncursesw/term.h) esac ])dnl dnl --------------------------------------------------------------------------- -dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50 -dnl ------------------- -dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we -dnl can define it successfully. -AC_DEFUN([CF_TRY_XOPEN_SOURCE],[ -AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[ - AC_TRY_COMPILE([ -#include -#include -#include -],[ -#ifndef _XOPEN_SOURCE -make an error -#endif], - [cf_cv_xopen_source=no], - [cf_save="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" - AC_TRY_COMPILE([ -#include -#include -#include -],[ -#ifdef _XOPEN_SOURCE -make an error -#endif], - [cf_cv_xopen_source=no], - [cf_cv_xopen_source=$cf_XOPEN_SOURCE]) - CPPFLAGS="$cf_save" - ]) -]) - -if test "$cf_cv_xopen_source" != no ; then - CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE) - CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE) - cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" - CF_ADD_CFLAGS($cf_temp_xopen_source) -fi -]) -dnl --------------------------------------------------------------------------- dnl CF_UNION_WAIT version: 5 updated: 1997/11/23 14:49:44 dnl ------------- dnl Check to see if the BSD-style union wait is declared. Some platforms may @@ -3779,7 +3680,7 @@ if test "$with_dmalloc" = yes ; then fi ])dnl dnl --------------------------------------------------------------------------- -dnl CF_WITH_LIBTOOL version: 28 updated: 2011/07/02 15:40:32 +dnl CF_WITH_LIBTOOL version: 27 updated: 2011/06/28 18:45:38 dnl --------------- dnl Provide a configure option to incorporate libtool. Define several useful dnl symbols for the makefile rules. @@ -3880,7 +3781,7 @@ ifdef([AC_PROG_LIBTOOL],[ # special hack to add -no-undefined (which libtool should do for itself) LT_UNDEF= case "$cf_cv_system_name" in #(vi - cygwin*|mingw32*|uwin*|aix[[4-7]]) #(vi + cygwin*|mingw32*|uwin*|aix[[456]]) #(vi LT_UNDEF=-no-undefined ;; esac @@ -4049,7 +3950,7 @@ AC_TRY_LINK([ test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED" ])dnl dnl --------------------------------------------------------------------------- -dnl CF_XOPEN_SOURCE version: 42 updated: 2012/01/07 08:26:49 +dnl CF_XOPEN_SOURCE version: 35 updated: 2011/02/20 20:37:37 dnl --------------- dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions, dnl or adapt to the vendor's definitions to get equivalent functionality, @@ -4065,7 +3966,7 @@ cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[ cf_xopen_source= case $host_os in #(vi -aix[[4-7]]*) #(vi +aix[[456]]*) #(vi cf_xopen_source="-D_ALL_SOURCE" ;; cygwin) #(vi @@ -4076,7 +3977,6 @@ darwin[[0-8]].*) #(vi ;; darwin*) #(vi cf_xopen_source="-D_DARWIN_C_SOURCE" - cf_XOPEN_SOURCE= ;; freebsd*|dragonfly*) #(vi # 5.x headers associate @@ -4094,23 +3994,15 @@ hpux*) #(vi ;; irix[[56]].*) #(vi cf_xopen_source="-D_SGI_SOURCE" - cf_XOPEN_SOURCE= ;; linux*|gnu*|mint*|k*bsd*-gnu) #(vi CF_GNU_SOURCE ;; mirbsd*) #(vi - # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks and other headers which use u_int / u_short types - cf_XOPEN_SOURCE= - CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) + # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks ;; netbsd*) #(vi - cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw - ;; -openbsd[[4-9]]*) #(vi - # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw - cf_xopen_source="-D_BSD_SOURCE" - cf_XOPEN_SOURCE=600 + # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw ;; openbsd*) #(vi # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw @@ -4124,46 +4016,42 @@ nto-qnx*) #(vi sco*) #(vi # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer ;; -solaris2.*) #(vi +solaris2.1[[0-9]]) #(vi + cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + ;; +solaris2.[[1-9]]) #(vi cf_xopen_source="-D__EXTENSIONS__" ;; *) - CF_TRY_XOPEN_SOURCE - CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) - ;; -esac - -if test -n "$cf_xopen_source" ; then - CF_ADD_CFLAGS($cf_xopen_source) -fi - -dnl In anything but the default case, we may have system-specific setting -dnl which is still not guaranteed to provide all of the entrypoints that -dnl _XOPEN_SOURCE would yield. -if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then - AC_MSG_CHECKING(if _XOPEN_SOURCE really is set) - AC_TRY_COMPILE([#include ],[ + AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[ + AC_TRY_COMPILE([#include ],[ #ifndef _XOPEN_SOURCE make an error #endif], - [cf_XOPEN_SOURCE_set=yes], - [cf_XOPEN_SOURCE_set=no]) - AC_MSG_RESULT($cf_XOPEN_SOURCE_set) - if test $cf_XOPEN_SOURCE_set = yes - then - AC_TRY_COMPILE([#include ],[ -#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE + [cf_cv_xopen_source=no], + [cf_save="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + AC_TRY_COMPILE([#include ],[ +#ifdef _XOPEN_SOURCE make an error #endif], - [cf_XOPEN_SOURCE_set_ok=yes], - [cf_XOPEN_SOURCE_set_ok=no]) - if test $cf_XOPEN_SOURCE_set_ok = no - then - AC_MSG_WARN(_XOPEN_SOURCE is lower than requested) - fi - else - CF_TRY_XOPEN_SOURCE + [cf_cv_xopen_source=no], + [cf_cv_xopen_source=$cf_XOPEN_SOURCE]) + CPPFLAGS="$cf_save" + ]) +]) + if test "$cf_cv_xopen_source" != no ; then + CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE) + CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE) + cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" + CF_ADD_CFLAGS($cf_temp_xopen_source) fi + CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) + ;; +esac + +if test -n "$cf_xopen_source" ; then + CF_ADD_CFLAGS($cf_xopen_source) fi ]) dnl --------------------------------------------------------------------------- Modified: user/attilio/vmcontention/contrib/dialog/arrows.c ============================================================================== --- user/attilio/vmcontention/contrib/dialog/arrows.c Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/contrib/dialog/arrows.c Wed Jan 9 11:58:47 2013 (r245224) @@ -1,5 +1,5 @@ /* - * $Id: arrows.c,v 1.41 2011/10/20 23:37:17 tom Exp $ + * $Id: arrows.c,v 1.36 2011/06/27 09:13:56 tom Exp $ * * arrows.c -- draw arrows to indicate end-of-range for lists * @@ -79,9 +79,9 @@ dlg_draw_helpline(WINDOW *win, bool deco const int *cols = dlg_index_columns(dialog_vars.help_line); int other = decorations ? (ON_LEFT + ON_RIGHT) : 0; int avail = (getmaxx(win) - other - 2); - int limit = dlg_count_real_columns(dialog_vars.help_line) + 2; + int limit = dlg_limit_columns(dialog_vars.help_line, avail, 0); - if (limit < avail) { + if (limit > 0) { getyx(win, cur_y, cur_x); other = decorations ? ON_LEFT : 0; (void) wmove(win, bottom, other + (avail - limit) / 2); @@ -107,14 +107,13 @@ dlg_draw_arrows2(WINDOW *win, int cur_x, cur_y; int limit_x = getmaxx(win); bool draw_top = TRUE; - bool is_toplevel = (wgetparent(win) == stdscr); getyx(win, cur_y, cur_x); /* * If we're drawing a centered title, do not overwrite with the arrows. */ - if (dialog_vars.title && is_toplevel && (top - getbegy(win)) < MARGIN) { + if (dialog_vars.title) { int have = (limit_x - dlg_count_columns(dialog_vars.title)) / 2; int need = x + 5; if (need > have) @@ -124,11 +123,11 @@ dlg_draw_arrows2(WINDOW *win, if (draw_top) { (void) wmove(win, top, x); if (top_arrow) { - (void) wattrset(win, merge_colors(uarrow_attr, attr)); + wattrset(win, merge_colors(uarrow_attr, attr)); (void) add_acs(win, ACS_UARROW); (void) waddstr(win, "(-)"); } else { - (void) wattrset(win, attr); + wattrset(win, attr); (void) whline(win, dlg_boxchar(ACS_HLINE), ON_LEFT); } } @@ -136,11 +135,11 @@ dlg_draw_arrows2(WINDOW *win, (void) wmove(win, bottom, x); if (bottom_arrow) { - (void) wattrset(win, merge_colors(darrow_attr, attr)); + wattrset(win, merge_colors(darrow_attr, attr)); (void) add_acs(win, ACS_DARROW); (void) waddstr(win, "(+)"); } else { - (void) wattrset(win, borderattr); + wattrset(win, borderattr); (void) whline(win, dlg_boxchar(ACS_HLINE), ON_LEFT); } mouse_mkbutton(bottom, x - 1, 6, KEY_NPAGE); @@ -148,7 +147,7 @@ dlg_draw_arrows2(WINDOW *win, (void) wmove(win, cur_y, cur_x); wrefresh(win); - (void) wattrset(win, save); + wattrset(win, save); } void @@ -167,13 +166,14 @@ dlg_draw_scrollbar(WINDOW *win, char buffer[80]; int percent; int len; - int oldy, oldx; + int oldy, oldx, maxy, maxx; chtype save = dlg_get_attrs(win); int top_arrow = (first_data != 0); int bottom_arrow = (next_data < total_data); getyx(win, oldy, oldx); + getmaxyx(win, maxy, maxx); dlg_draw_helpline(win, TRUE); if (bottom_arrow || top_arrow || dialog_state.use_scrollbar) { @@ -187,12 +187,12 @@ dlg_draw_scrollbar(WINDOW *win, else if (percent > 100) percent = 100; - (void) wattrset(win, position_indicator_attr); + wattrset(win, position_indicator_attr); (void) sprintf(buffer, "%d%%", percent); (void) wmove(win, bottom, right - 7); (void) waddstr(win, buffer); if ((len = dlg_count_columns(buffer)) < 4) { - (void) wattrset(win, border_attr); + wattrset(win, border_attr); whline(win, dlg_boxchar(ACS_HLINE), 4 - len); } } @@ -212,7 +212,7 @@ dlg_draw_scrollbar(WINDOW *win, if (bar_high < all_high) { wmove(win, top + 1, right); - (void) wattrset(win, save); + wattrset(win, save); wvline(win, ACS_VLINE | A_REVERSE, all_high); bar_y = BARSIZE(this_data); @@ -221,7 +221,7 @@ dlg_draw_scrollbar(WINDOW *win, wmove(win, top + 1 + bar_y, right); - (void) wattrset(win, position_indicator_attr); + wattrset(win, position_indicator_attr); wattron(win, A_REVERSE); wvline(win, ACS_BLOCK, bar_high); } @@ -236,7 +236,7 @@ dlg_draw_scrollbar(WINDOW *win, attr, borderattr); - (void) wattrset(win, save); + wattrset(win, save); wmove(win, oldy, oldx); } @@ -255,6 +255,6 @@ dlg_draw_arrows(WINDOW *win, x, top, bottom, - menubox_border2_attr, + menubox_attr, menubox_border_attr); } Modified: user/attilio/vmcontention/contrib/dialog/buttons.c ============================================================================== --- user/attilio/vmcontention/contrib/dialog/buttons.c Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/contrib/dialog/buttons.c Wed Jan 9 11:58:47 2013 (r245224) @@ -1,9 +1,9 @@ /* - * $Id: buttons.c,v 1.90 2012/07/01 20:42:05 tom Exp $ + * $Id: buttons.c,v 1.86 2011/06/28 10:46:46 tom Exp $ * * buttons.c -- draw buttons, e.g., OK/Cancel * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2010,2011 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -104,11 +104,11 @@ print_button(WINDOW *win, char *label, i : button_label_inactive_attr); (void) wmove(win, y, x); - (void) wattrset(win, selected - ? button_active_attr - : button_inactive_attr); + wattrset(win, selected + ? button_active_attr + : button_inactive_attr); (void) waddstr(win, "<"); - (void) wattrset(win, label_attr); + wattrset(win, label_attr); for (i = 0; i < limit; ++i) { int first = indx[i]; int last = indx[i + 1]; @@ -120,14 +120,14 @@ print_button(WINDOW *win, char *label, i const char *temp = (label + first); int cmp = string_to_char(&temp); if (dlg_isupper(cmp)) { - (void) wattrset(win, key_attr); + wattrset(win, key_attr); state = 1; } break; } #endif if (dlg_isupper(UCH(label[first]))) { - (void) wattrset(win, key_attr); + wattrset(win, key_attr); state = 1; } break; @@ -138,9 +138,9 @@ print_button(WINDOW *win, char *label, i } waddnstr(win, label + first, last - first); } - (void) wattrset(win, selected - ? button_active_attr - : button_inactive_attr); + wattrset(win, selected + ? button_active_attr + : button_inactive_attr); (void) waddstr(win, ">"); (void) wmove(win, y, x + ((int) strspn(label, " ")) + 1); } @@ -310,7 +310,7 @@ dlg_draw_buttons(WINDOW *win, (void) wmove(win, final_y, final_x); wrefresh(win); free(buffer); - (void) wattrset(win, save); + wattrset(win, save); } /* @@ -488,12 +488,10 @@ dlg_exit_buttoncode(int button) const char ** dlg_ok_label(void) { - static const char *labels[4]; + static const char *labels[3]; int n = 0; labels[n++] = my_ok_label(); - if (dialog_vars.extra_button) - labels[n++] = my_extra_label(); if (dialog_vars.help_button) labels[n++] = my_help_label(); labels[n] = 0; @@ -539,7 +537,6 @@ dlg_ok_buttoncode(int button) } else if (dialog_vars.help_button && (button == n)) { result = DLG_EXIT_HELP; } - dlg_trace_msg("# dlg_ok_buttoncode(%d) = %d\n", button, result); return result; } @@ -578,7 +575,7 @@ dlg_prev_ok_buttonindex(int current, int /* * Find the button-index for the "OK" or "Cancel" button, according to * whether --defaultno is given. If --nocancel was given, we always return - * the index for the first button (usually "OK" unless --nook was used). + * the index for "OK". */ int dlg_defaultno_button(void) @@ -589,30 +586,6 @@ dlg_defaultno_button(void) while (dlg_ok_buttoncode(result) != DLG_EXIT_CANCEL) ++result; } - dlg_trace_msg("# dlg_defaultno_button() = %d\n", result); - return result; -} - -/* - * Find the button-index for a button named with --default-button. If the - * option was not specified, or if the selected button does not exist, return - * the index of the first button (usually "OK" unless --nook was used). - */ -int -dlg_default_button(void) -{ - int i, n; - int result = 0; - - if (dialog_vars.default_button >= 0) { - for (i = 0; (n = dlg_ok_buttoncode(i)) >= 0; i++) { - if (n == dialog_vars.default_button) { - result = i; - break; - } - } - } - dlg_trace_msg("# dlg_default_button() = %d\n", result); return result; } Modified: user/attilio/vmcontention/contrib/dialog/calendar.c ============================================================================== --- user/attilio/vmcontention/contrib/dialog/calendar.c Wed Jan 9 09:29:22 2013 (r245223) +++ user/attilio/vmcontention/contrib/dialog/calendar.c Wed Jan 9 11:58:47 2013 (r245224) @@ -1,9 +1,9 @@ /* - * $Id: calendar.c,v 1.66 2012/07/01 18:13:07 Zoltan.Kelemen Exp $ + * $Id: calendar.c,v 1.62 2011/06/29 09:47:06 tom Exp $ * * calendar.c -- implements the calendar box * - * Copyright 2001-2011,2012 Thomas E. Dickey + * Copyright 2001-2010,2011 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -225,14 +225,12 @@ draw_day(BOX * data, struct tm *current) int prev = days_in_month(current, -1); werase(data->window); - dlg_draw_box2(data->parent, - data->y - MARGIN, data->x - MARGIN, - data->height + (2 * MARGIN), data->width + (2 * MARGIN), - menubox_attr, - menubox_border_attr, - menubox_border2_attr); + dlg_draw_box(data->parent, + data->y - MARGIN, data->x - MARGIN, + data->height + (2 * MARGIN), data->width + (2 * MARGIN), + menubox_border_attr, menubox_attr); /* border of daybox */ - (void) wattrset(data->window, menubox_attr); /* daynames headline */ + wattrset(data->window, menubox_attr); /* daynames headline */ for (x = 0; x < 7; x++) { mvwprintw(data->window, 0, (x + 1) * cell_wide, "%*.*s ", @@ -248,7 +246,7 @@ draw_day(BOX * data, struct tm *current) week = (current->tm_yday + 6 + mday - current->tm_mday) / 7; for (y = 1; mday < last; y++) { - (void) wattrset(data->window, menubox_attr); /* weeknumbers headline */ + wattrset(data->window, menubox_attr); /* weeknumbers headline */ mvwprintw(data->window, y, 0, "%*d ", @@ -259,9 +257,9 @@ draw_day(BOX * data, struct tm *current) ++mday; if (wmove(data->window, y, this_x) == ERR) continue; - (void) wattrset(data->window, item_attr); /* not selected days */ + wattrset(data->window, item_attr); /* not selected days */ if (mday == day) { - (void) wattrset(data->window, item_selected_attr); /* selected day */ + wattrset(data->window, item_selected_attr); /* selected day */ save_y = y; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 20:01:09 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E8679F06; Wed, 9 Jan 2013 20:01:09 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DA1099C4; Wed, 9 Jan 2013 20:01:09 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r09K19r1005523; Wed, 9 Jan 2013 20:01:09 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r09K19C8005518; Wed, 9 Jan 2013 20:01:09 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301092001.r09K19C8005518@svn.freebsd.org> From: Adrian Chadd Date: Wed, 9 Jan 2013 20:01:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245235 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 20:01:10 -0000 Author: adrian Date: Wed Jan 9 20:01:08 2013 New Revision: 245235 URL: http://svnweb.freebsd.org/changeset/base/245235 Log: Break out the display specific code into a separate file and begin the process of turning it into a (kind of) stand-alone class. Added: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c - copied, changed from r245197, user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h Modified: user/adrian/ath_radar_stuff/src/spectral_fft/Makefile user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/Makefile ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/Makefile Wed Jan 9 19:49:35 2013 (r245234) +++ user/adrian/ath_radar_stuff/src/spectral_fft/Makefile Wed Jan 9 20:01:08 2013 (r245235) @@ -1,6 +1,6 @@ PROG= fft_eval -SRCS= fft_eval.c fft_freebsd.c fft_histogram.c +SRCS= fft_eval.c fft_freebsd.c fft_histogram.c fft_display.c CFLAGS+= -I/usr/local/include -L/usr/local/lib -I../../lib/ -L../../lib/libradarpkt -pthread Copied and modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c (from r245197, user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c) ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 00:01:26 2013 (r245197, copy source) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c Wed Jan 9 20:01:08 2013 (r245235) @@ -26,16 +26,17 @@ #include #include -#include #include #include #include +#include #include #include #include "fft_eval.h" +#if 1 #include "net80211/ieee80211.h" #include "net80211/ieee80211_radiotap.h" @@ -43,11 +44,12 @@ #include "libradarpkt/ar5212_radar.h" #include "libradarpkt/ar5416_radar.h" #include "libradarpkt/ar9280_radar.h" +#endif -#include "fft_eval.h" -#include "fft_freebsd.h" #include "fft_histogram.h" +#include "fft_display.h" + #define WIDTH 1600 #define HEIGHT 650 #define BPP 32 @@ -64,62 +66,9 @@ #define AMASK 0xff000000 /* XXX ew globals */ -pthread_mutex_t mtx_histogram; -int g_do_update = 0; - -SDL_Surface *screen = NULL; -TTF_Font *font = NULL; - -int graphics_init_sdl(void) -{ - SDL_VideoInfo *VideoInfo; - int SDLFlags; - - SDLFlags = SDL_HWPALETTE | SDL_RESIZABLE; - - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { - fprintf(stderr, "Initializing SDL failed\n"); - return -1; - } - - if ((VideoInfo = (SDL_VideoInfo *) SDL_GetVideoInfo()) == NULL) { - fprintf(stderr, "Getting SDL Video Info failed\n"); - return -1; - } - - else { - if (VideoInfo->hw_available) { - SDLFlags |= SDL_HWSURFACE; - } else { - SDLFlags |= SDL_SWSURFACE; - } - if (VideoInfo->blit_hw) - SDLFlags |= SDL_HWACCEL; - } - SDL_WM_SetCaption("FFT eval", "FFT eval"); - screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, SDLFlags); - - if (TTF_Init() < 0) { - fprintf(stderr, "Initializing SDL TTF failed\n"); - return -1; - } - - font = TTF_OpenFont("font/LiberationSans-Regular.ttf", 14); - if (!font) { - fprintf(stderr, "Opening font failed\n"); - return -1; - } - - return 0; -} - -void graphics_quit_sdl(void) -{ - SDL_Quit(); -} - -int pixel(Uint32 *pixels, int x, int y, Uint32 color) +static int +pixel(Uint32 *pixels, int x, int y, Uint32 color) { if (x < 0 || x >= WIDTH) return -1; @@ -145,7 +94,8 @@ is_in_viewport(int x, int y) /* this function blends a 2*SIZE x 2*SIZE blob at the given position with * the defined opacity. */ -int bigpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) +static int +bigpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) { int x1, y1; @@ -174,7 +124,12 @@ int bigpixel(Uint32 *pixels, int x, int return 0; } -int bighotpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) +/* + * Like bigpixel, but blending blue (the "data average" colour) to + * green if the blue is saturated. A total hack, but a pretty one. + */ +static int +bighotpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) { int x1, y1; @@ -212,7 +167,9 @@ int bighotpixel(Uint32 *pixels, int x, i return 0; } -int render_text(SDL_Surface *surface, char *text, int x, int y) +static int +render_text(struct fft_display *fdisp, SDL_Surface *surface, + char *text, int x, int y) { SDL_Surface *text_surface; SDL_Color fontcolor = {255, 255, 255, 255}; @@ -221,7 +178,7 @@ int render_text(SDL_Surface *surface, ch fontdest.x = x; fontdest.y = y; - text_surface = TTF_RenderText_Solid(font, text, fontcolor); + text_surface = TTF_RenderText_Solid(fdisp->font, text, fontcolor); if (!text_surface) return -1; @@ -231,6 +188,28 @@ int render_text(SDL_Surface *surface, ch return 0; } +struct fft_display * +fft_display_create(SDL_Surface *screen, TTF_Font *font) +{ + struct fft_display *fdisp; + + fdisp = calloc(1, sizeof(*fdisp)); + if (fdisp == NULL) { + warn("%s: malloc", __func__); + return (NULL); + } + fdisp->screen = screen; + fdisp->font = font; + return (fdisp); +} + +void +fft_display_destroy(struct fft_display *fdisp) +{ + + free(fdisp); +} + /* * draw_picture - draws the current screen. * @@ -238,7 +217,9 @@ int render_text(SDL_Surface *surface, ch * * returns the center frequency of the currently highlighted dataset */ -int draw_picture(int highlight, int startfreq) +int +fft_display_draw_picture(struct fft_display *fdisp, int highlight, + int startfreq) { Uint32 *pixels, color, opacity; int x, y, i, rnum, j; @@ -264,7 +245,7 @@ int draw_picture(int highlight, int star pixels[x + y * WIDTH] = 0x40404040 | AMASK; snprintf(text, sizeof(text), "%d MHz", i); - render_text(surface, text, x - 30, HEIGHT - 20); + render_text(fdisp, surface, text, x - 30, HEIGHT - 20); } /* horizontal lines (dBm) */ @@ -275,7 +256,7 @@ int draw_picture(int highlight, int star pixels[x + y * WIDTH] = 0x40404040 | AMASK; snprintf(text, sizeof(text), "-%d dBm", (150 - i)); - render_text(surface, text, 5, y - 15); + render_text(fdisp, surface, text, 5, y - 15); } /* Render 2300 -> 6000 in 1MHz increments, but using KHz math */ @@ -317,180 +298,9 @@ int draw_picture(int highlight, int star continue; } - SDL_BlitSurface(surface, NULL, screen, NULL); + SDL_BlitSurface(surface, NULL, fdisp->screen, NULL); SDL_FreeSurface(surface); - SDL_Flip(screen); + SDL_Flip(fdisp->screen); return highlight_freq; } - -/* - * graphics_main - sets up the data and holds the mainloop. - * - */ -void graphics_main(void) -{ - SDL_Event event; - int quit = 0; - int highlight = 0; - int change = 1, scroll = 0; - int startfreq = 2350, accel = 0; - int highlight_freq = startfreq; - - if (graphics_init_sdl() < 0) { - fprintf(stderr, "Failed to initialize graphics.\n"); - return; - } - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - while (!quit) { - pthread_mutex_lock(&mtx_histogram); - if (g_do_update == 1) { - change = 1; /* XXX always render */ - g_do_update = 0; - } - pthread_mutex_unlock(&mtx_histogram); - - if (change) { - highlight_freq = draw_picture(highlight, startfreq); - change = 0; - } - - if (!scroll) { - /* move to highlighted object */ - if (highlight_freq - 20 < startfreq) - accel = -10; - if (highlight_freq > (startfreq + WIDTH/X_SCALE)) - accel = 10; - - /* if we are "far off", move a little bit faster */ - if (highlight_freq + 300 < startfreq) - accel = -100; - - if (highlight_freq - 300 > (startfreq + WIDTH/X_SCALE)) - accel = 100; - } - -// if (accel) - SDL_PollEvent(&event); -// else -// SDL_WaitEvent(&event); - - switch (event.type) { - case SDL_QUIT: - quit = 1; - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { -#if 0 - case SDLK_LEFT: - if (highlight > 0) { - highlight--; - scroll = 0; - change = 1; - } - break; - case SDLK_RIGHT: - if (highlight < scanresults_n - 1){ - highlight++; - scroll = 0; - change = 1; - } - break; -#endif - case SDLK_PAGEUP: - accel-= 2; - scroll = 1; - break; - case SDLK_PAGEDOWN: - accel+= 2; - scroll = 1; - break; - case SDLK_HOME: - startfreq = 2300; - accel = 0; - break; - case SDLK_END: - startfreq = 5100; - accel = 0; - break; - default: - break; - } - break; - } - if (accel) { - startfreq += accel; - if (accel > 0) accel--; - if (accel < 0) accel++; - change = 1; - } - if (startfreq < 2300) startfreq = 2300; - if (startfreq > 6000) startfreq = 6000; - if (accel < -20) accel = -20; - if (accel > 20) accel = 20; - } - - graphics_quit_sdl(); -} - -void usage(int argc, char *argv[]) -{ - fprintf(stderr, "Usage: %s [scanfile]\n", argv[0]); - fprintf(stderr, "\n"); - fprintf(stderr, "scanfile is generated by the spectral analyzer feature\n"); - fprintf(stderr, "of your wifi card. If you have a AR92xx or AR93xx based\n"); - fprintf(stderr, "card, try:\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "ifconfig wlan0 up\n"); - fprintf(stderr, "iw dev wlan0 scan spec-scan\n"); - fprintf(stderr, "cat /sys/kernel/debug/ieee80211/phy0/ath9k/spectral_scan > /tmp/fft_results\n"); - fprintf(stderr, "%s /tmp/fft_results\n", argv[0]); - fprintf(stderr, "\n"); - fprintf(stderr, "(NOTE: maybe debugfs must be mounted first: mount -t debugfs none /sys/kernel/debug/ )\n"); - fprintf(stderr, "\n"); - -} - -static void -fft_eval_cb(struct radar_entry *re, void *cbdata) -{ - struct radar_fft_entry *fe; - int i; - - pthread_mutex_lock(&mtx_histogram); - for (i = 0; i < re->re_num_spectral_entries; i++) { - fft_add_sample(re, &re->re_spectral_entries[i]); - } - g_do_update = 1; - pthread_mutex_unlock(&mtx_histogram); - -} - -int main(int argc, char *argv[]) -{ - int ret; - - if (argc < 2) { - usage(argc, argv); - return -1; - } - - fprintf(stderr, "WARNING: Experimental Software! Don't trust anything you see. :)\n"); - fprintf(stderr, "\n"); - - /* Setup radar entry callback */ - pthread_mutex_init(&mtx_histogram, NULL); - set_scandata_callback(fft_eval_cb, NULL); - - /* Fetch data */ - ret = read_scandata_freebsd(argv[1], NULL); - - if (ret < 0) { - fprintf(stderr, "Couldn't read scanfile ...\n"); - usage(argc, argv); - return -1; - } - graphics_main(); - - return 0; -} Added: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h Wed Jan 9 20:01:08 2013 (r245235) @@ -0,0 +1,15 @@ +#ifndef __FFT_DISPLAY_H__ +#define __FFT_DISPLAY_H__ + +struct fft_display { + SDL_Surface *screen; + TTF_Font *font; +}; + +extern struct fft_display * fft_display_create(SDL_Surface *screen, + TTF_Font *font); +extern void fft_display_destroy(struct fft_display *disp); +extern int fft_display_draw_picture(struct fft_display *fdisp, + int highlight, int startfreq); + +#endif /* __FFT_DISPLAY_H__ */ Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 19:49:35 2013 (r245234) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:01:08 2013 (r245235) @@ -47,6 +47,7 @@ #include "fft_eval.h" #include "fft_freebsd.h" #include "fft_histogram.h" +#include "fft_display.h" #define WIDTH 1600 #define HEIGHT 650 @@ -66,7 +67,6 @@ /* XXX ew globals */ pthread_mutex_t mtx_histogram; int g_do_update = 0; - SDL_Surface *screen = NULL; TTF_Font *font = NULL; @@ -119,216 +119,11 @@ void graphics_quit_sdl(void) SDL_Quit(); } -int pixel(Uint32 *pixels, int x, int y, Uint32 color) -{ - if (x < 0 || x >= WIDTH) - return -1; - if (y < 0 || y >= HEIGHT) - return -1; - - pixels[x + y * WIDTH] |= color; - return 0; -} - -#define SIZE 2 - -/* Is this pixel in the viewport? */ -static int -is_in_viewport(int x, int y) -{ - if (x - SIZE < 0 || x + SIZE >= WIDTH) - return 0; - if (y - SIZE < 0 || y + SIZE >= HEIGHT) - return 0; - return (1); -} - -/* this function blends a 2*SIZE x 2*SIZE blob at the given position with - * the defined opacity. */ -int bigpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) -{ - int x1, y1; - - if (! is_in_viewport(x, y)) - return -1; - - for (x1 = x - SIZE; x1 < x + SIZE; x1++) - for (y1 = y - SIZE; y1 < y + SIZE; y1++) { - Uint32 r, g, b; - - r = ((pixels[x1 + y1 * WIDTH] & RMASK) >> RBITS) + - ((((color & RMASK) >> RBITS) * opacity) / 255); - if (r > 255) r = 255; - - g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + - ((((color & GMASK) >> GBITS) * opacity) / 255); - if (g > 255) g = 255; - - b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS) + - ((((color & BMASK) >> BBITS) * opacity) / 255); - if (b > 255) b = 255; - - pixels[x1 + y1 * WIDTH] = r << RBITS | - g << GBITS | b << BBITS | (color & AMASK); - } - return 0; -} - -int bighotpixel(Uint32 *pixels, int x, int y, Uint32 color, uint8_t opacity) -{ - int x1, y1; - - if (! is_in_viewport(x, y)) - return -1; - - for (x1 = x - SIZE; x1 < x + SIZE; x1++) - for (y1 = y - SIZE; y1 < y + SIZE; y1++) { - Uint32 r, g, b; - - r = ((pixels[x1 + y1 * WIDTH] & RMASK) >> RBITS) + - ((((color & RMASK) >> RBITS) * opacity) / 255); - if (r > 255) r = 255; - - g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + - ((((color & GMASK) >> GBITS) * opacity) / 255); - if (g > 255) g = 255; - - /* If we've capped out blue, increment red */ - b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS); - if (b > 248) { - /* green bumped by bluemask */ - g = ((pixels[x1 + y1 * WIDTH] & GMASK) >> GBITS) + - ((((color & BMASK) >> BBITS) * (opacity/2)) / 255); - if (g > 255) g = 255; - } else { - b = ((pixels[x1 + y1 * WIDTH] & BMASK) >> BBITS) + - ((((color & BMASK) >> BBITS) * opacity) / 255); - if (b > 255) b = 255; - } - - pixels[x1 + y1 * WIDTH] = r << RBITS | - g << GBITS | b << BBITS | (color & AMASK); - } - return 0; -} - -int render_text(SDL_Surface *surface, char *text, int x, int y) -{ - SDL_Surface *text_surface; - SDL_Color fontcolor = {255, 255, 255, 255}; - SDL_Rect fontdest = {0, 0, 0, 0}; - - fontdest.x = x; - fontdest.y = y; - - text_surface = TTF_RenderText_Solid(font, text, fontcolor); - if (!text_surface) - return -1; - - SDL_BlitSurface(text_surface, NULL, surface, &fontdest); - SDL_FreeSurface(text_surface); - - return 0; -} - -/* - * draw_picture - draws the current screen. - * - * @highlight: the index of the dataset to be highlighted - * - * returns the center frequency of the currently highlighted dataset - */ -int draw_picture(int highlight, int startfreq) -{ - Uint32 *pixels, color, opacity; - int x, y, i, rnum, j; - int highlight_freq = startfreq + 20; - char text[1024]; - struct scanresult *result; - SDL_Surface *surface; - - surface = SDL_CreateRGBSurface(SDL_SWSURFACE, WIDTH, HEIGHT, BPP, RMASK, GMASK, BMASK, AMASK); - pixels = (Uint32 *) surface->pixels; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) - pixels[x + y * WIDTH] = AMASK; - - /* vertical lines (frequency) */ - for (i = 2300; i < 6000; i += 20) { - x = (X_SCALE * (i - startfreq)); - - if (x < 0 || x > WIDTH) - continue; - - for (y = 0; y < HEIGHT - 20; y++) - pixels[x + y * WIDTH] = 0x40404040 | AMASK; - - snprintf(text, sizeof(text), "%d MHz", i); - render_text(surface, text, x - 30, HEIGHT - 20); - } - - /* horizontal lines (dBm) */ - for (i = 0; i < 150; i += 10) { - y = 600 - Y_SCALE * i; - - for (x = 0; x < WIDTH; x++) - pixels[x + y * WIDTH] = 0x40404040 | AMASK; - - snprintf(text, sizeof(text), "-%d dBm", (150 - i)); - render_text(surface, text, 5, y - 15); - } - - /* Render 2300 -> 6000 in 1MHz increments, but using KHz math */ - /* .. as right now the canvas is .. quite large. */ - /* XXX should just do it based on the current viewport! */ - for (i = 2300*1000; i < 6000*1000; i+= 250) { - float signal; - int freqKhz = i; - int16_t *s; - - x = X_SCALE * (freqKhz - (startfreq * 1000)) / 1000; - - if (x < 0 || x > WIDTH) - continue; - - /* Fetch dBm value at the given frequency in KHz */ - s = fft_fetch_freq_avg(freqKhz); - if (s == NULL) - continue; - - for (j = 0; j < FFT_HISTOGRAM_HISTORY_DEPTH; j++) { - if (s[j] == 0) - continue; - signal = (float) s[j]; - color = BMASK | AMASK; - opacity = 64; - y = 400 - (400.0 + Y_SCALE * signal); - if (bighotpixel(pixels, x, y, color, opacity) < 0) - continue; - } - - - /* .. and the max */ - signal = (float) fft_fetch_freq_max(freqKhz); - color = RMASK | AMASK; - opacity = 128; - y = 400 - (400.0 + Y_SCALE * signal); - if (bigpixel(pixels, x, y, color, opacity) < 0) - continue; - } - - SDL_BlitSurface(surface, NULL, screen, NULL); - SDL_FreeSurface(surface); - SDL_Flip(screen); - - return highlight_freq; -} - /* * graphics_main - sets up the data and holds the mainloop. * */ -void graphics_main(void) +void graphics_main(struct fft_display *fdisp) { SDL_Event event; int quit = 0; @@ -337,11 +132,6 @@ void graphics_main(void) int startfreq = 2350, accel = 0; int highlight_freq = startfreq; - if (graphics_init_sdl() < 0) { - fprintf(stderr, "Failed to initialize graphics.\n"); - return; - } - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); while (!quit) { pthread_mutex_lock(&mtx_histogram); if (g_do_update == 1) { @@ -351,7 +141,8 @@ void graphics_main(void) pthread_mutex_unlock(&mtx_histogram); if (change) { - highlight_freq = draw_picture(highlight, startfreq); + highlight_freq = fft_display_draw_picture(fdisp, + highlight, startfreq); change = 0; } @@ -429,8 +220,6 @@ void graphics_main(void) if (accel < -20) accel = -20; if (accel > 20) accel = 20; } - - graphics_quit_sdl(); } void usage(int argc, char *argv[]) @@ -469,6 +258,7 @@ fft_eval_cb(struct radar_entry *re, void int main(int argc, char *argv[]) { int ret; + struct fft_display *fdisp; if (argc < 2) { usage(argc, argv); @@ -482,6 +272,19 @@ int main(int argc, char *argv[]) pthread_mutex_init(&mtx_histogram, NULL); set_scandata_callback(fft_eval_cb, NULL); + /* Setup graphics */ + if (graphics_init_sdl() < 0) { + fprintf(stderr, "Failed to initialize graphics.\n"); + exit(127); + } + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + + /* Setup fft display */ + + fdisp = fft_display_create(screen, font); + if (fdisp == NULL) + exit(127); + /* Fetch data */ ret = read_scandata_freebsd(argv[1], NULL); @@ -490,7 +293,9 @@ int main(int argc, char *argv[]) usage(argc, argv); return -1; } - graphics_main(); + graphics_main(fdisp); + + graphics_quit_sdl(); return 0; } From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 20:13:48 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B0133566; Wed, 9 Jan 2013 20:13:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 93986A70; Wed, 9 Jan 2013 20:13:48 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r09KDm8f008841; Wed, 9 Jan 2013 20:13:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r09KDmtJ008837; Wed, 9 Jan 2013 20:13:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301092013.r09KDmtJ008837@svn.freebsd.org> From: Adrian Chadd Date: Wed, 9 Jan 2013 20:13:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245237 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 20:13:48 -0000 Author: adrian Date: Wed Jan 9 20:13:47 2013 New Revision: 245237 URL: http://svnweb.freebsd.org/changeset/base/245237 Log: * break out the width/height/scaling to fft_display.h * modify acceleration max to 40, rather than 20, so I can quickly scroll around the 5ghz range * change the scroll to be left/right, rather than pageup/pagedown. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c Wed Jan 9 20:10:45 2013 (r245236) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c Wed Jan 9 20:13:47 2013 (r245237) @@ -36,6 +36,10 @@ #include "fft_eval.h" +/* + * This is needed for fft_histogram, which currently + * manipulates fft_radar_entry structs. + */ #if 1 #include "net80211/ieee80211.h" #include "net80211/ieee80211_radiotap.h" @@ -50,13 +54,6 @@ #include "fft_display.h" -#define WIDTH 1600 -#define HEIGHT 650 -#define BPP 32 - -#define X_SCALE 5 -#define Y_SCALE 4 - #define RMASK 0x000000ff #define RBITS 0 #define GMASK 0x0000ff00 Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h Wed Jan 9 20:10:45 2013 (r245236) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h Wed Jan 9 20:13:47 2013 (r245237) @@ -1,6 +1,13 @@ #ifndef __FFT_DISPLAY_H__ #define __FFT_DISPLAY_H__ +#define WIDTH 1600 +#define HEIGHT 650 +#define BPP 32 + +#define X_SCALE 5 +#define Y_SCALE 4 + struct fft_display { SDL_Surface *screen; TTF_Font *font; Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:10:45 2013 (r245236) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:13:47 2013 (r245237) @@ -49,21 +49,6 @@ #include "fft_histogram.h" #include "fft_display.h" -#define WIDTH 1600 -#define HEIGHT 650 -#define BPP 32 - -#define X_SCALE 5 -#define Y_SCALE 4 - -#define RMASK 0x000000ff -#define RBITS 0 -#define GMASK 0x0000ff00 -#define GBITS 8 -#define BMASK 0x00ff0000 -#define BBITS 16 -#define AMASK 0xff000000 - /* XXX ew globals */ pthread_mutex_t mtx_histogram; int g_do_update = 0; @@ -188,11 +173,11 @@ void graphics_main(struct fft_display *f } break; #endif - case SDLK_PAGEUP: + case SDLK_LEFT: accel-= 2; scroll = 1; break; - case SDLK_PAGEDOWN: + case SDLK_RIGHT: accel+= 2; scroll = 1; break; @@ -217,8 +202,8 @@ void graphics_main(struct fft_display *f } if (startfreq < 2300) startfreq = 2300; if (startfreq > 6000) startfreq = 6000; - if (accel < -20) accel = -20; - if (accel > 20) accel = 20; + if (accel < -40) accel = -40; + if (accel > 40) accel = 40; } } From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 20:27:38 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B930495E; Wed, 9 Jan 2013 20:27:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id ABFC5B02; Wed, 9 Jan 2013 20:27:38 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r09KRc6D011852; Wed, 9 Jan 2013 20:27:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r09KRcEb011851; Wed, 9 Jan 2013 20:27:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301092027.r09KRcEb011851@svn.freebsd.org> From: Adrian Chadd Date: Wed, 9 Jan 2013 20:27:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245239 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 20:27:38 -0000 Author: adrian Date: Wed Jan 9 20:27:38 2013 New Revision: 245239 URL: http://svnweb.freebsd.org/changeset/base/245239 Log: Break out the global app variables into an app struct. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:27:06 2013 (r245238) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:27:38 2013 (r245239) @@ -26,8 +26,8 @@ #include #include -#include #include +#include #include #include @@ -49,13 +49,15 @@ #include "fft_histogram.h" #include "fft_display.h" -/* XXX ew globals */ -pthread_mutex_t mtx_histogram; -int g_do_update = 0; -SDL_Surface *screen = NULL; -TTF_Font *font = NULL; +struct fft_app { + pthread_mutex_t mtx_histogram; + int g_do_update; + SDL_Surface *screen; + TTF_Font *font; + struct fft_display *fdisp; +}; -int graphics_init_sdl(void) +int graphics_init_sdl(struct fft_app *fap) { SDL_VideoInfo *VideoInfo; int SDLFlags; @@ -83,15 +85,15 @@ int graphics_init_sdl(void) } SDL_WM_SetCaption("FFT eval", "FFT eval"); - screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, SDLFlags); + fap->screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, SDLFlags); if (TTF_Init() < 0) { fprintf(stderr, "Initializing SDL TTF failed\n"); return -1; } - font = TTF_OpenFont("font/LiberationSans-Regular.ttf", 14); - if (!font) { + fap->font = TTF_OpenFont("font/LiberationSans-Regular.ttf", 14); + if (! fap->font) { fprintf(stderr, "Opening font failed\n"); return -1; } @@ -108,7 +110,7 @@ void graphics_quit_sdl(void) * graphics_main - sets up the data and holds the mainloop. * */ -void graphics_main(struct fft_display *fdisp) +void graphics_main(struct fft_app *fap) { SDL_Event event; int quit = 0; @@ -118,15 +120,15 @@ void graphics_main(struct fft_display *f int highlight_freq = startfreq; while (!quit) { - pthread_mutex_lock(&mtx_histogram); - if (g_do_update == 1) { + pthread_mutex_lock(&fap->mtx_histogram); + if (fap->g_do_update == 1) { change = 1; /* XXX always render */ - g_do_update = 0; + fap->g_do_update = 0; } - pthread_mutex_unlock(&mtx_histogram); + pthread_mutex_unlock(&fap->mtx_histogram); if (change) { - highlight_freq = fft_display_draw_picture(fdisp, + highlight_freq = fft_display_draw_picture(fap->fdisp, highlight, startfreq); change = 0; } @@ -228,22 +230,23 @@ void usage(int argc, char *argv[]) static void fft_eval_cb(struct radar_entry *re, void *cbdata) { + struct fft_app *fap = cbdata; struct radar_fft_entry *fe; int i; - pthread_mutex_lock(&mtx_histogram); + pthread_mutex_lock(&fap->mtx_histogram); for (i = 0; i < re->re_num_spectral_entries; i++) { fft_add_sample(re, &re->re_spectral_entries[i]); } - g_do_update = 1; - pthread_mutex_unlock(&mtx_histogram); + fap->g_do_update = 1; + pthread_mutex_unlock(&fap->mtx_histogram); } int main(int argc, char *argv[]) { int ret; - struct fft_display *fdisp; + struct fft_app *fap; if (argc < 2) { usage(argc, argv); @@ -253,12 +256,17 @@ int main(int argc, char *argv[]) fprintf(stderr, "WARNING: Experimental Software! Don't trust anything you see. :)\n"); fprintf(stderr, "\n"); + fap = calloc(1, sizeof(*fap)); + if (! fap) { + errx(127, "calloc"); + } + /* Setup radar entry callback */ - pthread_mutex_init(&mtx_histogram, NULL); - set_scandata_callback(fft_eval_cb, NULL); + pthread_mutex_init(&fap->mtx_histogram, NULL); + set_scandata_callback(fft_eval_cb, fap); /* Setup graphics */ - if (graphics_init_sdl() < 0) { + if (graphics_init_sdl(fap) < 0) { fprintf(stderr, "Failed to initialize graphics.\n"); exit(127); } @@ -266,8 +274,8 @@ int main(int argc, char *argv[]) /* Setup fft display */ - fdisp = fft_display_create(screen, font); - if (fdisp == NULL) + fap->fdisp = fft_display_create(fap->screen, fap->font); + if (fap->fdisp == NULL) exit(127); /* Fetch data */ @@ -278,7 +286,7 @@ int main(int argc, char *argv[]) usage(argc, argv); return -1; } - graphics_main(fdisp); + graphics_main(fap); graphics_quit_sdl(); From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 20:39:31 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 42B3BC7B; Wed, 9 Jan 2013 20:39:31 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 26C40B9E; Wed, 9 Jan 2013 20:39:31 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r09KdVZ9014511; Wed, 9 Jan 2013 20:39:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r09KdUnF014505; Wed, 9 Jan 2013 20:39:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301092039.r09KdUnF014505@svn.freebsd.org> From: Adrian Chadd Date: Wed, 9 Jan 2013 20:39:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245240 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 20:39:31 -0000 Author: adrian Date: Wed Jan 9 20:39:29 2013 New Revision: 245240 URL: http://svnweb.freebsd.org/changeset/base/245240 Log: Migrate the fft histogram code to work as an object, rather than a global. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c Wed Jan 9 20:27:38 2013 (r245239) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.c Wed Jan 9 20:39:29 2013 (r245240) @@ -186,7 +186,8 @@ render_text(struct fft_display *fdisp, S } struct fft_display * -fft_display_create(SDL_Surface *screen, TTF_Font *font) +fft_display_create(SDL_Surface *screen, TTF_Font *font, + struct fft_histogram *fh) { struct fft_display *fdisp; @@ -197,6 +198,7 @@ fft_display_create(SDL_Surface *screen, } fdisp->screen = screen; fdisp->font = font; + fdisp->fh = fh; return (fdisp); } @@ -270,7 +272,7 @@ fft_display_draw_picture(struct fft_disp continue; /* Fetch dBm value at the given frequency in KHz */ - s = fft_fetch_freq_avg(freqKhz); + s = fft_fetch_freq_avg(fdisp->fh, freqKhz); if (s == NULL) continue; @@ -287,7 +289,7 @@ fft_display_draw_picture(struct fft_disp /* .. and the max */ - signal = (float) fft_fetch_freq_max(freqKhz); + signal = (float) fft_fetch_freq_max(fdisp->fh, freqKhz); color = RMASK | AMASK; opacity = 128; y = 400 - (400.0 + Y_SCALE * signal); Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h Wed Jan 9 20:27:38 2013 (r245239) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_display.h Wed Jan 9 20:39:29 2013 (r245240) @@ -11,10 +11,11 @@ struct fft_display { SDL_Surface *screen; TTF_Font *font; + struct fft_histogram *fh; }; extern struct fft_display * fft_display_create(SDL_Surface *screen, - TTF_Font *font); + TTF_Font *font, struct fft_histogram *fh); extern void fft_display_destroy(struct fft_display *disp); extern int fft_display_draw_picture(struct fft_display *fdisp, int highlight, int startfreq); Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:27:38 2013 (r245239) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 20:39:29 2013 (r245240) @@ -55,6 +55,7 @@ struct fft_app { SDL_Surface *screen; TTF_Font *font; struct fft_display *fdisp; + struct fft_histogram *fh; }; int graphics_init_sdl(struct fft_app *fap) @@ -236,7 +237,7 @@ fft_eval_cb(struct radar_entry *re, void pthread_mutex_lock(&fap->mtx_histogram); for (i = 0; i < re->re_num_spectral_entries; i++) { - fft_add_sample(re, &re->re_spectral_entries[i]); + fft_add_sample(fap->fh, re, &re->re_spectral_entries[i]); } fap->g_do_update = 1; pthread_mutex_unlock(&fap->mtx_histogram); @@ -261,6 +262,11 @@ int main(int argc, char *argv[]) errx(127, "calloc"); } + /* Setup histogram data */ + fap->fh = fft_histogram_init(); + if (! fap->fh) + exit(127); + /* Setup radar entry callback */ pthread_mutex_init(&fap->mtx_histogram, NULL); set_scandata_callback(fft_eval_cb, fap); @@ -274,7 +280,7 @@ int main(int argc, char *argv[]) /* Setup fft display */ - fap->fdisp = fft_display_create(fap->screen, fap->font); + fap->fdisp = fft_display_create(fap->screen, fap->font, fap->fh); if (fap->fdisp == NULL) exit(127); Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Wed Jan 9 20:27:38 2013 (r245239) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.c Wed Jan 9 20:39:29 2013 (r245240) @@ -19,18 +19,24 @@ #include "fft_histogram.h" -struct fft_histogram_data fdata; - /* XXX ew */ #define SPECTRAL_HT20_NUM_BINS 56 -void +struct fft_histogram * fft_histogram_init(void) { - bzero(&fdata, sizeof(fdata)); + struct fft_histogram *fh; + + fh = calloc(1, sizeof(*fh)); + if (fh == NULL) { + warn("%s: calloc", __func__); + return (NULL); + } + + return (fh); } -int +static int freq2fidx(int freqKhz) { int freqMhz = freqKhz / 1000; @@ -53,7 +59,8 @@ freq2fidx(int freqKhz) } void -fft_add_sample(struct radar_entry *re, struct radar_fft_entry *fe) +fft_add_sample(struct fft_histogram *fh, struct radar_entry *re, + struct radar_fft_entry *fe) { float ffreq; int i; @@ -75,25 +82,25 @@ fft_add_sample(struct radar_entry *re, s continue; /* Rolling/decaying average */ - cur = fdata.avg_pts_cur[fidx]; - if (fdata.avg_pts[fidx][cur] == 0) { - fdata.avg_pts[fidx][cur] = fe->pri.bins[i].dBm; + cur = fh->d.avg_pts_cur[fidx]; + if (fh->d.avg_pts[fidx][cur] == 0) { + fh->d.avg_pts[fidx][cur] = fe->pri.bins[i].dBm; } else { - fdata.avg_pts[fidx][cur] = (((fdata.avg_pts[fidx][cur] * 100) / 90) + fe->pri.bins[i].dBm) / 2; + fh->d.avg_pts[fidx][cur] = (((fh->d.avg_pts[fidx][cur] * 100) / 90) + fe->pri.bins[i].dBm) / 2; } - fdata.avg_pts_cur[fidx] = (fdata.avg_pts_cur[fidx] + 1) % FFT_HISTOGRAM_HISTORY_DEPTH; + fh->d.avg_pts_cur[fidx] = (fh->d.avg_pts_cur[fidx] + 1) % FFT_HISTOGRAM_HISTORY_DEPTH; /* Max */ - if (fdata.max_pts[fidx] == 0 || fe->pri.bins[i].dBm > fdata.max_pts[fidx]) { - fdata.max_pts[fidx] = fe->pri.bins[i].dBm; + if (fh->d.max_pts[fidx] == 0 || fe->pri.bins[i].dBm > fh->d.max_pts[fidx]) { + fh->d.max_pts[fidx] = fe->pri.bins[i].dBm; } else { - fdata.max_pts[fidx] = ((fdata.max_pts[fidx] * 975) + (fe->pri.bins[i].dBm * 25)) / 1000; + fh->d.max_pts[fidx] = ((fh->d.max_pts[fidx] * 975) + (fe->pri.bins[i].dBm * 25)) / 1000; } } } int16_t * -fft_fetch_freq_avg(int freqKhz) +fft_fetch_freq_avg(struct fft_histogram *fh, int freqKhz) { int fidx; @@ -101,11 +108,11 @@ fft_fetch_freq_avg(int freqKhz) if (fidx < 0) return NULL; - return fdata.avg_pts[fidx]; + return fh->d.avg_pts[fidx]; } int16_t -fft_fetch_freq_max(int freqKhz) +fft_fetch_freq_max(struct fft_histogram *fh, int freqKhz) { int fidx; @@ -113,5 +120,5 @@ fft_fetch_freq_max(int freqKhz) if (fidx < 0) return -180; /* XXX */ - return fdata.max_pts[fidx]; + return fh->d.max_pts[fidx]; } Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Wed Jan 9 20:27:38 2013 (r245239) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_histogram.h Wed Jan 9 20:39:29 2013 (r245240) @@ -18,10 +18,14 @@ struct fft_histogram_data { int16_t max_pts[FFT_HISTOGRAM_SIZE]; }; -extern void fft_histogram_init(void); -extern void fft_add_sample(struct radar_entry *re, - struct radar_fft_entry *fe); -extern int16_t * fft_fetch_freq_avg(int freqKhz); -extern int16_t fft_fetch_freq_max(int freqKhz); +struct fft_histogram { + struct fft_histogram_data d; +}; + +extern struct fft_histogram * fft_histogram_init(void); +extern void fft_add_sample(struct fft_histogram *, + struct radar_entry *re, struct radar_fft_entry *fe); +extern int16_t * fft_fetch_freq_avg(struct fft_histogram *, int freqKhz); +extern int16_t fft_fetch_freq_max(struct fft_histogram *, int freqKhz); #endif From owner-svn-src-user@FreeBSD.ORG Wed Jan 9 21:19:01 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6EAA7A68; Wed, 9 Jan 2013 21:19:01 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5F896EAC; Wed, 9 Jan 2013 21:19:01 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r09LJ1Bo025916; Wed, 9 Jan 2013 21:19:01 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r09LJ10f025915; Wed, 9 Jan 2013 21:19:01 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301092119.r09LJ10f025915@svn.freebsd.org> From: Adrian Chadd Date: Wed, 9 Jan 2013 21:19:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245242 - user/adrian/ath_radar_stuff/src/spectral_fft X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jan 2013 21:19:01 -0000 Author: adrian Date: Wed Jan 9 21:19:00 2013 New Revision: 245242 URL: http://svnweb.freebsd.org/changeset/base/245242 Log: Break out the rendering into a timer-based event, rather than as part of the main loop. The rendering is still done in the main loop, but it's done as a response to a posted timer event. This removes the whole "just keep running and chewing CPU" hack that was going on before. Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c ============================================================================== --- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 21:07:08 2013 (r245241) +++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Wed Jan 9 21:19:00 2013 (r245242) @@ -49,13 +49,23 @@ #include "fft_histogram.h" #include "fft_display.h" +/* 10 a second for now, the rendering is too inefficient otherwise? */ +#define RENDER_PERIOD_MSEC 100 + +#define LCL_EVENT_RENDER 69 + struct fft_app { pthread_mutex_t mtx_histogram; - int g_do_update; SDL_Surface *screen; + SDL_TimerID rendering_timer_id; + int g_do_update; TTF_Font *font; struct fft_display *fdisp; struct fft_histogram *fh; + int highlight_freq; + int startfreq; + int accel; + int scroll; }; int graphics_init_sdl(struct fft_app *fap) @@ -107,6 +117,63 @@ void graphics_quit_sdl(void) SDL_Quit(); } +static void +graphics_render(struct fft_app *fap) +{ + +// printf("render: %d MHz\n", fap->startfreq); + + if (!fap->scroll) { + /* move to highlighted object */ + if (fap->highlight_freq - 20 < fap->startfreq) + fap->accel = -10; + if (fap->highlight_freq > (fap->startfreq + WIDTH/X_SCALE)) + fap->accel = 10; + + /* if we are "far off", move a little bit faster */ + if (fap->highlight_freq + 300 < fap->startfreq) + fap->accel = -100; + + if (fap->highlight_freq - 300 > (fap->startfreq + WIDTH/X_SCALE)) + fap->accel = 100; + } + + if (fap->accel) { + fap->startfreq += fap->accel; + if (fap->accel > 0) + fap->accel--; + if (fap->accel < 0) + fap->accel++; + } + + /* Cap rendering offset */ + if (fap->startfreq < 2300) + fap->startfreq = 2300; + if (fap->startfreq > 6000) + fap->startfreq = 6000; + + /* .. and now, render */ + fft_display_draw_picture(fap->fdisp, fap->highlight_freq, + fap->startfreq); + +} + +static uint32_t +graphics_draw_event(uint32_t interval, void *cbdata) +{ + struct fft_app *fap = cbdata; + SDL_Event event; + + event.type = SDL_USEREVENT; + event.user.code = LCL_EVENT_RENDER; + event.user.data1 = 0; + event.user.data2 = 0; + + SDL_PushEvent(&event); + + return (RENDER_PERIOD_MSEC); +} + /* * graphics_main - sets up the data and holds the mainloop. * @@ -115,98 +182,54 @@ void graphics_main(struct fft_app *fap) { SDL_Event event; int quit = 0; - int highlight = 0; - int change = 1, scroll = 0; - int startfreq = 2350, accel = 0; - int highlight_freq = startfreq; while (!quit) { - pthread_mutex_lock(&fap->mtx_histogram); - if (fap->g_do_update == 1) { - change = 1; /* XXX always render */ - fap->g_do_update = 0; - } - pthread_mutex_unlock(&fap->mtx_histogram); - - if (change) { - highlight_freq = fft_display_draw_picture(fap->fdisp, - highlight, startfreq); - change = 0; - } - - if (!scroll) { - /* move to highlighted object */ - if (highlight_freq - 20 < startfreq) - accel = -10; - if (highlight_freq > (startfreq + WIDTH/X_SCALE)) - accel = 10; - - /* if we are "far off", move a little bit faster */ - if (highlight_freq + 300 < startfreq) - accel = -100; - - if (highlight_freq - 300 > (startfreq + WIDTH/X_SCALE)) - accel = 100; - } -// if (accel) - SDL_PollEvent(&event); -// else -// SDL_WaitEvent(&event); + /* Wait for the next event */ + SDL_WaitEvent(&event); switch (event.type) { + case SDL_USEREVENT: + switch (event.user.code) { + case LCL_EVENT_RENDER: + graphics_render(fap); + break; + default: + break; + } + break; case SDL_QUIT: quit = 1; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { -#if 0 case SDLK_LEFT: - if (highlight > 0) { - highlight--; - scroll = 0; - change = 1; - } + fap->accel-= 2; + fap->scroll = 1; break; case SDLK_RIGHT: - if (highlight < scanresults_n - 1){ - highlight++; - scroll = 0; - change = 1; - } - break; -#endif - case SDLK_LEFT: - accel-= 2; - scroll = 1; - break; - case SDLK_RIGHT: - accel+= 2; - scroll = 1; + fap->accel+= 2; + fap->scroll = 1; break; case SDLK_HOME: - startfreq = 2300; - accel = 0; + fap->startfreq = 2300; + fap->accel = 0; break; case SDLK_END: - startfreq = 5100; - accel = 0; + fap->startfreq = 5100; + fap->accel = 0; break; default: break; } break; } - if (accel) { - startfreq += accel; - if (accel > 0) accel--; - if (accel < 0) accel++; - change = 1; - } - if (startfreq < 2300) startfreq = 2300; - if (startfreq > 6000) startfreq = 6000; - if (accel < -40) accel = -40; - if (accel > 40) accel = 40; + + /* Cap acceleration */ + if (fap->accel < -40) + fap->accel = -40; + if (fap->accel > 40) + fap->accel = 40; } } @@ -262,6 +285,10 @@ int main(int argc, char *argv[]) errx(127, "calloc"); } + /* Setup rendering details */ + fap->startfreq = 2350; + fap->highlight_freq = 2350; + /* Setup histogram data */ fap->fh = fft_histogram_init(); if (! fap->fh) @@ -279,19 +306,22 @@ int main(int argc, char *argv[]) SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); /* Setup fft display */ - fap->fdisp = fft_display_create(fap->screen, fap->font, fap->fh); if (fap->fdisp == NULL) exit(127); /* Fetch data */ ret = read_scandata_freebsd(argv[1], NULL); - if (ret < 0) { fprintf(stderr, "Couldn't read scanfile ...\n"); usage(argc, argv); return -1; } + + /* Begin rendering timer */ + fap->rendering_timer_id = SDL_AddTimer(RENDER_PERIOD_MSEC, + graphics_draw_event, fap); + graphics_main(fap); graphics_quit_sdl(); From owner-svn-src-user@FreeBSD.ORG Thu Jan 10 12:30:59 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9E00B1BC; Thu, 10 Jan 2013 12:30:59 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 81CA4A90; Thu, 10 Jan 2013 12:30:59 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0ACUx05087516; Thu, 10 Jan 2013 12:30:59 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0ACUxTG087512; Thu, 10 Jan 2013 12:30:59 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201301101230.r0ACUxTG087512@svn.freebsd.org> From: Attilio Rao Date: Thu, 10 Jan 2013 12:30:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245254 - user/attilio/vmc-playground/sys/vm X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jan 2013 12:30:59 -0000 Author: attilio Date: Thu Jan 10 12:30:58 2013 New Revision: 245254 URL: http://svnweb.freebsd.org/changeset/base/245254 Log: Remove vm_radix_lookupn() and its usage in the kernel. Modified: user/attilio/vmc-playground/sys/vm/vm_object.c user/attilio/vmc-playground/sys/vm/vm_radix.c user/attilio/vmc-playground/sys/vm/vm_radix.h Modified: user/attilio/vmc-playground/sys/vm/vm_object.c ============================================================================== --- user/attilio/vmc-playground/sys/vm/vm_object.c Thu Jan 10 12:25:00 2013 (r245253) +++ user/attilio/vmc-playground/sys/vm/vm_object.c Thu Jan 10 12:30:58 2013 (r245254) @@ -96,7 +96,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define VM_RADIX_STACK 8 /* Nodes to store on stack for ranged ops. */ +#define VM_PINDEX_MAX ((vm_pindex_t)(-1)) static int old_msync; SYSCTL_INT(_vm, OID_AUTO, old_msync, CTLFLAG_RW, &old_msync, 0, @@ -679,12 +679,9 @@ vm_object_destroy(vm_object_t object) void vm_object_terminate(vm_object_t object) { - vm_page_t pa[VM_RADIX_STACK]; - vm_page_t p; + vm_page_t p, p_next; vm_pindex_t start; struct vnode *vp; - u_int exhausted; - int n, i; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); @@ -729,67 +726,53 @@ vm_object_terminate(vm_object_t object) * from the object. Rather than incrementally removing each page from * the object, the page and object are reset to any empty state. */ - start = 0; - exhausted = 0; - n = VM_RADIX_STACK; - while (n == VM_RADIX_STACK && exhausted == 0 && - (n = vm_radix_lookupn(&object->rtree, start, 0, (void **)pa, - VM_RADIX_STACK, &start, &exhausted)) != 0) { - for (i = 0; i < n; i++) { - p = pa[i]; - KASSERT(!p->busy && (p->oflags & VPO_BUSY) == 0, - ("vm_object_terminate: freeing busy page %p", p)); - vm_page_lock(p); - - /* - * Optimize the page's removal from the object by - * resetting its "object" field. Specifically, if - * the page is not wired, then the effect of this - * assignment is that vm_page_free()'s call to - * vm_page_remove() will return immediately without - * modifying the page or the object. - * Anyway, the radix tree cannot be accessed anymore - * from within the object, thus all the nodes need - * to be reclaimed later on. - */ - p->object = NULL; - if (p->wire_count == 0) { - vm_page_free(p); - PCPU_INC(cnt.v_pfree); - } - vm_page_unlock(p); + TAILQ_FOREACH_SAFE(p, &object->memq, listq, p_next) { + KASSERT(!p->busy && (p->oflags & VPO_BUSY) == 0, + ("vm_object_terminate: freeing busy page %p", p)); + vm_page_lock(p); + /* + * Optimize the page's removal from the object by resetting + * its "object" field. Specifically, if the page is not + * wired, then the effect of this assignment is that + * vm_page_free()'s call to vm_page_remove() will return + * immediately without modifying the page or the object. + */ + p->object = NULL; + if (p->wire_count == 0) { + vm_page_free(p); + PCPU_INC(cnt.v_pfree); } + vm_page_unlock(p); } vm_radix_reclaim_allnodes(&object->rtree); vp = NULL; if (!vm_object_cache_is_empty(object)) { - mtx_lock(&vm_page_queue_free_mtx); start = 0; - exhausted = 0; - n = VM_RADIX_STACK; - while (n == VM_RADIX_STACK && exhausted == 0 && - (n = vm_radix_lookupn(&object->cache, start, 0, - (void **)pa, VM_RADIX_STACK, &start, &exhausted)) != 0) { - for (i = 0; i < n; i++) { - p = pa[i]; - MPASS(p->object == object); - p->object = NULL; - p->valid = 0; + mtx_lock(&vm_page_queue_free_mtx); + while ((p = vm_radix_lookup_ge(&object->cache, + start)) != NULL) { + MPASS(p->object == object); + p->object = NULL; + p->valid = 0; - /* Clear PG_CACHED and set PG_FREE. */ - p->flags ^= PG_CACHED | PG_FREE; - cnt.v_cache_count--; - cnt.v_free_count++; + /* Clear PG_CACHED and set PG_FREE. */ + p->flags ^= PG_CACHED | PG_FREE; + cnt.v_cache_count--; + cnt.v_free_count++; - /* - * At least one cached page was removed and - * in the end all the cached pages will be - * reclaimed. If the object is a vnode, - * drop a reference to it. - */ - if (object->type == OBJT_VNODE) - vp = object->handle; - } + /* + * At least one cached page was removed and + * in the end all the cached pages will be + * reclaimed. If the object is a vnode, + * drop a reference to it. + */ + if (object->type == OBJT_VNODE) + vp = object->handle; + + /* Point to the next available index. */ + if (p->pindex == VM_PINDEX_MAX) + break; + start = p->pindex + 1; } vm_radix_reclaim_allnodes(&object->cache); mtx_unlock(&vm_page_queue_free_mtx); @@ -1328,13 +1311,10 @@ vm_object_shadow( void vm_object_split(vm_map_entry_t entry) { - vm_page_t ma[VM_RADIX_STACK]; - vm_page_t m; + vm_page_t m, m_next; vm_object_t orig_object, new_object, source; vm_pindex_t idx, offidxstart, start; vm_size_t size; - u_int exhausted; - int i, n; orig_object = entry->object.vm_object; if (orig_object->type != OBJT_DEFAULT && orig_object->type != OBJT_SWAP) @@ -1387,60 +1367,46 @@ vm_object_split(vm_map_entry_t entry) ("orig_object->charge < 0")); orig_object->charge -= ptoa(size); } - start = offidxstart; retry: - exhausted = 0; - n = VM_RADIX_STACK; - while (n == VM_RADIX_STACK && exhausted == 0 && - (n = vm_radix_lookupn(&orig_object->rtree, start, - offidxstart + size, (void **)ma, VM_RADIX_STACK, &start, - &exhausted)) != 0) { - for (i = 0; i < n; i++) { - m = ma[i]; - idx = m->pindex - offidxstart; + m = vm_page_find_least(orig_object, offidxstart); + for (; m != NULL && (idx = m->pindex - offidxstart) < size; + m = m_next) { + m_next = TAILQ_NEXT(m, listq); - /* - * We must wait for pending I/O to complete before - * we can rename the page. - * - * We do not have to VM_PROT_NONE the page as mappings - * should not be changed by this operation. - */ - if ((m->oflags & VPO_BUSY) || m->busy) { - start = m->pindex; - VM_OBJECT_UNLOCK(new_object); - m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(orig_object), PVM, - "spltwt", 0); - VM_OBJECT_LOCK(new_object); - goto retry; - } + /* + * We must wait for pending I/O to complete before we can + * rename the page. + * + * We do not have to VM_PROT_NONE the page as mappings should + * not be changed by this operation. + */ + if ((m->oflags & VPO_BUSY) || m->busy) { + VM_OBJECT_UNLOCK(new_object); + m->oflags |= VPO_WANTED; + msleep(m, VM_OBJECT_MTX(orig_object), PVM, "spltwt", 0); + VM_OBJECT_LOCK(new_object); + goto retry; + } #if VM_NRESERVLEVEL > 0 - /* - * If some of the reservation's allocated pages remain - * with the original object, then transferring the - * reservation to the new object is neither - * particularly beneficial nor particularly harmful as - * compared to leaving the reservation with the - * original object. If, however, all of the - * reservation's allocated pages are transferred to - * the new object, then transferring the reservation - * is typically beneficial. Determining which of - * these two cases applies would be more costly than - * unconditionally renaming the reservation. - */ - vm_reserv_rename(m, new_object, orig_object, - offidxstart); + /* + * If some of the reservation's allocated pages remain with + * the original object, then transferring the reservation to + * the new object is neither particularly beneficial nor + * particularly harmful as compared to leaving the reservation + * with the original object. If, however, all of the + * reservation's allocated pages are transferred to the new + * object, then transferring the reservation is typically + * beneficial. Determining which of these two cases applies + * would be more costly than unconditionally renaming the + * reservation. + */ + vm_reserv_rename(m, new_object, orig_object, offidxstart); #endif - vm_page_lock(m); - vm_page_rename(m, new_object, idx); - vm_page_unlock(m); - /* - * page automatically made dirty by rename and - * cache handled - */ - vm_page_busy(m); - } + vm_page_lock(m); + vm_page_rename(m, new_object, idx); + vm_page_unlock(m); + /* page automatically made dirty by rename and cache handled */ + vm_page_busy(m); } if (orig_object->type == OBJT_SWAP) { /* @@ -1460,19 +1426,13 @@ retry: */ if (!vm_object_cache_is_empty(orig_object)) { start = offidxstart; - exhausted = 0; - n = VM_RADIX_STACK; mtx_lock(&vm_page_queue_free_mtx); - while (n == VM_RADIX_STACK && exhausted == 0 && - (n = vm_radix_lookupn(&orig_object->cache, start, - offidxstart + size, (void **)ma, VM_RADIX_STACK, - &start, &exhausted)) != 0) { - for (i = 0; i < n; i++) { - m = ma[i]; - idx = m->pindex - offidxstart; - vm_page_cache_rename(m, new_object, - idx); - } + while ((m = vm_radix_lookup_ge(&orig_object->cache, + start)) != NULL) { + if (m->pindex >= (offidxstart + size)) + break; + idx = m->pindex - offidxstart; + vm_page_cache_rename(m, new_object, idx); } mtx_unlock(&vm_page_queue_free_mtx); } @@ -1494,14 +1454,10 @@ retry: static int vm_object_backing_scan(vm_object_t object, int op) { - vm_page_t pa[VM_RADIX_STACK]; + int r = 1; vm_page_t p; vm_object_t backing_object; - vm_pindex_t backing_offset_index, new_pindex; - vm_pindex_t start; - u_int exhausted; - int i, n; - int r = 1; + vm_pindex_t backing_offset_index; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); VM_OBJECT_LOCK_ASSERT(object->backing_object, MA_OWNED); @@ -1529,25 +1485,15 @@ vm_object_backing_scan(vm_object_t objec if (op & OBSC_COLLAPSE_WAIT) { vm_object_set_flag(backing_object, OBJ_DEAD); } + /* * Our scan */ -restart: - start = 0; - i = n = VM_RADIX_STACK; - exhausted = 0; - for (;;) { - if (i == n) { - if (n < VM_RADIX_STACK || exhausted != 0 || - (n = vm_radix_lookupn(&backing_object->rtree, - start, 0, (void **)pa, VM_RADIX_STACK, - &start, &exhausted)) == 0) - break; - i = 0; - } - p = pa[i++]; + p = TAILQ_FIRST(&backing_object->memq); + while (p) { + vm_page_t next = TAILQ_NEXT(p, listq); + vm_pindex_t new_pindex = p->pindex - backing_offset_index; - new_pindex = p->pindex - backing_offset_index; if (op & OBSC_TEST_ALL_SHADOWED) { vm_page_t pp; @@ -1559,9 +1505,13 @@ restart: * note that we do not busy the backing object's * page. */ - if (p->pindex < backing_offset_index || - new_pindex >= object->size) + if ( + p->pindex < backing_offset_index || + new_pindex >= object->size + ) { + p = next; continue; + } /* * See if the parent has the page or if the parent's @@ -1590,9 +1540,12 @@ restart: vm_page_t pp; if (op & OBSC_COLLAPSE_NOWAIT) { - if ((p->oflags & VPO_BUSY) || !p->valid || - p->busy) + if ((p->oflags & VPO_BUSY) || + !p->valid || + p->busy) { + p = next; continue; + } } else if (op & OBSC_COLLAPSE_WAIT) { if ((p->oflags & VPO_BUSY) || p->busy) { VM_OBJECT_UNLOCK(object); @@ -1608,7 +1561,8 @@ restart: * should not have changed so we * just restart our scan. */ - goto restart; + p = TAILQ_FIRST(&backing_object->memq); + continue; } } @@ -1644,6 +1598,7 @@ restart: else vm_page_remove(p); vm_page_unlock(p); + p = next; continue; } @@ -1663,6 +1618,7 @@ restart: * page before we can (re)lock the parent. * Hence we can get here. */ + p = next; continue; } if ( @@ -1684,6 +1640,7 @@ restart: else vm_page_remove(p); vm_page_unlock(p); + p = next; continue; } @@ -1707,6 +1664,7 @@ restart: vm_page_unlock(p); /* page automatically made dirty by rename */ } + p = next; } return (r); } @@ -1741,10 +1699,8 @@ vm_object_qcollapse(vm_object_t object) void vm_object_collapse(vm_object_t object) { - vm_page_t pa[VM_RADIX_STACK]; - vm_pindex_t start; - u_int exhausted; - int i, n; + vm_page_t p; + vm_pindex_t start, tmpindex; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); @@ -1833,17 +1789,20 @@ vm_object_collapse(vm_object_t object) * backing_object. */ start = 0; - exhausted = 0; - n = VM_RADIX_STACK; mtx_lock(&vm_page_queue_free_mtx); - while (n == VM_RADIX_STACK && - exhausted == 0 && (n = - vm_radix_lookupn(&backing_object->cache, - start, 0, (void **)pa, - VM_RADIX_STACK, &start, - &exhausted)) != 0) { - for (i = 0; i < n; i++) - vm_page_cache_free(pa[i]); + while ((p = + vm_radix_lookup_ge(&backing_object->cache, + start)) != NULL) { + tmpindex = p->pindex; + vm_page_cache_free(p); + + /* + * Point to the next available + * index. + */ + if (tmpindex == VM_PINDEX_MAX) + break; + start = tmpindex + 1; } mtx_unlock(&vm_page_queue_free_mtx); } @@ -1969,102 +1928,92 @@ vm_object_page_remove(vm_object_t object int options) { struct vnode *vp; - vm_page_t pa[VM_RADIX_STACK]; - vm_pindex_t cstart; - vm_page_t p; - u_int exhausted; - int i, n; + vm_page_t p, next; int wirings; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); KASSERT((object->type != OBJT_DEVICE && object->type != OBJT_PHYS) || (options & (OBJPR_CLEANONLY | OBJPR_NOTMAPPED)) == OBJPR_NOTMAPPED, ("vm_object_page_remove: illegal options for object %p", object)); - if (object->resident_page_count == 0 && - vm_object_cache_is_empty(object)) - return; - vp = NULL; + if (object->resident_page_count == 0) { + if (vm_object_cache_is_empty(object)) + return; + goto skipmemq; + } vm_object_pip_add(object, 1); - cstart = start; -restart: - exhausted = 0; - n = VM_RADIX_STACK; - while (n == VM_RADIX_STACK && exhausted == 0 && - (n = vm_radix_lookupn(&object->rtree, start, end, (void **)pa, - VM_RADIX_STACK, &start, &exhausted)) != 0) { - for (i = 0; i < n; i++) { - p = pa[i]; - - /* - * If the page is wired for any reason besides - * the existence of managed, wired mappings, then - * it cannot be freed. For example, fictitious - * pages, which represent device memory, are - * inherently wired and cannot be freed. They can, - * however, be invalidated if the option - * OBJPR_CLEANONLY is not specified. - */ - vm_page_lock(p); - if ((wirings = p->wire_count) != 0 && - (wirings = pmap_page_wired_mappings(p)) != - p->wire_count) { - if ((options & OBJPR_NOTMAPPED) == 0) { - pmap_remove_all(p); - /* - * Account for removal of wired - * mappings. - */ - if (wirings != 0) - p->wire_count -= wirings; - } - if ((options & OBJPR_CLEANONLY) == 0) { - p->valid = 0; - vm_page_undirty(p); - } - vm_page_unlock(p); - continue; - } - if (vm_page_sleep_if_busy(p, TRUE, "vmopar")) { - start = p->pindex; - goto restart; - } - KASSERT((p->flags & PG_FICTITIOUS) == 0, - ("vm_object_page_remove: page %p is fictitious", - p)); - if ((options & OBJPR_CLEANONLY) != 0 && p->valid != 0) { - if ((options & OBJPR_NOTMAPPED) == 0) - pmap_remove_write(p); - if (p->dirty) { - vm_page_unlock(p); - continue; - } - } +again: + p = vm_page_find_least(object, start); + + /* + * Here, the variable "p" is either (1) the page with the least pindex + * greater than or equal to the parameter "start" or (2) NULL. + */ + for (; p != NULL && (p->pindex < end || end == 0); p = next) { + next = TAILQ_NEXT(p, listq); + + /* + * If the page is wired for any reason besides the existence + * of managed, wired mappings, then it cannot be freed. For + * example, fictitious pages, which represent device memory, + * are inherently wired and cannot be freed. They can, + * however, be invalidated if the option OBJPR_CLEANONLY is + * not specified. + */ + vm_page_lock(p); + if ((wirings = p->wire_count) != 0 && + (wirings = pmap_page_wired_mappings(p)) != p->wire_count) { if ((options & OBJPR_NOTMAPPED) == 0) { pmap_remove_all(p); /* Account for removal of wired mappings. */ if (wirings != 0) p->wire_count -= wirings; } - vm_page_free(p); + if ((options & OBJPR_CLEANONLY) == 0) { + p->valid = 0; + vm_page_undirty(p); + } vm_page_unlock(p); + continue; + } + if (vm_page_sleep_if_busy(p, TRUE, "vmopar")) + goto again; + KASSERT((p->flags & PG_FICTITIOUS) == 0, + ("vm_object_page_remove: page %p is fictitious", p)); + if ((options & OBJPR_CLEANONLY) != 0 && p->valid != 0) { + if ((options & OBJPR_NOTMAPPED) == 0) + pmap_remove_write(p); + if (p->dirty) { + vm_page_unlock(p); + continue; + } + } + if ((options & OBJPR_NOTMAPPED) == 0) { + pmap_remove_all(p); + /* Account for removal of wired mappings. */ + if (wirings != 0) { + KASSERT(p->wire_count == wirings, + ("inconsistent wire count %d %d %p", + p->wire_count, wirings, p)); + p->wire_count = 0; + atomic_subtract_int(&cnt.v_wire_count, 1); + } } + vm_page_free(p); + vm_page_unlock(p); } vm_object_pip_wakeup(object); +skipmemq: + vp = NULL; if (!vm_object_cache_is_empty(object)) { - start = cstart; - exhausted = 0; - n = VM_RADIX_STACK; mtx_lock(&vm_page_queue_free_mtx); - while (n == VM_RADIX_STACK && exhausted == 0 && - (n = vm_radix_lookupn(&object->cache, start, end, - (void **)pa, VM_RADIX_STACK, &start, &exhausted)) != 0) { - for (i = 0; i < n; i++) { - p = pa[i]; - vm_page_cache_free(p); - if (vm_object_cache_is_empty(object) && - object->type == OBJT_VNODE) - vp = object->handle; - } + while ((p = vm_radix_lookup_ge(&object->cache, + start)) != NULL) { + if (p->pindex >= end) + break; + vm_page_cache_free(p); + if (vm_object_cache_is_empty(object) && + object->type == OBJT_VNODE) + vp = object->handle; } mtx_unlock(&vm_page_queue_free_mtx); } Modified: user/attilio/vmc-playground/sys/vm/vm_radix.c ============================================================================== --- user/attilio/vmc-playground/sys/vm/vm_radix.c Thu Jan 10 12:25:00 2013 (r245253) +++ user/attilio/vmc-playground/sys/vm/vm_radix.c Thu Jan 10 12:30:58 2013 (r245254) @@ -477,7 +477,7 @@ vm_radix_lookup(struct vm_radix *rtree, * the index of the first valid item in the leaf in *startp. */ static struct vm_radix_node * -vm_radix_leaf(struct vm_radix *rtree, vm_pindex_t *startp, vm_pindex_t end) +vm_radix_leaf(struct vm_radix *rtree, vm_pindex_t *startp) { struct vm_radix_node *rnode; vm_pindex_t start; @@ -488,13 +488,13 @@ vm_radix_leaf(struct vm_radix *rtree, vm start = *startp; restart: level = vm_radix_height(rtree, &rnode); - if (start > VM_RADIX_MAX(level) || (end && start >= end)) { + if (start > VM_RADIX_MAX(level)) { rnode = NULL; goto out; } /* * Search the tree from the top for any leaf node holding an index - * between start and end. + * between start and maxval. */ for (level--; level; level--) { slot = vm_radix_slot(start, level); @@ -524,16 +524,12 @@ restart: } start += inc; slot++; - CTR6(KTR_VM, - "leaf: " KFRMT64(start) ", " KFRMT64(end) ", " KFRMT64(inc), - KSPLT64L(start), KSPLT64H(start), KSPLT64L(end), - KSPLT64H(end), KSPLT64L(inc), KSPLT64H(inc)); + CTR4(KTR_VM, + "leaf: " KFRMT64(start) ", " KFRMT64(inc), + KSPLT64L(start), KSPLT64H(start), KSPLT64L(inc), + KSPLT64H(inc)); CTR2(KTR_VM, "leaf: level %d, slot %d", level, slot); for (; slot < VM_RADIX_COUNT; slot++, start += inc) { - if (end != 0 && start >= end) { - rnode = NULL; - goto out; - } if (rnode->rn_child[slot]) { rnode = rnode->rn_child[slot]; break; @@ -552,35 +548,23 @@ out: return (rnode); } - - /* - * Looks up as many as cnt values between start and end, and stores - * them in the caller allocated array out. The next index can be used - * to restart the scan. This optimizes forward scans in the tree. + * Look up any entry at a position bigger than or equal to index. */ -int -vm_radix_lookupn(struct vm_radix *rtree, vm_pindex_t start, - vm_pindex_t end, void **out, int cnt, vm_pindex_t *next, u_int *exhausted) +void * +vm_radix_lookup_ge(struct vm_radix *rtree, vm_pindex_t start) { struct vm_radix_node *rnode; void *val; int slot; - int outidx; - CTR5(KTR_VM, "lookupn: tree %p, " KFRMT64(start) ", " KFRMT64(end), - rtree, KSPLT64L(start), KSPLT64H(start), KSPLT64L(end), - KSPLT64H(end)); - if (end == 0) - *exhausted = 0; + CTR3(KTR_VM, "lookupn: tree %p, " KFRMT64(start), rtree, + KSPLT64L(start), KSPLT64H(start)); if (rtree->rt_root == 0) - return (0); - outidx = 0; - while ((rnode = vm_radix_leaf(rtree, &start, end)) != NULL) { + return (NULL); + while ((rnode = vm_radix_leaf(rtree, &start)) != NULL) { slot = vm_radix_slot(start, 0); for (; slot < VM_RADIX_COUNT; slot++, start++) { - if (end != 0 && start >= end) - goto out; val = vm_radix_match(rnode->rn_child[slot]); if (val == NULL) { @@ -595,33 +579,18 @@ vm_radix_lookupn(struct vm_radix *rtree, * be done after all the necessary controls * on start are completed. */ - if ((VM_RADIX_MAXVAL - start) == 0) { - start++; - if (end == 0) - *exhausted = 1; - goto out; - } + if ((VM_RADIX_MAXVAL - start) == 0) + return (NULL); continue; } CTR5(KTR_VM, "lookupn: tree %p " KFRMT64(index) " slot %d found child %p", rtree, KSPLT64L(start), KSPLT64H(start), slot, val); - out[outidx] = val; - if (++outidx == cnt || - (VM_RADIX_MAXVAL - start) == 0) { - start++; - if ((VM_RADIX_MAXVAL - start) == 0 && end == 0) - *exhausted = 1; - goto out; - } + return (val); } MPASS((VM_RADIX_MAXVAL - start) != 0); - if (end != 0 && start >= end) - break; } -out: - *next = start; - return (outidx); + return (NULL); } /* Modified: user/attilio/vmc-playground/sys/vm/vm_radix.h ============================================================================== --- user/attilio/vmc-playground/sys/vm/vm_radix.h Thu Jan 10 12:25:00 2013 (r245253) +++ user/attilio/vmc-playground/sys/vm/vm_radix.h Thu Jan 10 12:30:58 2013 (r245254) @@ -42,25 +42,10 @@ struct vm_radix { void vm_radix_init(void); int vm_radix_insert(struct vm_radix *, vm_pindex_t, void *); void *vm_radix_lookup(struct vm_radix *, vm_pindex_t); -int vm_radix_lookupn(struct vm_radix *, vm_pindex_t, vm_pindex_t, void **, - int, vm_pindex_t *, u_int *); +void *vm_radix_lookup_ge(struct vm_radix *, vm_pindex_t); void *vm_radix_lookup_le(struct vm_radix *, vm_pindex_t); void vm_radix_reclaim_allnodes(struct vm_radix *); void vm_radix_remove(struct vm_radix *, vm_pindex_t); -/* - * Look up any entry at a position greater or equal to index. - */ -static inline void * -vm_radix_lookup_ge(struct vm_radix *rtree, vm_pindex_t index) -{ - void *val; - u_int dummy; - - if (vm_radix_lookupn(rtree, index, 0, &val, 1, &index, &dummy)) - return (val); - return (NULL); -} - #endif /* _KERNEL */ #endif /* !_VM_RADIX_H_ */ From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 09:20:34 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 522EEC47; Fri, 11 Jan 2013 09:20:34 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1475BB54; Fri, 11 Jan 2013 09:20:34 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0B9KXa7044346; Fri, 11 Jan 2013 09:20:33 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0B9KXxu044345; Fri, 11 Jan 2013 09:20:33 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301110920.r0B9KXxu044345@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 09:20:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245292 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 09:20:34 -0000 Author: pho Date: Fri Jan 11 09:20:33 2013 New Revision: 245292 URL: http://svnweb.freebsd.org/changeset/base/245292 Log: Added a "umount -f" test scenario for nullfs. Added: user/pho/stress2/misc/nullfs12.sh (contents, props changed) Added: user/pho/stress2/misc/nullfs12.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/nullfs12.sh Fri Jan 11 09:20:33 2013 (r245292) @@ -0,0 +1,66 @@ +#!/bin/sh + +# +# Copyright (c) 2013 Peter Holm +# 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# "umount -f" test with files open for writing +# "panic: vputx: missed vn_close" seen. +# Scenario by kib@. Fixed in r245262. + +. ../default.cfg + +mnt2=/mnt2 +mount | grep -q $mnt2 && umount $mnt2 + +[ -d $mnt2 ] || mkdir $mnt2 +mount | grep $mnt2 | grep -q /dev/md && umount -f $mnt2 +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs -U md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint +chmod 777 $mntpoint +mount -t nullfs $mntpoint $mnt2 + +(sleep 5 > $mnt2/log) & +sleep 1 +umount -f $mnt2 + +kill $! +wait + +while mount | grep -q "$mnt2 "; do + umount $mnt2 || sleep 1 +done + +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 09:22:54 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2D8DED82; Fri, 11 Jan 2013 09:22:54 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 072DAB6C; Fri, 11 Jan 2013 09:22:54 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0B9MrMq044790; Fri, 11 Jan 2013 09:22:53 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0B9Mr3C044789; Fri, 11 Jan 2013 09:22:53 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301110922.r0B9Mr3C044789@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 09:22:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245293 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 09:22:54 -0000 Author: pho Date: Fri Jan 11 09:22:53 2013 New Revision: 245293 URL: http://svnweb.freebsd.org/changeset/base/245293 Log: Added a test of nullfs mount options cache / nocache Added: user/pho/stress2/misc/nullfs11.sh (contents, props changed) Added: user/pho/stress2/misc/nullfs11.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/nullfs11.sh Fri Jan 11 09:22:53 2013 (r245293) @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# Copyright (c) 2013 Peter Holm +# 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$ +# + +# nullfs cache / nocache benchmark + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +if [ -r ../default.cfg ]; then + . ../default.cfg +else + mntpoint=/mnt + mdstart=5 + part=a +fi + +export LANG=C +CACHE=nullfs11-cache.log +NOCACHE=nullfs11-nocache.log +mp1=/mnt +mp2=/mnt2 +[ -d $mp2 ] || mkdir $mp2 +rm -f $CACHE $NOCACHE + +cc -o /tmp/fstool ../tools/fstool.c + +test() { + opt=$1 + mount | grep -wq $mp2 && umount $mp2 + mount | grep -wq $mp1 && umount $mp1 + mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart + mdconfig -a -t swap -s 2g -u $mdstart || exit 1 + bsdlabel -w md$mdstart auto + newfs -U md${mdstart}${part} > /dev/null + mount /dev/md${mdstart}$part $mp1 + + mount -t nullfs $opt $mp1 $mp2 + + i=1 + (mkdir $mp2/test$i; cd $mp2/test$i; /tmp/fstool -l -f 50 -n 500 -s 4k) + rm -rf $mp2/test$i + sync + sleep 5 + + parallel=4 + for j in `jot 5`; do + s=`date '+%s'` + for i in `jot $parallel`; do + (mkdir $mp2/test$i; cd $mp2/test$i; \ + /tmp/fstool -l -f 50 -n 500 -s $((i * 4))k) & + done + for i in `jot $parallel`; do + wait + done + rm -rf $mp2/* + echo $((`date '+%s'` - $s)) + done + while mount | grep -wq $mp2; do + umount $mp2 || sleep 1 + done + while mount | grep $mp1 | grep -q /dev/md; do + umount $mp1 || sleep 1 + done + mdconfig -d -u $mdstart +} + +test "-o nocache" > $NOCACHE +test "-o cache" > $CACHE + +ministat -s -w 60 $NOCACHE $CACHE +rm -f /tmp/fstool $CACHE $NOCACHE From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 09:25:50 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A02ADEBC; Fri, 11 Jan 2013 09:25:50 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 91F79BDA; Fri, 11 Jan 2013 09:25:50 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0B9PoEj045145; Fri, 11 Jan 2013 09:25:50 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0B9PoQ4045144; Fri, 11 Jan 2013 09:25:50 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301110925.r0B9PoQ4045144@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 09:25:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245294 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 09:25:50 -0000 Author: pho Date: Fri Jan 11 09:25:50 2013 New Revision: 245294 URL: http://svnweb.freebsd.org/changeset/base/245294 Log: Unmapped I/O test scenario. Added: user/pho/stress2/misc/rot.sh (contents, props changed) Added: user/pho/stress2/misc/rot.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/rot.sh Fri Jan 11 09:25:50 2013 (r245294) @@ -0,0 +1,138 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Unmapped I/O test scenario: +# http://people.freebsd.org/~pho/stress/log/kostik515.txt + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > rot.c +cc -o rot -Wall -Wextra -O2 -g rot.c || exit 1 +rm -f rot.c +cd $here + +mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 2g -u $mdstart || exit 1 +bsdlabel -w md$mdstart auto + +newfs -U md${mdstart}$part > /dev/null + +mount /dev/md${mdstart}$part $mntpoint +chmod 777 $mntpoint + +(cd $mntpoint; /tmp/rot) +(cd /tmp; /tmp/rot) + +while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart +rm -f /tmp/rot +exit +EOF +#include +#include +#include +#include +#include +#include +#include + +#define N 10240 /* 40 Mb */ +#define PARALLEL 20 + +int +test(void) +{ + unsigned char *buf; + char path[128]; + int fd, i, j, s; + + s = getpagesize(); + + sprintf(path,"%s.%05d", getprogname(), getpid()); + if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) + err(1, "open(%s)", path); + if (lseek(fd, s * N - 1, SEEK_SET) == -1) + err(1, "lseek error"); + + /* write a dummy byte at the last location */ + if (write(fd, "", 1) != 1) + err(1, "write error"); + + for (i = 0; i < N; i++) { + if ((buf = mmap(0, s, PROT_READ | PROT_WRITE, MAP_SHARED, fd, i * s)) == MAP_FAILED) + err(1, "write map"); + for (j = 0; j < s; j++) + buf[j] = i % 256; + } + if (munmap(buf, s) == -1) + err(1, "unmap (write)"); + close(fd); + + if ((fd = open(path, O_RDONLY)) < 0) + err(1, "open(%s)", path); + for (i = 0; i < N; i++) { + if ((buf = mmap(0, s, PROT_READ, MAP_SHARED, fd, i * s)) == MAP_FAILED) + err(1, "write map"); + for (j = 0; j < s; j++) + if (buf[j] != i % 256) + fprintf(stderr, "read %d, expected %d at %d\n", + buf[j], i % 256, i); + } + if (munmap(buf, s) == -1) + err(1, "unmap (read)"); + close(fd); + unlink(path); + + _exit(0); +} + +int +main(void) +{ + int i, j; + + for (j = 0; j < 50; j++) { + for (i = 0; i < PARALLEL; i++) + if (fork() == 0) + test(); + for (i = 0; i < PARALLEL; i++) + wait(NULL); + } + + return(0); +} From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 09:27:25 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7C7A7FDF; Fri, 11 Jan 2013 09:27:25 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5F463BE6; Fri, 11 Jan 2013 09:27:25 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0B9RPu8045354; Fri, 11 Jan 2013 09:27:25 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0B9RPeX045353; Fri, 11 Jan 2013 09:27:25 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301110927.r0B9RPeX045353@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 09:27:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245295 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 09:27:25 -0000 Author: pho Date: Fri Jan 11 09:27:24 2013 New Revision: 245295 URL: http://svnweb.freebsd.org/changeset/base/245295 Log: nullfs + tmpfs regression test Added: user/pho/stress2/misc/nullfs9.sh (contents, props changed) Added: user/pho/stress2/misc/nullfs9.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/nullfs9.sh Fri Jan 11 09:27:24 2013 (r245295) @@ -0,0 +1,84 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# nullfs + tmpfs regression test: +# ETXTBSY problem of executable +# Fails with "./nullfs9.sh: cannot create /mnt2/mp/true: Text file busy" + +. ../default.cfg + +mnt2=/mnt2 +mount | grep -q $mnt2/mp && umount $mnt2/mp + +[ -d $mnt2 ] || mkdir $mnt2 +mount | grep $mnt2 | grep -q /dev/md && umount -f $mnt2 +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs -U md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mnt2 +chmod 777 $mnt2 + +mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint +mount -t tmpfs tmpfs $mntpoint +chmod 777 $mntpoint + +mkdir $mnt2/mp +mount -t nullfs $mntpoint $mnt2/mp + +# OK +cp /usr/bin/true $mnt2/mp/true +$mntpoint/true +if ! > $mntpoint/true ; then + echo FAIL 1 + mount | egrep "tmpfs|nullfs|$mntpoint |$mnt2 " +fi +rm -f $mntpoint/true + +# Fails +cp /usr/bin/true $mnt2/mp/true +$mnt2/mp/true +if ! > $mnt2/mp/true; then + echo FAIL 2 + mount | egrep "tmpfs|nullfs|$mntpoint |$mnt2 " +fi +rm -f $mnt2/mp/true + +umount $mnt2/mp +while mount | grep -q "$mnt2 "; do + umount $mnt2 || sleep 1 +done +mdconfig -d -u $mdstart + +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 12:37:02 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 278F84C9; Fri, 11 Jan 2013 12:37:02 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 117A08BC; Fri, 11 Jan 2013 12:37:02 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0BCb1YY097460; Fri, 11 Jan 2013 12:37:01 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0BCb1Gk097459; Fri, 11 Jan 2013 12:37:01 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301111237.r0BCb1Gk097459@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 12:37:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245298 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 12:37:02 -0000 Author: pho Date: Fri Jan 11 12:37:01 2013 New Revision: 245298 URL: http://svnweb.freebsd.org/changeset/base/245298 Log: Regression test: exec returning EIO problem scenario for tmpfs. Added: user/pho/stress2/misc/tmpfs9.sh (contents, props changed) Added: user/pho/stress2/misc/tmpfs9.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/tmpfs9.sh Fri Jan 11 12:37:01 2013 (r245298) @@ -0,0 +1,113 @@ +#!/bin/sh + +# +# Copyright (c) 2013 Peter Holm +# 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Regression test: exec returning EIO problem scenario for tmpfs + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > tmpfs9.c +cc -o tmpfs9 -Wall -Wextra -O2 tmpfs9.c +rm -f tmpfs9.c +cd $here + +mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint +mount -t tmpfs tmpfs $mntpoint +chmod 777 $mntpoint + +cp /usr/bin/true $mntpoint +su ${testuser} -c "/tmp/tmpfs9 $mntpoint" & + +while kill -0 $! 2>/dev/null; do + ../testcases/swap/swap -t 2m -i 40 -h +done +wait + +while mount | grep $mntpoint | grep -q tmpfs; do + umount $mntpoint || sleep 1 +done +rm -d /tmp/tmpfs9 +exit +EOF +#include +#include +#include +#include +#include +#include +#include +#include + +#define N 5000 +#define PARALLEL 10 +const char path[] = "./true"; + +void test(void) +{ + pid_t p; + int i; + + for (i = 0; i < N; i++) { + if ((p = fork()) == 0) + if (execl(path, path, (char *)0) == -1) + err(1, "exec(%s)", path); + if (p > 0) + wait(NULL); + } + _exit(0); +} + + +int +main(int argc, char **argv) +{ + int i, status; + + if (argc != 2) + errx(1, "Usage: %s ", argv[0]); + if (chdir(argv[1]) == -1) + err(1, "chdir(%s)", argv[1]); + + for (i = 0; i < PARALLEL; i++) { + if (fork() == 0) + test(); + } + + for (i = 0; i < PARALLEL; i++) { + wait(&status); + if (status != 0) + return (1); + } + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 12:39:35 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 14FCF60D; Fri, 11 Jan 2013 12:39:35 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DA1668D8; Fri, 11 Jan 2013 12:39:34 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0BCdYKF097729; Fri, 11 Jan 2013 12:39:34 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0BCdYuZ097728; Fri, 11 Jan 2013 12:39:34 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301111239.r0BCdYuZ097728@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 12:39:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245299 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 12:39:35 -0000 Author: pho Date: Fri Jan 11 12:39:34 2013 New Revision: 245299 URL: http://svnweb.freebsd.org/changeset/base/245299 Log: Regression test added. Added: user/pho/stress2/misc/nullfs10.sh (contents, props changed) Added: user/pho/stress2/misc/nullfs10.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/nullfs10.sh Fri Jan 11 12:39:34 2013 (r245299) @@ -0,0 +1,72 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Regression test: + +# There is an issue, namely, when the lower file is already +# opened r/w, but its nullfs alias is executed. This situation obviously +# shall result in ETXTBUSY, but it currently does not. + +# Test scenario by kib@ + +. ../default.cfg + +mnt2=/mnt2 +mount | grep -q $mnt2 && umount $mnt2 + +[ -d $mnt2 ] || mkdir $mnt2 +mount | grep $mnt2 | grep -q /dev/md && umount -f $mnt2 +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs -U md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint +chmod 777 $mntpoint + +mount -t nullfs $mntpoint $mnt2 + +cp /bin/ls $mntpoint +chmod +w $mntpoint/ls +sleep 2 >> $mntpoint/ls & +sleep .5 +# This line should cause a "/mnt2/ls: Text file busy" +$mnt2/ls -l /bin/ls $mntpoint $mnt2 && echo FAIL || echo OK +kill $! + +while mount | grep -q "$mnt2 "; do + umount $mnt2 || sleep 1 +done + +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 13:58:53 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CA98B617; Fri, 11 Jan 2013 13:58:53 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A6C1AC3F; Fri, 11 Jan 2013 13:58:53 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0BDwrHT019070; Fri, 11 Jan 2013 13:58:53 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0BDwrw2019069; Fri, 11 Jan 2013 13:58:53 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301111358.r0BDwrw2019069@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 13:58:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245300 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 13:58:53 -0000 Author: pho Date: Fri Jan 11 13:58:53 2013 New Revision: 245300 URL: http://svnweb.freebsd.org/changeset/base/245300 Log: Parallel mount and unmount of the same mount point. Added: user/pho/stress2/misc/parallelmount.sh (contents, props changed) Added: user/pho/stress2/misc/parallelmount.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/parallelmount.sh Fri Jan 11 13:58:53 2013 (r245300) @@ -0,0 +1,71 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# 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$ +# + +# Parallel mount and unmount of the same mount point +# http://people.freebsd.org/~pho/stress/log/parallelumount3.txt + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +parallel=40 + +if [ $# -eq 0 ]; then + mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart + mdconfig -a -t swap -s 10m -u $mdstart || exit 1 + bsdlabel -w md$mdstart auto + newfs -U md${mdstart}$part > /dev/null + + # start the parallel tests + for i in `jot $parallel`; do + ./$0 $i & + done + + while kill -0 $! 2> /dev/null; do + for i in `jot 200`; do + find $mntpoint > /dev/null 2>&1 + done + done + + for i in `jot $parallel`; do + wait + done + + while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 + done + mdconfig -d -u $mdstart +else + for i in `jot 1000`; do + mount /dev/md${mdstart}$part $mntpoint > /dev/null 2>&1 + umount $mntpoint > /dev/null 2>&1 + mount > /dev/null + done +fi From owner-svn-src-user@FreeBSD.ORG Fri Jan 11 14:01:08 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 16BD178A; Fri, 11 Jan 2013 14:01:08 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EF361CC7; Fri, 11 Jan 2013 14:01:07 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0BE17gq021006; Fri, 11 Jan 2013 14:01:07 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0BE17QE021005; Fri, 11 Jan 2013 14:01:07 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301111401.r0BE17QE021005@svn.freebsd.org> From: Peter Holm Date: Fri, 11 Jan 2013 14:01:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245301 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2013 14:01:08 -0000 Author: pho Date: Fri Jan 11 14:01:07 2013 New Revision: 245301 URL: http://svnweb.freebsd.org/changeset/base/245301 Log: Change mount point from rw to ro with a file mapped rw. Added: user/pho/stress2/misc/mountu.sh (contents, props changed) Added: user/pho/stress2/misc/mountu.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mountu.sh Fri Jan 11 14:01:07 2013 (r245301) @@ -0,0 +1,164 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# 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$ +# + +# Change mount point from rw to ro with a file mapped rw +# Currently fails for NFS + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mountu.c +cc -o mountu -Wall -Wextra -O2 mountu.c +rm -f mountu.c + +pstat() { + pid=`ps a | grep -v grep | grep /tmp/mountu | awk '{print $1}'` + [ -n "$pid" ] && procstat -v $pid +} + +mount | grep -q "$mntpoint " && umount $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 100m -u $mdstart +bsdlabel -w md${mdstart} auto +newfs -U md${mdstart}${part} > /dev/null +mount /dev/md${mdstart}${part} $mntpoint +chmod 777 $mntpoint + +/tmp/mountu $mntpoint/file & + +sleep 1 +if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then + echo "UFS FAILED" + pstat +fi +wait +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done + +mdconfig -d -u $mdstart + +mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +rm -f /tmp/file +/tmp/mountu $mntpoint/file & +sleep 1 + +if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then + echo "NFS FAILED" + pstat +fi +wait +umount $mntpoint + +mdconfig -a -t swap -s 100m -u $mdstart +bsdlabel -w md${mdstart} auto +newfs_msdos -F 16 -b 8192 /dev/md${mdstart}a > /dev/null 2>&1 +mount_msdosfs -m 777 /dev/md${mdstart}a $mntpoint +/tmp/mountu $mntpoint/file & + +sleep 1 +if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then + echo "MSDOS FAILED" + pstat +fi +wait + +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done +rm -f /tmp/mountu /tmp/file +exit 0 +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define STARTADDR 0x0U +#define ADRSPACE 0x0640000U + +int +main(int argc __unused, char **argv) +{ + int fd, ps; + void *p; + size_t len; + struct passwd *pw; + char *c, *path; + + if ((pw = getpwnam("nobody")) == NULL) + err(1, "no such user: nobody"); + + if (setgroups(1, &pw->pw_gid) || + setegid(pw->pw_gid) || setgid(pw->pw_gid) || + seteuid(pw->pw_uid) || setuid(pw->pw_uid)) + err(1, "Can't drop privileges to \"nobody\""); + endpwent(); + + p = (void *)STARTADDR; + len = ADRSPACE; + + path = argv[1]; + if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) + err(1,"open(%s)", path); + if (ftruncate(fd, len) == -1) + err(1, "ftruncate"); + if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == + MAP_FAILED) { + if (errno == ENOMEM) { + warn("mmap()"); + return (1); + } + err(1, "mmap(1)"); + } +// fprintf(stderr, "%s mapped to %p\n", path, p); + + c = p; + ps = getpagesize(); + for (c = p; (void *)c < p + len; c += ps) { + *c = 1; + } + + close(fd); + sleep(5); + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Sat Jan 12 19:05:49 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DC7B3443; Sat, 12 Jan 2013 19:05:49 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id ACFC263B; Sat, 12 Jan 2013 19:05:49 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0CJ5nkL034747; Sat, 12 Jan 2013 19:05:49 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0CJ5nEx034746; Sat, 12 Jan 2013 19:05:49 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301121905.r0CJ5nEx034746@svn.freebsd.org> From: Sean Bruno Date: Sat, 12 Jan 2013 19:05:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245340 - user/sbruno/pxe_http X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jan 2013 19:05:49 -0000 Author: sbruno Date: Sat Jan 12 19:05:49 2013 New Revision: 245340 URL: http://svnweb.freebsd.org/changeset/base/245340 Log: Nuke this copy of pxe_http, which came from the 2007 SOC tar ball on google code in preparation to import from the p4 repo that has newer things Deleted: user/sbruno/pxe_http/