translate.c revision 745cd3c5371d020efae7a911c58c526aa1fd0dba
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <libzfs.h>
#include <sys/zfs_context.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/dmu_objset.h>
#include <sys/vdev_impl.h>
#include "zinject.h"
extern void kernel_init(int);
extern void kernel_fini(void);
static int debug;
static void
{
if (!debug)
return;
}
/*
* Given a full path to a file, translate into a dataset name and a relative
* path within the dataset. 'dataset' must be at least MAXNAMELEN characters,
* and 'relpath' must be at least MAXPATHLEN characters. We also pass a stat64
* buffer, which we need later to get the object ID.
*/
static int
{
int match;
const char *rel;
if (fullpath[0] != '/') {
"path\n", fullpath);
usage();
return (-1);
}
return (-1);
}
return (-1);
}
return (-1);
}
match = 0;
match = 1;
break;
}
}
if (!match) {
fullpath);
return (-1);
}
"filesystem\n", fullpath);
return (-1);
}
"doesn't match path\n", fullpath);
return (-1);
}
if (rel[0] == '/')
rel++;
return (0);
}
/*
* Convert from a (dataset, path) pair into a (objset, object) pair. Note that
* we grab the object number from the inode number, since looking this up via
* libzpool is a real pain.
*/
/* ARGSUSED */
static int
{
int err;
/*
* Before doing any libzpool operations, call sync() to ensure that the
* on-disk state is consistent with the in-core state.
*/
sync();
return (-1);
}
return (0);
}
/*
* Calculate the real range based on the type, level, and range given.
*/
static int
{
int err;
int ret = -1;
/*
* Determine the numeric range from the string.
*/
/*
* If range is unspecified, set the range to [0,-1], which
* indicates that the whole object should be treated as an
* error.
*/
} else {
char *end;
/* XXX add support for suffixes */
if (*end == '\0')
else if (*end == ',')
if (*end != '\0') {
"a numeric range of the form 'start[,end]'\n",
range);
goto out;
}
}
switch (type) {
case TYPE_DATA:
break;
case TYPE_DNODE:
/*
* If this is a request to inject faults into the dnode, then we
* must translate the current (objset,object) pair into an
* offset within the metadnode for the objset. Specifying any
* kind of range with type 'dnode' is illegal.
*/
"type is 'dnode'\n");
goto out;
}
break;
}
/*
* Get the dnode associated with object, so we can calculate the block
* size.
*/
goto out;
}
} else {
if (err != 0) {
"for object %llu\n",
goto out;
}
}
/*
* Translate range into block IDs.
*/
}
/*
* Check level, and then translate level 0 blkids into ranges
* appropriate for level of indirection.
*/
if (level > 0) {
ziprintf("level 0 blkid range: [%llu, %llu]\n",
goto out;
}
}
}
}
ret = 0;
out:
if (dn) {
}
if (os)
return (ret);
}
int
{
char path[MAXPATHLEN];
char *slash;
int ret = -1;
/*
* MOS objects are treated specially.
*/
switch (type) {
case TYPE_MOS:
break;
case TYPE_MOSDIR:
break;
case TYPE_METASLAB:
break;
case TYPE_CONFIG:
break;
case TYPE_BPLIST:
break;
case TYPE_SPACEMAP:
break;
case TYPE_ERRLOG:
break;
}
dataset[0] = '\0';
return (0);
}
/*
* Convert a full path into a (dataset, file) pair.
*/
goto err;
/*
* Convert (dataset, file) into (objset, object)
*/
goto err;
/*
* For the given object, calculate the real (type, level, range)
*/
goto err;
ziprintf(" range: all\n");
else
/*
* Copy the pool name
*/
*slash = '\0';
ret = 0;
err:
kernel_fini();
return (ret);
}
int
{
/*
* A raw bookmark of the form objset:object:level:blkid, where each
* number is a hexidecimal value.
*/
"'objset:object:level:blkid'\n", str);
return (-1);
}
return (0);
}
int
{
char *end;
/*
* Given a device name or GUID, create an appropriate injection record
* with zi_guid set.
*/
return (-1);
return (-1);
}
}
switch (label_type) {
case TYPE_LABEL_UBERBLOCK:
break;
case TYPE_LABEL_NVLIST:
break;
}
return (0);
}