Date: Mon, 26 Nov 2007 07:41:24 GMT From: Zhouyi ZHOU <zhouzhouyi@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 129551 for review Message-ID: <200711260741.lAQ7fOxk005962@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=129551 Change 129551 by zhouzhouyi@zhouzhouyi_mactest on 2007/11/26 07:41:00 set limit for the log Affected files ... .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/pipe_io.c#3 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test.c#14 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test_log.c#9 edit Differences ... ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/pipe_io.c#3 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/tools/regression/mactest/pipe_io.c,v 1.6 2006/11/07 23:28:30 jkim Exp $ + * $FreeBSD$ */ #include <sys/types.h> @@ -45,8 +45,6 @@ #include <unistd.h> #include "mactest.h" -#define BEGINLOG _IO('m',1) -int logfd; static void usage(void) @@ -130,7 +128,7 @@ fprintf(stderr, "too few arguments\n"); usage(); } - logfd = open("/dev/mactest", O_RDWR); + logfd = open(LOGDEV, O_RDWR); ioctl(logfd, BEGINLOG, NULL); if (pipe(fd) < 0) { @@ -160,6 +158,9 @@ } mac_free(label); } + + + switch (fork()) { case -1: perror("fork"); @@ -184,9 +185,10 @@ exit(-1); } close(fd[1]); + for (;;) { - i = read(fd[0], buf, 256); /* any small size should - * do */ + i = read(fd[0], buf, 256); + if (i == 0) break; if (i < 0) { @@ -195,12 +197,15 @@ exit(1); } } + exit(0); } default: break; } + close(logfd); + { mac_t label; @@ -219,13 +224,16 @@ exit(-1); } } + + + close(fd[0]); memset(buf, 0, sizeof buf); for (i = 0; i < 2; i++) write_frame(fd[1], buf, sizeof buf); - close(logfd); + machookmatch(macconf_file, pid); ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test.c#14 (text+ko) ==== @@ -133,7 +133,8 @@ buffer = malloc(2560, M_MAC_TEST_LOG, M_NOWAIT); \ if (!buffer) \ badmem = 1; \ - bzero(buffer, 2048); \ + else \ + bzero(buffer, 2048); \ element1 = buffer + 512; buffer1 = element1 + 256; \ flagbuffer = buffer + 1024; \ submitbuffer = buffer + 1536; \ ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test_log.c#9 (text+ko) ==== @@ -85,7 +85,9 @@ static struct vnode *logvnode = 0; +static int loglength = 0; +#define LOGMAX 1000 static int mac_test_log_open(struct cdev *dev, int oflags, int devtype, struct thread *td) @@ -154,7 +156,7 @@ VOP_UNLOCK(logvnode, 0, curthread); vn_finished_write(mp); - + loglength = 0; bad: NDFREE(&nd, NDF_ONLY_PNBUF); VFS_UNLOCK_GIANT(vfslocked); @@ -204,7 +206,9 @@ if (!mac_test_can_log) return; - + if (loglength > LOGMAX) + return; + mte = malloc(sizeof(*mte), M_MAC_TEST_LOG, M_NOWAIT | M_ZERO); if (NULL == mte) { return; @@ -219,6 +223,7 @@ bcopy(record, mte->mte_record, record_len); mte->mte_record_len = record_len; mtx_lock(&mac_test_submit_mtx); + loglength++; TAILQ_INSERT_TAIL(&mac_test_log_list, mte, mte_queue); mtx_unlock(&mac_test_submit_mtx); cv_signal(&mac_test_worker_cv);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711260741.lAQ7fOxk005962>