iicpshd.c revision 570de38f63910201fdd77246630b7aa8f9dc5661
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <values.h>
#include <locale.h>
#include <strings.h>
#include <stdarg.h>
#include <nsctl.h>
#define DSW_TEXT_DOMAIN "II"
#define BITMAP_TOKEN "ii.set%d.bitmap"
#define SHADOW_TOKEN "ii.set%d.shadow"
#define DSVOL_TOKEN "dsvol.set%d.path"
void iicpshd_usage();
void copyshd(char *, char *);
int find_cfg_info(char *, char *);
int copy_shadow_vol(char *, char *);
void convert_to_blockdevice();
int update_dscfg(char *);
extern int optind;
extern char *optarg;
int copy_shadow = 1;
char real_bitmap[DSW_NAMELEN];
char buf[CFG_MAX_BUF];
char key[CFG_MAX_KEY];
int set_number;
int sv_number;
int dsvol_number;
#ifdef lint
int
#else
int
#endif
{
if (argc > 1) {
/* don't copy shadow, only update dscfg and ii header */
copy_shadow = 0;
argc--;
argv++;
}
}
/* open dscfg anyway */
exit(1);
}
/* close dscfg */
exit(0);
return (0);
}
void
{
gettext("\tiicpshd [-s] old_shadow new_shadow\n"));
exit(1);
}
void
{
int dsw_fd;
/*LINTED pointer alignment*/
if (dsw_fd < 0) {
exit(1);
}
"file names must begin with a /.\n"));
exit(1);
}
gettext("New shadow name is to long.\n"));
exit(1);
}
/* check old shadow is in dscfg */
gettext("Old shadow not in existing cfg\n"));
exit(1);
}
/* check ii set status, suspend if need */
"set first\n"));
exit(1);
}
if (copy_shadow) {
exit(1);
}
}
gettext("Old shadow not in existing cfg\n"));
exit(1);
}
gettext("Old shadow not in existing cfg\n"));
exit(1);
}
exit(1);
}
/* use block device /dsk/ to update bitmap header */
/* open bitmap by using update mode */
exit(1);
}
/* Check old header looks like an II bitmap header */
exit(1);
}
gettext("%s is not a Point-in-Time Copy "
"shadow.\n"), old_vol);
exit(1);
}
"shadow magic number,\n"
"but does not contain correct data.\n"), old_vol);
exit(1);
}
/* reset the pointer position */
gettext("Can't write new bitmap header\n"));
exit(1);
}
if (update_dscfg(new_vol) == 0) {
exit(1);
} else {
"iicpshd copy shadow from %s to %s",
}
}
/*
* find_cfg_info()
*
*/
int
{
int i;
/* get read lock */
"iicpbmp CFG_RDLOCK failed, errno %d", errno);
exit(1);
}
for (i = 1; ; i++) {
return (0);
}
BITMAP_TOKEN, i);
set_number = i;
sv_number = i;
dsvol_number = i;
}
/* release read lock */
return (1);
}
}
}
int
int i;
char cp_buffer[256];
return (0);
}
return (0);
}
/* Copy the shadow vol */
> 0) {
return (0);
}
}
return (1);
}
int
update_dscfg(char *new_shadow) {
/* get write lock */
"iicpbmp CFG_WRLOCK failed, errno %d", errno);
return (0);
}
perror("cfg_put_cstring");
return (0);
}
perror("cfg_put_cstring");
return (0);
}
perror("cfg_put_cstring");
return (0);
}
(void) cfg_commit(cfg);
return (1);
}
void
int i = 0, j = 0;
while (i < len + 1) {
if (real_bitmap[i] != 'r') {
temp_string[j] = real_bitmap[i];
j++;
}
i++;
}
}