stats_create.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
*
* Routines for the `clean interface' to cachefs statistics.
*/
#include <stdarg.h>
#include <libintl.h>
#include <assert.h>
#include <string.h>
#include "stats.h"
/* forward declarations of statics */
static stats_cookie_t *stats_create(char *);
static stats_cookie_t *
stats_create(char *progname)
{
goto out;
rc->st_progname++;
else
gettext("Cannot initialize kstats"));
goto out;
}
out:
return (rc);
}
stats_create_unbound(char *progname)
{
goto out;
out:
return (st);
}
{
struct stat64 s;
int i, n;
goto out;
== NULL) {
gettext("Cannot lookup cachefs key kstat"));
goto out;
}
gettext("Cannot read cachefs key kstat"));
goto out;
}
goto out;
}
for (i = 0; i < n; i++) {
k[i].ks_mountpoint += (uintptr_t)k;
k[i].ks_cachedir += (uintptr_t)k;
k[i].ks_cacheid += (uintptr_t)k;
if (! k[i].ks_mounted)
continue;
if ((stat64((char *)k[i].ks_mountpoint, &s) == 0) &&
break;
}
if (i >= n) {
goto out;
}
out:
return (st);
}
/*
* stats_next - bind the cookie to the next valid cachefs mount.
*
* returns cachefs_kstat_key_t *, which gives all the info you need.
* returns NULL if we're out of mounts, or if an error occured.
* returns malloc()ed data, which the client has to free() itself.
*/
{
int i, n;
"key")) == NULL) ||
gettext("Cannot get cachefs key kstat"));
goto out;
}
for (i = 0; i < n; i++)
break;
++i;
if (i < n) {
prc = k + i;
} else
} else if (n > 0) {
prc = k;
}
out:
char *s;
int size;
if ((rc = (cachefs_kstat_key_t *)
gettext("Cannot malloc return code"));
} else {
s += strlen(s) + 1;
s += strlen(s) + 1;
s += strlen(s) + 1;
}
}
return (rc);
}
{
int size;
char *s;
"key")) == NULL) ||
gettext("Cannot get cachefs key kstat"));
goto out;
}
gettext("Cannot malloc return code"));
else {
(void) strcpy(s, (char *)k->ks_mountpoint);
s += strlen(s) + 1;
s += strlen(s) + 1;
(void) strcpy(s, (char *)k->ks_cachedir);
s += strlen(s) + 1;
(void) strcpy(s, (char *)k->ks_cacheid);
s += strlen(s) + 1;
}
out:
return (rc);
}
void
{
void free();
return;
/*
* we don't want to depend on dbm (or stats_dbm), so we don't
* do a stats_dbm_close. we do try to require the client to
* have done it, via an assert(), however.
*/
}
int
{
return (0);
return (0);
return (0);
return (1);
}
void
/*PRINTFLIKE3*/
{
}
char *
{
return (st->st_errorstr);
}
int
{
}
int
{
}