From owner-svn-src-user@FreeBSD.ORG Mon Aug 9 06:02:23 2010 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 6616F1065672; Mon, 9 Aug 2010 06:02:23 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 55F3C8FC0C; Mon, 9 Aug 2010 06:02:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7962Nc4096825; Mon, 9 Aug 2010 06:02:23 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7962NsW096823; Mon, 9 Aug 2010 06:02:23 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008090602.o7962NsW096823@svn.freebsd.org> From: Doug Barton Date: Mon, 9 Aug 2010 06:02:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211090 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2010 06:02:23 -0000 Author: dougb Date: Mon Aug 9 06:02:23 2010 New Revision: 211090 URL: http://svn.freebsd.org/changeset/base/211090 Log: Move from using MD5 to detect distinfo files to using SHA256. It is now universal except for a few ports, and hopefully we can drop MD5 altogether very soon. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Mon Aug 9 01:47:09 2010 (r211089) +++ user/dougb/portmaster/portmaster Mon Aug 9 06:02:23 2010 (r211090) @@ -866,7 +866,7 @@ read_distinfos () { fi if [ -s "$distinfo" ]; then - grep '^MD5' $distinfo | while read disc1 f disc2; do + grep '^SHA256 ' $distinfo | while read disc1 f disc2; do f=${f#(} ; f=${f%)} echo $f >> $DI_FILES done @@ -901,7 +901,7 @@ read_distinfos_all () { fi if [ -s "$distinfo" ]; then - grep '^MD5' $distinfo | while read disc1 f disc2; do + grep '^SHA256 ' $distinfo | while read disc1 f disc2; do f=${f#(} ; f=${f%)} echo $f >> $DI_FILES done @@ -3526,8 +3526,7 @@ if [ -n "$distfiles" ]; then for file in $distfiles; do size=`grep "^SIZE (${ds}${file})" $distinfo` sha256=`grep "^SHA256 (${ds}${file})" $distinfo` - md5=`grep "^MD5 (${ds}${file})" $distinfo` - echo "DISTFILE:${ds}${file}:SIZE=${size##* }:SHA256=${sha256##* }:MD5=${md5##* }" \ + echo "DISTFILE:${ds}${file}:SIZE=${size##* }:SHA256=${sha256##* }" \ >> $dist_list_temp # Make sure any new distfiles get added to the list [ -z "$DONT_SCRUB_DISTFILES" -a ! "$$" -eq "$PM_PARENT_PID" ] && From owner-svn-src-user@FreeBSD.ORG Mon Aug 9 08:41:30 2010 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 307FD106566C; Mon, 9 Aug 2010 08:41:30 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 062BA8FC08; Mon, 9 Aug 2010 08:41:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o798fTZr032166; Mon, 9 Aug 2010 08:41:29 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o798fT02032164; Mon, 9 Aug 2010 08:41:29 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008090841.o798fT02032164@svn.freebsd.org> From: Doug Barton Date: Mon, 9 Aug 2010 08:41:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211093 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2010 08:41:30 -0000 Author: dougb Date: Mon Aug 9 08:41:29 2010 New Revision: 211093 URL: http://svn.freebsd.org/changeset/base/211093 Log: Add quotes around arguments to pm_sv() that throw off vim's syntax checker Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Mon Aug 9 07:58:32 2010 (r211092) +++ user/dougb/portmaster/portmaster Mon Aug 9 08:41:29 2010 (r211093) @@ -132,7 +132,7 @@ parent_exit () { fi fi if [ -z "$BACKUP" -a -z "$NO_BACKUP" -a -n "$NB_DELETE" ]; then - pm_sv Deleting safety packages for successful installs + pm_sv 'Deleting safety packages for successful installs' pm_cd $pbu || fail "Cannot cd to $pbu" pm_rm_s $NB_DELETE fi @@ -140,7 +140,7 @@ parent_exit () { [ -n "$pbu" ] && pbu=`find $pbu -type d -empty 2>/dev/null` if [ -d "$pbu" ]; then - pm_sv Removing empty backup package directory + pm_sv 'Removing empty backup package directory' pm_rmdir_s $pbu fi @@ -2758,7 +2758,7 @@ all_first_pass () { safe_exit fi - post_first_pass for ports that need updating + post_first_pass 'for ports that need updating' [ -n "$PM_BUILD_ONLY_LIST" ] && clean_build_only_list fi @@ -3392,11 +3392,11 @@ if [ -n "$upg_port" -o -n "$ro_upg_port" done if [ -n "$temp" ]; then if [ ! -d "$LOCALBASE_COMPAT" ]; then - pm_sv Creating $LOCALBASE_COMPAT for -w + pm_sv "Creating $LOCALBASE_COMPAT for -w" pm_mkdir_s $LOCALBASE_COMPAT fi - pm_sv Copying old shared libraries for -w + pm_sv 'Copying old shared libraries for -w' $PM_SU_CMD cp -p $temp ${LOCALBASE_COMPAT}/ pm_sv Running ldconfig $PM_SU_CMD /etc/rc.d/ldconfig start > /dev/null @@ -3409,13 +3409,13 @@ if [ -n "$upg_port" -o -n "$ro_upg_port" if [ -n "$REPLACE_ORIGIN" -a -n "$ro_upg_port" ]; then # Delete any existing versions of the old port - pm_sv Running pkg_delete for $ro_upg_port + pm_sv "Running pkg_delete for $ro_upg_port" pm_pkg_delete_s -f $ro_upg_port fi # Could be empty if -o if [ -n "$upg_port" ]; then - pm_sv Running pkg_delete for $upg_port + pm_sv "Running pkg_delete for $upg_port" pm_pkg_delete_s -f $upg_port fi From owner-svn-src-user@FreeBSD.ORG Tue Aug 10 07:18:18 2010 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 032AA1065674; Tue, 10 Aug 2010 07:18:18 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E6B2B8FC12; Tue, 10 Aug 2010 07:18:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7A7IH19045527; Tue, 10 Aug 2010 07:18:17 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7A7IH0U045525; Tue, 10 Aug 2010 07:18:17 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008100718.o7A7IH0U045525@svn.freebsd.org> From: Doug Barton Date: Tue, 10 Aug 2010 07:18:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211133 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2010 07:18:18 -0000 Author: dougb Date: Tue Aug 10 07:18:17 2010 New Revision: 211133 URL: http://svn.freebsd.org/changeset/base/211133 Log: While we're doing the first pass, instead of generating a list of all the ports we see (which usually ends up being a duplicate of CUR_DEPS) keep a list of just those ports that need updating. This has many benefits: 1. While doing the first pass we can use the list the same way, whilst keeping CUR_DEPS for now. The latter is still deeply integrated, and useful. The major benefit here is that for example in -a mode we cut the stack space used very nearly in half. This can be significant if the user has a lot of ports installed, and is the cause of most (if not all) of the "argument list too long" errors that users have reported. 2. As a side effect of generating the list I can now use it in -a mode. I'm leaving the old code there for now till I'm sure this works, is safe, etc.; but it's much faster to just run updates for the list of ports that need them, rather than going through every port again (even with CUR_DEPS helping). 3. This will also serve as the basis for future work on a couple of fronts: a. If the current run fails I can now print a "To resume quickly do this:" message. This is not implemented yet, but I am currently updating the list as things are built for that purpose. b. Way down the road I'm going to use code in this same neighborhood to keep track of what depends on what to implement the "continue with everything else after something fails" idea. While I'm here take advantage of the slightly improved mechanism to fix a buglet. Now that we can be more deterministic in multiport() about what is a dependency and what isn't, tune up the term_printf() stuff there to finally make sense. Also, zero out the IPC_SAVE file right before we write to it both in the first pass and during the build phase. That lets us eliminate a useless write to the file during initialization. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Tue Aug 10 06:58:12 2010 (r211132) +++ user/dougb/portmaster/portmaster Tue Aug 10 07:18:17 2010 (r211133) @@ -219,20 +219,24 @@ safe_exit () { [ -n "$grep_deps" ] && pm_unlink $grep_deps # Save state for the parent process to read back in - echo "CUR_DEPS='$CUR_DEPS'" >> $IPC_SAVE - echo "dep_of_deps='$dep_of_deps'" >> $IPC_SAVE if [ -z "$PM_FIRST_PASS" ]; then + > $IPC_SAVE echo "DISPLAY_LIST='$DISPLAY_LIST'" >> $IPC_SAVE echo "INSTALLED_LIST='$INSTALLED_LIST'" >> $IPC_SAVE [ -n "$PM_DEL_BUILD_ONLY" ] && echo "build_deps_il='$build_deps_il'" >> $IPC_SAVE + + PM_NEEDS_UPDATE=${PM_NEEDS_UPDATE#* } else # Do these here so +IGNOREME can modify them echo "num_of_deps='$num_of_deps'" >> $IPC_SAVE echo "build_l='$build_l'" >> $IPC_SAVE [ -z "$NO_DEP_UPDATES" ] && echo 'unset NO_DEP_UPDATES' >> $IPC_SAVE fi + echo "CUR_DEPS='$CUR_DEPS'" >> $IPC_SAVE + echo "dep_of_deps='$dep_of_deps'" >> $IPC_SAVE + echo "PM_NEEDS_UPDATE='$PM_NEEDS_UPDATE'" >> $IPC_SAVE [ -z "$NO_BACKUP" -a -z "$BACKUP" ] && echo "NB_DELETE='$NB_DELETE'" >> $IPC_SAVE [ -n "$PM_MULTI_BUILT" ] && echo "PM_MULTI_BUILT='$PM_MULTI_BUILT'" >> $IPC_SAVE if [ -n "$INTERACTIVE_UPDATE" ]; then @@ -377,7 +381,7 @@ pm_cd_pd () { builtin cd $pd/$1 2>/dev/ fail "Cannot cd to port directory: $pd/$1"; } pm_kill () { /bin/kill $* >/dev/null 2>/dev/null; } pm_make () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH build_l; - unset -v MASTER_RB_LIST PM_FP_SEEN_LIST; + unset -v MASTER_RB_LIST; /usr/bin/nice /usr/bin/make $PM_MAKE_ARGS $*; ); } pm_make_b () { /usr/bin/make $PM_MAKE_ARGS BEFOREPORTMK=bpm $*; } pm_mktemp () { /usr/bin/mktemp -t f-${PM_PARENT_PID}-$1 || @@ -392,7 +396,7 @@ pm_unlink () { /bin/test -e $1 && /bin/u pm_find_s () { $PM_SU_CMD /usr/bin/find $*; } pm_install_s () { $PM_SU_CMD /usr/bin/install -o root -g wheel -m 644 $1 $2; } pm_make_s () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH build_l; - unset -v MASTER_RB_LIST PM_FP_SEEN_LIST; + unset -v MASTER_RB_LIST; $PM_SU_CMD /usr/bin/nice /usr/bin/make $PM_MAKE_ARGS $*; ); } pm_mkdir_s () { $PM_SU_CMD /bin/mkdir -p $1; } pm_pkg_delete_s () { $PM_SU_CMD /usr/sbin/pkg_delete $*; } @@ -2061,13 +2065,19 @@ term_printf () { printf "\033]0;${0##*/}: ${PM_PARENT_PORT}${1}\007" } -update_build_l () { - [ -n "$PM_NO_CONFIRM" ] && return +update_pm_nu () { + case "$PM_NEEDS_UPDATE" in *\ $1\ *) return ;; esac + PM_NEEDS_UPDATE="${PM_NEEDS_UPDATE}${1} " +} + +update_build_l () { local origin iport new_port case "$1" in */*) origin=$1 + update_pm_nu $origin + [ -n "$PM_NO_CONFIRM" ] && return case "$build_l" in *\ $origin\\*) return ;; esac iport=`iport_from_origin $origin` if [ -z "$iport" ]; then @@ -2075,10 +2085,13 @@ update_build_l () { return fi ;; *) iport=$1 - case "$build_l" in *\ $iport\ *|*\ $iport\\*) return ;; esac - origin=`origin_from_pdb $1` ;; + origin=`origin_from_pdb $1` + update_pm_nu $origin + case "$build_l" in *\ $iport\ *|*\ $iport\\*) return ;; esac ;; esac + [ -n "$PM_NO_CONFIRM" ] && return + if [ -z "$PM_INDEX_ONLY" ]; then pm_cd $pd/$origin && new_port=`pm_make -V PKGNAME` else @@ -2274,7 +2287,7 @@ dependency_check () { # Do this first to catch out of date dependencies [ -n "$PM_FIRST_PASS" ] && - case "$PM_FP_SEEN_LIST" in *:${origin}:*) continue ;; esac + case "$PM_NEEDS_UPDATE" in *\ $origin\ *) continue ;; esac [ -z "$URB_YES" ] && case "$CUR_DEPS" in *:${origin}:*) continue ;; esac @@ -2414,6 +2427,8 @@ post_first_pass () { term_printf fi + PM_NEEDS_UPDATE=${PM_NEEDS_UPDATE# } + action=build if [ "$PM_PACKAGES" = only ]; then action=install @@ -2423,7 +2438,7 @@ post_first_pass () { echo ''; echo "===>>> Starting $action for $* <<<==="; echo '' - unset PM_FP_SEEN_LIST PM_FIRST_PASS PM_NO_CONFIRM + unset PM_FIRST_PASS PM_NO_CONFIRM dep_of_deps=0 @@ -2472,7 +2487,7 @@ multiport () { PM_MULTI_PORTS=':' ; PM_MULTI_BUILT=':' export PM_MULTI_PORTS PM_MULTI_BUILT - local port worklist_temp worklist portlist numports num + local port worklist_temp worklist portlist numports origin num # Expand globs and check that the directories exist for port in "$@"; do @@ -2500,7 +2515,6 @@ multiport () { esac done - numports=0 for port in $worklist_temp; do check_exclude $port || continue check_interactive $port || continue @@ -2508,8 +2522,6 @@ multiport () { worklist="$worklist $port" portlist="${portlist}\t${port}\n" PM_MULTI_PORTS="${PM_MULTI_PORTS}${port}:" - numports=$(( $numports + 1 )) - update_build_l $port done echo "===>>> Working on multiple ports:" @@ -2526,12 +2538,20 @@ multiport () { done fi - num=1 + numports=0 for port in $worklist; do - init_term_printf "$port ${num}/${numports}" + case "$port" in + */*) origin=$port ;; + *) origin=`origin_from_pdb $port` ;; + esac + + case "$PM_NEEDS_UPDATE" in *\ ${origin}\ *) continue ;; esac + + numports=$(( $numports + 1 )) + init_term_printf "$port ${numports}/${numports}" ($0 $ARGS $port) || fail "Update for $port failed" . $IPC_SAVE - num=$(( $num + 1 )) + update_build_l $port done check_fetch_only @@ -2539,7 +2559,7 @@ multiport () { fi export PM_BUILDING=pmbuildingmultiport - num=1 + num=0 for port in $worklist; do case "$PM_MULTI_BUILT" in *:${port}:*) continue ;; esac @@ -2552,10 +2572,10 @@ multiport () { continue fi ;; esac + num=$(( $num + 1 )) init_term_printf "$port ${num}/${numports}" ($0 $ARGS $port) || fail "Update for $port failed" . $IPC_SAVE - num=$(( $num + 1 )) done safe_exit } @@ -2660,9 +2680,9 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S fi fi - PM_FP_SEEN_LIST=':' ; PM_FIRST_PASS=pm_first_pass + PM_FIRST_PASS=pm_first_pass ; PM_NEEDS_UPDATE=' ' NO_DEP_UPDATES=no_dep_updates ; build_l='' - export PM_FP_SEEN_LIST PM_FIRST_PASS NO_DEP_UPDATES build_l + export PM_FIRST_PASS PM_NEEDS_UPDATE NO_DEP_UPDATES build_l if [ -n "$PM_BUILD_ONLY_LIST" ]; then run_dl_g='' ; build_only_dl_g='' ; rundep_list='' @@ -2688,9 +2708,6 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S export DI_FILES=`pm_mktemp DI-FILES` [ $# -gt 1 -a -z "$REPLACE_ORIGIN" ] && multiport "$@" -elif [ -z "$SHOW_WORK" ]; then - # Zero out this file so that we can save our data to it safely - > $IPC_SAVE fi # This has to come after the initialization, it uses all the same stuff @@ -2716,7 +2733,7 @@ all_first_pass () { CUR_DEPS="${CUR_DEPS}${iport}:"; continue; } - case "$PM_FP_SEEN_LIST" in *:${origin}:*) continue ;; esac + case "$PM_NEEDS_UPDATE" in *\ $origin\ *) continue ;; esac [ -n "$PM_BUILD_ONLY_LIST" ] && run_dl_g="$run_dl_g ${pd}/${origin} " @@ -2724,8 +2741,6 @@ all_first_pass () { PM_DEPTH= check_for_updates $iport $origin || fail 'Update failed' - - PM_FP_SEEN_LIST="${PM_FP_SEEN_LIST}${origin}:" done } [ -n "$DI_FILES" ] && (read_distinfos)& @@ -2765,6 +2780,7 @@ all_first_pass () { export PM_BUILDING=pmbuildingall +if ! : ; then for iport in $roots $trunks $branches $leaves; do # Probably got updated as a dependency for something else [ -d "$pdb/$iport" ] || continue @@ -2790,6 +2806,11 @@ all_first_pass () { # We got here, so we know we have to build it update_port $iport done +fi + + unset roots trunks branches leaves + + for origin in $PM_NEEDS_UPDATE; do update_port $origin; done echo "===>>> Update check of installed ports complete" ; echo '' safe_exit @@ -2924,9 +2945,6 @@ fi # START -# Should only be reached for multiport already built as a dependency -case "$PM_FP_SEEN_LIST" in *:${portdir}:*) safe_exit ;; esac - [ -z "$PM_INDEX_ONLY" ] && { pm_cd $pd/$portdir || no_valid_port; } if [ -z "$PM_DEPTH" ]; then @@ -3024,8 +3042,6 @@ if [ -n "$PM_FIRST_PASS" ]; then [ -z "$PM_PACKAGES" -a -z "$PM_NO_MAKE_CONFIG" ] && make_config - PM_FP_SEEN_LIST="${PM_FP_SEEN_LIST}${portdir}:" - dep_check_type='build-depends-list run-depends-list' [ -n "$RECURSE_THOROUGH" ] && dep_check_type=all-depends-list dependency_check "$dep_check_type" @@ -3035,8 +3051,7 @@ if [ -n "$PM_FIRST_PASS" ]; then if [ ! "$$" -eq "$PM_PARENT_PID" ]; then # Save state for the parent process to read back in - echo "PM_FP_SEEN_LIST='$PM_FP_SEEN_LIST'" > $IPC_SAVE - + > $IPC_SAVE if [ "$PM_BUILD_ONLY_LIST" = pmp_doing_build_deps ]; then echo "build_only_dl_g='$build_only_dl_g'" >> $IPC_SAVE echo "run_dl_g='$run_dl_g'" >> $IPC_SAVE From owner-svn-src-user@FreeBSD.ORG Tue Aug 10 14:44:21 2010 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 1ECF31065686; Tue, 10 Aug 2010 14:44:21 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DF4E8FC2D; Tue, 10 Aug 2010 14:44:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7AEiKmr049088; Tue, 10 Aug 2010 14:44:20 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7AEiKkD049085; Tue, 10 Aug 2010 14:44:20 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008101444.o7AEiKkD049085@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 10 Aug 2010 14:44:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211147 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2010 14:44:21 -0000 Author: des Date: Tue Aug 10 14:44:20 2010 New Revision: 211147 URL: http://svn.freebsd.org/changeset/base/211147 Log: This is a small program that runs a series of performance tests designed to reveal the physical block size of a disk. It performs a series of staggered reads and / or writes of different lengths at different alignments. The idea is that a disk that has a large physical blocksize but simulates a smaller one will perform poorly, due to read-modify-write, except when both the I/O size and the offset are multiples of the physical block size. The program supports read-only, write-only and read-write tests. The default is write-only. A read-write test is probably not very useful, because it primes the cache in cases where the disk would actually perform an extra read. A read-only test is useless except as a quick way to verify that the program works. Note that the program currently assumes a logical block size of 512 bytes and that the parameters (size range, interval and iterations) are hardcoded. Added: user/des/phybs/ user/des/phybs/Makefile (contents, props changed) user/des/phybs/phybs.c (contents, props changed) Added: user/des/phybs/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/phybs/Makefile Tue Aug 10 14:44:20 2010 (r211147) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +PROG = phybs +CSTD ?= c99 +WARNS ?= 6 +MAN = # none + +.include "../Makefile.inc" +.include Added: user/des/phybs/phybs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/phybs/phybs.c Tue Aug 10 14:44:20 2010 (r211147) @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2010 Dag-Erling Coïdan Smørgrav + * 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 + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include +#include +#include +#include + +#define MINSIZE 512 +#define MAXSIZE 8192 +#define STEP MAXSIZE +#define COUNT 65536 + +static int opt_r = 0; +static int opt_w = 1; + +static void +scan(int fd, size_t size, off_t offset, off_t step, unsigned int count) +{ + struct timeval t0, t1; + unsigned long usec; + ssize_t rlen, wlen; + char *buf; + + printf("%8u%8lu%8lu%8lu", count, (unsigned long)size, + (unsigned long)offset, (unsigned long)step); + fflush(stdout); + if ((buf = malloc(size)) == NULL) + err(1, "malloc()"); + memset(buf, 0, size); + if (gettimeofday(&t0, NULL) == -1) + err(1, "gettimeofday()"); + for (unsigned int i = 0; i < count; ++i, offset += step) { + if (opt_r) { + if (lseek(fd, offset, SEEK_SET) != offset) + err(1, "lseek(%lu)", (unsigned long)offset); + if ((rlen = read(fd, buf, size)) == -1) + err(1, "read(%lu)", (unsigned long)size); + if (rlen < (ssize_t)size) + errx(1, "short read: %ld < %lu", + (long)rlen, (unsigned long)size); + } + if (opt_w) { + if (lseek(fd, offset, SEEK_SET) != offset) + err(1, "lseek(%lu)", (unsigned long)offset); + if ((wlen = write(fd, buf, size)) == -1) + err(1, "write(%lu)", (unsigned long)size); + if (wlen < (ssize_t)size) + errx(1, "short write: %ld < %lu", + (long)wlen, (unsigned long)size); + } + } + if (gettimeofday(&t1, NULL) == -1) + err(1, "gettimeofday()"); + usec = t1.tv_sec * 1000000 + t1.tv_usec; + usec -= t0.tv_sec * 1000000 + t0.tv_usec; + printf("%12lu%8lu%8lu\n", usec / 1000, + count * 1000000 / usec, + count * size * 1000000 / 1024 / usec); + free(buf); +} + +static void +usage(void) +{ + + fprintf(stderr, "usage: phybs [-R | -r] [-W | -w] device\n"); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + char *device; + int fd, opt; + + while ((opt = getopt(argc, argv, "RrWw")) != -1) + switch (opt) { + case 'R': + opt_r = 0; + break; + case 'r': + opt_r = 1; + break; + case 'W': + opt_w = 0; + break; + case 'w': + opt_w = 1; + break; + default: + usage(); + } + + argc -= optind; + argv += optind; + + if (argc != 1) + usage(); + + if (!opt_r && !opt_w) + opt_r = opt_w = 1; + + device = argv[0]; + if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) + err(1, "open(%s)", device); + printf("%8s%8s%8s%8s%12s%8s%8s\n", + "count", "size", "offset", "step", + "msec", "tps", "kBps"); + for (size_t size = MINSIZE; size <= MAXSIZE; size *= 2) + for (off_t offset = 0; offset < (off_t)size; offset += 512) + scan(fd, size, offset, STEP, COUNT); + close(fd); + exit(0); +} From owner-svn-src-user@FreeBSD.ORG Tue Aug 10 17:06:38 2010 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 CF1E21065672; Tue, 10 Aug 2010 17:06:38 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9A0758FC13; Tue, 10 Aug 2010 17:06:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7AH6cLk081152; Tue, 10 Aug 2010 17:06:38 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7AH6cWN081151; Tue, 10 Aug 2010 17:06:38 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008101706.o7AH6cWN081151@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 10 Aug 2010 17:06:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211150 - in user/des: phybs sizes X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2010 17:06:38 -0000 Author: des Date: Tue Aug 10 17:06:38 2010 New Revision: 211150 URL: http://svn.freebsd.org/changeset/base/211150 Log: Remove dependence on ../Makefile.inc Modified: user/des/phybs/Makefile user/des/sizes/Makefile Modified: user/des/phybs/Makefile ============================================================================== --- user/des/phybs/Makefile Tue Aug 10 16:14:10 2010 (r211149) +++ user/des/phybs/Makefile Tue Aug 10 17:06:38 2010 (r211150) @@ -5,5 +5,4 @@ CSTD ?= c99 WARNS ?= 6 MAN = # none -.include "../Makefile.inc" .include Modified: user/des/sizes/Makefile ============================================================================== --- user/des/sizes/Makefile Tue Aug 10 16:14:10 2010 (r211149) +++ user/des/sizes/Makefile Tue Aug 10 17:06:38 2010 (r211150) @@ -1,8 +1,8 @@ # $FreeBSD$ PROG = sizes +CSTD ?= c99 WARNS ?= 6 MAN = # none -.include "../Makefile.inc" .include From owner-svn-src-user@FreeBSD.ORG Tue Aug 10 18:58:06 2010 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 8153D106564A; Tue, 10 Aug 2010 18:58:06 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 717B78FC1E; Tue, 10 Aug 2010 18:58:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7AIw6Y4006104; Tue, 10 Aug 2010 18:58:06 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7AIw6Bh006102; Tue, 10 Aug 2010 18:58:06 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008101858.o7AIw6Bh006102@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 10 Aug 2010 18:58:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211152 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2010 18:58:06 -0000 Author: des Date: Tue Aug 10 18:58:06 2010 New Revision: 211152 URL: http://svn.freebsd.org/changeset/base/211152 Log: Increase MINSIZE; there isn't much point in doing 512-byte transactions, as they will always be either perfectly aligned or short. Increase STEP to MAXSIZE * 4; having STEP equal to MAXSIZE means that the last round actually tests sequential reading / writing, which is not what we're after. Instead of testing all offsets from 0 to size, test 0 and power-of-two multiples of BSIZE, since we assume that the physical block size is a power-of-two multiple of BSIZE. This should both shorten the test's run time and improve the significance of its output. Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Tue Aug 10 18:29:39 2010 (r211151) +++ user/des/phybs/phybs.c Tue Aug 10 18:58:06 2010 (r211152) @@ -36,9 +36,10 @@ #include #include -#define MINSIZE 512 +#define BSIZE 512 +#define MINSIZE 1024 #define MAXSIZE 8192 -#define STEP MAXSIZE +#define STEP (MAXSIZE * 4) #define COUNT 65536 static int opt_r = 0; @@ -137,9 +138,12 @@ main(int argc, char *argv[]) printf("%8s%8s%8s%8s%12s%8s%8s\n", "count", "size", "offset", "step", "msec", "tps", "kBps"); - for (size_t size = MINSIZE; size <= MAXSIZE; size *= 2) - for (off_t offset = 0; offset < (off_t)size; offset += 512) + for (size_t size = MINSIZE; size <= MAXSIZE; size *= 2) { + printf("\n"); + scan(fd, size, 0, STEP, COUNT); + for (off_t offset = BSIZE; offset <= (off_t)size; offset *= 2) scan(fd, size, offset, STEP, COUNT); + } close(fd); exit(0); } From owner-svn-src-user@FreeBSD.ORG Wed Aug 11 05:30:53 2010 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 1B299106566B; Wed, 11 Aug 2010 05:30:53 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0AB928FC1F; Wed, 11 Aug 2010 05:30:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7B5UqqV050651; Wed, 11 Aug 2010 05:30:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7B5UqLY050648; Wed, 11 Aug 2010 05:30:52 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201008110530.o7B5UqLY050648@svn.freebsd.org> From: Adrian Chadd Date: Wed, 11 Aug 2010 05:30:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211162 - user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 11 Aug 2010 05:30:53 -0000 Author: adrian Date: Wed Aug 11 05:30:52 2010 New Revision: 211162 URL: http://svn.freebsd.org/changeset/base/211162 Log: Since the AR_PHY_AGC_CONTROL flags are also in AR5212, look at migrating the NF-cal related routines I've written out from AR5416 to here. This adds AR5212 versions; it doesn't delete the AR5416 versions (yet). Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212.h user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212.h ============================================================================== --- user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212.h Wed Aug 11 04:55:58 2010 (r211161) +++ user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212.h Wed Aug 11 05:30:52 2010 (r211162) @@ -608,4 +608,8 @@ extern void ar5212AniPoll(struct ath_hal const struct ieee80211_channel *); extern void ar5212AniReset(struct ath_hal *, const struct ieee80211_channel *, HAL_OPMODE, int); + +extern HAL_BOOL ar5212IsNFCalInProgress(struct ath_hal *ah); +extern HAL_BOOL ar5212WaitNFCalComplete(struct ath_hal *ah, int i); + #endif /* _ATH_AR5212_H_ */ Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c ============================================================================== --- user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Wed Aug 11 04:55:58 2010 (r211161) +++ user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Wed Aug 11 05:30:52 2010 (r211162) @@ -567,13 +567,13 @@ ar5212SetDecompMask(struct ath_hal *ah, { struct ath_hal_5212 *ahp = AH5212(ah); - if (keyidx >= HAL_DECOMP_MASK_SIZE) - return HAL_EINVAL; - OS_REG_WRITE(ah, AR_DCM_A, keyidx); - OS_REG_WRITE(ah, AR_DCM_D, en ? AR_DCM_D_EN : 0); - ahp->ah_decompMask[keyidx] = en; + if (keyidx >= HAL_DECOMP_MASK_SIZE) + return HAL_EINVAL; + OS_REG_WRITE(ah, AR_DCM_A, keyidx); + OS_REG_WRITE(ah, AR_DCM_D, en ? AR_DCM_D_EN : 0); + ahp->ah_decompMask[keyidx] = en; - return AH_TRUE; + return AH_TRUE; } /* Setup coverage class */ @@ -646,7 +646,7 @@ ar5212Use32KHzclock(struct ath_hal *ah, struct ath_hal_5212 *ahp = AH5212(ah); return ath_hal_eepromGetFlag(ah, AR_EEP_32KHZCRYSTAL) && (ahp->ah_enable32kHzClock == USE_32KHZ || - ahp->ah_enable32kHzClock == AUTO_32KHZ); + ahp->ah_enable32kHzClock == AUTO_32KHZ); } else return AH_FALSE; } @@ -675,16 +675,16 @@ ar5212SetupClock(struct ath_hal *ah, HAL if (IS_2413(ah) || IS_5413(ah) || IS_2417(ah)) { OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_LIMIT, 0x26); - OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0d); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x07); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x3f); + OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0d); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x07); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x3f); /* # Set sleep clock rate to 32 KHz. */ OS_REG_RMW_FIELD(ah, AR_PCICFG, AR_PCICFG_SCLK_RATE_IND, 0x2); } else { OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_LIMIT, 0x0a); - OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0c); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x03); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x20); + OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0c); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x03); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x20); OS_REG_RMW_FIELD(ah, AR_PCICFG, AR_PCICFG_SCLK_RATE_IND, 0x3); } } else { @@ -702,8 +702,8 @@ ar5212SetupClock(struct ath_hal *ah, HAL OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x32); else OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0e); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); OS_REG_WRITE(ah, AR_PHY_REFCLKPD, IS_RAD5112_ANY(ah) || IS_5413(ah) || IS_2417(ah) ? 0x14 : 0x18); OS_REG_RMW_FIELD(ah, AR_USEC, AR_USEC_USEC32, @@ -731,9 +731,9 @@ ar5212RestoreClock(struct ath_hal *ah, H */ OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_CONTROL, 0x1f); OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_LIMIT, 0x7f); - OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0e); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); + OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0e); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); OS_REG_WRITE(ah, AR_PHY_REFCLKPD, IS_RAD5112_ANY(ah) || IS_5413(ah) ? 0x14 : 0x18); } @@ -1071,3 +1071,39 @@ ar5212GetDiagState(struct ath_hal *ah, i } return AH_FALSE; } + +/* + * Check whether there's an in-progress NF completion. + * + * Returns AH_TRUE if there's a in-progress NF calibration, AH_FALSE + * otherwise. + */ +HAL_BOOL +ar5212IsNFCalInProgress(struct ath_hal *ah) +{ + if (OS_REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) + return AH_TRUE; + return AH_FALSE; +} + +/* + * Wait for an in-progress NF calibration to complete. + * + * The completion function waits "i" times 10uS. + * It returns AH_TRUE if the NF calibration completed (or was never + * in progress); AH_FALSE if it was still in progress after "i" checks. + */ +HAL_BOOL +ar5212WaitNFCalComplete(struct ath_hal *ah, int i) +{ + int j; + if (i <= 0) + i = 1; /* it should run at least once */ + for (j = 0; j < i; j++) { + if (! ar5212IsNFCalInProgress(ah)) + return AH_TRUE; + OS_DELAY(10); + } + return AH_FALSE; +} + From owner-svn-src-user@FreeBSD.ORG Wed Aug 11 05:35:42 2010 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 B15611065670; Wed, 11 Aug 2010 05:35:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A112F8FC08; Wed, 11 Aug 2010 05:35:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7B5ZfOC051855; Wed, 11 Aug 2010 05:35:41 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7B5Zff6051853; Wed, 11 Aug 2010 05:35:41 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201008110535.o7B5Zff6051853@svn.freebsd.org> From: Adrian Chadd Date: Wed, 11 Aug 2010 05:35:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211163 - user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 11 Aug 2010 05:35:42 -0000 Author: adrian Date: Wed Aug 11 05:35:41 2010 New Revision: 211163 URL: http://svn.freebsd.org/changeset/base/211163 Log: Remove the ar5416 related NF Cal routines; they're in AR5212 now. Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c ============================================================================== --- user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Wed Aug 11 05:30:52 2010 (r211162) +++ user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Wed Aug 11 05:35:41 2010 (r211163) @@ -24,6 +24,8 @@ #include "ah_eeprom_v14.h" +#include "ar5212/ar5212.h" /* for NF cal related declarations */ + #include "ar5416/ar5416.h" #include "ar5416/ar5416reg.h" #include "ar5416/ar5416phy.h" @@ -34,8 +36,6 @@ static void ar5416StartNFCal(struct ath_hal *ah); static void ar5416LoadNF(struct ath_hal *ah, const struct ieee80211_channel *); static int16_t ar5416GetNf(struct ath_hal *, struct ieee80211_channel *); -static int ar5416IsNFCalInProgress(struct ath_hal *ah); -static int ar5416WaitNfComplete(struct ath_hal *ah, int i); /* * Determine if calibration is supported by device and channel flags @@ -227,7 +227,7 @@ ar5416InitCal(struct ath_hal *ah, const * Try to make sure the above NF cal completes, just so * it doesn't clash with subsequent percals -adrian */ - if (! ar5416WaitNfComplete(ah, 10000)) { + if (! ar5212WaitNFCalComplete(ah, 10000)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: initial NF calibration did " "not complete in time; noisy environment?\n", __func__); return AH_FALSE; @@ -412,7 +412,7 @@ ar5416PerCalibrationN(struct ath_hal *ah * the CCA registers and kick another NF calibration ; periodic * calibrations shouldn't be occuring during a NF calibration. */ - if (ar5416IsNFCalInProgress(ah)) { + if (ar5212IsNFCalInProgress(ah)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: NF calibration in-progress; skipping\n", __func__); @@ -606,7 +606,7 @@ ar5416LoadNF(struct ath_hal *ah, const s OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); /* Wait for load to complete, should be fast, a few 10s of us. */ - if (! ar5416WaitNfComplete(ah, 1000)) { + if (! ar5212WaitNFCalComplete(ah, 1000)) { /* * We timed out waiting for the noisefloor to load, probably due to an * in-progress rx. Simply return here and allow the load plenty of time @@ -678,41 +678,6 @@ ar5416UpdateNFHistBuff(struct ar5212NfCa } /* - * Check whether there's an in-progress NF completion. - * - * Returns AH_TRUE if there's a in-progress NF calibration, AH_FALSE - * otherwise. - */ -static int -ar5416IsNFCalInProgress(struct ath_hal *ah) -{ - if (OS_REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) - return AH_TRUE; - return FALSE; -} - -/* - * Wait for an in-progress calibration to complete. - * - * The completion function waits "i" times 10uS. - * It returns AH_TRUE if the NF calibration completed (or was never - * in progress); AH_FALSE if it was still in progress after "i" checks. - */ -static int -ar5416WaitNfComplete(struct ath_hal *ah, int i) -{ - int j; - if (i <= 0) - i = 1; /* it should run at least once */ - for (j = 0; j < i; j++) { - if (! ar5416IsNFCalInProgress(ah)) - return AH_TRUE; - OS_DELAY(10); - } - return AH_FALSE; -} - -/* * Read the NF and check it against the noise floor threshhold */ static int16_t @@ -720,7 +685,7 @@ ar5416GetNf(struct ath_hal *ah, struct i { int16_t nf, nfThresh; - if (ar5416IsNFCalInProgress(ah)) { + if (ar5212IsNFCalInProgress(ah)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: NF didn't complete in calibration window\n", __func__); nf = 0; From owner-svn-src-user@FreeBSD.ORG Wed Aug 11 06:22:20 2010 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 07E5A1065672; Wed, 11 Aug 2010 06:22:20 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC8A28FC3A; Wed, 11 Aug 2010 06:22:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7B6MJDs062774; Wed, 11 Aug 2010 06:22:19 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7B6MJqf062773; Wed, 11 Aug 2010 06:22:19 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008110622.o7B6MJqf062773@svn.freebsd.org> From: Doug Barton Date: Wed, 11 Aug 2010 06:22:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211164 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 11 Aug 2010 06:22:20 -0000 Author: dougb Date: Wed Aug 11 06:22:18 2010 New Revision: 211164 URL: http://svn.freebsd.org/changeset/base/211164 Log: After staring at this for so long during the whitespace cleanup I can't believe I didn't see this one. 99% non-functional except moving an echo '' up to where it should have been (the output to the user is the same). Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Wed Aug 11 05:35:41 2010 (r211163) +++ user/dougb/portmaster/portmaster Wed Aug 11 06:22:18 2010 (r211164) @@ -2967,74 +2967,72 @@ echo '' [ "$$" -eq "$PM_PARENT_PID" -a -n "$upg_port" ] && echo "===>>> Currently installed version: $upg_port" -if [ -z "$PM_INDEX_ONLY" ]; then - echo "===>>> Port directory: $pd/$portdir" +echo "===>>> Port directory: $pd/$portdir" ; echo '' - # Do these things first time through - if [ -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ]; then - if ! check_state; then - echo " ===>>> If you are sure you can build it, remove the" - echo " $state line in the Makefile and try again." - safe_exit 1 - fi - - # Do not start this in the background until we are sure we are going to build - [ "$$" -eq "$PM_PARENT_PID" -a -n "$DI_FILES" ] && { echo ''; (read_distinfos)& } - - # Handle the problem of manual fetching - [ -z "$PM_PACKAGES" ] && master_sites=`pm_make_b -V MASTER_SITES` - - if [ -n "$master_sites" ]; then - # PATCHFILES may get added after the first pass, but we want to - # do as much of this as we can, as early as we can, and - # patch files are usually small anyway. - distfiles=`pm_make -V ALLFILES | sed -e 's# *$##g'` - [ -n "$distfiles" ] && distfiles=" ${distfiles} " - - # Make sure that different ports using the same distfiles - # do not clobber each other's fetchs - for file in $distfiles; do - case "$file" in */*) file=`echo $file | sed s#/#_#g` ;; esac - if ! ls ${TMPDIR}/f-${PM_PARENT_PID}-${file}-* >/dev/null 2>&1; then - pm_mktemp ${file}-${portdir#*/} >/dev/null - else - DONT_FETCH=dont_fetch - break - fi - done - - if [ -z "$DONT_FETCH" -a -n "$distfiles" ]; then - echo "===>>> Launching 'make checksum' for $portdir in background" - fetchlog=`pm_mktemp fetchlog-${portdir#*/}` - (pm_make -DBATCH checksum >> $fetchlog 2>&1 && { - rm -f ${TMPDIR}/f-${PM_PARENT_PID}-*-${portdir#*/}.*; exit 0; } - allfiles=`pm_make -V ALLFILES` - pm_make delete-distfiles RESTRICTED_FILES="${allfiles}" \ - >> $fetchlog 2>&1 && - echo "===>>> RE-STARTING FETCH <<<===" >> $fetchlog - pm_make -DBATCH checksum >> $fetchlog 2>&1 - rm -f ${TMPDIR}/f-${PM_PARENT_PID}-*-${portdir#*/}.* )& +# Do these things first time through +if [ -z "$PM_INDEX_ONLY" -a -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ]; then + if ! check_state; then + echo " ===>>> If you are sure you can build it, remove the" + echo " $state line in the Makefile and try again." + safe_exit 1 + fi + + # Do not start this in the background until we are sure we are going to build + [ "$$" -eq "$PM_PARENT_PID" -a -n "$DI_FILES" ] && (read_distinfos)& + + # Handle the problem of manual fetching + [ -z "$PM_PACKAGES" ] && master_sites=`pm_make_b -V MASTER_SITES` + + if [ -n "$master_sites" ]; then + # PATCHFILES may get added after the first pass, but we want to + # do as much of this as we can, as early as we can, and + # patch files are usually small anyway. + distfiles=`pm_make -V ALLFILES | sed -e 's# *$##g'` + [ -n "$distfiles" ] && distfiles=" ${distfiles} " + + # Make sure that different ports using the same distfiles + # do not clobber each other's fetchs + for file in $distfiles; do + case "$file" in */*) file=`echo $file | sed s#/#_#g` ;; esac + if ! ls ${TMPDIR}/f-${PM_PARENT_PID}-${file}-* >/dev/null 2>&1; then + pm_mktemp ${file}-${portdir#*/} >/dev/null + else + DONT_FETCH=dont_fetch + break fi - unset master_sites distfiles file DONT_FETCH fetchlog allfiles - fi + done - if [ -z "$FETCH_ONLY" -a ! "$PM_PACKAGES" = only ]; then - TESTINT=`grep -l ^IS_INTERACTIVE Makefile` - else - [ -n "$ALL_FETCH" ] && safe_exit - fi - if [ -n "$TESTINT" ]; then - echo '' - echo "===>>> Warning: $portdir is interactive, and will likely" - echo " require attention during the build" - echo '' - echo -n "===>>> Press the [Enter] or [Return] key to continue " - read DISCARD - echo '' - unset TESTINT DISCARD - fi - fi # [ -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ] -fi # [ -z "$PM_INDEX_ONLY" ] + if [ -z "$DONT_FETCH" -a -n "$distfiles" ]; then + echo "===>>> Launching 'make checksum' for $portdir in background" + fetchlog=`pm_mktemp fetchlog-${portdir#*/}` + (pm_make -DBATCH checksum >> $fetchlog 2>&1 && { + rm -f ${TMPDIR}/f-${PM_PARENT_PID}-*-${portdir#*/}.*; exit 0; } + allfiles=`pm_make -V ALLFILES` + pm_make delete-distfiles RESTRICTED_FILES="${allfiles}" \ + >> $fetchlog 2>&1 && + echo "===>>> RE-STARTING FETCH <<<===" >> $fetchlog + pm_make -DBATCH checksum >> $fetchlog 2>&1 + rm -f ${TMPDIR}/f-${PM_PARENT_PID}-*-${portdir#*/}.* )& + fi + unset master_sites distfiles file DONT_FETCH fetchlog allfiles + fi + + if [ -z "$FETCH_ONLY" -a ! "$PM_PACKAGES" = only ]; then + TESTINT=`grep -l ^IS_INTERACTIVE Makefile` + else + [ -n "$ALL_FETCH" ] && safe_exit + fi + if [ -n "$TESTINT" ]; then + echo '' + echo "===>>> Warning: $portdir is interactive, and will likely" + echo " require attention during the build" + echo '' + echo -n "===>>> Press the [Enter] or [Return] key to continue " + read DISCARD + echo '' + unset TESTINT DISCARD + fi +fi # [ -z "$PM_INDEX_ONLY" -a -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ] if [ -n "$PM_FIRST_PASS" ]; then [ "$$" -eq "$PM_PARENT_PID" -a -n "$PM_BUILD_ONLY_LIST" ] && From owner-svn-src-user@FreeBSD.ORG Wed Aug 11 06:33:38 2010 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 A3249106568A; Wed, 11 Aug 2010 06:33:38 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 93E9F8FC0A; Wed, 11 Aug 2010 06:33:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7B6XcOJ065418; Wed, 11 Aug 2010 06:33:38 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7B6XcFQ065416; Wed, 11 Aug 2010 06:33:38 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008110633.o7B6XcFQ065416@svn.freebsd.org> From: Doug Barton Date: Wed, 11 Aug 2010 06:33:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211166 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 11 Aug 2010 06:33:38 -0000 Author: dougb Date: Wed Aug 11 06:33:38 2010 New Revision: 211166 URL: http://svn.freebsd.org/changeset/base/211166 Log: If using --index-only and neither INDEXDIR nor PORTSDIR are set, set INDEXDIR to $TMPDIR so that we can proceed. That makes PACKAGES the only variable the user has to set to use --index-only and --packages-only with no $PORTSDIR and no ports directory. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Wed Aug 11 06:29:40 2010 (r211165) +++ user/dougb/portmaster/portmaster Wed Aug 11 06:33:38 2010 (r211166) @@ -534,6 +534,9 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then INDEXFILE=INDEX-${ver%%\.*} unset ver fi + + [ -z "$INDEXDIR" -a -n "$PM_INDEX_ONLY" -z "$pd" ] && INDEXDIR="$TMPDIR" + PM_INDEX="${INDEXDIR:-$pd}/${INDEXFILE}" if [ -z "$PM_NO_INDEX_FETCH" ]; then From owner-svn-src-user@FreeBSD.ORG Wed Aug 11 06:49:30 2010 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 006D71065670; Wed, 11 Aug 2010 06:49:30 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E18698FC0A; Wed, 11 Aug 2010 06:49:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7B6nTX5069286; Wed, 11 Aug 2010 06:49:29 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7B6nTgE069285; Wed, 11 Aug 2010 06:49:29 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008110649.o7B6nTgE069285@svn.freebsd.org> From: Doug Barton Date: Wed, 11 Aug 2010 06:49:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211168 - user/dougb/portmaster/files X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 11 Aug 2010 06:49:30 -0000 Author: dougb Date: Wed Aug 11 06:49:29 2010 New Revision: 211168 URL: http://svn.freebsd.org/changeset/base/211168 Log: As of r211166 PACKAGES is the only variable needed for --index-only and no /usr/ports and/or $PORTSDIR Modified: user/dougb/portmaster/files/portmaster.8 Modified: user/dougb/portmaster/files/portmaster.8 ============================================================================== --- user/dougb/portmaster/files/portmaster.8 Wed Aug 11 06:43:14 2010 (r211167) +++ user/dougb/portmaster/files/portmaster.8 Wed Aug 11 06:49:29 2010 (r211168) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 7, 2010 +.Dd August 8, 2010 .Dt PORTMASTER 8 .Os .Sh NAME @@ -572,14 +572,13 @@ When using the .Fl -index-only option the .Ev PACKAGES -and -.Ev INDEXDIR -variables must each be set to a dirctory where the +variable must be set to a dirctory where the superuser has write permissions. Other useful variables include: .Bd -literal MASTER_SITE_INDEX (default http://www.FreeBSD.org/ports/) FETCHINDEX (default fetch -am -o) +INDEXDIR (default $PORTSDIR, or $TMPDIR for --index-only) INDEXFILE (default auto per FreeBSD version) .Ed .Pp From owner-svn-src-user@FreeBSD.ORG Wed Aug 11 07:05:28 2010 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 6F1A3106567C; Wed, 11 Aug 2010 07:05:28 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5FDF78FC1A; Wed, 11 Aug 2010 07:05:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7B75SsY073085; Wed, 11 Aug 2010 07:05:28 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7B75RMN073083; Wed, 11 Aug 2010 07:05:27 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008110705.o7B75RMN073083@svn.freebsd.org> From: Doug Barton Date: Wed, 11 Aug 2010 07:05:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211170 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 11 Aug 2010 07:05:28 -0000 Author: dougb Date: Wed Aug 11 07:05:27 2010 New Revision: 211170 URL: http://svn.freebsd.org/changeset/base/211170 Log: Blah, I knew that line from r211166 looked funny Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Wed Aug 11 07:02:08 2010 (r211169) +++ user/dougb/portmaster/portmaster Wed Aug 11 07:05:27 2010 (r211170) @@ -535,7 +535,7 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then unset ver fi - [ -z "$INDEXDIR" -a -n "$PM_INDEX_ONLY" -z "$pd" ] && INDEXDIR="$TMPDIR" + [ -z "$INDEXDIR" -a -n "$PM_INDEX_ONLY" -a -z "$pd" ] && INDEXDIR="$TMPDIR" PM_INDEX="${INDEXDIR:-$pd}/${INDEXFILE}" From owner-svn-src-user@FreeBSD.ORG Thu Aug 12 19:15:21 2010 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 5B3621065698; Thu, 12 Aug 2010 19:15:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B7D18FC1C; Thu, 12 Aug 2010 19:15:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7CJFLLu069383; Thu, 12 Aug 2010 19:15:21 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7CJFLxr069381; Thu, 12 Aug 2010 19:15:21 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008121915.o7CJFLxr069381@svn.freebsd.org> From: Doug Barton Date: Thu, 12 Aug 2010 19:15:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211231 - user/dougb/portmaster/files X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Aug 2010 19:15:21 -0000 Author: dougb Date: Thu Aug 12 19:15:21 2010 New Revision: 211231 URL: http://svn.freebsd.org/changeset/base/211231 Log: Document the change to the variable and behavior of -G Reminded by: jsa Modified: user/dougb/portmaster/files/portmaster.rc.sample.in Modified: user/dougb/portmaster/files/portmaster.rc.sample.in ============================================================================== --- user/dougb/portmaster/files/portmaster.rc.sample.in Thu Aug 12 17:17:05 2010 (r211230) +++ user/dougb/portmaster/files/portmaster.rc.sample.in Thu Aug 12 19:15:21 2010 (r211231) @@ -28,8 +28,7 @@ # ALWAYS_SCRUB_DISTFILES=dopt # # Do not run 'make config' for ports that need updating (-G) -# (This unsets --force-config) -# NO_RECURSIVE_CONFIG=Gopt +# PM_NO_MAKE_CONFIG=Gopt # # Hide the build and install processes in a log file (-H) # HIDE_BUILD=Hopt From owner-svn-src-user@FreeBSD.ORG Thu Aug 12 19:40:50 2010 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 6D3471065672; Thu, 12 Aug 2010 19:40:50 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4315C8FC15; Thu, 12 Aug 2010 19:40:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7CJeop4075419; Thu, 12 Aug 2010 19:40:50 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7CJeoWf075417; Thu, 12 Aug 2010 19:40:50 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008121940.o7CJeoWf075417@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Thu, 12 Aug 2010 19:40:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211233 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Aug 2010 19:40:50 -0000 Author: des Date: Thu Aug 12 19:40:49 2010 New Revision: 211233 URL: http://svn.freebsd.org/changeset/base/211233 Log: Parametrize minsize and maxsize, and instead of a fixed count, write a fixed amount of data. Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Thu Aug 12 19:26:27 2010 (r211232) +++ user/des/phybs/phybs.c Thu Aug 12 19:40:49 2010 (r211233) @@ -31,16 +31,18 @@ #include #include +#include #include #include #include #include -#define BSIZE 512 -#define MINSIZE 1024 -#define MAXSIZE 8192 -#define STEP (MAXSIZE * 4) -#define COUNT 65536 +#define BSIZE 512 + +static unsigned int minsize = 1024; +static unsigned int maxsize = 8192; +#define STEP (maxsize * 4) +static unsigned int total = (128 * 1024 * 1024); static int opt_r = 0; static int opt_w = 1; @@ -95,13 +97,14 @@ static void usage(void) { - fprintf(stderr, "usage: phybs [-R | -r] [-W | -w] device\n"); + fprintf(stderr, "usage: phybs [-R | -r] [-W | -w] device [min [max]]\n"); exit(1); } int main(int argc, char *argv[]) { + int64_t tmp; char *device; int fd, opt; @@ -126,23 +129,34 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (argc != 1) - usage(); - if (!opt_r && !opt_w) opt_r = opt_w = 1; - + if (argc < 1 || argc > 3) + usage(); device = argv[0]; + if (argc > 1) { + if (expand_number(argv[1], &tmp) != 0 || + tmp < BSIZE || (tmp & (tmp - 1)) != 0) + usage(); + minsize = tmp; + } + if (argc > 2) { + if (expand_number(argv[2], &tmp) != 0 || + tmp < minsize || (tmp & (tmp - 1)) != 0) + usage(); + maxsize = tmp; + } + if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) err(1, "open(%s)", device); printf("%8s%8s%8s%8s%12s%8s%8s\n", "count", "size", "offset", "step", "msec", "tps", "kBps"); - for (size_t size = MINSIZE; size <= MAXSIZE; size *= 2) { + for (size_t size = minsize; size <= maxsize; size *= 2) { printf("\n"); - scan(fd, size, 0, STEP, COUNT); + scan(fd, size, 0, STEP, total / size); for (off_t offset = BSIZE; offset <= (off_t)size; offset *= 2) - scan(fd, size, offset, STEP, COUNT); + scan(fd, size, offset, STEP, total / size); } close(fd); exit(0); From owner-svn-src-user@FreeBSD.ORG Thu Aug 12 22:20:20 2010 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 6D3B91065675; Thu, 12 Aug 2010 22:20:20 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D2E88FC14; Thu, 12 Aug 2010 22:20:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7CMKKha011434; Thu, 12 Aug 2010 22:20:20 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7CMKKOs011432; Thu, 12 Aug 2010 22:20:20 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008122220.o7CMKKOs011432@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Thu, 12 Aug 2010 22:20:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211246 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Aug 2010 22:20:20 -0000 Author: des Date: Thu Aug 12 22:20:20 2010 New Revision: 211246 URL: http://svn.freebsd.org/changeset/base/211246 Log: Show a progress bar when stdout is a tty. Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Thu Aug 12 22:16:37 2010 (r211245) +++ user/des/phybs/phybs.c Thu Aug 12 22:20:20 2010 (r211246) @@ -47,6 +47,10 @@ static unsigned int total = (128 * 1024 static int opt_r = 0; static int opt_w = 1; +static int tty = 0; +static char progress[] = " [----------------]" + "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; + static void scan(int fd, size_t size, off_t offset, off_t step, unsigned int count) { @@ -55,7 +59,7 @@ scan(int fd, size_t size, off_t offset, ssize_t rlen, wlen; char *buf; - printf("%8u%8lu%8lu%8lu", count, (unsigned long)size, + printf("%8u%8lu%8lu%8lu ", count, (unsigned long)size, (unsigned long)offset, (unsigned long)step); fflush(stdout); if ((buf = malloc(size)) == NULL) @@ -82,12 +86,18 @@ scan(int fd, size_t size, off_t offset, errx(1, "short write: %ld < %lu", (long)wlen, (unsigned long)size); } + if (tty && i % 256 == 0) { + progress[2 + (i * 16) / count] = '|'; + fputs(progress, stdout); + progress[2 + (i * 16) / count] = '-'; + fflush(stdout); + } } if (gettimeofday(&t1, NULL) == -1) err(1, "gettimeofday()"); usec = t1.tv_sec * 1000000 + t1.tv_usec; usec -= t0.tv_sec * 1000000 + t0.tv_usec; - printf("%12lu%8lu%8lu\n", usec / 1000, + printf("%10lu%8lu%8lu\n", usec / 1000, count * 1000000 / usec, count * size * 1000000 / 1024 / usec); free(buf); @@ -147,6 +157,8 @@ main(int argc, char *argv[]) maxsize = tmp; } + tty = isatty(STDIN_FILENO); + if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) err(1, "open(%s)", device); printf("%8s%8s%8s%8s%12s%8s%8s\n", From owner-svn-src-user@FreeBSD.ORG Thu Aug 12 22:22:41 2010 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 AC2FE1065670; Thu, 12 Aug 2010 22:22:41 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C2828FC12; Thu, 12 Aug 2010 22:22:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7CMMf3e012012; Thu, 12 Aug 2010 22:22:41 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7CMMf7U012010; Thu, 12 Aug 2010 22:22:41 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008122222.o7CMMf7U012010@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Thu, 12 Aug 2010 22:22:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211247 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Aug 2010 22:22:41 -0000 Author: des Date: Thu Aug 12 22:22:41 2010 New Revision: 211247 URL: http://svn.freebsd.org/changeset/base/211247 Log: braino: stdout, not stdin! Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Thu Aug 12 22:20:20 2010 (r211246) +++ user/des/phybs/phybs.c Thu Aug 12 22:22:41 2010 (r211247) @@ -157,14 +157,14 @@ main(int argc, char *argv[]) maxsize = tmp; } - tty = isatty(STDIN_FILENO); + tty = isatty(STDOUT_FILENO); if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) err(1, "open(%s)", device); printf("%8s%8s%8s%8s%12s%8s%8s\n", "count", "size", "offset", "step", "msec", "tps", "kBps"); - for (size_t size = minsize; size <= maxsize; size *= 2) { + for (size_t size = minsize; size < maxsize; size *= 2) { printf("\n"); scan(fd, size, 0, STEP, total / size); for (off_t offset = BSIZE; offset <= (off_t)size; offset *= 2) From owner-svn-src-user@FreeBSD.ORG Thu Aug 12 22:25:17 2010 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 1D19910656B4; Thu, 12 Aug 2010 22:25:17 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E73B08FC21; Thu, 12 Aug 2010 22:25:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7CMPGRG012609; Thu, 12 Aug 2010 22:25:16 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7CMPGJc012607; Thu, 12 Aug 2010 22:25:16 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008122225.o7CMPGJc012607@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Thu, 12 Aug 2010 22:25:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211248 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Aug 2010 22:25:17 -0000 Author: des Date: Thu Aug 12 22:25:16 2010 New Revision: 211248 URL: http://svn.freebsd.org/changeset/base/211248 Log: phybs needs libutil for expand_number() Modified: user/des/phybs/Makefile Modified: user/des/phybs/Makefile ============================================================================== --- user/des/phybs/Makefile Thu Aug 12 22:22:41 2010 (r211247) +++ user/des/phybs/Makefile Thu Aug 12 22:25:16 2010 (r211248) @@ -5,4 +5,7 @@ CSTD ?= c99 WARNS ?= 6 MAN = # none +LDADD = -lutil +DPADD = ${LIBUTIL} + .include From owner-svn-src-user@FreeBSD.ORG Thu Aug 12 23:36:36 2010 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 DBF8910656A6; Thu, 12 Aug 2010 23:36:36 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC0CE8FC08; Thu, 12 Aug 2010 23:36:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7CNaa4k028373; Thu, 12 Aug 2010 23:36:36 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7CNaa5U028371; Thu, 12 Aug 2010 23:36:36 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008122336.o7CNaa5U028371@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Thu, 12 Aug 2010 23:36:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211250 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 12 Aug 2010 23:36:36 -0000 Author: des Date: Thu Aug 12 23:36:36 2010 New Revision: 211250 URL: http://svn.freebsd.org/changeset/base/211250 Log: A previous commit changed a <= to a < in the wrong place. Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Thu Aug 12 22:46:31 2010 (r211249) +++ user/des/phybs/phybs.c Thu Aug 12 23:36:36 2010 (r211250) @@ -164,10 +164,10 @@ main(int argc, char *argv[]) printf("%8s%8s%8s%8s%12s%8s%8s\n", "count", "size", "offset", "step", "msec", "tps", "kBps"); - for (size_t size = minsize; size < maxsize; size *= 2) { + for (size_t size = minsize; size <= maxsize; size *= 2) { printf("\n"); scan(fd, size, 0, STEP, total / size); - for (off_t offset = BSIZE; offset <= (off_t)size; offset *= 2) + for (off_t offset = BSIZE; offset < (off_t)size; offset *= 2) scan(fd, size, offset, STEP, total / size); } close(fd); From owner-svn-src-user@FreeBSD.ORG Fri Aug 13 00:21:33 2010 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 3279C1065672; Fri, 13 Aug 2010 00:21:33 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 227968FC16; Fri, 13 Aug 2010 00:21:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7D0LXNY038263; Fri, 13 Aug 2010 00:21:33 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7D0LXhr038261; Fri, 13 Aug 2010 00:21:33 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008130021.o7D0LXhr038261@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Fri, 13 Aug 2010 00:21:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211251 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 13 Aug 2010 00:21:33 -0000 Author: des Date: Fri Aug 13 00:21:32 2010 New Revision: 211251 URL: http://svn.freebsd.org/changeset/base/211251 Log: Use size * 4 instead of a fixed interval. This may speed things up for smaller block sizes. Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Thu Aug 12 23:36:36 2010 (r211250) +++ user/des/phybs/phybs.c Fri Aug 13 00:21:32 2010 (r211251) @@ -41,7 +41,6 @@ static unsigned int minsize = 1024; static unsigned int maxsize = 8192; -#define STEP (maxsize * 4) static unsigned int total = (128 * 1024 * 1024); static int opt_r = 0; @@ -166,9 +165,9 @@ main(int argc, char *argv[]) "msec", "tps", "kBps"); for (size_t size = minsize; size <= maxsize; size *= 2) { printf("\n"); - scan(fd, size, 0, STEP, total / size); + scan(fd, size, 0, size * 4, total / size); for (off_t offset = BSIZE; offset < (off_t)size; offset *= 2) - scan(fd, size, offset, STEP, total / size); + scan(fd, size, offset, size * 4, total / size); } close(fd); exit(0); From owner-svn-src-user@FreeBSD.ORG Sat Aug 14 15:21:06 2010 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 70A1510656A3; Sat, 14 Aug 2010 15:21:06 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 462768FC1A; Sat, 14 Aug 2010 15:21:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7EFL64M031208; Sat, 14 Aug 2010 15:21:06 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7EFL6Xi031206; Sat, 14 Aug 2010 15:21:06 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008141521.o7EFL6Xi031206@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Sat, 14 Aug 2010 15:21:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211305 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 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, 14 Aug 2010 15:21:06 -0000 Author: des Date: Sat Aug 14 15:21:06 2010 New Revision: 211305 URL: http://svn.freebsd.org/changeset/base/211305 Log: getopt()ify minsize and maxsize Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Sat Aug 14 14:34:36 2010 (r211304) +++ user/des/phybs/phybs.c Sat Aug 14 15:21:06 2010 (r211305) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -106,28 +107,49 @@ static void usage(void) { - fprintf(stderr, "usage: phybs [-R | -r] [-W | -w] device [min [max]]\n"); + fprintf(stderr, "usage: phybs [-rw] [-l min] [-h max] device\n"); exit(1); } +static unsigned int +poweroftwo(char opt, const char *valstr, unsigned int min, unsigned int max) +{ + uint64_t val; + + if (expand_number(valstr, &val) != 0) { + fprintf(stderr, "-%c: invalid number\n", opt); + usage(); + } + if ((val & (val - 1)) != 0) { + fprintf(stderr, "-%c: not a power of two\n", opt); + usage(); + } + if (val < min || (max != 0 && val > max) || val > UINT_MAX) { + fprintf(stderr, "-%c: out of range\n", opt); + usage(); + } + return (val); +} + int main(int argc, char *argv[]) { - int64_t tmp; char *device; int fd, opt; - while ((opt = getopt(argc, argv, "RrWw")) != -1) + tty = isatty(STDOUT_FILENO); + + while ((opt = getopt(argc, argv, "h:l:rw")) != -1) switch (opt) { - case 'R': - opt_r = 0; + case 'h': + maxsize = poweroftwo(opt, optarg, minsize, 0); + break; + case 'l': + minsize = poweroftwo(opt, optarg, BSIZE, maxsize); break; case 'r': opt_r = 1; break; - case 'W': - opt_w = 0; - break; case 'w': opt_w = 1; break; @@ -140,23 +162,10 @@ main(int argc, char *argv[]) if (!opt_r && !opt_w) opt_r = opt_w = 1; - if (argc < 1 || argc > 3) + + if (argc != 1) usage(); device = argv[0]; - if (argc > 1) { - if (expand_number(argv[1], &tmp) != 0 || - tmp < BSIZE || (tmp & (tmp - 1)) != 0) - usage(); - minsize = tmp; - } - if (argc > 2) { - if (expand_number(argv[2], &tmp) != 0 || - tmp < minsize || (tmp & (tmp - 1)) != 0) - usage(); - maxsize = tmp; - } - - tty = isatty(STDOUT_FILENO); if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) err(1, "open(%s)", device);