/*
* 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.
*/
/*LINTLIBRARY*/
#include <stdio.h>
#include <errno.h>
#include <memory.h>
#include <unistd.h>
#include <strings.h>
#include <limits.h>
/*
* To copy each field of vtoc individually for copying extvtoc
* to 32 bit vtoc and vs.
* Currently bootinfo and timestamp are not really supported.
*/
{ \
int i; \
for (i = 0; i < 10; i++) \
for (i = 0; i < V_NUMPAR; i++) { \
} \
for (i = 0; i < V_NUMPAR; i++) \
else \
}
/*
* Read VTOC - return partition number.
*/
int
{
/*
* Read the vtoc.
*/
switch (errno) {
case EIO:
return (VT_EIO);
case EINVAL:
return (VT_EINVAL);
case ENOTSUP:
/* GPT labeled or disk > 1TB with no extvtoc support */
return (VT_ENOTSUP);
case EOVERFLOW:
return (VT_EOVERFLOW);
default:
return (VT_ERROR);
}
}
/*
* Sanity-check the vtoc.
*/
return (VT_EINVAL);
}
/*
* Convert older-style vtoc's.
*/
case 0:
/*
* No vtoc information. Install default
* assuming that the driver returns the
* current partition information correctly.
*/
if (vtoc->v_sectorsz == 0)
break;
case V_VERSION:
break;
default:
return (VT_EINVAL);
}
/*
* Return partition number for this file descriptor.
*/
switch (errno) {
case EIO:
return (VT_EIO);
case EINVAL:
return (VT_EINVAL);
default:
return (VT_ERROR);
}
}
return (VT_EINVAL);
}
return ((int)dki_info.dki_partition);
}
/*
* Write VTOC
*/
int
{
int i;
/*
* Sanity-check the vtoc
*/
return (-1);
}
/*
* since many drivers won't allow opening a device make sure
* all partitions aren't being set to zero. If all are zero then
* we have no way to set them to something else
*/
break;
return (-1);
/*
* Write the vtoc
*/
switch (errno) {
case EIO:
return (VT_EIO);
case EINVAL:
return (VT_EINVAL);
case ENOTSUP:
/* GPT labeled or disk > 1TB with no extvtoc support */
return (VT_ENOTSUP);
case EOVERFLOW:
return (VT_EOVERFLOW);
default:
return (VT_ERROR);
}
}
return (0);
}
int
{
int ret;
/*
* Read the vtoc.
*/
switch (errno) {
case EIO:
return (VT_EIO);
case EINVAL:
return (VT_EINVAL);
/* for disks > 1TB */
case ENOTSUP:
return (VT_ENOTSUP);
case EOVERFLOW:
return (VT_EOVERFLOW);
case ENOTTY:
return (ret);
#ifdef _LP64
/*
* 64-bit vtoc and extvtoc have the same field sizes
* and offsets.
*/
#else
#endif
return (ret);
default:
return (VT_ERROR);
}
}
/*
* Sanity-check the vtoc.
*/
return (VT_EINVAL);
}
case 0:
/*
* For pre-version 1 vtoc keep same functionality
* as read_vtoc.
*/
if (extvtoc->v_sectorsz == 0)
break;
case V_VERSION:
break;
default:
return (VT_EINVAL);
}
/*
* Return partition number for this file descriptor.
*/
switch (errno) {
case EIO:
return (VT_EIO);
case EINVAL:
return (VT_EINVAL);
default:
return (VT_ERROR);
}
}
return (VT_EINVAL);
}
return ((int)dki_info.dki_partition);
}
/*
* Write ext VTOC.
*/
int
{
int i;
/*
* Sanity-check the vtoc
*/
return (-1);
}
/*
* since many drivers won't allow opening a device make sure
* all partitions aren't being set to zero. If all are zero then
* we have no way to set them to something else
*/
break;
return (-1);
/*
* Write the extvtoc
*/
switch (errno) {
case EIO:
return (VT_EIO);
case EINVAL:
return (VT_EINVAL);
/* for disks > 1TB */
case ENOTSUP:
return (VT_ENOTSUP);
case EOVERFLOW:
return (VT_EOVERFLOW);
case ENOTTY:
#ifdef _LP64
/*
* 64-bit vtoc and extvtoc have the same field sizes
* and offsets.
*/
#else
#endif
default:
return (VT_ERROR);
}
}
return (0);
}