From owner-svn-soc-all@FreeBSD.ORG Sun Jul 15 21:28:25 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 1FD31106564A for ; Sun, 15 Jul 2012 21:28:23 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 15 Jul 2012 21:28:23 +0000 Date: Sun, 15 Jul 2012 21:28:23 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120715212823.1FD31106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239437 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2012 21:28:25 -0000 Author: gmiller Date: Sun Jul 15 21:28:22 2012 New Revision: 239437 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239437 Log: r239381@FreeBSD-dev: root | 2012-07-13 16:00:37 -0500 Add a regression test for the previously-fixed recursive mutex bug. Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.t Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Sun Jul 15 20:51:41 2012 (r239436) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Sun Jul 15 21:28:22 2012 (r239437) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= lock-cycle +TESTS= lock-cycle recurse CFLAGS+= -DLOCK_PROFILING -g -Wall -Wextra -Werror -lthr_profile .PHONY: tests @@ -12,4 +12,7 @@ -rm -f ${TESTS} lock-cycle: lock-cycle.c - ${CC} -o lock-cycle lock-cycle.c ${CFLAGS} \ No newline at end of file + ${CC} -o lock-cycle lock-cycle.c ${CFLAGS} + +recurse: recurse.c + ${CC} -o recurse recurse.c ${CFLAGS} Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Sun Jul 15 20:51:41 2012 (r239436) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Sun Jul 15 21:28:22 2012 (r239437) @@ -130,10 +130,6 @@ check(record_count == 1); - pthread_statistics_begin_np(&stats); - pthread_statistics_next_np(&stats); - pthread_statistics_end_np(&stats); - check(strcmp(stats.file, "lock-cycle.c") == 0); check(stats.line == 16); @@ -168,10 +164,6 @@ check(record_count == 1); - pthread_statistics_begin_np(&stats); - pthread_statistics_next_np(&stats); - pthread_statistics_end_np(&stats); - check(strcmp(stats.file, "lock-cycle.c") == 0); check(stats.line == 16); @@ -182,8 +174,6 @@ stats.hold_time.tv_nsec / 1000; check(tm >= 30000); - printf("count = %d\n", stats.acq_count); - check(stats.acq_count == 3000); } @@ -217,10 +207,6 @@ check(record_count == 1); - pthread_statistics_begin_np(&stats); - pthread_statistics_next_np(&stats); - pthread_statistics_end_np(&stats); - check(stats.contest_count == 1); tm = stats.wait_time.tv_sec * 1000000L + Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c Sun Jul 15 21:28:22 2012 (r239437) @@ -0,0 +1,104 @@ + +#include +#include +#include +#include +#include + +void +recursion_test(void) +{ + pthread_mutex_t mutex; + pthread_mutexattr_t attr; + + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&mutex, &attr); + + pthread_mutex_lock(&mutex); + pthread_mutex_lock(&mutex); + + pthread_mutex_unlock(&mutex); + + sleep(1); + + pthread_mutex_unlock(&mutex); +} + +#define MAX_TESTS (100) + +int success_count = 0; +int fail_count = 0; +char result[MAX_TESTS]; + +void +check(char cond) +{ + result[success_count + fail_count] = cond; + + if (cond) { + success_count++; + } else { + fail_count++; + } +} + +void +show_test_results(void) +{ + int i; + + printf("1..%d\n", success_count + fail_count); + + for (i = 1; i <= success_count + fail_count; i++) { + if (result[i - 1]) { + printf("ok %d\n", i); + } else { + printf("not ok %d\n", i); + } + } +} + +void +check_stats_recursion(void) +{ + int record_count = 0; + struct pthread_statistics_np stats; + long tm; + + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { + record_count++; + } + pthread_statistics_end_np(&stats); + + check(record_count == 1); + + check(strcmp(stats.file, "recurse.c") == 0); + + check(stats.wait_max.tv_sec == 0 && stats.wait_max.tv_nsec == 0); + + check(stats.contest_count == 0); + + check(stats.wait_time.tv_sec == 0 && stats.wait_time.tv_nsec == 0); + + check(stats.acq_count == 1); + + tm = stats.hold_max.tv_sec * 1000000L + stats.hold_max.tv_nsec / 1000; + check(tm >= 1000000); + + tm = stats.hold_time.tv_sec * 1000000L + + stats.hold_time.tv_nsec / 1000; + check(tm >= 1000000); +} + +int +main(void) +{ + recursion_test(); + check_stats_recursion(); + + show_test_results(); + + return 0; +} Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.t ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.t Sun Jul 15 21:28:22 2012 (r239437) @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD$ + +cd `dirname $0` + +executable=`basename $0 .t` + +make $executable 2>&1 > /dev/null + +exec ./$executable From owner-svn-soc-all@FreeBSD.ORG Sun Jul 15 22:05:24 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id DC0EC1065672 for ; Sun, 15 Jul 2012 22:05:22 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 15 Jul 2012 22:05:22 +0000 Date: Sun, 15 Jul 2012 22:05:22 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120715220522.DC0EC1065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239441 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2012 22:05:25 -0000 Author: gmiller Date: Sun Jul 15 22:05:22 2012 New Revision: 239441 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239441 Log: r239382@FreeBSD-dev: root | 2012-07-13 16:32:20 -0500 Factor out the functions for recording and displaying test results to eliminate code duplication. Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Sun Jul 15 21:46:19 2012 (r239440) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Sun Jul 15 22:05:22 2012 (r239441) @@ -11,8 +11,8 @@ clean: -rm -f ${TESTS} -lock-cycle: lock-cycle.c - ${CC} -o lock-cycle lock-cycle.c ${CFLAGS} +lock-cycle: lock-cycle.c check.c + ${CC} -o lock-cycle lock-cycle.c check.c ${CFLAGS} -recurse: recurse.c - ${CC} -o recurse recurse.c ${CFLAGS} +recurse: recurse.c check.c + ${CC} -o recurse recurse.c check.c ${CFLAGS} Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c Sun Jul 15 22:05:22 2012 (r239441) @@ -0,0 +1,36 @@ + +#include + +#define MAX_TESTS (100) + +int success_count = 0; +int fail_count = 0; +char result[MAX_TESTS]; + +void +check(char cond) +{ + result[success_count + fail_count] = cond; + + if (cond) { + success_count++; + } else { + fail_count++; + } +} + +void +show_test_results(void) +{ + int i; + + printf("1..%d\n", success_count + fail_count); + + for (i = 1; i <= success_count + fail_count; i++) { + if (result[i - 1]) { + printf("ok %d\n", i); + } else { + printf("not ok %d\n", i); + } + } +} Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h Sun Jul 15 22:05:22 2012 (r239441) @@ -0,0 +1,3 @@ + +void check(char cond); +void show_test_results(void); Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Sun Jul 15 21:46:19 2012 (r239440) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Sun Jul 15 22:05:22 2012 (r239441) @@ -1,10 +1,11 @@ #include #include -#include #include #include +#include "check.h" + pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void @@ -81,40 +82,6 @@ pthread_join(thread1, NULL); } -#define MAX_TESTS (100) - -int success_count = 0; -int fail_count = 0; -char result[MAX_TESTS]; - -void -check(char cond) -{ - result[success_count + fail_count] = cond; - - if (cond) { - success_count++; - } else { - fail_count++; - } -} - -void -show_test_results(void) -{ - int i; - - printf("1..%d\n", success_count + fail_count); - - for (i = 1; i <= success_count + fail_count; i++) { - if (result[i - 1]) { - printf("ok %d\n", i); - } else { - printf("not ok %d\n", i); - } - } -} - void check_stats_single(void) { @@ -131,7 +98,7 @@ check(record_count == 1); check(strcmp(stats.file, "lock-cycle.c") == 0); - check(stats.line == 16); + check(stats.line == 17); check(stats.wait_max.tv_sec == 0 && stats.wait_max.tv_nsec == 0); @@ -165,7 +132,7 @@ check(record_count == 1); check(strcmp(stats.file, "lock-cycle.c") == 0); - check(stats.line == 16); + check(stats.line == 17); tm = stats.hold_max.tv_sec * 1000000L + stats.hold_max.tv_nsec / 1000; check(tm >= 30); Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c Sun Jul 15 21:46:19 2012 (r239440) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/recurse.c Sun Jul 15 22:05:22 2012 (r239441) @@ -1,10 +1,11 @@ #include #include -#include #include #include +#include "check.h" + void recursion_test(void) { @@ -25,40 +26,6 @@ pthread_mutex_unlock(&mutex); } -#define MAX_TESTS (100) - -int success_count = 0; -int fail_count = 0; -char result[MAX_TESTS]; - -void -check(char cond) -{ - result[success_count + fail_count] = cond; - - if (cond) { - success_count++; - } else { - fail_count++; - } -} - -void -show_test_results(void) -{ - int i; - - printf("1..%d\n", success_count + fail_count); - - for (i = 1; i <= success_count + fail_count; i++) { - if (result[i - 1]) { - printf("ok %d\n", i); - } else { - printf("not ok %d\n", i); - } - } -} - void check_stats_recursion(void) { From owner-svn-soc-all@FreeBSD.ORG Sun Jul 15 22:05:40 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 54D221065673 for ; Sun, 15 Jul 2012 22:05:38 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 15 Jul 2012 22:05:38 +0000 Date: Sun, 15 Jul 2012 22:05:38 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120715220538.54D221065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239442 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2012 22:05:40 -0000 Author: gmiller Date: Sun Jul 15 22:05:38 2012 New Revision: 239442 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239442 Log: r239383@FreeBSD-dev: root | 2012-07-13 16:44:37 -0500 Remove intrusive debugging code from libwitness. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/witness.h Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Sun Jul 15 22:05:22 2012 (r239441) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Sun Jul 15 22:05:38 2012 (r239442) @@ -30,19 +30,6 @@ static _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head = SLIST_HEAD_INITIALIZER(lock_head); -// XXX: temporary debugging code -static void -dump_locks(void) { - struct lock_entry *entry; - int count = 1; - - SLIST_FOREACH(entry, &lock_head, lock_next) { - printf("[%d] %p\n", count++, entry->lock); - } - - puts(""); -} - void add_lock(void *lock) { @@ -59,9 +46,6 @@ if (next != NULL && insert_lock(entry, next) < 0) { log_reversal(entry, next); } - - printf("inserted lock %p\n", lock); - dump_locks(); } void @@ -78,7 +62,4 @@ break; } } - - printf("removed lock %p\n", lock); - dump_locks(); } Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Sun Jul 15 22:05:22 2012 (r239441) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Sun Jul 15 22:05:38 2012 (r239442) @@ -29,7 +29,6 @@ #include #include -#include #include struct lock_entry { From owner-svn-soc-all@FreeBSD.ORG Sun Jul 15 22:05:52 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 23AB81065670 for ; Sun, 15 Jul 2012 22:05:50 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 15 Jul 2012 22:05:50 +0000 Date: Sun, 15 Jul 2012 22:05:50 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120715220550.23AB81065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239443 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2012 22:05:52 -0000 Author: gmiller Date: Sun Jul 15 22:05:49 2012 New Revision: 239443 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239443 Log: r239384@FreeBSD-dev: root | 2012-07-13 19:06:36 -0500 Fix the insert_lock() and log_reversal() calls to correctly use the address of the lock, not the address of the list entry referring to the lock. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/logs.c Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Sun Jul 15 22:05:38 2012 (r239442) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Sun Jul 15 22:05:49 2012 (r239443) @@ -33,23 +33,21 @@ scan_graph(struct graph_node *graph, void *lock) { struct graph_node *ret; - struct graph_node *child; + + if (graph == NULL) { + return (NULL); + } if (graph->lock == lock) { return (graph); } - child = graph->child; - while (child != NULL) { - ret = scan_graph(child, lock); - if (ret != NULL) { - return (ret); - } - - child = child->sibling; + ret = scan_graph(graph->child, lock); + if (ret == NULL) { + ret = scan_graph(graph->sibling, lock); } - return (NULL); + return (ret); } static void @@ -95,7 +93,8 @@ node = malloc(sizeof(struct graph_node)); node->lock = lock; node->child = NULL; - node->sibling = NULL; + node->sibling = root; + root = node; } return (node); Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Sun Jul 15 22:05:38 2012 (r239442) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Sun Jul 15 22:05:49 2012 (r239443) @@ -43,8 +43,8 @@ SLIST_INSERT_HEAD(&lock_head, entry, lock_next); - if (next != NULL && insert_lock(entry, next) < 0) { - log_reversal(entry, next); + if (next != NULL && insert_lock(entry->lock, next->lock) < 0) { + log_reversal(entry->lock, next->lock); } } Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Sun Jul 15 22:05:38 2012 (r239442) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Sun Jul 15 22:05:49 2012 (r239443) @@ -54,13 +54,26 @@ void pthread_lor_begin_np(struct pthread_lock_order_np *lor) { + /* + The lock isn't needed to prevent races, but it is needed to ensure + that any locks grabbed by malloc() don't get logged. + */ + + pthread_mutex_lock(&witness_mtx); + lor->_pvt = malloc(sizeof(struct _pthread_lor_private)); lor->_pvt->last_record = NULL; + + pthread_mutex_unlock(&witness_mtx); } int pthread_lor_next_np(struct pthread_lock_order_np *lor) { + int res = 0; + + pthread_mutex_lock(&witness_mtx); + if (lor->_pvt->last_record == NULL) { lor->_pvt->last_record = STAILQ_FIRST(&lor_head); } else { @@ -68,14 +81,16 @@ STAILQ_NEXT(lor->_pvt->last_record, lor_next); } - if (lor->_pvt->last_record == NULL) { - return (0); + if (lor->_pvt->last_record != NULL) { + lor->lock_first = lor->_pvt->last_record->lock_first; + lor->lock_second = lor->_pvt->last_record->lock_second; + + res = 1; } - lor->lock_first = lor->_pvt->last_record->lock_first; - lor->lock_second = lor->_pvt->last_record->lock_second; + pthread_mutex_unlock(&witness_mtx); - return (1); + return (res); } void @@ -93,8 +108,12 @@ struct lor_entry *lor; struct lor_entry *lor_temp; + pthread_mutex_lock(&witness_mtx); + STAILQ_FOREACH_SAFE(lor, &lor_head, lor_next, lor_temp) { STAILQ_REMOVE(&lor_head, lor, lor_entry, lor_next); free(lor); } + + pthread_mutex_unlock(&witness_mtx); } From owner-svn-soc-all@FreeBSD.ORG Sun Jul 15 22:06:10 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3A487106566B for ; Sun, 15 Jul 2012 22:06:08 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 15 Jul 2012 22:06:08 +0000 Date: Sun, 15 Jul 2012 22:06:08 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120715220608.3A487106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239444 - in soc2012/gmiller/locking-head: . tools/regression/lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2012 22:06:10 -0000 Author: gmiller Date: Sun Jul 15 22:06:07 2012 New Revision: 239444 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239444 Log: r239385@FreeBSD-dev: root | 2012-07-13 19:11:05 -0500 Add basic libwitness testing. Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c - copied unchanged from r239441, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h - copied unchanged from r239441, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t - copied unchanged from r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t Deleted: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/witness.t Modified: soc2012/gmiller/locking-head/ (props changed) Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Sun Jul 15 22:06:07 2012 (r239444) @@ -0,0 +1,15 @@ +# $FreeBSD$ + +TESTS= lor-basic +CFLAGS+= -g -Wall -Wextra -Werror -lwitness + +.PHONY: tests +tests: ${TESTS} + for p in ${TESTS}; do ${.OBJDIR}/$$p; done + +.PHONY: clean +clean: + -rm -f ${TESTS} + +lor-basic: lor-basic.c check.c + ${CC} -o lor-basic lor-basic.c check.c ${CFLAGS} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c (from r239441, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.c Sun Jul 15 22:06:07 2012 (r239444, copy of r239441, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.c) @@ -0,0 +1,36 @@ + +#include + +#define MAX_TESTS (100) + +int success_count = 0; +int fail_count = 0; +char result[MAX_TESTS]; + +void +check(char cond) +{ + result[success_count + fail_count] = cond; + + if (cond) { + success_count++; + } else { + fail_count++; + } +} + +void +show_test_results(void) +{ + int i; + + printf("1..%d\n", success_count + fail_count); + + for (i = 1; i <= success_count + fail_count; i++) { + if (result[i - 1]) { + printf("ok %d\n", i); + } else { + printf("not ok %d\n", i); + } + } +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h (from r239441, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/check.h Sun Jul 15 22:06:07 2012 (r239444, copy of r239441, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/check.h) @@ -0,0 +1,3 @@ + +void check(char cond); +void show_test_results(void); Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Sun Jul 15 22:06:07 2012 (r239444) @@ -0,0 +1,57 @@ + +#include +#include + +#include "check.h" + +void +lor_basic_test(void) +{ + pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER; + + pthread_mutex_lock(&mutex1); + pthread_mutex_lock(&mutex2); + + pthread_mutex_unlock(&mutex2); + pthread_mutex_unlock(&mutex1); + + pthread_mutex_lock(&mutex2); + pthread_mutex_lock(&mutex3); + + pthread_mutex_unlock(&mutex3); + pthread_mutex_unlock(&mutex2); + + pthread_mutex_lock(&mutex3); + pthread_mutex_lock(&mutex1); + + pthread_mutex_unlock(&mutex1); + pthread_mutex_unlock(&mutex3); +} + +void +check_lor_basic(void) +{ + int record_count = 0; + struct pthread_lock_order_np lor; + + pthread_lor_begin_np(&lor); + while (pthread_lor_next_np(&lor)) { + record_count++; + } + pthread_lor_end_np(&lor); + + check(record_count == 1); +} + +int +main(void) +{ + lor_basic_test(); + check_lor_basic(); + + show_test_results(); + + return 0; +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t (from r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t Sun Jul 15 22:06:07 2012 (r239444, copy of r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t) @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD$ + +cd `dirname $0` + +executable=`basename $0 .t` + +make $executable 2>&1 > /dev/null + +exec ./$executable From owner-svn-soc-all@FreeBSD.ORG Sun Jul 15 22:06:25 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 8874F106564A for ; Sun, 15 Jul 2012 22:06:23 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 15 Jul 2012 22:06:23 +0000 Date: Sun, 15 Jul 2012 22:06:23 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120715220623.8874F106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239445 - in soc2012/gmiller/locking-head: . tools/regression/lib/libthr/lockprof X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jul 2012 22:06:25 -0000 Author: gmiller Date: Sun Jul 15 22:06:23 2012 New Revision: 239445 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239445 Log: r239386@FreeBSD-dev: root | 2012-07-13 19:44:47 -0500 Give the conflict tests their own file. Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.t - copied unchanged from r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Sun Jul 15 22:06:07 2012 (r239444) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/Makefile Sun Jul 15 22:06:23 2012 (r239445) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= lock-cycle recurse +TESTS= lock-cycle recurse conflict CFLAGS+= -DLOCK_PROFILING -g -Wall -Wextra -Werror -lthr_profile .PHONY: tests @@ -16,3 +16,6 @@ recurse: recurse.c check.c ${CC} -o recurse recurse.c check.c ${CFLAGS} + +conflict: conflict.c check.c + ${CC} -o conflict conflict.c check.c ${CFLAGS} Added: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.c Sun Jul 15 22:06:23 2012 (r239445) @@ -0,0 +1,73 @@ + +#include +#include +#include + +#include "check.h" + +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +void * +conflict_thread_func(void *v) +{ + v = v; + + pthread_mutex_lock(&mutex); + + sleep(5); + + pthread_mutex_unlock(&mutex); + + return NULL; +} + +void +conflict_test() +{ + pthread_t thread1; + pthread_t thread2; + + pthread_statistics_reset_np(); + + pthread_create(&thread1, NULL, conflict_thread_func, NULL); + pthread_create(&thread2, NULL, conflict_thread_func, NULL); + + pthread_join(thread2, NULL); + pthread_join(thread1, NULL); +} + +void +check_stats_conflict(void) +{ + int record_count = 0; + struct pthread_statistics_np stats; + long tm; + + pthread_statistics_begin_np(&stats); + while (pthread_statistics_next_np(&stats)) { + record_count++; + } + pthread_statistics_end_np(&stats); + + check(record_count == 1); + + check(stats.contest_count == 1); + + tm = stats.wait_time.tv_sec * 1000000L + + stats.wait_time.tv_nsec / 1000; + check(tm > 0); + + tm = stats.wait_max.tv_sec * 1000000L + stats.wait_max.tv_nsec / 1000; + check(tm > 0); +} + +int +main(void) +{ + conflict_test(); + check_stats_conflict(); + + show_test_results(); + + return 0; +} Copied: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.t (from r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/conflict.t Sun Jul 15 22:06:23 2012 (r239445, copy of r238936, soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.t) @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD$ + +cd `dirname $0` + +executable=`basename $0 .t` + +make $executable 2>&1 > /dev/null + +exec ./$executable Modified: soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Sun Jul 15 22:06:07 2012 (r239444) +++ soc2012/gmiller/locking-head/tools/regression/lib/libthr/lockprof/lock-cycle.c Sun Jul 15 22:06:23 2012 (r239445) @@ -53,35 +53,6 @@ pthread_statistics_reset_np(); } -void * -conflict_thread_func(void *v) -{ - v = v; - - pthread_mutex_lock(&mutex); - - sleep(5); - - pthread_mutex_unlock(&mutex); - - return NULL; -} - -void -conflict_test() -{ - pthread_t thread1; - pthread_t thread2; - - pthread_statistics_reset_np(); - - pthread_create(&thread1, NULL, conflict_thread_func, NULL); - pthread_create(&thread2, NULL, conflict_thread_func, NULL); - - pthread_join(thread2, NULL); - pthread_join(thread1, NULL); -} - void check_stats_single(void) { @@ -159,31 +130,6 @@ check(record_count == 0); } -void -check_stats_conflict(void) -{ - int record_count = 0; - struct pthread_statistics_np stats; - long tm; - - pthread_statistics_begin_np(&stats); - while (pthread_statistics_next_np(&stats)) { - record_count++; - } - pthread_statistics_end_np(&stats); - - check(record_count == 1); - - check(stats.contest_count == 1); - - tm = stats.wait_time.tv_sec * 1000000L + - stats.wait_time.tv_nsec / 1000; - check(tm > 0); - - tm = stats.wait_max.tv_sec * 1000000L + stats.wait_max.tv_nsec / 1000; - check(tm > 0); -} - int main(void) { @@ -196,9 +142,6 @@ multi_cycle(); check_stats_multi(); - conflict_test(); - check_stats_conflict(); - show_test_results(); return 0; From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 06:39:45 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 2B82F1065670 for ; Mon, 16 Jul 2012 06:39:43 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 06:39:43 +0000 Date: Mon, 16 Jul 2012 06:39:43 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716063943.2B82F1065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239449 - in soc2012/gmiller/locking-head: . include lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 06:39:45 -0000 Author: gmiller Date: Mon Jul 16 06:39:42 2012 New Revision: 239449 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239449 Log: r239480@FreeBSD-dev: root | 2012-07-14 03:51:04 -0500 Declare the remaining libwitness support functions. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/logs.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Mon Jul 16 02:10:26 2012 (r239448) +++ soc2012/gmiller/locking-head/include/pthread_np.h Mon Jul 16 06:39:42 2012 (r239449) @@ -60,12 +60,18 @@ struct _pthread_lor_private; -struct pthread_lock_order_np { +struct pthread_lor_np { struct _pthread_lor_private *_pvt; void *lock_first; void *lock_second; }; +struct _pthread_lockorder_private; + +struct pthread_lockorder_np { + struct _pthread_lockorder_private *_pvt; +}; + typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); /* @@ -97,10 +103,17 @@ int pthread_switch_add_np(pthread_switch_routine_t); int pthread_switch_delete_np(pthread_switch_routine_t); int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); -void pthread_lor_begin_np(struct pthread_lock_order_np *); -int pthread_lor_next_np(struct pthread_lock_order_np *); -void pthread_lor_end_np(struct pthread_lock_order_np *); +void pthread_lor_begin_np(struct pthread_lor_np *); +int pthread_lor_next_np(struct pthread_lor_np *); +void pthread_lor_end_np(struct pthread_lor_np *); void pthread_lor_clear_np(void); +void pthread_lockorder_bless_np(void *, void *); +void pthread_lockorder_set_np(void *first, void *second); +void pthread_lockorder_reset_np(void); +void pthread_lockorder_begin_np(struct pthread_lockorder_np *); +int pthread_lockorder_next_np(struct pthread_lockorder_np *); +void pthread_lockorder_end_np(struct pthread_lockorder_np *); +void pthread_setname_np(void *, const char *); #ifdef LOCK_PROFILING Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 16 02:10:26 2012 (r239448) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 16 06:39:42 2012 (r239449) @@ -52,7 +52,7 @@ } void -pthread_lor_begin_np(struct pthread_lock_order_np *lor) +pthread_lor_begin_np(struct pthread_lor_np *lor) { /* The lock isn't needed to prevent races, but it is needed to ensure @@ -68,7 +68,7 @@ } int -pthread_lor_next_np(struct pthread_lock_order_np *lor) +pthread_lor_next_np(struct pthread_lor_np *lor) { int res = 0; @@ -94,7 +94,7 @@ } void -pthread_lor_end_np(struct pthread_lock_order_np *lor) +pthread_lor_end_np(struct pthread_lor_np *lor) { if (lor->_pvt != NULL) { free(lor->_pvt); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 14:05:36 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 74797106564A for ; Mon, 16 Jul 2012 14:05:34 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 14:05:34 +0000 Date: Mon, 16 Jul 2012 14:05:34 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716140534.74797106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239469 - in soc2012/gmiller/locking-head: . tools/regression/lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 14:05:36 -0000 Author: gmiller Date: Mon Jul 16 14:05:33 2012 New Revision: 239469 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239469 Log: r239485@FreeBSD-dev: root | 2012-07-14 05:27:05 -0500 Update libwitness test for new structure name. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c ============================================================================== --- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 16 11:58:44 2012 (r239468) +++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 16 14:05:33 2012 (r239469) @@ -34,7 +34,7 @@ check_lor_basic(void) { int record_count = 0; - struct pthread_lock_order_np lor; + struct pthread_lor_np lor; pthread_lor_begin_np(&lor); while (pthread_lor_next_np(&lor)) { From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 15:14:24 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 3E9BA1065672 for ; Mon, 16 Jul 2012 15:14:22 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 15:14:22 +0000 Date: Mon, 16 Jul 2012 15:14:22 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716151422.3E9BA1065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239470 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 15:14:24 -0000 Author: gmiller Date: Mon Jul 16 15:14:21 2012 New Revision: 239470 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239470 Log: r239506@FreeBSD-dev: root | 2012-07-14 06:11:18 -0500 Create a new structure lock_info for use as a lock identifier instead of using the lock's address. This correctly handles stack-allocated locks and allows for the addition of lock names. Added: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/Makefile soc2012/gmiller/locking-head/lib/libwitness/graph.c soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/logs.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/Makefile ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/Makefile Mon Jul 16 14:05:33 2012 (r239469) +++ soc2012/gmiller/locking-head/lib/libwitness/Makefile Mon Jul 16 15:14:21 2012 (r239470) @@ -4,7 +4,7 @@ LIB= witness SHLIB_MAJOR= 1 -SRCS= wrappers.c graph.c lists.c logs.c +SRCS= wrappers.c graph.c lists.c logs.c lockinfo.c DPADD= ${LIBTHR} LDADD= -lthr Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 16 14:05:33 2012 (r239469) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 16 15:14:21 2012 (r239470) @@ -27,10 +27,16 @@ #include "witness.h" +struct graph_node { + struct lock_info *lock; + struct graph_node *child; + struct graph_node *sibling; +}; + struct graph_node *root = NULL; static struct graph_node * -scan_graph(struct graph_node *graph, void *lock) +scan_graph(struct graph_node *graph, struct lock_info *lock) { struct graph_node *ret; @@ -101,7 +107,7 @@ } int -insert_lock(void *new_lock, void *previous) +insert_lock(struct lock_info *new_lock, struct lock_info *previous) { return (insert_edge(lookup_node(previous), lookup_node(new_lock))); } Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Mon Jul 16 14:05:33 2012 (r239469) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Mon Jul 16 15:14:21 2012 (r239470) @@ -27,11 +27,16 @@ #include "witness.h" +struct lock_entry { + SLIST_ENTRY(lock_entry) lock_next; + struct lock_info *lock; +}; + static _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head = SLIST_HEAD_INITIALIZER(lock_head); void -add_lock(void *lock) +add_lock(struct lock_info *lock) { struct lock_entry *entry; struct lock_entry *next; @@ -49,7 +54,7 @@ } void -remove_lock(void *lock) +remove_lock(struct lock_info *lock) { struct lock_entry *entry; struct lock_entry *temp; Added: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 16 15:14:21 2012 (r239470) @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 2012 Greg Miller .. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "witness.h" + +static SLIST_HEAD(lock_info_head, lock_info) lock_info_head = + SLIST_HEAD_INITIALIZER(lock_info_head); + +struct lock_info * +lookup_lock(void *lock) +{ + struct lock_info *info; + + SLIST_FOREACH(info, &lock_info_head, lock_info_next) { + if (info->lock == lock && info->active) { + break; + } + } + + if (info == NULL) { + info = malloc(sizeof(struct lock_info)); + info->active = 1; + info->lock = lock; + SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); + } + + return (info); +} + +void +destroy_lock(void *lock) +{ + struct lock_info *info; + + info = lookup_lock(lock); + info->active = 0; +} Modified: soc2012/gmiller/locking-head/lib/libwitness/logs.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 16 14:05:33 2012 (r239469) +++ soc2012/gmiller/locking-head/lib/libwitness/logs.c Mon Jul 16 15:14:21 2012 (r239470) @@ -31,8 +31,8 @@ struct lor_entry { STAILQ_ENTRY(lor_entry) lor_next; - void *lock_first; - void *lock_second; + struct lock_info *lock_first; + struct lock_info *lock_second; }; struct _pthread_lor_private { @@ -40,7 +40,7 @@ }; void -log_reversal(void *lock, void *previous) +log_reversal(struct lock_info *lock, struct lock_info *previous) { struct lor_entry *entry; @@ -58,7 +58,6 @@ The lock isn't needed to prevent races, but it is needed to ensure that any locks grabbed by malloc() don't get logged. */ - pthread_mutex_lock(&witness_mtx); lor->_pvt = malloc(sizeof(struct _pthread_lor_private)); Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Mon Jul 16 14:05:33 2012 (r239469) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Mon Jul 16 15:14:21 2012 (r239470) @@ -31,22 +31,20 @@ #include #include -struct lock_entry { - SLIST_ENTRY(lock_entry) lock_next; +struct lock_info { + SLIST_ENTRY(lock_info) lock_info_next; void *lock; -}; - -struct graph_node { - void *lock; - struct graph_node *child; - struct graph_node *sibling; + int active; }; extern pthread_mutex_t witness_mtx; -void add_lock(void *lock); -void remove_lock(void *lock); +void add_lock(struct lock_info *lock); +void remove_lock(struct lock_info *lock); + +int insert_lock(struct lock_info *new_lock, struct lock_info *previous); -int insert_lock(void *new_lock, void *previous); +void log_reversal(struct lock_info *lock, struct lock_info *previous); -void log_reversal(void *lock, void *previous); +struct lock_info *lookup_lock(void *lock); +void destroy_lock(void *lock); Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 16 14:05:33 2012 (r239469) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Mon Jul 16 15:14:21 2012 (r239470) @@ -32,6 +32,7 @@ int _pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *ts); int _pthread_mutex_unlock(pthread_mutex_t *mutex); +int _pthread_mutex_destroy(pthread_mutex_t *mutex); int _pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); int _pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock); int _pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, @@ -41,9 +42,11 @@ int _pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts); int _pthread_rwlock_unlock(pthread_rwlock_t *rwlock); +int _pthread_rwlock_destroy(pthread_rwlock_t *rwlock); int _pthread_spin_lock(pthread_spinlock_t *spin); int _pthread_spin_trylock(pthread_spinlock_t *spin); int _pthread_spin_unlock(pthread_spinlock_t *spin); +int _pthread_spin_destroy(pthread_spinlock_t *spin); pthread_mutex_t witness_mtx = PTHREAD_MUTEX_INITIALIZER; @@ -54,7 +57,7 @@ ret = _pthread_mutex_lock(mutex); if (mutex != &witness_mtx && ret == 0) { - add_lock(mutex); + add_lock(lookup_lock(mutex)); } return (ret); @@ -67,7 +70,7 @@ ret = _pthread_mutex_trylock(mutex); if (mutex != &witness_mtx && ret == 0) { - add_lock(mutex); + add_lock(lookup_lock(mutex)); } return (ret); @@ -80,7 +83,7 @@ ret = _pthread_mutex_timedlock(mutex, ts); if (mutex != &witness_mtx && ret == 0) { - add_lock(mutex); + add_lock(lookup_lock(mutex)); } return (ret); @@ -93,20 +96,27 @@ ret = _pthread_mutex_unlock(mutex); if (mutex != &witness_mtx && ret == 0) { - remove_lock(mutex); + remove_lock(lookup_lock(mutex)); } return (ret); } int +pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + destroy_lock(mutex); + return (_pthread_mutex_destroy(mutex)); +} + +int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) { int ret; ret = _pthread_rwlock_rdlock(rwlock); if (ret == 0) { - add_lock(rwlock); + add_lock(lookup_lock(rwlock)); } return (ret); @@ -119,7 +129,7 @@ ret = _pthread_rwlock_tryrdlock(rwlock); if (ret == 0) { - add_lock(rwlock); + add_lock(lookup_lock(rwlock)); } return (ret); @@ -132,7 +142,7 @@ ret = _pthread_rwlock_timedrdlock(rwlock, ts); if (ret == 0) { - add_lock(rwlock); + add_lock(lookup_lock(rwlock)); } return (ret); @@ -145,7 +155,7 @@ ret = _pthread_rwlock_wrlock(rwlock); if (ret == 0) { - add_lock(rwlock); + add_lock(lookup_lock(rwlock)); } return (ret); @@ -158,7 +168,7 @@ ret = _pthread_rwlock_trywrlock(rwlock); if (ret == 0) { - add_lock(rwlock); + add_lock(lookup_lock(rwlock)); } return (ret); @@ -171,7 +181,7 @@ ret = _pthread_rwlock_timedwrlock(rwlock, ts); if (ret == 0) { - add_lock(rwlock); + add_lock(lookup_lock(rwlock)); } return (ret); @@ -184,20 +194,27 @@ ret = _pthread_rwlock_unlock(rwlock); if (ret == 0) { - remove_lock(rwlock); + remove_lock(lookup_lock(rwlock)); } return (ret); } int +pthread_rwlock_destroy(pthread_rwlock_t *rwlock) +{ + destroy_lock(rwlock); + return (_pthread_rwlock_destroy(rwlock)); +} + +int pthread_spin_lock(pthread_spinlock_t *spin) { int ret; ret = _pthread_spin_lock(spin); if (ret == 0) { - add_lock(spin); + add_lock(lookup_lock(spin)); } return (ret); @@ -210,7 +227,7 @@ ret = _pthread_spin_lock(spin); if (ret == 0) { - add_lock(spin); + add_lock(lookup_lock(spin)); } return (ret); @@ -223,8 +240,15 @@ ret = _pthread_spin_unlock(spin); if (ret == 0) { - remove_lock(spin); + remove_lock(lookup_lock(spin)); } return (ret); } + +int +pthread_spin_destroy(pthread_spinlock_t *spin) +{ + destroy_lock(spin); + return (_pthread_spin_destroy(spin)); +} From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 15:14:35 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D1474106567D for ; Mon, 16 Jul 2012 15:14:33 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 15:14:33 +0000 Date: Mon, 16 Jul 2012 15:14:33 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716151433.D1474106567D@hub.freebsd.org> Cc: Subject: socsvn commit: r239471 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 15:14:36 -0000 Author: gmiller Date: Mon Jul 16 15:14:33 2012 New Revision: 239471 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239471 Log: r239507@FreeBSD-dev: root | 2012-07-14 06:35:51 -0500 Merge graph_node into lock_info to simplify code and improve performance. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 16 15:14:21 2012 (r239470) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Mon Jul 16 15:14:33 2012 (r239471) @@ -27,29 +27,23 @@ #include "witness.h" -struct graph_node { - struct lock_info *lock; - struct graph_node *child; - struct graph_node *sibling; -}; +struct lock_info *root = NULL; -struct graph_node *root = NULL; - -static struct graph_node * -scan_graph(struct graph_node *graph, struct lock_info *lock) +static int +scan_graph(struct lock_info *graph, struct lock_info *lock) { - struct graph_node *ret; + int ret; if (graph == NULL) { - return (NULL); + return (0); } - if (graph->lock == lock) { - return (graph); + if (graph == lock) { + return (1); } ret = scan_graph(graph->child, lock); - if (ret == NULL) { + if (!ret) { ret = scan_graph(graph->sibling, lock); } @@ -57,24 +51,24 @@ } static void -optimize_links(struct graph_node *to) +optimize_links(struct lock_info *to) { - to = to; - /* - find first node with multiple children, then start scanning for - multiple paths to "to" from any node with multiple children and - a link to "to" - */ + to = to; + /* + XXX find first node with multiple children, then start scanning for + multiple paths to "to" from any node with multiple children and + a link to "to" + */ } -static int -insert_edge(struct graph_node *from, struct graph_node *to) +int +insert_lock(struct lock_info *from, struct lock_info *to) { if (from == to) { return (0); } - if (scan_graph(to, from->lock) != NULL) { + if (scan_graph(to, from)) { return (-1); } @@ -85,29 +79,3 @@ return (0); } - -static struct graph_node * -lookup_node(void *lock) -{ - struct graph_node *node = NULL; - - if (root != NULL) { - node = scan_graph(root, lock); - } - - if (node == NULL) { - node = malloc(sizeof(struct graph_node)); - node->lock = lock; - node->child = NULL; - node->sibling = root; - root = node; - } - - return (node); -} - -int -insert_lock(struct lock_info *new_lock, struct lock_info *previous) -{ - return (insert_edge(lookup_node(previous), lookup_node(new_lock))); -} Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 16 15:14:21 2012 (r239470) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Mon Jul 16 15:14:33 2012 (r239471) @@ -45,6 +45,8 @@ info = malloc(sizeof(struct lock_info)); info->active = 1; info->lock = lock; + info->child = NULL; + info->sibling = NULL; SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); } Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Mon Jul 16 15:14:21 2012 (r239470) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Mon Jul 16 15:14:33 2012 (r239471) @@ -35,6 +35,8 @@ SLIST_ENTRY(lock_info) lock_info_next; void *lock; int active; + struct lock_info *child; + struct lock_info *sibling; }; extern pthread_mutex_t witness_mtx; From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 15:56:32 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 4B3DD106566B for ; Mon, 16 Jul 2012 15:56:30 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 15:56:30 +0000 Date: Mon, 16 Jul 2012 15:56:30 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716155630.4B3DD106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239472 - in soc2012/exxo: freebsd-head/include/rpcsvc freebsd-head/usr.bin/ypwhich openssl-1.0.1c/apps openssl-1.0.1c/crypto/bio X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 15:56:32 -0000 Author: exxo Date: Mon Jul 16 15:56:29 2012 New Revision: 239472 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239472 Log: Openssl TODO fixes and ypwhich patch Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c soc2012/exxo/openssl-1.0.1c/apps/s_client.c soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Mon Jul 16 15:14:33 2012 (r239471) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Mon Jul 16 15:56:29 2012 (r239472) @@ -199,7 +199,7 @@ struct dom_binding { struct dom_binding *dom_pnext; char dom_domain[YPMAXDOMAIN + 1]; - struct sockaddr_in dom_server_addr; + struct sockaddr_storage dom_server_addr; u_short dom_server_port; int dom_socket; CLIENT *dom_client; @@ -238,7 +238,11 @@ /* network order, of course */ struct ypbind_binding { - struct in_addr ypbind_binding_addr; + sa_family_t ypbind_binding_family; + union { + struct in_addr in; + struct in6_addr in6; + } ypbind_binding_addr; u_short ypbind_binding_port; }; Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Mon Jul 16 15:14:33 2012 (r239471) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Mon Jul 16 15:56:29 2012 (r239472) @@ -83,26 +83,32 @@ exit(ERR_USAGE); } +#define ypb_family ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family +#define ypb_addr ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr /* * Like yp_bind except can query a specific host */ static int -bind_host(char *dom, struct sockaddr_in *lsin) +bind_host(char *dom, const char *host) { struct hostent *hent = NULL; struct ypbind_resp ypbr; struct timeval tv; CLIENT *client; - int sock, r; - struct in_addr ss_addr; + int r; + char str[INET6_ADDRSTRLEN]; + size_t len; + union { + struct in_addr in; + struct in6_addr in6; + } ss_addr; - sock = RPC_ANYSOCK; tv.tv_sec = 15; tv.tv_usec = 0; - client = clntudp_create(lsin, YPBINDPROG, YPBINDVERS, tv, &sock); + client = clnt_create_timed(host, YPBINDPROG, YPBINDVERS, "udp", &tv); if (client == NULL) { - warnx("can't clntudp_create: %s", yperr_string(YPERR_YPBIND)); + warnx("can't clnt_create_timed: %s", yperr_string(YPERR_YPBIND)); return (YPERR_YPBIND); } @@ -124,14 +130,16 @@ } } clnt_destroy(client); - - ss_addr = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr; - /*printf("%08x\n", ss_addr);*/ - hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET); + bcopy(&ypb_addr, &ss_addr, sizeof(ss_addr)); + if (ypb_family == AF_INET) + len = sizeof(ss_addr.in); + else /* AF_INET6 */ + len = sizeof(ss_addr.in6); + hent = gethostbyaddr((char *)&ss_addr, len, ypb_family); if (hent) printf("%s\n", hent->h_name); else - printf("%s\n", inet_ntoa(ss_addr)); + printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, INET6_ADDRSTRLEN)); return (0); } @@ -141,8 +149,7 @@ char *domnam = NULL, *master; char *map = NULL; struct ypmaplist *ypml, *y; - struct hostent *hent; - struct sockaddr_in lsin; + char *host; int notrans, mode; int c, r; u_int i; @@ -166,38 +173,20 @@ mode++; break; default: - usage(); + usage(); } if (!domnam) yp_get_default_domain(&domnam); if (mode == 0) { - switch (argc-optind) { - case 0: - bzero(&lsin, sizeof lsin); - lsin.sin_family = AF_INET; - lsin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if (bind_host(domnam, &lsin)) + if (argc-optind == 0 || argc-optind == 1) { + host = argc-optind ? argv[optind] : "127.0.0.1"; + if (bind_host(domnam, host)) exit(ERR_NOBINDING); - break; - case 1: - bzero(&lsin, sizeof lsin); - lsin.sin_family = AF_INET; - if ((lsin.sin_addr.s_addr = inet_addr(argv[optind])) == INADDR_NONE) { - hent = gethostbyname(argv[optind]); - if (!hent) - errx(ERR_NOSUCHHOST, "host %s unknown", argv[optind]); - bcopy((char *)hent->h_addr_list[0], - (char *)&lsin.sin_addr, sizeof lsin.sin_addr); - } - if (bind_host(domnam, &lsin)) - exit(ERR_NOBINDING); - break; - default: - usage(); } + else + usage(); exit(0); } Modified: soc2012/exxo/openssl-1.0.1c/apps/s_client.c ============================================================================== --- soc2012/exxo/openssl-1.0.1c/apps/s_client.c Mon Jul 16 15:14:33 2012 (r239471) +++ soc2012/exxo/openssl-1.0.1c/apps/s_client.c Mon Jul 16 15:56:29 2012 (r239472) @@ -686,8 +686,7 @@ else if (strcmp(*argv,"-connect") == 0) { if (--argc < 1) goto bad; - /* TODO - if (!extract_host_port(*(++argv),&host,NULL,&port)) */ + if (!BIO_extract_addr(*(++argv),&host,&port,NULL)) goto bad; } else if (strcmp(*argv,"-verify") == 0) Modified: soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c ============================================================================== --- soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c Mon Jul 16 15:14:33 2012 (r239471) +++ soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c Mon Jul 16 15:56:29 2012 (r239472) @@ -113,8 +113,7 @@ #endif static int get_ip(const char *str,unsigned char *ip); -static int parse_ip(char *str, char **host, char **port, int *is_inet6); -static int fill_addr(union sa_storage *sa, char *host, char *port, int is_inet6, int is_local); +static int fill_addr(union sa_storage *sa, const char *host, const char *port, int is_inet6, int is_local); #if 0 static void ghbn_free(struct hostent *a); static struct hostent *ghbn_dup(struct hostent *a); @@ -774,42 +773,44 @@ return(1); } -static int parse_ip(char *str, char **host, char **port, int *is_inet6) +int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6) { char *tmp; char *h = *host = NULL; char *p = *port = NULL; - *is_inet6 = 0; - if (*str == '\0') + if (is_inet6) + *is_inet6 = 0; + if (*addr == '\0') return (0); - if (*str == '[' && (tmp = strchr(str + 1, ']'))) + if (*addr == '[' && (tmp = strchr(addr + 1, ']'))) { - h = str + 1; + h = addr + 1; *tmp++ = '\0'; if (*tmp == ':') p = tmp + 1; else if (*tmp != '\0') return (0); - *is_inet6 = 1; + if (is_inet6) + *is_inet6 = 1; } else { - if ((tmp = strchr(str, ':'))) + if ((tmp = strchr(addr, ':'))) { - h = str; + h = addr; *tmp++ = '\0'; p = tmp; } - else if ((tmp = strchr(str, '/'))) + else if ((tmp = strchr(addr, '/'))) { if (*(tmp + 1) != '\0') return (0); - p = str; + p = addr; *tmp = '\0'; } else - h = str; + h = addr; } if (h && (*h == '\0' || !strcmp(h, "*"))) h = NULL; @@ -820,7 +821,7 @@ return (1); } -static int fill_addr(union sa_storage *sa, char *host, char *port, int is_inet6, int is_local) +static int fill_addr(union sa_storage *sa, const char *host, const char *port, int is_inet6, int is_local) { unsigned short p; int sa_len = 0; @@ -889,7 +890,7 @@ char *h, *p; int is_inet6 = 0; - if (parse_ip(host, &h, &p, &is_inet6) != 1) + if (BIO_extract_addr(host, &h, &p, &is_inet6) != 1) { BIOerr(BIO_F_BIO_GET_HOST_ADDR,BIO_R_INVALID_IP_ADDRESS); return (0); @@ -912,7 +913,7 @@ if (BIO_sock_init() != 1) return(INVALID_SOCKET); if ((str=BUF_strdup(host)) == NULL) return(INVALID_SOCKET); - if (parse_ip(str, &h, &p, &is_inet6) != 1) + if (BIO_extract_addr(str, &h, &p, &is_inet6) != 1) { BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_INVALID_IP_ADDRESS); goto err; Modified: soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h ============================================================================== --- soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h Mon Jul 16 15:14:33 2012 (r239471) +++ soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h Mon Jul 16 15:56:29 2012 (r239472) @@ -76,10 +76,12 @@ # endif #endif -/* TODO Under which conditions include the following ? */ +/* TODO Under which conditions include the following OPENSSL_SYS_UNIX ? */ +#ifdef OPENSSL_SYS_UNIX #include #include #include +#endif #ifdef __cplusplus extern "C" { @@ -780,6 +782,7 @@ int BIO_get_port(const char *str, unsigned short *port_ptr); int BIO_get_host_ip(const char *str, unsigned char *ip); int BIO_get_host_ip6(const char *str, unsigned char *ip, unsigned char mode); +int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6); int BIO_get_accept_socket(char *host_port,int mode); int BIO_accept(int sock,char **ip_port); int BIO_sock_init(void ); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 17:07:23 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 6D3E0106566B for ; Mon, 16 Jul 2012 17:07:21 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 17:07:21 +0000 Date: Mon, 16 Jul 2012 17:07:21 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716170721.6D3E0106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239474 - in soc2012/exxo/freebsd-head: include/rpcsvc usr.bin/ypwhich X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 17:07:23 -0000 Author: exxo Date: Mon Jul 16 17:07:21 2012 New Revision: 239474 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239474 Log: Add INET6 definitions to ypwhich Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Mon Jul 16 16:50:28 2012 (r239473) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Mon Jul 16 17:07:21 2012 (r239474) @@ -241,7 +241,9 @@ sa_family_t ypbind_binding_family; union { struct in_addr in; +#ifdef INET6 struct in6_addr in6; +#endif } ypbind_binding_addr; u_short ypbind_binding_port; }; Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile Mon Jul 16 16:50:28 2012 (r239473) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile Mon Jul 16 17:07:21 2012 (r239474) @@ -5,4 +5,8 @@ WARNS?= 2 +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif + .include Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Mon Jul 16 16:50:28 2012 (r239473) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Mon Jul 16 17:07:21 2012 (r239474) @@ -85,6 +85,11 @@ #define ypb_family ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family #define ypb_addr ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr +#ifdef INET6 +# define ADDRSTRLEN INET6_ADDRSTRLEN +#else +# define ADDRSTRLEN INET_ADDRSTRLEN +#endif /* * Like yp_bind except can query a specific host @@ -97,11 +102,13 @@ struct timeval tv; CLIENT *client; int r; - char str[INET6_ADDRSTRLEN]; + char str[ADDRSTRLEN]; size_t len; union { struct in_addr in; +#ifdef INET6 struct in6_addr in6; +#endif } ss_addr; tv.tv_sec = 15; @@ -131,15 +138,17 @@ } clnt_destroy(client); bcopy(&ypb_addr, &ss_addr, sizeof(ss_addr)); - if (ypb_family == AF_INET) - len = sizeof(ss_addr.in); - else /* AF_INET6 */ +#ifdef INET6 + if (ypb_family == AF_INET6) len = sizeof(ss_addr.in6); + else /* AF_INET */ +#endif + len = sizeof(ss_addr.in); hent = gethostbyaddr((char *)&ss_addr, len, ypb_family); if (hent) printf("%s\n", hent->h_name); else - printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, INET6_ADDRSTRLEN)); + printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, ADDRSTRLEN)); return (0); } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 17:20:17 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D3A381065670 for ; Mon, 16 Jul 2012 17:20:14 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 17:20:14 +0000 Date: Mon, 16 Jul 2012 17:20:14 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716172014.D3A381065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239475 - soc2012/exxo/patches X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 17:20:17 -0000 Author: exxo Date: Mon Jul 16 17:20:13 2012 New Revision: 239475 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239475 Log: Add ypwhich patch and update openssl one Added: soc2012/exxo/patches/ypwhich.patch Modified: soc2012/exxo/patches/openssl-1.0.1c.patch Modified: soc2012/exxo/patches/openssl-1.0.1c.patch ============================================================================== --- soc2012/exxo/patches/openssl-1.0.1c.patch Mon Jul 16 17:07:21 2012 (r239474) +++ soc2012/exxo/patches/openssl-1.0.1c.patch Mon Jul 16 17:20:13 2012 (r239475) @@ -1,4 +1,4 @@ -diff -rpu -X diff-exclude openssl-1.0.1c/Configure gsoc/openssl-1.0.1c/Configure +diff -r -pu -X diff-exclude openssl-1.0.1c/Configure gsoc/openssl-1.0.1c/Configure --- openssl-1.0.1c/Configure 2012-03-14 23:20:40.000000000 +0100 +++ gsoc/openssl-1.0.1c/Configure 2012-06-26 02:18:50.000000000 +0200 @@ -168,8 +168,8 @@ my %table=( @@ -65,7 +65,7 @@ # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -diff -rpu -X diff-exclude openssl-1.0.1c/apps/s_apps.h gsoc/openssl-1.0.1c/apps/s_apps.h +diff -r -pu -X diff-exclude openssl-1.0.1c/apps/s_apps.h gsoc/openssl-1.0.1c/apps/s_apps.h --- openssl-1.0.1c/apps/s_apps.h 2009-09-04 19:42:04.000000000 +0200 +++ gsoc/openssl-1.0.1c/apps/s_apps.h 2012-06-26 01:10:06.000000000 +0200 @@ -148,7 +148,7 @@ typedef fd_mask fd_set; @@ -89,9 +89,9 @@ long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret); -diff -rpu -X diff-exclude openssl-1.0.1c/apps/s_client.c gsoc/openssl-1.0.1c/apps/s_client.c +diff -r -pu -X diff-exclude openssl-1.0.1c/apps/s_client.c gsoc/openssl-1.0.1c/apps/s_client.c --- openssl-1.0.1c/apps/s_client.c 2012-03-18 19:16:05.000000000 +0100 -+++ gsoc/openssl-1.0.1c/apps/s_client.c 2012-06-26 02:24:47.000000000 +0200 ++++ gsoc/openssl-1.0.1c/apps/s_client.c 2012-07-16 17:02:41.000000000 +0200 @@ -287,6 +287,10 @@ static void sc_usage(void) BIO_printf(bio_err,"\n"); BIO_printf(bio_err," -host host - use -connect instead\n"); @@ -126,7 +126,7 @@ argc--; argv++; while (argc >= 1) -@@ -664,13 +675,19 @@ int MAIN(int argc, char **argv) +@@ -664,13 +675,18 @@ int MAIN(int argc, char **argv) else if (strcmp(*argv,"-port") == 0) { if (--argc < 1) goto bad; @@ -144,12 +144,11 @@ { if (--argc < 1) goto bad; - if (!extract_host_port(*(++argv),&host,NULL,&port)) -+ /* TODO -+ if (!extract_host_port(*(++argv),&host,NULL,&port)) */ ++ if (!BIO_extract_addr(*(++argv),&host,&port,NULL)) goto bad; } else if (strcmp(*argv,"-verify") == 0) -@@ -1252,10 +1269,9 @@ bad: +@@ -1252,10 +1268,9 @@ bad: re_start: @@ -162,7 +161,7 @@ goto end; } BIO_printf(bio_c_out,"CONNECTED(%08X)\n",s); -diff -rpu -X diff-exclude openssl-1.0.1c/apps/s_server.c gsoc/openssl-1.0.1c/apps/s_server.c +diff -r -pu -X diff-exclude openssl-1.0.1c/apps/s_server.c gsoc/openssl-1.0.1c/apps/s_server.c --- openssl-1.0.1c/apps/s_server.c 2012-03-18 19:16:05.000000000 +0100 +++ gsoc/openssl-1.0.1c/apps/s_server.c 2012-06-26 01:24:25.000000000 +0200 @@ -460,6 +460,10 @@ static void sv_usage(void) @@ -230,7 +229,7 @@ print_stats(bio_s_out,ctx); ret=0; end: -diff -rpu -X diff-exclude openssl-1.0.1c/apps/s_socket.c gsoc/openssl-1.0.1c/apps/s_socket.c +diff -r -pu -X diff-exclude openssl-1.0.1c/apps/s_socket.c gsoc/openssl-1.0.1c/apps/s_socket.c --- openssl-1.0.1c/apps/s_socket.c 2011-12-02 15:39:40.000000000 +0100 +++ gsoc/openssl-1.0.1c/apps/s_socket.c 2012-06-26 02:04:07.000000000 +0200 @@ -97,16 +97,15 @@ typedef unsigned int u_int; @@ -631,15 +630,14 @@ +#endif #endif -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/bio/b_sock.c gsoc/openssl-1.0.1c/crypto/bio/b_sock.c +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/bio/b_sock.c gsoc/openssl-1.0.1c/crypto/bio/b_sock.c --- openssl-1.0.1c/crypto/bio/b_sock.c 2012-04-16 19:43:14.000000000 +0200 -+++ gsoc/openssl-1.0.1c/crypto/bio/b_sock.c 2012-06-26 02:08:30.000000000 +0200 -@@ -113,21 +113,40 @@ static struct ghbn_cache_st ++++ gsoc/openssl-1.0.1c/crypto/bio/b_sock.c 2012-07-16 17:14:45.000000000 +0200 +@@ -113,21 +113,39 @@ static struct ghbn_cache_st #endif static int get_ip(const char *str,unsigned char *ip); -+static int parse_ip(char *str, char **host, char **port, int *is_inet6); -+static int fill_addr(union sa_storage *sa, char *host, char *port, int is_inet6, int is_local); ++static int fill_addr(union sa_storage *sa, const char *host, const char *port, int is_inet6, int is_local); #if 0 static void ghbn_free(struct hostent *a); static struct hostent *ghbn_dup(struct hostent *a); @@ -677,7 +675,7 @@ goto err; } -@@ -138,38 +157,93 @@ int BIO_get_host_ip(const char *str, uns +@@ -138,38 +156,93 @@ int BIO_get_host_ip(const char *str, uns /* If the string actually contained an IP address, we need not do anything more */ @@ -785,7 +783,7 @@ } int BIO_get_port(const char *str, unsigned short *port_ptr) -@@ -467,9 +541,90 @@ end: +@@ -467,9 +540,90 @@ end: #endif } @@ -877,12 +875,12 @@ #ifdef OPENSSL_SYS_WINDOWS static struct WSAData wsa_state; -@@ -619,121 +774,151 @@ static int get_ip(const char *str, unsig +@@ -619,121 +773,153 @@ static int get_ip(const char *str, unsig return(1); } -int BIO_get_accept_socket(char *host, int bind_mode) -+static int parse_ip(char *str, char **host, char **port, int *is_inet6) ++int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6) { - int ret=0; - union { @@ -913,36 +911,38 @@ + char *h = *host = NULL; + char *p = *port = NULL; + -+ *is_inet6 = 0; -+ if (*str == '\0') ++ if (is_inet6) ++ *is_inet6 = 0; ++ if (*addr == '\0') + return (0); -+ if (*str == '[' && (tmp = strchr(str + 1, ']'))) ++ if (*addr == '[' && (tmp = strchr(addr + 1, ']'))) + { -+ h = str + 1; ++ h = addr + 1; + *tmp++ = '\0'; + if (*tmp == ':') + p = tmp + 1; + else if (*tmp != '\0') + return (0); -+ *is_inet6 = 1; ++ if (is_inet6) ++ *is_inet6 = 1; + } + else + { -+ if ((tmp = strchr(str, ':'))) ++ if ((tmp = strchr(addr, ':'))) { - p=e; -+ h = str; ++ h = addr; + *tmp++ = '\0'; + p = tmp; } - else if (*e == '/') -+ else if ((tmp = strchr(str, '/'))) ++ else if ((tmp = strchr(addr, '/'))) { - *e='\0'; - break; + if (*(tmp + 1) != '\0') + return (0); -+ p = str; ++ p = addr; + *tmp = '\0'; } - } @@ -961,7 +961,7 @@ - } p_freeaddrinfo = {NULL}; - struct addrinfo *res,hint; + else -+ h = str; ++ h = addr; + } + if (h && (*h == '\0' || !strcmp(h, "*"))) + h = NULL; @@ -979,7 +979,7 @@ - p_getaddrinfo.p=(void*)-1; - } - if (p_getaddrinfo.p==(void *)-1) break; -+static int fill_addr(union sa_storage *sa, char *host, char *port, int is_inet6, int is_local) ++static int fill_addr(union sa_storage *sa, const char *host, const char *port, int is_inet6, int is_local) + { + unsigned short p; + int sa_len = 0; @@ -1076,7 +1076,7 @@ + int is_inet6 = 0; - if (!BIO_get_port(p,&port)) goto err; -+ if (parse_ip(host, &h, &p, &is_inet6) != 1) ++ if (BIO_extract_addr(host, &h, &p, &is_inet6) != 1) + { + BIOerr(BIO_F_BIO_GET_HOST_ADDR,BIO_R_INVALID_IP_ADDRESS); + return (0); @@ -1106,7 +1106,7 @@ - else + if (BIO_sock_init() != 1) return(INVALID_SOCKET); + if ((str=BUF_strdup(host)) == NULL) return(INVALID_SOCKET); -+ if (parse_ip(str, &h, &p, &is_inet6) != 1) ++ if (BIO_extract_addr(str, &h, &p, &is_inet6) != 1) { - if (!BIO_get_host_ip(h,&(ip[0]))) goto err; - l=(unsigned long) @@ -1124,7 +1124,7 @@ again: s=socket(server.sa.sa_family,SOCK_STREAM,SOCKET_PROTOCOL); if (s == INVALID_SOCKET) -@@ -768,7 +953,7 @@ again: +@@ -768,7 +954,7 @@ again: #endif { client = server; @@ -1133,7 +1133,7 @@ { #if OPENSSL_USE_IPV6 if (client.sa.sa_family == AF_INET6) -@@ -830,6 +1015,9 @@ int BIO_accept(int sock, char **addr) +@@ -830,6 +1016,9 @@ int BIO_accept(int sock, char **addr) unsigned long l; unsigned short port; char *p; @@ -1143,7 +1143,7 @@ struct { /* -@@ -854,13 +1042,7 @@ int BIO_accept(int sock, char **addr) +@@ -854,13 +1043,7 @@ int BIO_accept(int sock, char **addr) * */ union { size_t s; int i; } len; @@ -1158,7 +1158,7 @@ } sa; sa.len.s=0; -@@ -883,43 +1065,27 @@ int BIO_accept(int sock, char **addr) +@@ -883,43 +1066,27 @@ int BIO_accept(int sock, char **addr) if (addr == NULL) goto end; @@ -1221,22 +1221,24 @@ if (sa.from.sa.sa_family != AF_INET) goto end; l=ntohl(sa.from.sa_in.sin_addr.s_addr); port=ntohs(sa.from.sa_in.sin_port); -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/bio/bio.h gsoc/openssl-1.0.1c/crypto/bio/bio.h +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/bio/bio.h gsoc/openssl-1.0.1c/crypto/bio/bio.h --- openssl-1.0.1c/crypto/bio/bio.h 2012-03-06 14:47:26.000000000 +0100 -+++ gsoc/openssl-1.0.1c/crypto/bio/bio.h 2012-06-26 02:07:31.000000000 +0200 -@@ -76,6 +76,11 @@ ++++ gsoc/openssl-1.0.1c/crypto/bio/bio.h 2012-07-16 17:18:33.000000000 +0200 +@@ -76,6 +76,13 @@ # endif #endif -+/* TODO Under which conditions include the following ? */ ++/* TODO Under which conditions include the following OPENSSL_SYS_UNIX ? */ ++#ifdef OPENSSL_SYS_UNIX +#include +#include +#include ++#endif + #ifdef __cplusplus extern "C" { #endif -@@ -715,11 +720,66 @@ struct hostent *BIO_gethostbyname(const +@@ -715,11 +722,67 @@ struct hostent *BIO_gethostbyname(const * substructures; if the buffer does not suffice, NULL is returned * and an appropriate error code is set). */ @@ -1300,10 +1302,11 @@ int BIO_get_port(const char *str, unsigned short *port_ptr); int BIO_get_host_ip(const char *str, unsigned char *ip); +int BIO_get_host_ip6(const char *str, unsigned char *ip, unsigned char mode); ++int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6); int BIO_get_accept_socket(char *host_port,int mode); int BIO_accept(int sock,char **ip_port); int BIO_sock_init(void ); -@@ -782,9 +842,14 @@ void ERR_load_BIO_strings(void); +@@ -782,9 +845,14 @@ void ERR_load_BIO_strings(void); #define BIO_F_BIO_CALLBACK_CTRL 131 #define BIO_F_BIO_CTRL 103 #define BIO_F_BIO_GETHOSTBYNAME 120 @@ -1318,7 +1321,7 @@ #define BIO_F_BIO_GET_PORT 107 #define BIO_F_BIO_MAKE_PAIR 121 #define BIO_F_BIO_NEW 108 -@@ -814,6 +879,7 @@ void ERR_load_BIO_strings(void); +@@ -814,6 +882,7 @@ void ERR_load_BIO_strings(void); #define BIO_R_ACCEPT_ERROR 100 #define BIO_R_BAD_FOPEN_MODE 101 #define BIO_R_BAD_HOSTNAME_LOOKUP 102 @@ -1326,7 +1329,7 @@ #define BIO_R_BROKEN_PIPE 124 #define BIO_R_CONNECT_ERROR 103 #define BIO_R_EOF_ON_MEMORY_BIO 127 -@@ -840,6 +906,7 @@ void ERR_load_BIO_strings(void); +@@ -840,6 +909,7 @@ void ERR_load_BIO_strings(void); #define BIO_R_UNSUPPORTED_METHOD 121 #define BIO_R_WRITE_TO_READ_ONLY_BIO 126 #define BIO_R_WSASTARTUP 122 @@ -1334,7 +1337,7 @@ #ifdef __cplusplus } -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/bio/bio_err.c gsoc/openssl-1.0.1c/crypto/bio/bio_err.c +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/bio/bio_err.c gsoc/openssl-1.0.1c/crypto/bio/bio_err.c --- openssl-1.0.1c/crypto/bio/bio_err.c 2011-12-27 15:37:43.000000000 +0100 +++ gsoc/openssl-1.0.1c/crypto/bio/bio_err.c 2012-06-25 12:36:42.000000000 +0200 @@ -76,9 +76,14 @@ static ERR_STRING_DATA BIO_str_functs[]= @@ -1368,7 +1371,7 @@ {0,NULL} }; -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/bio/bss_dgram.c gsoc/openssl-1.0.1c/crypto/bio/bss_dgram.c +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/bio/bss_dgram.c gsoc/openssl-1.0.1c/crypto/bio/bss_dgram.c --- openssl-1.0.1c/crypto/bio/bss_dgram.c 2012-03-06 14:47:26.000000000 +0100 +++ gsoc/openssl-1.0.1c/crypto/bio/bss_dgram.c 2012-06-25 19:05:34.000000000 +0200 @@ -143,13 +143,7 @@ static BIO_METHOD methods_dgramp_sctp= @@ -1431,7 +1434,7 @@ #endif data = (bio_dgram_data *)b->ptr; -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/crypto.h gsoc/openssl-1.0.1c/crypto/crypto.h +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/crypto.h gsoc/openssl-1.0.1c/crypto/crypto.h --- openssl-1.0.1c/crypto/crypto.h 2011-06-01 18:54:03.000000000 +0200 +++ gsoc/openssl-1.0.1c/crypto/crypto.h 2012-06-10 01:01:26.000000000 +0200 @@ -222,6 +222,7 @@ typedef struct openssl_item_st @@ -1442,7 +1445,7 @@ #define CRYPTO_LOCK 1 #define CRYPTO_UNLOCK 2 -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/err/err.c gsoc/openssl-1.0.1c/crypto/err/err.c +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/err/err.c gsoc/openssl-1.0.1c/crypto/err/err.c --- openssl-1.0.1c/crypto/err/err.c 2011-01-14 16:13:59.000000000 +0100 +++ gsoc/openssl-1.0.1c/crypto/err/err.c 2012-06-26 01:41:28.000000000 +0200 @@ -174,6 +174,7 @@ static ERR_STRING_DATA ERR_str_functs[]= @@ -1453,7 +1456,7 @@ {0,NULL}, }; -diff -rpu -X diff-exclude openssl-1.0.1c/crypto/err/err.h gsoc/openssl-1.0.1c/crypto/err/err.h +diff -r -pu -X diff-exclude openssl-1.0.1c/crypto/err/err.h gsoc/openssl-1.0.1c/crypto/err/err.h --- openssl-1.0.1c/crypto/err/err.h 2011-06-06 13:49:35.000000000 +0200 +++ gsoc/openssl-1.0.1c/crypto/err/err.h 2012-06-26 01:41:21.000000000 +0200 @@ -258,6 +258,7 @@ typedef struct err_state_st @@ -1464,22 +1467,24 @@ /* reasons */ -diff -rpu -X diff-exclude openssl-1.0.1c/include/openssl/bio.h gsoc/openssl-1.0.1c/include/openssl/bio.h +diff -r -pu -X diff-exclude openssl-1.0.1c/include/openssl/bio.h gsoc/openssl-1.0.1c/include/openssl/bio.h --- openssl-1.0.1c/include/openssl/bio.h 2012-03-06 14:47:26.000000000 +0100 -+++ gsoc/openssl-1.0.1c/include/openssl/bio.h 2012-06-26 02:07:31.000000000 +0200 -@@ -76,6 +76,11 @@ ++++ gsoc/openssl-1.0.1c/include/openssl/bio.h 2012-07-16 17:18:33.000000000 +0200 +@@ -76,6 +76,13 @@ # endif #endif -+/* TODO Under which conditions include the following ? */ ++/* TODO Under which conditions include the following OPENSSL_SYS_UNIX ? */ ++#ifdef OPENSSL_SYS_UNIX +#include +#include +#include ++#endif + #ifdef __cplusplus extern "C" { #endif -@@ -715,11 +720,66 @@ struct hostent *BIO_gethostbyname(const +@@ -715,11 +722,67 @@ struct hostent *BIO_gethostbyname(const * substructures; if the buffer does not suffice, NULL is returned * and an appropriate error code is set). */ @@ -1543,10 +1548,11 @@ int BIO_get_port(const char *str, unsigned short *port_ptr); int BIO_get_host_ip(const char *str, unsigned char *ip); +int BIO_get_host_ip6(const char *str, unsigned char *ip, unsigned char mode); ++int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6); int BIO_get_accept_socket(char *host_port,int mode); int BIO_accept(int sock,char **ip_port); int BIO_sock_init(void ); -@@ -782,9 +842,14 @@ void ERR_load_BIO_strings(void); +@@ -782,9 +845,14 @@ void ERR_load_BIO_strings(void); #define BIO_F_BIO_CALLBACK_CTRL 131 #define BIO_F_BIO_CTRL 103 #define BIO_F_BIO_GETHOSTBYNAME 120 @@ -1561,7 +1567,7 @@ #define BIO_F_BIO_GET_PORT 107 #define BIO_F_BIO_MAKE_PAIR 121 #define BIO_F_BIO_NEW 108 -@@ -814,6 +879,7 @@ void ERR_load_BIO_strings(void); +@@ -814,6 +882,7 @@ void ERR_load_BIO_strings(void); #define BIO_R_ACCEPT_ERROR 100 #define BIO_R_BAD_FOPEN_MODE 101 #define BIO_R_BAD_HOSTNAME_LOOKUP 102 @@ -1569,7 +1575,7 @@ #define BIO_R_BROKEN_PIPE 124 #define BIO_R_CONNECT_ERROR 103 #define BIO_R_EOF_ON_MEMORY_BIO 127 -@@ -840,6 +906,7 @@ void ERR_load_BIO_strings(void); +@@ -840,6 +909,7 @@ void ERR_load_BIO_strings(void); #define BIO_R_UNSUPPORTED_METHOD 121 #define BIO_R_WRITE_TO_READ_ONLY_BIO 126 #define BIO_R_WSASTARTUP 122 @@ -1577,7 +1583,7 @@ #ifdef __cplusplus } -diff -rpu -X diff-exclude openssl-1.0.1c/include/openssl/crypto.h gsoc/openssl-1.0.1c/include/openssl/crypto.h +diff -r -pu -X diff-exclude openssl-1.0.1c/include/openssl/crypto.h gsoc/openssl-1.0.1c/include/openssl/crypto.h --- openssl-1.0.1c/include/openssl/crypto.h 2011-06-01 18:54:03.000000000 +0200 +++ gsoc/openssl-1.0.1c/include/openssl/crypto.h 2012-06-10 01:01:26.000000000 +0200 @@ -222,6 +222,7 @@ typedef struct openssl_item_st @@ -1588,7 +1594,7 @@ #define CRYPTO_LOCK 1 #define CRYPTO_UNLOCK 2 -diff -rpu -X diff-exclude openssl-1.0.1c/include/openssl/err.h gsoc/openssl-1.0.1c/include/openssl/err.h +diff -r -pu -X diff-exclude openssl-1.0.1c/include/openssl/err.h gsoc/openssl-1.0.1c/include/openssl/err.h --- openssl-1.0.1c/include/openssl/err.h 2011-06-06 13:49:35.000000000 +0200 +++ gsoc/openssl-1.0.1c/include/openssl/err.h 2012-06-26 01:41:21.000000000 +0200 @@ -258,6 +258,7 @@ typedef struct err_state_st Added: soc2012/exxo/patches/ypwhich.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/exxo/patches/ypwhich.patch Mon Jul 16 17:20:13 2012 (r239475) @@ -0,0 +1,170 @@ +Index: freebsd-head/usr.bin/ypwhich/ypwhich.c +=================================================================== +--- freebsd-head/usr.bin/ypwhich/ypwhich.c (revision 239326) ++++ freebsd-head/usr.bin/ypwhich/ypwhich.c (working copy) +@@ -83,26 +83,39 @@ usage(void) + exit(ERR_USAGE); + } + ++#define ypb_family ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family ++#define ypb_addr ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr ++#ifdef INET6 ++# define ADDRSTRLEN INET6_ADDRSTRLEN ++#else ++# define ADDRSTRLEN INET_ADDRSTRLEN ++#endif + + /* + * Like yp_bind except can query a specific host + */ + static int +-bind_host(char *dom, struct sockaddr_in *lsin) ++bind_host(char *dom, const char *host) + { + struct hostent *hent = NULL; + struct ypbind_resp ypbr; + struct timeval tv; + CLIENT *client; +- int sock, r; +- struct in_addr ss_addr; ++ int r; ++ char str[ADDRSTRLEN]; ++ size_t len; ++ union { ++ struct in_addr in; ++#ifdef INET6 ++ struct in6_addr in6; ++#endif ++ } ss_addr; + +- sock = RPC_ANYSOCK; + tv.tv_sec = 15; + tv.tv_usec = 0; +- client = clntudp_create(lsin, YPBINDPROG, YPBINDVERS, tv, &sock); ++ client = clnt_create_timed(host, YPBINDPROG, YPBINDVERS, "udp", &tv); + if (client == NULL) { +- warnx("can't clntudp_create: %s", yperr_string(YPERR_YPBIND)); ++ warnx("can't clnt_create_timed: %s", yperr_string(YPERR_YPBIND)); + return (YPERR_YPBIND); + } + +@@ -124,14 +137,18 @@ bind_host(char *dom, struct sockaddr_in + } + } + clnt_destroy(client); +- +- ss_addr = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr; +- /*printf("%08x\n", ss_addr);*/ +- hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET); ++ bcopy(&ypb_addr, &ss_addr, sizeof(ss_addr)); ++#ifdef INET6 ++ if (ypb_family == AF_INET6) ++ len = sizeof(ss_addr.in6); ++ else /* AF_INET */ ++#endif ++ len = sizeof(ss_addr.in); ++ hent = gethostbyaddr((char *)&ss_addr, len, ypb_family); + if (hent) + printf("%s\n", hent->h_name); + else +- printf("%s\n", inet_ntoa(ss_addr)); ++ printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, ADDRSTRLEN)); + return (0); + } + +@@ -141,8 +158,7 @@ main(int argc, char *argv[]) + char *domnam = NULL, *master; + char *map = NULL; + struct ypmaplist *ypml, *y; +- struct hostent *hent; +- struct sockaddr_in lsin; ++ char *host; + int notrans, mode; + int c, r; + u_int i; +@@ -166,38 +182,20 @@ main(int argc, char *argv[]) + mode++; + break; + default: +- usage(); ++ usage(); + } + + if (!domnam) + yp_get_default_domain(&domnam); + + if (mode == 0) { +- switch (argc-optind) { +- case 0: +- bzero(&lsin, sizeof lsin); +- lsin.sin_family = AF_INET; +- lsin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); +- +- if (bind_host(domnam, &lsin)) ++ if (argc-optind == 0 || argc-optind == 1) { ++ host = argc-optind ? argv[optind] : "127.0.0.1"; ++ if (bind_host(domnam, host)) + exit(ERR_NOBINDING); +- break; +- case 1: +- bzero(&lsin, sizeof lsin); +- lsin.sin_family = AF_INET; +- if ((lsin.sin_addr.s_addr = inet_addr(argv[optind])) == INADDR_NONE) { +- hent = gethostbyname(argv[optind]); +- if (!hent) +- errx(ERR_NOSUCHHOST, "host %s unknown", argv[optind]); +- bcopy((char *)hent->h_addr_list[0], +- (char *)&lsin.sin_addr, sizeof lsin.sin_addr); +- } +- if (bind_host(domnam, &lsin)) +- exit(ERR_NOBINDING); +- break; +- default: +- usage(); + } ++ else ++ usage(); + exit(0); + } + +Index: freebsd-head/usr.bin/ypwhich/Makefile +=================================================================== +--- freebsd-head/usr.bin/ypwhich/Makefile (revision 239326) ++++ freebsd-head/usr.bin/ypwhich/Makefile (working copy) +@@ -5,4 +5,8 @@ PROG= ypwhich + + WARNS?= 2 + ++.if ${MK_INET6_SUPPORT} != "no" ++CFLAGS+= -DINET6 ++.endif ++ + .include +Index: freebsd-head/include/rpcsvc/yp_prot.h +=================================================================== +--- freebsd-head/include/rpcsvc/yp_prot.h (revision 239326) ++++ freebsd-head/include/rpcsvc/yp_prot.h (working copy) +@@ -199,7 +199,7 @@ struct ypresp_maplist { + struct dom_binding { + struct dom_binding *dom_pnext; + char dom_domain[YPMAXDOMAIN + 1]; +- struct sockaddr_in dom_server_addr; ++ struct sockaddr_storage dom_server_addr; + u_short dom_server_port; + int dom_socket; + CLIENT *dom_client; +@@ -238,7 +238,13 @@ enum ypbind_resptype { + + /* network order, of course */ + struct ypbind_binding { +- struct in_addr ypbind_binding_addr; ++ sa_family_t ypbind_binding_family; ++ union { ++ struct in_addr in; ++#ifdef INET6 ++ struct in6_addr in6; ++#endif ++ } ypbind_binding_addr; + u_short ypbind_binding_port; + }; + From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 19:24:30 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7D4501065674 for ; Mon, 16 Jul 2012 19:24:28 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 19:24:28 +0000 Date: Mon, 16 Jul 2012 19:24:28 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716192428.7D4501065674@hub.freebsd.org> Cc: Subject: socsvn commit: r239479 - in soc2012/jhagewood: diff diff/diff sdiff sdiff/sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 19:24:30 -0000 Author: jhagewood Date: Mon Jul 16 19:24:27 2012 New Revision: 239479 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239479 Log: Fixed some style issues in diff and sdiff Modified: soc2012/jhagewood/diff/diff/diff.c soc2012/jhagewood/diff/diff/diffdir.c soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff/hagewood-diff.patch soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/diff/diff/diff.c ============================================================================== --- soc2012/jhagewood/diff/diff/diff.c Mon Jul 16 18:13:43 2012 (r239478) +++ soc2012/jhagewood/diff/diff/diff.c Mon Jul 16 19:24:27 2012 (r239479) @@ -194,13 +194,11 @@ }; char **help_strs = (char **)help_msg; -void set_argstr(char **, char **); - - -void usage(void); -void push_excludes(char *); -void push_ignore_pats(char *); -void read_excludes_file(char *); +static void set_argstr(char **, char **); +static void usage(void); +static void push_excludes(char *); +static void push_ignore_pats(char *); +static void read_excludes_file(char *); int main(int argc, char **argv) @@ -423,7 +421,7 @@ oargv[0] = _PATH_SDIFF; *argv= "\0"; execv(_PATH_SDIFF, oargv); - _exit(127); + _exit(1); } /* @@ -479,7 +477,7 @@ /* Checks if --to-file or --from-file are specified */ if (Toflag && Fromflag) { (void)fprintf(stderr, "--from-file and --to-file both specified.\n"); - exit(2); + exit(1); } if (Toflag) { print_status(diffreg(optfile, argv[0], 0), optfile, argv[0], @@ -555,11 +553,11 @@ return (cp); } -void +static void set_argstr(char **av, char **ave) { - size_t argsize; - char **ap; + size_t argsize; + char **ap; argsize = 4 + *ave - *av + 1; diffargs = emalloc(argsize); @@ -575,12 +573,12 @@ /* * Read in an excludes file and push each line. */ -void +static void read_excludes_file(char *file) { - FILE *fp; - char *buf, *pattern; - size_t len; + FILE *fp; + char *buf, *pattern; + size_t len; if (strcmp(file, "-") == 0) fp = stdin; @@ -601,7 +599,7 @@ /* * Push a pattern onto the excludes list. */ -void +static void push_excludes(char *pattern) { struct excludes *entry; @@ -612,10 +610,10 @@ excludes_list = entry; } -void +static void push_ignore_pats(char *pattern) { - size_t len; + size_t len; if (ignore_pats == NULL) ignore_pats = estrdup(pattern); @@ -684,7 +682,7 @@ } } -void +static void usage(void) { @@ -698,5 +696,5 @@ " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n" " diff [-v]\n"); - exit(2); + exit(1); } Modified: soc2012/jhagewood/diff/diff/diffdir.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffdir.c Mon Jul 16 18:13:43 2012 (r239478) +++ soc2012/jhagewood/diff/diff/diffdir.c Mon Jul 16 19:24:27 2012 (r239479) @@ -27,6 +27,7 @@ #endif /* not lint */ #include __FBSDID("$FreeBSD$"); + #include #include Modified: soc2012/jhagewood/diff/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 16 18:13:43 2012 (r239478) +++ soc2012/jhagewood/diff/diff/diffreg.c Mon Jul 16 19:24:27 2012 (r239479) @@ -94,7 +94,7 @@ # define TIMESPEC_NS(timespec) 0 #endif -#define MAX_CHECK 768 +#define MAX_CHECK 768 /* 3 kilobytes of chars. */ /* * diff - compare two files. @@ -187,47 +187,47 @@ }; static FILE *opentemp(const char *); -static void output(char *, FILE *, char *, FILE *, int); -static void check(char *, FILE *, char *, FILE *); -static void range(int, int, char *); -static void uni_range(int, int); -static void dump_context_vec(FILE *, FILE *); -static void dump_unified_vec(FILE *, FILE *); -static void prepare(int, FILE *, off_t); -static void prune(void); -static void equiv(struct line *, int, struct line *, int, int *); -static void unravel(int); -static void unsort(struct line *, int, int *); -static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *); -static void sort(struct line *, int); -static void print_header(const char *, const char *); -static int ignoreline(char *); -static int istextfile(FILE *); -static int fetch(long *, int, int, FILE *, int, int); -static int newcand(int, int, int); -static int search(int *, int, int); -static int skipline(FILE *); -static int isqrt(int); -static int stone(int *, int, int *, int *); -static int readhash(FILE *); -static int files_differ(FILE *, FILE *, int); +static void output(char *, FILE *, char *, FILE *, int); +static void check(char *, FILE *, char *, FILE *); +static void range(int, int, char *); +static void uni_range(int, int); +static void dump_context_vec(FILE *, FILE *); +static void dump_unified_vec(FILE *, FILE *); +static void prepare(int, FILE *, off_t); +static void prune(void); +static void equiv(struct line *, int, struct line *, int, int *); +static void unravel(int); +static void unsort(struct line *, int, int *); +static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *); +static void sort(struct line *, int); +static void print_header(const char *, const char *); +static int ignoreline(char *); +static int istextfile(FILE *); +static int fetch(long *, int, int, FILE *, int, int); +static int newcand(int, int, int); +static int search(int *, int, int); +static int skipline(FILE *); +static int isqrt(int); +static int stone(int *, int, int *, int *); +static int readhash(FILE *); +static int files_differ(FILE *, FILE *, int); static char *match_function(const long *, int, FILE *); static char *preadline(int, size_t, off_t); -static int *J; /* will be overlaid on class */ -static int *class; /* will be overlaid on file[0] */ -static int *klist; /* will be overlaid on file[0] after class */ -static int *member; /* will be overlaid on file[1] */ -static int clen; -static int inifdef; /* whether or not we are in a #ifdef block */ -static int len[2]; -static int pref, suff; /* length of prefix and suffix */ -static int slen[2]; -static int anychange; +static int *J; /* will be overlaid on class */ +static int *class; /* will be overlaid on file[0] */ +static int *klist; /* will be overlaid on file[0] after class */ +static int *member; /* will be overlaid on file[1] */ +static int clen; +static int inifdef; /* whether or not we are in a #ifdef block */ +static int len[2]; +static int pref, suff; /* length of prefix and suffix */ +static int slen[2]; +static int anychange; static long *ixnew; /* will be overlaid on file[1] */ static long *ixold; /* will be overlaid on klist */ static struct cand *clist; /* merely a free storage pot for candidates */ -static int clistlen; /* the length of clist */ +static int clistlen; /* the length of clist */ static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ static u_char *chrtran; /* translation table for case-folding */ static struct context_vec *context_vec_start; @@ -316,7 +316,7 @@ if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode)) return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0) - goto closem; + goto CLOSEM; if (flags & D_EMPTY1) f1 = fopen(_PATH_DEVNULL, "r"); @@ -326,7 +326,7 @@ fstat(fileno(f1), &stb1) < 0) { warn("%s", file1); status |= 2; - goto closem; + goto CLOSEM; } } else if (strcmp(file1, "-") == 0) f1 = stdin; @@ -336,7 +336,7 @@ if (f1 == NULL) { warn("%s", file1); status |= 2; - goto closem; + goto CLOSEM; } if (flags & D_EMPTY2) @@ -347,7 +347,7 @@ fstat(fileno(f2), &stb2) < 0) { warn("%s", file2); status |= 2; - goto closem; + goto CLOSEM; } } else if (strcmp(file2, "-") == 0) f2 = stdin; @@ -357,23 +357,23 @@ if (f2 == NULL) { warn("%s", file2); status |= 2; - goto closem; + goto CLOSEM; } switch (files_differ(f1, f2, flags)) { case 0: - goto closem; + goto CLOSEM; case 1: break; default: /* error */ status |= 2; - goto closem; + goto CLOSEM; } if (!istextfile(f1) || !istextfile(f2)) { rval = D_BINARY; status |= 1; - goto closem; + goto CLOSEM; } if (lflag) { /* redirect stdout to pr */ @@ -457,7 +457,11 @@ } waitpid(pid, &wstatus, 0); } -closem: + + /* + * Closes and frees open files + */ +CLOSEM: if (anychange) { status |= 1; if (rval == D_SAME) @@ -1069,7 +1073,7 @@ static size_t max_context = 64; int i; -restart: +RESTART: if (format != D_IFDEF && a > b && c > d) return; if (ignore_pats != NULL) { @@ -1084,7 +1088,7 @@ line = preadline(fileno(f1), ixold[i] - ixold[i - 1], ixold[i - 1]); if (!ignoreline(line)) - goto proceed; + goto PROCEED; } } if (a > b || c <= d) { /* Changes and inserts. */ @@ -1092,12 +1096,12 @@ line = preadline(fileno(f2), ixnew[i] - ixnew[i - 1], ixnew[i - 1]); if (!ignoreline(line)) - goto proceed; + goto PROCEED; } } return; } -proceed: +PROCEED: if (*pflags & D_HEADER) { printf("%s %s %s\n", diffargs, file1, file2); *pflags &= ~D_HEADER; @@ -1186,7 +1190,7 @@ printf("%ds/^\\.\\././\n", a); a += i; c += i; - goto restart; + goto RESTART; } if ((format == D_EDIT || format == D_REVERSE) && c <= d) printf("."); Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 16 18:13:43 2012 (r239478) +++ soc2012/jhagewood/diff/hagewood-diff.patch Mon Jul 16 19:24:27 2012 (r239479) @@ -1,6 +1,6 @@ diff -rupN jhagewood/diff/diff-orig/diff.c jhagewood/diff/diff/diff.c ---- jhagewood/diff/diff-orig/diff.c 2012-07-07 19:37:17.000000000 -0400 -+++ jhagewood/diff/diff/diff.c 2012-07-07 19:37:18.000000000 -0400 +--- jhagewood/diff/diff-orig/diff.c 2012-07-14 03:47:28.000000000 -0400 ++++ jhagewood/diff/diff/diff.c 2012-07-16 05:03:03.000000000 -0400 @@ -1,4 +1,4 @@ -/*- +/* @@ -56,7 +56,7 @@ /* Options which exceed manageable alphanumeric assignments */ -@@ -69,84 +67,129 @@ enum +@@ -69,107 +67,151 @@ enum OPT_STRIPCR, OPT_NORMAL, OPT_LEFTC, @@ -238,7 +238,20 @@ NULL, }; char **help_strs = (char **)help_msg; -@@ -162,14 +205,15 @@ void read_excludes_file(char *); + +-void set_argstr(char **, char **); +- +- +-void usage(void); +-void push_excludes(char *); +-void push_ignore_pats(char *); +-void read_excludes_file(char *); ++static void set_argstr(char **, char **); ++static void usage(void); ++static void push_excludes(char *); ++static void push_ignore_pats(char *); ++static void read_excludes_file(char *); + int main(int argc, char **argv) { @@ -259,7 +272,7 @@ lastch = '\0'; prevoptind = 1; -@@ -197,6 +241,7 @@ main(int argc, char **argv) +@@ -197,6 +239,7 @@ main(int argc, char **argv) break; case 'C': case 'c': @@ -267,7 +280,7 @@ format = D_CONTEXT; if (optarg != NULL) { l = strtol(optarg, &ep, 10); -@@ -213,6 +258,9 @@ main(int argc, char **argv) +@@ -213,6 +256,9 @@ main(int argc, char **argv) case 'd': dflag = 1; break; @@ -277,7 +290,7 @@ case 'e': format = D_EDIT; break; -@@ -284,7 +332,7 @@ main(int argc, char **argv) +@@ -284,7 +330,7 @@ main(int argc, char **argv) case 'v': printf("FreeBSD diff 2.8.7\n"); exit(0); @@ -286,7 +299,7 @@ wflag = 1; break; case 'X': -@@ -296,15 +344,48 @@ main(int argc, char **argv) +@@ -296,15 +342,48 @@ main(int argc, char **argv) case 'y': yflag = 1; break; @@ -343,7 +356,7 @@ case OPT_STRIPCR: strip_cr=1; break; -@@ -315,11 +396,10 @@ main(int argc, char **argv) +@@ -315,11 +394,10 @@ main(int argc, char **argv) ignore_file_case = 0; break; case OPT_HELP: @@ -357,7 +370,7 @@ break; default: usage(); -@@ -328,20 +408,20 @@ main(int argc, char **argv) +@@ -328,22 +406,22 @@ main(int argc, char **argv) lastch = ch; newarg = optind != prevoptind; prevoptind = optind; @@ -381,9 +394,12 @@ *argv= "\0"; - execv(_PATH_SDIFF, oargv); - _exit(127); +- _exit(127); ++ _exit(1); } -@@ -380,7 +460,10 @@ main(int argc, char **argv) + + /* +@@ -380,7 +458,10 @@ main(int argc, char **argv) set_argstr(oargv, argv); if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) { if (format == D_IFDEF) @@ -395,7 +411,7 @@ diffdir(argv[0], argv[1]); } else { if (S_ISDIR(stb1.st_mode)) { -@@ -393,8 +476,26 @@ main(int argc, char **argv) +@@ -393,8 +474,26 @@ main(int argc, char **argv) if (stat(argv[1], &stb2) < 0) err(2, "%s", argv[1]); } @@ -404,7 +420,7 @@ + /* Checks if --to-file or --from-file are specified */ + if (Toflag && Fromflag) { + (void)fprintf(stderr, "--from-file and --to-file both specified.\n"); -+ exit(2); ++ exit(1); + } + if (Toflag) { + print_status(diffreg(optfile, argv[0], 0), optfile, argv[0], @@ -424,7 +440,7 @@ } exit(status); } -@@ -402,11 +503,10 @@ main(int argc, char **argv) +@@ -402,11 +501,10 @@ main(int argc, char **argv) void * emalloc(size_t n) { @@ -437,7 +453,7 @@ if ((p = malloc(n)) == NULL) errx(2, NULL); return (p); -@@ -415,7 +515,7 @@ emalloc(size_t n) +@@ -415,7 +513,7 @@ emalloc(size_t n) void * erealloc(void *p, size_t n) { @@ -446,7 +462,7 @@ if (n == 0) errx(2, NULL); -@@ -431,13 +531,12 @@ erealloc(void *p, size_t n) +@@ -431,13 +529,12 @@ erealloc(void *p, size_t n) int easprintf(char **ret, const char *fmt, ...) { @@ -462,7 +478,7 @@ if (len < 0 || *ret == NULL) errx(2, NULL); return (len); -@@ -446,11 +545,12 @@ easprintf(char **ret, const char *fmt, . +@@ -446,20 +543,21 @@ easprintf(char **ret, const char *fmt, . char * estrdup(const char *str) { @@ -477,7 +493,58 @@ strlcpy(cp, str, len); return (cp); } -@@ -531,6 +631,7 @@ push_ignore_pats(char *pattern) + +-void ++static void + set_argstr(char **av, char **ave) + { +- size_t argsize; +- char **ap; ++ size_t argsize; ++ char **ap; + + argsize = 4 + *ave - *av + 1; + diffargs = emalloc(argsize); +@@ -475,12 +573,12 @@ set_argstr(char **av, char **ave) + /* + * Read in an excludes file and push each line. + */ +-void ++static void + read_excludes_file(char *file) + { +- FILE *fp; +- char *buf, *pattern; +- size_t len; ++ FILE *fp; ++ char *buf, *pattern; ++ size_t len; + + if (strcmp(file, "-") == 0) + fp = stdin; +@@ -501,7 +599,7 @@ read_excludes_file(char *file) + /* + * Push a pattern onto the excludes list. + */ +-void ++static void + push_excludes(char *pattern) + { + struct excludes *entry; +@@ -512,10 +610,10 @@ push_excludes(char *pattern) + excludes_list = entry; + } + +-void ++static void + push_ignore_pats(char *pattern) + { +- size_t len; ++ size_t len; + + if (ignore_pats == NULL) + ignore_pats = estrdup(pattern); +@@ -531,6 +629,7 @@ push_ignore_pats(char *pattern) void print_only(const char *path, size_t dirlen, const char *entry) { @@ -485,7 +552,7 @@ if (dirlen > 1) dirlen--; printf("Only in %.*s: %s\n", (int)dirlen, path, entry); -@@ -539,45 +640,46 @@ print_only(const char *path, size_t dirl +@@ -539,52 +638,54 @@ print_only(const char *path, size_t dirl void print_status(int val, char *path1, char *path2, char *entry) { @@ -543,17 +610,25 @@ break; } } -@@ -585,6 +687,7 @@ print_status(int val, char *path1, char - void + +-void ++static void usage(void) { + (void)fprintf(stderr, "usage: diff [-abdilpqTtw] [-I pattern] [-c | -e | -f | -n | -u]\n" " [-L label] file1 file2\n" +@@ -595,5 +696,5 @@ usage(void) + " [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n" + " diff [-v]\n"); + +- exit(2); ++ exit(1); + } diff -rupN jhagewood/diff/diff-orig/diff.h jhagewood/diff/diff/diff.h ---- jhagewood/diff/diff-orig/diff.h 2012-07-07 19:37:17.000000000 -0400 -+++ jhagewood/diff/diff/diff.h 2012-07-07 19:37:18.000000000 -0400 +--- jhagewood/diff/diff-orig/diff.h 2012-07-14 03:47:28.000000000 -0400 ++++ jhagewood/diff/diff/diff.h 2012-07-14 03:47:29.000000000 -0400 @@ -48,6 +48,8 @@ #define D_NREVERSE 5 /* Reverse ed script with numbered lines and no trailing . */ @@ -577,9 +652,9 @@ extern char ignore_file_case; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; diff -rupN jhagewood/diff/diff-orig/diffdir.c jhagewood/diff/diff/diffdir.c ---- jhagewood/diff/diff-orig/diffdir.c 2012-07-07 19:37:17.000000000 -0400 -+++ jhagewood/diff/diff/diffdir.c 2012-07-07 19:37:18.000000000 -0400 -@@ -20,14 +20,13 @@ +--- jhagewood/diff/diff-orig/diffdir.c 2012-07-14 03:47:28.000000000 -0400 ++++ jhagewood/diff/diff/diffdir.c 2012-07-16 05:03:32.000000000 -0400 +@@ -20,13 +20,13 @@ #include @@ -592,13 +667,12 @@ +static char sccsid[] = "@(#)diffdir.c 8.1 (Berkeley) 6/6/93"; #endif #endif /* not lint */ -- +#include +__FBSDID("$FreeBSD$"); + #include #include - -@@ -57,12 +56,12 @@ static void diffit(struct dirent *, char +@@ -57,12 +57,12 @@ static void diffit(struct dirent *, char void diffdir(char *p1, char *p2) { @@ -617,7 +691,7 @@ dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1)); if (dirlen1 >= sizeof(path1) - 1) { -@@ -169,17 +168,16 @@ diffdir(char *p1, char *p2) +@@ -169,17 +169,16 @@ diffdir(char *p1, char *p2) static struct dirent ** slurpdir(char *path, char **bufp, int enoentok) { @@ -641,7 +715,7 @@ if (!enoentok || errno != ENOENT) { warn("%s", path); return (NULL); -@@ -191,19 +189,17 @@ slurpdir(char *path, char **bufp, int en +@@ -191,19 +190,17 @@ slurpdir(char *path, char **bufp, int en close(fd); return (NULL); } @@ -666,7 +740,7 @@ } nbytes = getdirentries(fd, ebuf, have, &base); if (nbytes == -1) { -@@ -255,8 +251,8 @@ slurpdir(char *path, char **bufp, int en +@@ -255,8 +252,8 @@ slurpdir(char *path, char **bufp, int en static int dircompare(const void *vp1, const void *vp2) { @@ -677,7 +751,7 @@ return (strcmp(dp1->d_name, dp2->d_name)); } -@@ -267,7 +263,7 @@ dircompare(const void *vp1, const void * +@@ -267,7 +264,7 @@ dircompare(const void *vp1, const void * static void diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2) { @@ -687,8 +761,8 @@ strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1); if (stat(path1, &stb1) != 0) { diff -rupN jhagewood/diff/diff-orig/diffreg.c jhagewood/diff/diff/diffreg.c ---- jhagewood/diff/diff-orig/diffreg.c 2012-07-07 19:37:17.000000000 -0400 -+++ jhagewood/diff/diff/diffreg.c 2012-07-07 19:37:18.000000000 -0400 +--- jhagewood/diff/diff-orig/diffreg.c 2012-07-14 03:47:28.000000000 -0400 ++++ jhagewood/diff/diff/diffreg.c 2012-07-16 05:51:05.000000000 -0400 @@ -62,15 +62,13 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ @@ -719,20 +793,94 @@ +# define TIMESPEC_NS(timespec) 0 +#endif + -+#define MAX_CHECK 768 ++#define MAX_CHECK 768 /* 3 kilobytes of chars. */ + /* * diff - compare two files. */ -@@ -196,7 +202,7 @@ static void change(char *, FILE *, char - static void sort(struct line *, int); - static void print_header(const char *, const char *); - static int ignoreline(char *); +@@ -181,47 +187,47 @@ struct context_vec { + }; + + static FILE *opentemp(const char *); +-static void output(char *, FILE *, char *, FILE *, int); +-static void check(char *, FILE *, char *, FILE *); +-static void range(int, int, char *); +-static void uni_range(int, int); +-static void dump_context_vec(FILE *, FILE *); +-static void dump_unified_vec(FILE *, FILE *); +-static void prepare(int, FILE *, off_t); +-static void prune(void); +-static void equiv(struct line *, int, struct line *, int, int *); +-static void unravel(int); +-static void unsort(struct line *, int, int *); +-static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *); +-static void sort(struct line *, int); +-static void print_header(const char *, const char *); +-static int ignoreline(char *); -static int asciifile(FILE *); -+static int istextfile(FILE *); - static int fetch(long *, int, int, FILE *, int, int); - static int newcand(int, int, int); - static int search(int *, int, int); +-static int fetch(long *, int, int, FILE *, int, int); +-static int newcand(int, int, int); +-static int search(int *, int, int); +-static int skipline(FILE *); +-static int isqrt(int); +-static int stone(int *, int, int *, int *); +-static int readhash(FILE *); +-static int files_differ(FILE *, FILE *, int); ++static void output(char *, FILE *, char *, FILE *, int); ++static void check(char *, FILE *, char *, FILE *); ++static void range(int, int, char *); ++static void uni_range(int, int); ++static void dump_context_vec(FILE *, FILE *); ++static void dump_unified_vec(FILE *, FILE *); ++static void prepare(int, FILE *, off_t); ++static void prune(void); ++static void equiv(struct line *, int, struct line *, int, int *); ++static void unravel(int); ++static void unsort(struct line *, int, int *); ++static void change(char *, FILE *, char *, FILE *, int, int, int, int, int *); ++static void sort(struct line *, int); ++static void print_header(const char *, const char *); ++static int ignoreline(char *); ++static int istextfile(FILE *); ++static int fetch(long *, int, int, FILE *, int, int); ++static int newcand(int, int, int); ++static int search(int *, int, int); ++static int skipline(FILE *); ++static int isqrt(int); ++static int stone(int *, int, int *, int *); ++static int readhash(FILE *); ++static int files_differ(FILE *, FILE *, int); + static char *match_function(const long *, int, FILE *); + static char *preadline(int, size_t, off_t); + +-static int *J; /* will be overlaid on class */ +-static int *class; /* will be overlaid on file[0] */ +-static int *klist; /* will be overlaid on file[0] after class */ +-static int *member; /* will be overlaid on file[1] */ +-static int clen; +-static int inifdef; /* whether or not we are in a #ifdef block */ +-static int len[2]; +-static int pref, suff; /* length of prefix and suffix */ +-static int slen[2]; +-static int anychange; ++static int *J; /* will be overlaid on class */ ++static int *class; /* will be overlaid on file[0] */ ++static int *klist; /* will be overlaid on file[0] after class */ ++static int *member; /* will be overlaid on file[1] */ ++static int clen; ++static int inifdef; /* whether or not we are in a #ifdef block */ ++static int len[2]; ++static int pref, suff; /* length of prefix and suffix */ ++static int slen[2]; ++static int anychange; + static long *ixnew; /* will be overlaid on file[1] */ + static long *ixold; /* will be overlaid on klist */ + static struct cand *clist; /* merely a free storage pot for candidates */ +-static int clistlen; /* the length of clist */ ++static int clistlen; /* the length of clist */ + static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ + static u_char *chrtran; /* translation table for case-folding */ + static struct context_vec *context_vec_start; @@ -294,13 +300,13 @@ u_char cup2low[256] = { int diffreg(char *ofile1, char *ofile2, int flags) @@ -754,24 +902,86 @@ anychange = 0; lastline = 0; -@@ -353,7 +359,6 @@ diffreg(char *ofile1, char *ofile2, int +@@ -310,7 +316,7 @@ diffreg(char *ofile1, char *ofile2, int + if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode)) + return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); + if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0) +- goto closem; ++ goto CLOSEM; + + if (flags & D_EMPTY1) + f1 = fopen(_PATH_DEVNULL, "r"); +@@ -320,7 +326,7 @@ diffreg(char *ofile1, char *ofile2, int + fstat(fileno(f1), &stb1) < 0) { + warn("%s", file1); + status |= 2; +- goto closem; ++ goto CLOSEM; + } + } else if (strcmp(file1, "-") == 0) + f1 = stdin; +@@ -330,7 +336,7 @@ diffreg(char *ofile1, char *ofile2, int + if (f1 == NULL) { + warn("%s", file1); status |= 2; - goto closem; +- goto closem; ++ goto CLOSEM; + } + + if (flags & D_EMPTY2) +@@ -341,7 +347,7 @@ diffreg(char *ofile1, char *ofile2, int + fstat(fileno(f2), &stb2) < 0) { + warn("%s", file2); + status |= 2; +- goto closem; ++ goto CLOSEM; + } + } else if (strcmp(file2, "-") == 0) + f2 = stdin; +@@ -351,24 +357,23 @@ diffreg(char *ofile1, char *ofile2, int + if (f2 == NULL) { + warn("%s", file2); + status |= 2; +- goto closem; ++ goto CLOSEM; } - switch (files_differ(f1, f2, flags)) { case 0: - goto closem; -@@ -365,7 +370,7 @@ diffreg(char *ofile1, char *ofile2, int - goto closem; +- goto closem; ++ goto CLOSEM; + case 1: + break; + default: + /* error */ + status |= 2; +- goto closem; ++ goto CLOSEM; } - if (!asciifile(f1) || !asciifile(f2)) { + if (!istextfile(f1) || !istextfile(f2)) { rval = D_BINARY; status |= 1; - goto closem; -@@ -477,8 +482,8 @@ closem: +- goto closem; ++ goto CLOSEM; + } + if (lflag) { + /* redirect stdout to pr */ +@@ -452,7 +457,11 @@ diffreg(char *ofile1, char *ofile2, int + } + waitpid(pid, &wstatus, 0); + } +-closem: ++ ++ /* ++ * Closes and frees open files ++ */ ++CLOSEM: + if (anychange) { + status |= 1; + if (rval == D_SAME) +@@ -477,8 +486,8 @@ closem: static int files_differ(FILE *f1, FILE *f2, int flags) { @@ -782,7 +992,7 @@ if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size || (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) -@@ -503,9 +508,9 @@ files_differ(FILE *f1, FILE *f2, int fla +@@ -503,9 +512,9 @@ files_differ(FILE *f1, FILE *f2, int fla static FILE * opentemp(const char *file) { @@ -795,7 +1005,7 @@ if (strcmp(file, "-") == 0) ifd = STDIN_FILENO; -@@ -541,7 +546,7 @@ opentemp(const char *file) +@@ -541,7 +550,7 @@ opentemp(const char *file) char * splice(char *dir, char *file) { @@ -804,7 +1014,7 @@ if ((tail = strrchr(file, '/')) == NULL) tail = file; -@@ -555,8 +560,8 @@ static void +@@ -555,8 +564,8 @@ static void prepare(int i, FILE *fd, off_t filesize) { struct line *p; @@ -815,7 +1025,7 @@ rewind(fd); -@@ -579,7 +584,7 @@ prepare(int i, FILE *fd, off_t filesize) +@@ -579,7 +588,7 @@ prepare(int i, FILE *fd, off_t filesize) static void prune(void) { @@ -824,7 +1034,7 @@ for (pref = 0; pref < len[0] && pref < len[1] && file[0][pref + 1].value == file[1][pref + 1].value; -@@ -600,7 +605,7 @@ prune(void) +@@ -600,7 +609,7 @@ prune(void) static void equiv(struct line *a, int n, struct line *b, int m, int *c) { @@ -833,7 +1043,7 @@ i = j = 1; while (i <= n && j <= m) { -@@ -629,7 +634,7 @@ equiv(struct line *a, int n, struct line +@@ -629,7 +638,7 @@ equiv(struct line *a, int n, struct line static int isqrt(int n) { @@ -842,7 +1052,7 @@ if (n == 0) return (0); -@@ -647,9 +652,9 @@ isqrt(int n) +@@ -647,9 +656,9 @@ isqrt(int n) static int stone(int *a, int n, int *b, int *c) { @@ -855,7 +1065,7 @@ const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n)); k = 0; -@@ -705,7 +710,7 @@ newcand(int x, int y, int pred) +@@ -705,7 +714,7 @@ newcand(int x, int y, int pred) static int search(int *c, int k, int y) { @@ -864,7 +1074,7 @@ if (clist[c[k]].y < y) /* quick look for typical case */ return (k + 1); -@@ -730,7 +735,7 @@ static void +@@ -730,7 +739,7 @@ static void unravel(int p) { struct cand *q; @@ -873,7 +1083,7 @@ for (i = 0; i <= len[0]; i++) J[i] = i <= pref ? i : -@@ -748,9 +753,10 @@ unravel(int p) +@@ -748,9 +757,10 @@ unravel(int p) static void check(char *file1, FILE *f1, char *file2, FILE *f2) { @@ -887,7 +1097,7 @@ rewind(f1); rewind(f2); j = 1; -@@ -766,7 +772,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -766,7 +776,7 @@ check(char *file1, FILE *f1, char *file2 ixnew[j] = ctnew += skipline(f2); j++; } @@ -896,7 +1106,7 @@ for (;;) { c = getc(f1); d = getc(f2); -@@ -781,6 +787,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -781,6 +791,7 @@ check(char *file1, FILE *f1, char *file2 } ctold++; ctnew++; @@ -904,7 +1114,7 @@ if (bflag && isspace(c) && isspace(d)) { do { if (c == '\n') -@@ -792,6 +799,7 @@ check(char *file1, FILE *f1, char *file2 +@@ -792,6 +803,7 @@ check(char *file1, FILE *f1, char *file2 break; ctnew++; } while (isspace(d = getc(f2))); @@ -912,7 +1122,7 @@ } else if (wflag) { while (isspace(c) && c != '\n') { c = getc(f1); -@@ -801,31 +809,55 @@ check(char *file1, FILE *f1, char *file2 +@@ -801,31 +813,55 @@ check(char *file1, FILE *f1, char *file2 d = getc(f2); ctnew++; } @@ -989,7 +1199,7 @@ if (chrtran[c] != chrtran[d]) { jackpot++; J[i] = 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Mon Jul 16 19:29:21 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 28CE61065670 for ; Mon, 16 Jul 2012 19:29:19 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Mon, 16 Jul 2012 19:29:19 +0000 Date: Mon, 16 Jul 2012 19:29:19 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120716192919.28CE61065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239480 - in soc2012/jhagewood/sdiff: . sdiff X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jul 2012 19:29:21 -0000 Author: jhagewood Date: Mon Jul 16 19:29:18 2012 New Revision: 239480 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239480 Log: Fixed some style issues in sdiff Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/common.c soc2012/jhagewood/sdiff/sdiff/common.h soc2012/jhagewood/sdiff/sdiff/edit.c soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 16 19:24:27 2012 (r239479) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Mon Jul 16 19:29:18 2012 (r239480) @@ -1,3 +1,64 @@ +diff -rupN jhagewood/sdiff/sdiff-orig/common.c jhagewood/sdiff/sdiff/common.c +--- jhagewood/sdiff/sdiff-orig/common.c 2012-07-14 03:47:32.000000000 -0400 ++++ jhagewood/sdiff/sdiff/common.c 2012-07-16 19:27:40.000000000 -0400 +@@ -5,16 +5,24 @@ + * Public domain. + */ + ++#if 0 ++#ifndef lint ++static char sccsid[] = "@(#)common.c"; ++#endif ++#endif /* not lint */ ++#include ++__FBSDID("$FreeBSD$"); ++ + #include + #include + #include + + #include "common.h" + +-__dead void ++void + cleanup(const char *filename) + { + if (unlink(filename)) + err(2, "could not delete: %s", filename); +- exit(2); ++ exit(1); + } +diff -rupN jhagewood/sdiff/sdiff-orig/common.h jhagewood/sdiff/sdiff/common.h +--- jhagewood/sdiff/sdiff-orig/common.h 2012-07-14 03:47:32.000000000 -0400 ++++ jhagewood/sdiff/sdiff/common.h 2012-07-16 19:27:30.000000000 -0400 +@@ -5,8 +5,4 @@ + * Public domain. + */ + +-#ifdef __FreeBSD__ +-#define __dead +-#endif +- +-__dead void cleanup(const char *); ++void cleanup(const char *) __dead2; +diff -rupN jhagewood/sdiff/sdiff-orig/edit.c jhagewood/sdiff/sdiff/edit.c +--- jhagewood/sdiff/sdiff-orig/edit.c 2012-07-14 03:47:32.000000000 -0400 ++++ jhagewood/sdiff/sdiff/edit.c 2012-07-16 19:29:10.000000000 -0400 +@@ -4,6 +4,14 @@ + * Written by Raymond Lai . + * Public domain. + */ ++ ++#if 0 ++#ifndef lint ++static char sccsid[] = "@(#)edit.c"; ++#endif ++#endif /* not lint */ ++#include ++__FBSDID("$FreeBSD$"); + + #include + #include diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.1 jhagewood/sdiff/sdiff/sdiff.1 --- jhagewood/sdiff/sdiff-orig/sdiff.1 2012-07-14 03:47:32.000000000 -0400 +++ jhagewood/sdiff/sdiff/sdiff.1 2012-07-14 03:47:32.000000000 -0400 @@ -112,8 +173,8 @@ + diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c --- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-14 03:47:32.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-14 03:52:09.000000000 -0400 -@@ -5,6 +5,15 @@ ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-16 19:26:27.000000000 -0400 +@@ -5,6 +5,14 @@ * Public domain. */ @@ -122,14 +183,13 @@ +static char sccsid[] = "@(#)sdiff.c"; +#endif +#endif /* not lint */ -+ +#include +__FBSDID("$FreeBSD$"); + #include #include #include -@@ -62,81 +71,108 @@ static void printd(FILE *, size_t); +@@ -62,81 +70,108 @@ static void printd(FILE *, size_t); static void println(const char *, const char, const char *); static void processq(void); static void prompt(const char *, const char *); @@ -296,7 +356,7 @@ /* * Create temporary file if source_file is not a regular file. * Returns temporary file name if one was malloced, NULL if unnecessary. -@@ -175,7 +211,7 @@ mktmpcpy(const char *source_file) +@@ -175,7 +210,7 @@ mktmpcpy(const char *source_file) err(2, "asprintf"); if ((ofd = mkstemp(target_file)) == -1) { warn("error opening %s", target_file); @@ -305,7 +365,7 @@ } while ((rcount = read(ifd, buf, sizeof(buf))) != -1 && rcount != 0) { -@@ -184,22 +220,18 @@ mktmpcpy(const char *source_file) +@@ -184,22 +219,18 @@ mktmpcpy(const char *source_file) wcount = write(ofd, buf, (size_t)rcount); if (-1 == wcount || rcount != wcount) { warn("error writing to %s", target_file); @@ -330,7 +390,7 @@ } int -@@ -240,18 +272,13 @@ main(int argc, char **argv) +@@ -240,18 +271,13 @@ main(int argc, char **argv) const char *errstr; switch (ch) { @@ -349,7 +409,7 @@ /* combine no-arg single switches */ case 'a': case 'B': -@@ -261,11 +288,17 @@ main(int argc, char **argv) +@@ -261,11 +287,17 @@ main(int argc, char **argv) case 'i': case 't': case 'H': @@ -370,7 +430,7 @@ case DIFFPROG_OPT: diffargv[0] = diffprog = optarg; break; -@@ -289,32 +322,27 @@ main(int argc, char **argv) +@@ -289,32 +321,27 @@ main(int argc, char **argv) if (errstr) errx(2, "width is %s: %s", errstr, optarg); break; @@ -410,7 +470,7 @@ diffargv[i] = diffargv[i+1]; } diffargv[diffargc-1] = NULL; -@@ -362,19 +390,18 @@ main(int argc, char **argv) +@@ -362,19 +389,18 @@ main(int argc, char **argv) /* Add NULL to end of array to indicate end of array. */ diffargv[diffargc++] = NULL; @@ -435,7 +495,7 @@ case 0: /* child */ /* We don't read from the pipe. */ -@@ -383,7 +410,6 @@ main(int argc, char **argv) +@@ -383,7 +409,6 @@ main(int argc, char **argv) err(2, "child could not duplicate descriptor"); /* Free unused descriptor. */ close(fd[1]); @@ -443,7 +503,7 @@ execvp(diffprog, diffargv); err(2, "could not execute diff: %s", diffprog); break; -@@ -461,6 +487,7 @@ main(int argc, char **argv) +@@ -461,6 +486,7 @@ main(int argc, char **argv) static void printcol(const char *s, size_t *col, const size_t col_max) { @@ -451,7 +511,7 @@ for (; *s && *col < col_max; ++s) { size_t new_col; -@@ -484,11 +511,9 @@ printcol(const char *s, size_t *col, con +@@ -484,11 +510,9 @@ printcol(const char *s, size_t *col, con return; *col = new_col; break; @@ -463,7 +523,7 @@ putchar(*s); } } -@@ -512,56 +537,47 @@ prompt(const char *s1, const char *s2) +@@ -512,56 +536,47 @@ prompt(const char *s1, const char *s2) /* Skip leading whitespace. */ for (p = cmd; isspace(*p); ++p) ; @@ -529,7 +589,7 @@ free(cmd); return; } -@@ -570,7 +586,7 @@ PROMPT: +@@ -570,7 +585,7 @@ PROMPT: * If there was no error, we received an EOF from stdin, so we * should quit. */ @@ -538,7 +598,7 @@ fclose(outfp); exit(0); } -@@ -678,7 +694,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI +@@ -678,7 +693,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI /* A range is specified for file1. */ if (c == ',') { @@ -546,7 +606,7 @@ q = p; /* Go to character after file2end. */ while (isdigit(*p)) -@@ -690,7 +705,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI +@@ -690,7 +704,6 @@ parsecmd(FILE *diffpipe, FILE *file1, FI errx(2, "file1 end is %s: %s", errstr, line); if (file1start > file1end) errx(2, "invalid line range in file1: %s", line); @@ -554,7 +614,7 @@ } else file1end = file1start; -@@ -809,17 +823,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FI +@@ -809,17 +822,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FI printa(file2, file2end); n = file2end - file2start + 1; break; @@ -572,7 +632,7 @@ default: errx(2, "invalid diff command: %c: %s", cmd, line); } -@@ -854,6 +865,7 @@ enqueue(char *left, char div, char *righ +@@ -854,6 +864,7 @@ enqueue(char *left, char div, char *righ static void freediff(struct diffline *diffp) { @@ -580,7 +640,7 @@ free(diffp->left); free(diffp->right); free(diffp); -@@ -876,7 +888,6 @@ astrcat(char **s, const char *append) +@@ -876,7 +887,6 @@ astrcat(char **s, const char *append) static const char *oldstr = NULL; char *newstr; @@ -588,7 +648,7 @@ /* * First string is NULL, so just copy append. */ -@@ -1002,7 +1013,6 @@ printa(FILE *file, size_t line2) +@@ -1002,7 +1012,6 @@ printa(FILE *file, size_t line2) errx(2, "append ended early"); enqueue(NULL, '>', line); } @@ -596,7 +656,7 @@ processq(); } -@@ -1103,24 +1113,35 @@ printd(FILE *file1, size_t file1end) +@@ -1103,24 +1112,35 @@ printd(FILE *file1, size_t file1end) static void int_usage(void) { Modified: soc2012/jhagewood/sdiff/sdiff/common.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/common.c Mon Jul 16 19:24:27 2012 (r239479) +++ soc2012/jhagewood/sdiff/sdiff/common.c Mon Jul 16 19:29:18 2012 (r239480) @@ -5,16 +5,24 @@ * Public domain. */ +#if 0 +#ifndef lint +static char sccsid[] = "@(#)common.c"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include #include "common.h" -__dead void +void cleanup(const char *filename) { if (unlink(filename)) err(2, "could not delete: %s", filename); - exit(2); + exit(1); } Modified: soc2012/jhagewood/sdiff/sdiff/common.h ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/common.h Mon Jul 16 19:24:27 2012 (r239479) +++ soc2012/jhagewood/sdiff/sdiff/common.h Mon Jul 16 19:29:18 2012 (r239480) @@ -5,8 +5,4 @@ * Public domain. */ -#ifdef __FreeBSD__ -#define __dead -#endif - -__dead void cleanup(const char *); +void cleanup(const char *) __dead2; Modified: soc2012/jhagewood/sdiff/sdiff/edit.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/edit.c Mon Jul 16 19:24:27 2012 (r239479) +++ soc2012/jhagewood/sdiff/sdiff/edit.c Mon Jul 16 19:29:18 2012 (r239480) @@ -4,6 +4,14 @@ * Written by Raymond Lai . * Public domain. */ + +#if 0 +#ifndef lint +static char sccsid[] = "@(#)edit.c"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); #include #include Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/sdiff.c Mon Jul 16 19:24:27 2012 (r239479) +++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Mon Jul 16 19:29:18 2012 (r239480) @@ -10,7 +10,6 @@ static char sccsid[] = "@(#)sdiff.c"; #endif #endif /* not lint */ - #include __FBSDID("$FreeBSD$"); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 17 15:48:46 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7FE911065675 for ; Tue, 17 Jul 2012 15:48:44 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 17 Jul 2012 15:48:44 +0000 Date: Tue, 17 Jul 2012 15:48:44 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120717154844.7FE911065675@hub.freebsd.org> Cc: Subject: socsvn commit: r239497 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2012 15:48:46 -0000 Author: gmiller Date: Tue Jul 17 15:48:43 2012 New Revision: 239497 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239497 Log: r239510@FreeBSD-dev: root | 2012-07-14 07:22:18 -0500 Implement pthread_lockorder_set_np(). Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 14:36:40 2012 (r239496) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 15:48:43 2012 (r239497) @@ -27,6 +27,7 @@ #include +#include #include #include #include Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 17 14:36:40 2012 (r239496) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 17 15:48:43 2012 (r239497) @@ -252,3 +252,13 @@ destroy_lock(spin); return (_pthread_spin_destroy(spin)); } + +int +pthread_lockorder_set_np(void *first, void *second) +{ + if (insert_lock(lookup_lock(first), lookup_lock(second)) < 0) { + return (EINVAL); + } + + return (0); +} From owner-svn-soc-all@FreeBSD.ORG Tue Jul 17 15:49:38 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 09B851065677 for ; Tue, 17 Jul 2012 15:49:36 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 17 Jul 2012 15:49:36 +0000 Date: Tue, 17 Jul 2012 15:49:36 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120717154936.09B851065677@hub.freebsd.org> Cc: Subject: socsvn commit: r239498 - in soc2012/gmiller/locking-head: . include lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2012 15:49:38 -0000 Author: gmiller Date: Tue Jul 17 15:49:35 2012 New Revision: 239498 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239498 Log: r239511@FreeBSD-dev: root | 2012-07-14 14:00:40 -0500 Implement pthread_lockorder_set_np() and partially implement pthread_lockorder_bless_np(). Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/include/pthread_np.h Tue Jul 17 15:49:35 2012 (r239498) @@ -107,8 +107,8 @@ int pthread_lor_next_np(struct pthread_lor_np *); void pthread_lor_end_np(struct pthread_lor_np *); void pthread_lor_clear_np(void); -void pthread_lockorder_bless_np(void *, void *); -void pthread_lockorder_set_np(void *first, void *second); +int pthread_lockorder_bless_np(void *, void *); +int pthread_lockorder_set_np(void *first, void *second); void pthread_lockorder_reset_np(void); void pthread_lockorder_begin_np(struct pthread_lockorder_np *); int pthread_lockorder_next_np(struct pthread_lockorder_np *); Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 17 15:49:35 2012 (r239498) @@ -47,6 +47,7 @@ info->lock = lock; info->child = NULL; info->sibling = NULL; + SLIST_INIT(&info->bless_head); SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); } Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 15:49:35 2012 (r239498) @@ -32,12 +32,18 @@ #include #include +struct blessing { + SLIST_ENTRY(blessing) bless_next; + struct lock_info *lock; +}; + struct lock_info { SLIST_ENTRY(lock_info) lock_info_next; void *lock; int active; struct lock_info *child; struct lock_info *sibling; + SLIST_HEAD(bless_head, blessing) bless_head; }; extern pthread_mutex_t witness_mtx; Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 17 15:48:43 2012 (r239497) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Tue Jul 17 15:49:35 2012 (r239498) @@ -262,3 +262,35 @@ return (0); } + +int +pthread_lockorder_bless_np(void *first_addr, void *second_addr) +{ + struct lock_info *first; + struct lock_info *second; + struct blessing *first_bless; + struct blessing *second_bless = NULL; + + first = lookup_lock(first_addr); + second = lookup_lock(second_addr); + + first_bless = malloc(sizeof(struct blessing)); + if (first_bless != NULL) { + second_bless = malloc(sizeof(struct blessing)); + if (second_bless == NULL) { + free(first_bless); + } + } + + if (second_bless == NULL) { + return (ENOMEM); + } + + first_bless->lock = second; + SLIST_INSERT_HEAD(&first->bless_head, first_bless, bless_next); + + second_bless->lock = first; + SLIST_INSERT_HEAD(&second->bless_head, second_bless, bless_next); + + return (0); +} From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 02:46:46 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id E1D27106564A for ; Wed, 18 Jul 2012 02:46:43 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 02:46:43 +0000 Date: Wed, 18 Jul 2012 02:46:43 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718024643.E1D27106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239506 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 02:46:46 -0000 Author: gmiller Date: Wed Jul 18 02:46:43 2012 New Revision: 239506 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239506 Log: r239539@FreeBSD-dev: root | 2012-07-14 17:22:10 -0500 Finish implementation of blessed locks. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Tue Jul 17 22:16:10 2012 (r239505) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Wed Jul 18 02:46:43 2012 (r239506) @@ -68,7 +68,7 @@ return (0); } - if (scan_graph(to, from)) { + if (scan_graph(to, from) && !blessed(from, to)) { return (-1); } Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Tue Jul 17 22:16:10 2012 (r239505) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Wed Jul 18 02:46:43 2012 (r239506) @@ -62,3 +62,17 @@ info = lookup_lock(lock); info->active = 0; } + +int +blessed(struct lock_info *first, struct lock_info *second) +{ + struct blessing *bless; + + SLIST_FOREACH(bless, &first->bless_head, bless_next) { + if (bless->lock == second) { + return (1); + } + } + + return (0); +} Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Tue Jul 17 22:16:10 2012 (r239505) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Wed Jul 18 02:46:43 2012 (r239506) @@ -56,4 +56,5 @@ void log_reversal(struct lock_info *lock, struct lock_info *previous); struct lock_info *lookup_lock(void *lock); -void destroy_lock(void *lock); +void destroy_lock(void *lock); +int blessed(struct lock_info *first, struct lock_info *second); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 02:47:10 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id E77F5106564A for ; Wed, 18 Jul 2012 02:47:07 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 02:47:07 +0000 Date: Wed, 18 Jul 2012 02:47:07 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718024707.E77F5106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239507 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 02:47:10 -0000 Author: gmiller Date: Wed Jul 18 02:47:07 2012 New Revision: 239507 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239507 Log: r239542@FreeBSD-dev: root | 2012-07-14 18:44:29 -0500 Implement pthread_lockorder_reset_np() and add some previously-omitted lock/unlock pairs. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Wed Jul 18 02:46:43 2012 (r239506) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Wed Jul 18 02:47:07 2012 (r239507) @@ -35,6 +35,9 @@ static _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head = SLIST_HEAD_INITIALIZER(lock_head); +static int reset_count = 0; +static _Thread_local int thread_reset_count = 0; + void add_lock(struct lock_info *lock) { @@ -46,6 +49,20 @@ entry = malloc(sizeof(*entry)); entry->lock = lock; + if (reset_count > thread_reset_count) { + thread_reset_count = reset_count; + + while (!SLIST_EMPTY(&lock_head)) { + entry = SLIST_FIRST(&lock_head); + + SLIST_REMOVE_HEAD(&lock_head, lock_next); + + free(entry); + } + + next = NULL; + } + SLIST_INSERT_HEAD(&lock_head, entry, lock_next); if (next != NULL && insert_lock(entry->lock, next->lock) < 0) { @@ -68,3 +85,9 @@ } } } + +void +reset_lists(void) +{ + reset_count++; +} Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Wed Jul 18 02:46:43 2012 (r239506) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Wed Jul 18 02:47:07 2012 (r239507) @@ -76,3 +76,17 @@ return (0); } + +void +reset_lock_info(void) +{ + struct lock_info *info; + + while (!SLIST_EMPTY(&lock_info_head)) { + info = SLIST_FIRST(&lock_info_head); + + SLIST_REMOVE_HEAD(&lock_info_head, lock_info_next); + + free(info); + } +} Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Wed Jul 18 02:46:43 2012 (r239506) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Wed Jul 18 02:47:07 2012 (r239507) @@ -48,13 +48,16 @@ extern pthread_mutex_t witness_mtx; -void add_lock(struct lock_info *lock); -void remove_lock(struct lock_info *lock); +void add_lock(struct lock_info *lock); +void remove_lock(struct lock_info *lock); +int insert_lock(struct lock_info *new_lock, + struct lock_info *previous); +void reset_lists(void); -int insert_lock(struct lock_info *new_lock, struct lock_info *previous); - -void log_reversal(struct lock_info *lock, struct lock_info *previous); +void log_reversal(struct lock_info *lock, + struct lock_info *previous); struct lock_info *lookup_lock(void *lock); void destroy_lock(void *lock); int blessed(struct lock_info *first, struct lock_info *second); +void reset_lock_info(void); Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Wed Jul 18 02:46:43 2012 (r239506) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Wed Jul 18 02:47:07 2012 (r239507) @@ -55,11 +55,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_mutex_lock(mutex); if (mutex != &witness_mtx && ret == 0) { add_lock(lookup_lock(mutex)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -68,11 +72,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_mutex_trylock(mutex); if (mutex != &witness_mtx && ret == 0) { add_lock(lookup_lock(mutex)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -81,11 +89,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_mutex_timedlock(mutex, ts); if (mutex != &witness_mtx && ret == 0) { add_lock(lookup_lock(mutex)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -94,19 +106,31 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_mutex_unlock(mutex); if (mutex != &witness_mtx && ret == 0) { remove_lock(lookup_lock(mutex)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } int pthread_mutex_destroy(pthread_mutex_t *mutex) { + int ret; + + _pthread_mutex_lock(&witness_mtx); + destroy_lock(mutex); - return (_pthread_mutex_destroy(mutex)); + ret = _pthread_mutex_destroy(mutex); + + _pthread_mutex_unlock(&witness_mtx); + + return (ret); } int @@ -114,11 +138,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_rdlock(rwlock); if (ret == 0) { add_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -127,11 +155,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_tryrdlock(rwlock); if (ret == 0) { add_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -140,11 +172,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_timedrdlock(rwlock, ts); if (ret == 0) { add_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -153,11 +189,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_wrlock(rwlock); if (ret == 0) { add_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -166,11 +206,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_trywrlock(rwlock); if (ret == 0) { add_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -179,11 +223,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_timedwrlock(rwlock, ts); if (ret == 0) { add_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -192,19 +240,31 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_rwlock_unlock(rwlock); if (ret == 0) { remove_lock(lookup_lock(rwlock)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } int pthread_rwlock_destroy(pthread_rwlock_t *rwlock) { + int ret; + + _pthread_mutex_lock(&witness_mtx); + destroy_lock(rwlock); - return (_pthread_rwlock_destroy(rwlock)); + ret = _pthread_rwlock_destroy(rwlock); + + _pthread_mutex_unlock(&witness_mtx); + + return (ret); } int @@ -212,11 +272,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_spin_lock(spin); if (ret == 0) { add_lock(lookup_lock(spin)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -225,11 +289,15 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_spin_lock(spin); if (ret == 0) { add_lock(lookup_lock(spin)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } @@ -238,29 +306,47 @@ { int ret; + _pthread_mutex_lock(&witness_mtx); + ret = _pthread_spin_unlock(spin); if (ret == 0) { remove_lock(lookup_lock(spin)); } + _pthread_mutex_unlock(&witness_mtx); + return (ret); } int pthread_spin_destroy(pthread_spinlock_t *spin) { + int ret; + + _pthread_mutex_lock(&witness_mtx); + destroy_lock(spin); - return (_pthread_spin_destroy(spin)); + ret = _pthread_spin_destroy(spin); + + _pthread_mutex_unlock(&witness_mtx); + + return (ret); } int pthread_lockorder_set_np(void *first, void *second) { + int ret = 0; + + _pthread_mutex_lock(&witness_mtx); + if (insert_lock(lookup_lock(first), lookup_lock(second)) < 0) { - return (EINVAL); + ret = EINVAL; } - return (0); + _pthread_mutex_unlock(&witness_mtx); + + return (ret); } int @@ -270,6 +356,9 @@ struct lock_info *second; struct blessing *first_bless; struct blessing *second_bless = NULL; + int ret = 0; + + _pthread_mutex_lock(&witness_mtx); first = lookup_lock(first_addr); second = lookup_lock(second_addr); @@ -283,14 +372,28 @@ } if (second_bless == NULL) { - return (ENOMEM); + ret = ENOMEM; + } else { + first_bless->lock = second; + SLIST_INSERT_HEAD(&first->bless_head, first_bless, bless_next); + + second_bless->lock = first; + SLIST_INSERT_HEAD(&second->bless_head, second_bless, + bless_next); } - first_bless->lock = second; - SLIST_INSERT_HEAD(&first->bless_head, first_bless, bless_next); + _pthread_mutex_unlock(&witness_mtx); + + return (ret); +} + +void +pthread_lockorder_reset_np(void) +{ + _pthread_mutex_lock(&witness_mtx); - second_bless->lock = first; - SLIST_INSERT_HEAD(&second->bless_head, second_bless, bless_next); + reset_lists(); + reset_lock_info(); - return (0); + _pthread_mutex_unlock(&witness_mtx); } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 10:04:42 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 147E61065686 for ; Wed, 18 Jul 2012 10:04:40 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 10:04:40 +0000 Date: Wed, 18 Jul 2012 10:04:40 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718100440.147E61065686@hub.freebsd.org> Cc: Subject: socsvn commit: r239530 - soc2012/syuu/bhyve-bios/lib/libbiosemul X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 10:04:42 -0000 Author: syuu Date: Wed Jul 18 10:04:39 2012 New Revision: 239530 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239530 Log: import doscmd source code to libbiosemul, cannnot compile for now Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/ soc2012/syuu/bhyve-bios/lib/libbiosemul/AsyncIO.c soc2012/syuu/bhyve-bios/lib/libbiosemul/AsyncIO.h soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile.dos soc2012/syuu/bhyve-bios/lib/libbiosemul/PROBLEMS soc2012/syuu/bhyve-bios/lib/libbiosemul/ParseBuffer.c soc2012/syuu/bhyve-bios/lib/libbiosemul/README soc2012/syuu/bhyve-bios/lib/libbiosemul/README.booting_dos soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.h soc2012/syuu/bhyve-bios/lib/libbiosemul/cmos.c soc2012/syuu/bhyve-bios/lib/libbiosemul/com.h soc2012/syuu/bhyve-bios/lib/libbiosemul/config.c soc2012/syuu/bhyve-bios/lib/libbiosemul/cp437-8x14.fnt.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/cp437-8x14.pcf.gz.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/cp437-8x16.fnt.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/cp437-8x16.pcf.gz.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/cp437-8x8.fnt.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/cp437-8x8.pcf.gz.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c soc2012/syuu/bhyve-bios/lib/libbiosemul/crt0.c soc2012/syuu/bhyve-bios/lib/libbiosemul/cwd.c soc2012/syuu/bhyve-bios/lib/libbiosemul/cwd.h soc2012/syuu/bhyve-bios/lib/libbiosemul/debug.c soc2012/syuu/bhyve-bios/lib/libbiosemul/disktab.c soc2012/syuu/bhyve-bios/lib/libbiosemul/dispatch.h soc2012/syuu/bhyve-bios/lib/libbiosemul/dos.c soc2012/syuu/bhyve-bios/lib/libbiosemul/dos.h soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.1 soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.c soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd_loader.c soc2012/syuu/bhyve-bios/lib/libbiosemul/ems.c soc2012/syuu/bhyve-bios/lib/libbiosemul/ems.h soc2012/syuu/bhyve-bios/lib/libbiosemul/emsdriv.S soc2012/syuu/bhyve-bios/lib/libbiosemul/emsdriv.sys.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/emuint.c soc2012/syuu/bhyve-bios/lib/libbiosemul/emuint.h soc2012/syuu/bhyve-bios/lib/libbiosemul/exe.c soc2012/syuu/bhyve-bios/lib/libbiosemul/fonts.dir soc2012/syuu/bhyve-bios/lib/libbiosemul/i386-pinsn.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int10.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int13.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int14.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int16.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int17.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int1a.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int2f.c soc2012/syuu/bhyve-bios/lib/libbiosemul/intff.c soc2012/syuu/bhyve-bios/lib/libbiosemul/mem.c soc2012/syuu/bhyve-bios/lib/libbiosemul/mouse.c soc2012/syuu/bhyve-bios/lib/libbiosemul/mouse.h soc2012/syuu/bhyve-bios/lib/libbiosemul/net.c soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c soc2012/syuu/bhyve-bios/lib/libbiosemul/redir.S soc2012/syuu/bhyve-bios/lib/libbiosemul/redir.com.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/register.h soc2012/syuu/bhyve-bios/lib/libbiosemul/setver.c soc2012/syuu/bhyve-bios/lib/libbiosemul/signal.c soc2012/syuu/bhyve-bios/lib/libbiosemul/timer.c soc2012/syuu/bhyve-bios/lib/libbiosemul/trace.c soc2012/syuu/bhyve-bios/lib/libbiosemul/trap.c soc2012/syuu/bhyve-bios/lib/libbiosemul/trap.h soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.c soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.h soc2012/syuu/bhyve-bios/lib/libbiosemul/video.c soc2012/syuu/bhyve-bios/lib/libbiosemul/video.h soc2012/syuu/bhyve-bios/lib/libbiosemul/vparams.h soc2012/syuu/bhyve-bios/lib/libbiosemul/xms.c soc2012/syuu/bhyve-bios/lib/libbiosemul/xms.h Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/AsyncIO.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/AsyncIO.c Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,263 @@ +/* + * Copyright (c) 1992, 1993, 1996 + * Berkeley Software Design, Inc. 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software + * Design, Inc. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, 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 Berkeley Software Design, 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. + * + * BSDI AsyncIO.c,v 2.2 1996/04/08 19:32:10 bostic Exp + */ + +#include +__FBSDID("$FreeBSD: projects/doscmd/AsyncIO.c,v 1.9 2002/05/10 10:40:46 tg Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "doscmd.h" +#include "AsyncIO.h" + +#define FD_ISZERO(p) ((p)->fds_bits[0] == 0) + +/* + * Set or Clear the Async nature of an FD + */ + +#define SETASYNC(fd) fcntl(fd, F_SETFL, handlers[fd].flag | FASYNC) +#define CLRASYNC(fd) fcntl(fd, F_SETFL, handlers[fd].flag & ~FASYNC) + +/* + * Request that ``func'' be called everytime data is available on ``fd'' + */ + +static fd_set fdset; /* File Descriptors to select on */ + +typedef struct { + void (*func)(int, int, void *, regcontext_t *); + /* Function to call on data arrival */ + void (*failure)(void *); /* Function to call on failure */ + void *arg; /* Argument to above functions */ + int lockcnt; /* Nested level of lock */ + fd_set members; /* Set of FD's to disable on SIGIO */ + int flag; /* The flag from F_GETFL (we own it) */ +} Async; + +static Async handlers[OPEN_MAX]; + +static void CleanIO(void); +static void HandleIO(struct sigframe *sf); + +void +_RegisterIO(int fd, void (*func)(int, int, void *, regcontext_t *), + void *arg, void (*failure)(void *)) +{ + static int firsttime = 1; + Async *as; + + if (fd < 0 || fd > OPEN_MAX) { +printf("%d: Invalid FD\n", fd); + return; + } + + as = &handlers[fd]; + + if ((as->flag = fcntl(fd, F_GETFL, 0)) == -1) { + if (func) { +/*@*/ perror("get fcntl"); +/*@*/ abort(); + return; + } + } + + if (firsttime) { + firsttime = 0; + setsignal(SIGIO, HandleIO); + } + + if ((handlers[fd].func = func) != 0) { + as->lockcnt = 0; + as->arg = arg; + as->failure = failure; + + FD_SET(fd, &fdset); + FD_ZERO(&handlers[fd].members); + FD_SET(fd, &handlers[fd].members); + if (fcntl(fd, F_SETOWN, getpid()) < 0) { +/*@*/ perror("SETOWN"); + } + SETASYNC(fd); + } else { + as->arg = 0; + as->failure = 0; + as->lockcnt = 0; + + CLRASYNC(fd); + FD_CLR(fd, &fdset); + } +} + +static void +CleanIO() +{ + int x; + static struct timeval tv; + + /* + * For every file des in fd_set, we check to see if it + * causes a fault on select(). If so, we unregister it + * for the user. + */ + for (x = 0; x < OPEN_MAX; ++x) { + fd_set set; + + if (!FD_ISSET(x, &fdset)) + continue; + + FD_ZERO(&set); + FD_SET(x, &set); + errno = 0; + if (select(FD_SETSIZE, &set, 0, 0, &tv) < 0 && + errno == EBADF) { + void (*f)(void *); + void *a; +printf("Closed file descriptor %d\n", x); + + f = handlers[x].failure; + a = handlers[x].arg; + handlers[x].failure = 0; + handlers[x].func = 0; + handlers[x].arg = 0; + handlers[x].lockcnt = 0; + FD_CLR(x, &fdset); + if (f) + (*f)(a); + } + } +} + +static void +HandleIO(struct sigframe *sf) +{ + static struct timeval tv; + fd_set readset, writeset; + int x, fd; + +again: + readset = writeset = fdset; + if ((x = select(FD_SETSIZE, &readset, &writeset, 0, &tv)) < 0) { + /* + * If we failed because of a BADFiledes, go find + * which one(s), fail them out and then try a + * new select to see if any of the good ones are + * okay. + */ + if (errno == EBADF) { + CleanIO(); + if (FD_ISZERO(&fdset)) + return; + goto again; + } + perror("select"); + return; + } + + /* + * If we run out of fds to look at, break out of the loop + * and exit the handler. + */ + if (x == 0) + return; + + /* + * If there is at least 1 fd saying it has something for + * us, then loop through the sets looking for those + * bits, stopping when we have handleed the number it has + * asked for. + */ + for (fd = 0; x && fd < OPEN_MAX; fd ++) { + Async *as; + int cond; + + cond = 0; + + if (FD_ISSET(fd, &readset)) { + cond |= AS_RD; + x --; + } + if (FD_ISSET(fd, &writeset)) { + cond |= AS_WR; + x --; + } + + if (cond == 0) + continue; + + /* + * Is suppose it is possible that one of the previous + * I/O requests changed the fdset. + * We do know that SIGIO is turned off right now, + * so it is safe to checkit. + */ + if (!FD_ISSET(fd, &fdset)) { + continue; + } + as = &handlers[fd]; + + /* + * as in above, maybe someone locked us... + * we are in dangerous water now if we are + * multi-tasked + */ + if (as->lockcnt) { + fprintf(stderr, "Selected IO on locked %d\n",fd); + continue; + } + /* + * Okay, now if there exists a handler, we should + * call it. We must turn back on SIGIO if there + * are possibly other people waiting for it. + */ + if (as->func) { + (*handlers[fd].func)(fd, cond, handlers[fd].arg, + (regcontext_t *)&sf->sf_uc.uc_mcontext); + } else { + /* + * Otherwise deregister this guy. + */ + _RegisterIO(fd, 0, 0, 0); + } + } + /* + * If we did not process all the fd's, then we should + * break out of the probable infinite loop. + */ +} Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/AsyncIO.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/AsyncIO.h Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1992, 1993, 1996 + * Berkeley Software Design, Inc. 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software + * Design, Inc. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, 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 Berkeley Software Design, 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. + * + * BSDI AsyncIO.h,v 2.2 1996/04/08 19:32:12 bostic Exp + * + * $FreeBSD: projects/doscmd/AsyncIO.h,v 1.4 2001/10/02 11:28:59 tg Exp $ + */ + +#if defined(__cplusplus) +extern "C" { +#endif +enum { + AS_RD = 1, + AS_WR = 2 +}; + +void _RegisterIO(int, void (*)(int, int, void *, regcontext_t *), + void *, void (*)(void *)); +#if defined(__cplusplus) +} +#endif + +#define _Un_RegisterIO(x) _RegisterIO((x), (void (*))0, (void *)0, (void (*))0) Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,80 @@ +# from BSDI Makefile,v 2.6 1996/04/08 20:06:40 bostic Exp +# +# $FreeBSD: projects/doscmd/Makefile,v 1.39 2004/03/30 17:10:01 des Exp $ + +PROG= doscmd +WARNS?= 2 +SRCS= AsyncIO.c ParseBuffer.c bios.c callback.c cmos.c config.c cpu.c cwd.c \ + debug.c disktab.c dos.c doscmd.c ems.c emuint.c exe.c i386-pinsn.c \ + int.c int10.c int13.c int14.c int16.c int17.c int1a.c int2f.c intff.c \ + mem.c mouse.c net.c port.c setver.c signal.c timer.c trace.c trap.c \ + tty.c video.c xms.c ${FONTHDRS} +CFLAGS+= -I. -DDISASSEMBLER +FONTFILES= cp437-8x8.pcf.gz cp437-8x14.pcf.gz cp437-8x16.pcf.gz +FONTHDRS= font8x8.h font8x14.h font8x16.h +CLEANFILES= ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com + +PREFIX?= /usr/local +BINDIR?= ${PREFIX}/bin +DATADIR?= ${PREFIX}/share/doscmd +DOCSDIR?= ${PREFIX}/share/doc/doscmd +FONTDIR?= ${DATADIR}/fonts + +X11BASE?= /usr/X11R6 +XINCDIR?= ${X11BASE}/include +XLIBDIR?= ${X11BASE}/lib + +DIRMODE?= 0755 + +.if !defined(NO_X) +CFLAGS+= -I${XINCDIR} +LDFLAGS= -L${XLIBDIR} +LDADD= -lX11 +DPADD= ${XLIBDIR}/libX11.a +.else +CFLAGS+= -DNO_X +.endif + +beforeinstall: + ${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${DIRMODE} ${DATADIR} + ${INSTALL} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \ + emsdriv.sys redir.com ${DATADIR} + ${INSTALL} -d -o ${DOCOWN} -g ${DOCGRP} -m ${DIRMODE} ${DOCSDIR} + ${INSTALL} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE} \ + ${.CURDIR}/README* ${.CURDIR}/PROBLEMS ${DOCSDIR} +.if !defined(NO_X) + ${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${DIRMODE} ${FONTDIR} + ${INSTALL} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \ + ${FONTFILES} ${.CURDIR}/fonts.dir ${FONTDIR} +.endif + +doscmd: ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com + +cp437-8x8.pcf.gz: cp437-8x8.pcf.gz.uu + uudecode ${.CURDIR}/cp437-8x8.pcf.gz.uu + +cp437-8x14.pcf.gz: cp437-8x14.pcf.gz.uu + uudecode ${.CURDIR}/cp437-8x14.pcf.gz.uu + +cp437-8x16.pcf.gz: cp437-8x16.pcf.gz.uu + uudecode ${.CURDIR}/cp437-8x16.pcf.gz.uu + +emsdriv.sys: emsdriv.sys.uu + uudecode ${.CURDIR}/emsdriv.sys.uu + +font8x8.h: cp437-8x8.fnt.uu + uudecode -p ${.ALLSRC} | \ + file2c 'u_int8_t font8x8[] = {' '};' > ${.TARGET} + +font8x14.h: cp437-8x14.fnt.uu + uudecode -p ${.ALLSRC} | \ + file2c 'u_int8_t font8x14[] = {' '};' > ${.TARGET} + +font8x16.h: cp437-8x16.fnt.uu + uudecode -p ${.ALLSRC} | \ + file2c 'u_int8_t font8x16[] = {' '};' > ${.TARGET} + +redir.com: redir.com.uu + uudecode ${.CURDIR}/redir.com.uu + +.include Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile.dos ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile.dos Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,48 @@ +# Special makefile for the as86/ld86 tools +# +# This is used only to make the dos tools. It is not used in the normal +# build process, except one of the *.S files is changed. The ready to +# use tools are included as uuencoded files. +# To use this makefile you must have Bruce Evans bcc package installed +# +# $FreeBSD: projects/doscmd/Makefile.dos,v 1.2 2001/07/24 11:50:23 tg Exp $ + +AS86 = as86 +LD86 = ld86 + +OBJS = redir.o emsdriv.o +DOSPROG = redir.com emsdriv.sys +DOSDIST = redir.com.uu emsdriv.sys.uu + +all: ${DOSPROG} ${DOSDIST} + +redir.com: redir.o + $(LD86) -T 0 -s -o ${.PREFIX}.tmp ${.ALLSRC} + dd if=${.PREFIX}.tmp of=${.TARGET} bs=1 skip=288 + rm -f ${.PREFIX}.tmp + +emsdriv.sys: emsdriv.o + $(LD86) -T 0 -s -o ${.PREFIX}.tmp ${.ALLSRC} + dd if=${.PREFIX}.tmp of=${.TARGET} bs=1 skip=32 + rm -f ${.PREFIX}.tmp + +redir.com.uu: redir.com + uuencode redir.com redir.com > redir.com.uu + +emsdriv.sys.uu: emsdriv.sys + uuencode emsdriv.sys emsdriv.sys > emsdriv.sys.uu + +clean: + rm -f ${DOSPROG} ${OBJS} + +allclean: + rm -f ${DOSPROG} ${DOSDIST} ${OBJS} + + +# Rule for as86 +.S.o: + $(AS86) -0 -o ${.TARGET} ${.IMPSRC} + + + + Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/PROBLEMS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/PROBLEMS Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,21 @@ +trailing \ missing in tempname (affects PKZIP) + +FCB find routines don't store the state correctly (affects DIR, NUSQ, GET) +support for non-extended FCBs is broken (affects LAR) +wrong device attributes reported after redirection (affects GZIP) +REP IN/OUT not implemented +find_next may not close fd +tty modes wrong when running in terminal session +devices not really implemented + +keyboard queue not fully implemented (affects VSAFE) +several ioctl request not implemented (affects PKZOOM) +no font file +int 0x28 not implemented +timer chip not implemented +country info needs localization + +specific programs: +charc crashes with a segment overrun +sqwez gets a fault while exiting +jrc outputs its banner again on exit, and sometimes complains about aa.aaa Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/ParseBuffer.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/ParseBuffer.c Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1992, 1993, 1996 + * Berkeley Software Design, Inc. 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software + * Design, Inc. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, 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 Berkeley Software Design, 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. + * + * BSDI ParseBuffer.c,v 2.2 1996/04/08 19:32:15 bostic Exp + */ + +#include +__FBSDID("$FreeBSD: projects/doscmd/ParseBuffer.c,v 1.5 2002/03/07 12:52:26 obrien Exp $"); + +#include +#include + +#include "doscmd.h" +int +ParseBuffer(obuf, av, mac) +char *obuf; +char **av; +int mac; +{ + static char *_buf; + char *buf; + static int buflen = 0; + int len; + + register char *b = buf; + register char *p; + register char **a; + register char **e; + + len = strlen(obuf) + 1; + if (len > buflen) { + if (buflen) + free(_buf); + buflen = (len + 1023) & ~1023; + _buf = malloc(buflen); + } + buf = _buf; + strcpy(buf, obuf); + + a = av; + e = &av[mac]; + + while (*buf) { + while (*buf == ' ' || *buf == '\t' || *buf == '\n') + ++buf; + if (*buf) { + p = b = buf; + + *a++ = buf; + if (a == e) { + a[-1] = (char *)0; + return(mac - 1); + } + + while (*p && !(*p == ' ' || *p == '\t' || *p == '\n')) { + *b++ = *p++ & 0177; + } + if (*p) + ++p; + *b = 0; + buf = p; + } + } + *a = (char *)0; + return(a - av); +} Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/README Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,37 @@ +/* BSDI README,v 2.2 1996/04/08 19:32:16 bostic Exp*/ +/* $FreeBSD: projects/doscmd/README,v 1.4 2002/05/16 02:18:59 trhodes Exp $ */ + +This is the merged doscmd/rundos project. Please read the man +page for help on configuring doscmd. + +Things known not to work: + * No mouse support (yet) + * No raw VGA support (yet) + * Printer support (yet) + * COM ports (being worked on) + * redirected filesystem only supported for DOS 4.0 and above + (3.3 will be supported in a future version) + * Graphics in an X window (only 16 colors, very few programs) + +Even with this, I think it is actually a much better product. There have +been problems reported with the ibmpc font and the distributed X server. +If you have that problem, try setting + + X11_FONT=fixed + +in your .doscmdrc. Be aware that graphics characters will not print correctly +if you do this. + +You will need to patch your kernel. Diffs are provided against the CD-ROM. +Please let me know if there are a problem with them (I am running a pre 1.1 +kernel now). + +It is possible there are some problems in the floppy code due to the fact +that I am not set up to test under 1.0 at this point. I will be in a few +days I hope. + +Please send all bug reports to prb@BSDI.COM. + + -Paul Borman + prb@BSDI.COM + Jan 4 1994 Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/README.booting_dos ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/README.booting_dos Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,98 @@ +/* BSDI README.booting_dos,v 2.2 1996/04/08 19:32:18 bostic Exp*/ +/* $FreeBSD: projects/doscmd/README.booting_dos,v 1.5 2002/05/16 02:18:59 trhodes Exp $ */ + +To install DOS on a pseudo hard disk under doscmd: + + 1) Create a .doscmdrc with at least the following: + + assign A: /dev/fd0.1440 1440 + assign A: /dev/fd0.720 720 + assign hard boot_drive 80 2 2 + + You may need to adjust the raw files for the A: drive to match + your system. This example will cause the HD drive to be tried + first and the DD drive second. + + Note that you should only use raw devices or files at this point, + do not use a cooked device! (Well, it would probably be okay + for a hard disk, but certainly not the floppy) + + boot_drive should be the file name of where you want your bootable + image to be. The three numbers which follow "80 2 2" say that the + drive will have 80 cylinders, 2 heads and 2 sectors per track. + This is the smallest drive possible which still can have MS DOS + 5.0 installed on it along with a config.sys and autoexec.bat file. + + You might want to create a larger boot drive. + + The file boot_drive must exist, so use the command touch to create + it. + + 2) Insert a floppy disk into the A: drive which is bootable to MS-DOS + and has the commands fdisk, format and sys on it. You should also + copy the file redir.com onto the floppy by either mounting it + with the msdos filesystem type or by using mtools. + + (i.e. mwrite redir.com a:) + + 3) run doscmd. + + 4) At the > prompt type "fdisk" + + 5) Select "Create DOS partition or Logical Drive" + + 6) Select "Create Primary DOS Partition" + + 7) Tell it how big to make it (I say use the whole drive. + It is pretty tiny after all.) + + 8) Get out of FDISK by hitting a few times. + + 9) doscmd will now abort (will try and fix this in a future version) + + 10) start up doscmd again, leaving the floppy in the drive. + + 11) At the > prompt, type "format c:" and follow the instructions. + + 12) At the > prompt type "sys c:" + + 13) Get out of doscmd. + + 14) Either remove the floppy from the drive or add the line + + boot C: + + to your .doscmdrc + + 15) You should now be running DOS off of your new disk. You will + probably want both config.sys and an autoexec.bat file. To + start with, you can say: + + > copy con: config.sys + LASTDRIVE=Z + ^Z + > copy con: autoexec.bat + @echo off + redir.com + ^Z + + + 16) Quit doscmd. + + 17) You now have a bootable pseudo disk which will automatically call + the magic "redir" program, which installs FreeBSD disks. To use + them add lines to your .doscmdrc such as: + + assign D: /usr/dos + assign P: -ro /usr/prb + + Note that you will not always be able to access every file due to + naming problems. + + 18) To use the new EMS memory you need to copy the file emsdriv.sys + to your DOS boot disk (disk image) in the same way you copied + redir.com. The use it in your "config.sys" from DOS: + device=C:\emsdriv.sys + where C: is your boot drive (supply the correct letter, if needed) + and emsdriv.sys is the driver. You could load it high. It should + report "Doscmd EMS 4.0 driver installed". Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c Wed Jul 18 10:04:39 2012 (r239530) @@ -0,0 +1,322 @@ +/* + * Copyright (c) 1992, 1993, 1996 + * Berkeley Software Design, Inc. 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Berkeley Software + * Design, Inc. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, 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 Berkeley Software Design, 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. + * + * BSDI bios.c,v 2.3 1996/04/08 19:32:19 bostic Exp + */ + +#include +#include +__FBSDID("$FreeBSD: projects/doscmd/bios.c,v 1.9 2002/03/07 12:52:26 obrien Exp $"); + +#include "doscmd.h" +#include "mouse.h" +#include "com.h" + +#define BIOS_copyright 0xfe000 +#define BIOS_reset 0xfe05b +#define BIOS_nmi 0xfe2c3 +#define BIOS_hdisk_table 0xfe401 +#define BIOS_boot 0xfe6f2 +#define BIOS_comm_table 0xfe729 +#define BIOS_comm_io 0xfe739 +#define BIOS_keyboard_io 0xfe82e +#define BIOS_keyboard_isr 0xfe987 +#define BIOS_fdisk_io 0xfec59 +#define BIOS_fdisk_isr 0xfef57 +#define BIOS_disk_parms 0xfefc7 +#define BIOS_printer_io 0xfefd2 +#define BIOS_video_io 0xff065 +#define BIOS_video_parms 0xff0a4 +#define BIOS_mem_size 0xff841 +#define BIOS_equipment 0xff84d +#define BIOS_cassette_io 0xff859 +#define BIOS_video_font 0xffa6e +#define BIOS_time_of_day 0xffe6e +#define BIOS_timer_int 0xffea5 +#define BIOS_vector 0xffef3 +#define BIOS_dummy_iret 0xfff53 +#define BIOS_print_screen 0xfff54 +#define BIOS_hard_reset 0xffff0 +#define BIOS_date_stamp 0xffff5 +#define BIOS_hardware_id 0xffffe + +static u_char disk_params[] = { + 0xdf, 2, 0x25, 2, 0x0f, 0x1b, 0xff, 0x54, 0xf6, 0x0f, 8, +}; + +static u_short comm_table[] = { + 1047, 768, 384, 192, 96, 48, 24, 12, +}; + +/* exports */ + +int nfloppies = 0; +int ndisks = 0; +int nserial = 0; +int nparallel = 0; +unsigned long rom_config; + +/* +** BIOS equipment list +*/ +static void +int11(regcontext_t *REGS) +{ + R_AX = + (nfloppies ? 1:0) | /* do we have any floppydisks? */ + (0x2 << 4) | /* 80x25 colour */ + ((nfloppies-1) << 6) | /* how many floppies? */ + (nserial << 9) | /* serial ports? */ + (nparallel << 14); /* parallel ports? */ +} + +/* +** get installed memory +*/ +static void +int12(regcontext_t *REGS) +{ + R_AX = 640; +} + +/* +** assorted oddments +*/ +static void +int15(regcontext_t *REGS) +{ + const struct timespec rqtp={0,1}; + R_FLAGS &= ~PSL_C; + + switch (R_AH) { + case 0x00: /* Get Cassette Status */ + R_AH = 0x86; + R_FLAGS |= PSL_C; /* We don't support a cassette */ + break; + case 0x04: /* Set ABIOS table */ + R_FLAGS |= PSL_C; /* We don't support it */ + break; + case 0x10: /* DesqView */ + switch (R_AL) { + case 0x00: /* Give up CPU time */ + nanosleep(&rqtp, NULL); + break; + case 0x22: /* Get version */ + R_BH = 0x0a; /* Use v2.0 for timeslice support */ + R_BL = 0x01; + break; + } + break; + case 0x4f: /* Keyboard intercept */ + debug(D_TRAPS | 0x15, "BIOS: Keyboard intercept\n"); + /* Don't translate scan code. */ + break; + case 0x88: + get_raw_extmemory_info(REGS); + break; + case 0xc0: /* Get configuration */ + debug(D_TRAPS | 0x15, "BIOS: Get configuration\n"); + PUTVEC(R_ES, R_BX, rom_config); + R_AH = 0; + break; + case 0xc1: /* Get extended BIOS data area */ + R_FLAGS |= PSL_C; + break; + case 0xc2: /* Pointing device */ + debug(D_TRAPS | 0x15, "BIOS: Pointing device?\n"); + R_FLAGS |= PSL_C; + R_AH = 5; /* No pointer */ + break; + default: + unknown_int2(0x15, R_AX, REGS); + break; + } +} + +void +bios_init(void) +{ + int i, j, k; + u_char *jtab; + struct timeval tv; + time_t tv_sec; + struct timezone tz; + struct tm tm; + u_long vec; + + strcpy((char *)BIOS_copyright, + "Copyright (C) 1993 Krystal Technologies/BSDI"); + + *(u_short *)BIOS_reset = 0xffcd; + *(u_short *)BIOS_nmi = 0xffcd; + *(u_short *)BIOS_boot = 0xffcd; + *(u_short *)BIOS_comm_io = 0xffcd; + *(u_short *)BIOS_keyboard_io = 0xffcd; + *(u_short *)BIOS_keyboard_isr = 0xffcd; + *(u_short *)BIOS_fdisk_io = 0xffcd; + *(u_short *)BIOS_fdisk_isr = 0xffcd; + *(u_short *)BIOS_printer_io = 0xffcd; + *(u_short *)BIOS_video_io = 0xffcd; + *(u_short *)BIOS_cassette_io = 0xffcd; + *(u_short *)BIOS_time_of_day = 0xffcd; + *(u_short *)BIOS_timer_int = 0xffcd; + *(u_short *)BIOS_dummy_iret = 0xffcd; + *(u_short *)BIOS_print_screen = 0xffcd; + *(u_short *)BIOS_hard_reset = 0xffcd; + *(u_short *)BIOS_mem_size = 0xffcd; + *(u_short *)BIOS_equipment = 0xffcd; + *(u_short *)BIOS_vector = 0xffcd; + *(u_char *)0xffff2 = 0xcf; /* IRET */ + + memcpy((u_char *)BIOS_disk_parms, disk_params, sizeof(disk_params)); + memcpy((u_char *)BIOS_comm_table, comm_table, sizeof(comm_table)); + + *(u_short *)BIOS_video_font = 0xffcd; + + jtab = (u_char *)BIOS_date_stamp; + *jtab++ = '1'; + *jtab++ = '0'; + *jtab++ = '/'; + *jtab++ = '3'; + *jtab++ = '1'; + *jtab++ = '/'; + *jtab++ = '9'; + *jtab++ = '3'; + + *(u_char *)BIOS_hardware_id = 0xfc; /* Identify as a PC/AT */ + + /* + * Interrupt revectors F000:0000 - F000:03ff + */ + for (i = 0, j = 0, k = 0; i < 0x100; ++i) { + if ((i >= 0x60 && i < 0x68) || + (i >= 0x78 && i < 0xe2)) + continue; + if ((i >= 0x00 && i < 0x2f) || + (i >= 0x30 && i < 0xfe)) { + ivec[i] = 0xF0300000L | (k * 1); + jtab = (u_char *)VECPTR(ivec[i]); + *jtab++ = 0xf4; /* HLT */ + ++k; + } else { + ivec[i] = 0xF0000000L | (j * 6); + jtab = (u_char *)VECPTR(ivec[i]); + *jtab++ = 0xcd; /* INT i */ + *jtab++ = i; + *jtab++ = 0xca; /* RETF 2 */ + *jtab++ = 2; + *jtab++ = 0; + ++j; + } + } + + /* + * Misc variables from F000:0400 - F000:0fff + */ + rom_config = 0xF0000400; + jtab = (u_char *)VECPTR(rom_config); + *jtab++ = 20; /* length of entry */ + *jtab++ = 0; + *jtab++ = *(u_char *)BIOS_hardware_id; + *jtab++ = 0x00; /* Sub model */ + *jtab++ = 0x01; /* Bios Rev Enhanced kbd w/3.5" floppy */ + *jtab++ = 0x20; /* real time clock present */ + *jtab++ = 0; /* Reserved */ + *jtab++ = 0; + *jtab++ = 0; + *jtab++ = 0; + strcpy((char *)jtab, "BSDI BIOS"); + *jtab += 10; + + InDOS = jtab++; + *InDOS = 0; + + mouse_area = jtab; + jtab += 0x10; + + *(u_short *)&BIOSDATA[0x10] = + (1 << 0) | /* Diskette avail for boot */ + (1 << 1) | /* Math co-processor */ + (nmice << 2) | /* No pointing device */ + (2 << 4) | /* Initial video (80 x 25 C) */ + ((nfloppies - 1) << 6) | /* Number of floppies - 1 */ + (nserial << 9) | /* Number of serial devices */ + (nparallel << 14); /* Number of parallel devices */ + + + *(u_short *)&BIOSDATA[0x13] = 640; /* Amount of memory */ + BIOSDATA[0x75] = ndisks; /* number of fixed disks */ + + BIOSDATA[0x8F] = 0; + if (nfloppies >= 1) { + BIOSDATA[0x8F] |= 0x04; + BIOSDATA[0x90] = 0x40; + } + if (nfloppies >= 2) { + BIOSDATA[0x8F] |= 0x40; + BIOSDATA[0x91] = 0x40; + } + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 15:16:10 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id EECE01065672 for ; Wed, 18 Jul 2012 15:16:07 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 15:16:07 +0000 Date: Wed, 18 Jul 2012 15:16:07 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718151607.EECE01065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239546 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 15:16:10 -0000 Author: gmiller Date: Wed Jul 18 15:16:07 2012 New Revision: 239546 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239546 Log: r239588@FreeBSD-dev: root | 2012-07-15 01:23:43 -0500 Implement pthread_lockorder_begin_np(), pthread_lockorder_next_np(), and pthread_lockorder_end_np() to obtain a lock order graph. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/graph.c Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/graph.c Wed Jul 18 12:41:09 2012 (r239545) +++ soc2012/gmiller/locking-head/lib/libwitness/graph.c Wed Jul 18 15:16:07 2012 (r239546) @@ -27,6 +27,15 @@ #include "witness.h" +struct lock_iter { + SLIST_ENTRY(lock_iter) iter_next; + void *lock; +}; + +struct _pthread_lockorder_private { + SLIST_HEAD(lock_iter_head, lock_iter) lock_iter_head; +}; + struct lock_info *root = NULL; static int @@ -79,3 +88,72 @@ return (0); } + +static void +add_graph(struct pthread_lockorder_np *iter_node, struct lock_info *graph_node) +{ + struct lock_iter *iter; + + if (graph_node != NULL) { + iter = malloc(sizeof(struct pthread_lockorder_np)); + iter->lock = graph_node->lock; + SLIST_INSERT_HEAD(&iter_node->_pvt->lock_iter_head, iter, + iter_next); + + add_graph(iter_node, graph_node->sibling); + add_graph(iter_node, graph_node->child); + } +} + +void +pthread_lockorder_begin_np(struct pthread_lockorder_np *node) +{ + /* + The lock isn't needed to prevent races, but it is needed to ensure + that any locks grabbed by malloc() don't get logged. + */ + pthread_mutex_lock(&witness_mtx); + + node->_pvt = malloc(sizeof(struct _pthread_lockorder_private)); + + add_graph(node, root); + + pthread_mutex_unlock(&witness_mtx); +} + +int +pthread_lockorder_next_np(struct pthread_lockorder_np *node) +{ + struct lock_iter *iter; + + iter = SLIST_FIRST(&node->_pvt->lock_iter_head); + if (iter != NULL) { + SLIST_REMOVE_HEAD(&node->_pvt->lock_iter_head, iter_next); + + node->lock = iter->lock; + + free(iter); + + return (1); + } else { + return (0); + } +} + +void +pthread_lockorder_end_np(struct pthread_lockorder_np *node) +{ + struct lock_iter *iter; + + if (node->_pvt != NULL) { + while (!SLIST_EMPTY(&node->_pvt->lock_iter_head)) { + iter = SLIST_FIRST(&node->_pvt->lock_iter_head); + SLIST_REMOVE_HEAD(&node->_pvt->lock_iter_head, + iter_next); + free(iter); + } + + free(node->_pvt); + node->_pvt = NULL; + } +} From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 15:51:00 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D1774106564A for ; Wed, 18 Jul 2012 15:50:57 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 15:50:57 +0000 Date: Wed, 18 Jul 2012 15:50:57 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718155057.D1774106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239547 - soc2012/syuu/bhyve-bios/lib/libbiosemul X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 15:51:00 -0000 Author: syuu Date: Wed Jul 18 15:50:56 2012 New Revision: 239547 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239547 Log: refactoring doscmd program to library. only provides int13h handling for now. Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c - copied, changed from r239530, soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.c soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h Replaced: soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h - copied, changed from r239530, soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h Deleted: soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile.dos soc2012/syuu/bhyve-bios/lib/libbiosemul/ParseBuffer.c soc2012/syuu/bhyve-bios/lib/libbiosemul/README soc2012/syuu/bhyve-bios/lib/libbiosemul/README.booting_dos soc2012/syuu/bhyve-bios/lib/libbiosemul/config.c soc2012/syuu/bhyve-bios/lib/libbiosemul/crt0.c soc2012/syuu/bhyve-bios/lib/libbiosemul/dos.c soc2012/syuu/bhyve-bios/lib/libbiosemul/dos.h soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.1 soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.c soc2012/syuu/bhyve-bios/lib/libbiosemul/ems.c soc2012/syuu/bhyve-bios/lib/libbiosemul/ems.h soc2012/syuu/bhyve-bios/lib/libbiosemul/emsdriv.S soc2012/syuu/bhyve-bios/lib/libbiosemul/emsdriv.sys.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/exe.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int2f.c soc2012/syuu/bhyve-bios/lib/libbiosemul/intff.c soc2012/syuu/bhyve-bios/lib/libbiosemul/net.c soc2012/syuu/bhyve-bios/lib/libbiosemul/redir.S soc2012/syuu/bhyve-bios/lib/libbiosemul/redir.com.uu soc2012/syuu/bhyve-bios/lib/libbiosemul/setver.c soc2012/syuu/bhyve-bios/lib/libbiosemul/xms.c soc2012/syuu/bhyve-bios/lib/libbiosemul/xms.h Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.h soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c soc2012/syuu/bhyve-bios/lib/libbiosemul/cwd.c soc2012/syuu/bhyve-bios/lib/libbiosemul/debug.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int13.c soc2012/syuu/bhyve-bios/lib/libbiosemul/int14.c soc2012/syuu/bhyve-bios/lib/libbiosemul/mem.c soc2012/syuu/bhyve-bios/lib/libbiosemul/mouse.c soc2012/syuu/bhyve-bios/lib/libbiosemul/mouse.h soc2012/syuu/bhyve-bios/lib/libbiosemul/port.c soc2012/syuu/bhyve-bios/lib/libbiosemul/register.h soc2012/syuu/bhyve-bios/lib/libbiosemul/signal.c soc2012/syuu/bhyve-bios/lib/libbiosemul/timer.c soc2012/syuu/bhyve-bios/lib/libbiosemul/trap.c soc2012/syuu/bhyve-bios/lib/libbiosemul/tty.c soc2012/syuu/bhyve-bios/lib/libbiosemul/video.c Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/Makefile Wed Jul 18 15:50:56 2012 (r239547) @@ -2,53 +2,19 @@ # # $FreeBSD: projects/doscmd/Makefile,v 1.39 2004/03/30 17:10:01 des Exp $ -PROG= doscmd +LIB= biosemul WARNS?= 2 -SRCS= AsyncIO.c ParseBuffer.c bios.c callback.c cmos.c config.c cpu.c cwd.c \ - debug.c disktab.c dos.c doscmd.c ems.c emuint.c exe.c i386-pinsn.c \ - int.c int10.c int13.c int14.c int16.c int17.c int1a.c int2f.c intff.c \ - mem.c mouse.c net.c port.c setver.c signal.c timer.c trace.c trap.c \ - tty.c video.c xms.c ${FONTHDRS} +SRCS= biosemul.c \ + bios.c callback.c \ + debug.c i386-pinsn.c \ + int13.c +INCS= biosemul.h CFLAGS+= -I. -DDISASSEMBLER FONTFILES= cp437-8x8.pcf.gz cp437-8x14.pcf.gz cp437-8x16.pcf.gz FONTHDRS= font8x8.h font8x14.h font8x16.h -CLEANFILES= ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com +CLEANFILES= ${FONTFILES} ${FONTHDRS} -PREFIX?= /usr/local -BINDIR?= ${PREFIX}/bin -DATADIR?= ${PREFIX}/share/doscmd -DOCSDIR?= ${PREFIX}/share/doc/doscmd -FONTDIR?= ${DATADIR}/fonts - -X11BASE?= /usr/X11R6 -XINCDIR?= ${X11BASE}/include -XLIBDIR?= ${X11BASE}/lib - -DIRMODE?= 0755 - -.if !defined(NO_X) -CFLAGS+= -I${XINCDIR} -LDFLAGS= -L${XLIBDIR} -LDADD= -lX11 -DPADD= ${XLIBDIR}/libX11.a -.else CFLAGS+= -DNO_X -.endif - -beforeinstall: - ${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${DIRMODE} ${DATADIR} - ${INSTALL} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \ - emsdriv.sys redir.com ${DATADIR} - ${INSTALL} -d -o ${DOCOWN} -g ${DOCGRP} -m ${DIRMODE} ${DOCSDIR} - ${INSTALL} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE} \ - ${.CURDIR}/README* ${.CURDIR}/PROBLEMS ${DOCSDIR} -.if !defined(NO_X) - ${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${DIRMODE} ${FONTDIR} - ${INSTALL} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} \ - ${FONTFILES} ${.CURDIR}/fonts.dir ${FONTDIR} -.endif - -doscmd: ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com cp437-8x8.pcf.gz: cp437-8x8.pcf.gz.uu uudecode ${.CURDIR}/cp437-8x8.pcf.gz.uu @@ -59,9 +25,6 @@ cp437-8x16.pcf.gz: cp437-8x16.pcf.gz.uu uudecode ${.CURDIR}/cp437-8x16.pcf.gz.uu -emsdriv.sys: emsdriv.sys.uu - uudecode ${.CURDIR}/emsdriv.sys.uu - font8x8.h: cp437-8x8.fnt.uu uudecode -p ${.ALLSRC} | \ file2c 'u_int8_t font8x8[] = {' '};' > ${.TARGET} @@ -74,7 +37,4 @@ uudecode -p ${.ALLSRC} | \ file2c 'u_int8_t font8x16[] = {' '};' > ${.TARGET} -redir.com: redir.com.uu - uudecode ${.CURDIR}/redir.com.uu - -.include +.include Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/bios.c Wed Jul 18 15:50:56 2012 (r239547) @@ -80,8 +80,9 @@ int ndisks = 0; int nserial = 0; int nparallel = 0; -unsigned long rom_config; +u_int32_t rom_config; +#if 0 /* ** BIOS equipment list */ @@ -137,9 +138,11 @@ debug(D_TRAPS | 0x15, "BIOS: Keyboard intercept\n"); /* Don't translate scan code. */ break; +#if 0 case 0x88: get_raw_extmemory_info(REGS); break; +#endif case 0xc0: /* Get configuration */ debug(D_TRAPS | 0x15, "BIOS: Get configuration\n"); PUTVEC(R_ES, R_BX, rom_config); @@ -158,17 +161,20 @@ break; } } +#endif void bios_init(void) { int i, j, k; u_char *jtab; +#if 0 struct timeval tv; time_t tv_sec; struct timezone tz; struct tm tm; - u_long vec; + u_int32_t vec; +#endif strcpy((char *)BIOS_copyright, "Copyright (C) 1993 Krystal Technologies/BSDI"); @@ -254,16 +260,21 @@ strcpy((char *)jtab, "BSDI BIOS"); *jtab += 10; +#if 0 InDOS = jtab++; *InDOS = 0; mouse_area = jtab; +#endif jtab += 0x10; *(u_short *)&BIOSDATA[0x10] = (1 << 0) | /* Diskette avail for boot */ (1 << 1) | /* Math co-processor */ +#if 0 (nmice << 2) | /* No pointing device */ +#endif + (0 << 2) | (2 << 4) | /* Initial video (80 x 25 C) */ ((nfloppies - 1) << 6) | /* Number of floppies - 1 */ (nserial << 9) | /* Number of serial devices */ @@ -283,10 +294,11 @@ BIOSDATA[0x91] = 0x40; } +#if 0 gettimeofday(&tv, &tz); tv_sec = tv.tv_sec; tm = *localtime(&tv_sec); - *(u_long *)&BIOSDATA[0x6c] = + *(u_int32_t *)&BIOSDATA[0x6c] = (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10; vec = insert_softint_trampoline(); @@ -319,4 +331,5 @@ vec = insert_softint_trampoline(); ivec[0x1a] = vec; register_callback(vec, int1a, "int 1a"); +#endif } Copied and modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c (from r239530, soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.c) ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.c Wed Jul 18 10:04:39 2012 (r239530, copy source) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.c Wed Jul 18 15:50:56 2012 (r239547) @@ -52,11 +52,11 @@ #include #include +#if 0 #include +#endif #include "doscmd.h" -#include "cwd.h" -#include "trap.h" #include "tty.h" #include "video.h" @@ -69,7 +69,8 @@ int raw_kbd = 0; int timer_disable = 0; struct timeval boot_time; -unsigned long *ivec = (unsigned long *)0; +u_int32_t *ivec = (u_int32_t *)0; +char *lomem_addr = NULL; #ifndef USE_VM86 #define PRB_V86_FORMAT 0x4242 @@ -82,6 +83,7 @@ }; #endif +#if 0 /* local prototypes */ static void setup_boot(regcontext_t *REGS); static int try_boot(int); @@ -103,128 +105,30 @@ char cmdname[256]; /* referenced from dos.c */ static struct vm86_init_args kargs; - -/* lobotomise */ -int -main(int argc, char **argv) -{ -#ifndef USE_VM86 - ucontext_t uc; -#else - struct vm86_struct vm86s; -#define sc vm86s.substr.regs.vmsc #endif - regcontext_t *REGS = (regcontext_t *)&uc.uc_mcontext; - int fd; - int i; - sigset_t sigset; - - sigemptyset(&sigset); - sigaddset(&sigset, SIGIO); - sigaddset(&sigset, SIGALRM); - sigprocmask(SIG_BLOCK, &sigset, 0); - init_ints(); +#define HDISK_CYL 0 +#define HDISK_HEAD 0 +#define HDISK_TRACK 0 +#define HDISK_FILE "diskdev" +/* lobotomise */ +void biosemul_init(char *lomem) +{ + lomem_addr = lomem; debugf = stderr; - /* XXX should only be for tty mode */ - fd = open (_PATH_DEVNULL, O_RDWR); - if (fd != 3) - dup2 (fd, 3); /* stdaux */ - if (fd != 4) - dup2 (fd, 4); /* stdprt */ - if (fd != 3 && fd != 4) - close (fd); - fd = -1; debug_set(0); /* debug any D_TRAPS without intnum */ - - /* perform option argument processing */ - do_args(argc, argv); - argc -= optind; - argv += optind; - - if (vflag && debugf == stderr) { - debugf = stdout; - setbuf (stdout, NULL); - } - - if (!initHMA()) { - return 1; - } - - /* This needs to happen before the executable is loaded */ - mem_init(); - -#ifdef USE_VM86 - memset(&vm86s, 0, sizeof(vm86s)); -#endif - - /* - * With no other arguments we will assume we must boot DOS - */ - if (argc <= 0) - booting = 1; - -#if 1 - /* - * Nominate interrupts to handle here when the kernel is - * performing interrupt handling. - * - * I would like to let INT 2F pass through as well, but I - * need to get my hands on INT 2F:11 to do file redirection. - */ - for (i = 0; i <= 0xff; ++i) { - switch (i) { - case 0x2f: - case 0xff: -#if 1 - kargs.int_map[i >> 3] |= (1 << (i & 7)); -#ifndef USE_VM86 - vconnect_area.passthru[i >> 5] &= ~(1 << (i & 0x1f)); -#else - vm86s.int_byuser[i >> 3] |= (1 << (i & 0x07)); -#endif -#endif - break; - default: -#if 1 - kargs.int_map[i >> 3] &= ~(1 << (i & 7)); -#ifndef USE_VM86 - vconnect_area.passthru[i >> 5] |= (1 << (i & 0x1f)); -#else - vm86s.int_byuser[i >> 3] |= (1 << (i & 0x07)); -#endif -#endif - break; - } - } -#endif - - if (booting) { /* are we booting? */ - setup_boot(REGS); - } else { /* no, load a command */ - setup_command(argc, argv, REGS); - } - - /* install signal handlers */ - setsignal(SIGFPE, sigfpe); /* */ - setsignal(SIGALRM, sigalrm); /* */ - setsignal(SIGILL, sigill); /* */ - setsignal(SIGTRAP, sigtrap); /* */ - setsignal(SIGUSR2, sigtrace); /* */ - setsignal(SIGINFO, sigtrace); /* */ -#ifdef USE_VM86 - setsignal(SIGURG, sigurg); /* entry from NetBSD vm86 */ -#else - setsignal(SIGBUS, sigbus); /* entry from FreeBSD, BSD/OS vm86 */ -#endif +#if 0 /* Call init functions */ if (raw_kbd) console_init(); init_io_port_handlers(); +#endif bios_init(); + init_hdisk(3, HDISK_CYL, HDISK_HEAD, HDISK_TRACK, HDISK_FILE, NULL); +#if 0 cpu_init(); kbd_init(); kbd_bios_init(); @@ -234,69 +138,16 @@ video_bios_init(); disk_bios_init(); cmos_init(); - xms_init(); - dos_init(); - net_init(); - speaker_init(); +#endif +#if 0 timer_init(); /* iomap_init(); */ gettimeofday(&boot_time, 0); - - if (zflag) for (;;) pause(); /* spin if requested */ - - if (raw_kbd) { - /* - * If we have a raw keyboard, and hence, video, - * sneak in a call to the video BIOS to reinit the - * the video display. - */ - u_long video_vector; - static u_char video_trampoline[] = { - 0x60, /* pusha */ - 0xB8, 0x03, 0x00, /* mov ax,00003h */ - 0xCD, 0x10, /* int 010h */ - 0x61, /* popa */ - 0xCF, /* iret */ - }; - - video_vector = insert_generic_trampoline( - sizeof(video_trampoline), video_trampoline); - - PUSH(R_FLAGS, REGS); - PUSH(R_CS, REGS); - PUSH(R_IP, REGS); - PUTVEC(R_CS, R_IP, video_vector); - } - - sigemptyset(&uc.uc_sigmask); - sigaltstack(NULL, &uc.uc_stack); - uc.uc_mcontext.mc_onstack = 0; - - if (tmode) - tracetrap(REGS); - -#ifndef USE_VM86 - R_EAX = (booting || raw_kbd) ? (int)&vconnect_area : -1; - R_EFLAGS |= PSL_VM | PSL_VIF; /* request VM86 mode */ - - i386_vm86(VM86_INIT, &kargs); - - sigreturn(&uc); - debug(D_ALWAYS,"sigreturn failed : %s\n", strerror(errno)); -#else - vm86s.cpu_type = VCPU_586; - i386_vm86(&vm86s); #endif - - /* shouldn't get here */ - if (vflag) dump_regs(REGS); - fatal ("vm86 returned (no kernel support?)\n"); -#undef sc - /* quiet -Wall */ - return 0; } +#if 0 /* ** setup_boot ** @@ -305,27 +156,6 @@ static void setup_boot(regcontext_t *REGS) { - FILE *fp; /* doscmdrc handle */ - int fd; /* don't close this! */ - - fp = find_doscmdrc(); /* get doscmdrc */ - if (!fp) { - fprintf(stderr, "You must have a doscmdrc to boot\n"); - quit(1); - } - - booting = read_config(fp); /* where to boot from? */ - fclose(fp); - if (booting < 0) { /* not specified */ - if ((fd = try_boot(booting = 0)) < 0) /* try A: */ - fd = try_boot(booting = 2); /* try C: */ - } else { - fd = try_boot(booting); /* do like the man says */ - } - - if (fd < 0) - errx(1, "Failed to boot"); - /* initialise registers for entry to bootblock */ R_EFLAGS = 0x20202; R_CS = 0x0000; @@ -797,6 +627,7 @@ fprintf(stderr, "Environment full, ignoring %s\n", value); } } +#endif /* ** replicate a fd up at the top of the range @@ -819,6 +650,7 @@ return(fd); } +#if 0 /* ** Exit-time stuff */ @@ -850,6 +682,7 @@ } exec_return(REGS, val); } +#endif typedef struct COQ { void (*func)(void *); @@ -920,6 +753,7 @@ } #endif +#if 0 /* This is used to map in only the specified port range, instead of all the ports or only certain port ranges. */ @@ -931,3 +765,4 @@ debug(D_PORT,"mapped I/O port: port=%#x count=%d\n", port, count); } +#endif Added: soc2012/syuu/bhyve-bios/lib/libbiosemul/biosemul.h ============================================================================== Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.c Wed Jul 18 15:50:56 2012 (r239547) @@ -13,7 +13,7 @@ struct callback { LIST_ENTRY(callback) chain; - u_long vec; + u_int32_t vec; callback_t func; const char *name; }; @@ -26,7 +26,7 @@ ** Register (func) as a handler for (vec) */ void -register_callback(u_long vec, callback_t func, const char *name) +register_callback(u_int32_t vec, callback_t func, const char *name) { struct cbhead *head; struct callback *elm; @@ -44,7 +44,7 @@ ** Find a handler for (vec) */ callback_t -find_callback(u_long vec) +find_callback(u_int32_t vec) { struct cbhead *head; struct callback *elm; @@ -60,7 +60,7 @@ return ((callback_t)0); } -u_long trampoline_rover = 0xF1000000; +u_int32_t trampoline_rover = 0xF1000000; /* * Interrupts are disabled on an INTn call, so we must restore interrupts @@ -103,11 +103,11 @@ 0xcf, /* IRET */ }; -u_long +u_int32_t insert_generic_trampoline(size_t len, u_char *p) { u_char *q; - u_long where; + u_int32_t where; where = trampoline_rover; q = (u_char *)VECPTR(where); @@ -116,28 +116,28 @@ return (where); } -u_long +u_int32_t insert_softint_trampoline(void) { return (insert_generic_trampoline( sizeof(softint_trampoline), softint_trampoline)); } -u_long +u_int32_t insert_fossil_softint_trampoline(void) { return (insert_generic_trampoline( sizeof(fossil_softint_trampoline), fossil_softint_trampoline)); } -u_long +u_int32_t insert_hardint_trampoline(void) { return (insert_generic_trampoline( sizeof(hardint_trampoline), hardint_trampoline)); } -u_long +u_int32_t insert_null_trampoline(void) { return (insert_generic_trampoline( Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.h ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.h Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/callback.h Wed Jul 18 15:50:56 2012 (r239547) @@ -5,10 +5,10 @@ */ typedef void (*callback_t)(regcontext_t *); -void register_callback(u_long, callback_t, const char *); -callback_t find_callback(u_long); -u_long insert_generic_trampoline(size_t, u_char *); -u_long insert_softint_trampoline(void); -u_long insert_fossil_softint_trampoline(void); -u_long insert_hardint_trampoline(void); -u_long insert_null_trampoline(void); +void register_callback(u_int32_t, callback_t, const char *); +callback_t find_callback(u_int32_t); +u_int32_t insert_generic_trampoline(size_t, u_char *); +u_int32_t insert_softint_trampoline(void); +u_int32_t insert_fossil_softint_trampoline(void); +u_int32_t insert_hardint_trampoline(void); +u_int32_t insert_null_trampoline(void); Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/cpu.c Wed Jul 18 15:50:56 2012 (r239547) @@ -72,7 +72,7 @@ void cpu_init(void) { - u_long vec; + u_int32_t vec; vec = insert_hardint_trampoline(); ivec[0x00] = vec; @@ -121,7 +121,7 @@ emu_instr(regcontext_t *REGS) { int prefix = 1; - u_int8_t *cs = (u_int8_t *)(R_CS << 4); + u_int8_t *cs = (u_int8_t *)(uintptr_t)(R_CS << 4); int ip = R_IP; int dir, i, instrlen; u_int8_t *r8; @@ -400,7 +400,7 @@ if (addr >= 0xa0000 && addr < 0xb0000) return vga_read(addr); else - return *(u_int8_t *)addr; + return *(u_int8_t *)(uintptr_t)addr; } /* Write an 8-bit value to the location specified by 'addr'. If 'addr' lies @@ -411,7 +411,7 @@ if (addr >= 0xa0000 && addr < 0xb0000) vga_write(addr, val); else - *(u_int8_t *)addr = val; + *(u_int8_t *)(uintptr_t)addr = val; return; } @@ -425,7 +425,7 @@ vga_write(addr, (u_int8_t)(val & 0xff)); vga_write(addr + 1, (u_int8_t)((val & 0xff00) >> 8)); } else - *(u_int16_t *)addr = val; + *(u_int16_t *)(uintptr_t)addr = val; return; } Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/cwd.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/cwd.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/cwd.c Wed Jul 18 15:50:56 2012 (r239547) @@ -854,7 +854,7 @@ int error; search_t *search = &dir_search; - debug(D_REDIR, "find_first(%s, %x, %x)\n", path, attr, (int)dta); + debug(D_REDIR, "find_first(%s, %x, %p)\n", path, attr, dta); error = dos_makepath(path, new_path); if (error) Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/debug.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/debug.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/debug.c Wed Jul 18 15:50:56 2012 (r239547) @@ -36,9 +36,12 @@ __FBSDID("$FreeBSD: projects/doscmd/debug.c,v 1.8 2002/03/07 12:52:26 obrien Exp $"); #include +#include #include "doscmd.h" +#if 0 #include "tty.h" +#endif /* debug output goes here */ FILE *debugf; @@ -50,8 +53,8 @@ int vflag = 0; /* interrupts to trace */ -#define BPW (sizeof(u_long) << 3) -u_long debug_ints[256/BPW]; +#define BPW (sizeof(u_int32_t) << 3) +u_int32_t debug_ints[256/BPW]; /* Debug flag manipulation */ void @@ -68,7 +71,7 @@ debug_ints[x/BPW] &= ~(1 << (x & (BPW - 1))); } -u_long +u_int32_t debug_isset(int x) { x &= 0xff; @@ -104,6 +107,7 @@ { va_list args; +#if 0 dead = 1; if (xmode && !quietmode) { @@ -126,12 +130,16 @@ for (;;) tty_pause(); } +#endif va_start (args, fmt); fprintf (debugf, "doscmd: fatal error "); vfprintf (debugf, fmt, args); va_end (args); +#if 0 quit (1); +#endif + exit (1); } /* @@ -148,7 +156,7 @@ debug (D_ALWAYS, "ax=%04x bx=%04x cx=%04x dx=%04x\n", R_AX, R_BX, R_CX, R_DX); debug (D_ALWAYS, "si=%04x di=%04x sp=%04x bp=%04x\n", R_SI, R_DI, R_SP, R_BP); debug (D_ALWAYS, "cs=%04x ss=%04x ds=%04x es=%04x\n", R_CS, R_SS, R_DS, R_ES); - debug (D_ALWAYS, "ip=%x eflags=%lx\n", R_IP, R_EFLAGS); + debug (D_ALWAYS, "ip=%x eflags=%"PRIx32"\n", R_IP, R_EFLAGS); addr = (u_char *)MAKEPTR(R_CS, R_IP); Copied and modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h (from r239530, soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h) ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h Wed Jul 18 10:04:39 2012 (r239530, copy source) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/doscmd.h Wed Jul 18 15:50:56 2012 (r239547) @@ -62,7 +62,6 @@ #endif #include "register.h" -#include "dos.h" #include "callback.h" #define drlton(a) ((islower((a)) ? toupper((a)) : (a)) - 'A') @@ -82,25 +81,23 @@ struct vconnect_area { int int_state; int magic; /* 0x4242 -> PRB format */ - u_long passthru[256>>5]; /* bitmap of INTs to handle */ - u_long magiciret[2]; /* Bounds of "magic" IRET */ + u_int32_t passthru[256>>5]; /* bitmap of INTs to handle */ + u_int32_t magiciret[2]; /* Bounds of "magic" IRET */ }; extern struct vconnect_area vconnect_area; #define IntState vconnect_area.int_state -/* ParseBuffer.c */ -int ParseBuffer(char *, char **, int); - /* bios.c */ -#define BIOSDATA ((u_char *)0x400) -extern unsigned long rom_config; +#define BIOSDATA ((u_char *)(0x400 + lomem_addr)) +extern u_int32_t rom_config; extern int nfloppies; extern int ndisks; extern int nserial; extern int nparallel; -extern volatile int poll_cnt; void bios_init(void); +#if 0 +extern volatile int poll_cnt; void wakeup_poll(void); void reset_poll(void); void sleep_poll(void); @@ -108,11 +105,6 @@ /* cmos.c */ extern time_t delta_clock; -void cmos_init(void); - -/* config.c */ -int read_config(FILE *fp); - /* cpu.c */ void cpu_init(void); int emu_instr(regcontext_t *); @@ -120,6 +112,7 @@ void int01(regcontext_t *); void int03(regcontext_t *); void int0d(regcontext_t *); +#endif /* debug.c */ extern int vflag; @@ -166,10 +159,12 @@ void dump_regs(regcontext_t *); void debug_set(int); void debug_unset(int); -u_long debug_isset(int); +u_int32_t debug_isset(int); +#if 0 /* disktab.c */ int map_type(int, int *, int *, int *); +#endif /* doscmd.c */ extern int capture_fd; @@ -181,7 +176,7 @@ extern int timer_disable; extern char cmdname[]; extern struct timeval boot_time; -extern unsigned long *ivec; +extern u_int32_t *ivec; int _prog(char *); void call_on_quit(void (*)(void *), void *); @@ -192,17 +187,20 @@ void quit(int); int squirrel_fd(int); +#if 0 /* ems.c */ int ems_init(void); void ems_entry(regcontext_t *); /* emuint.c */ extern void emuint(regcontext_t *REGS); +#endif /* i386-pinsn.c */ extern int i386dis(unsigned short, unsigned short, unsigned char *, char *, int); +#if 0 /* int.c */ void init_ints(void); int isinhardint(int); @@ -215,6 +213,7 @@ /* int10.c */ extern void int10(regcontext_t *); +#endif /* int13.c */ extern int init_hdisk(int drive, int cyl, int head, int tracksize, @@ -223,8 +222,11 @@ extern int disk_fd(int drive); extern void make_readonly(int drive); extern int search_floppy(int i); +#if 0 extern void disk_bios_init(void); +#endif +#if 0 /* int14.c */ extern int fossil; @@ -241,35 +243,24 @@ /* int1a.c */ void int1a(regcontext_t *); -/* int2f.c */ -extern void int2f(regcontext_t *); - -/* intff.c */ -extern int int2f_11(regcontext_t *REGS); -extern void intff(regcontext_t *REGS); - /* mem.c */ extern char *dosmem; extern void mem_init(void); extern int mem_alloc(int size, int owner, int *biggestp); -extern int mem_adjust(int addr, int size, int *availp); +extern int mem_adjust(long addr, int size, int *availp); extern void mem_free_owner(int owner); -extern void mem_change_owner(int addr, int owner); +extern void mem_change_owner(long addr, int owner); /* mouse.c */ void int33(regcontext_t *); void mouse_init(void); -/* net.c */ -void net_init(void); - /* port.c */ void define_input_port_handler(int, unsigned char (*)(int)); void define_output_port_handler(int, void (*)(int, unsigned char)); void inb(regcontext_t *, int); unsigned char inb_port(int); -unsigned char inb_speaker(int); unsigned char inb_traceport(int); void init_io_port_handlers(void); void insb(regcontext_t *, int); @@ -277,12 +268,10 @@ void inx(regcontext_t *, int); void outb(regcontext_t *, int); void outb_port(int, unsigned char); -void outb_speaker(int, unsigned char); void outb_traceport(int, unsigned char); void outsb(regcontext_t *, int); void outsx(regcontext_t *, int); void outx(regcontext_t *, int); -void speaker_init(void); /* setver.c */ extern void setver(char *, short); @@ -306,6 +295,7 @@ extern int int2f_43(regcontext_t *REGS); extern int initHMA(void); extern void xms_init(void); -extern u_long xms_maxsize; +extern u_int32_t xms_maxsize; +#endif /****************************** dirty below here *****************************/extern int nmice; Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/int.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/int.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/int.c Wed Jul 18 15:50:56 2012 (r239547) @@ -23,6 +23,8 @@ #include __FBSDID("$FreeBSD: projects/doscmd/int.c,v 1.8 2002/03/30 13:51:40 dwmalone Exp $"); +#include + #include "doscmd.h" struct IRQ { @@ -52,6 +54,7 @@ return Irqs[irql].within; } +#if 0 static void set_vip(void) { @@ -71,10 +74,12 @@ R_EFLAGS &= ~PSL_VIP; } +#endif void resume_interrupt(void) { +#if 0 regcontext_t *REGS = saved_regcontext; int irql; @@ -94,6 +99,7 @@ } } set_vip(); +#endif } void @@ -118,8 +124,9 @@ void hardint(int irql) { +#if 0 regcontext_t *REGS = saved_regcontext; - u_long vec = ivec[8 + irql]; + u_int32_t vec = ivec[8 + irql]; /* ** if we're dead, or there's no vector, or the saved registers @@ -146,7 +153,7 @@ return; } - debug(D_TRAPS | (8 + irql), "Int%02x [%04lx:%04lx]\n", + debug(D_TRAPS | (8 + irql), "Int%02x [%04"PRIx32":%04"PRIx32"]\n", 8 + irql, vec >> 16, vec & 0xffff); Irql = irql; @@ -159,15 +166,18 @@ PUSH(R_IP, REGS); R_EFLAGS &= ~PSL_VIF; /* XXX disable interrupts */ PUTVEC(R_CS, R_IP, vec); +#endif } void unpend(int irql) { +#if 0 if (!Irqs[irql].pending) return; Irqs[irql].pending = 0; set_vip(); +#endif } static unsigned char @@ -204,7 +214,7 @@ softint(int intnum) { regcontext_t *REGS = saved_regcontext; - u_long vec = ivec[intnum]; + u_int32_t vec = ivec[intnum]; /* ** if we're dead, or there's no vector or the saved registers are @@ -220,7 +230,7 @@ if ((vec >> 16) == 0xf000 || *(u_char *)VECPTR(vec) == 0xcf) return; - debug(D_TRAPS | intnum, "INT %02x [%04lx:%04lx]\n", + debug(D_TRAPS | intnum, "INT %02x [%04"PRIx32":%04"PRIx32"]\n", intnum, vec >> 16, vec & 0xffff); PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); Modified: soc2012/syuu/bhyve-bios/lib/libbiosemul/int13.c ============================================================================== --- soc2012/syuu/bhyve-bios/lib/libbiosemul/int13.c Wed Jul 18 15:16:07 2012 (r239546) +++ soc2012/syuu/bhyve-bios/lib/libbiosemul/int13.c Wed Jul 18 15:50:56 2012 (r239547) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 15:53:03 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 93E691065672 for ; Wed, 18 Jul 2012 15:53:01 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 15:53:01 +0000 Date: Wed, 18 Jul 2012 15:53:01 +0000 From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718155301.93E691065672@hub.freebsd.org> Cc: Subject: socsvn commit: r239548 - soc2012/syuu/bhyve-bios/usr.sbin/bhyve X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 15:53:03 -0000 Author: syuu Date: Wed Jul 18 15:53:01 2012 New Revision: 239548 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239548 Log: link libbiosemul to bhyve Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Modified: soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile ============================================================================== --- soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Wed Jul 18 15:50:56 2012 (r239547) +++ soc2012/syuu/bhyve-bios/usr.sbin/bhyve/Makefile Wed Jul 18 15:53:01 2012 (r239548) @@ -12,8 +12,8 @@ NO_MAN= -DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} -LDADD= -lvmmapi -lmd -lpthread +DPADD= ${LIBVMMAPI} ${LIBMD} ${LIBPTHREAD} ${LIBBIOSEMUL} +LDADD= -lvmmapi -lmd -lpthread -lbiosemul WARNS?= 2 From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 16:12:29 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 588901065674 for ; Wed, 18 Jul 2012 16:12:28 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 16:12:28 +0000 Date: Wed, 18 Jul 2012 16:12:28 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718161228.588901065674@hub.freebsd.org> Cc: Subject: socsvn commit: r239552 - soc2012/jhagewood/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 16:12:29 -0000 Author: jhagewood Date: Wed Jul 18 16:12:27 2012 New Revision: 239552 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239552 Log: list of todos Added: soc2012/jhagewood/diff3/TODO Added: soc2012/jhagewood/diff3/TODO ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff3/TODO Wed Jul 18 16:12:27 2012 (r239552) @@ -0,0 +1,6 @@ +--show-all INCOMPLETE +--easy-only INCOMPLETE +--merge INCOMPLETE +--label INCOMPLETE +--strip-trailing-cr COMPLETE +--diff-program INCOMPLETE From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 16:22:25 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 42F711065674 for ; Wed, 18 Jul 2012 16:22:23 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 16:22:23 +0000 Date: Wed, 18 Jul 2012 16:22:23 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718162223.42F711065674@hub.freebsd.org> Cc: Subject: socsvn commit: r239553 - in soc2012/aleek/beaglexm-armv6: . sys/arm/ti X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 16:22:25 -0000 Author: aleek Date: Wed Jul 18 16:22:22 2012 New Revision: 239553 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239553 Log: cleanup Modified: soc2012/aleek/beaglexm-armv6/ (props changed) soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Wed Jul 18 16:12:27 2012 (r239552) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_machdep.c Wed Jul 18 16:22:22 2012 (r239553) @@ -342,10 +342,7 @@ dtbp = (vm_offset_t)NULL; - arm_early_puts( "set_cpufuncs()..." ); set_cpufuncs(); - arm_early_puts( "done!\n" ); - bootverbose = 1; /* @@ -354,7 +351,6 @@ * bootloader must have passed us something else than the metadata * ptr... In this case we want to fall back to some built-in settings. */ - arm_early_puts( "FDT related stuff..." ); mdp = (void *)((uint32_t)mdp & ~PAGE_MASK); /* Parse metadata and fetch parameters */ @@ -404,13 +400,10 @@ // if (fdt_immr_addr(OMAP44XX_L4_PERIPH_VBASE) != 0) // while (1); - arm_early_puts( "done!\n" ); /* Platform-specific initialisation */ pmap_bootstrap_lastaddr = DEVMAP_BOOTSTRAP_MAP_START - ARM_NOCACHE_KVA_SIZE; - arm_early_puts( "pcpu0_init()..." ); pcpu0_init(); - arm_early_puts( "done!\n" ); /* Calculate number of L2 tables needed for mapping vm_page_array */ l2size = (memsize / PAGE_SIZE) * sizeof(struct vm_page); @@ -428,7 +421,6 @@ #define KERNEL_TEXT_BASE (KERNBASE) freemempos = (lastaddr + PAGE_MASK) & ~PAGE_MASK; - arm_early_puts( "allocing pages..." ); /* Define a macro to simplify memory allocation */ #define valloc_pages(var, np) \ alloc_pages((var).pv_va, (np)); \ @@ -477,8 +469,6 @@ init_param1(); valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE); - arm_early_puts( "done!\n" ); - arm_early_puts( "pmapping pages..." ); /* * Now we start construction of the L1 page table @@ -531,29 +521,18 @@ /* Map pmap_devmap[] entries */ if (platform_devmap_init() != 0) while (1); - arm_early_puts( "done!\n" ); - arm_early_puts( "pmap_devmap_bootstrap()..." ); pmap_devmap_bootstrap(l1pagetable, pmap_devmap_bootstrap_table); - arm_early_puts( "done!\n" ); - arm_early_puts( "cpu_domains()..." ); cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT); - arm_early_puts( "done!\n" ); pmap_pa = kernel_l1pt.pv_pa; //arm_early_puts( "Dumping memory layout!\n" ); //dump_l1pagetable( kernel_l1pt.pv_pa ); - arm_early_puts( "setttb()..." ); setttb(kernel_l1pt.pv_pa); - arm_early_puts( "done!\n" ); - arm_early_puts( "cpu_tlb_flushID()..." ); cpu_tlb_flushID(); - arm_early_puts( "done!\n" ); - arm_early_puts( "cpu_domains2()..." ); cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)); - arm_early_puts( "done!\n" ); /* * Only after the SOC registers block is mapped we can perform device @@ -561,9 +540,7 @@ */ OF_interpret("perform-fixup", 0); - arm_early_puts( "cninit()..." ); cninit(); - arm_early_puts( "done!\n" ); physmem = memsize / PAGE_SIZE; @@ -633,7 +610,6 @@ /* Do basic tuning, hz etc */ init_param2(physmem); - debugf("initarm: kdb_init()\n"); kdb_init(); return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP - From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 16:23:51 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 74FC3106564A for ; Wed, 18 Jul 2012 16:23:49 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 16:23:49 +0000 Date: Wed, 18 Jul 2012 16:23:49 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718162349.74FC3106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239554 - in soc2012/jhagewood/diff3: . diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 16:23:51 -0000 Author: jhagewood Date: Wed Jul 18 16:23:49 2012 New Revision: 239554 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239554 Log: Fixed textfile detection in diff3 Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3prog.c Wed Jul 18 16:22:22 2012 (r239553) +++ soc2012/jhagewood/diff3/diff3/diff3prog.c Wed Jul 18 16:23:49 2012 (r239554) @@ -148,7 +148,7 @@ static void change(int, struct range *, int); static void keep(int, struct range *); static void merge(int, int); -static int asciifile(FILE *); +static int istextfile(FILE *); static void prange(struct range *); static void repos(int); static void separate(const char *); @@ -381,7 +381,7 @@ d2 = d23; j = 0; - if ((asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2])) == 0) { + if ((istextfile(fp[0]) && istextfile(fp[1]) && istextfile(fp[2])) == 0) { printf("Binary file detected; comparison failed\n"); exit(EXIT_FAILURE); } @@ -477,24 +477,22 @@ } static int -asciifile(FILE *f) +istextfile(FILE *f) { - wint_t ch = L'\0'; - size_t i; + int i, check_size; + char ch; if (aflag || f == NULL) return (1); rewind(f); - errno = 0; - for (i = 0; i <= BUFSIZ; i++) { - if ((ch = fgetwc(f)) == WEOF) { - if (errno == EILSEQ) - return (0); - break; - } - if (!iswspace(ch) && iswcntrl(ch)) + for (i = 0; i <= MAX_CHECK || ch != EOF; i++) { + ch = fgetc(f); + if (ch == '\0') { + rewind(f); return (0); + } } + rewind(f); return (1); } Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Wed Jul 18 16:22:22 2012 (r239553) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Wed Jul 18 16:23:49 2012 (r239554) @@ -1,6 +1,6 @@ diff -rupN jhagewood/diff3/diff3-orig/Makefile jhagewood/diff3/diff3/Makefile ---- jhagewood/diff3/diff3-orig/Makefile 2012-07-07 19:37:18.000000000 -0400 -+++ jhagewood/diff3/diff3/Makefile 2012-07-07 19:37:18.000000000 -0400 +--- jhagewood/diff3/diff3-orig/Makefile 2012-07-18 16:22:12.000000000 -0400 ++++ jhagewood/diff3/diff3/Makefile 2012-07-18 16:22:12.000000000 -0400 @@ -6,6 +6,6 @@ BINDIR= /usr/libexec beforeinstall: @@ -10,8 +10,8 @@ .include diff -rupN jhagewood/diff3/diff3-orig/diff3prog.c jhagewood/diff3/diff3/diff3prog.c ---- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-07 19:37:18.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3prog.c 2012-07-07 19:37:18.000000000 -0400 +--- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-18 16:22:12.000000000 -0400 ++++ jhagewood/diff3/diff3/diff3prog.c 2012-07-18 16:23:30.267560000 -0400 @@ -64,19 +64,23 @@ * @(#)diff3.c 8.1 (Berkeley) 6/6/93 */ @@ -66,6 +66,14 @@ -void change(int, struct range *, int); -void keep(int, struct range *); -void merge(int, int); +-static int asciifile(FILE *); +-void prange(struct range *); +-void repos(int); +-void separate(const char *); +-__dead void edscript(int); +-__dead void trouble(void); +-void increase(void); +-__dead void usage(void); +static int duplicate(struct range *, struct range *); +static int edit(struct diff *, int, int); +static char *getchange(FILE *); @@ -76,14 +84,7 @@ +static void change(int, struct range *, int); +static void keep(int, struct range *); +static void merge(int, int); - static int asciifile(FILE *); --void prange(struct range *); --void repos(int); --void separate(const char *); --__dead void edscript(int); --__dead void trouble(void); --void increase(void); --__dead void usage(void); ++static int istextfile(FILE *); +static void prange(struct range *); +static void repos(int); +static void separate(const char *); @@ -225,22 +226,25 @@ - if( (asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2]) ) == 0) - { -+ if ((asciifile(fp[0]) && asciifile(fp[1]) && asciifile(fp[2])) == 0) { ++ if ((istextfile(fp[0]) && istextfile(fp[1]) && istextfile(fp[2])) == 0) { printf("Binary file detected; comparison failed\n"); exit(EXIT_FAILURE); } -@@ -466,29 +479,29 @@ merge(int m1, int m2) +@@ -464,31 +477,29 @@ merge(int m1, int m2) + } + static int - asciifile(FILE *f) +-asciifile(FILE *f) ++istextfile(FILE *f) { - wint_t ch = L'\0'; - size_t i; -- ++ int i, check_size; ++ char ch; + - if (aflag || f == NULL) - return (1); -+ wint_t ch = L'\0'; -+ size_t i; - +- - rewind(f); - errno = 0; - for (i = 0; i <= BUFSIZ; i++) { @@ -256,16 +260,14 @@ + if (aflag || f == NULL) + return (1); + rewind(f); -+ errno = 0; -+ for (i = 0; i <= BUFSIZ; i++) { -+ if ((ch = fgetwc(f)) == WEOF) { -+ if (errno == EILSEQ) -+ return (0); -+ break; -+ } -+ if (!iswspace(ch) && iswcntrl(ch)) ++ for (i = 0; i <= MAX_CHECK || ch != EOF; i++) { ++ ch = fgetc(f); ++ if (ch == '\0') { ++ rewind(f); + return (0); ++ } + } ++ rewind(f); + return (1); } @@ -277,7 +279,7 @@ printf("====%s\n", s); } -@@ -497,9 +510,10 @@ separate(const char *s) +@@ -497,9 +508,10 @@ separate(const char *s) * It is to be printed only if it does not duplicate something to be * printed later. */ @@ -289,7 +291,7 @@ printf("%d:", i); last[i] = rold->to; prange(rold); -@@ -510,12 +524,14 @@ change(int i, struct range *rold, int du +@@ -510,12 +522,14 @@ change(int i, struct range *rold, int du (void)skip(i, rold->to, " "); } @@ -307,7 +309,7 @@ if (rold->to <= rold->from) printf("%da\n", rold->from - 1); else { -@@ -531,7 +547,7 @@ prange(struct range *rold) +@@ -531,7 +545,7 @@ prange(struct range *rold) * and an artificial dummy difference (trange) must be ginned up to * correspond to the change reported in the other file. */ @@ -316,7 +318,7 @@ keep(int i, struct range *rnew) { int delta; -@@ -547,7 +563,7 @@ keep(int i, struct range *rnew) +@@ -547,7 +561,7 @@ keep(int i, struct range *rnew) * skip to just before line number from in file "i". If "pr" is non-NULL, * print all skipped stuff with string pr as a prefix. */ @@ -325,7 +327,7 @@ skip(int i, int from, char *pr) { size_t j, n; -@@ -558,7 +574,6 @@ skip(int i, int from, char *pr) +@@ -558,7 +572,6 @@ skip(int i, int from, char *pr) trouble(); if (pr != NULL) printf("%s%s", Tflag == 1? "\t" : pr, line); @@ -333,7 +335,7 @@ cline[i]++; } return ((int) n); -@@ -568,10 +583,10 @@ skip(int i, int from, char *pr) +@@ -568,10 +581,10 @@ skip(int i, int from, char *pr) * Return 1 or 0 according as the old range (in file 1) contains exactly * the same data as the new range (in file 2). */ @@ -346,7 +348,7 @@ int nchar; int nline; -@@ -597,7 +612,7 @@ duplicate(struct range *r1, struct range +@@ -597,7 +610,7 @@ duplicate(struct range *r1, struct range return (1); } @@ -355,7 +357,7 @@ repos(int nchar) { int i; -@@ -606,18 +621,43 @@ repos(int nchar) +@@ -606,18 +619,43 @@ repos(int nchar) (void)fseek(fp[i], (long)-nchar, SEEK_CUR); } @@ -401,7 +403,7 @@ if (((dup + 1) & eflag) == 0) return (j); j++; -@@ -632,10 +672,10 @@ edit(struct diff *diff, int dup, int j) +@@ -632,10 +670,10 @@ edit(struct diff *diff, int dup, int j) } /* regurgitate */ @@ -414,7 +416,7 @@ char block[BUFSIZ]; for (n = n; n > 0; n--) { -@@ -657,14 +697,13 @@ edscript(int n) +@@ -657,14 +695,13 @@ edscript(int n) printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark); } } @@ -431,7 +433,7 @@ increase(void) { struct diff *p; -@@ -698,13 +737,29 @@ increase(void) +@@ -698,13 +735,29 @@ increase(void) szchanges = newsz; } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 16:26:09 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7E839106564A for ; Wed, 18 Jul 2012 16:26:07 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 16:26:07 +0000 Date: Wed, 18 Jul 2012 16:26:07 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718162607.7E839106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239555 - soc2012/jhagewood/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 16:26:09 -0000 Author: jhagewood Date: Wed Jul 18 16:26:07 2012 New Revision: 239555 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239555 Log: updated TODO Modified: soc2012/jhagewood/diff3/TODO Modified: soc2012/jhagewood/diff3/TODO ============================================================================== --- soc2012/jhagewood/diff3/TODO Wed Jul 18 16:23:49 2012 (r239554) +++ soc2012/jhagewood/diff3/TODO Wed Jul 18 16:26:07 2012 (r239555) @@ -4,3 +4,4 @@ --label INCOMPLETE --strip-trailing-cr COMPLETE --diff-program INCOMPLETE +Fixed binary detection COMPLETE From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 17:06:51 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 1052F1065670 for ; Wed, 18 Jul 2012 17:06:49 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 17:06:49 +0000 Date: Wed, 18 Jul 2012 17:06:49 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718170649.1052F1065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239557 - soc2012/gpf/pefs_kmod/sbin/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 17:06:51 -0000 Author: gpf Date: Wed Jul 18 17:06:48 2012 New Revision: 239557 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239557 Log: require that all files that need integrity checking should have schg flag set. provide an option to set the flags during `addchecksum` action, if they are not already set. ([-f] option) `verify` action checks for this as well. same checks should be performed in kernel land when a vnode is looked up in our index tables. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Wed Jul 18 16:13:03 2012 (r239556) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Wed Jul 18 17:06:48 2012 (r239557) @@ -57,7 +57,7 @@ #include "pefs_ctl.h" -//#define PEFS_INTEGRITY_DEBUG +#define PEFS_INTEGRITY_DEBUG #if defined (PEFS_INTEGRITY_DEBUG) #define dprintf(a) printf a #else @@ -188,10 +188,14 @@ static void pefs_close_file(struct file_header *fhp) { - if (fhp->fd >= 0) + if (fhp->fd >= 0) { close(fhp->fd); - if (fhp->pfd >= 0) + fhp->fd = -1; + } + if (fhp->pfd >= 0) { close(fhp->pfd); + fhp->pfd = -1; + } } static int @@ -476,7 +480,7 @@ { struct checksum *csp, *tcsp; if (fhp != NULL) { - /* XXXgpf: [TODO] should probably call pefs_close_file() at this point */ + pefs_close_file(fhp); TAILQ_FOREACH_SAFE(csp, &(fhp->checksums), checksum_entries, tcsp) { TAILQ_REMOVE(&(fhp->checksums), csp, checksum_entries); if (csp->hash != NULL) @@ -896,7 +900,7 @@ struct statfs this_fs; char *dirnamep, *namep; size_t target_path_size; - int nchars; + int error, nchars; /* retrieve dirpath & filename */ strlcpy(dirbuf, fhp->path, sizeof(dirbuf)); @@ -917,7 +921,7 @@ } strlcpy(fhp->filename, namep, sizeof(fhp->filename)); - dprintf(("path = %s!\ndirname = %s!\nbasename =%s!\n", fhp->path, + dprintf(("path = %s!\ndirname = %s!\nbasename = %s!\n", fhp->path, fhp->dirpath, fhp->filename)); if (lstat(fhp->path, &sb) != 0) { @@ -925,6 +929,13 @@ return (PEFS_ERR_SYS); } + if ((sb.st_flags & SF_IMMUTABLE) == 0 && + (flags & PEFS_SETIMMUTABLE) == 0 && + (flags & PEFS_VERIFY) == 0) { + pefs_warn("file %s does not have schg flag", fhp->path); + return (PEFS_ERR_SYS); + } + if (S_ISLNK(sb.st_mode) != 0) { fhp->pfd = open(fhp->dirpath, O_RDONLY); if (fhp->pfd < 0) { @@ -932,6 +943,16 @@ return (PEFS_ERR_IO); } + if ((sb.st_flags & SF_IMMUTABLE) == 0 && + (flags & PEFS_SETIMMUTABLE) != 0) { + dprintf(("setting immutable flag %s\n", fhp->path)); + error = lchflags(fhp->path, SF_IMMUTABLE); + if (error != 0) { + warn("cannot set schg flag to file %s", fhp->path); + return (PEFS_ERR_SYS); + } + } + nchars = readlink(fhp->path, sbuf, sizeof(sbuf)); if (nchars == -1) { warn("readlink failed: %s", fhp->path); @@ -1007,6 +1028,16 @@ return (PEFS_ERR_INVALID); } + if ((sb.st_flags & SF_IMMUTABLE) == 0 && + (flags & PEFS_SETIMMUTABLE) != 0) { + dprintf(("setting immutable flag %s\n", fhp->path)); + error = fchflags(fhp->fd, SF_IMMUTABLE); + if (error != 0) { + warn("cannot set schg flag to file %s", fhp->path); + return (PEFS_ERR_SYS); + } + } + if ((flags & PEFS_UNMOUNTED) == 0) { if (fstatfs(fhp->fd, &this_fs) == -1) { pefs_warn("statfs failed: %s: %s", fhp->path, strerror(errno)); @@ -1089,7 +1120,7 @@ */ static int pefs_create_in_memory_db(FILE *fpin, const EVP_MD *md, uint8_t hash_len, - struct cuckoo_hash_table *chtp, char *fsroot) + struct cuckoo_hash_table *chtp, char *fsroot, int flags) { struct statfs fs; struct file_header_head fh_head; @@ -1107,23 +1138,20 @@ TAILQ_INIT(&fh_head); RB_INIT(&hlc_head); while((fhp = pefs_next_file(fpin, &error, &nfiles)) != NULL) { - error = pefs_open_semantic_checks(fhp, &fs, &hlc_head, 0); + error = pefs_open_semantic_checks(fhp, &fs, &hlc_head, flags); if (error != 0) { - pefs_close_file(fhp); pefs_free_file_header(fhp); return (error); } - error = pefs_get_file_id(fhp, 0); + error = pefs_get_file_id(fhp, flags); if (error != 0) { - pefs_close_file(fhp); pefs_free_file_header(fhp); return (error); } - error = pefs_compute_file_checksums(fhp, md, hash_len, 0); + error = pefs_compute_file_checksums(fhp, md, hash_len, flags); if (error != 0) { - pefs_close_file(fhp); pefs_free_file_header(fhp); return (error); } @@ -1440,7 +1468,7 @@ */ int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, - const char *algo) + const char *algo, int flags) { struct cuckoo_hash_table checksum_hash_table; struct checksum_file_header cfh; @@ -1464,7 +1492,7 @@ goto out; error = pefs_create_in_memory_db(fpin, md, hash_len, - &checksum_hash_table, fsroot); + &checksum_hash_table, fsroot, flags); if (error != 0) goto out; @@ -1819,14 +1847,12 @@ error = pefs_get_file_id(fhp, flags); if (error != 0) { closedir(dirp); - pefs_close_file(fhp); pefs_free_file_header(fhp); return (error); } indexfhp = pefs_cuckoo_lookup(chtp, fhp); if (indexfhp == NULL) { - pefs_close_file(fhp); pefs_free_file_header(fhp); break; } @@ -1835,17 +1861,21 @@ error = pefs_compute_file_checksums(fhp, md, hash_len, flags); if (error != 0) { closedir(dirp); - pefs_close_file(fhp); pefs_free_file_header(fhp); return (error); } - /* get sb for pefs_rb_insert */ error = lstat(fhp->path, &sb); if (error != 0) { warn("cannot stat file %s", fhp->path); closedir(dirp); - pefs_close_file(fhp); + pefs_free_file_header(fhp); + return (PEFS_ERR_SYS); + } + + if ((sb.st_flags & SF_IMMUTABLE) == 0) { + pefs_warn("file %s does not have schg flag", fhp->path); + closedir(dirp); pefs_free_file_header(fhp); return (PEFS_ERR_SYS); } @@ -1853,7 +1883,6 @@ error = pefs_rb_insert(hlc_headp, fhp, &sb); if (error != 0) { closedir(dirp); - pefs_close_file(fhp); pefs_free_file_header(fhp); return (error); } @@ -1994,6 +2023,7 @@ pefs_free_hash_table(&cht); pefs_rb_free(&hlc_head); pefs_free_file_header_tail(&fh_head); + return (error); } Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Wed Jul 18 16:13:03 2012 (r239556) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Wed Jul 18 17:06:48 2012 (r239557) @@ -1004,7 +1004,7 @@ /* * XXXgpf: Instead of a man page entry: * - * pefs addchecksum [-a algo] [-i inputfile] [-p path] filesystem + * pefs addchecksum [-f] [-a algo] [-i inputfile] [-p path] filesystem * * $command creates .pefs.checksum db file for filesystem. * This file will contain all checksums necessary to check integrity @@ -1021,6 +1021,9 @@ * .pefs.checksum is created under $PWD. path should be a directory, * outside of target pefs filesystem. * + * -f symbolizes that $command should set immutable flag schg for every file + * in inputlist if the flag is not already set. + * * When $command is run, filesystem must be mounted with pefs, and * user must have supplied the necessary key(s). * @@ -1034,16 +1037,17 @@ char csm_path[MAXPATHLEN]; struct stat sb; FILE *fpin; - int error, i, j; + int error, flags, i, j; const char *algo; + flags = 0; fpin = stdin; /* by default use sha256 */ algo = supported_digests[0]; /* by default create checksum file under $PWD */ snprintf(csm_path, sizeof(csm_path), "./%s", PEFS_FILE_CHECKSUM); - while ((i = getopt(argc, argv, "a:i:p:")) != -1) + while ((i = getopt(argc, argv, "fa:i:p:")) != -1) switch(i) { case 'a': for (j=0; j < PEFS_SUPPORTED_DIGESTS; j++) @@ -1058,6 +1062,9 @@ goto out; } break; + case 'f': + flags|= PEFS_SETIMMUTABLE; + break; case 'i': fpin = fopen(optarg, "r"); if (fpin == NULL) { @@ -1093,7 +1100,7 @@ initfsroot(argc, argv, 0, fsroot, sizeof(fsroot)); - error = pefs_create_checksum_file(fpin, fsroot, csm_path, algo); + error = pefs_create_checksum_file(fpin, fsroot, csm_path, algo, flags); out: if (fpin != NULL) @@ -1133,7 +1140,7 @@ char fsroot[MAXPATHLEN]; int error, fdin, flags, i; - flags = 0; + flags = PEFS_VERIFY; while ((i = getopt(argc, argv, "nu")) != -1) switch(i) { case 'n': @@ -1230,7 +1237,7 @@ " pefs randomchain [-fv] [-n min] [-N max] filesystem\n" " pefs showchains [-fp] [-i iterations] [-k keyfile] filesystem\n" " pefs showalgs\n" -" pefs addchecksum [-a algo] [-i inputfile] [-p checksumpath] filesystem\n" +" pefs addchecksum [-f] [-a algo] [-i inputfile] [-p checksumpath] filesystem\n" " pefs verify [-n/u] [checksumpath filesystem]\n" ); exit(PEFS_ERR_USAGE); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Wed Jul 18 16:13:03 2012 (r239556) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Wed Jul 18 17:06:48 2012 (r239557) @@ -46,6 +46,8 @@ #define PEFS_NOKEY 0x0001 #define PEFS_UNMOUNTED 0x0002 +#define PEFS_SETIMMUTABLE 0x0004 +#define PEFS_VERIFY 0x0010 #define PEFS_KEYCONF_ALG_IND 0 #define PEFS_KEYCONF_ITERATIONS_IND 1 @@ -99,7 +101,7 @@ const struct pefs_xkey *xk_parent); uintmax_t pefs_keyid_as_int(char *keyid); int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, - const char *algo); + const char *algo, int flags); int pefs_verify_checksum(int fdin, char *fsroot, int flags); int pefs_name_pton(char const *src, size_t srclen, u_char *target, From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 17:34:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C062B106564A for ; Wed, 18 Jul 2012 17:34:04 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 17:34:04 +0000 Date: Wed, 18 Jul 2012 17:34:04 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718173404.C062B106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239558 - in soc2012/tzabal/server-side: akcrs-release/9.0.0/usr.sbin/crashreportd akcrs-setup X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 17:34:07 -0000 Author: tzabal Date: Wed Jul 18 17:34:04 2012 New Revision: 239558 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239558 Log: Add the directory server-side/akcrs-setup populated with the database.sql and setup files. The file database.sql creates the database schema of the database that will store the crash reports. The file setup is an installation guide that describes the steps that need to be done in the server machine before hosting the AKCRS. Added: soc2012/tzabal/server-side/akcrs-setup/ soc2012/tzabal/server-side/akcrs-setup/database.sql soc2012/tzabal/server-side/akcrs-setup/setup Modified: soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Modified: soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py ============================================================================== --- soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Wed Jul 18 17:06:48 2012 (r239557) +++ soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Wed Jul 18 17:34:04 2012 (r239558) @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/usr/local/bin/python -tt import os import re @@ -111,8 +111,7 @@ def create_pid_file(): pid = os.getpid() - pid_file = '/home/tzabal/Desktop/crashreportd.pid' - #pid_file = '/var/run/crashreportd.pid' + pid_file = '/var/run/crashreportd.pid' try: file_obj = open(pid_file, 'w') file_obj.write(str(pid)) @@ -125,18 +124,22 @@ return True -# The infinite loop of the daemon -interval = 10 -crashreports_dir = '/home/tzabal/Desktop/crashreports' -#crashreports_dir = '/var/spool/crashreports' -extraction_dir = '/tmp/crashreports' -counter = 1 -create_pid_file() -while True: - print "== Pass:", counter, "==" - dirlist = os.listdir(crashreports_dir) - for filename in dirlist: - print "Report:", filename - check_report(filename) - counter += 1 - time.sleep(interval) \ No newline at end of file +def main(): + # The infinite loop of the daemon + interval = 10 + crashreports_dir = '/var/spool/crashreports' + extraction_dir = '/tmp/crashreports' + counter = 1 + create_pid_file() + while True: + print "== Pass: " + counter + " ==" + dirlist = os.listdir(crashreports_dir) + for filename in dirlist: + print "Report: " + filename + check_report(filename) + counter += 1 + time.sleep(interval) + + +if __name__ == '__main__': + main() \ No newline at end of file Added: soc2012/tzabal/server-side/akcrs-setup/database.sql ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-setup/database.sql Wed Jul 18 17:34:04 2012 (r239558) @@ -0,0 +1,69 @@ +/* + * Create the database schema of the AKCRS system + * for the PostgreSQL DBMS + */ + +--DROP TABLE Submitters; +--DROP TABLE Bugs; +--DROP TABLE Reports; + + +CREATE TABLE Submitters +( + id integer, + email varchar(254) NOT NULL, + passwd varchar(12) NOT NULL, + + PRIMARY KEY (id) +); + + +CREATE TABLE Bugs +( + id integer, + state varchar(10) NOT NULL, + reported integer NOT NULL, + + PRIMARY KEY (id) +); + + +CREATE TABLE Reports +( + id integer, + bug_id integer NOT NULL, + submitter_id integer NOT NULL, + received_date date DEFAULT CURRENT_DATE, + crash_type text, + crash_date date, + hostname text, + ostype text, + osrelease text, + version text, + machine text, + ps_axl text, + vmstat_s text, + vmstat_m text, + vmstat_z text, + vmstat_i text, + pstat_T text, + pstat_s text, + iostat text, + ipcs_a text, + ipcs_T text, + nfsstat text, + netstat_s text, + netstat_m text, + netstat_id text, + netstat_anr text, + netstat_anA text, + netstat_aL text, + fstat text, + dmesg text, + kernelconfig text, + ddbcapturebuffer text, + + PRIMARY KEY (id), + FOREIGN KEY (bug_id) REFERENCES Bugs(id), + FOREIGN KEY (submitter_id) REFERENCES Reports(id) +); Added: soc2012/tzabal/server-side/akcrs-setup/setup ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/server-side/akcrs-setup/setup Wed Jul 18 17:34:04 2012 (r239558) @@ -0,0 +1,81 @@ +############################################################################### +## An installation guide that should be followed by the System Administrator ## +## of the machine that will host the Server side part of the AKCRS project. ## +## ## +## After the completion of this guide, the source code of the server side ## +## part of the project could be downloaded in /usr/src and build the system. ## +############################################################################### + + +########################################################### +# Part 1. FreeBSD +########################################################### + +# Find a machine that will host the server side part of the project. +# The machine's environment should be clean, dry, secure and preferably with low temperature. + +# Install the FreeBSD 9.0-RELEASE amd64 version. +# Login to the fresh system as root. + +# Add a new user named reporter (accept the default answers) +adduser + +# Create the directory where crash reports will arrive +mkdir /var/spool/crashreports + +# Give ownership of the directory to reporter +chown reporter:reporter /var/spool/crashreports + +# Make sure that the OpenSSH daemon is enabled +cat /etc/rc.conf | grep 'sshd_enable="YES"' + +# Create a backup of the original sshd_config file +cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig + +# For protocol version 2, use the HostKey of the ECDSA algorithm (default, but declare it explicitly) +sed -E -i '' 's/^#(HostKey.*ecdsa_key)/\1/' /etc/ssh/sshd_config + +# Distribute the SSH Host public key of the ECDSA algorithm with the crash reporter program (single line) +cat /etc/ssh/ssh_host_ecdsa_key.pub + +# Login as reporter +su reporter + +# Generate the SSH User pair of keys using the ECDSA algorithm without passphrase +ssh-keygen -t ecdsa + +# Copy the generated SSH User public key into the authorized_keys file +cat ~/.ssh/id_ecdsa.pub >> ~/.ssh/authorized_keys + +# Distribute the SSH User private key with the crash reporter program (multiple lines) +cat ~/.ssh/id_ecdsa + +# Logout (back to root) +exit + +# Restart the ssh daemon to load the new configurations +/etc/rc.d/sshd restart + +# Install the FreeBSD Ports Collection +portsnap fetch extract update + + +########################################################### +# Part 2. Apache +########################################################### + + + +########################################################### +# Part 3. PostgreSQL +########################################################### + + + +########################################################### +# Part 4. Python +########################################################### + +# Install Python (default: python 2.7.3) +cd /usr/ports/lang/python +make -DBATCH install clean \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Wed Jul 18 18:26:13 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 824DC106566C for ; Wed, 18 Jul 2012 18:26:11 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 18 Jul 2012 18:26:11 +0000 Date: Wed, 18 Jul 2012 18:26:11 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120718182611.824DC106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239559 - in soc2012/gpf/pefs_kmod: sbin/pefs sys/fs/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2012 18:26:13 -0000 Author: gpf Date: Wed Jul 18 18:26:10 2012 New Revision: 239559 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239559 Log: - when a vnode is looked up for the first time in our index tables, check that schg flag is turned on in case the file needs integrity checking. deny reading access to the file if it's not. We *could* also check during setattr if the user is trying to set schg for a file, in which case we could see if there's an nameid conflict with entries in our index tables. Not sure if it's worth it though. note about previous commit: pefs_free_file_header() now closes all file descriptors associated with a file header before freeing it. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Wed Jul 18 17:34:04 2012 (r239558) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Wed Jul 18 18:26:10 2012 (r239559) @@ -57,7 +57,7 @@ #include "pefs_ctl.h" -#define PEFS_INTEGRITY_DEBUG +//#define PEFS_INTEGRITY_DEBUG #if defined (PEFS_INTEGRITY_DEBUG) #define dprintf(a) printf a #else Modified: soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Wed Jul 18 17:34:04 2012 (r239558) +++ soc2012/gpf/pefs_kmod/sys/fs/pefs/pefs_checksum.c Wed Jul 18 18:26:10 2012 (r239559) @@ -239,8 +239,10 @@ pefs_checksum_lookup(char *enc_name, size_t enc_name_len, struct componentname *cnp, struct vnode *vp) { + struct vattr va; struct pefs_checksum_index_entry pcie; struct pefs_node *pn = VP_TO_PN(vp); + struct ucred *cred = vp->v_mount->mnt_cred; char *buf; size_t buf_len; int error, r; @@ -278,6 +280,21 @@ goto not_found; } } + /* + * Check to see if schg flag is set, if not mark the vnode so that all + * read access is denied. + */ + error = VOP_GETATTR(vp, &va, cred); + if (error != 0) { + dprintf(("unable to retrieve attributes of %llu\n", pcie.pcie_file_id)); + pn->pn_flags|= PN_WRONG_CHECKSUM; + } + else { + if ((va.va_flags & SF_IMMUTABLE) == 0) { + dprintf(("schg not set for %llu\n", pcie.pcie_file_id)); + pn->pn_flags|= PN_WRONG_CHECKSUM; + } + } free(buf, M_TEMP); return; @@ -389,6 +406,10 @@ dprintf(("integrity checking!\noffset %llu\n", offset)); + /* + * XXXgpf: For the moment, this flag's only purpose is to deny read access + * to the file. Should it do more? + */ if ((pn->pn_flags & PN_WRONG_CHECKSUM) != 0) return (EAUTH); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 19 17:30:46 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 65A4D1065673 for ; Thu, 19 Jul 2012 17:30:44 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 19 Jul 2012 17:30:44 +0000 Date: Thu, 19 Jul 2012 17:30:44 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120719173044.65A4D1065673@hub.freebsd.org> Cc: Subject: socsvn commit: r239582 - in soc2012/jhagewood/diff3: . diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 17:30:46 -0000 Author: jhagewood Date: Thu Jul 19 17:30:43 2012 New Revision: 239582 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239582 Log: Fixed file open bug in diff3 Modified: soc2012/jhagewood/diff3/TODO soc2012/jhagewood/diff3/diff3/diff3prog.c soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/TODO ============================================================================== --- soc2012/jhagewood/diff3/TODO Thu Jul 19 15:36:36 2012 (r239581) +++ soc2012/jhagewood/diff3/TODO Thu Jul 19 17:30:43 2012 (r239582) @@ -5,3 +5,9 @@ --strip-trailing-cr COMPLETE --diff-program INCOMPLETE Fixed binary detection COMPLETE +Test script COMPLETE + +- BUG: Goes to usage when argc < 5 FIX: argc < 3 +- BUG: Would not open files correctly FIX: change which argv[] is passed +to fopen() +- BUG: Seg faults. Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3prog.c Thu Jul 19 15:36:36 2012 (r239581) +++ soc2012/jhagewood/diff3/diff3/diff3prog.c Thu Jul 19 17:30:43 2012 (r239582) @@ -165,6 +165,8 @@ DIFFPROG_OPT, }; +#define MAX_CHECK 768 /* 3 kilobytes of chars. */ + #define OPTIONS "3aAeEiL:mTvxX" static struct option longopts[] = { { "ed", no_argument, NULL, 'e' }, @@ -189,7 +191,7 @@ int main(int argc, char **argv) { - int ch, i, m, n; + int ch, i, j, m, n; eflag = 0; oflag = 0; @@ -245,8 +247,7 @@ } argc -= optind; argv += optind; - /* XXX - argc usage seems wrong here */ - if (argc < 5) + if (argc < 3) usage(); if (oflag) { (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", @@ -262,11 +263,13 @@ increase(); m = readin(argv[0], &d13); n = readin(argv[1], &d23); - for (i = 0; i <= 2; i++) { - if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) - err(EXIT_FAILURE, "can't open %s", argv[i + 2]); + j = 0; + for (i = 2; i >= 0; i++) { + if ((fp[j] = fopen(argv[(argc-1)-i], "r")) == NULL) + err(EXIT_FAILURE, "Can't open %s", argv[(argc-1)-i]); if (strip_cr) - remove_cr(fp[i]); + remove_cr(fp[j]); + j++; } merge(m, n); exit(EXIT_SUCCESS); Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Thu Jul 19 15:36:36 2012 (r239581) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Thu Jul 19 17:30:43 2012 (r239582) @@ -11,7 +11,7 @@ .include diff -rupN jhagewood/diff3/diff3-orig/diff3prog.c jhagewood/diff3/diff3/diff3prog.c --- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-18 16:22:12.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3prog.c 2012-07-18 16:23:30.267560000 -0400 ++++ jhagewood/diff3/diff3/diff3prog.c 2012-07-19 17:13:54.000000000 -0400 @@ -64,19 +64,23 @@ * @(#)diff3.c 8.1 (Berkeley) 6/6/93 */ @@ -52,7 +52,7 @@ * is stored in last[1-3]; */ int last[4]; -@@ -134,29 +138,31 @@ int strip_cr; +@@ -134,31 +138,35 @@ int strip_cr; int debug = 0; char f1mark[40], f2mark[40], f3mark[40]; /* markers for -E and -X */ @@ -102,8 +102,12 @@ + DIFFPROG_OPT, }; ++#define MAX_CHECK 768 /* 3 kilobytes of chars. */ ++ #define OPTIONS "3aAeEiL:mTvxX" -@@ -166,19 +172,20 @@ static struct option longopts[] = { + static struct option longopts[] = { + { "ed", no_argument, NULL, 'e' }, +@@ -166,23 +174,24 @@ static struct option longopts[] = { { "overlap-only", no_argument, NULL, 'x' }, { "initial-tab", no_argument, NULL, 'T' }, { "text", no_argument, NULL, 'a' }, @@ -129,7 +133,12 @@ int main(int argc, char **argv) { -@@ -216,12 +223,18 @@ main(int argc, char **argv) +- int ch, i, m, n; ++ int ch, i, j, m, n; + + eflag = 0; + oflag = 0; +@@ -216,12 +225,18 @@ main(int argc, char **argv) case 'X': oflag = eflag = 1; break; @@ -148,15 +157,19 @@ case STRIPCR_OPT: strip_cr = 1; break; -@@ -235,7 +248,6 @@ main(int argc, char **argv) - /* XXX - argc usage seems wrong here */ - if (argc < 5) +@@ -232,10 +247,8 @@ main(int argc, char **argv) + } + argc -= optind; + argv += optind; +- /* XXX - argc usage seems wrong here */ +- if (argc < 5) ++ if (argc < 3) usage(); - if (oflag) { (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", labels[0] != NULL ? labels[0] : -@@ -247,13 +259,14 @@ main(int argc, char **argv) +@@ -247,13 +260,16 @@ main(int argc, char **argv) labels[2] != NULL ? labels[2] : argc >= 7 ? argv[6] : argv[4]); } @@ -164,15 +177,20 @@ increase(); m = readin(argv[0], &d13); n = readin(argv[1], &d23); - for (i = 0; i <= 2; i++) { - if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) - err(EXIT_FAILURE, "can't open %s", argv[i + 2]); +- for (i = 0; i <= 2; i++) { +- if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) +- err(EXIT_FAILURE, "can't open %s", argv[i + 2]); ++ j = 0; ++ for (i = 2; i >= 0; i++) { ++ if ((fp[j] = fopen(argv[(argc-1)-i], "r")) == NULL) ++ err(EXIT_FAILURE, "Can't open %s", argv[(argc-1)-i]); + if (strip_cr) -+ remove_cr(fp[i]); ++ remove_cr(fp[j]); ++ j++; } merge(m, n); exit(EXIT_SUCCESS); -@@ -265,7 +278,7 @@ main(int argc, char **argv) +@@ -265,7 +281,7 @@ main(int argc, char **argv) * since the vector is processed in one sequential pass. * The vector could be optimized out of existence) */ @@ -181,7 +199,7 @@ readin(char *name, struct diff **dd) { int a, b, c, d, i; -@@ -307,17 +320,18 @@ readin(char *name, struct diff **dd) +@@ -307,17 +323,18 @@ readin(char *name, struct diff **dd) return (i); } @@ -202,7 +220,7 @@ getchange(FILE *b) { char *line; -@@ -329,7 +343,7 @@ getchange(FILE *b) +@@ -329,7 +346,7 @@ getchange(FILE *b) return (NULL); } @@ -211,7 +229,7 @@ getline(FILE *b, size_t *n) { char *cp; -@@ -357,7 +371,7 @@ getline(FILE *b, size_t *n) +@@ -357,7 +374,7 @@ getline(FILE *b, size_t *n) return (buf); } @@ -220,7 +238,7 @@ merge(int m1, int m2) { struct diff *d1, *d2, *d3; -@@ -367,8 +381,7 @@ merge(int m1, int m2) +@@ -367,8 +384,7 @@ merge(int m1, int m2) d2 = d23; j = 0; @@ -230,7 +248,7 @@ printf("Binary file detected; comparison failed\n"); exit(EXIT_FAILURE); } -@@ -464,31 +477,29 @@ merge(int m1, int m2) +@@ -464,31 +480,29 @@ merge(int m1, int m2) } static int @@ -239,12 +257,12 @@ { - wint_t ch = L'\0'; - size_t i; +- +- if (aflag || f == NULL) +- return (1); + int i, check_size; + char ch; -- if (aflag || f == NULL) -- return (1); -- - rewind(f); - errno = 0; - for (i = 0; i <= BUFSIZ; i++) { @@ -279,7 +297,7 @@ printf("====%s\n", s); } -@@ -497,9 +508,10 @@ separate(const char *s) +@@ -497,9 +511,10 @@ separate(const char *s) * It is to be printed only if it does not duplicate something to be * printed later. */ @@ -291,7 +309,7 @@ printf("%d:", i); last[i] = rold->to; prange(rold); -@@ -510,12 +522,14 @@ change(int i, struct range *rold, int du +@@ -510,12 +525,14 @@ change(int i, struct range *rold, int du (void)skip(i, rold->to, " "); } @@ -309,7 +327,7 @@ if (rold->to <= rold->from) printf("%da\n", rold->from - 1); else { -@@ -531,7 +545,7 @@ prange(struct range *rold) +@@ -531,7 +548,7 @@ prange(struct range *rold) * and an artificial dummy difference (trange) must be ginned up to * correspond to the change reported in the other file. */ @@ -318,7 +336,7 @@ keep(int i, struct range *rnew) { int delta; -@@ -547,7 +561,7 @@ keep(int i, struct range *rnew) +@@ -547,7 +564,7 @@ keep(int i, struct range *rnew) * skip to just before line number from in file "i". If "pr" is non-NULL, * print all skipped stuff with string pr as a prefix. */ @@ -327,7 +345,7 @@ skip(int i, int from, char *pr) { size_t j, n; -@@ -558,7 +572,6 @@ skip(int i, int from, char *pr) +@@ -558,7 +575,6 @@ skip(int i, int from, char *pr) trouble(); if (pr != NULL) printf("%s%s", Tflag == 1? "\t" : pr, line); @@ -335,7 +353,7 @@ cline[i]++; } return ((int) n); -@@ -568,10 +581,10 @@ skip(int i, int from, char *pr) +@@ -568,10 +584,10 @@ skip(int i, int from, char *pr) * Return 1 or 0 according as the old range (in file 1) contains exactly * the same data as the new range (in file 2). */ @@ -348,7 +366,7 @@ int nchar; int nline; -@@ -597,7 +610,7 @@ duplicate(struct range *r1, struct range +@@ -597,7 +613,7 @@ duplicate(struct range *r1, struct range return (1); } @@ -357,7 +375,7 @@ repos(int nchar) { int i; -@@ -606,18 +619,43 @@ repos(int nchar) +@@ -606,18 +622,43 @@ repos(int nchar) (void)fseek(fp[i], (long)-nchar, SEEK_CUR); } @@ -403,7 +421,7 @@ if (((dup + 1) & eflag) == 0) return (j); j++; -@@ -632,10 +670,10 @@ edit(struct diff *diff, int dup, int j) +@@ -632,10 +673,10 @@ edit(struct diff *diff, int dup, int j) } /* regurgitate */ @@ -416,7 +434,7 @@ char block[BUFSIZ]; for (n = n; n > 0; n--) { -@@ -657,14 +695,13 @@ edscript(int n) +@@ -657,14 +698,13 @@ edscript(int n) printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark); } } @@ -433,7 +451,7 @@ increase(void) { struct diff *p; -@@ -698,13 +735,29 @@ increase(void) +@@ -698,13 +738,29 @@ increase(void) szchanges = newsz; } From owner-svn-soc-all@FreeBSD.ORG Thu Jul 19 17:31:46 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id D5AF8106566B for ; Thu, 19 Jul 2012 17:31:44 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 19 Jul 2012 17:31:44 +0000 Date: Thu, 19 Jul 2012 17:31:44 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120719173144.D5AF8106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239583 - soc2012/jhagewood/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 17:31:47 -0000 Author: jhagewood Date: Thu Jul 19 17:31:44 2012 New Revision: 239583 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239583 Log: test script Added: soc2012/jhagewood/diff3/diff3-test.sh Added: soc2012/jhagewood/diff3/diff3-test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/jhagewood/diff3/diff3-test.sh Thu Jul 19 17:31:44 2012 (r239583) @@ -0,0 +1,79 @@ +# Script for testing BSD diff3 outputs against GNU diff3 outputs. +# Jesse Hagewood +# jhagewood@freebsd.org + +#!/bin/sh + +rm -rf ./test_outputs +mkdir ./test_outputs +mkdir ./test_outputs/gnu +mkdir ./test_outputs/bsd + +run () { + + # --strip-trailing-cr + $1 --ignore-space-change 1.txt 2.txt 3.txt >> $2/ignrspacechg.txt + + # --text + $1 -a 1.txt 2.txt 3.txt >> $2/text.txt + $1 --text 1.txt 2.txt 3.txt >> $2/text.txt + + # --ed + $1 -e 1.txt 2.txt 3.txt >> $2/ed.txt + $1 --ed 1.txt 2.txt 3.txt >> $2/ed.txt + + # --show-overlap + $1 -E 1.txt 2.txt 3.txt >> $2/showoverlap.txt + $1 --show-overlap 1.txt 2.txt 3.txt >> $2/showoverlap.txt + + # --show-all + $1 -A 1.txt 2.txt 3.txt >> $2/showall.txt + $1 --show-all 1.txt 2.txt 3.txt >> $2/showall.txt + + # --overlap-only + $1 -x 1.txt 2.txt 3.txt >> $2/overlaponly.txt + $1 --overlap-only 1.txt 2.txt 3.txt >> $2/overlaponly.txt + + # -X + $1 -X 1.txt 2.txt 3.txt >> $2/X.txt + + # --easy-only + $1 -3 1.txt 2.txt 3.txt >> $2/easyonly.txt + $1 --easy-only 1.txt 2.txt 3.txt >> $2/easyonly.txt + + # --merge + $1 -m 1.txt 2.txt 3.txt >> $2/merge.txt + $1 --merge 1.txt 2.txt 3.txt >> $2/merge.txt + + # --label + $1 -L "test" 1.txt 2.txt 3.txt >> $2/label.txt + $1 --label="test" 1.txt 2.txt 3.txt >> $2/label.txt + + # -i + $1 -i 1.txt 2.txt 3.txt >> $2/i.txt + + # --initial-tab + $1 -T 1.txt 2.txt 3.txt >> $2/initialtab.txt + $1 --initial-tab 1.txt 2.txt 3.txt >> $2/initialtab.txt + + # --diff-program + $1 --diff-program="/usr/bin/diff" 1.txt 2.txt 3.txt >> $2/diffprog.txt + + # --output + $1 -o $2/output.txt 1.txt 2.txt >> /dev/null + $1 --output=$2/output.txt 1.txt 2.txt >> /dev/null + +} + +DIR_PATH="./test_outputs/gnu" +DIFF_PATH="/usr/bin/diff3" +run "$DIFF_PATH" "$DIR_PATH" +DIR_PATH="./test_outputs/bsd" +DIFF_PATH="./diff3prog" +run "$DIFF_PATH" "$DIR_PATH" + +# +# Get the diff between the GNU sdiff and BSD sdiff outputs. +# + +diff -rupN ./test_outputs/gnu/ ./test_outputs/bsd/ >> ./test_outputs/gnu-bsd-diff3.txt From owner-svn-soc-all@FreeBSD.ORG Thu Jul 19 20:11:10 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 33630106566C for ; Thu, 19 Jul 2012 20:11:08 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 19 Jul 2012 20:11:08 +0000 Date: Thu, 19 Jul 2012 20:11:08 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120719201108.33630106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239587 - in soc2012/gmiller/locking-head: . include lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 20:11:10 -0000 Author: gmiller Date: Thu Jul 19 20:11:07 2012 New Revision: 239587 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239587 Log: r239627@FreeBSD-dev: root | 2012-07-15 10:17:50 -0500 Implement pthread_setname_np(). Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/include/pthread_np.h soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h Modified: soc2012/gmiller/locking-head/include/pthread_np.h ============================================================================== --- soc2012/gmiller/locking-head/include/pthread_np.h Thu Jul 19 19:57:23 2012 (r239586) +++ soc2012/gmiller/locking-head/include/pthread_np.h Thu Jul 19 20:11:07 2012 (r239587) @@ -70,6 +70,7 @@ struct pthread_lockorder_np { struct _pthread_lockorder_private *_pvt; + void *lock; }; typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Thu Jul 19 19:57:23 2012 (r239586) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Thu Jul 19 20:11:07 2012 (r239587) @@ -47,6 +47,7 @@ info->lock = lock; info->child = NULL; info->sibling = NULL; + info->name = NULL; SLIST_INIT(&info->bless_head); SLIST_INSERT_HEAD(&lock_info_head, info, lock_info_next); } @@ -87,6 +88,21 @@ SLIST_REMOVE_HEAD(&lock_info_head, lock_info_next); + if (info->name != NULL) { + free(info->name); + } free(info); } } + +void +pthread_setname_np(void *lock, const char *name) +{ + struct lock_info *info; + + info = lookup_lock(lock); + if (info->name != NULL) { + info->name = realloc(info->name, strlen(name) + 1); + strcpy(info->name, name); + } +} Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Thu Jul 19 19:57:23 2012 (r239586) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Thu Jul 19 20:11:07 2012 (r239587) @@ -31,6 +31,7 @@ #include #include #include +#include struct blessing { SLIST_ENTRY(blessing) bless_next; @@ -44,6 +45,7 @@ struct lock_info *child; struct lock_info *sibling; SLIST_HEAD(bless_head, blessing) bless_head; + char *name; }; extern pthread_mutex_t witness_mtx; From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 03:08:15 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id CB1CD106564A for ; Fri, 20 Jul 2012 03:08:13 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 03:08:13 +0000 Date: Fri, 20 Jul 2012 03:08:13 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720030813.CB1CD106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239602 - soc2012/jhagewood/diff3/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 03:08:16 -0000 Author: jhagewood Date: Fri Jul 20 03:08:12 2012 New Revision: 239602 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239602 Log: Fixed file opening in diff3 Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3prog.c Fri Jul 20 02:18:47 2012 (r239601) +++ soc2012/jhagewood/diff3/diff3/diff3prog.c Fri Jul 20 03:08:12 2012 (r239602) @@ -264,7 +264,7 @@ m = readin(argv[0], &d13); n = readin(argv[1], &d23); j = 0; - for (i = 2; i >= 0; i++) { + for (i = 2; i >= 0; i--) { if ((fp[j] = fopen(argv[(argc-1)-i], "r")) == NULL) err(EXIT_FAILURE, "Can't open %s", argv[(argc-1)-i]); if (strip_cr) From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 03:09:18 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 9C394106566B for ; Fri, 20 Jul 2012 03:09:16 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 03:09:16 +0000 Date: Fri, 20 Jul 2012 03:09:16 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720030916.9C394106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239603 - soc2012/jhagewood/diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 03:09:18 -0000 Author: jhagewood Date: Fri Jul 20 03:09:16 2012 New Revision: 239603 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239603 Log: Fixed file opening in diff3 Modified: soc2012/jhagewood/diff3/TODO soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/TODO ============================================================================== --- soc2012/jhagewood/diff3/TODO Fri Jul 20 03:08:12 2012 (r239602) +++ soc2012/jhagewood/diff3/TODO Fri Jul 20 03:09:16 2012 (r239603) @@ -6,6 +6,7 @@ --diff-program INCOMPLETE Fixed binary detection COMPLETE Test script COMPLETE +Pipe to diff INCOMPLETE - BUG: Goes to usage when argc < 5 FIX: argc < 3 - BUG: Would not open files correctly FIX: change which argv[] is passed Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Fri Jul 20 03:08:12 2012 (r239602) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Fri Jul 20 03:09:16 2012 (r239603) @@ -1,6 +1,6 @@ diff -rupN jhagewood/diff3/diff3-orig/Makefile jhagewood/diff3/diff3/Makefile ---- jhagewood/diff3/diff3-orig/Makefile 2012-07-18 16:22:12.000000000 -0400 -+++ jhagewood/diff3/diff3/Makefile 2012-07-18 16:22:12.000000000 -0400 +--- jhagewood/diff3/diff3-orig/Makefile 2012-07-19 17:32:16.000000000 -0400 ++++ jhagewood/diff3/diff3/Makefile 2012-07-19 17:32:16.000000000 -0400 @@ -6,6 +6,6 @@ BINDIR= /usr/libexec beforeinstall: @@ -10,8 +10,8 @@ .include diff -rupN jhagewood/diff3/diff3-orig/diff3prog.c jhagewood/diff3/diff3/diff3prog.c ---- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-18 16:22:12.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3prog.c 2012-07-19 17:13:54.000000000 -0400 +--- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-19 17:32:16.000000000 -0400 ++++ jhagewood/diff3/diff3/diff3prog.c 2012-07-20 03:04:16.000000000 -0400 @@ -64,19 +64,23 @@ * @(#)diff3.c 8.1 (Berkeley) 6/6/93 */ @@ -181,7 +181,7 @@ - if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) - err(EXIT_FAILURE, "can't open %s", argv[i + 2]); + j = 0; -+ for (i = 2; i >= 0; i++) { ++ for (i = 2; i >= 0; i--) { + if ((fp[j] = fopen(argv[(argc-1)-i], "r")) == NULL) + err(EXIT_FAILURE, "Can't open %s", argv[(argc-1)-i]); + if (strip_cr) From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 03:10:39 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 1581E106566C for ; Fri, 20 Jul 2012 03:10:37 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 03:10:37 +0000 Date: Fri, 20 Jul 2012 03:10:37 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720031037.1581E106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239604 - in soc2012/jhagewood/diff3: . diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 03:10:39 -0000 Author: jhagewood Date: Fri Jul 20 03:10:36 2012 New Revision: 239604 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239604 Log: Changed output bin from diff3prog to diff3 in Makefile Modified: soc2012/jhagewood/diff3/diff3/Makefile soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/diff3/Makefile ============================================================================== --- soc2012/jhagewood/diff3/diff3/Makefile Fri Jul 20 03:09:16 2012 (r239603) +++ soc2012/jhagewood/diff3/diff3/Makefile Fri Jul 20 03:10:36 2012 (r239604) @@ -1,6 +1,6 @@ # $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $ -PROG= diff3prog +PROG= diff3 MAN= diff3.1 BINDIR= /usr/libexec Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Fri Jul 20 03:09:16 2012 (r239603) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Fri Jul 20 03:10:36 2012 (r239604) @@ -1,7 +1,13 @@ diff -rupN jhagewood/diff3/diff3-orig/Makefile jhagewood/diff3/diff3/Makefile --- jhagewood/diff3/diff3-orig/Makefile 2012-07-19 17:32:16.000000000 -0400 -+++ jhagewood/diff3/diff3/Makefile 2012-07-19 17:32:16.000000000 -0400 -@@ -6,6 +6,6 @@ BINDIR= /usr/libexec ++++ jhagewood/diff3/diff3/Makefile 2012-07-20 03:09:41.000000000 -0400 +@@ -1,11 +1,11 @@ + # $OpenBSD: Makefile,v 1.2 2003/07/22 00:11:30 millert Exp $ + +-PROG= diff3prog ++PROG= diff3 + MAN= diff3.1 + BINDIR= /usr/libexec beforeinstall: install ${INSTALL_COPY}c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 03:40:49 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 27A49106566C for ; Fri, 20 Jul 2012 03:40:47 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 03:40:47 +0000 Date: Fri, 20 Jul 2012 03:40:47 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720034047.27A49106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239605 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 03:40:49 -0000 Author: gmiller Date: Fri Jul 20 03:40:46 2012 New Revision: 239605 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239605 Log: r239632@FreeBSD-dev: root | 2012-07-15 12:32:28 -0500 Assign default names to locks. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c soc2012/gmiller/locking-head/lib/libwitness/witness.h soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Fri Jul 20 03:10:36 2012 (r239604) +++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Fri Jul 20 03:40:46 2012 (r239605) @@ -27,6 +27,8 @@ #include "witness.h" +#define MAX_DEFAULT_NAME_LENGTH (80) + static SLIST_HEAD(lock_info_head, lock_info) lock_info_head = SLIST_HEAD_INITIALIZER(lock_info_head); @@ -106,3 +108,15 @@ strcpy(info->name, name); } } + +void +check_default_name(struct lock_info *lock, const char *prefix) +{ + if (lock->name == NULL) { + lock->name = malloc(MAX_DEFAULT_NAME_LENGTH + 1); + if (lock->name != NULL) { + snprintf(lock->name, MAX_DEFAULT_NAME_LENGTH, "%s%p", + prefix, lock->lock); + } + } +} Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/witness.h Fri Jul 20 03:10:36 2012 (r239604) +++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Fri Jul 20 03:40:46 2012 (r239605) @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -63,3 +64,4 @@ void destroy_lock(void *lock); int blessed(struct lock_info *first, struct lock_info *second); void reset_lock_info(void); +void check_default_name(struct lock_info *lock, const char *prefix); Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Fri Jul 20 03:10:36 2012 (r239604) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Fri Jul 20 03:40:46 2012 (r239605) @@ -54,12 +54,16 @@ pthread_mutex_lock(pthread_mutex_t *mutex) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(mutex); + check_default_name(lock, "mutex_"); + ret = _pthread_mutex_lock(mutex); if (mutex != &witness_mtx && ret == 0) { - add_lock(lookup_lock(mutex)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -71,12 +75,16 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(mutex); + check_default_name(lock, "mutex_"); + ret = _pthread_mutex_trylock(mutex); if (mutex != &witness_mtx && ret == 0) { - add_lock(lookup_lock(mutex)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -88,12 +96,16 @@ pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *ts) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(mutex); + check_default_name(lock, "mutex_"); + ret = _pthread_mutex_timedlock(mutex, ts); if (mutex != &witness_mtx && ret == 0) { - add_lock(lookup_lock(mutex)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -137,12 +149,16 @@ pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(rwlock); + check_default_name(lock, "rwlock_"); + ret = _pthread_rwlock_rdlock(rwlock); if (ret == 0) { - add_lock(lookup_lock(rwlock)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -154,12 +170,16 @@ pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(rwlock); + check_default_name(lock, "rwlock_"); + ret = _pthread_rwlock_tryrdlock(rwlock); if (ret == 0) { - add_lock(lookup_lock(rwlock)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -171,12 +191,16 @@ pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *ts) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(rwlock); + check_default_name(lock, "rwlock_"); + ret = _pthread_rwlock_timedrdlock(rwlock, ts); if (ret == 0) { - add_lock(lookup_lock(rwlock)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -188,12 +212,16 @@ pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(rwlock); + check_default_name(lock, "rwlock_"); + ret = _pthread_rwlock_wrlock(rwlock); if (ret == 0) { - add_lock(lookup_lock(rwlock)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -205,12 +233,16 @@ pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(rwlock); + check_default_name(lock, "rwlock_"); + ret = _pthread_rwlock_trywrlock(rwlock); if (ret == 0) { - add_lock(lookup_lock(rwlock)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -222,12 +254,16 @@ pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(rwlock); + check_default_name(lock, "rwlock_"); + ret = _pthread_rwlock_timedwrlock(rwlock, ts); if (ret == 0) { - add_lock(lookup_lock(rwlock)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -271,12 +307,16 @@ pthread_spin_lock(pthread_spinlock_t *spin) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(spin); + check_default_name(lock, "spinlock_"); + ret = _pthread_spin_lock(spin); if (ret == 0) { - add_lock(lookup_lock(spin)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); @@ -288,12 +328,16 @@ pthread_spin_trylock(pthread_spinlock_t *spin) { int ret; + struct lock_info *lock; _pthread_mutex_lock(&witness_mtx); + lock = lookup_lock(spin); + check_default_name(lock, "spinlock_"); + ret = _pthread_spin_lock(spin); if (ret == 0) { - add_lock(lookup_lock(spin)); + add_lock(lock); } _pthread_mutex_unlock(&witness_mtx); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 14:57:20 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id AD457106566B for ; Fri, 20 Jul 2012 14:57:18 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 14:57:18 +0000 Date: Fri, 20 Jul 2012 14:57:18 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720145718.AD457106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239622 - in soc2012/rudot/sys: kern sys X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 14:57:20 -0000 Author: rudot Date: Fri Jul 20 14:57:18 2012 New Revision: 239622 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239622 Log: roll back a small change in rctl_enforce and create instead a new function that does exactly what I need Modified: soc2012/rudot/sys/kern/kern_racct.c soc2012/rudot/sys/kern/kern_rctl.c soc2012/rudot/sys/sys/rctl.h Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Fri Jul 20 09:49:50 2012 (r239621) +++ soc2012/rudot/sys/kern/kern_racct.c Fri Jul 20 14:57:18 2012 (r239622) @@ -562,10 +562,9 @@ ("racct_set: usage of non-reclaimable resource %d dropping", resource)); #endif -#ifdef RCTL - over_limit = rctl_enforce(p, resource, diff); -#else over_limit = 0; +#ifdef RCTL + over_limit = rctl_over_limit(p, resource, diff); #endif racct_alloc_resource(p->p_racct, resource, diff); if (diff > 0) Modified: soc2012/rudot/sys/kern/kern_rctl.c ============================================================================== --- soc2012/rudot/sys/kern/kern_rctl.c Fri Jul 20 09:49:50 2012 (r239621) +++ soc2012/rudot/sys/kern/kern_rctl.c Fri Jul 20 14:57:18 2012 (r239622) @@ -272,12 +272,40 @@ } /* + * Return non-zero if allocating 'amount' by proc 'p' would exceed + * 'resource' limit specified by any rule applicable to the process 'p'. + * The 'amount' can be negative. + */ +int +rctl_over_limit(const struct proc *p, int resource, int64_t amount) { + struct rctl_rule *rule; + struct rctl_rule_link *link; + int over_limit; + + over_limit = 0; + rw_rlock(&rctl_lock); + + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (rctl_would_exceed(p, rule, amount)) { + over_limit = 1; + break; + } + } + + rw_runlock(&rctl_lock); + return (over_limit); +} + +/* * Check whether the proc 'p' can allocate 'amount' of 'resource' in addition * to what it keeps allocated now. Returns non-zero if the allocation should * be denied, 0 otherwise. */ int -rctl_enforce(struct proc *p, int resource, int64_t amount) +rctl_enforce(struct proc *p, int resource, uint64_t amount) { struct rctl_rule *rule; struct rctl_rule_link *link; Modified: soc2012/rudot/sys/sys/rctl.h ============================================================================== --- soc2012/rudot/sys/sys/rctl.h Fri Jul 20 09:49:50 2012 (r239621) +++ soc2012/rudot/sys/sys/rctl.h Fri Jul 20 14:57:18 2012 (r239622) @@ -139,7 +139,8 @@ void rctl_rule_release(struct rctl_rule *rule); int rctl_rule_add(struct rctl_rule *rule); int rctl_rule_remove(struct rctl_rule *filter); -int rctl_enforce(struct proc *p, int resource, int64_t amount); +int rctl_enforce(struct proc *p, int resource, uint64_t amount); +int rctl_over_limit(const struct proc *p, int resource, int64_t amount); uint64_t rctl_get_limit(struct proc *p, int resource); uint64_t rctl_get_available(struct proc *p, int resource); const char *rctl_resource_name(int resource); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 17:25:15 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 5A94E1065670 for ; Fri, 20 Jul 2012 17:25:13 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 17:25:13 +0000 Date: Fri, 20 Jul 2012 17:25:13 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720172513.5A94E1065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239624 - soc2012/gpf/pefs_kmod/sbin/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 17:25:15 -0000 Author: gpf Date: Fri Jul 20 17:25:12 2012 New Revision: 239624 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239624 Log: use openssl lib to sign .pefs.checksum for the moment, DSA and sha1 are used by default. future commit will probably allow all legal combinations of digest type and dsa/rsa .pefs.checksum's signature is stored in a different file during `addchecksum` action: .pefs.signature. The public key of DSA is stored in yet another file, .pefs.pkey. Since all trust falls upon .pefs.checksum, having .pefs.pkey in a readonly media seems like a must. next commit will contain verification code for `/sbin/pefs verify` action. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 20 16:56:34 2012 (r239623) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 20 17:25:12 2012 (r239624) @@ -53,7 +53,11 @@ #include +#include +#include #include +#include +#include #include "pefs_ctl.h" @@ -72,6 +76,11 @@ #define PEFS_HASH_BYTE_ALIGNMENT 512 #define PEFS_EXTRA_TABLE_SIZE 15 +#define PEFS_PLEN 1024 +#define PEFS_SEED_LEN 20 + +#define PEFS_BUFISZE 512 + /* tail that contains a single file's checksums */ TAILQ_HEAD(checksum_head, checksum); /* tail that contains all file headers that require integrity checking */ @@ -1419,20 +1428,154 @@ strlcpy(cfhp->hash_algo, algo, sizeof(cfhp->hash_algo)); } +static EVP_PKEY * +pefs_generate_dsa(FILE *pkfp) +{ + unsigned char seed[PEFS_SEED_LEN]; + DSA *dsa; + EVP_PKEY *pkey; + int rval; + + RAND_bytes(seed, sizeof(seed)); + dsa = DSA_generate_parameters(PEFS_PLEN, seed, sizeof(seed), NULL, + NULL, NULL, NULL); + if (dsa == NULL) { + pefs_warn("error generating dsa parameters"); + return (NULL); + } + + rval = DSA_generate_key(dsa); + if (rval != 1) { + pefs_warn("error generating dsa key"); + DSA_free(dsa); + return (NULL); + } + + pkey = EVP_PKEY_new(); + if (pkey == NULL) { + pefs_warn("error allocating a pkey"); + DSA_free(dsa); + return (NULL); + } + rval = EVP_PKEY_assign_DSA(pkey, dsa); + if (rval != 1) { + pefs_warn("error generating dsa key"); + EVP_PKEY_free(pkey); + DSA_free(dsa); + return (NULL); + } + + rval = PEM_write_DSA_PUBKEY(pkfp, dsa); + if (rval != 1) { + pefs_warn("error writing dsa pubkey"); + EVP_PKEY_free(pkey); + DSA_free(dsa); + return (NULL); + } + + return (pkey); +} + +//int PEM_write_PUBKEY(FILe *, pkey *) +//int PEM_read_DSA_PUBKEY + +//Certificates using any digest algorithm are compatible with RSA sign keys; +//however, only SHA and SHA1 certificates are compatible with DSA sign keys. +static int +pefs_sign_file(int fd, FILE *pkfp, FILE *signfp) +{ + unsigned char buf[PEFS_BUFISZE]; + EVP_MD_CTX ctx; + const EVP_MD *md; + EVP_PKEY *pkey; + unsigned char *sign; + unsigned int sign_len; + int bytes, error, rval; + + pkey = pefs_generate_dsa(pkfp); + if (pkey == NULL) + return (PEFS_ERR_SYS); + + md = EVP_dss1(); + if (md == NULL) { + pefs_warn("error acquiring digest type"); + EVP_PKEY_free(pkey); + return (PEFS_ERR_GENERIC); + } + + EVP_SignInit(&ctx, md); + + error = lseek(fd, 0, SEEK_SET); + if (error != 0) { + warn("lseek: "); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + + while ((bytes = read(fd, buf, sizeof(buf))) > 0) { + rval = EVP_SignUpdate(&ctx, buf, bytes); + if (rval != 1) { + pefs_warn("error updating sign data"); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + } + + if (bytes == -1) { + warn("read error"); + EVP_PKEY_free(pkey); + return (PEFS_ERR_IO); + } + + sign = malloc(EVP_PKEY_size(pkey)); + if (sign == NULL) { + pefs_warn("memory allocation error"); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + + rval = EVP_SignFinal(&ctx, sign, &sign_len, pkey); + if (rval != 1) { + pefs_warn("error generating signature"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + + if (fwrite(sign, sizeof(char), sign_len, signfp) < sign_len) { + pefs_warn("error writing signature"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_IO); + } + + free(sign); + EVP_PKEY_free(pkey); + + return (0); +} + /* * If .pefs.checksum is created inside pefs mounted fs, then it will obtain an * encrypted filename & encrypted data, which is unacceptable. User should * create checksum file outside of filesystem and then copy it by hand. + * Alongside with the checksum file, we will create two additional files as + * placeholders for the public key and the file's digital signature. */ static int -pefs_open_checksum_file(int *fdp, char *fsroot, char *csm_path) +pefs_open_checksum_files(int *fdp, char *fsroot, char *csm_path, FILE **pkfpp, + char *pk_path, FILE **signfpp, char *sign_path) { struct statfs pefs_fs, checksum_fs; + FILE *pkfp, *signfp; int fd; *fdp = -1; + *pkfpp = NULL; + *signfpp = NULL; - fd = open(csm_path, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + /* create checksum file */ + fd = open(csm_path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); if (fd == -1) { warn("cannot open %s", csm_path); return (PEFS_ERR_IO); @@ -1456,6 +1599,23 @@ csm_path, pefs_fs.f_mntonname); return (PEFS_ERR_INVALID); } + + /* create files for the public key and .pefs.checksum's signature */ + pkfp = fopen(pk_path, "wx"); + if (pkfp == NULL) { + warn("cannot open %s", pk_path); + return (PEFS_ERR_SYS); + } + + *pkfpp = pkfp; + + signfp = fopen(sign_path, "wx"); + if (signfp == NULL) { + warn("cannot open %s", sign_path); + return (PEFS_ERR_SYS); + } + + *signfpp = signfp; return (0); } @@ -1468,11 +1628,12 @@ */ int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, - const char *algo, int flags) + char *pk_path, char *sign_path, const char *algo, int flags) { struct cuckoo_hash_table checksum_hash_table; struct checksum_file_header cfh; const EVP_MD *md; + FILE *pkfp, *signfp; int error, fdout; uint8_t hash_len; @@ -1487,7 +1648,8 @@ pefs_init_hash_table(&checksum_hash_table); - error = pefs_open_checksum_file(&fdout, fsroot, csm_path); + error = pefs_open_checksum_files(&fdout, fsroot, csm_path, &pkfp, pk_path, + &signfp, sign_path); if (error != 0) goto out; @@ -1499,6 +1661,10 @@ pefs_init_checksum_file_header(&cfh, algo, hash_len, &checksum_hash_table); error = pefs_write_checksum_file(fdout, &cfh, &checksum_hash_table); + if (error != 0) + goto out; + + error = pefs_sign_file(fdout, pkfp, signfp); out: if (fdout >= 0) { @@ -1506,6 +1672,16 @@ if (error != 0) unlink(csm_path); } + if (pkfp != NULL) { + fclose(pkfp); + if (error != 0) + unlink(pk_path); + } + if (signfp != NULL) { + fclose(signfp); + if (error != 0) + unlink(sign_path); + } pefs_free_hash_table(&checksum_hash_table); return (error); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Jul 20 16:56:34 2012 (r239623) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Jul 20 17:25:12 2012 (r239624) @@ -1033,8 +1033,9 @@ static int pefs_addchecksum(int argc, char *argv[]) { - char fsroot[MAXPATHLEN]; - char csm_path[MAXPATHLEN]; + char fsroot[MAXPATHLEN + 1]; + char csm_path[MAXPATHLEN + 1], pk_path[MAXPATHLEN + 1]; + char sign_path[MAXPATHLEN + 1]; struct stat sb; FILE *fpin; int error, flags, i, j; @@ -1046,6 +1047,8 @@ algo = supported_digests[0]; /* by default create checksum file under $PWD */ snprintf(csm_path, sizeof(csm_path), "./%s", PEFS_FILE_CHECKSUM); + snprintf(pk_path, sizeof(pk_path), "./%s", PEFS_FILE_PKEY); + snprintf(sign_path, sizeof(sign_path), "./%s", PEFS_FILE_SIGNATURE); while ((i = getopt(argc, argv, "fa:i:p:")) != -1) switch(i) { @@ -1088,7 +1091,10 @@ snprintf(csm_path, sizeof(csm_path), "%s/%s", optarg, PEFS_FILE_CHECKSUM); - + snprintf(pk_path, sizeof(pk_path), "%s/%s", optarg, + PEFS_FILE_PKEY); + snprintf(sign_path, sizeof(sign_path), "%s/%s", optarg, + PEFS_FILE_SIGNATURE); break; default: if (fpin != NULL) @@ -1100,7 +1106,8 @@ initfsroot(argc, argv, 0, fsroot, sizeof(fsroot)); - error = pefs_create_checksum_file(fpin, fsroot, csm_path, algo, flags); + error = pefs_create_checksum_file(fpin, fsroot, csm_path, pk_path, + sign_path,algo, flags); out: if (fpin != NULL) @@ -1137,7 +1144,7 @@ pefs_verify(int argc, char *argv[]) { struct stat sb; - char fsroot[MAXPATHLEN]; + char fsroot[MAXPATHLEN + 1]; int error, fdin, flags, i; flags = PEFS_VERIFY; Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Fri Jul 20 16:56:34 2012 (r239623) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Fri Jul 20 17:25:12 2012 (r239624) @@ -43,6 +43,8 @@ #define PEFS_FILE_KEYCHAIN ".pefs.db" #define PEFS_FILE_KEYCONF ".pefs.conf" #define PEFS_FILE_CHECKSUM ".pefs.checksum" +#define PEFS_FILE_SIGNATURE ".pefs.signature" +#define PEFS_FILE_PKEY ".pefs.pkey" #define PEFS_NOKEY 0x0001 #define PEFS_UNMOUNTED 0x0002 @@ -101,7 +103,7 @@ const struct pefs_xkey *xk_parent); uintmax_t pefs_keyid_as_int(char *keyid); int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, - const char *algo, int flags); + char *pk_path, char *sign_path, const char *algo, int flags); int pefs_verify_checksum(int fdin, char *fsroot, int flags); int pefs_name_pton(char const *src, size_t srclen, u_char *target, From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 18:36:05 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C65A1106564A for ; Fri, 20 Jul 2012 18:36:03 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 18:36:03 +0000 Date: Fri, 20 Jul 2012 18:36:03 +0000 From: gpf@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720183603.C65A1106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239626 - soc2012/gpf/pefs_kmod/sbin/pefs X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 18:36:05 -0000 Author: gpf Date: Fri Jul 20 18:36:03 2012 New Revision: 239626 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239626 Log: verify .pefs.checksum's signature with public key found in .pefs.pkey. once again, dsa and sha1 are used by default. next commit will update comments and clean up new code as needed. Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 20 17:51:20 2012 (r239625) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_checksum.c Fri Jul 20 18:36:03 2012 (r239626) @@ -1459,28 +1459,23 @@ } rval = EVP_PKEY_assign_DSA(pkey, dsa); if (rval != 1) { - pefs_warn("error generating dsa key"); + pefs_warn("error assigning dsa key"); EVP_PKEY_free(pkey); DSA_free(dsa); return (NULL); } - + rval = PEM_write_DSA_PUBKEY(pkfp, dsa); if (rval != 1) { pefs_warn("error writing dsa pubkey"); EVP_PKEY_free(pkey); DSA_free(dsa); - return (NULL); + return (NULL); } return (pkey); } -//int PEM_write_PUBKEY(FILe *, pkey *) -//int PEM_read_DSA_PUBKEY - -//Certificates using any digest algorithm are compatible with RSA sign keys; -//however, only SHA and SHA1 certificates are compatible with DSA sign keys. static int pefs_sign_file(int fd, FILE *pkfp, FILE *signfp) { @@ -1507,7 +1502,7 @@ error = lseek(fd, 0, SEEK_SET); if (error != 0) { - warn("lseek: "); + warn("lseek:"); EVP_PKEY_free(pkey); return (PEFS_ERR_SYS); } @@ -1546,7 +1541,7 @@ pefs_warn("error writing signature"); free(sign); EVP_PKEY_free(pkey); - return (PEFS_ERR_IO); + return (PEFS_ERR_IO); } free(sign); @@ -1555,15 +1550,126 @@ return (0); } +static EVP_PKEY * +pefs_read_dsa(FILE *pk_fp) +{ + DSA *dsa; + EVP_PKEY *pkey; + int rval; + + dsa = PEM_read_DSA_PUBKEY(pk_fp, NULL, NULL, NULL); + if (dsa == NULL) { + pefs_warn("error reading dsa pubkey"); + return (NULL); + } + + pkey = EVP_PKEY_new(); + if (pkey == NULL) { + pefs_warn("error allocating a pkey"); + DSA_free(dsa); + return (NULL); + } + + rval = EVP_PKEY_assign_DSA(pkey, dsa); + if (rval != 1) { + pefs_warn("error assigning dsa key"); + EVP_PKEY_free(pkey); + DSA_free(dsa); + return (NULL); + } + + return (pkey); +} + +static int +pefs_verify_signature(int fd, FILE *pk_fp, FILE *sign_fp) +{ + unsigned char buf[PEFS_BUFISZE]; + EVP_MD_CTX ctx; + const EVP_MD *md; + EVP_PKEY *pkey; + unsigned char *sign; + unsigned int sign_len; + int bytes, error, rval; + + pkey = pefs_read_dsa(pk_fp); + if (pkey == NULL) + return (PEFS_ERR_SYS); + + sign = malloc(EVP_PKEY_size(pkey)); + if (sign == NULL) { + pefs_warn("memory allocation error"); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + + sign_len = fread(sign, sizeof(char), EVP_PKEY_size(pkey), sign_fp); + if (ferror(sign_fp)) { + pefs_warn("error reading from signature file"); + free(sign); + return (PEFS_ERR_IO); + } + + md = EVP_dss1(); + if (md == NULL) { + pefs_warn("error acquiring digest type"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_GENERIC); + } + EVP_VerifyInit(&ctx, md); + + error = lseek(fd, 0, SEEK_SET); + if (error != 0) { + warn("lseek:"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + + while ((bytes = read(fd, buf, sizeof(buf))) > 0) { + rval = EVP_VerifyUpdate(&ctx, buf, bytes); + if (rval != 1) { + pefs_warn("error updating sign data"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_SYS); + } + } + + if (bytes == -1) { + warn("read error"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_IO); + } + + rval = EVP_VerifyFinal(&ctx, sign, sign_len, pkey); + if (rval == 0) { + pefs_warn("file signature is not verified by public key"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_GENERIC); + } + else if (rval == -1) { + pefs_warn("error verifying signature"); + free(sign); + EVP_PKEY_free(pkey); + return (PEFS_ERR_GENERIC); + } + + return (0); +} + /* * If .pefs.checksum is created inside pefs mounted fs, then it will obtain an * encrypted filename & encrypted data, which is unacceptable. User should * create checksum file outside of filesystem and then copy it by hand. - * Alongside with the checksum file, we will create two additional files as + * Alongside with the checksum file, we will create two additional files as * placeholders for the public key and the file's digital signature. */ static int -pefs_open_checksum_files(int *fdp, char *fsroot, char *csm_path, FILE **pkfpp, +pefs_open_checksum_files(int *fdp, char *fsroot, char *csm_path, FILE **pkfpp, char *pk_path, FILE **signfpp, char *sign_path) { struct statfs pefs_fs, checksum_fs; @@ -1599,22 +1705,22 @@ csm_path, pefs_fs.f_mntonname); return (PEFS_ERR_INVALID); } - + /* create files for the public key and .pefs.checksum's signature */ pkfp = fopen(pk_path, "wx"); if (pkfp == NULL) { warn("cannot open %s", pk_path); return (PEFS_ERR_SYS); } - + *pkfpp = pkfp; - + signfp = fopen(sign_path, "wx"); if (signfp == NULL) { warn("cannot open %s", sign_path); return (PEFS_ERR_SYS); } - + *signfpp = signfp; return (0); @@ -2130,7 +2236,8 @@ * D) check that every file in .pefs.checksum was actually found in filesystem. */ int -pefs_verify_checksum(int fdin, char *fsroot, int flags) +pefs_verify_checksum(int fdin, FILE *pk_fp, FILE *sign_fp, + char *fsroot, int flags) { struct statfs fs; struct checksum_file_header cfh; @@ -2186,7 +2293,7 @@ goto out; /* pefs_rb_print(&hlc_head); */ - pefs_rb_warn(&hlc_head);printf("3\n"); + pefs_rb_warn(&hlc_head); if ((flags & PEFS_UNMOUNTED) == 0 && (flags & PEFS_NOKEY) == 0) pefs_symlink_warn(&cht, &fh_head); @@ -2195,6 +2302,8 @@ if (error == 0 && checksum_error != 0) error = checksum_error; + error = pefs_verify_signature(fdin, pk_fp, sign_fp); + out: pefs_free_hash_table(&cht); pefs_rb_free(&hlc_head); Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Jul 20 17:51:20 2012 (r239625) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.c Fri Jul 20 18:36:03 2012 (r239626) @@ -1119,7 +1119,7 @@ /* * XXXgpf: Instead of a man page entry: * - * pefs verify [-u/-n] checksumpath filesystem + * pefs verify [-u/-n] [-k pkey_file] [-s sign_file] checksumpath filesystem * * $command verifies the contents of a .pefs.checksum file. It scans the * entire filesystem and checks that every entry in .pefs.checksum is @@ -1144,12 +1144,24 @@ pefs_verify(int argc, char *argv[]) { struct stat sb; - char fsroot[MAXPATHLEN + 1]; + char fsroot[MAXPATHLEN + 1], pk_path[MAXPATHLEN + 1]; + char sign_path[MAXPATHLEN + 1]; + char *dirnamep; + FILE *pk_fp, *sign_fp; int error, fdin, flags, i; flags = PEFS_VERIFY; - while ((i = getopt(argc, argv, "nu")) != -1) + pk_fp = NULL; + sign_fp = NULL; + while ((i = getopt(argc, argv, "k:ns:u")) != -1) switch(i) { + case 'k': + pk_fp = fopen(optarg, "r"); + if (pk_fp == NULL) { + warn("error opening pkey file %s", optarg); + return (PEFS_ERR_SYS); + } + break; case 'n': flags|= PEFS_NOKEY; if ((flags & PEFS_UNMOUNTED) != 0) { @@ -1157,6 +1169,13 @@ return (PEFS_ERR_INVALID); } break; + case 's': + sign_fp = fopen(optarg, "r"); + if (sign_fp == NULL) { + warn("error opening signature file %s", optarg); + return (PEFS_ERR_SYS); + } + break; case 'u': flags|= PEFS_UNMOUNTED; if ((flags & PEFS_NOKEY) != 0) { @@ -1178,11 +1197,31 @@ pefs_usage(); } + /* XXXgpf: [TODO] close files if error */ fdin = open(argv[0], O_RDONLY); if (fdin == -1) { warn("cannot open %s file: %s", PEFS_FILE_CHECKSUM, argv[0]); return (PEFS_ERR_INVALID); } + dirnamep = dirname(argv[0]); + if (pk_fp == NULL) { + snprintf(pk_path, sizeof(pk_path), "%s/%s", dirnamep, PEFS_FILE_PKEY); + pk_fp = fopen(pk_path, "r"); + if (pk_fp == NULL) { + warn("error opening pkey file %s", pk_path); + return (PEFS_ERR_SYS); + } + } + if (sign_fp == NULL) { + snprintf(sign_path, sizeof(sign_path), "%s/%s", dirnamep, + PEFS_FILE_SIGNATURE); + sign_fp = fopen(sign_path, "r"); + if (sign_fp == NULL) { + warn("error opening signature file %s", sign_path); + return (PEFS_ERR_SYS); + } + } + argc -=1; argv +=1; @@ -1207,13 +1246,15 @@ } } - error = pefs_verify_checksum(fdin, fsroot, flags); + error = pefs_verify_checksum(fdin, pk_fp, sign_fp, fsroot, flags); if (error == 0) printf("integrity verification ok!\n"); else pefs_warn("integrity verification encountered error(s)"); close(fdin); + fclose(pk_fp); + fclose(sign_fp); return (error); } Modified: soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h ============================================================================== --- soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Fri Jul 20 17:51:20 2012 (r239625) +++ soc2012/gpf/pefs_kmod/sbin/pefs/pefs_ctl.h Fri Jul 20 18:36:03 2012 (r239626) @@ -104,7 +104,8 @@ uintmax_t pefs_keyid_as_int(char *keyid); int pefs_create_checksum_file(FILE *fpin, char *fsroot, char *csm_path, char *pk_path, char *sign_path, const char *algo, int flags); -int pefs_verify_checksum(int fdin, char *fsroot, int flags); +int pefs_verify_checksum(int fdin, FILE *pk_fp, FILE *sign_fp, + char *fsroot, int flags); int pefs_name_pton(char const *src, size_t srclen, u_char *target, size_t targsize); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 20 21:47:27 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id B1F66106566B for ; Fri, 20 Jul 2012 21:47:25 +0000 (UTC) (envelope-from exxo@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Fri, 20 Jul 2012 21:47:25 +0000 Date: Fri, 20 Jul 2012 21:47:25 +0000 From: exxo@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120720214725.B1F66106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r239628 - in soc2012/exxo/freebsd-head: include/rpcsvc usr.bin/ypwhich X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 21:47:27 -0000 Author: exxo Date: Fri Jul 20 21:47:24 2012 New Revision: 239628 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239628 Log: Update YPBIND protocol v2 -> v3. Fix ypwhich accordingly and provide backward compatibility Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp.x soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp.x ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp.x Fri Jul 20 19:35:20 2012 (r239627) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp.x Fri Jul 20 21:47:24 2012 (r239628) @@ -196,7 +196,8 @@ }; struct ypbind_binding { - opaque ypbind_binding_addr[4]; /* In network order */ + unsigned char ypbind_binding_family; + opaque ypbind_binding_addr[16]; /* In network order */ opaque ypbind_binding_port[2]; /* In network order */ }; @@ -223,6 +224,28 @@ unsigned ypsetdom_vers; }; +/* Backward compatibility for YPBIND protocol version 2 */ +#ifdef YPBIND_COMPAT_V2 + +struct ypbind_binding_v2 { + opaque ypbind_binding_addr[4]; /* In network order */ + opaque ypbind_binding_port[2]; /* In network order */ +}; + +union ypbind_resp_v2 switch (ypbind_resptype ypbind_status) { +case YPBIND_FAIL_VAL: + unsigned ypbind_error; +case YPBIND_SUCC_VAL: + ypbind_binding_v2 ypbind_bindinfo; +}; + +struct ypbind_setdom_v2 { + domainname ypsetdom_domain; + ypbind_binding_v2 ypsetdom_binding; + unsigned ypsetdom_vers; +}; + +#endif /* * NIS v1 support for backwards compatibility @@ -371,7 +394,7 @@ void YPBINDPROC_SETDOM(ypbind_setdom) = 2; - } = 2; + } = 3; } = 100007; #endif Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h ============================================================================== --- soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Fri Jul 20 19:35:20 2012 (r239627) +++ soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h Fri Jul 20 21:47:24 2012 (r239628) @@ -199,7 +199,7 @@ struct dom_binding { struct dom_binding *dom_pnext; char dom_domain[YPMAXDOMAIN + 1]; - struct sockaddr_storage dom_server_addr; + struct sockaddr_storage dom_server_addr; /* TODO impact of changing this ? */ u_short dom_server_port; int dom_socket; CLIENT *dom_client; @@ -222,7 +222,8 @@ */ #define YPBINDPROG ((u_long)100007) -#define YPBINDVERS ((u_long)2) +#define YPBINDVERS ((u_long)3) +#define YPBINDVERS_2 ((u_long)2) #define YPBINDVERS_ORIG ((u_long)1) /* ypbind procedure numbers */ @@ -272,6 +273,30 @@ #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr #define ypsetdom_port ypsetdom_binding.ypbind_binding_port +/* Backward compatibility for YPBIND protocol version 2 */ +#ifdef YPBIND_COMPAT_V2 + +struct ypbind_binding_v2 { + struct in_addr ypbind_binding_addr; + u_short ypbind_binding_port; +}; + +struct ypbind_resp_v2 { + enum ypbind_resptype ypbind_status; + union { + u_int ypbind_error; + struct ypbind_binding_v2 ypbind_bindinfo; + } ypbind_respbody; +}; + +struct ypbind_setdom_v2 { + char ypsetdom_domain[YPMAXDOMAIN + 1]; + struct ypbind_binding_v2 ypsetdom_binding; + u_int ypsetdom_vers; +}; + +#endif + /* * YPPUSH PROTOCOL: * @@ -323,6 +348,7 @@ bool_t xdr_ypresp_val(XDR *, struct ypresp_val *); bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *); bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *); +bool_t xdr_ypbind_resp_v2(XDR *, struct ypbind_resp_v2 *); bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *); bool_t xdr_yp_inaddr(XDR *, struct inaddr *); bool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *); Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile Fri Jul 20 19:35:20 2012 (r239627) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/Makefile Fri Jul 20 21:47:24 2012 (r239628) @@ -1,12 +1,14 @@ # from: @(#)Makefile 5.8 (Berkeley) 7/28/90 # $FreeBSD$ +.include + PROG= ypwhich WARNS?= 2 .if ${MK_INET6_SUPPORT} != "no" -CFLAGS+= -DINET6 +CFLAGS+= -DINET6 -DYPBIND_COMPAT_V2 .endif .include Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c ============================================================================== --- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Fri Jul 20 19:35:20 2012 (r239627) +++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c Fri Jul 20 21:47:24 2012 (r239628) @@ -83,26 +83,36 @@ exit(ERR_USAGE); } -#define ypb_family ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family -#define ypb_addr ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr +union ypb_resp { + struct { + enum ypbind_resptype status; + u_int error; + } header; + struct ypbind_resp resp; +#ifdef YPBIND_COMPAT_V2 + struct ypbind_resp_v2 resp2; +#endif +}; +#define ypb_status header.status +#define ypb_error header.error +#define ypb_family resp.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family +#define ypb_addr resp.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr +#ifdef YPBIND_COMPAT_V2 +# define ypb_addr_v2 resp2.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr +#endif + #ifdef INET6 # define ADDRSTRLEN INET6_ADDRSTRLEN #else # define ADDRSTRLEN INET_ADDRSTRLEN #endif -/* - * Like yp_bind except can query a specific host - */ -static int -bind_host(char *dom, const char *host) +static void +print_addr(union ypb_resp *ypbr, int version) { struct hostent *hent = NULL; - struct ypbind_resp ypbr; - struct timeval tv; - CLIENT *client; - int r; char str[ADDRSTRLEN]; + int family; size_t len; union { struct in_addr in; @@ -111,9 +121,46 @@ #endif } ss_addr; +#ifdef YPBIND_COMPAT_V2 + if (version == YPBINDVERS_2) { + family = AF_INET; + len = sizeof(ss_addr.in); + bcopy(&ypbr->ypb_addr_v2, &ss_addr, len); + } + else /* YPBINDVERS */ +#endif + { + family = ypbr->ypb_family; +#ifdef INET6 + if (family == AF_INET6) + len = sizeof(ss_addr.in6); + else /* AF_INET */ +#endif + len = sizeof(ss_addr.in); + bcopy(&ypbr->ypb_addr, &ss_addr, len); + } + hent = gethostbyaddr((char *)&ss_addr, len, family); + if (hent) + printf("%s\n", hent->h_name); + else + printf("%s\n", inet_ntop(family, &ss_addr, str, ADDRSTRLEN)); +} + +/* + * Like yp_bind except can query a specific host + */ +static int +bind_host(char *dom, const char *host) +{ + union ypb_resp ypbr; + struct timeval tv; + CLIENT *client; + int r; + int version = YPBINDVERS; + tv.tv_sec = 15; tv.tv_usec = 0; - client = clnt_create_timed(host, YPBINDPROG, YPBINDVERS, "udp", &tv); + client = clnt_create_timed(host, YPBINDPROG, version, "udp", &tv); if (client == NULL) { warnx("can't clnt_create_timed: %s", yperr_string(YPERR_YPBIND)); return (YPERR_YPBIND); @@ -123,32 +170,31 @@ tv.tv_usec = 0; r = clnt_call(client, YPBINDPROC_DOMAIN, (xdrproc_t)xdr_domainname, &dom, - (xdrproc_t)xdr_ypbind_resp, &ypbr, tv); + (xdrproc_t)xdr_ypbind_resp, &ypbr.resp, tv); +#ifdef YPBIND_COMPAT_V2 + if (r == RPC_PROGVERSMISMATCH) { + fprintf(stderr, "Warning: %s, fallback in V2 compatibility mode\n", clnt_sperrno(r)); + version = YPBINDVERS_2; + if (clnt_control(client, CLSET_VERS, &version) == TRUE) + r = clnt_call(client, YPBINDPROC_DOMAIN, + (xdrproc_t)xdr_domainname, &dom, + (xdrproc_t)xdr_ypbind_resp_v2, &ypbr.resp2, tv); /* TODO libc must define YPBIND_COMPAT_V2 */ + } +#endif if (r != RPC_SUCCESS) { warnx("can't clnt_call: %s", yperr_string(YPERR_YPBIND)); clnt_destroy(client); return (YPERR_YPBIND); } else { - if (ypbr.ypbind_status != YPBIND_SUCC_VAL) { + if (ypbr.ypb_status != YPBIND_SUCC_VAL) { warnx("can't yp_bind: reason: %s", - ypbinderr_string(ypbr.ypbind_respbody.ypbind_error)); + ypbinderr_string(ypbr.ypb_error)); clnt_destroy(client); return (r); } } clnt_destroy(client); - bcopy(&ypb_addr, &ss_addr, sizeof(ss_addr)); -#ifdef INET6 - if (ypb_family == AF_INET6) - len = sizeof(ss_addr.in6); - else /* AF_INET */ -#endif - len = sizeof(ss_addr.in); - hent = gethostbyaddr((char *)&ss_addr, len, ypb_family); - if (hent) - printf("%s\n", hent->h_name); - else - printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, ADDRSTRLEN)); + print_addr(&ypbr, version); return (0); } From owner-svn-soc-all@FreeBSD.ORG Sat Jul 21 00:05:48 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 253D01065670 for ; Sat, 21 Jul 2012 00:05:46 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 21 Jul 2012 00:05:46 +0000 Date: Sat, 21 Jul 2012 00:05:46 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120721000546.253D01065670@hub.freebsd.org> Cc: Subject: socsvn commit: r239631 - soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 00:05:48 -0000 Author: tzabal Date: Sat Jul 21 00:05:45 2012 New Revision: 239631 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239631 Log: Upload changes of crashreportd. Modified: soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Modified: soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py ============================================================================== --- soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Fri Jul 20 23:56:23 2012 (r239630) +++ soc2012/tzabal/server-side/akcrs-release/9.0.0/usr.sbin/crashreportd/crashreportd.py Sat Jul 21 00:05:45 2012 (r239631) @@ -5,141 +5,211 @@ import time import tarfile +import argparse +import logging -# Check if the filename matches the pattern of a valid crash report name -# Return False in failure and True in success -def check_report_name(filename): - match_obj = re.match('^crashreport\.[A-Za-z0-9]{6}\.tar\.gz$', filename) - - if not match_obj: - print "debug1" - return False - - return True +# Module Variables +_interval_time = 10 +_pid_file = '/var/run/crashreportd.pid' +_crashreports_dir = '/var/spool/crashreports' +_logging_file = '' -# Check if the filename matches the pattern of a valid crash data name -# Return False in failure and True in success -def check_data_name(filename): - match_obj = re.match('^crashreport\.[A-Za-z0-9]{6}\.xml$', filename) +def valid_report_name(report): + """Checks if the filename matches the pattern of a valid crash report name.""" + filename = os.path.basename(report) + match_obj = re.match('^crashreport\.[A-Za-z0-9]{6}\.tar\.gz$', filename) + if not match_obj: - print "debug2" - return False + logging.info('Invalid crash report name: %s' % filename) + return return True -# Check if the report is a tar.gz file and if it has only one file inside -# with a valid name. -# Return False in failure and True in success -def check_report_contents(filename): - report = crashreports_dir + "/" + filename - +def valid_report_type(report): + """Check if the report's file type matches the file type of a valid crash report.""" if not tarfile.is_tarfile(report): - print "debug3" - return False + logging.info('Report %s is not a tar file.' % report) + return try: tarfile_obj = tarfile.open(report, 'r:gz') - contents_list = tarfile_obj.getnames() except ReadError: - print "debug4" - return False + logging.info('ReadError exception.') + return except CompressionError: - print "debug5" - return False - - if not len(contents_list) == 1: - print "debug6" - return False - - if not check_data_name(contents_list[0]): - print "debug7" - return False + logging.info('CompressionError exception') + return + finally: + tarfile_obj.close() return True -def extract_report(filename): - if not os.path.isdir(extraction_dir): - print "debug11" - return False +def valid_contents_number(report): + """Checks if the report contains the same number of files as a valid report.""" + try: + tarfile_obj = tarfile.open(report, 'r:gz') + except ReadError: + logging.info('ReadError exception.') + return + except CompressionError: + logging.info('CompressionError exception') + return + else: + contents_list = tarfile_obj.getnames() + if not len(contents_list) == 1: + logging.info('Invalid number of files inside the crash report.') + return + finally: + tarfile_obj.close() + return True + + +def valid_data_name(report): + """Checks if the filename matches the pattern of a valid crash data name.""" try: - report = crashreports_dir + "/" + filename tarfile_obj = tarfile.open(report, 'r:gz') - tarfile_obj.extractall(extraction_dir); except ReadError: - print "debug12" - return False + logging.info('ReadError exception.') + return except CompressionError: - print "debug13" - return False + logging.info('CompressionError exception') + return + else: + contents_list = tarfile_obj.getnames() + match_obj = re.match('^crashreport\.[A-Za-z0-9]{6}\.xml$', contents_list[0]) + finally: + tarfile_obj.close() - dirlist = os.listdir(extraction_dir) - if not len(dirlist) == 1: - print "debug14" - return False + if not match_obj: + logging.info('Invalid crash data name: %s' % contents_list[0]) + return - data_name = dirlist[0] - #print "data_name: ", data_name - return True -# Container function that call all the check related functions -# Return False in failure and True in success -def check_report(filename): - if not check_report_name(filename): - print "debug8" - return False +def discard_report(report): + """Discard a crash report from the system.""" + os.remove(report) + + +def check_report(report): + """Container function that calls all the functions related to validity.""" + if not valid_report_name(report): + discard_report(report) + return + + if not valid_report_type(report): + discard_report(report) + return - if not check_report_contents(filename): - print "debug9" - return False + if not valid_contents_number(report): + discard_report(report) + return - if not extract_report(filename): - print "debug10" - return False + if not valid_data_name(report): + discard_report(report) + return return True -# Create the Process ID file that contains the PID of crashreportd. -# It used from the rc.d script to stop the program normally. def create_pid_file(): + """Creates the Process ID file that contains the PID of crashreportd. + + It used from the rc.d script to stop the program normally. + """ pid = os.getpid() - - pid_file = '/var/run/crashreportd.pid' try: - file_obj = open(pid_file, 'w') + file_obj = open(_pid_file, 'w') file_obj.write(str(pid)) file_obj.close() except IOError: - return False + return finally: file_obj.close() return True +def parse_arguments(): + """Parse the command line arguments provided.""" + parser = argparse.ArgumentParser() + parser.add_argument('-d', help='the directory where crash reports arrive in the system', dest='crashreports_dir') + parser.add_argument('-p', help='the file that stores the process id of crashreportd', dest='pid_file') + parser.add_argument('-t', type=int, help='the minimum delay between two checks of the crash reports directory', dest='interval_time') + parser.add_argument('-l', help='the file that various log messages will be stored (enables logging)', dest='logging_file') + args = parser.parse_args() + + if args.crashreports_dir: + global _crashreports_dir + _crashreports_dir = args.crashreports_dir + if args.pid_file: + global _pid_file + _pid_file = args.pid_file + if args.interval_time: + global _interval_time + _interval_time = args.interval_time + if args.logging_file: + global _logging_file + _logging_file = args.logging_file + + +def log(): + """Turns on or off the logging facility.""" + global _logging_file + if _logging_file: + logging.basicConfig(level=logging.DEBUG, filename=_logging_file, + format='%(asctime)s %(funcName)s() %(levelname)s: %(message)s', + datefmt='%Y-%m-%d %H:%M:%S') + + def main(): - # The infinite loop of the daemon - interval = 10 - crashreports_dir = '/var/spool/crashreports' - extraction_dir = '/tmp/crashreports' - counter = 1 + """The infinite loop of the daemon. + + It is the starting point of the program when it is invoked directly. Here + lives the infinite loop that checks the directory that crash reports arrive + in the server. For every new crash report, a number of actions are executed. + """ + parse_arguments() + log() create_pid_file() while True: - print "== Pass: " + counter + " ==" - dirlist = os.listdir(crashreports_dir) + dirlist = os.listdir(_crashreports_dir) for filename in dirlist: - print "Report: " + filename - check_report(filename) - counter += 1 - time.sleep(interval) + report = _crashreports_dir + '/' + filename + check_report(report) + time.sleep(_interval_time) if __name__ == '__main__': - main() \ No newline at end of file + main() + +#def extract_report(filename): +# if not os.path.isdir(extraction_dir): +# logging.debug() +# return False +# +# try: +# tarfile_obj = tarfile.open(report, 'r:gz') +# tarfile_obj.extractall(extraction_dir); +# except ReadError: +# logging.debug() +# return +# except CompressionError: +# logging.debug() +# return +# +# dirlist = os.listdir(extraction_dir) +# if not len(dirlist) == 1: +# logging.debug() +# return False +# +# data_name = dirlist[0] +# #print "data_name: ", data_name +# +# return True \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Sat Jul 21 19:32:39 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id BA30C106566C for ; Sat, 21 Jul 2012 19:32:37 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 21 Jul 2012 19:32:37 +0000 Date: Sat, 21 Jul 2012 19:32:37 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120721193237.BA30C106566C@hub.freebsd.org> Cc: Subject: socsvn commit: r239645 - in soc2012/aleek/beaglexm-armv6/sys: arm/conf boot/fdt/dts X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 19:32:39 -0000 Author: aleek Date: Sat Jul 21 19:32:37 2012 New Revision: 239645 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239645 Log: usb initial for bb-xm Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sat Jul 21 14:59:43 2012 (r239644) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sat Jul 21 19:32:37 2012 (r239645) @@ -82,7 +82,7 @@ device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" +options ROOTDEVNAME=\"msdosfs:mmcsd0s3\" # Console and misc Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sat Jul 21 14:59:43 2012 (r239644) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sat Jul 21 19:32:37 2012 (r239645) @@ -166,6 +166,16 @@ reg = <0x24>; }; }; + + ehci { + compatible = "ti, ehci", "usb-ehci"; + reg = < 0x48064800 0x400 /* EHCI */ + 0x48064000 0x400 /* UHH */ + 0x48062000 0x1000 /* TLL */ > + interrupts = < 77 >; + interrupt-parent = <&AINTC>; + }; + }; chosen { From owner-svn-soc-all@FreeBSD.ORG Sat Jul 21 20:52:23 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id A8EB4106564A for ; Sat, 21 Jul 2012 20:52:21 +0000 (UTC) (envelope-from jhagewood@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 21 Jul 2012 20:52:21 +0000 Date: Sat, 21 Jul 2012 20:52:21 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120721205221.A8EB4106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r239647 - in soc2012/jhagewood/diff3: . diff3 X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 20:52:23 -0000 Author: jhagewood Date: Sat Jul 21 20:52:20 2012 New Revision: 239647 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239647 Log: Changed executable name in diff3's man file Modified: soc2012/jhagewood/diff3/TODO soc2012/jhagewood/diff3/diff3/diff3.1 soc2012/jhagewood/diff3/diff3/diff3prog.c soc2012/jhagewood/diff3/hagewood-diff3.patch Modified: soc2012/jhagewood/diff3/TODO ============================================================================== --- soc2012/jhagewood/diff3/TODO Sat Jul 21 19:46:14 2012 (r239646) +++ soc2012/jhagewood/diff3/TODO Sat Jul 21 20:52:20 2012 (r239647) @@ -3,7 +3,7 @@ --merge INCOMPLETE --label INCOMPLETE --strip-trailing-cr COMPLETE ---diff-program INCOMPLETE +--diff-program INCOMPLETE Pipe to diff process Fixed binary detection COMPLETE Test script COMPLETE Pipe to diff INCOMPLETE Modified: soc2012/jhagewood/diff3/diff3/diff3.1 ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3.1 Sat Jul 21 19:46:14 2012 (r239646) +++ soc2012/jhagewood/diff3/diff3/diff3.1 Sat Jul 21 20:52:20 2012 (r239647) @@ -173,7 +173,7 @@ temporary file .It Pa /tmp/d3b.XXXXXXXXXX temporary file -.It Pa /usr/libexec/diff3prog +.It Pa /usr/libexec/diff3 the actual executable .El .Sh SEE ALSO Modified: soc2012/jhagewood/diff3/diff3/diff3prog.c ============================================================================== --- soc2012/jhagewood/diff3/diff3/diff3prog.c Sat Jul 21 19:46:14 2012 (r239646) +++ soc2012/jhagewood/diff3/diff3/diff3prog.c Sat Jul 21 20:52:20 2012 (r239647) @@ -132,7 +132,7 @@ * is stored in last[1-3]; */ int last[4]; -int aflag, Aflag, eflag, iflag, Tflag; +int aflag, Aflag, eflag, iflag, mflag, Tflag; int oflag; /* indicates whether to mark overlaps (-E or -X)*/ int strip_cr; int debug = 0; @@ -219,6 +219,11 @@ i = i <= 2 ? i : 2 ; labels[i] = optarg; break; + case 'm': + Aflag = 1; + eflag = 0; + mflag = 1; + break; case 'T': Tflag = 1; break; @@ -289,7 +294,7 @@ fp[0] = fopen(name, "r"); if (fp[0] == NULL) - err(EXIT_FAILURE, "can't open %s", name); + err(EXIT_FAILURE, "Can't open %s", name); for (i=0; (p = getchange(fp[0])); i++) { if (i >= szchanges - 1) increase(); @@ -399,7 +404,7 @@ /* first file is different from others */ if (!t2 || (t1 && d1->new.to < d2->new.from)) { /* stuff peculiar to 1st file */ - if (eflag==0) { + if (eflag == 0) { separate("1"); change(1, &d1->old, 0); keep(2, &d1->new); @@ -410,7 +415,7 @@ } /* second file is different from others */ if (!t1 || (t2 && d2->new.to < d1->new.from)) { - if (eflag==0) { + if (eflag == 0) { separate("2"); keep(1, &d2->new); change(2, &d2->old, 0); @@ -444,7 +449,7 @@ * dup = 0 means all files differ * dup = 1 means files 1 and 2 identical */ - if (eflag==0) { + if (eflag == 0) { separate(dup ? "3" : ""); change(1, &d1->old, dup); change(2, &d2->old, 0); Modified: soc2012/jhagewood/diff3/hagewood-diff3.patch ============================================================================== --- soc2012/jhagewood/diff3/hagewood-diff3.patch Sat Jul 21 19:46:14 2012 (r239646) +++ soc2012/jhagewood/diff3/hagewood-diff3.patch Sat Jul 21 20:52:20 2012 (r239647) @@ -15,9 +15,21 @@ + ${.CURDIR}/diff3.sh ${DESTDIR}/usr/bin/diff3 .include +diff -rupN jhagewood/diff3/diff3-orig/diff3.1 jhagewood/diff3/diff3/diff3.1 +--- jhagewood/diff3/diff3-orig/diff3.1 2012-07-19 17:32:16.000000000 -0400 ++++ jhagewood/diff3/diff3/diff3.1 2012-07-21 20:49:56.000000000 -0400 +@@ -173,7 +173,7 @@ as the temporary directory. + temporary file + .It Pa /tmp/d3b.XXXXXXXXXX + temporary file +-.It Pa /usr/libexec/diff3prog ++.It Pa /usr/libexec/diff3 + the actual executable + .El + .Sh SEE ALSO diff -rupN jhagewood/diff3/diff3-orig/diff3prog.c jhagewood/diff3/diff3/diff3prog.c --- jhagewood/diff3/diff3-orig/diff3prog.c 2012-07-19 17:32:16.000000000 -0400 -+++ jhagewood/diff3/diff3/diff3prog.c 2012-07-20 03:04:16.000000000 -0400 ++++ jhagewood/diff3/diff3/diff3prog.c 2012-07-21 20:48:17.000000000 -0400 @@ -64,19 +64,23 @@ * @(#)diff3.c 8.1 (Berkeley) 6/6/93 */ @@ -49,7 +61,7 @@ #include #include -@@ -124,7 +128,7 @@ int cline[3]; /* # of the last-read lin +@@ -124,41 +128,45 @@ int cline[3]; /* # of the last-read lin char *diff_prog = NULL; char *labels[3] = {NULL}; /* @@ -58,7 +70,10 @@ * is stored in last[1-3]; */ int last[4]; -@@ -134,31 +138,35 @@ int strip_cr; +-int aflag, Aflag, eflag, iflag, Tflag; ++int aflag, Aflag, eflag, iflag, mflag, Tflag; + int oflag; /* indicates whether to mark overlaps (-E or -X)*/ + int strip_cr; int debug = 0; char f1mark[40], f2mark[40], f3mark[40]; /* markers for -E and -X */ @@ -144,7 +159,18 @@ eflag = 0; oflag = 0; -@@ -216,12 +225,18 @@ main(int argc, char **argv) +@@ -210,18 +219,29 @@ main(int argc, char **argv) + i = i <= 2 ? i : 2 ; + labels[i] = optarg; + break; ++ case 'm': ++ Aflag = 1; ++ eflag = 0; ++ mflag = 1; ++ break; + case 'T': + Tflag = 1; + break; case 'X': oflag = eflag = 1; break; @@ -163,7 +189,7 @@ case STRIPCR_OPT: strip_cr = 1; break; -@@ -232,10 +247,8 @@ main(int argc, char **argv) +@@ -232,10 +252,8 @@ main(int argc, char **argv) } argc -= optind; argv += optind; @@ -175,7 +201,7 @@ if (oflag) { (void)snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", labels[0] != NULL ? labels[0] : -@@ -247,13 +260,16 @@ main(int argc, char **argv) +@@ -247,13 +265,16 @@ main(int argc, char **argv) labels[2] != NULL ? labels[2] : argc >= 7 ? argv[6] : argv[4]); } @@ -196,7 +222,7 @@ } merge(m, n); exit(EXIT_SUCCESS); -@@ -265,7 +281,7 @@ main(int argc, char **argv) +@@ -265,7 +286,7 @@ main(int argc, char **argv) * since the vector is processed in one sequential pass. * The vector could be optimized out of existence) */ @@ -205,7 +231,16 @@ readin(char *name, struct diff **dd) { int a, b, c, d, i; -@@ -307,17 +323,18 @@ readin(char *name, struct diff **dd) +@@ -273,7 +294,7 @@ readin(char *name, struct diff **dd) + + fp[0] = fopen(name, "r"); + if (fp[0] == NULL) +- err(EXIT_FAILURE, "can't open %s", name); ++ err(EXIT_FAILURE, "Can't open %s", name); + for (i=0; (p = getchange(fp[0])); i++) { + if (i >= szchanges - 1) + increase(); +@@ -307,17 +328,18 @@ readin(char *name, struct diff **dd) return (i); } @@ -226,7 +261,7 @@ getchange(FILE *b) { char *line; -@@ -329,7 +346,7 @@ getchange(FILE *b) +@@ -329,7 +351,7 @@ getchange(FILE *b) return (NULL); } @@ -235,7 +270,7 @@ getline(FILE *b, size_t *n) { char *cp; -@@ -357,7 +374,7 @@ getline(FILE *b, size_t *n) +@@ -357,7 +379,7 @@ getline(FILE *b, size_t *n) return (buf); } @@ -244,7 +279,7 @@ merge(int m1, int m2) { struct diff *d1, *d2, *d3; -@@ -367,8 +384,7 @@ merge(int m1, int m2) +@@ -367,8 +389,7 @@ merge(int m1, int m2) d2 = d23; j = 0; @@ -254,7 +289,34 @@ printf("Binary file detected; comparison failed\n"); exit(EXIT_FAILURE); } -@@ -464,31 +480,29 @@ merge(int m1, int m2) +@@ -383,7 +404,7 @@ merge(int m1, int m2) + /* first file is different from others */ + if (!t2 || (t1 && d1->new.to < d2->new.from)) { + /* stuff peculiar to 1st file */ +- if (eflag==0) { ++ if (eflag == 0) { + separate("1"); + change(1, &d1->old, 0); + keep(2, &d1->new); +@@ -394,7 +415,7 @@ merge(int m1, int m2) + } + /* second file is different from others */ + if (!t1 || (t2 && d2->new.to < d1->new.from)) { +- if (eflag==0) { ++ if (eflag == 0) { + separate("2"); + keep(1, &d2->new); + change(2, &d2->old, 0); +@@ -428,7 +449,7 @@ merge(int m1, int m2) + * dup = 0 means all files differ + * dup = 1 means files 1 and 2 identical + */ +- if (eflag==0) { ++ if (eflag == 0) { + separate(dup ? "3" : ""); + change(1, &d1->old, dup); + change(2, &d2->old, 0); +@@ -464,31 +485,29 @@ merge(int m1, int m2) } static int @@ -263,12 +325,12 @@ { - wint_t ch = L'\0'; - size_t i; -- -- if (aflag || f == NULL) -- return (1); + int i, check_size; + char ch; +- if (aflag || f == NULL) +- return (1); +- - rewind(f); - errno = 0; - for (i = 0; i <= BUFSIZ; i++) { @@ -303,7 +365,7 @@ printf("====%s\n", s); } -@@ -497,9 +511,10 @@ separate(const char *s) +@@ -497,9 +516,10 @@ separate(const char *s) * It is to be printed only if it does not duplicate something to be * printed later. */ @@ -315,7 +377,7 @@ printf("%d:", i); last[i] = rold->to; prange(rold); -@@ -510,12 +525,14 @@ change(int i, struct range *rold, int du +@@ -510,12 +530,14 @@ change(int i, struct range *rold, int du (void)skip(i, rold->to, " "); } @@ -333,7 +395,7 @@ if (rold->to <= rold->from) printf("%da\n", rold->from - 1); else { -@@ -531,7 +548,7 @@ prange(struct range *rold) +@@ -531,7 +553,7 @@ prange(struct range *rold) * and an artificial dummy difference (trange) must be ginned up to * correspond to the change reported in the other file. */ @@ -342,7 +404,7 @@ keep(int i, struct range *rnew) { int delta; -@@ -547,7 +564,7 @@ keep(int i, struct range *rnew) +@@ -547,7 +569,7 @@ keep(int i, struct range *rnew) * skip to just before line number from in file "i". If "pr" is non-NULL, * print all skipped stuff with string pr as a prefix. */ @@ -351,7 +413,7 @@ skip(int i, int from, char *pr) { size_t j, n; -@@ -558,7 +575,6 @@ skip(int i, int from, char *pr) +@@ -558,7 +580,6 @@ skip(int i, int from, char *pr) trouble(); if (pr != NULL) printf("%s%s", Tflag == 1? "\t" : pr, line); @@ -359,7 +421,7 @@ cline[i]++; } return ((int) n); -@@ -568,10 +584,10 @@ skip(int i, int from, char *pr) +@@ -568,10 +589,10 @@ skip(int i, int from, char *pr) * Return 1 or 0 according as the old range (in file 1) contains exactly * the same data as the new range (in file 2). */ @@ -372,7 +434,7 @@ int nchar; int nline; -@@ -597,7 +613,7 @@ duplicate(struct range *r1, struct range +@@ -597,7 +618,7 @@ duplicate(struct range *r1, struct range return (1); } @@ -381,7 +443,7 @@ repos(int nchar) { int i; -@@ -606,18 +622,43 @@ repos(int nchar) +@@ -606,18 +627,43 @@ repos(int nchar) (void)fseek(fp[i], (long)-nchar, SEEK_CUR); } @@ -427,7 +489,7 @@ if (((dup + 1) & eflag) == 0) return (j); j++; -@@ -632,10 +673,10 @@ edit(struct diff *diff, int dup, int j) +@@ -632,10 +678,10 @@ edit(struct diff *diff, int dup, int j) } /* regurgitate */ @@ -440,7 +502,7 @@ char block[BUFSIZ]; for (n = n; n > 0; n--) { -@@ -657,14 +698,13 @@ edscript(int n) +@@ -657,14 +703,13 @@ edscript(int n) printf("%da\n%s\n.\n", de[n].old.from - 1, f1mark); } } @@ -457,7 +519,7 @@ increase(void) { struct diff *p; -@@ -698,13 +738,29 @@ increase(void) +@@ -698,13 +743,29 @@ increase(void) szchanges = newsz; } From owner-svn-soc-all@FreeBSD.ORG Sat Jul 21 21:53:06 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 7E1BE10657A1 for ; Sat, 21 Jul 2012 21:53:04 +0000 (UTC) (envelope-from aleek@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sat, 21 Jul 2012 21:53:04 +0000 Date: Sat, 21 Jul 2012 21:53:04 +0000 From: aleek@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120721215304.7E1BE10657A1@hub.freebsd.org> Cc: Subject: socsvn commit: r239648 - in soc2012/aleek/beaglexm-armv6/sys: arm/conf arm/ti/am37x arm/ti/usb boot/fdt/dts X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 21:53:06 -0000 Author: aleek Date: Sat Jul 21 21:53:03 2012 New Revision: 239648 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239648 Log: probing usb driver for bb-xm Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/files.am37x soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Modified: soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sat Jul 21 20:52:20 2012 (r239647) +++ soc2012/aleek/beaglexm-armv6/sys/arm/conf/BEAGLEBOARD-XM Sat Jul 21 21:53:03 2012 (r239648) @@ -82,7 +82,7 @@ device mmcsd # mmc/sd flash cards # Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"msdosfs:mmcsd0s3\" +options ROOTDEVNAME=\"msdosfs:mmcsd0s2\" # Console and misc @@ -103,14 +103,15 @@ device gpio # USB support -#device usb -#options USB_DEBUG -#options USB_REQ_DEBUG -#options USB_VERBOSE -#device musb -#device umass -#device scbus # SCSI bus (required for SCSI) -#device da # Direct Access (disks) +device usb +options USB_DEBUG +options USB_REQ_DEBUG +options USB_VERBOSE +device musb +device ehci +device umass +device scbus # SCSI bus (required for SCSI) +device da # Direct Access (disks) # Ethernet device loop Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/files.am37x ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/files.am37x Sat Jul 21 20:52:20 2012 (r239647) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/am37x/files.am37x Sat Jul 21 21:53:03 2012 (r239648) @@ -5,6 +5,7 @@ arm/ti/am37x/am37x_gptimer_tc.c standard arm/ti/am37x/am37x_scm_padconf.c standard arm/ti/ti_sdma.c standard +arm/ti/am37x/am37x_early_uart.c standard arm/ti/ti_mmchs.c optional mmc arm/ti/cpsw/if_cpsw.c optional cpsw -arm/ti/am37x/am37x_early_uart.c standard +arm/ti/usb/omap_ehci.c optional usb Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sat Jul 21 20:52:20 2012 (r239647) +++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Sat Jul 21 21:53:03 2012 (r239648) @@ -742,9 +742,11 @@ static int omap_ehci_probe(device_t dev) { - if (!ofw_bus_is_compatible(dev, "ti,usb-ehci")) + device_printf( dev, "probing!\n\n" ); + if (!ofw_bus_is_compatible(dev, "ti,ehci")) return (ENXIO); + device_printf( dev, "probed!!!\n\n" ); device_set_desc(dev, OMAP_EHCI_HC_DEVSTR); return (BUS_PROBE_DEFAULT); @@ -778,6 +780,8 @@ int len, tuple_size; int i; + device_printf( dev, "%s:%d\n", __FUNCTION__, __LINE__ ); + /* initialise some bus fields */ sc->sc_bus.parent = dev; sc->sc_bus.devices = sc->sc_devices; Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts ============================================================================== --- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sat Jul 21 20:52:20 2012 (r239647) +++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Sat Jul 21 21:53:03 2012 (r239648) @@ -167,11 +167,11 @@ }; }; - ehci { - compatible = "ti, ehci", "usb-ehci"; + ehci@48064800 { + compatible = "ti, ehci"; reg = < 0x48064800 0x400 /* EHCI */ 0x48064000 0x400 /* UHH */ - 0x48062000 0x1000 /* TLL */ > + 0x48062000 0x1000 /* TLL */ >; interrupts = < 77 >; interrupt-parent = <&AINTC>; };