From owner-p4-projects@FreeBSD.ORG Mon Aug 8 06:48:56 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 95FA816A421; Mon, 8 Aug 2005 06:48:55 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 574CC16A41F for ; Mon, 8 Aug 2005 06:48:55 +0000 (GMT) (envelope-from soc-cjones@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 18C0443D45 for ; Mon, 8 Aug 2005 06:48:55 +0000 (GMT) (envelope-from soc-cjones@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j786msEF088895 for ; Mon, 8 Aug 2005 06:48:54 GMT (envelope-from soc-cjones@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j786msem088892 for perforce@freebsd.org; Mon, 8 Aug 2005 06:48:54 GMT (envelope-from soc-cjones@freebsd.org) Date: Mon, 8 Aug 2005 06:48:54 GMT Message-Id: <200508080648.j786msem088892@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-cjones@freebsd.org using -f From: soc-cjones To: Perforce Change Reviews Cc: Subject: PERFORCE change 81632 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: Mon, 08 Aug 2005 06:48:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=81632 Change 81632 by soc-cjones@soc-cjones_ishtar on 2005/08/08 06:48:06 Renaming volumes now works, both recursively and non-. Next up, drives, subdisks, and plexes. Affected files ... .. //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_rename.c#3 edit Differences ... ==== //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_rename.c#3 (text+ko) ==== @@ -180,11 +180,58 @@ int err; struct gv_plex *p; struct gv_sd *s; + char oldvolname[GV_MAXVOLNAME]; + char oldplexname[GV_MAXPLEXNAME]; g_topology_assert(); KASSERT(d != NULL, ("gv_rename_vol: NULL v")); - printf("gv_rename_vol:\n"); + printf("gv_rename_vol: flags = %x\n", flags); + + /* Rename the volume. We need to hold on to the old volume name. */ + strncpy(oldvolname, v->name, GV_MAXVOLNAME); + printf("Renaming volume %s to %s\n", v->name, newname); + strncpy(v->name, newname, GV_MAXVOLNAME); + + /* Rename the associated plexes. For each plex, iterate across + list of all subdisks and check to see if its plex is the one + we're renaming. Yes, this is icky and O(N_{plexes} x N_{sds}), + but it works. */ + + LIST_FOREACH(p, &sc->plexes, plex) { + if (!strncmp(p->volume, oldvolname, GV_MAXVOLNAME)) { + strncpy(p->volume, v->name, GV_MAXVOLNAME); + if (flags && GV_FLAG_R) { + char plexnumber[GV_MAXPLEXNAME]; + char *pplexnumber = plexnumber; + printf("Modifying plex %s, p->volume = %s\n", p->name, p->volume); + strncpy(oldplexname, p->name, GV_MAXPLEXNAME); + strncpy(plexnumber, p->name, GV_MAXPLEXNAME); + strsep(&pplexnumber, "."); + printf("Renaming plex %s to %s.%s\n", p->name, v->name, pplexnumber); + snprintf(p->name, GV_MAXPLEXNAME, "%s.%s", v->name, pplexnumber); + LIST_FOREACH(s, &sc->subdisks, sd) { + if (!strncmp(s->plex, oldplexname, GV_MAXPLEXNAME)) { + char sdnumber[GV_MAXSDNAME]; + char *psdnumber = sdnumber; + printf("Modifying subdisk %s, s->plex = %s\n", s->name, s->plex); + strncpy(sdnumber, s->name, GV_MAXSDNAME); + strsep(&psdnumber, "."); + strsep(&psdnumber, "."); + printf("Renaming subdisk %s to %s.%s\n", s->name, p->name, psdnumber); + snprintf(s->name, GV_MAXSDNAME, "%s.%s", p->name, psdnumber); + strncpy(s->plex, p->name, GV_MAXPLEXNAME); + } else { + printf("Ignoring subdisk %s, s->plex = %s\n", s->name, s->plex); + } + } + } + } else { + printf("Ignoring plex %s, p->volume = %s\n", p->name, p->volume); + } + } + + printf("Debugging output:\n"); printf("\tsc = %p\n", sc); printf("\treq = %p\n", req); printf("\tv = %p\n", v); @@ -193,23 +240,25 @@ printf("\t\tv->plexcount = %d\n", v->plexcount); printf("\tnewname = \"%s\"\n", newname); printf("\tflags = %x\n", flags); - - printf("iterating across plexes list...\n"); - LIST_FOREACH(p, &v->plexes, plex) { - if (strcmp(p->volume, v->name)) { - continue; /* Not a plex we're looking for. */ + + LIST_FOREACH(p, &sc->plexes, plex) { + if (!strncmp(p->volume, v->name, GV_MAXVOLNAME)) { + printf("\tp->name = %s\n", p->name); + printf("\tp->size = %d\n", (int) p->size); + printf("\tp->volume = %s\n", p->volume); + printf("\tp->sdcount = %d\n", p->sdcount); + printf("\tp->sddown = %d\n", p->sddown); + LIST_FOREACH(s, &sc->subdisks, sd) { + if (!strncmp(s->plex, p->name, GV_MAXPLEXNAME)) { + printf("\t\ts->name = %s\n", s->name); + printf("\t\ts->size = %d\n", (int) s->size); + printf("\t\ts->drive = %s\n", s->drive); + printf("\t\ts->plex = %s\n", s->plex); + } + } } - printf("\tp->name = %s\n", p->name); - printf("\tp->size = %d\n", (int) p->size); - printf("\tp->volume = %s\n", p->volume); -/* LIST_FOREACH(s, &p->subdisks, sd) { - printf("\t\ts->name = %s\n", s->name); - printf("\t\ts->size = %d\n", (int) s->size); - printf("\t\ts->drive = %s\n", s->drive); - printf("\t\ts->plex = %s\n", s->plex); - } */ } + printf("\n\n"); return (0); - }