/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifdef DKIOCPARTITION
#include <sys/efi_partition.h>
#endif
#include <strings.h>
#include <stdarg.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <locale.h>
#include <unistd.h>
#include <libgen.h>
#include <kstat.h>
static char *program;
void
usage(void)
{
"[bitmap_volume]\n"), program);
"bitmap\n"));
"bitmap\n"));
}
static void
{
if (status) {
}
}
static void
{
exit(1);
}
static void
{
}
#if defined(_LP64)
/* max value of a "long int" */
#else /* _ILP32 */
#endif
static uint64_t
{
#ifdef DKIOCPARTITION
#endif
int fd;
int rc;
/* NOTREACHED */
}
if (rc >= 0) {
return (size);
}
#ifdef DKIOCPARTITION
else if (rc != VT_ENOTSUP) {
#endif
gettext("unable to read the vtoc from partition, %s: %s"),
/* NOTREACHED */
#ifdef DKIOCPARTITION
}
/* See if there is an EFI label */
if (rc < 0) {
"from partition, %s: %s"),
/* NOTREACHED */
}
if (rc >= 0) {
return (size);
} else {
/*
* See if the stat64 for ZFS's zvol matches
* this file descriptor's fstat64 data.
*/
gettext("unable to read disk partition, %s: %s"),
/* NOTREACHED */
}
if (rc >= 0) {
return (size);
} else {
"from partition, %s: %s"),
/* NOTREACHED */
}
}
return (size);
#endif /* DKIOCPARTITION */
}
int
{
int rc = 0;
if (bitmap) {
}
bsize_bits * sizeof (unsigned int));
"%llu blocks\n"), bsize_simple);
"%llu blocks\n"), bsize_diskq);
"refcount: %llu blocks\n"), bsize_diskq32);
if (bitmap) {
(void) printf("\n");
"(%llu blocks)\n"),
if (bblocks >= bsize_diskq32) {
"replication modes\n"));
} else if (bblocks >= bsize_diskq) {
"replication modes, but with restricted diskq "
"reference counts\n"));
} else if (bblocks >= bsize_simple) {
"is large enough for: Sync and Async(memory) "
"replication modes only\n"));
rc = 3;
} else {
"is not large enough for any replication modes\n"));
rc = 4;
}
}
return (rc);
}
/* sizes in bytes */
/* rounding function */
int
{
int rc = 0;
if (bitmap) {
}
/* round up to multiple of DSW_SIZE blocks */
int32_bits : int64_bits);
if (bitmap) {
(void) printf("\n");
if (bblocks >= bsize_cdep) {
"of shadow volume\n"));
"Independent and full size dependent shadow "
"volumes only\n"));
rc = 6;
} else {
"any type of shadow volume\n"));
rc = 5;
}
}
return (rc);
}
/*
* Return codes:
* 0 success (if bitmap was supplied it is large enough for all uses)
* 1 usage, programing, or access errors
* 2 unknown option supplied on command line
* 3 SNDR bitmap is not large enough for diskq usage
* 4 SNDR bitmap is not large enough for any usage
* 5 II bitmap is not large enough for any usage
* 6 II bitmap is not large enough for compact dependent usage
*/
int
{
extern int optind;
int opt;
int rc = 0;
(void) textdomain("dsbitmap");
switch (opt) {
case 'p':
"cannot specify -p with other options"));
usage();
return (1);
}
break;
case 'r':
"cannot specify -r with other options"));
usage();
return (1);
}
break;
case 'h':
if (argc != 2) {
"cannot specify -h with other options"));
rc = 1;
}
usage();
return (rc);
/* NOTREACHED */
default:
usage();
return (2);
/* NOTREACHED */
}
}
usage();
return (1);
}
usage();
return (1);
}
} else {
}
switch (type) {
case SNDR:
break;
case II:
break;
default:
/* cannot happen */
rc = 1;
break;
}
return (rc);
}