summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-10-01 10:21:17 +0200
committerGünther Deschner <gd@samba.org>2009-10-01 12:19:48 +0200
commite80891db4123a2ae326517c27c559ace18b0f05b (patch)
treef44b79200d2c4c7852f925710ba048a30ea15d72 /source3
parent25ab8828a191bf67c85be1c8e21dc7d17c2f65d1 (diff)
downloadsamba-e80891db4123a2ae326517c27c559ace18b0f05b.tar.gz
samba-e80891db4123a2ae326517c27c559ace18b0f05b.tar.bz2
samba-e80891db4123a2ae326517c27c559ace18b0f05b.zip
s3-perfcount: more cleanup.
Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h14
-rw-r--r--source3/include/rpc_perfcount.h126
-rw-r--r--source3/include/rpc_perfcount_defs.h93
-rw-r--r--source3/registry/reg_perfcount.c80
4 files changed, 39 insertions, 274 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 93bad7f0d0..c9f57b46a6 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5130,20 +5130,6 @@ uint32 reg_perfcount_get_last_counter(uint32 base_index);
uint32 reg_perfcount_get_last_help(uint32 last_counter);
uint32 reg_perfcount_get_counter_help(uint32 base_index, char **retbuf);
uint32 reg_perfcount_get_counter_names(uint32 base_index, char **retbuf);
-bool _reg_perfcount_get_counter_data(TDB_DATA key, TDB_DATA *data);
-bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *inst,
- TALLOC_CTX *mem_ctx,
- int instId,
- struct PERF_OBJECT_TYPE *obj,
- TDB_CONTEXT *names);
-bool _reg_perfcount_add_instance(struct PERF_OBJECT_TYPE *obj,
- TALLOC_CTX *mem_ctx,
- int instInd,
- TDB_CONTEXT *names);
-uint32 reg_perfcount_get_perf_data_block(uint32 base_index,
- prs_struct *ps,
- struct PERF_DATA_BLOCK *block,
- const char *object_ids);
WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, const char *object_ids);
/* The following definitions come from registry/reg_util.c */
diff --git a/source3/include/rpc_perfcount.h b/source3/include/rpc_perfcount.h
deleted file mode 100644
index 0cb2fdc212..0000000000
--- a/source3/include/rpc_perfcount.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifndef _RPC_PERFCOUNT_H
-#define _RPC_PERFCOUNT_H
-/*
- * Unix SMB/CIFS implementation.
- * Virtual Windows Registry Layer
- *
- * Copyright (C) Marcin Krzysztof Porwit 2005,
- * Copyright (C) Gerald (Jerry) Carter 2005.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-typedef struct perf_counter_definition
-{
- /* sizeof(PERF_COUNTER_DEFINITION) */
- uint32 ByteLength;
- uint32 CounterNameTitleIndex;
- uint32 CounterNameTitlePointer;
- uint32 CounterHelpTitleIndex;
- uint32 CounterHelpTitlePointer;
- uint32 DefaultScale;
- uint32 DetailLevel;
- uint32 CounterType;
- uint32 CounterSize;
- uint32 CounterOffset;
-}
-PERF_COUNTER_DEFINITION;
-
-typedef struct perf_counter_block
-{
- /* Total size of the data block, including all data plus this header */
- uint32 ByteLength;
- uint8 *data;
-}
-PERF_COUNTER_BLOCK;
-
-typedef struct perf_instance_definition
-{
- /* Total size of the instance definition, including the length of the terminated Name string */
- uint32 ByteLength;
- uint32 ParentObjectTitleIndex;
- uint32 ParentObjectTitlePointer;
- uint32 UniqueID;
- /* From the start of the PERF_INSTANCE_DEFINITION, the byte offset to the start of the Name string */
- uint32 NameOffset;
- uint32 NameLength;
- /* Unicode string containing the name for the instance */
- uint8 *data;
- PERF_COUNTER_BLOCK counter_data;
-}
-PERF_INSTANCE_DEFINITION;
-
-typedef struct perf_object_type
-{
- /* Total size of the object block, including all PERF_INSTANCE_DEFINITIONs,
- PERF_COUNTER_DEFINITIONs and PERF_COUNTER_BLOCKs in bytes */
- uint32 TotalByteLength;
- /* Size of this PERF_OBJECT_TYPE plus all PERF_COUNTER_DEFINITIONs in bytes */
- uint32 DefinitionLength;
- /* Size of this PERF_OBJECT_TYPE */
- uint32 HeaderLength;
- uint32 ObjectNameTitleIndex;
- uint32 ObjectNameTitlePointer;
- uint32 ObjectHelpTitleIndex;
- uint32 ObjectHelpTitlePointer;
- uint32 DetailLevel;
- uint32 NumCounters;
- uint32 DefaultCounter;
- uint32 NumInstances;
- uint32 CodePage;
- uint64 PerfTime;
- uint64 PerfFreq;
- PERF_COUNTER_DEFINITION *counters;
- PERF_INSTANCE_DEFINITION *instances;
- PERF_COUNTER_BLOCK counter_data;
-}
-PERF_OBJECT_TYPE;
-
-/* PerfCounter Inner Buffer structs */
-typedef struct perf_data_block
-{
- /* hardcoded to read "P.E.R.F" */
- uint16 Signature[4];
- uint32 LittleEndian;
- /* both currently hardcoded to 1 */
- uint32 Version;
- uint32 Revision;
- /* bytes of PERF_OBJECT_TYPE data, does NOT include the PERF_DATA_BLOCK */
- uint32 TotalByteLength;
- /* size of PERF_DATA_BLOCK including the uint8 *data */
- uint32 HeaderLength;
- /* number of PERF_OBJECT_TYPE structures encoded */
- uint32 NumObjectTypes;
- uint32 DefaultObject;
- SYSTEMTIME SystemTime;
- /* This will guarantee that we're on a 64-bit boundary before we encode
- PerfTime, and having it there will make my offset math much easier. */
- uint32 Padding;
- /* Now when I'm marshalling this, I'll need to call prs_align_uint64()
- before I start encodint the uint64 structs */
- /* clock rate * seconds uptime */
- uint64 PerfTime;
- /* The clock rate of the CPU */
- uint64 PerfFreq;
- /* used for high-res timers -- for now PerfTime * 10e7 */
- uint64 PerfTime100nSec;
- uint32 SystemNameLength;
- uint32 SystemNameOffset;
- /* The SystemName, in unicode, terminated */
- uint8* data;
- PERF_OBJECT_TYPE *objects;
-}
-PERF_DATA_BLOCK;
-
-#endif /* _RPC_PERFCOUNT_H */
diff --git a/source3/include/rpc_perfcount_defs.h b/source3/include/rpc_perfcount_defs.h
deleted file mode 100644
index 6c84c270e5..0000000000
--- a/source3/include/rpc_perfcount_defs.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef _RPC_PERFCOUNT_DEFS_H
-#define _RPC_PERFCOUNT_DEFS_H
-/*
- * Unix SMB/CIFS implementation.
- * Virtual Windows Registry Layer
- *
- * Copyright (C) Marcin Krzysztof Porwit 2005,
- * Copyright (C) Gerald (Jerry) Carter 2005.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * The following #defines match what is in winperf.h.
- * See that include file for more details, or look up
- * "Performance Data Format" on MSDN
- *
- * Rather than including them in rpc_perfcount.h, they
- * were broken out into a separate .h file so that they
- * can be included by other programs that need this info
- * without pulling in everything else samba-related.
- */
-
-#define PERF_NO_INSTANCES -1
-#define PERF_NO_UNIQUE_ID -1
-
-/* These determine the data size */
-#define PERF_SIZE_DWORD 0x00000000
-#define PERF_SIZE_LARGE 0x00000100
-#define PERF_SIZE_ZERO 0x00000200
-#define PERF_SIZE_VARIABLE_LEN 0x00000300
-
-/* These determine the usage of the counter */
-#define PERF_TYPE_NUMBER 0x00000000
-#define PERF_TYPE_COUNTER 0x00000400
-#define PERF_TYPE_TEXT 0x00000800
-#define PERF_TYPE_ZERO 0x00000C00
-
-/* If PERF_TYPE_NUMBER was selected, these provide display information */
-#define PERF_NUMBER_HEX 0x00000000
-#define PERF_NUMBER_DECIMAL 0x00010000
-#define PERF_NUMBER_DEC_1000 0x00020000
-
-/* If PERF_TYPE_COUNTER was selected, these provide display information */
-#define PERF_COUNTER_VALUE 0x00000000
-#define PERF_COUNTER_RATE 0x00010000
-#define PERF_COUNTER_FRACTION 0x00020000
-#define PERF_COUNTER_BASE 0x00030000
-#define PERF_COUNTER_ELAPSED 0x00040000
-#define PERF_COUNTER_QUEUELEN 0x00050000
-#define PERF_COUNTER_HISTOGRAM 0x00060000
-#define PERF_COUNTER_PRECISION 0x00070000
-
-/* If PERF_TYPE_TEXT was selected, these provide display information */
-#define PERF_TEXT_UNICODE 0x00000000
-#define PERF_TEXT_ASCII 0x00010000
-
-/* These provide information for which tick count to use when computing elapsed interval */
-#define PERF_TIMER_TICK 0x00000000
-#define PERF_TIMER_100NS 0x00100000
-#define PERF_OBJECT_TIMER 0x00200000
-
-/* These affect how the data is manipulated prior to being displayed */
-#define PERF_DELTA_COUNTER 0x00400000
-#define PERF_DELTA_BASE 0x00800000
-#define PERF_INVERSE_COUNTER 0x01000000
-#define PERF_MULTI_COUNTER 0x02000000
-
-/* These determine if any text gets added when the value is displayed */
-#define PERF_DISPLAY_NO_SUFFIX 0x00000000
-#define PERF_DISPLAY_PER_SEC 0x10000000
-#define PERF_DISPLAY_PERCENT 0x20000000
-#define PERF_DISPLAY_SECONDS 0x30000000
-#define PERF_DISPLAY_NOSHOW 0x40000000
-
-/* These determine the DetailLevel of the counter */
-#define PERF_DETAIL_NOVICE 100
-#define PERF_DETAIL_ADVANCED 200
-#define PERF_DETAIL_EXPERT 300
-#define PERF_DETAIL_WIZARD 400
-
-#endif /* _RPC_PERFCOUNT_DEFS_H */
diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c
index 82b6ee277b..1991af10ca 100644
--- a/source3/registry/reg_perfcount.c
+++ b/source3/registry/reg_perfcount.c
@@ -365,6 +365,11 @@ static uint32 _reg_perfcount_get_numinst(int objInd, TDB_CONTEXT *names)
/*********************************************************************
*********************************************************************/
+static bool _reg_perfcount_add_instance(struct PERF_OBJECT_TYPE *obj,
+ TALLOC_CTX *mem_ctx,
+ int instInd,
+ TDB_CONTEXT *names);
+
static bool _reg_perfcount_add_object(struct PERF_DATA_BLOCK *block,
TALLOC_CTX *mem_ctx,
int num,
@@ -407,7 +412,7 @@ static bool _reg_perfcount_add_object(struct PERF_DATA_BLOCK *block,
/*********************************************************************
*********************************************************************/
-bool _reg_perfcount_get_counter_data(TDB_DATA key, TDB_DATA *data)
+static bool _reg_perfcount_get_counter_data(TDB_DATA key, TDB_DATA *data)
{
TDB_CONTEXT *counters;
const char *fname = counters_directory( DATA_DB );
@@ -660,11 +665,11 @@ static bool _reg_perfcount_add_counter(struct PERF_DATA_BLOCK *block,
/*********************************************************************
*********************************************************************/
-bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *inst,
- TALLOC_CTX *mem_ctx,
- int instId,
- struct PERF_OBJECT_TYPE *obj,
- TDB_CONTEXT *names)
+static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *inst,
+ TALLOC_CTX *mem_ctx,
+ int instId,
+ struct PERF_OBJECT_TYPE *obj,
+ TDB_CONTEXT *names)
{
TDB_DATA key, data;
char buf[PERFCOUNT_MAX_LEN], temp[PERFCOUNT_MAX_LEN];
@@ -754,10 +759,10 @@ bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *inst,
/*********************************************************************
*********************************************************************/
-bool _reg_perfcount_add_instance(struct PERF_OBJECT_TYPE *obj,
- TALLOC_CTX *mem_ctx,
- int instInd,
- TDB_CONTEXT *names)
+static bool _reg_perfcount_add_instance(struct PERF_OBJECT_TYPE *obj,
+ TALLOC_CTX *mem_ctx,
+ int instInd,
+ TDB_CONTEXT *names)
{
struct PERF_INSTANCE_DEFINITION *inst;
@@ -961,7 +966,7 @@ static bool _reg_perfcount_init_data_block(struct PERF_DATA_BLOCK *block,
/*********************************************************************
*********************************************************************/
-static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block, prs_struct *ps)
+static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block, TALLOC_CTX *mem_ctx)
{
int obj, cnt, inst, pad, i;
struct PERF_OBJECT_TYPE *object;
@@ -992,7 +997,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
counter_data = &(instance->counter_data);
counter = &(object[obj].counters[object[obj].NumCounters - 1]);
counter_data->ByteLength = counter->CounterOffset + counter->CounterSize + sizeof(counter_data->ByteLength);
- temp = TALLOC_REALLOC_ARRAY(ps->mem_ctx,
+ temp = TALLOC_REALLOC_ARRAY(mem_ctx,
temp,
char,
counter_data->ByteLength- sizeof(counter_data->ByteLength));
@@ -1013,7 +1018,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
{
pad = 8 - pad;
}
- counter_data->data = TALLOC_REALLOC_ARRAY(ps->mem_ctx,
+ counter_data->data = TALLOC_REALLOC_ARRAY(mem_ctx,
counter_data->data,
uint8,
counter_data->ByteLength - sizeof(counter_data->ByteLength) + pad);
@@ -1033,7 +1038,7 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
if((pad = (object[obj].counter_data.ByteLength % 8)))
{
pad = 8 - pad;
- object[obj].counter_data.data = TALLOC_REALLOC_ARRAY(ps->mem_ctx,
+ object[obj].counter_data.data = TALLOC_REALLOC_ARRAY(mem_ctx,
object[obj].counter_data.data,
uint8,
object[obj].counter_data.ByteLength + pad);
@@ -1055,10 +1060,11 @@ static uint32 _reg_perfcount_perf_data_block_fixup(struct PERF_DATA_BLOCK *block
/*********************************************************************
*********************************************************************/
-uint32 reg_perfcount_get_perf_data_block(uint32 base_index,
- prs_struct *ps,
- struct PERF_DATA_BLOCK *block,
- const char *object_ids)
+static uint32 reg_perfcount_get_perf_data_block(uint32 base_index,
+ TALLOC_CTX *mem_ctx,
+ struct PERF_DATA_BLOCK *block,
+ const char *object_ids,
+ bool bigendian_data)
{
uint32 buffer_size = 0;
const char *fname = counters_directory( NAMES_DB );
@@ -1073,7 +1079,7 @@ uint32 reg_perfcount_get_perf_data_block(uint32 base_index,
return 0;
}
- if (!_reg_perfcount_init_data_block(block, ps->mem_ctx, names, ps->bigendian_data)) {
+ if (!_reg_perfcount_init_data_block(block, mem_ctx, names, bigendian_data)) {
DEBUG(0, ("_reg_perfcount_init_data_block failed\n"));
tdb_close(names);
return 0;
@@ -1084,14 +1090,14 @@ uint32 reg_perfcount_get_perf_data_block(uint32 base_index,
if(object_ids == NULL)
{
/* we're getting a request for "Global" here */
- retval = _reg_perfcount_assemble_global(block, ps->mem_ctx, base_index, names);
+ retval = _reg_perfcount_assemble_global(block, mem_ctx, base_index, names);
}
else
{
/* we're getting a request for a specific set of PERF_OBJECT_TYPES */
- retval = _reg_perfcount_assemble_global(block, ps->mem_ctx, base_index, names);
+ retval = _reg_perfcount_assemble_global(block, mem_ctx, base_index, names);
}
- buffer_size = _reg_perfcount_perf_data_block_fixup(block, ps);
+ buffer_size = _reg_perfcount_perf_data_block_fixup(block, mem_ctx);
tdb_close(names);
@@ -1362,20 +1368,6 @@ static bool _reg_perfcount_marshall_perf_objects(prs_struct *ps, struct PERF_DAT
/*********************************************************************
*********************************************************************/
-static bool _reg_perfcount_marshall_hkpd(prs_struct *ps, struct PERF_DATA_BLOCK block)
-{
- int depth = 0;
- if(_reg_perfcount_marshall_perf_data_block(ps, block, depth) == True)
- {
- if(_reg_perfcount_marshall_perf_objects(ps, block, depth) == True)
- return True;
- }
- return False;
-}
-
-/*********************************************************************
-*********************************************************************/
-
WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbuf_len, const char *object_ids)
{
/*
@@ -1393,20 +1385,26 @@ WERROR reg_perfcount_get_hkpd(prs_struct *ps, uint32 max_buf_size, uint32 *outbu
base_index = reg_perfcount_get_base_index();
ZERO_STRUCT(block);
- buffer_size = reg_perfcount_get_perf_data_block(base_index, ps, &block, object_ids);
+ buffer_size = reg_perfcount_get_perf_data_block(base_index, ps->mem_ctx, &block, object_ids, ps->bigendian_data);
if(buffer_size < max_buf_size)
{
*outbuf_len = buffer_size;
- if(_reg_perfcount_marshall_hkpd(ps, block) == True)
- return WERR_OK;
- else
+
+ if (!_reg_perfcount_marshall_perf_data_block(ps, block, 0))
return WERR_NOMEM;
+
+ if (!_reg_perfcount_marshall_perf_objects(ps, block, 0))
+ return WERR_NOMEM;
+
+ return WERR_OK;
}
else
{
*outbuf_len = max_buf_size;
- _reg_perfcount_marshall_perf_data_block(ps, block, 0);
+ if (!_reg_perfcount_marshall_perf_data_block(ps, block, 0))
+ return WERR_NOMEM;
+
return WERR_INSUFFICIENT_BUFFER;
}
}