label_sun.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1996 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include "vold.h"
/*
* this is the datastructure that we keep around for each sun
* label to allow us to identify it.
*/
struct sun_label {
};
/* sl_type: */
#define SL_UNKNOWN 0
#define SL_CDROM 1
#define SL_MO 2
#define SL_FLOPPY 3
#define SL_DISK 4
#define SL_PCMEM 5
#define SUN_VERSION 1
/*
* XXX: what is this used for, and what size should really be used
*/
sun_key, /* l_key */
sun_compare, /* l_compare */
sun_read, /* l_read */
NULL, /* l_write */
sun_setup, /* l_setup */
sun_xdr, /* l_xdr */
SUN_SIZE, /* l_size */
SUN_SIZE, /* l_xdrsize */
UFS_LTYPE, /* l_ident */
1, /* l_nll */
&sun_labelloc /* l_ll */
};
/*
* Initialization function, called by the dso loader.
*/
label_init(void)
{
return (TRUE);
}
/*
* Read the label off the disk and build an sl label structure
* to represent it.
*
* XXX: the way in which we both read the sun label and we
* "unique-ify" UFS media is non-standard at best (and
* changes in media layout format
*/
static enum laread_res
{
extern time_t unique_time(char *, char *);
extern char *laread_res_to_str(enum laread_res);
static bool_t sun_get_dklabel(int, char *,
struct dk_label *);
static bool_t sun_put_dklabel(int, char *,
struct dk_label *);
enum laread_res retval;
/* get the label */
goto out;
}
debug(3,
"sun_read: dkl_magic wrong # (%#x expected, %#x found)\n",
goto out;
}
/* if we have a name then get it */
}
/*
* ok, it is really ugly here -- we assume that if no one
* has set a time stamp that the label probably isn't very
* unique
*
* we make it unique, calculate a new checksum (else it will be off),
* and write it back out
*/
/* are we allowed to unique-ify it ?? */
goto out;
}
/* unique-ify it */
/* update the checksum */
/* write it back out */
goto out;
}
} else {
}
sizeof (struct dk_label));
/* set the "type" field */
} else {
}
/*
* cdrom is really the only known case of strange
* sizes in the label, so its the only one we should
* have to special case here. Its also the only
* device type that can really be considered to be
* a "fixed" size.
*/
} else {
}
out:
}
}
} else {
}
return (retval);
}
/*
* return the offset for the sun label for a given media type
*
* XXX: I don't know how this should be done once SPARC starts handling
* FDISK -- what will DK_LABEL_LOC be then?
*
* NOTE: this is centralized here since two routines use this number,
* and it's *important* that they both use the same formula! (;-)
*
* XXX: volmgt shouldn't know *anything* about seperate media
* types (but it certainly does)
*/
static daddr_t
dklabel_offset(char *type)
{
} else {
}
return (offset);
}
/*
* try to get the "dk label" by reading directly from the disk
*/
static bool_t
{
/* seek to the proper place */
debug(6,
"sun_get_dklabel: seek to %ld failed (for label); %m\n",
offset);
goto dun;
}
/* read the label */
sizeof (struct dk_label)) {
goto dun;
}
/* success (at reading where the label *should* be) */
dun:
return (ret_res);
}
static bool_t
{
/* seek to the proper place */
debug(6,
"sun_put_dklabel: seek to %ld failed (for label); %m\n",
offset);
goto dun;
}
/* write back out the label */
sizeof (struct dk_label)) {
goto dun;
}
dun:
return (ret_res);
}
static char *
{
char buf[MAXNAMELEN];
}
static bool_t
{
return (FALSE);
}
return (FALSE);
}
return (TRUE);
}
static void
{
int do_unnamed = 0;
/* makename() couldn't name a name */
do_unnamed++;
}
} else {
do_unnamed++;
}
if (do_unnamed) {
char *mtype;
case SL_FLOPPY:
break;
case SL_CDROM:
mtype = CDROM_MTYPE;
break;
case SL_MO:
break;
case SL_DISK:
break;
case SL_UNKNOWN:
default:
} else {
mtype = OTHER_MTYPE;
}
break;
}
}
/* if it's a CDROM, it's readonly */
}
}
static void
{
char *s = NULL;
(void *)&ssl.sl_version);
/*
* yes, well, this is a bit of a hack here, but
* I don't know of any other way to do it.
* I know that xdr_string encodes the string
* as an int + the bytes, so I just allocate that
* much space. silveri said it would work.
*/
}
if (op == XDR_ENCODE) {
s = sl->sl_vtocname;
xdr_destroy(&xdrs);
} else if (op == XDR_DECODE) {
l->l_label =
}
/*
* here's where we'll deal with other versions of this
* structure...
*/
/*
* xdr_string seems not to allocate any memory for
* a null string, and therefore s is null on return...
*/
if (s != NULL) {
xdr_free(xdr_string, (void *)&s);
}
xdr_destroy(&xdrs);
}
}
/*
* this routine calculates the label checksum
*/
static void
{
register short *sp;
register short sum = 0;
/*
* we are generating a checksum so don't include the checksum
* in the rolling xor
*/
count -= 1;
/*
* take the xor of all the half-words in the label
*/
while (count--) {
}
/* fill in the generated checksum */
}