From owner-p4-projects@FreeBSD.ORG Thu Nov 1 21:50:42 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BE2B016A475; Thu, 1 Nov 2007 21:50:42 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E469116A421 for ; Thu, 1 Nov 2007 21:50:41 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D12B813C4B5 for ; Thu, 1 Nov 2007 21:50:41 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lA1Lofpl023967 for ; Thu, 1 Nov 2007 21:50:41 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lA1Lof9v023964 for perforce@freebsd.org; Thu, 1 Nov 2007 21:50:41 GMT (envelope-from zec@FreeBSD.org) Date: Thu, 1 Nov 2007 21:50:41 GMT Message-Id: <200711012150.lA1Lof9v023964@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 128481 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2007 21:50:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=128481 Change 128481 by zec@zec_tpx32 on 2007/11/01 21:50:14 "vimage -l" now lists only direct children vimages, while "vimage -lr" traverses the entire hierarchy bellow the current position. Affected files ... .. //depot/projects/vimage/src/sys/kern/kern_vimage.c#55 edit .. //depot/projects/vimage/src/sys/sys/vimage.h#50 edit .. //depot/projects/vimage/src/usr.sbin/vimage/vimage.c#8 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#55 (text+ko) ==== @@ -503,19 +503,21 @@ static struct vimage * -vimage_get_next(struct vimage *top, struct vimage *where) +vimage_get_next(struct vimage *top, struct vimage *where, int recurse) { struct vimage *next; - /* Try to go deeper in the hierarchy */ - next = LIST_FIRST(&where->vi_child_head); - if (next != NULL) - return(next); + if (recurse) { + /* Try to go deeper in the hierarchy */ + next = LIST_FIRST(&where->vi_child_head); + if (next != NULL) + return(next); + } do { /* Try to find next sibling */ next = LIST_NEXT(where, vi_sibling); - if (next != NULL) + if (!recurse || next != NULL) return(next); /* Nothing left on this level, go one level up */ @@ -547,12 +549,17 @@ if (vip_r != NULL && vi_req->req_action & VI_CREATE) return (EADDRINUSE); if (vi_req->req_action == VI_GETNEXT) { - vip_r = vimage_get_next(vip, vip_r); + vip_r = vimage_get_next(vip, vip_r, 0); + if (vip_r == NULL) + return (ESRCH); + } + if (vi_req->req_action == VI_GETNEXT_RECURSE) { + vip_r = vimage_get_next(vip, vip_r, 1); if (vip_r == NULL) return (ESRCH); } - if (vip_r && !vi_child_of(vip, vip_r) && /* XXX delete the rest! */ + if (vip_r && !vi_child_of(vip, vip_r) && /* XXX delete the rest? */ vi_req->req_action != VI_GET && vi_req->req_action != VI_GETNEXT) return (EPERM); ==== //depot/projects/vimage/src/sys/sys/vimage.h#50 (text+ko) ==== @@ -483,6 +483,7 @@ #define VI_GET 0x00000100 #define VI_GETNEXT 0x00000200 +#define VI_GETNEXT_RECURSE 0x00000300 #define VI_SET_CPU_MIN 0x00001000 #define VI_SET_CPU_MAX 0x00002000 ==== //depot/projects/vimage/src/usr.sbin/vimage/vimage.c#8 (text+ko) ==== @@ -128,7 +128,12 @@ if (argc == 2 && strcmp(argv[1], "-l") == 0) { strcpy(vi_req.vi_name, "."); - cmd = VI_GETNEXT; /* here this means walk! */ + cmd = VI_GETNEXT; + } + + if (argc == 2 && strcmp(argv[1], "-lr") == 0) { + strcpy(vi_req.vi_name, "."); + cmd = VI_GETNEXT_RECURSE; } if (argc == 3) { @@ -164,13 +169,16 @@ exit(0); case VI_GETNEXT: + case VI_GETNEXT_RECURSE: vi_req.req_action = VI_GET; if (ioctl(s, SIOCGPVIMAGE, (caddr_t)&vi_req) < 0) goto abort; vi_print(&vi_req); - vi_req.req_action = VI_GETNEXT; - while (ioctl(s, SIOCGPVIMAGE, (caddr_t)&vi_req) == 0) + vi_req.req_action = VI_GETNEXT_RECURSE; + while (ioctl(s, SIOCGPVIMAGE, (caddr_t)&vi_req) == 0) { vi_print(&vi_req); + vi_req.req_action = cmd; + } exit(0); case VI_IFACE: