Date: Thu, 1 Nov 2007 21:50:41 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 128481 for review Message-ID: <200711012150.lA1Lof9v023964@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711012150.lA1Lof9v023964>