17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
217836SJohn.Forte@Sun.COM
227836SJohn.Forte@Sun.COM /*
23*11576SSurya.Prakki@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
247836SJohn.Forte@Sun.COM * Use is subject to license terms.
257836SJohn.Forte@Sun.COM */
267836SJohn.Forte@Sun.COM
277836SJohn.Forte@Sun.COM #include <sys/types.h>
287836SJohn.Forte@Sun.COM #include <sys/time.h>
297836SJohn.Forte@Sun.COM #include <errno.h>
307836SJohn.Forte@Sun.COM #include <signal.h>
317836SJohn.Forte@Sun.COM #include <stdio.h>
327836SJohn.Forte@Sun.COM #include <string.h>
337836SJohn.Forte@Sun.COM #include <fcntl.h>
347836SJohn.Forte@Sun.COM #include <stdlib.h>
357836SJohn.Forte@Sun.COM #include <unistd.h>
367836SJohn.Forte@Sun.COM #include <values.h>
377836SJohn.Forte@Sun.COM #include <locale.h>
387836SJohn.Forte@Sun.COM #include <sys/stat.h>
397836SJohn.Forte@Sun.COM #include <strings.h>
407836SJohn.Forte@Sun.COM #include <stdarg.h>
417836SJohn.Forte@Sun.COM #include <sys/param.h>
427836SJohn.Forte@Sun.COM #include <nsctl.h>
437836SJohn.Forte@Sun.COM
447836SJohn.Forte@Sun.COM #include <sys/nsctl/cfg.h>
457836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s.h>
467836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s_u.h>
477836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_errors.h>
487836SJohn.Forte@Sun.COM #include <sys/nsctl/dsw.h>
497836SJohn.Forte@Sun.COM #include <sys/nsctl/dsw_dev.h> /* for bitmap format */
507836SJohn.Forte@Sun.COM
517836SJohn.Forte@Sun.COM #define DSW_TEXT_DOMAIN "II"
527836SJohn.Forte@Sun.COM #define BITMAP_TOKEN "ii.set%d.bitmap"
537836SJohn.Forte@Sun.COM #define SHADOW_TOKEN "ii.set%d.shadow"
547836SJohn.Forte@Sun.COM #define SV_TOKEN "sv.set%d.vol"
557836SJohn.Forte@Sun.COM #define DSVOL_TOKEN "dsvol.set%d.path"
567836SJohn.Forte@Sun.COM
577836SJohn.Forte@Sun.COM void iicpshd_usage();
587836SJohn.Forte@Sun.COM void copyshd(char *, char *);
597836SJohn.Forte@Sun.COM int find_cfg_info(char *, char *);
607836SJohn.Forte@Sun.COM int copy_shadow_vol(char *, char *);
617836SJohn.Forte@Sun.COM void convert_to_blockdevice();
627836SJohn.Forte@Sun.COM int update_dscfg(char *);
637836SJohn.Forte@Sun.COM
647836SJohn.Forte@Sun.COM extern int optind;
657836SJohn.Forte@Sun.COM
667836SJohn.Forte@Sun.COM extern char *optarg;
677836SJohn.Forte@Sun.COM extern int optind, opterr, optopt;
687836SJohn.Forte@Sun.COM int copy_shadow = 1;
697836SJohn.Forte@Sun.COM CFGFILE *cfg;
707836SJohn.Forte@Sun.COM char real_bitmap[DSW_NAMELEN];
717836SJohn.Forte@Sun.COM char buf[CFG_MAX_BUF];
727836SJohn.Forte@Sun.COM char key[CFG_MAX_KEY];
737836SJohn.Forte@Sun.COM int set_number;
747836SJohn.Forte@Sun.COM int sv_number;
757836SJohn.Forte@Sun.COM int dsvol_number;
767836SJohn.Forte@Sun.COM
777836SJohn.Forte@Sun.COM #ifdef lint
787836SJohn.Forte@Sun.COM int
iicpshd_lintmain(int argc,char * argv[])797836SJohn.Forte@Sun.COM iicpshd_lintmain(int argc, char *argv[])
807836SJohn.Forte@Sun.COM #else
817836SJohn.Forte@Sun.COM int
827836SJohn.Forte@Sun.COM main(int argc, char *argv[])
837836SJohn.Forte@Sun.COM #endif
847836SJohn.Forte@Sun.COM {
857836SJohn.Forte@Sun.COM if (argc > 1) {
867836SJohn.Forte@Sun.COM if (strcmp(argv[1], "-s") == 0) {
877836SJohn.Forte@Sun.COM /* don't copy shadow, only update dscfg and ii header */
887836SJohn.Forte@Sun.COM copy_shadow = 0;
897836SJohn.Forte@Sun.COM argc--;
907836SJohn.Forte@Sun.COM argv++;
917836SJohn.Forte@Sun.COM }
927836SJohn.Forte@Sun.COM }
937836SJohn.Forte@Sun.COM
947836SJohn.Forte@Sun.COM if (argc == 1 || (argc%2) == 0) /* must have pairs of filenames */
957836SJohn.Forte@Sun.COM iicpshd_usage();
967836SJohn.Forte@Sun.COM
977836SJohn.Forte@Sun.COM /* open dscfg anyway */
987836SJohn.Forte@Sun.COM if ((cfg = cfg_open(NULL)) == NULL) {
99*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Error opening config\n"));
1007836SJohn.Forte@Sun.COM exit(1);
1017836SJohn.Forte@Sun.COM }
1027836SJohn.Forte@Sun.COM
1037836SJohn.Forte@Sun.COM for (argv++; *argv != NULL; argv += 2)
1047836SJohn.Forte@Sun.COM copyshd(argv[0], argv[1]);
1057836SJohn.Forte@Sun.COM
1067836SJohn.Forte@Sun.COM /* close dscfg */
1077836SJohn.Forte@Sun.COM cfg_close(cfg);
1087836SJohn.Forte@Sun.COM exit(0);
1097836SJohn.Forte@Sun.COM return (0);
1107836SJohn.Forte@Sun.COM }
1117836SJohn.Forte@Sun.COM
1127836SJohn.Forte@Sun.COM void
iicpshd_usage()1137836SJohn.Forte@Sun.COM iicpshd_usage()
1147836SJohn.Forte@Sun.COM {
115*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Usage:\n"));
116*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
117*11576SSurya.Prakki@Sun.COM gettext("\tiicpshd [-s] old_shadow new_shadow\n"));
1187836SJohn.Forte@Sun.COM exit(1);
1197836SJohn.Forte@Sun.COM }
1207836SJohn.Forte@Sun.COM
1217836SJohn.Forte@Sun.COM void
copyshd(char * old_vol,char * new_vol)1227836SJohn.Forte@Sun.COM copyshd(char *old_vol, char *new_vol)
1237836SJohn.Forte@Sun.COM {
1247836SJohn.Forte@Sun.COM int dsw_fd;
1257836SJohn.Forte@Sun.COM FILE *ifp;
1267836SJohn.Forte@Sun.COM char header[FBA_SIZE(1) * DSW_CBLK_FBA];
1277836SJohn.Forte@Sun.COM ii_header_t *hp;
1287836SJohn.Forte@Sun.COM dsw_stat_t args;
1297836SJohn.Forte@Sun.COM
1307836SJohn.Forte@Sun.COM /*LINTED pointer alignment*/
1317836SJohn.Forte@Sun.COM hp = (ii_header_t *)&header;
1327836SJohn.Forte@Sun.COM
1337836SJohn.Forte@Sun.COM dsw_fd = open(DSWDEV, O_RDONLY);
1347836SJohn.Forte@Sun.COM if (dsw_fd < 0) {
1357836SJohn.Forte@Sun.COM perror(DSWDEV);
1367836SJohn.Forte@Sun.COM exit(1);
1377836SJohn.Forte@Sun.COM }
1387836SJohn.Forte@Sun.COM if (*old_vol != '/' || *new_vol != '/') {
139*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Both old and new shadow "
140*11576SSurya.Prakki@Sun.COM "file names must begin with a /.\n"));
1417836SJohn.Forte@Sun.COM exit(1);
1427836SJohn.Forte@Sun.COM }
1437836SJohn.Forte@Sun.COM
1447836SJohn.Forte@Sun.COM if (strlen(new_vol) > DSW_NAMELEN) {
145*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
146*11576SSurya.Prakki@Sun.COM gettext("New shadow name is to long.\n"));
1477836SJohn.Forte@Sun.COM exit(1);
1487836SJohn.Forte@Sun.COM }
1497836SJohn.Forte@Sun.COM
1507836SJohn.Forte@Sun.COM /* check old shadow is in dscfg */
1517836SJohn.Forte@Sun.COM if (find_cfg_info(old_vol, SHADOW_TOKEN) == 0) {
152*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
153*11576SSurya.Prakki@Sun.COM gettext("Old shadow not in existing cfg\n"));
1547836SJohn.Forte@Sun.COM exit(1);
1557836SJohn.Forte@Sun.COM }
1567836SJohn.Forte@Sun.COM
1577836SJohn.Forte@Sun.COM /* check ii set status, suspend if need */
158*11576SSurya.Prakki@Sun.COM (void) strncpy(args.shadow_vol, old_vol, DSW_NAMELEN);
1597836SJohn.Forte@Sun.COM args.shadow_vol[DSW_NAMELEN-1] = '\0';
1607836SJohn.Forte@Sun.COM args.status = spcs_s_ucreate();
1617836SJohn.Forte@Sun.COM if (ioctl(dsw_fd, DSWIOC_STAT, &args) != -1) {
162*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Suspend the Point-in-Time Copy "
1637836SJohn.Forte@Sun.COM "set first\n"));
164*11576SSurya.Prakki@Sun.COM (void) close(dsw_fd);
1657836SJohn.Forte@Sun.COM exit(1);
1667836SJohn.Forte@Sun.COM }
1677836SJohn.Forte@Sun.COM
1687836SJohn.Forte@Sun.COM if (copy_shadow) {
1697836SJohn.Forte@Sun.COM if (copy_shadow_vol(old_vol, new_vol) == 0) {
1707836SJohn.Forte@Sun.COM perror(gettext("Write new shadow failed"));
171*11576SSurya.Prakki@Sun.COM (void) close(dsw_fd);
1727836SJohn.Forte@Sun.COM exit(1);
1737836SJohn.Forte@Sun.COM }
1747836SJohn.Forte@Sun.COM }
1757836SJohn.Forte@Sun.COM if (find_cfg_info(old_vol, SV_TOKEN) == 0) {
176*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
177*11576SSurya.Prakki@Sun.COM gettext("Old shadow not in existing cfg\n"));
1787836SJohn.Forte@Sun.COM exit(1);
1797836SJohn.Forte@Sun.COM }
1807836SJohn.Forte@Sun.COM if (find_cfg_info(old_vol, DSVOL_TOKEN) == 0) {
181*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
182*11576SSurya.Prakki@Sun.COM gettext("Old shadow not in existing cfg\n"));
1837836SJohn.Forte@Sun.COM exit(1);
1847836SJohn.Forte@Sun.COM }
1857836SJohn.Forte@Sun.COM if (strstr(real_bitmap, "/rdsk/") == NULL) {
186*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
187*11576SSurya.Prakki@Sun.COM gettext("%s is not a character device\n"), real_bitmap);
1887836SJohn.Forte@Sun.COM exit(1);
1897836SJohn.Forte@Sun.COM }
1907836SJohn.Forte@Sun.COM
1917836SJohn.Forte@Sun.COM /* use block device /dsk/ to update bitmap header */
1927836SJohn.Forte@Sun.COM convert_to_blockdevice();
1937836SJohn.Forte@Sun.COM
1947836SJohn.Forte@Sun.COM /* open bitmap by using update mode */
1957836SJohn.Forte@Sun.COM if ((ifp = fopen(real_bitmap, "r+")) == NULL) {
196*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Can't open bitmap file\n"));
1977836SJohn.Forte@Sun.COM exit(1);
1987836SJohn.Forte@Sun.COM }
1997836SJohn.Forte@Sun.COM
2007836SJohn.Forte@Sun.COM /* Check old header looks like an II bitmap header */
2017836SJohn.Forte@Sun.COM if (fread(&header, DSW_CBLK_FBA, FBA_SIZE(1), ifp) != FBA_SIZE(1)) {
202*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Can't read bitmap file\n"));
2037836SJohn.Forte@Sun.COM exit(1);
2047836SJohn.Forte@Sun.COM }
2057836SJohn.Forte@Sun.COM
2067836SJohn.Forte@Sun.COM if (hp->ii_magic != DSW_CLEAN && hp->ii_magic != DSW_DIRTY) {
207*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
208*11576SSurya.Prakki@Sun.COM gettext("%s is not a Point-in-Time Copy "
2097836SJohn.Forte@Sun.COM "shadow.\n"), old_vol);
2107836SJohn.Forte@Sun.COM exit(1);
2117836SJohn.Forte@Sun.COM }
2127836SJohn.Forte@Sun.COM
2137836SJohn.Forte@Sun.COM if (strncmp(hp->shadow_vol, old_vol, DSW_NAMELEN) != 0) {
214*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("%s has Point-in-Time Copy "
215*11576SSurya.Prakki@Sun.COM "shadow magic number,\n"
216*11576SSurya.Prakki@Sun.COM "but does not contain correct data.\n"), old_vol);
2177836SJohn.Forte@Sun.COM exit(1);
2187836SJohn.Forte@Sun.COM }
2197836SJohn.Forte@Sun.COM
220*11576SSurya.Prakki@Sun.COM (void) memset(hp->shadow_vol, 0, DSW_NAMELEN);
221*11576SSurya.Prakki@Sun.COM (void) strncpy(hp->shadow_vol, new_vol, DSW_NAMELEN);
2227836SJohn.Forte@Sun.COM
2237836SJohn.Forte@Sun.COM /* reset the pointer position */
2247836SJohn.Forte@Sun.COM rewind(ifp);
2257836SJohn.Forte@Sun.COM if (fwrite(&header, DSW_CBLK_FBA, FBA_SIZE(1), ifp) != FBA_SIZE(1)) {
2267836SJohn.Forte@Sun.COM perror(new_vol);
227*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr,
228*11576SSurya.Prakki@Sun.COM gettext("Can't write new bitmap header\n"));
2297836SJohn.Forte@Sun.COM exit(1);
2307836SJohn.Forte@Sun.COM }
231*11576SSurya.Prakki@Sun.COM (void) fclose(ifp);
232*11576SSurya.Prakki@Sun.COM (void) close(dsw_fd);
2337836SJohn.Forte@Sun.COM if (update_dscfg(new_vol) == 0) {
234*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Failed to update dscfg.\n"));
2357836SJohn.Forte@Sun.COM exit(1);
2367836SJohn.Forte@Sun.COM } else {
2377836SJohn.Forte@Sun.COM spcs_log("ii", NULL,
238*11576SSurya.Prakki@Sun.COM "iicpshd copy shadow from %s to %s",
239*11576SSurya.Prakki@Sun.COM old_vol, new_vol);
2407836SJohn.Forte@Sun.COM }
2417836SJohn.Forte@Sun.COM }
2427836SJohn.Forte@Sun.COM
2437836SJohn.Forte@Sun.COM /*
2447836SJohn.Forte@Sun.COM * find_cfg_info()
2457836SJohn.Forte@Sun.COM *
2467836SJohn.Forte@Sun.COM */
2477836SJohn.Forte@Sun.COM
2487836SJohn.Forte@Sun.COM int
find_cfg_info(char * volume,char * token)2497836SJohn.Forte@Sun.COM find_cfg_info(char *volume, char *token)
2507836SJohn.Forte@Sun.COM {
2517836SJohn.Forte@Sun.COM int i;
2527836SJohn.Forte@Sun.COM /* get read lock */
2537836SJohn.Forte@Sun.COM if (!cfg_lock(cfg, CFG_RDLOCK)) {
2547836SJohn.Forte@Sun.COM spcs_log("ii", NULL,
255*11576SSurya.Prakki@Sun.COM "iicpbmp CFG_RDLOCK failed, errno %d", errno);
256*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Error locking config\n"));
2577836SJohn.Forte@Sun.COM exit(1);
2587836SJohn.Forte@Sun.COM }
2597836SJohn.Forte@Sun.COM for (i = 1; ; i++) {
2607836SJohn.Forte@Sun.COM bzero(buf, CFG_MAX_BUF);
261*11576SSurya.Prakki@Sun.COM (void) snprintf(key, sizeof (key), token, i);
2627836SJohn.Forte@Sun.COM if (cfg_get_cstring(cfg, key, buf, DSW_NAMELEN) < 0) {
2637836SJohn.Forte@Sun.COM cfg_unlock(cfg);
2647836SJohn.Forte@Sun.COM return (0);
2657836SJohn.Forte@Sun.COM }
2667836SJohn.Forte@Sun.COM if (strcmp(buf, volume) == 0) {
2677836SJohn.Forte@Sun.COM if (strcmp(token, SHADOW_TOKEN) == 0) {
268*11576SSurya.Prakki@Sun.COM (void) snprintf(key, sizeof (key),
269*11576SSurya.Prakki@Sun.COM BITMAP_TOKEN, i);
270*11576SSurya.Prakki@Sun.COM (void) cfg_get_cstring(cfg, key,
271*11576SSurya.Prakki@Sun.COM real_bitmap, DSW_NAMELEN);
2727836SJohn.Forte@Sun.COM set_number = i;
2737836SJohn.Forte@Sun.COM } else if (strcmp(token, SV_TOKEN) == 0) {
2747836SJohn.Forte@Sun.COM sv_number = i;
2757836SJohn.Forte@Sun.COM } else if (strcmp(token, DSVOL_TOKEN) == 0) {
2767836SJohn.Forte@Sun.COM dsvol_number = i;
2777836SJohn.Forte@Sun.COM }
2787836SJohn.Forte@Sun.COM /* release read lock */
2797836SJohn.Forte@Sun.COM cfg_unlock(cfg);
2807836SJohn.Forte@Sun.COM return (1);
2817836SJohn.Forte@Sun.COM }
2827836SJohn.Forte@Sun.COM }
2837836SJohn.Forte@Sun.COM }
2847836SJohn.Forte@Sun.COM
2857836SJohn.Forte@Sun.COM int
copy_shadow_vol(char * old_shadow,char * new_shadow)2867836SJohn.Forte@Sun.COM copy_shadow_vol(char *old_shadow, char *new_shadow) {
2877836SJohn.Forte@Sun.COM int i;
2887836SJohn.Forte@Sun.COM char cp_buffer[256];
2897836SJohn.Forte@Sun.COM FILE *ishdfp, *oshdfp;
2907836SJohn.Forte@Sun.COM if ((ishdfp = fopen(old_shadow, "r")) == NULL) {
291*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Can't open old shadow file\n"));
2927836SJohn.Forte@Sun.COM return (0);
2937836SJohn.Forte@Sun.COM }
2947836SJohn.Forte@Sun.COM if ((oshdfp = fopen(new_shadow, "w")) == NULL) {
295*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Can't open new shadow file\n"));
2967836SJohn.Forte@Sun.COM return (0);
2977836SJohn.Forte@Sun.COM }
2987836SJohn.Forte@Sun.COM
2997836SJohn.Forte@Sun.COM /* Copy the shadow vol */
3007836SJohn.Forte@Sun.COM while ((i = fread(cp_buffer, sizeof (char), sizeof (cp_buffer), ishdfp))
3017836SJohn.Forte@Sun.COM > 0) {
3027836SJohn.Forte@Sun.COM if (fwrite(cp_buffer, sizeof (char), i, oshdfp) != i) {
303*11576SSurya.Prakki@Sun.COM (void) fclose(ishdfp);
304*11576SSurya.Prakki@Sun.COM (void) fclose(oshdfp);
3057836SJohn.Forte@Sun.COM return (0);
3067836SJohn.Forte@Sun.COM }
3077836SJohn.Forte@Sun.COM }
308*11576SSurya.Prakki@Sun.COM (void) fclose(ishdfp);
309*11576SSurya.Prakki@Sun.COM (void) fclose(oshdfp);
3107836SJohn.Forte@Sun.COM return (1);
3117836SJohn.Forte@Sun.COM }
3127836SJohn.Forte@Sun.COM
3137836SJohn.Forte@Sun.COM int
update_dscfg(char * new_shadow)3147836SJohn.Forte@Sun.COM update_dscfg(char *new_shadow) {
3157836SJohn.Forte@Sun.COM
3167836SJohn.Forte@Sun.COM int len = strlen(new_shadow);
3177836SJohn.Forte@Sun.COM /* get write lock */
3187836SJohn.Forte@Sun.COM if (!cfg_lock(cfg, CFG_WRLOCK)) {
3197836SJohn.Forte@Sun.COM spcs_log("ii", NULL,
320*11576SSurya.Prakki@Sun.COM "iicpbmp CFG_WRLOCK failed, errno %d", errno);
321*11576SSurya.Prakki@Sun.COM (void) fprintf(stderr, gettext("Error locking config\n"));
3227836SJohn.Forte@Sun.COM return (0);
3237836SJohn.Forte@Sun.COM }
324*11576SSurya.Prakki@Sun.COM (void) sprintf(key, SHADOW_TOKEN, set_number);
3257836SJohn.Forte@Sun.COM if (cfg_put_cstring(cfg, key, new_shadow, len) < 0) {
3267836SJohn.Forte@Sun.COM perror("cfg_put_cstring");
3277836SJohn.Forte@Sun.COM return (0);
3287836SJohn.Forte@Sun.COM }
329*11576SSurya.Prakki@Sun.COM (void) sprintf(key, SV_TOKEN, sv_number);
3307836SJohn.Forte@Sun.COM if (cfg_put_cstring(cfg, key, new_shadow, len) < 0) {
3317836SJohn.Forte@Sun.COM perror("cfg_put_cstring");
3327836SJohn.Forte@Sun.COM return (0);
3337836SJohn.Forte@Sun.COM }
334*11576SSurya.Prakki@Sun.COM (void) sprintf(key, DSVOL_TOKEN, dsvol_number);
3357836SJohn.Forte@Sun.COM if (cfg_put_cstring(cfg, key, new_shadow, len) < 0) {
3367836SJohn.Forte@Sun.COM perror("cfg_put_cstring");
3377836SJohn.Forte@Sun.COM return (0);
3387836SJohn.Forte@Sun.COM }
339*11576SSurya.Prakki@Sun.COM (void) cfg_commit(cfg);
3407836SJohn.Forte@Sun.COM cfg_unlock(cfg);
3417836SJohn.Forte@Sun.COM return (1);
3427836SJohn.Forte@Sun.COM }
3437836SJohn.Forte@Sun.COM
3447836SJohn.Forte@Sun.COM void
convert_to_blockdevice()3457836SJohn.Forte@Sun.COM convert_to_blockdevice() {
3467836SJohn.Forte@Sun.COM int len = strlen(real_bitmap);
3477836SJohn.Forte@Sun.COM int i = 0, j = 0;
3487836SJohn.Forte@Sun.COM char *temp_string = malloc(len-1);
3497836SJohn.Forte@Sun.COM while (i < len + 1) {
3507836SJohn.Forte@Sun.COM if (real_bitmap[i] != 'r') {
3517836SJohn.Forte@Sun.COM temp_string[j] = real_bitmap[i];
3527836SJohn.Forte@Sun.COM j++;
3537836SJohn.Forte@Sun.COM }
3547836SJohn.Forte@Sun.COM i++;
3557836SJohn.Forte@Sun.COM }
356*11576SSurya.Prakki@Sun.COM (void) strcpy(real_bitmap, temp_string);
3577836SJohn.Forte@Sun.COM free(temp_string);
3587836SJohn.Forte@Sun.COM }
359