dlog_ck.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 1996-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stddef.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
/* forward references */
int
{
int err;
int n;
char dlog_path[MAXPATHLEN];
char dmap_path[MAXPATHLEN];
int fd;
int dlog_version;
struct cfs_dlog_entry buf;
int max_seq_num;
int ent_count = 0;
if (maxlocalfilenop)
*maxlocalfilenop = 0LL;
if (n > MAXPATHLEN) {
return (-1);
}
if (n > MAXPATHLEN) {
return (-1);
}
if (err < 0) {
/*
* No disconnect log(dlog) file exists to check
*/
return (0);
}
/* this file will be <2GB */
if (fd < 0) {
return (-2);
}
if (err != sizeof (dlog_version)) {
return (-3);
}
if (dlog_version != CFS_DLOG_VERSION) {
"unknown version number in %s"), dlog_path);
return (-4);
}
offset = sizeof (dlog_version);
max_seq_num = 0;
maxlocalfileno = 0LL;
if (err == -1) {
return (-5);
}
if (err < 0) {
return (-6);
}
++ent_count;
goto out;
}
/*
* Record length must be on a word boundary and
* fit into the correct size range.
*/
goto out;
}
/*
* Make sure length does not point beyond end of
* file
*/
goto out;
}
} else {
goto out;
}
/* make sure the valid field is reasonable */
case CFS_DLOG_VAL_CRASH:
case CFS_DLOG_VAL_COMMITTED:
case CFS_DLOG_VAL_ERROR:
case CFS_DLOG_VAL_PROCESSED:
break;
default:
goto out;
}
/* make sure the operation field is reasonable */
case CFS_DLOG_CREATE:
break;
case CFS_DLOG_REMOVE:
break;
case CFS_DLOG_LINK:
break;
case CFS_DLOG_RENAME:
break;
case CFS_DLOG_MKDIR:
break;
case CFS_DLOG_RMDIR:
break;
case CFS_DLOG_SYMLINK:
break;
case CFS_DLOG_SETATTR:
break;
case CFS_DLOG_SETSECATTR:
break;
case CFS_DLOG_MODIFIED:
break;
case CFS_DLOG_MAPFID:
break;
default:
goto out;
}
/* track the largest local fileno used */
if (maxlocalfileno < fileno)
/* track the largest sequence number used */
}
}
out:
return (-7);
}
}
return (-8);
}
/* check to see that mapfile exists; if not, create it. */
/* XXX ent_count is a very high upper bound */
if (create_mapfile(dmap_path,
ent_count * sizeof (struct cfs_dlog_mapping_space)) != 0) {
return (-9);
}
}
if (maxlocalfilenop)
return (0);
}
int
{
int err;
if (err < 0) {
return (-1);
}
return (-2);
}
return (0);
}
static int
{
/* this file will be <2GB */
if (fd < 0)
return (errno);
while (size > 0) {
return (rc);
}
}
return (rc);
}
return (0);
}