fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid copybmp(char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* don't update cfg information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc == 1 || (argc%2) == 0) /* must have pairs of filenames */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki gettext("\tiicpbmp [-c] old_bitmap new_bitmap\n"));
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr, gettext("Both old and new bitmap "
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki "file names must begin with a /.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (update_cfg && find_bitmap_cfg(old_bitmap) == 0) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(args.shadow_vol, shadow, DSW_NAMELEN);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr, gettext("Suspend the Point-in-Time Copy "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "set first\n"));
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr, gettext("Can't open old bitmap file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check old header looks like an Point-in-Time Copy bitmap header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fread(&header, sizeof (header), 1, ifp) != 1) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr, gettext("Can't read old bitmap file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (header.ii_magic != DSW_CLEAN && header.ii_magic != DSW_DIRTY) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr, gettext("%s is not a Point-in-Time Copy "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(header.bitmap_vol, old_bitmap, DSW_NAMELEN) != 0) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki "%s has Point-in-Time Copy bitmap magic number,\n"
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki "but does not contain correct data.\n"), old_bitmap);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr, gettext("Can't open new bitmap file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set up new header */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) memset(header.bitmap_vol, 0, DSW_NAMELEN);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(header.bitmap_vol, new_bitmap, DSW_NAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fwrite(&header, sizeof (header), 1, ofp) != 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy the bitmap itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((i = fread(cp_buffer, sizeof (char), sizeof (cp_buffer), ifp))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fwrite(cp_buffer, sizeof (char), i, ofp) != i) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(key, "ii.set%d.bitmap", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, key, new_bitmap, strlen(new_bitmap))
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki "iicpbmp copy bit map for %s from %s to %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find_bitmap_cfg()
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) snprintf(key, sizeof (key), "ii.set%d.bitmap",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, DSW_NAMELEN) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) snprintf(key, sizeof (key), "ii.set%d.shadow",