From owner-svn-src-user@FreeBSD.ORG Wed Jan 2 02:44:22 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB944E39; Wed, 2 Jan 2013 02:44:22 +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 CB3DD8FC08; Wed, 2 Jan 2013 02:44:22 +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 r022iMXs094525; Wed, 2 Jan 2013 02:44:22 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r022iMCK094523; Wed, 2 Jan 2013 02:44:22 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301020244.r022iMCK094523@svn.freebsd.org> From: Peter Holm Date: Wed, 2 Jan 2013 02:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r244948 - 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: Wed, 02 Jan 2013 02:44:23 -0000 Author: pho Date: Wed Jan 2 02:44:22 2013 New Revision: 244948 URL: http://svnweb.freebsd.org/changeset/base/244948 Log: Added two gjournal scenarios. Added: user/pho/stress2/misc/gjournal2.sh (contents, props changed) user/pho/stress2/misc/gjournal3.sh (contents, props changed) Added: user/pho/stress2/misc/gjournal2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/gjournal2.sh Wed Jan 2 02:44:22 2013 (r244948) @@ -0,0 +1,60 @@ +#!/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$ +# + +# File system corruption seen + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +size="2g" +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 $size -u $mdstart || exit 1 + +gjournal load +gjournal label md$mdstart +sleep .5 +newfs -J /dev/md$mdstart.journal > /dev/null +mount -o async /dev/md$mdstart.journal $mntpoint +chmod 777 $mntpoint + +export runRUNTIME=30m +export RUNDIR=$mntpoint/stressX + +su $testuser -c 'cd ..; ./run.sh marcus.cfg' + +gjournal sync +while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +gjournal stop md$mdstart +gjournal unload +mdconfig -d -u $mdstart Added: user/pho/stress2/misc/gjournal3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/gjournal3.sh Wed Jan 2 02:44:22 2013 (r244948) @@ -0,0 +1,68 @@ +#!/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$ +# + +# Deadlock seen: http://people.freebsd.org/~pho/stress/log/gjournal3.txt +# Fixed in r244925 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +size="2g" +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 $size -u $mdstart || exit 1 + +gjournal load +gjournal label md$mdstart +sleep .5 +newfs -J /dev/md$mdstart.journal > /dev/null +mount -o async /dev/md$mdstart.journal $mntpoint +chmod 777 $mntpoint + +export runRUNTIME=10m +export RUNDIR=$mntpoint/stressX + +su $testuser -c 'cd ../testcases/rw + ./rw -t 2m -i 10 -l 100 > /dev/null 2>&1' & +while kill -0 $! 2>/dev/null; do + mksnap_ffs $mntpoint $mntpoint/.snap/snap + sleep .2 + rm -f $mntpoint/.snap/snap +done +wait + +gjournal sync +while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +gjournal stop md$mdstart +gjournal unload +mdconfig -d -u $mdstart From owner-svn-src-user@FreeBSD.ORG Wed Jan 2 02:44:54 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AFA0DF4C; Wed, 2 Jan 2013 02:44: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 9476A8FC0C; Wed, 2 Jan 2013 02:44: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 r022isSj094622; Wed, 2 Jan 2013 02:44:54 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r022issa094621; Wed, 2 Jan 2013 02:44:54 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201301020244.r022issa094621@svn.freebsd.org> From: Peter Holm Date: Wed, 2 Jan 2013 02:44:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r244949 - 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: Wed, 02 Jan 2013 02:44:54 -0000 Author: pho Date: Wed Jan 2 02:44:54 2013 New Revision: 244949 URL: http://svnweb.freebsd.org/changeset/base/244949 Log: Added check for root user. Modified: user/pho/stress2/misc/gjournal.sh Modified: user/pho/stress2/misc/gjournal.sh ============================================================================== --- user/pho/stress2/misc/gjournal.sh Wed Jan 2 02:44:22 2013 (r244948) +++ user/pho/stress2/misc/gjournal.sh Wed Jan 2 02:44:54 2013 (r244949) @@ -30,6 +30,8 @@ # Deadlock scenario based on kern/154228, fixed in r217880. +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + . ../default.cfg size="2g" From owner-svn-src-user@FreeBSD.ORG Wed Jan 2 04:20:52 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C63322CC; Wed, 2 Jan 2013 04:20:52 +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 A97C68FC13; Wed, 2 Jan 2013 04:20:52 +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 r024KqZZ011019; Wed, 2 Jan 2013 04:20:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r024Kqjp011018; Wed, 2 Jan 2013 04:20:52 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301020420.r024Kqjp011018@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 Jan 2013 04:20:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r244954 - 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: Wed, 02 Jan 2013 04:20:52 -0000 Author: adrian Date: Wed Jan 2 04:20:52 2013 New Revision: 244954 URL: http://svnweb.freebsd.org/changeset/base/244954 Log: More updates: * add a debugging printing for now * don't "fix" up the index to be signed from DC; no need to do that here * use combined RSSI for spectral scan printing for now rather than pri RSSI. I need to see what the "right" RSSI value to use is. 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 Wed Jan 2 04:02:27 2013 (r244953) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Wed Jan 2 04:20:52 2013 (r244954) @@ -112,6 +112,26 @@ convert_data(struct spectral_ht20_msg *m } #endif +static int +ar9280_radar_spectral_print(struct radar_fft_entry *fe) +{ + int i; + printf("PRI: max index=%d, magnitude=%d, bitmap weight=%d, max_exp=%d\n", + fe->pri.max_index, + fe->pri.max_magnitude, + fe->pri.bitmap_weight, + fe->max_exp); + + for (i = 0; i < 56; i++) { + if (i % 8 == 0) + printf("PRI: %d:", i); + printf("%02x ", fe->pri.bins[i].raw_mag); + if (i % 8 == 7) + printf("\n"); + } + printf("\n"); +} + /* XXX why do we need this? */ static int8_t fix_max_index(uint8_t max_index) @@ -146,7 +166,7 @@ ar9280_radar_spectral_decode_ht20(struct ((pkt[56] & 0xc0) >> 6) | ((pkt[58] & 0x03) << 10); fe->pri.bitmap_weight = pkt[56] & 0x3f; - fe->pri.max_index = fix_max_index(pkt[58] & 0x3f); + fe->pri.max_index = (pkt[58] & 0x3f); fe->max_exp = pkt[59] & 0x0f; /* Decode each bin - the dBm calculation will come later */ @@ -188,6 +208,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]); fr_len -= AR9280_SPECTRAL_SAMPLE_SIZE_HT20; fr += AR9280_SPECTRAL_SAMPLE_SIZE_HT20; if (fr_len < 0) @@ -239,7 +260,7 @@ ar9280_radar_decode(struct ieee80211_rad * HAL/DFS code, so they can all be plotted as appropriate. */ -#if 0 +#if 1 printf("tsf: %lld", tsf); printf(" len: %d", len); printf(" rssi %d/%d", comb_rssi, nf); @@ -276,7 +297,8 @@ ar9280_radar_decode(struct ieee80211_rad * things) whether the pulse duration is based on 40MHz or 44MHz. */ re->re_timestamp = tsf; - re->re_rssi = pri_rssi; /* XXX extension rssi? */ + //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 = 2412; /* XXX DO this! */ re->re_num_spectral_entries = 0; From owner-svn-src-user@FreeBSD.ORG Wed Jan 2 16:47:24 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 8109FB9; Wed, 2 Jan 2013 16:47:24 +0000 (UTC) (envelope-from crees@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 739301708; Wed, 2 Jan 2013 16:47:24 +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 r02GlOKG024880; Wed, 2 Jan 2013 16:47:24 GMT (envelope-from crees@svn.freebsd.org) Received: (from crees@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r02GlOJS024879; Wed, 2 Jan 2013 16:47:24 GMT (envelope-from crees@svn.freebsd.org) Message-Id: <201301021647.r02GlOJS024879@svn.freebsd.org> From: Chris Rees Date: Wed, 2 Jan 2013 16:47:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r244959 - user/crees/rclint 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, 02 Jan 2013 16:47:24 -0000 Author: crees (ports committer) Date: Wed Jan 2 16:47:23 2013 New Revision: 244959 URL: http://svnweb.freebsd.org/changeset/base/244959 Log: Copyrights can't be owned by The FreeBSD Project apparently Submitted by: theraven Modified: user/crees/rclint/rclint.py Modified: user/crees/rclint/rclint.py ============================================================================== --- user/crees/rclint/rclint.py Wed Jan 2 13:25:11 2013 (r244958) +++ user/crees/rclint/rclint.py Wed Jan 2 16:47:23 2013 (r244959) @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2012 The FreeBSD Project. All rights reserved. +# Copyright (c) 2012 Chris Rees. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions From owner-svn-src-user@FreeBSD.ORG Wed Jan 2 23:42:41 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 45EC5A23 for ; Wed, 2 Jan 2013 23:42:41 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx1.freebsd.org (Postfix) with ESMTP id AF91EA5E for ; Wed, 2 Jan 2013 23:42:40 +0000 (UTC) Received: by mail-la0-f41.google.com with SMTP id em20so7041884lab.14 for ; Wed, 02 Jan 2013 15:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=+n6hnqpJX9XIM8ic5zoPbWiW6IBH+tiHnSca/gR0Q+I=; b=f4nIX01yjS+PFwm9kkk9hgUqKzt9yYDwuxOR0ORbzwV9TQrdTKMxHGb6I8gGciyHS6 15ZMuma+50sR3SuAPtmXDUCR8/tdU/4TbbJ+eSo3QgXrzcFjpqdDOZA8Of/LE5Ht8l11 OYS1meizj2iF2FtCqZxGiTvx/3sCgxloakEWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=+n6hnqpJX9XIM8ic5zoPbWiW6IBH+tiHnSca/gR0Q+I=; b=CtHFcz+7MnUn+u5WFzIf5axVLCr3hOQnO4gQw43c2xWXfldfg9g3pRmf/lw2jiFkUR jeJ2ocJkf2j9XQ+b8ku72R9EdiJQbS7r235LZGHxg65Dx1KfSJD2IHfuDSz0gsV2iQyR +D2P1D0Wh4MR5NeP3BiW0lfHo+BAN2HtC5aNqza/Y5vv3p3cuAsWfT8d96x0exLliFIk Jw8ES2o2d0mNumBeuGASiZ15/GJtWKawsFoW3IT9T4wbeX8UH20mwz4LW+S/Y3NudaKD qffzRGZ/w7L6dHJL2x/PaJdJLDR6n5N2yrhrVbqqQftkVc437ILeO8lk/ifffG3uHrTa 8+Mw== Received: by 10.112.85.35 with SMTP id e3mr18170721lbz.106.1357170154206; Wed, 02 Jan 2013 15:42:34 -0800 (PST) MIME-Version: 1.0 Sender: lists@eitanadler.com Received: by 10.112.75.200 with HTTP; Wed, 2 Jan 2013 15:42:04 -0800 (PST) In-Reply-To: <201301021647.r02GlOJS024879@svn.freebsd.org> References: <201301021647.r02GlOJS024879@svn.freebsd.org> From: Eitan Adler Date: Wed, 2 Jan 2013 18:42:04 -0500 X-Google-Sender-Auth: 0ui_lx_CVXEdXCBCZCYmNBHOw-M Message-ID: Subject: Re: svn commit: r244959 - user/crees/rclint To: Chris Rees Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkLwPjcNSvyhqOny7eMQc8bw8xtipAyqlZqyq43z3VW0/95Li82hzTw1voAcn+L+YCH/J6+ 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: Wed, 02 Jan 2013 23:42:41 -0000 On 2 January 2013 11:47, Chris Rees wrote: > Author: crees (ports committer) > Date: Wed Jan 2 16:47:23 2013 > New Revision: 244959 > URL: http://svnweb.freebsd.org/changeset/base/244959 > > Log: > Copyrights can't be owned by The FreeBSD Project apparently We actually have this issue in a few places. One example: http://svnweb.freebsd.org/ports/head/COPYRIGHT?view=co In addition some files claim copyright by the FreeBSD foundation but there have been no copyright assignments: http://svnweb.freebsd.org/ports/head/CHANGES?view=co There is a separate issue of copyrights in src/ having subtly distinct copyrights (- vs * for the bullets). This is a ripe project for $someone to work on: finding the subtle differences and making them conform to a single standard. Note that this would likely require the copyright owner(s) to agree to the change. -- Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams From owner-svn-src-user@FreeBSD.ORG Thu Jan 3 09:27:12 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 D6DBDB70; Thu, 3 Jan 2013 09:27:12 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176]) by mx1.freebsd.org (Postfix) with ESMTP id 8FB5A85C; Thu, 3 Jan 2013 09:27:12 +0000 (UTC) Received: by mail-ie0-f176.google.com with SMTP id 13so17785263iea.35 for ; Thu, 03 Jan 2013 01:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=u6g1HHiGEDHX5IaFd8CZGdeQOh31ivkQ8y+4suIeRw8=; b=U/kkiah7JsnYtepxiC5MNN839eFi4iy1Osxh9SmshXeVFynovkr0vBCU3xDUdpzwO0 peTeERBoYAVC76g003PnBU1FRmVIvrkqq0KeYvn3+Oi2Y+fXDRfjTuECNn+09BbaMVR8 BvTEyIl3feTKAxJ4I1K9NX0TAFUrSwm4hjVf5unvT56kYDHIV/+DFVfbdqJdN46caN0x gAYOumlvp/u1NFbDQQndWpWC7dSV96GHco5ctNRRWxw2Rqx4LXDPqbW4Qen1B9WF1BrM yyItshOGReSGcO7Q4ynFJsGla+fl0j+AlgdFiL43o+WePpes9GjCHSNbnIzvG8ibhtrC UBlg== MIME-Version: 1.0 Received: by 10.50.158.170 with SMTP id wv10mr37926659igb.75.1357205226617; Thu, 03 Jan 2013 01:27:06 -0800 (PST) Received: by 10.64.65.132 with HTTP; Thu, 3 Jan 2013 01:27:05 -0800 (PST) Received: by 10.64.65.132 with HTTP; Thu, 3 Jan 2013 01:27:05 -0800 (PST) In-Reply-To: References: <201301021647.r02GlOJS024879@svn.freebsd.org> Date: Thu, 3 Jan 2013 09:27:05 +0000 Message-ID: Subject: Re: svn commit: r244959 - user/crees/rclint From: Chris Rees To: Eitan Adler Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Chris Rees , 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: Thu, 03 Jan 2013 09:27:12 -0000 On 2 Jan 2013 23:42, "Eitan Adler" wrote: > > On 2 January 2013 11:47, Chris Rees wrote: > > Author: crees (ports committer) > > Date: Wed Jan 2 16:47:23 2013 > > New Revision: 244959 > > URL: http://svnweb.freebsd.org/changeset/base/244959 > > > > Log: > > Copyrights can't be owned by The FreeBSD Project apparently > > We actually have this issue in a few places. One example: > http://svnweb.freebsd.org/ports/head/COPYRIGHT?view=co > > In addition some files claim copyright by the FreeBSD foundation but > there have been no copyright assignments: > http://svnweb.freebsd.org/ports/head/CHANGES?view=co > > There is a separate issue of copyrights in src/ having subtly distinct > copyrights (- vs * for the bullets). > > This is a ripe project for $someone to work on: finding the subtle > differences and making them conform to a single standard. Note that > this would likely require the copyright owner(s) to agree to the > change. I think a higher priority than bullet format is weeding out the last of the "advertising clauses". Warner Losh has done a lot of work on this, but I think bringing it up again may cause a nervous breakdown :) Chris From owner-svn-src-user@FreeBSD.ORG Thu Jan 3 10:45: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 3FC73461; Thu, 3 Jan 2013 10:45:50 +0000 (UTC) (envelope-from joel@freebsd.org) Received: from mail.vnode.se (mail.vnode.se [62.119.52.80]) by mx1.freebsd.org (Postfix) with ESMTP id 937B5EC0; Thu, 3 Jan 2013 10:45:49 +0000 (UTC) Received: from mail.vnode.se (localhost [127.0.0.1]) by mail.vnode.se (Postfix) with ESMTP id 223ABE3F07A; Thu, 3 Jan 2013 11:45:42 +0100 (CET) X-Virus-Scanned: amavisd-new at vnode.se Received: from mail.vnode.se ([127.0.0.1]) by mail.vnode.se (mail.vnode.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oyXsWUy6Rzk9; Thu, 3 Jan 2013 11:45:37 +0100 (CET) Received: from jd.benders.se (jd.benders.se [212.247.52.12]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.vnode.se (Postfix) with ESMTPSA id E48DAE3F079; Thu, 3 Jan 2013 11:45:36 +0100 (CET) Date: Thu, 3 Jan 2013 11:45:31 +0100 From: Joel Dahl To: Chris Rees Subject: Re: svn commit: r244959 - user/crees/rclint Message-ID: <20130103104531.GF86255@jd.benders.se> References: <201301021647.r02GlOJS024879@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Chris Rees , src-committers@freebsd.org, Eitan Adler , 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: Thu, 03 Jan 2013 10:45:50 -0000 On 03-01-2013 9:27, Chris Rees wrote: > On 2 Jan 2013 23:42, "Eitan Adler" wrote: > > > > On 2 January 2013 11:47, Chris Rees wrote: > > > Author: crees (ports committer) > > > Date: Wed Jan 2 16:47:23 2013 > > > New Revision: 244959 > > > URL: http://svnweb.freebsd.org/changeset/base/244959 > > > > > > Log: > > > Copyrights can't be owned by The FreeBSD Project apparently > > > > We actually have this issue in a few places. One example: > > http://svnweb.freebsd.org/ports/head/COPYRIGHT?view=co > > > > In addition some files claim copyright by the FreeBSD foundation but > > there have been no copyright assignments: > > http://svnweb.freebsd.org/ports/head/CHANGES?view=co > > > > There is a separate issue of copyrights in src/ having subtly distinct > > copyrights (- vs * for the bullets). > > > > This is a ripe project for $someone to work on: finding the subtle > > differences and making them conform to a single standard. Note that > > this would likely require the copyright owner(s) to agree to the > > change. > > I think a higher priority than bullet format is weeding out the last of the > "advertising clauses". I've done multiple sweeps over the tree in the past. Just a few thoughts: * The NetBSD Foundation switched from a 4-clause to a 2-clause license back in 2008. Identify and make sure all TNF licensed files in our tree have the new 2-clause license. They encourage third parties to change the license on any files which have a 4-clause license contributed to the NetBSD Foundation to a 2-clause license. [1] * We have lots of files with UC Berkeley copyrights in the tree. Some of them may still have the advertising clause, but we can safely remove it. [2] [1] http://www.netbsd.org/about/redistribution.html [2] ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change -- Joel From owner-svn-src-user@FreeBSD.ORG Thu Jan 3 16:41: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 3A4243FC for ; Thu, 3 Jan 2013 16:41:48 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx1.freebsd.org (Postfix) with ESMTP id AC6432D3 for ; Thu, 3 Jan 2013 16:41:47 +0000 (UTC) Received: by mail-la0-f52.google.com with SMTP id fq12so8057750lab.25 for ; Thu, 03 Jan 2013 08:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=XUZBaQiLmOpPSrmVlM95Kj+8SNrF8uh3OUy32AzT0hw=; b=rET7FkE3gNSbHf5pDGsZUEu2EtVlCw8RZz5w2nUDzckHPCqJlz8kzo9wSgnSpUTUZz 5ekUul3NL5bSejPh880f5uYsVpWCqQD4MlN5cQibv5GLZf6vj6I/LWAukonrkVdF73zs Ji8S85KnWlEZgAb6rNso59auvOTC1D6aGqI54= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=XUZBaQiLmOpPSrmVlM95Kj+8SNrF8uh3OUy32AzT0hw=; b=kaWUSriNcf668iyyGu2vcXFFRIcOsX76mRYgdGWAjCXjBLoLxvp2kzvKgZ40ixhTke jpm7NtuLvl1ziXChK3uIw90wOcZIjxjSi0250saxJh7CRQItFak9fvVE6A6LvVLOjIdU 4FyR3LrqSgpW8JWyS/JSTZyX55c2aPBXoRCeSZVb+pLuHhS1h9gB4UuXNYym3HR5qxPx TSPsEDnnvGVgbF6ckxd46JfXClzvccdPpi5Bonpka7aSmjG1SEv7k0yWWyB0hR12JIRm WEG2RJaQxWHXQfz05flTF7RWoBzZX9ogBRtd6y6TzriIO0+em/XGiDW0FbBVzV1+qEzF e0iQ== Received: by 10.152.106.163 with SMTP id gv3mr47085810lab.55.1357231301038; Thu, 03 Jan 2013 08:41:41 -0800 (PST) MIME-Version: 1.0 Sender: lists@eitanadler.com Received: by 10.112.75.200 with HTTP; Thu, 3 Jan 2013 08:41:10 -0800 (PST) In-Reply-To: References: <201301021647.r02GlOJS024879@svn.freebsd.org> From: Eitan Adler Date: Thu, 3 Jan 2013 11:41:10 -0500 X-Google-Sender-Auth: _FPtU4sOJZhacJnILFgdeoi0rNg Message-ID: Subject: Re: svn commit: r244959 - user/crees/rclint To: Chris Rees Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkExxi5phMShyj+Jh1hIGZuaN9ho0J/BGAGXZpaQsZPgAHrxJq3aMKK+Izajde/cd3XBkK8 Cc: Chris Rees , 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: Thu, 03 Jan 2013 16:41:48 -0000 On 3 January 2013 04:27, Chris Rees wrote: > I think a higher priority than bullet format is weeding out the last of the > "advertising clauses". These are actually distinct instead of subtly distinct. I did a sweep a while back but many licenses referenced people, not UCB. > Warner Losh has done a lot of work on this, but I think bringing it up again > may cause a nervous breakdown :) eh? -- Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams From owner-svn-src-user@FreeBSD.ORG Fri Jan 4 05:35: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 B709520B; Fri, 4 Jan 2013 05:35: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 9871FA5B; Fri, 4 Jan 2013 05:35: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 r045ZT2v062443; Fri, 4 Jan 2013 05:35:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r045ZTfD062440; Fri, 4 Jan 2013 05:35:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301040535.r045ZTfD062440@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 Jan 2013 05:35:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245027 - user/adrian/ath_radar_stuff/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: Fri, 04 Jan 2013 05:35:29 -0000 Author: adrian Date: Fri Jan 4 05:35:28 2013 New Revision: 245027 URL: http://svnweb.freebsd.org/changeset/base/245027 Log: Add a radiotap library from sipsolutions.net Added: 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 Added: user/adrian/ath_radar_stuff/src/pktlog/radiotap.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/pktlog/radiotap.c Fri Jan 4 05:35:28 2013 (r245027) @@ -0,0 +1,384 @@ +/* + * 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" + +/* 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_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_VENDOR_NAMESPACE: + 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_VENDOR_NAMESPACE) { + 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_VENDOR_NAMESPACE: + 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_VENDOR_NAMESPACE; + 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/src/pktlog/radiotap.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/pktlog/radiotap.h Fri Jan 4 05:35:28 2013 (r245027) @@ -0,0 +1,280 @@ +/*- + * Copyright (c) 2003, 2004 David Young. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of David Young may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID + * YOUNG 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. + */ + +/* + * Modifications to fit into the linux IEEE 802.11 stack, + * Mike Kershaw (dragorn@kismetwireless.net) + */ + +#ifndef IEEE80211RADIOTAP_H +#define IEEE80211RADIOTAP_H + +#include + +/* Base version of the radiotap packet header data */ +#define PKTHDR_RADIOTAP_VERSION 0 + +/* A generic radio capture format is desirable. There is one for + * Linux, but it is neither rigidly defined (there were not even + * units given for some fields) nor easily extensible. + * + * I suggest the following extensible radio capture format. It is + * based on a bitmap indicating which fields are present. + * + * I am trying to describe precisely what the application programmer + * should expect in the following, and for that reason I tell the + * units and origin of each measurement (where it applies), or else I + * use sufficiently weaselly language ("is a monotonically nondecreasing + * function of...") that I cannot set false expectations for lawyerly + * readers. + */ + +/* The radio capture header precedes the 802.11 header. + * All data in the header is little endian on all platforms. + */ +struct ieee80211_radiotap_header { + uint8_t it_version; /* Version 0. Only increases + * for drastic changes, + * introduction of compatible + * new fields does not count. + */ + uint8_t it_pad; + uint16_t it_len; /* length of the whole + * header in bytes, including + * it_version, it_pad, + * it_len, and data fields. + */ + uint32_t it_present; /* A bitmap telling which + * fields are present. Set bit 31 + * (0x80000000) to extend the + * bitmap by another 32 bits. + * Additional extensions are made + * by setting bit 31. + */ +}; + +/* Name Data type Units + * ---- --------- ----- + * + * IEEE80211_RADIOTAP_TSFT __le64 microseconds + * + * Value in microseconds of the MAC's 64-bit 802.11 Time + * Synchronization Function timer when the first bit of the + * MPDU arrived at the MAC. For received frames, only. + * + * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap + * + * Tx/Rx frequency in MHz, followed by flags (see below). + * + * IEEE80211_RADIOTAP_FHSS uint16_t see below + * + * For frequency-hopping radios, the hop set (first byte) + * and pattern (second byte). + * + * IEEE80211_RADIOTAP_RATE u8 500kb/s + * + * Tx/Rx data rate + * + * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from + * one milliwatt (dBm) + * + * RF signal power at the antenna, decibel difference from + * one milliwatt. + * + * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from + * one milliwatt (dBm) + * + * RF noise power at the antenna, decibel difference from one + * milliwatt. + * + * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) + * + * RF signal power at the antenna, decibel difference from an + * arbitrary, fixed reference. + * + * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) + * + * RF noise power at the antenna, decibel difference from an + * arbitrary, fixed reference point. + * + * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless + * + * Quality of Barker code lock. Unitless. Monotonically + * nondecreasing with "better" lock strength. Called "Signal + * Quality" in datasheets. (Is there a standard way to measure + * this?) + * + * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless + * + * Transmit power expressed as unitless distance from max + * power set at factory calibration. 0 is max power. + * Monotonically nondecreasing with lower power levels. + * + * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) + * + * Transmit power expressed as decibel distance from max power + * set at factory calibration. 0 is max power. Monotonically + * nondecreasing with lower power levels. + * + * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from + * one milliwatt (dBm) + * + * Transmit power expressed as dBm (decibels from a 1 milliwatt + * reference). This is the absolute power level measured at + * the antenna port. + * + * IEEE80211_RADIOTAP_FLAGS u8 bitmap + * + * Properties of transmitted and received frames. See flags + * defined below. + * + * IEEE80211_RADIOTAP_ANTENNA u8 antenna index + * + * Unitless indication of the Rx/Tx antenna for this packet. + * The first antenna is antenna 0. + * + * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap + * + * Properties of received frames. See flags defined below. + * + * IEEE80211_RADIOTAP_TX_FLAGS uint16_t bitmap + * + * Properties of transmitted frames. See flags defined below. + * + * IEEE80211_RADIOTAP_RTS_RETRIES u8 data + * + * Number of rts retries a transmitted frame used. + * + * IEEE80211_RADIOTAP_DATA_RETRIES u8 data + * + * Number of unicast retries a transmitted frame used. + * + * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless + * + * Contains a bitmap of known fields/flags, the flags, and + * the MCS index. + * + * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitlesss + * + * Contains the AMPDU information for the subframe. + */ +enum ieee80211_radiotap_type { + IEEE80211_RADIOTAP_TSFT = 0, + IEEE80211_RADIOTAP_FLAGS = 1, + IEEE80211_RADIOTAP_RATE = 2, + IEEE80211_RADIOTAP_CHANNEL = 3, + IEEE80211_RADIOTAP_FHSS = 4, + IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, + IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, + IEEE80211_RADIOTAP_LOCK_QUALITY = 7, + IEEE80211_RADIOTAP_TX_ATTENUATION = 8, + IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, + IEEE80211_RADIOTAP_DBM_TX_POWER = 10, + IEEE80211_RADIOTAP_ANTENNA = 11, + IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, + IEEE80211_RADIOTAP_DB_ANTNOISE = 13, + IEEE80211_RADIOTAP_RX_FLAGS = 14, + IEEE80211_RADIOTAP_TX_FLAGS = 15, + IEEE80211_RADIOTAP_RTS_RETRIES = 16, + IEEE80211_RADIOTAP_DATA_RETRIES = 17, + + IEEE80211_RADIOTAP_MCS = 19, + IEEE80211_RADIOTAP_AMPDU_STATUS = 20, + + /* valid in every it_present bitmap, even vendor namespaces */ + IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, + IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, + IEEE80211_RADIOTAP_EXT = 31 +}; + +/* Channel flags. */ +#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ +#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ +#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ +#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ +#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ +#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ +#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ +#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ + +/* For IEEE80211_RADIOTAP_FLAGS */ +#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received + * during CFP + */ +#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received + * with short + * preamble + */ +#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received + * with WEP encryption + */ +#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received + * with fragmentation + */ +#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ +#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between + * 802.11 header and payload + * (to 32-bit boundary) + */ +#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* frame failed FCS check */ + +/* For IEEE80211_RADIOTAP_RX_FLAGS */ +#define IEEE80211_RADIOTAP_F_RX_BADPLCP 0x0002 /* bad PLCP */ + +/* For IEEE80211_RADIOTAP_TX_FLAGS */ +#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive + * retries */ +#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ +#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ + +/* For IEEE80211_RADIOTAP_AMPDU_STATUS */ +#define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001 +#define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002 +#define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004 +#define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008 +#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010 +#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020 + +/* For IEEE80211_RADIOTAP_MCS */ +#define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01 +#define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02 +#define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04 +#define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08 +#define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10 + +#define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03 +#define IEEE80211_RADIOTAP_MCS_BW_20 0 +#define IEEE80211_RADIOTAP_MCS_BW_40 1 +#define IEEE80211_RADIOTAP_MCS_BW_20L 2 +#define IEEE80211_RADIOTAP_MCS_BW_20U 3 +#define IEEE80211_RADIOTAP_MCS_SGI 0x04 +#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 +#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 + +#endif /* IEEE80211_RADIOTAP_H */ Added: user/adrian/ath_radar_stuff/src/pktlog/radiotap_iter.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/pktlog/radiotap_iter.h Fri Jan 4 05:35:28 2013 (r245027) @@ -0,0 +1,96 @@ +#ifndef __RADIOTAP_ITER_H +#define __RADIOTAP_ITER_H + +#include +#include "radiotap.h" + +/* 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 */ From owner-svn-src-user@FreeBSD.ORG Fri Jan 4 05:50: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 552FC6F0; Fri, 4 Jan 2013 05:50:45 +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 46B96C16; Fri, 4 Jan 2013 05:50: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 r045ojsj064463; Fri, 4 Jan 2013 05:50:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r045oimV064462; Fri, 4 Jan 2013 05:50:44 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301040550.r045oimV064462@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 Jan 2013 05:50:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245028 - user/adrian/ath_radar_stuff/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: Fri, 04 Jan 2013 05:50:45 -0000 Author: adrian Date: Fri Jan 4 05:50:44 2013 New Revision: 245028 URL: http://svnweb.freebsd.org/changeset/base/245028 Log: .. another part from the radiotap import. Added: user/adrian/ath_radar_stuff/src/pktlog/platform.h Added: user/adrian/ath_radar_stuff/src/pktlog/platform.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/pktlog/platform.h Fri Jan 4 05:50:44 2013 (r245028) @@ -0,0 +1,19 @@ +#include +#include +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif +#include + +#define le16_to_cpu le16toh +#define le32_to_cpu le32toh +#define get_unaligned(p) \ +({ \ + struct packed_dummy_struct { \ + typeof(*(p)) __val; \ + } __attribute__((packed)) *__ptr = (void *) (p); \ + \ + __ptr->__val; \ +}) +#define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *)(p))) +#define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *)(p))) From owner-svn-src-user@FreeBSD.ORG Fri Jan 4 05:51:09 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 C462580B; Fri, 4 Jan 2013 05:51: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 9D55AC1C; Fri, 4 Jan 2013 05:51: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 r045p9c6064576; Fri, 4 Jan 2013 05:51:09 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r045p9KC064574; Fri, 4 Jan 2013 05:51:09 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301040551.r045p9KC064574@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 Jan 2013 05:51:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245029 - user/adrian/ath_radar_stuff/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: Fri, 04 Jan 2013 05:51:09 -0000 Author: adrian Date: Fri Jan 4 05:51:08 2013 New Revision: 245029 URL: http://svnweb.freebsd.org/changeset/base/245029 Log: Add radiotap xchannel field support. Modified: user/adrian/ath_radar_stuff/src/pktlog/radiotap.c user/adrian/ath_radar_stuff/src/pktlog/radiotap.h Modified: user/adrian/ath_radar_stuff/src/pktlog/radiotap.c ============================================================================== --- user/adrian/ath_radar_stuff/src/pktlog/radiotap.c Fri Jan 4 05:50:44 2013 (r245028) +++ user/adrian/ath_radar_stuff/src/pktlog/radiotap.c Fri Jan 4 05:51:08 2013 (r245029) @@ -38,6 +38,7 @@ static const struct radiotap_align_size [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 Modified: user/adrian/ath_radar_stuff/src/pktlog/radiotap.h ============================================================================== --- user/adrian/ath_radar_stuff/src/pktlog/radiotap.h Fri Jan 4 05:50:44 2013 (r245028) +++ user/adrian/ath_radar_stuff/src/pktlog/radiotap.h Fri Jan 4 05:51:08 2013 (r245029) @@ -175,6 +175,17 @@ struct ieee80211_radiotap_header { * * Number of unicast retries a transmitted frame used. * + * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap + * uint16_t MHz + * uint8_t channel number + * int8_t .5 dBm + * + * Extended channel specification: flags (see below) followed by + * frequency in MHz, the corresponding IEEE channel number, and + * finally the maximum regulatory transmit power cap in .5 dBm + * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL + * and only one of the two should be present. + * * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless * * Contains a bitmap of known fields/flags, the flags, and @@ -203,7 +214,7 @@ enum ieee80211_radiotap_type { IEEE80211_RADIOTAP_TX_FLAGS = 15, IEEE80211_RADIOTAP_RTS_RETRIES = 16, IEEE80211_RADIOTAP_DATA_RETRIES = 17, - + IEEE80211_RADIOTAP_XCHANNEL = 18, IEEE80211_RADIOTAP_MCS = 19, IEEE80211_RADIOTAP_AMPDU_STATUS = 20, @@ -222,6 +233,9 @@ enum ieee80211_radiotap_type { #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ +#define IEEE80211_CHAN_HT20 0x00010000 /* HT 20 channel */ +#define IEEE80211_CHAN_HT40U 0x00020000 /* HT 40 channel w/ ext above */ +#define IEEE80211_CHAN_HT40D 0x00040000 /* HT 40 channel w/ ext below */ /* For IEEE80211_RADIOTAP_FLAGS */ #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received From owner-svn-src-user@FreeBSD.ORG Fri Jan 4 05:53:18 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 56DBF992; Fri, 4 Jan 2013 05:53:18 +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 455A1CC4; Fri, 4 Jan 2013 05:53:18 +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 r045rIhq064881; Fri, 4 Jan 2013 05:53:18 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r045rH7u064879; Fri, 4 Jan 2013 05:53:17 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301040553.r045rH7u064879@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 Jan 2013 05:53:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245030 - 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: Fri, 04 Jan 2013 05:53:18 -0000 Author: adrian Date: Fri Jan 4 05:53:17 2013 New Revision: 245030 URL: http://svnweb.freebsd.org/changeset/base/245030 Log: Add pri/sec frequency and channel width fields; remove the hard-coded channel 1. Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c user/adrian/ath_radar_stuff/lib/libradarpkt/pkt.h Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Fri Jan 4 05:51:08 2013 (r245029) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c Fri Jan 4 05:53:17 2013 (r245030) @@ -300,7 +300,7 @@ 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 = 2412; /* XXX DO this! */ + re->re_freq = 0; re->re_num_spectral_entries = 0; /* XXX flags? */ Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/pkt.h ============================================================================== --- user/adrian/ath_radar_stuff/lib/libradarpkt/pkt.h Fri Jan 4 05:51:08 2013 (r245029) +++ user/adrian/ath_radar_stuff/lib/libradarpkt/pkt.h Fri Jan 4 05:53:17 2013 (r245030) @@ -62,7 +62,16 @@ struct radar_fft_entry { struct radar_entry { uint64_t re_timestamp; + + /* Primary frequency */ uint32_t re_freq; + + /* Secondary channel frequency, if applicable */ + uint32_t re_freq_sec; + + /* Channel width */ + uint32_t re_freqwidth; + /* * The hardware may give it to us as a negative number; * eg CCK decode which can use self-correlation to decode From owner-svn-src-user@FreeBSD.ORG Fri Jan 4 06:29: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 1446E539; Fri, 4 Jan 2013 06:29:54 +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 EB1C0F08; Fri, 4 Jan 2013 06:29: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 r046TrE9070515; Fri, 4 Jan 2013 06:29:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r046TrTE070510; Fri, 4 Jan 2013 06:29:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201301040629.r046TrTE070510@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 Jan 2013 06:29:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245032 - user/adrian/ath_radar_stuff/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: Fri, 04 Jan 2013 06:29:54 -0000 Author: adrian Date: Fri Jan 4 06:29:52 2013 New Revision: 245032 URL: http://svnweb.freebsd.org/changeset/base/245032 Log: Add some logic to pull out the XCHANNEL field from the radiotap header and decode it. The -HEAD driver now includes the correct xchan flags for PHY errors, so I can figure out whether it's a HT20/HT40 configured channel. Added: user/adrian/ath_radar_stuff/src/pktlog/chan.c user/adrian/ath_radar_stuff/src/pktlog/chan.h Modified: user/adrian/ath_radar_stuff/src/pktlog/Makefile user/adrian/ath_radar_stuff/src/pktlog/main.c Modified: user/adrian/ath_radar_stuff/src/pktlog/Makefile ============================================================================== --- user/adrian/ath_radar_stuff/src/pktlog/Makefile Fri Jan 4 06:28:34 2013 (r245031) +++ user/adrian/ath_radar_stuff/src/pktlog/Makefile Fri Jan 4 06:29:52 2013 (r245032) @@ -3,7 +3,7 @@ PROG= main X_INCS= -I../../lib/ X_LIBS= -L../../lib/libradarpkt/ -SRCS= main.c +SRCS= main.c chan.c radiotap.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 Added: user/adrian/ath_radar_stuff/src/pktlog/chan.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/pktlog/chan.c Fri Jan 4 06:29:52 2013 (r245032) @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +#include "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/src/pktlog/chan.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/adrian/ath_radar_stuff/src/pktlog/chan.h Fri Jan 4 06:29:52 2013 (r245032) @@ -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 Modified: user/adrian/ath_radar_stuff/src/pktlog/main.c ============================================================================== --- user/adrian/ath_radar_stuff/src/pktlog/main.c Fri Jan 4 06:28:34 2013 (r245031) +++ user/adrian/ath_radar_stuff/src/pktlog/main.c Fri Jan 4 06:29:52 2013 (r245032) @@ -14,6 +14,17 @@ #include "libradarpkt/ar5416_radar.h" #include "libradarpkt/ar9280_radar.h" +#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 */ + +// non-HT +// 0x00200140 +// HT, not HT40 +// 0x00210140 + /* * Compile up a rule that's bound to be useful - it only matches on * radar errors. @@ -35,9 +46,11 @@ pkt_compile(pcap_t *p, struct bpf_progra static void pkt_print(struct radar_entry *re) { - printf("ts: %llu, freq=%u, rssi=%d, dur=%d\n", + printf("ts: %llu, freq=%u, freqsec=%d, chwidth=%d, rssi=%d, dur=%d\n", re->re_timestamp, re->re_freq, + re->re_freq_sec, + re->re_freqwidth, re->re_rssi, re->re_dur); } @@ -49,6 +62,7 @@ pkt_handle(int chip, const char *pkt, in uint8_t rssi, nf; struct radar_entry re; int r; + struct xchan x; /* XXX assume it's a radiotap frame */ rh = (struct ieee80211_radiotap_header *) pkt; @@ -86,6 +100,16 @@ pkt_handle(int chip, const char *pkt, in return; } #endif + + /* + * Do a frequency lookup. + */ + /* XXX rh->it_len should be endian checked?! */ + if (pkt_lookup_chan((char *) pkt, len, &x) != 0) { + printf("%s: channel lookup failed\n", __func__); + return; + } + if (chip == CHIP_AR5212) r = ar5212_radar_decode(rh, pkt + rh->it_len, len - rh->it_len, &re); @@ -96,11 +120,32 @@ pkt_handle(int chip, const char *pkt, in r = ar9280_radar_decode(rh, pkt + rh->it_len, len - rh->it_len, &re); + /* 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; + } + /* * TODO: Print the summary record */ - if (r) + if (r) { pkt_print(&re); + } } static pcap_t * From owner-svn-src-user@FreeBSD.ORG Sat Jan 5 11: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 D66B41CD; Sat, 5 Jan 2013 11:13:48 +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 ACE5398C; Sat, 5 Jan 2013 11: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 r05BDmTn085928; Sat, 5 Jan 2013 11:13:48 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r05BDmum085927; Sat, 5 Jan 2013 11:13:48 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301051113.r05BDmum085927@svn.freebsd.org> From: Hiroki Sato Date: Sat, 5 Jan 2013 11:13:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245056 - user/hrs/releng 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, 05 Jan 2013 11:13:48 -0000 Author: hrs Date: Sat Jan 5 11:13:48 2013 New Revision: 245056 URL: http://svnweb.freebsd.org/changeset/base/245056 Log: Create new branch for releng work. Added: - copied from r245055, head/ Directory Properties: user/hrs/releng/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sat Jan 5 16:23:19 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 0B732142; Sat, 5 Jan 2013 16:23:19 +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 F0FA5305; Sat, 5 Jan 2013 16:23:18 +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 r05GNING079251; Sat, 5 Jan 2013 16:23:18 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r05GNIwK079250; Sat, 5 Jan 2013 16:23:18 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301051623.r05GNIwK079250@svn.freebsd.org> From: Hiroki Sato Date: Sat, 5 Jan 2013 16:23:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245061 - 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: Sat, 05 Jan 2013 16:23:19 -0000 Author: hrs Date: Sat Jan 5 16:23:18 2013 New Revision: 245061 URL: http://svnweb.freebsd.org/changeset/base/245061 Log: Remove mkisofs dependency in sparc64 boot iso image creation. A fixed sectors/cylinder (640) and the number of head (1) are used at this moment. Modified: user/hrs/releng/release/sparc64/mkisoimages.sh Modified: user/hrs/releng/release/sparc64/mkisoimages.sh ============================================================================== --- user/hrs/releng/release/sparc64/mkisoimages.sh Sat Jan 5 15:50:56 2013 (r245060) +++ user/hrs/releng/release/sparc64/mkisoimages.sh Sat Jan 5 16:23:18 2013 (r245061) @@ -22,51 +22,69 @@ # resulting ISO image, base-bits-dir contains the image contents and # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. - -publisher="The FreeBSD Project. http://www.freebsd.org/" -IMG=/tmp/bootfs -MNT=/mnt - -if [ "x$1" = "x-b" ]; then - dd if=/dev/zero of=${IMG} bs=512 count=1024 - MD=`mdconfig -a -t vnode -f ${IMG}` - sunlabel -w -B -b $4/boot/boot1 ${MD} auto - newfs -O1 -o space -m 0 /dev/${MD} - mount /dev/${MD} ${MNT} - mkdir ${MNT}/boot - cp $4/boot/loader ${MNT}/boot - umount ${MNT} - mdconfig -d -u ${MD#md} - bootable="-B ,,,,${IMG}" - shift -else - bootable="" -fi - if [ $# -lt 3 ]; then - echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' - rm -f ${IMG} + echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > /dev/stderr exit 1 fi -type mkisofs 2>&1 | grep " is " >/dev/null -if [ $? -ne 0 ]; then - echo The cdrtools port is not installed. Trying to get it now. - if [ -f /usr/ports/sysutils/cdrtools/Makefile ]; then - cd /usr/ports/sysutils/cdrtools && make install BATCH=yes && make clean - else - if ! pkg_add -r cdrtools; then - echo "Could not get it via pkg_add - please go install this" - echo "from the ports collection and run this script again." - exit 2 - fi - fi -fi - +case $1 in +-b) BOPT=$1; shift ;; +esac LABEL=$1; shift NAME=$1; shift +# Create an ISO image +publisher="The FreeBSD Project. http://www.freebsd.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab -mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $* +makefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* rm $1/etc/fstab -rm -f ${IMG} + +if [ "x$BOPT" != "x-b" ]; then + mv ${NAME}.tmp ${NAME} + exit 0 +fi +TMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1 +BOOTFSDIR="${TMPIMGDIR}/bootfs" +BOOTFSIMG="${TMPIMGDIR}/bootfs.img" + +# Create a boot filesystem +mkdir -p "${BOOTFSDIR}/boot" +cp $4/boot/loader "${BOOTFSDIR}/boot" +makefs -t ffs -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" +dd if=$4/boot/boot1 of="${BOOTFSIMG}" bs=512 conv=notrunc,sync + +# Create a boot ISO image +: ${CYLSIZE:=640} +ISOSIZE=$(stat -f %z ${NAME}.tmp) +ISOBLKS=$(( (${ISOSIZE} + 511) / 512 )) +ISOCYLS=$(( (${ISOBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE} )) + +BOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}") +BOOTFSBLKS=$(( (${BOOTFSSIZE} + 511) / 512 )) +BOOTFSCYLS=$(( (${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE} )) + +dd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync +dd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync +# The number of alternative cylinders is always 2. +dd if=/dev/zero of=${NAME} bs=${CYLSIZE}b seek=${ENDCYL} count=2 conv=notrunc,sync +rm -rf ${NAME}.tmp ${TMPIMGDIR} + +# Write VTOC8 label to boot ISO image +MD=`mdconfig -a -t vnode -f ${NAME}` +cat < 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 56D305B1; Sat, 5 Jan 2013 16:34:38 +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 2A4EB34D; Sat, 5 Jan 2013 16:34:37 +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 <0MG500B00VDJCN00@smtpauth1.wiscmail.wisc.edu>; Sat, 05 Jan 2013 10:34:31 -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 <0MG5005JTVDEK220@smtpauth1.wiscmail.wisc.edu>; Sat, 05 Jan 2013 10:34:28 -0600 (CST) Date: Sat, 05 Jan 2013 11:34:26 -0500 From: Nathan Whitehorn Subject: Re: svn commit: r245061 - user/hrs/releng/release/sparc64 In-reply-to: <201301051623.r05GNIwK079250@svn.freebsd.org> Sender: whitehorn@wisc.edu To: Hiroki Sato Message-id: <50E85612.1020903@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=107.17.54.205 X-Spam-PmxInfo: Server=avs-13, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2013.1.5.162415, SenderIP=107.17.54.205 References: <201301051623.r05GNIwK079250@svn.freebsd.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: Sat, 05 Jan 2013 16:34:38 -0000 With these changes, if you add -B big to the makefs flags for the boot fs and find a way to do sunlabel on not-sparc64 (this is the same as geom_part_vtoc8, right?), you should be able to cross-build sparc64 media (as you can already do with all other platforms). -Nathan On 01/05/13 11:23, Hiroki Sato wrote: > Author: hrs > Date: Sat Jan 5 16:23:18 2013 > New Revision: 245061 > URL: http://svnweb.freebsd.org/changeset/base/245061 > > Log: > Remove mkisofs dependency in sparc64 boot iso image creation. A fixed > sectors/cylinder (640) and the number of head (1) are used at this moment. > > Modified: > user/hrs/releng/release/sparc64/mkisoimages.sh > > Modified: user/hrs/releng/release/sparc64/mkisoimages.sh > ============================================================================== > --- user/hrs/releng/release/sparc64/mkisoimages.sh Sat Jan 5 15:50:56 2013 (r245060) > +++ user/hrs/releng/release/sparc64/mkisoimages.sh Sat Jan 5 16:23:18 2013 (r245061) > @@ -22,51 +22,69 @@ > # resulting ISO image, base-bits-dir contains the image contents and > # extra-bits-dir, if provided, contains additional files to be merged > # into base-bits-dir as part of making the image. > - > -publisher="The FreeBSD Project. http://www.freebsd.org/" > -IMG=/tmp/bootfs > -MNT=/mnt > - > -if [ "x$1" = "x-b" ]; then > - dd if=/dev/zero of=${IMG} bs=512 count=1024 > - MD=`mdconfig -a -t vnode -f ${IMG}` > - sunlabel -w -B -b $4/boot/boot1 ${MD} auto > - newfs -O1 -o space -m 0 /dev/${MD} > - mount /dev/${MD} ${MNT} > - mkdir ${MNT}/boot > - cp $4/boot/loader ${MNT}/boot > - umount ${MNT} > - mdconfig -d -u ${MD#md} > - bootable="-B ,,,,${IMG}" > - shift > -else > - bootable="" > -fi > - > if [ $# -lt 3 ]; then > - echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > - rm -f ${IMG} > + echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' > /dev/stderr > exit 1 > fi > > -type mkisofs 2>&1 | grep " is " >/dev/null > -if [ $? -ne 0 ]; then > - echo The cdrtools port is not installed. Trying to get it now. > - if [ -f /usr/ports/sysutils/cdrtools/Makefile ]; then > - cd /usr/ports/sysutils/cdrtools && make install BATCH=yes && make clean > - else > - if ! pkg_add -r cdrtools; then > - echo "Could not get it via pkg_add - please go install this" > - echo "from the ports collection and run this script again." > - exit 2 > - fi > - fi > -fi > - > +case $1 in > +-b) BOPT=$1; shift ;; > +esac > LABEL=$1; shift > NAME=$1; shift > > +# Create an ISO image > +publisher="The FreeBSD Project. http://www.freebsd.org/" > echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab > -mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $* > +makefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* > rm $1/etc/fstab > -rm -f ${IMG} > + > +if [ "x$BOPT" != "x-b" ]; then > + mv ${NAME}.tmp ${NAME} > + exit 0 > +fi > +TMPIMGDIR=`mktemp -d /tmp/bootfs.XXXXXXXX` || exit 1 > +BOOTFSDIR="${TMPIMGDIR}/bootfs" > +BOOTFSIMG="${TMPIMGDIR}/bootfs.img" > + > +# Create a boot filesystem > +mkdir -p "${BOOTFSDIR}/boot" > +cp $4/boot/loader "${BOOTFSDIR}/boot" > +makefs -t ffs -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" > +dd if=$4/boot/boot1 of="${BOOTFSIMG}" bs=512 conv=notrunc,sync > + > +# Create a boot ISO image > +: ${CYLSIZE:=640} > +ISOSIZE=$(stat -f %z ${NAME}.tmp) > +ISOBLKS=$(( (${ISOSIZE} + 511) / 512 )) > +ISOCYLS=$(( (${ISOBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE} )) > + > +BOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}") > +BOOTFSBLKS=$(( (${BOOTFSSIZE} + 511) / 512 )) > +BOOTFSCYLS=$(( (${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE} )) > + > +dd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync > +dd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync > +# The number of alternative cylinders is always 2. > +dd if=/dev/zero of=${NAME} bs=${CYLSIZE}b seek=${ENDCYL} count=2 conv=notrunc,sync > +rm -rf ${NAME}.tmp ${TMPIMGDIR} > + > +# Write VTOC8 label to boot ISO image > +MD=`mdconfig -a -t vnode -f ${NAME}` > +cat < +text: FreeBSD_Install cyl ${ENDCYL} alt 2 hd 1 sec ${CYLSIZE} > +bytes/sector: 512 > +sectors/cylinder: ${CYLSIZE} > +sectors/unit: ${ENDCYL} > + > +8 partitions: > +# > +# Size is in sectors. > +# Offset is in cylinders. > +# size offset tag flag > +# ---------- ---------- ---------- ---- > + c: * 0 backup rm > + a: ${ISOBLKS} 0 usr rm > + f: ${BOOTFSBLKS} ${ISOCYLS} root rm > +EOT > +mdconfig -d -u ${MD#md} > From owner-svn-src-user@FreeBSD.ORG Sat Jan 5 17:40:49 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 7182142F; Sat, 5 Jan 2013 17:40:49 +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 D483F8D2; Sat, 5 Jan 2013 17:40:48 +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 r05HeVk0078979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 6 Jan 2013 02:40:41 +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 r05HeTYl019646; Sun, 6 Jan 2013 02:40:30 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Sun, 06 Jan 2013 02:38:17 +0900 (JST) Message-Id: <20130106.023817.477940685460339224.hrs@allbsd.org> To: nwhitehorn@FreeBSD.org Subject: Re: svn commit: r245061 - user/hrs/releng/release/sparc64 From: Hiroki Sato In-Reply-To: <50E85612.1020903@freebsd.org> References: <201301051623.r05GNIwK079250@svn.freebsd.org> <50E85612.1020903@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_02_38_17_2013_974)--" 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 02:40:41 +0900 (JST) X-Spam-Status: No, score=-97.9 required=13.0 tests=CONTENT_TYPE_PRESENT, ONLY1HOPDIRECT,QENCPTR1,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: Sat, 05 Jan 2013 17:40:49 -0000 ----Security_Multipart(Sun_Jan__6_02_38_17_2013_974)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 ----Security_Multipart(Sun_Jan__6_02_38_17_2013_974)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEABECAAYFAlDoZQkACgkQTyzT2CeTzy0DOwCfSTu49wv0wmk4eQ1NfJZVLo4f 4aYAniO/P9IWs4SWW24+IYXzR9vdGZs6 =49yk -----END PGP SIGNATURE----- ----Security_Multipart(Sun_Jan__6_02_38_17_2013_974)---- From owner-svn-src-user@FreeBSD.ORG Sat Jan 5 17:41:22 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 5746C551; Sat, 5 Jan 2013 17:41:22 +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 308CD8DD; Sat, 5 Jan 2013 17:41:22 +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 r05HfMr1002688; Sat, 5 Jan 2013 17:41:22 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r05HfMCe002687; Sat, 5 Jan 2013 17:41:22 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301051741.r05HfMCe002687@svn.freebsd.org> From: Hiroki Sato Date: Sat, 5 Jan 2013 17:41:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245063 - 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: Sat, 05 Jan 2013 17:41:22 -0000 Author: hrs Date: Sat Jan 5 17:41:21 2013 New Revision: 245063 URL: http://svnweb.freebsd.org/changeset/base/245063 Log: - Fix calculation of the total number of sectors. - Add -B be to makefs to make cross-build possible[*]. Suggested by: nwhitehorn[*] Modified: user/hrs/releng/release/sparc64/mkisoimages.sh Modified: user/hrs/releng/release/sparc64/mkisoimages.sh ============================================================================== --- user/hrs/releng/release/sparc64/mkisoimages.sh Sat Jan 5 16:35:46 2013 (r245062) +++ user/hrs/releng/release/sparc64/mkisoimages.sh Sat Jan 5 17:41:21 2013 (r245063) @@ -36,7 +36,7 @@ NAME=$1; shift # Create an ISO image publisher="The FreeBSD Project. http://www.freebsd.org/" echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab -makefs -t cd9660 -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* +makefs -t cd9660 -B be -o rockridge -o label="$LABEL" -o publisher="$publisher" ${NAME}.tmp $* rm $1/etc/fstab if [ "x$BOPT" != "x-b" ]; then @@ -50,7 +50,7 @@ BOOTFSIMG="${TMPIMGDIR}/bootfs.img" # Create a boot filesystem mkdir -p "${BOOTFSDIR}/boot" cp $4/boot/loader "${BOOTFSDIR}/boot" -makefs -t ffs -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" +makefs -t ffs -B be -M 512k "${BOOTFSIMG}" "${BOOTFSDIR}" dd if=$4/boot/boot1 of="${BOOTFSIMG}" bs=512 conv=notrunc,sync # Create a boot ISO image @@ -63,6 +63,9 @@ BOOTFSSIZE=$(stat -f %z "${BOOTFSIMG}") BOOTFSBLKS=$(( (${BOOTFSSIZE} + 511) / 512 )) BOOTFSCYLS=$(( (${BOOTFSBLKS} + (${CYLSIZE} - 1)) / ${CYLSIZE} )) +ENDCYL=$(( ${ISOCYLS} + ${BOOTFSCYLS} )) +NSECTS=$(( ${ENDCYL} * 1 * ${CYLSIZE} )) + dd if=${NAME}.tmp of=${NAME} bs=${CYLSIZE}b conv=notrunc,sync dd if=${BOOTFSIMG} of=${NAME} bs=${CYLSIZE}b seek=${ISOCYLS} conv=notrunc,sync # The number of alternative cylinders is always 2. @@ -75,7 +78,7 @@ cat < 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 51BCE78; Sat, 5 Jan 2013 20:37:15 +0000 (UTC) (envelope-from ae@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 2CD9B174; Sat, 5 Jan 2013 20:37:15 +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 r05KbFVA053794; Sat, 5 Jan 2013 20:37:15 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r05KbFPr053793; Sat, 5 Jan 2013 20:37:15 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301052037.r05KbFPr053793@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Sat, 5 Jan 2013 20:37:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245069 - user/ae/bootcode 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, 05 Jan 2013 20:37:15 -0000 Author: ae Date: Sat Jan 5 20:37:14 2013 New Revision: 245069 URL: http://svnweb.freebsd.org/changeset/base/245069 Log: Remove bootcode branch. Deleted: user/ae/bootcode/ From owner-svn-src-user@FreeBSD.ORG Sat Jan 5 21:52:03 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 A08CA362; Sat, 5 Jan 2013 21:52:03 +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 82FB37B3; Sat, 5 Jan 2013 21:52: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 r05Lq3Ld076754; Sat, 5 Jan 2013 21:52:03 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r05Lq2P0076746; Sat, 5 Jan 2013 21:52:02 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201301052152.r05Lq2P0076746@svn.freebsd.org> From: Hiroki Sato Date: Sat, 5 Jan 2013 21:52:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245073 - in 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: Sat, 05 Jan 2013 21:52:03 -0000 Author: hrs Date: Sat Jan 5 21:52:01 2013 New Revision: 245073 URL: http://svnweb.freebsd.org/changeset/base/245073 Log: Add makevd(8) to generate a virtual disk image from a UFS image. Currently it supports VMWare VMDK format. The generated .vmdk file is a hosted sparse extent with an embedded descriptor for VMWare hosted products. Added: user/hrs/releng/usr.sbin/makevd/ user/hrs/releng/usr.sbin/makevd/Makefile (contents, props changed) user/hrs/releng/usr.sbin/makevd/makevd.8 user/hrs/releng/usr.sbin/makevd/makevd.c (contents, props changed) user/hrs/releng/usr.sbin/makevd/makevd.h (contents, props changed) user/hrs/releng/usr.sbin/makevd/raw.c (contents, props changed) user/hrs/releng/usr.sbin/makevd/vmdk.c (contents, props changed) user/hrs/releng/usr.sbin/makevd/vmdk.h (contents, props changed) Modified: user/hrs/releng/usr.sbin/Makefile Modified: user/hrs/releng/usr.sbin/Makefile ============================================================================== --- user/hrs/releng/usr.sbin/Makefile Sat Jan 5 21:42:14 2013 (r245072) +++ user/hrs/releng/usr.sbin/Makefile Sat Jan 5 21:52:01 2013 (r245073) @@ -39,6 +39,7 @@ SUBDIR= adduser \ kldxref \ mailwrapper \ makefs \ + makevd \ manctl \ memcontrol \ mergemaster \ Added: user/hrs/releng/usr.sbin/makevd/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/Makefile Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +PROG= makevd +MAN= makevd.8 +SRCS= makevd.c \ + raw.c \ + vmdk.c +WARNS?= 6 +CFLAGS+= -I${.CURDIR} + +.include Added: user/hrs/releng/usr.sbin/makevd/makevd.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/makevd.8 Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,111 @@ +.\" +.\" Copyright (c) 2011 +.\" 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 WASABI SYSTEMS, INC. ``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 +.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 6, 2013 +.Dt MAKEVD 8 +.Os +.Sh NAME +.Nm makevd +.Nd create a virtual disk image from a file system image +.Sh SYNOPSIS +.Nm +.Op Fl B Ar byte-order +.Op Fl o Ar image-options +.Op Fl t Ar image-type +.Ar input-image-file +.Sh DESCRIPTION +The utility +.Nm +creates a virtual disk image from the file system image specified in +.Ar input-image-file . +The output file name can be specified by using +.Op Fl o Ar imagename +option. +If not specified, it will be determined by the +.Ar input-image-file . +The options are as follows: +.Bl -tag -width flag +.It Fl B Ar byte-order +Set the byte order of the image to +.Ar byte-order . +Valid byte orders are +.Ql 4321 , +.Ql big , +or +.Ql be +for big endian, and +.Ql 1234 , +.Ql little , +or +.Ql le +for little endian. +Some file systems may have a fixed byte order; in those cases this +argument will be ignored. +.Ar image-options +is a comma separated list of options. +Valid image specific options are detailed below. +.It Fl t Ar image-type +Create an +.Ar image-type +virtual disk image. +The following image types are supported: +.Bl -tag -width cd9660 -offset indent +.It Sy vmdk +VMWare Virtual Machine DisK (VMDK) Format. +.It Sy raw +No conversion (default). +.El +.El +.\" +.\" +.Ss VMDK-specific options +.Sy vmdk +images have VMDK-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 +.Sh SEE ALSO +.Xr uuidgen 1 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 10.0 +.Sh AUTHORS +.An Hiroki Sato +.Aq hrs@FreeBSD.org +.Sh BUGS +The +.Fl B Ar byte-order +option does not work yet. Added: user/hrs/releng/usr.sbin/makevd/makevd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/makevd.c Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,202 @@ +/*- + * Copyright (c) 2011 + * 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 WASABI SYSTEMS, INC. ``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 + * 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 "makevd.h" +#include "vmdk.h" + +static LIST_HEAD(optlisthead_t, optlist) oplhead; + +/* list of supported disk image type and dispatch functions */ +static struct imtype { + const char *imt_type; + int (*imt_makeim)(struct iminfo *); +} imtypes[] = { + { "vmdk", vmdk_makeim }, + { "none", raw_makeim }, + { "raw", raw_makeim }, + { .imt_type = NULL }, +}; + +static struct imtype *get_imtype(const char *); +static void usage(void); + +int +main(int argc, char *argv[]) +{ + struct imtype *imt; + struct iminfo imi; + struct optlist *opl; + struct stat sb; + int ch; + int ifd; + int opl_new; + char *val; + + setprogname(argv[0]); + + if ((imt = get_imtype(DEFAULT_IMTYPE)) == NULL) + errx(1, "Unknown default image type `%s'.", DEFAULT_IMTYPE); + + memset(&imi, 0, sizeof(imi)); + memset(&sb, 0, sizeof(sb)); + LIST_INIT(&oplhead); + imi.imi_fd = -1; + + while ((ch = getopt(argc, argv, "B:t:o:")) != -1) { + switch (ch) { + case 'B': + if (strcmp(optarg, "be") == 0 || + strcmp(optarg, "4321") == 0 || + strcmp(optarg, "big") == 0) { +#if BYTE_ORDER == LITTLE_ENDIAN + imi.imi_needswap = 1; +#endif + } else if (strcmp(optarg, "le") == 0 || + strcmp(optarg, "1234") == 0 || + strcmp(optarg, "little") == 0) { +#if BYTE_ORDER == BIG_ENDIAN + imi.imi_needswap = 1; +#endif + } else { + warnx("Invalid endian `%s'.", optarg); + usage(); + } + break; + + case 't': + if ((imt = get_imtype(optarg)) == NULL) + errx(1, "Unknown image type `%s'.", optarg); + break; + + case 'o': + opl_new = 0; + val = strchr(optarg, '='); + if (val == '\0') + val = NULL; + else { + *val = '\0'; + val += 1; + } + /* Check duplicate entry. */ + LIST_FOREACH(opl, &oplhead, opl_next) + if (strcmp(opl->opl_name, optarg) == 0) + break; + if (opl == NULL) { + opl = calloc(1, sizeof(*opl)); + if (opl == NULL) + err(EX_OSERR, "%s", optarg); + opl_new = 1; + } else { + free(opl->opl_name); + opl->opl_name = NULL; + if (opl->opl_val) { + free(opl->opl_val); + opl->opl_val = NULL; + } + } + if (val) + opl->opl_val = strdup(val); + opl->opl_name = strdup(optarg); + if (opl_new) + LIST_INSERT_HEAD(&oplhead, opl, opl_next); + break; + case '?': + case 'h': + default: + usage(); + /* NOTREACHED */ + } + } + argc -= optind; + argv += optind; + + if (argc != 1) + usage(); + + ifd = open(argv[0], O_RDONLY); + if (ifd < 0) + err(EX_NOINPUT, "%s", argv[0]); + if (fstat(ifd, &sb) < 0) + err(EX_IOERR, "%s", argv[0]); + + imi.imi_fd = ifd; + imi.imi_size = sb.st_size; + imi.imi_oplhead = &oplhead; + LIST_FOREACH(opl, &oplhead, opl_next) { +#if 0 + printf("options: %s = %s\n", opl->opl_name, opl->opl_val); +#endif + if (strcmp(opl->opl_name, "uuid") == 0) + imi.imi_uuid = opl->opl_val; + else if (strcmp(opl->opl_name, "imagename") == 0) + imi.imi_imagename = opl->opl_val; + } + if (imi.imi_imagename == NULL) + imi.imi_imagename = strdup(argv[0]); + + imt->imt_makeim(&imi); + + return (0); +} + +static struct imtype * +get_imtype(const char *type) +{ + int i; + + for (i = 0; imtypes[i].imt_type != NULL; i++) + if (strcmp(imtypes[i].imt_type, type) == 0) + return (&imtypes[i]); + return (NULL); +} + +static void +usage(void) +{ + const char *prog; + + prog = getprogname(); + fprintf(stderr, "usage: %s [-t image-type] [-o image-options] " + "input-file\n",prog); + + exit(1); +} Added: user/hrs/releng/usr.sbin/makevd/makevd.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/makevd.h Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2011 + * 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 WASABI SYSTEMS, INC. ``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 + * 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 _MAKEVD_H +#define _MAKEVD_H + +#include + +struct iminfo { + int imi_fd; + off_t imi_size; + int imi_needswap; + + char *imi_imagename; /* vmdk specific */ + char *imi_uuid; /* vmdk specific */ + + struct optlisthead_t *imi_oplhead; +}; + +struct optlist { + LIST_ENTRY(optlist) opl_next; + char *opl_name; + char *opl_val; +}; + +int vmdk_makeim(struct iminfo *); +int raw_makeim(struct iminfo *); + +#ifndef DEFAULT_IMTYPE +#define DEFAULT_IMTYPE "raw" +#endif + +#endif /* _MAKEVD_H */ Added: user/hrs/releng/usr.sbin/makevd/raw.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/raw.c Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2011 + * 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 "makevd.h" + +int +raw_makeim(struct iminfo *imi) +{ + char buf[BUFSIZ], rawfile[PATH_MAX + 10]; + ssize_t len0, len = 0; + int ifd, ofd; + + ifd = imi->imi_fd; + + if (strcmp(imi->imi_imagename, "-") == 0) + ofd = STDOUT_FILENO; + else { + snprintf(rawfile, sizeof(rawfile), "%s.raw", + imi->imi_imagename); + ofd = open(rawfile, O_WRONLY|O_CREAT|O_TRUNC, + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + if (ofd < 0) + 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); + } + } + + return (0); +} Added: user/hrs/releng/usr.sbin/makevd/vmdk.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/vmdk.c Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,156 @@ +/*- + * Copyright (c) 2011 + * 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 "makevd.h" +#include "vmdk.h" + +int +vmdk_makeim(struct iminfo *imi) +{ + struct SparseExtentHeader SEH, *imh; + 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; + + imh = &SEH; + ifd = imi->imi_fd; + imagesize = imi->imi_size; + + memset(imh, 0, sizeof(*imh)); + memset(desc, 0, sizeof(desc)); + + if (imi->imi_uuid == NULL) + errx(EX_USAGE, "-o uuid option must be specified."); + + snprintf(vmdkfile, sizeof(vmdkfile), "%s.vmdk", imi->imi_imagename); + ofd = open(vmdkfile, O_WRONLY|O_CREAT|O_TRUNC, + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + if (ofd < 0) + err(EX_CANTCREAT, "%s", vmdkfile); + + vmdkfilebase = strrchr(vmdkfile, '/'); + 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'; + + sectors = 63; + heads = 16; + cylinders = imagesize / (sectors * heads * 512); + while (cylinders > 1024) { + cylinders >>= 1; + heads <<= 1; + } + + snprintf(desc, sizeof(desc), + "# Disk Descriptor File\n" + "version=1\n" + "CID=fffffffe\n" + "parentCID=ffffffff\n" + "createType=\"monolithicFlat\"\n" + "# Extent Description\n" + "RW %" PRIu64 " FLAT \"%s\" %" PRIu64 "\n" + "# Disk Data Base\n" + "ddb.toolsVersion = \"0\"\n" + "ddb.virtualHWVersion = \"3\"\n" + "ddb.geometry.sectors = \"%" PRIu64 "\"\n" + "ddb.adapterType = \"ide\"\n" + "ddb.geometry.heads = \"%" PRIu64 "\"\n" + "ddb.geometry.cylinders = \"%" PRIu64 "\"\n" + "ddb.uuid.image=\"%s\"\n", + cylinders * sectors * heads, + vmdkfilebase, + imh->overHead, + sectors, + heads, + 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); + } + } + + return (0); +} Added: user/hrs/releng/usr.sbin/makevd/vmdk.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/hrs/releng/usr.sbin/makevd/vmdk.h Sat Jan 5 21:52:01 2013 (r245073) @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2011 + * 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 _VMDK_H +#define _VMDK_H + +#include +#include + +typedef uint64_t SectorType; +typedef uint32_t uint32; +typedef uint16_t uint16; +typedef uint8_t uint8; +typedef uint8_t Bool; + +struct SparseExtentHeader { + uint32 magicNumber; + uint32 version; + uint32 flags; + SectorType capacity; + SectorType grainSize; + SectorType descriptorOffset; + SectorType descriptorSize; + uint32 numGTEsPerGT; + SectorType rgdOffset; + SectorType gdOffset; + SectorType overHead; + Bool uncleanShutdown; + char singleEndLineChar; + char nonEndLineChar; + char doubleEndLineChar1; + char doubleEndLineChar2; + uint16 compressAlgorithm; + 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 */