summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-07-11 18:01:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:14 -0500
commitfbdcf2663b56007a438ac4f0d8d82436b1bfe688 (patch)
tree4e42c1f061391cea3d640152fd240682cbf4fd9a /source3/utils
parent5bf62a0c3cc95abe918f3e772bb10e0a90fdce22 (diff)
downloadsamba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.gz
samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.bz2
samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.zip
r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/debug2html.c4
-rw-r--r--source3/utils/net.c8
-rw-r--r--source3/utils/net_ads.c11
-rw-r--r--source3/utils/net_idmap.c26
-rw-r--r--source3/utils/net_rpc.c23
-rw-r--r--source3/utils/net_rpc_printer.c25
-rw-r--r--source3/utils/net_rpc_registry.c67
-rw-r--r--source3/utils/net_rpc_samsync.c30
-rw-r--r--source3/utils/net_time.c10
-rw-r--r--source3/utils/ntlm_auth.c2
-rw-r--r--source3/utils/ntlm_auth_diagnostics.c8
-rw-r--r--source3/utils/sharesec.c414
-rw-r--r--source3/utils/smbcontrol.c2
-rw-r--r--source3/utils/status.c390
-rw-r--r--source3/utils/status_profile.c544
15 files changed, 1094 insertions, 470 deletions
diff --git a/source3/utils/debug2html.c b/source3/utils/debug2html.c
index bec4d81ae2..6d1b2b2535 100644
--- a/source3/utils/debug2html.c
+++ b/source3/utils/debug2html.c
@@ -145,6 +145,8 @@ static void newblock( dbg_Token old, dbg_Token newtok )
case dbg_lineno:
(void)printf( ")" );
break;
+ default:
+ break;
}
switch( newtok )
@@ -158,6 +160,8 @@ static void newblock( dbg_Token old, dbg_Token newtok )
case dbg_lineno:
(void)printf( "(" );
break;
+ default:
+ break;
}
} /* newblock */
diff --git a/source3/utils/net.c b/source3/utils/net.c
index bef2a0a83c..8b4fb042fc 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -77,6 +77,7 @@ const char *opt_target_workgroup = NULL;
int opt_machine_pass = 0;
BOOL opt_localgroup = False;
BOOL opt_domaingroup = False;
+static BOOL do_talloc_report=False;
const char *opt_newntname = "";
int opt_rid = 0;
int opt_acls = 0;
@@ -513,7 +514,7 @@ static int net_changesecretpw(int argc, const char **argv)
set_line_buffering(stdout);
set_line_buffering(stderr);
}
-
+
trust_pw = get_pass("Enter machine password: ", opt_stdin);
if (!secrets_store_machine_password(trust_pw, lp_workgroup(), sec_channel_type)) {
@@ -884,6 +885,7 @@ static struct functable net_func[] = {
{"timestamps", 0, POPT_ARG_NONE, &opt_timestamps},
{"exclude", 'e', POPT_ARG_STRING, &opt_exclude},
{"destination", 0, POPT_ARG_STRING, &opt_destination},
+ {"tallocreport", 0, POPT_ARG_NONE, &do_talloc_report},
POPT_COMMON_SAMBA
{ 0, 0, 0, 0}
@@ -947,6 +949,10 @@ static struct functable net_func[] = {
}
}
+ if (do_talloc_report) {
+ talloc_enable_leak_report();
+ }
+
if (opt_requester_name) {
set_global_myname(opt_requester_name);
}
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 9d122a466b..bfbc80759a 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -506,7 +506,8 @@ static int ads_user_info(int argc, const char **argv)
return -1;
}
- grouplist = ldap_get_values(ads->ld, res, "memberOf");
+ grouplist = ldap_get_values((LDAP *)ads->ld,
+ (LDAPMessage *)res, "memberOf");
if (grouplist) {
int i;
@@ -591,7 +592,7 @@ int net_ads_user(int argc, const char **argv)
shortattrs, usergrp_display,
disp_fields);
ads_destroy(&ads);
- return 0;
+ return ADS_ERR_OK(rc) ? 0 : -1;
}
return net_run_function(argc, argv, func, net_ads_user_usage);
@@ -716,7 +717,7 @@ int net_ads_group(int argc, const char **argv)
disp_fields);
ads_destroy(&ads);
- return 0;
+ return ADS_ERR_OK(rc) ? 0 : -1;
}
return net_run_function(argc, argv, func, net_ads_group_usage);
}
@@ -1011,7 +1012,7 @@ static ADS_STATUS net_precreate_machine_acct( ADS_STRUCT *ads, const char *ou )
asprintf(&dn, "%s,%s", ou_str, ads->config.bind_path);
free(ou_str);
- rc = ads_search_dn(ads, (void**)&res, dn, NULL);
+ rc = ads_search_dn(ads, &res, dn, NULL);
ads_msgfree(ads, res);
if (ADS_ERR_OK(rc)) {
@@ -1340,7 +1341,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
return -1;
}
- srv_dn = ldap_get_dn(ads->ld, res);
+ srv_dn = ldap_get_dn((LDAP *)ads->ld, (LDAPMessage *)res);
srv_cn = ldap_explode_dn(srv_dn, 1);
asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn[0], printername, srv_dn);
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 47e1f93b69..87da952247 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -185,6 +185,7 @@ static NTSTATUS net_idmap_fixup_hwm(void)
/***********************************************************
Write entries from stdin to current local idmap
**********************************************************/
+
static int net_idmap_restore(int argc, const char **argv)
{
if (!idmap_init(lp_idmap_backend())) {
@@ -193,10 +194,11 @@ static int net_idmap_restore(int argc, const char **argv)
}
while (!feof(stdin)) {
- fstring line, sid_string, fmt_string;
+ fstring line, sid_string, fmt_string1, fmt_string2;
int len;
unid_t id;
- int type = ID_EMPTY;
+ enum idmap_type type;
+ unsigned long idval;
DOM_SID sid;
if (fgets(line, sizeof(line)-1, stdin) == NULL)
@@ -207,20 +209,16 @@ static int net_idmap_restore(int argc, const char **argv)
if ( (len > 0) && (line[len-1] == '\n') )
line[len-1] = '\0';
- /* Yuck - this is broken for sizeof(gid_t) != sizeof(int) */
- snprintf(fmt_string, sizeof(fmt_string), "GID %%d %%%us", FSTRING_LEN);
- if (sscanf(line, fmt_string, &id.gid, sid_string) == 2) {
- type = ID_GROUPID;
- }
-
- /* Yuck - this is broken for sizeof(uid_t) != sizeof(int) */
+ snprintf(fmt_string1, sizeof(fmt_string1), "GID %%ul %%%us", FSTRING_LEN);
+ snprintf(fmt_string2, sizeof(fmt_string2), "UID %%ul %%%us", FSTRING_LEN);
- snprintf(fmt_string, sizeof(fmt_string), "UID %%d %%%us", FSTRING_LEN);
- if (sscanf(line, fmt_string, &id.uid, sid_string) == 2) {
+ if (sscanf(line, fmt_string1, &idval, sid_string) == 2) {
+ type = ID_GROUPID;
+ id.gid = (gid_t)idval;
+ } else if (sscanf(line, fmt_string2, &idval, sid_string) == 2) {
type = ID_USERID;
- }
-
- if (type == ID_EMPTY) {
+ id.uid = (uid_t)idval;
+ } else {
d_printf("ignoring invalid line [%s]\n", line);
continue;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index f32348935f..f2cd4adb17 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -4934,12 +4934,12 @@ static int rpc_file_close(int argc, const char **argv)
* @param str3 strings for FILE_INFO_3
**/
-static void display_file_info_3(FILE_INFO_3 *info3, FILE_INFO_3_STR *str3)
+static void display_file_info_3( FILE_INFO_3 *info3 )
{
fstring user = "", path = "";
- rpcstr_pull_unistr2_fstring(user, &str3->uni_user_name);
- rpcstr_pull_unistr2_fstring(path, &str3->uni_path_name);
+ rpcstr_pull_unistr2_fstring(user, info3->user);
+ rpcstr_pull_unistr2_fstring(path, info3->path);
d_printf("%-7.1d %-20.20s 0x%-4.2x %-6.1d %s\n",
info3->id, user, info3->perms, info3->num_locks, path);
@@ -4994,8 +4994,7 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid,
"\nFileId Opened by Perms Locks Path"\
"\n------ --------- ----- ----- ---- \n");
for (i = 0; i < ctr.num_entries; i++)
- display_file_info_3(&ctr.file.info3[i].info_3,
- &ctr.file.info3[i].info_3_str);
+ display_file_info_3(&ctr.file.info3[i]);
done:
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
@@ -6269,7 +6268,7 @@ static int rpc_trustdom(int argc, const char **argv)
*/
BOOL net_rpc_check(unsigned flags)
{
- struct cli_state cli;
+ struct cli_state *cli;
BOOL ret = False;
struct in_addr server_ip;
char *server_name = NULL;
@@ -6278,23 +6277,23 @@ BOOL net_rpc_check(unsigned flags)
if (!net_find_server(NULL, flags, &server_ip, &server_name))
return False;
- ZERO_STRUCT(cli);
- if (cli_initialise(&cli) == False)
+ if ((cli = cli_initialise()) == NULL) {
return False;
+ }
- if (!cli_connect(&cli, server_name, &server_ip))
+ if (!cli_connect(cli, server_name, &server_ip))
goto done;
if (!attempt_netbios_session_request(&cli, global_myname(),
server_name, &server_ip))
goto done;
- if (!cli_negprot(&cli))
+ if (!cli_negprot(cli))
goto done;
- if (cli.protocol < PROTOCOL_NT1)
+ if (cli->protocol < PROTOCOL_NT1)
goto done;
ret = True;
done:
- cli_shutdown(&cli);
+ cli_shutdown(cli);
return ret;
}
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 8808d549ac..50ab50bace 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -129,18 +129,23 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
break;
case REG_MULTI_SZ: {
- uint16 *curstr = (uint16 *) value.data_p;
- uint8 *start = value.data_p;
- d_printf("\t[%s:%s]: REG_MULTI_SZ:\n", subkey, value.valuename);
- while ((*curstr != 0) &&
- ((uint8 *) curstr < start + value.size)) {
- rpcstr_pull(text, curstr, sizeof(text), -1,
- STR_TERMINATE);
- d_printf("%s\n", text);
- curstr += strlen(text) + 1;
+ int i, num_values;
+ char **values;
+
+ if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
+ value.size,
+ &num_values,
+ &values))) {
+ d_printf("reg_pull_multi_sz failed\n");
+ break;
+ }
+
+ for (i=0; i<num_values; i++) {
+ d_printf("%s\n", values[i]);
}
+ TALLOC_FREE(values);
+ break;
}
- break;
default:
d_printf("\t%s: unknown type %d\n", value.valuename, value.type);
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 873cb7b459..3eaff90155 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -25,35 +25,6 @@
/********************************************************************
********************************************************************/
-char* dump_regval_type( uint32 type )
-{
- static fstring string;
-
- switch (type) {
- case REG_SZ:
- fstrcpy( string, "REG_SZ" );
- break;
- case REG_MULTI_SZ:
- fstrcpy( string, "REG_MULTI_SZ" );
- break;
- case REG_EXPAND_SZ:
- fstrcpy( string, "REG_EXPAND_SZ" );
- break;
- case REG_DWORD:
- fstrcpy( string, "REG_DWORD" );
- break;
- case REG_BINARY:
- fstrcpy( string, "REG_BINARY" );
- break;
- default:
- fstr_sprintf( string, "UNKNOWN [%d]", type );
- }
-
- return string;
-}
-/********************************************************************
-********************************************************************/
-
void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer )
{
pstring string;
@@ -64,9 +35,26 @@ void dump_regval_buffer( uint32 type, REGVAL_BUFFER *buffer )
rpcstr_pull( string, buffer->buffer, sizeof(string), -1, STR_TERMINATE );
d_printf("%s\n", string);
break;
- case REG_MULTI_SZ:
+ case REG_MULTI_SZ: {
+ int i, num_values;
+ char **values;
+
d_printf("\n");
+
+ if (!NT_STATUS_IS_OK(reg_pull_multi_sz(NULL, buffer->buffer,
+ buffer->buf_len,
+ &num_values,
+ &values))) {
+ d_printf("reg_pull_multi_sz failed\n");
+ break;
+ }
+
+ for (i=0; i<num_values; i++) {
+ d_printf("%s\n", values[i]);
+ }
+ TALLOC_FREE(values);
break;
+ }
case REG_DWORD:
value = IVAL( buffer->buffer, 0 );
d_printf( "0x%x\n", value );
@@ -113,16 +101,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
if ( !W_ERROR_IS_OK(result) ) {
- d_fprintf(stderr, "Unable to connect to remote registry\n");
+ d_fprintf(stderr, "Unable to connect to remote registry: "
+ "%s\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
- if ( strlen( subpath ) != 0 ) {
- result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key );
- if ( !W_ERROR_IS_OK(result) ) {
- d_fprintf(stderr, "Unable to open [%s]\n", argv[0]);
- return werror_to_ntstatus(result);
- }
+ result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath,
+ MAXIMUM_ALLOWED_ACCESS, &pol_key );
+ if ( !W_ERROR_IS_OK(result) ) {
+ d_fprintf(stderr, "Unable to open [%s]: %s\n", argv[0],
+ dos_errstr(result));
+ return werror_to_ntstatus(result);
}
/* get the subkeys */
@@ -173,7 +162,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
}
d_printf("Valuename = %s\n", name );
- d_printf("Type = %s\n", dump_regval_type(type) );
+ d_printf("Type = %s\n", reg_type_lookup(type));
d_printf("Data = " );
dump_regval_buffer( type, &value );
d_printf("\n" );
@@ -279,7 +268,7 @@ static void dump_values( REGF_NK_REC *nk )
for ( i=0; i<nk->num_values; i++ ) {
d_printf( "\"%s\" = ", nk->values[i].valuename ? nk->values[i].valuename : "(default)" );
- d_printf( "(%s) ", dump_regval_type( nk->values[i].type ) );
+ d_printf( "(%s) ", reg_type_lookup( nk->values[i].type ) );
data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET;
switch ( nk->values[i].type ) {
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 4f99c3035c..861040533c 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -42,7 +42,7 @@ static void display_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *g)
d_printf("\n");
}
-static const char *display_time(NTTIME *nttime)
+static const char *display_time(const UINT64_S *nttime)
{
static fstring string;
@@ -123,11 +123,19 @@ static void display_account_info(uint32 rid, SAM_ACCOUNT_INFO *a)
pdb_encode_acct_ctrl(a->acb_info, NEW_PW_FORMAT_SPACE_PADDED_LEN));
}
+static time_t uint64s_nt_time_to_unix_abs(const UINT64_S *src)
+{
+ NTTIME nttime;
+ nttime.high = src->high;
+ nttime.low = src->low;
+ return nt_time_to_unix_abs(&nttime);
+}
+
static void display_domain_info(SAM_DOMAIN_INFO *a)
{
time_t u_logout;
- u_logout = nt_time_to_unix_abs((NTTIME *)&a->force_logoff);
+ u_logout = uint64s_nt_time_to_unix_abs(&a->force_logoff);
d_printf("Domain name: %s\n", unistr2_static(&a->uni_dom_name));
@@ -136,11 +144,11 @@ static void display_domain_info(SAM_DOMAIN_INFO *a)
d_printf("Force Logoff: %d\n", (int)u_logout);
- d_printf("Max Password Age: %s\n", display_time((NTTIME *)&a->max_pwd_age));
- d_printf("Min Password Age: %s\n", display_time((NTTIME *)&a->min_pwd_age));
+ d_printf("Max Password Age: %s\n", display_time(&a->max_pwd_age));
+ d_printf("Min Password Age: %s\n", display_time(&a->min_pwd_age));
- d_printf("Lockout Time: %s\n", display_time((NTTIME *)&a->account_lockout.lockout_duration));
- d_printf("Lockout Reset Time: %s\n", display_time((NTTIME *)&a->account_lockout.reset_count));
+ d_printf("Lockout Time: %s\n", display_time(&a->account_lockout.lockout_duration));
+ d_printf("Lockout Reset Time: %s\n", display_time(&a->account_lockout.reset_count));
d_printf("Bad Attempt Lockout: %d\n", a->account_lockout.bad_attempt_lockout);
d_printf("User must logon to change password: %d\n", a->logon_chgpass);
@@ -858,11 +866,11 @@ static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta)
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
pstring domname;
- u_max_age = nt_time_to_unix_abs((NTTIME *)&delta->max_pwd_age);
- u_min_age = nt_time_to_unix_abs((NTTIME *)&delta->min_pwd_age);
- u_logout = nt_time_to_unix_abs((NTTIME *)&delta->force_logoff);
- u_lockoutreset = nt_time_to_unix_abs((NTTIME *)&delta->account_lockout.reset_count);
- u_lockouttime = nt_time_to_unix_abs((NTTIME *)&delta->account_lockout.lockout_duration);
+ u_max_age = uint64s_nt_time_to_unix_abs(&delta->max_pwd_age);
+ u_min_age = uint64s_nt_time_to_unix_abs(&delta->min_pwd_age);
+ u_logout = uint64s_nt_time_to_unix_abs(&delta->force_logoff);
+ u_lockoutreset = uint64s_nt_time_to_unix_abs(&delta->account_lockout.reset_count);
+ u_lockouttime = uint64s_nt_time_to_unix_abs(&delta->account_lockout.lockout_duration);
unistr2_to_ascii(domname, &delta->uni_dom_name, sizeof(domname) - 1);
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index f6486286a6..f6269627da 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -30,8 +30,10 @@ static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone)
time_t ret = 0;
struct cli_state *cli = NULL;
- cli = cli_initialise(NULL);
- if (!cli) goto done;
+ cli = cli_initialise();
+ if (!cli) {
+ goto done;
+ }
if (!cli_connect(cli, host, ip)) {
fprintf(stderr,"Can't contact server\n");
@@ -58,7 +60,9 @@ static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone)
if (zone) *zone = cli->serverzone;
done:
- if (cli) cli_shutdown(cli);
+ if (cli) {
+ cli_shutdown(cli);
+ }
return ret;
}
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index ef24f9f161..fc9e3e9546 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -515,7 +515,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_server(NTLMSSP_STATE **ntlmssp_state)
NTSTATUS status = ntlmssp_server_start(ntlmssp_state);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("Could not start NTLMSSP client: %s\n",
+ DEBUG(1, ("Could not start NTLMSSP server: %s\n",
nt_errstr(status)));
return status;
}
diff --git a/source3/utils/ntlm_auth_diagnostics.c b/source3/utils/ntlm_auth_diagnostics.c
index c8ea966a55..e69715affd 100644
--- a/source3/utils/ntlm_auth_diagnostics.c
+++ b/source3/utils/ntlm_auth_diagnostics.c
@@ -445,6 +445,7 @@ static BOOL test_plaintext(enum ntlm_break break_which)
DATA_BLOB nt_response = data_blob(NULL, 0);
DATA_BLOB lm_response = data_blob(NULL, 0);
char *password;
+ smb_ucs2_t *nt_response_ucs2;
uchar user_session_key[16];
uchar lm_key[16];
@@ -457,12 +458,13 @@ static BOOL test_plaintext(enum ntlm_break break_which)
flags |= WBFLAG_PAM_LMKEY;
flags |= WBFLAG_PAM_USER_SESSION_KEY;
- if ((push_ucs2_allocate((smb_ucs2_t **)&nt_response.data, opt_password)) == -1) {
+ if ((push_ucs2_allocate(&nt_response_ucs2, opt_password)) == -1) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
exit(1);
}
- nt_response.length = strlen_w(((void *)nt_response.data))*sizeof(smb_ucs2_t);
+ nt_response.data = (unsigned char *)nt_response_ucs2;
+ nt_response.length = strlen_w(nt_response_ucs2)*sizeof(smb_ucs2_t);
if ((password = strdup_upper(opt_password)) == NULL) {
DEBUG(0, ("strdup_upper failed!\n"));
@@ -472,7 +474,7 @@ static BOOL test_plaintext(enum ntlm_break break_which)
if ((convert_string_allocate(NULL, CH_UNIX,
CH_DOS, password,
strlen(password)+1,
- (void**)&lm_response.data,True)) == -1) {
+ &lm_response.data,True)) == -1) {
DEBUG(0, ("convert_string_allocate failed!\n"));
exit(1);
}
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
new file mode 100644
index 0000000000..aa4210b51d
--- /dev/null
+++ b/source3/utils/sharesec.c
@@ -0,0 +1,414 @@
+/*
+ * Unix SMB/Netbios implementation.
+ * Utility for managing share permissions
+ *
+ * Copyright (C) Tim Potter 2000
+ * Copyright (C) Jeremy Allison 2000
+ * Copyright (C) Jelmer Vernooij 2003
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "includes.h"
+
+#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
+
+/* numeric is set when the user wants numeric SIDs and ACEs rather
+ than going via LSA calls to resolve them */
+static BOOL numeric = False;
+
+enum acl_mode {SMB_ACL_REMOVE, SMB_ACL_MODIFY, SMB_ACL_ADD, SMB_ACL_REPLACE, SMB_ACL_VIEW };
+enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR};
+
+struct perm_value {
+ const char *perm;
+ uint32 mask;
+};
+
+/* These values discovered by inspection */
+
+static const struct perm_value special_values[] = {
+ { "R", 0x00120089 },
+ { "W", 0x00120116 },
+ { "X", 0x001200a0 },
+ { "D", 0x00010000 },
+ { "P", 0x00040000 },
+ { "O", 0x00080000 },
+ { NULL, 0 },
+};
+
+static const struct perm_value standard_values[] = {
+ { "READ", 0x001200a9 },
+ { "CHANGE", 0x001301bf },
+ { "FULL", 0x001f01ff },
+ { NULL, 0 },
+};
+
+/********************************************************************
+ print an ACE on a FILE, using either numeric or ascii representation
+********************************************************************/
+
+static void print_ace(FILE *f, SEC_ACE *ace)
+{
+ const struct perm_value *v;
+ fstring sidstr;
+ int do_print = 0;
+ uint32 got_mask;
+
+ sid_to_string(sidstr, &ace->trustee);
+
+ fprintf(f, "%s:", sidstr);
+
+ if (numeric) {
+ fprintf(f, "%d/%d/0x%08x",
+ ace->type, ace->flags, ace->info.mask);
+ return;
+ }
+
+ /* Ace type */
+
+ if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED) {
+ fprintf(f, "ALLOWED");
+ } else if (ace->type == SEC_ACE_TYPE_ACCESS_DENIED) {
+ fprintf(f, "DENIED");
+ } else {
+ fprintf(f, "%d", ace->type);
+ }
+
+ /* Not sure what flags can be set in a file ACL */
+
+ fprintf(f, "/%d/", ace->flags);
+
+ /* Standard permissions */
+
+ for (v = standard_values; v->perm; v++) {
+ if (ace->info.mask == v->mask) {
+ fprintf(f, "%s", v->perm);
+ return;
+ }
+ }
+
+ /* Special permissions. Print out a hex value if we have
+ leftover bits in the mask. */
+
+ got_mask = ace->info.mask;
+
+ again:
+ for (v = special_values; v->perm; v++) {
+ if ((ace->info.mask & v->mask) == v->mask) {
+ if (do_print) {
+ fprintf(f, "%s", v->perm);
+ }
+ got_mask &= ~v->mask;
+ }
+ }
+
+ if (!do_print) {
+ if (got_mask != 0) {
+ fprintf(f, "0x%08x", ace->info.mask);
+ } else {
+ do_print = 1;
+ goto again;
+ }
+ }
+}
+
+/********************************************************************
+ print a ascii version of a security descriptor on a FILE handle
+********************************************************************/
+
+static void sec_desc_print(FILE *f, SEC_DESC *sd)
+{
+ fstring sidstr;
+ uint32 i;
+
+ fprintf(f, "REVISION:%d\n", sd->revision);
+
+ /* Print owner and group sid */
+
+ if (sd->owner_sid) {
+ sid_to_string(sidstr, sd->owner_sid);
+ } else {
+ fstrcpy(sidstr, "");
+ }
+
+ fprintf(f, "OWNER:%s\n", sidstr);
+
+ if (sd->grp_sid) {
+ sid_to_string(sidstr, sd->grp_sid);
+ } else {
+ fstrcpy(sidstr, "");
+ }
+
+ fprintf(f, "GROUP:%s\n", sidstr);
+
+ /* Print aces */
+ for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) {
+ SEC_ACE *ace = &sd->dacl->ace[i];
+ fprintf(f, "ACL:");
+ print_ace(f, ace);
+ fprintf(f, "\n");
+ }
+
+}
+
+/********************************************************************
+********************************************************************/
+
+static BOOL parse_ace( TALLOC_CTX *ctx, SEC_ACE *ace, char *entry )
+{
+ SEC_ACCESS sa;
+ char *p = strchr_m( entry, ':' );
+ DOM_SID sid;
+ uint32 mask;
+
+ if ( !p )
+ return False;
+
+ *p = '\0';
+ p++;
+
+ string_to_sid( &sid, entry );
+
+ switch ( *p ) {
+ case 'F':
+ case 'f':
+ mask = GENERIC_RIGHTS_FILE_ALL_ACCESS|STD_RIGHT_ALL_ACCESS;
+ break;
+
+ case 'R':
+ case 'r':
+ mask = GENERIC_RIGHTS_FILE_READ|GENERIC_RIGHTS_FILE_EXECUTE|\
+ STANDARD_RIGHTS_READ_ACCESS|STANDARD_RIGHTS_EXECUTE_ACCESS;
+ break;
+
+ default:
+ return False;
+ }
+
+ init_sec_access( &sa, mask );
+
+ /* no flags on share permissions */
+ init_sec_ace( ace, &sid, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0 );
+
+ return True;
+}
+
+
+/********************************************************************
+********************************************************************/
+
+static SEC_DESC* parse_acl_string( TALLOC_CTX *ctx, const char *szACL, size_t *sd_size )
+{
+ SEC_DESC *sd = NULL;
+ SEC_ACE *ace;
+ SEC_ACL *acl;
+ int num_ace;
+ const char *pacl;
+ int i;
+
+ if ( !szACL )
+ return NULL;
+
+ pacl = szACL;
+ num_ace = count_chars( pacl, ',' ) + 1;
+
+ if ( !(ace = TALLOC_ZERO_ARRAY( ctx, SEC_ACE, num_ace )) )
+ return NULL;
+
+ for ( i=0; i<num_ace; i++ ) {
+ char *end_acl = strchr_m( pacl, ',' );
+ fstring acl_string;
+
+ strncpy( acl_string, pacl, MIN( PTR_DIFF( end_acl, pacl ), sizeof(fstring)-1) );
+ acl_string[MIN( PTR_DIFF( end_acl, pacl ), sizeof(fstring)-1)] = '\0';
+
+ if ( !parse_ace( ctx, &ace[i], acl_string ) )
+ return NULL;
+
+ pacl = end_acl;
+ pacl++;
+ }
+
+ if ( !(acl = make_sec_acl( ctx, NT4_ACL_REVISION, num_ace, ace )) )
+ return NULL;
+
+ sd = make_sec_desc( ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE,
+ &global_sid_Builtin_Administrators,
+ &global_sid_Builtin_Administrators,
+ NULL, acl, sd_size);
+
+ return sd;
+}
+
+/********************************************************************
+ main program
+********************************************************************/
+
+int main(int argc, const char *argv[])
+{
+ int opt;
+ enum acl_mode mode = SMB_ACL_REPLACE;
+ static char *the_acl = NULL;
+ fstring sharename;
+ BOOL force_acl = False;
+ size_t sd_size = 0;
+ SEC_DESC *secdesc;
+ int snum;
+ poptContext pc;
+ TALLOC_CTX *ctx;
+ BOOL initialize_sid = False;
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+#if 0
+ { "remove", 'r', POPT_ARG_STRING, NULL, 'r', "Delete an ACE", "ACL" },
+ { "modify", 'm', POPT_ARG_STRING, NULL, 'm', "Modify an acl", "ACL" },
+ { "add", 'a', POPT_ARG_STRING, NULL, 'a', "Add an ACE", "ACL" },
+#endif
+ { "replace", 'R', POPT_ARG_STRING, NULL, 'R', "Set share mission ACL", "ACLS" },
+ { "view", 'v', POPT_ARG_NONE, NULL, 'v', "View current share permissions" },
+ { "machine-sid", 'M', POPT_ARG_NONE, NULL, 'M', "Initialize the machine SID" },
+ { "force", 'F', POPT_ARG_NONE, NULL, 'F', "Force storing the ACL", "ACLS" },
+ POPT_COMMON_SAMBA
+ { NULL }
+ };
+
+ if ( !(ctx = talloc_init("main")) ) {
+ fprintf( stderr, "Failed to initialize talloc context!\n");
+ return -1;
+ }
+
+ /* set default debug level to 1 regardless of what smb.conf sets */
+ setup_logging( "sharesec", True );
+ DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
+ dbf = x_stderr;
+ x_setbuf( x_stderr, NULL );
+
+ setlinebuf(stdout);
+
+ load_case_tables();
+
+ lp_load( dyn_CONFIGFILE, False, False, False, True );
+
+ pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
+
+ poptSetOtherOptionHelp(pc, "sharename\n");
+
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+#if 0
+ case 'r':
+ the_acl = smb_xstrdup(poptGetOptArg(pc));
+ mode = SMB_ACL_REMOVE;
+ break;
+
+ case 'm':
+ the_acl = smb_xstrdup(poptGetOptArg(pc));
+ mode = SMB_ACL_MODIFY;
+ break;
+
+ case 'a':
+ the_acl = smb_xstrdup(poptGetOptArg(pc));
+ mode = SMB_ACL_ADD;
+ break;
+#endif
+ case 'R':
+ the_acl = smb_xstrdup(poptGetOptArg(pc));
+ mode = SMB_ACL_REPLACE;
+ break;
+
+ case 'v':
+ mode = SMB_ACL_VIEW;
+ break;
+
+ case 'F':
+ force_acl = True;
+ break;
+
+ case 'M':
+ initialize_sid = True;
+ break;
+ }
+ }
+
+ /* check for initializing secrets.tdb first */
+
+ if ( initialize_sid ) {
+ DOM_SID *sid = get_global_sam_sid();
+
+ if ( !sid ) {
+ fprintf( stderr, "Failed to retrieve Machine SID!\n");
+ return 3;
+ }
+
+ printf ("%s\n", sid_string_static( sid ) );
+ return 0;
+ }
+
+ if ( mode == SMB_ACL_VIEW && force_acl ) {
+ fprintf( stderr, "Invalid combination of -F and -v\n");
+ return -1;
+ }
+
+ /* get the sharename */
+
+ if(!poptPeekArg(pc)) {
+ poptPrintUsage(pc, stderr, 0);
+ return -1;
+ }
+
+ fstrcpy(sharename, poptGetArg(pc));
+
+ snum = lp_servicenumber( sharename );
+
+ if ( snum == -1 && !force_acl ) {
+ fprintf( stderr, "Invalid sharename: %s\n", sharename);
+ return -1;
+ }
+
+ switch ( mode ) {
+ case SMB_ACL_VIEW:
+ if (!(secdesc = get_share_security( ctx, snum, &sd_size )) ) {
+ fprintf(stderr, "Unable to retrieve permissions for share [%s]\n", sharename);
+ return -1;
+ }
+ sec_desc_print( stdout, secdesc );
+ break;
+
+ case SMB_ACL_REMOVE:
+ case SMB_ACL_ADD:
+ case SMB_ACL_MODIFY:
+ printf( "Not implemented\n");
+ break;
+
+ case SMB_ACL_REPLACE:
+ if ( !(secdesc = parse_acl_string( ctx, the_acl, &sd_size )) ) {
+ fprintf( stderr, "Failed to parse acl\n");
+ return -1;
+ }
+
+ if ( !set_share_security( ctx, lp_servicename(snum), secdesc ) ) {
+ fprintf( stderr, "Failed to store acl for share [%s]\n", sharename );
+ return 2;
+ }
+ break;
+ }
+
+ talloc_destroy(ctx);
+
+ return 0;
+}
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 0c6a1341c0..a23492f9dc 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -890,7 +890,7 @@ static BOOL do_winbind_offline(const struct process_id pid,
ret = send_message(pid, MSG_WINBIND_OFFLINE, NULL, 0, False);
/* Check that the entry "WINBINDD_OFFLINE" still exists. */
- tdb->ecode = TDB_SUCCESS;
+ /* tdb->ecode = TDB_SUCCESS; */
d = tdb_fetch_bystring( tdb, "WINBINDD_OFFLINE" );
/* As this is a key with no data we don't need to free, we
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 163d99a2f6..58349f1f9a 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -48,6 +48,9 @@ static BOOL numeric_only = False;
const char *username = NULL;
+extern BOOL status_profile_dump(BOOL be_verbose);
+extern BOOL status_profile_rates(BOOL be_verbose);
+
/* added by OH */
static void Ucrit_addUid(uid_t uid)
{
@@ -182,368 +185,6 @@ static void print_brl(SMB_DEV_T dev,
(double)start, (double)size);
}
-
-/*******************************************************************
- dump the elements of the profile structure
- ******************************************************************/
-static int profile_dump(void)
-{
-#ifdef WITH_PROFILE
- if (!profile_setup(True)) {
- fprintf(stderr,"Failed to initialise profile memory\n");
- return -1;
- }
-
- d_printf("smb_count: %u\n", profile_p->smb_count);
- d_printf("uid_changes: %u\n", profile_p->uid_changes);
- d_printf("************************ System Calls ****************************\n");
- d_printf("opendir_count: %u\n", profile_p->syscall_opendir_count);
- d_printf("opendir_time: %u\n", profile_p->syscall_opendir_time);
- d_printf("readdir_count: %u\n", profile_p->syscall_readdir_count);
- d_printf("readdir_time: %u\n", profile_p->syscall_readdir_time);
- d_printf("mkdir_count: %u\n", profile_p->syscall_mkdir_count);
- d_printf("mkdir_time: %u\n", profile_p->syscall_mkdir_time);
- d_printf("rmdir_count: %u\n", profile_p->syscall_rmdir_count);
- d_printf("rmdir_time: %u\n", profile_p->syscall_rmdir_time);
- d_printf("closedir_count: %u\n", profile_p->syscall_closedir_count);
- d_printf("closedir_time: %u\n", profile_p->syscall_closedir_time);
- d_printf("open_count: %u\n", profile_p->syscall_open_count);
- d_printf("open_time: %u\n", profile_p->syscall_open_time);
- d_printf("close_count: %u\n", profile_p->syscall_close_count);
- d_printf("close_time: %u\n", profile_p->syscall_close_time);
- d_printf("read_count: %u\n", profile_p->syscall_read_count);
- d_printf("read_time: %u\n", profile_p->syscall_read_time);
- d_printf("read_bytes: %u\n", profile_p->syscall_read_bytes);
- d_printf("write_count: %u\n", profile_p->syscall_write_count);
- d_printf("write_time: %u\n", profile_p->syscall_write_time);
- d_printf("write_bytes: %u\n", profile_p->syscall_write_bytes);
- d_printf("pread_count: %u\n", profile_p->syscall_pread_count);
- d_printf("pread_time: %u\n", profile_p->syscall_pread_time);
- d_printf("pread_bytes: %u\n", profile_p->syscall_pread_bytes);
- d_printf("pwrite_count: %u\n", profile_p->syscall_pwrite_count);
- d_printf("pwrite_time: %u\n", profile_p->syscall_pwrite_time);
- d_printf("pwrite_bytes: %u\n", profile_p->syscall_pwrite_bytes);
-#ifdef WITH_SENDFILE
- d_printf("sendfile_count: %u\n", profile_p->syscall_sendfile_count);
- d_printf("sendfile_time: %u\n", profile_p->syscall_sendfile_time);
- d_printf("sendfile_bytes: %u\n", profile_p->syscall_sendfile_bytes);
-#endif
- d_printf("lseek_count: %u\n", profile_p->syscall_lseek_count);
- d_printf("lseek_time: %u\n", profile_p->syscall_lseek_time);
- d_printf("rename_count: %u\n", profile_p->syscall_rename_count);
- d_printf("rename_time: %u\n", profile_p->syscall_rename_time);
- d_printf("fsync_count: %u\n", profile_p->syscall_fsync_count);
- d_printf("fsync_time: %u\n", profile_p->syscall_fsync_time);
- d_printf("stat_count: %u\n", profile_p->syscall_stat_count);
- d_printf("stat_time: %u\n", profile_p->syscall_stat_time);
- d_printf("fstat_count: %u\n", profile_p->syscall_fstat_count);
- d_printf("fstat_time: %u\n", profile_p->syscall_fstat_time);
- d_printf("lstat_count: %u\n", profile_p->syscall_lstat_count);
- d_printf("lstat_time: %u\n", profile_p->syscall_lstat_time);
- d_printf("unlink_count: %u\n", profile_p->syscall_unlink_count);
- d_printf("unlink_time: %u\n", profile_p->syscall_unlink_time);
- d_printf("chmod_count: %u\n", profile_p->syscall_chmod_count);
- d_printf("chmod_time: %u\n", profile_p->syscall_chmod_time);
- d_printf("fchmod_count: %u\n", profile_p->syscall_fchmod_count);
- d_printf("fchmod_time: %u\n", profile_p->syscall_fchmod_time);
- d_printf("chown_count: %u\n", profile_p->syscall_chown_count);
- d_printf("chown_time: %u\n", profile_p->syscall_chown_time);
- d_printf("fchown_count: %u\n", profile_p->syscall_fchown_count);
- d_printf("fchown_time: %u\n", profile_p->syscall_fchown_time);
- d_printf("chdir_count: %u\n", profile_p->syscall_chdir_count);
- d_printf("chdir_time: %u\n", profile_p->syscall_chdir_time);
- d_printf("getwd_count: %u\n", profile_p->syscall_getwd_count);
- d_printf("getwd_time: %u\n", profile_p->syscall_getwd_time);
- d_printf("utime_count: %u\n", profile_p->syscall_utime_count);
- d_printf("utime_time: %u\n", profile_p->syscall_utime_time);
- d_printf("ftruncate_count: %u\n", profile_p->syscall_ftruncate_count);
- d_printf("ftruncate_time: %u\n", profile_p->syscall_ftruncate_time);
- d_printf("fcntl_lock_count: %u\n", profile_p->syscall_fcntl_lock_count);
- d_printf("fcntl_lock_time: %u\n", profile_p->syscall_fcntl_lock_time);
- d_printf("readlink_count: %u\n", profile_p->syscall_readlink_count);
- d_printf("readlink_time: %u\n", profile_p->syscall_readlink_time);
- d_printf("symlink_count: %u\n", profile_p->syscall_symlink_count);
- d_printf("symlink_time: %u\n", profile_p->syscall_symlink_time);
- d_printf("************************ Statcache *******************************\n");
- d_printf("lookups: %u\n", profile_p->statcache_lookups);
- d_printf("misses: %u\n", profile_p->statcache_misses);
- d_printf("hits: %u\n", profile_p->statcache_hits);
- d_printf("************************ Writecache ******************************\n");
- d_printf("read_hits: %u\n", profile_p->writecache_read_hits);
- d_printf("abutted_writes: %u\n", profile_p->writecache_abutted_writes);
- d_printf("total_writes: %u\n", profile_p->writecache_total_writes);
- d_printf("non_oplock_writes: %u\n", profile_p->writecache_non_oplock_writes);
- d_printf("direct_writes: %u\n", profile_p->writecache_direct_writes);
- d_printf("init_writes: %u\n", profile_p->writecache_init_writes);
- d_printf("flushed_writes[SEEK]: %u\n", profile_p->writecache_flushed_writes[SEEK_FLUSH]);
- d_printf("flushed_writes[READ]: %u\n", profile_p->writecache_flushed_writes[READ_FLUSH]);
- d_printf("flushed_writes[WRITE]: %u\n", profile_p->writecache_flushed_writes[WRITE_FLUSH]);
- d_printf("flushed_writes[READRAW]: %u\n", profile_p->writecache_flushed_writes[READRAW_FLUSH]);
- d_printf("flushed_writes[OPLOCK_RELEASE]: %u\n", profile_p->writecache_flushed_writes[OPLOCK_RELEASE_FLUSH]);
- d_printf("flushed_writes[CLOSE]: %u\n", profile_p->writecache_flushed_writes[CLOSE_FLUSH]);
- d_printf("flushed_writes[SYNC]: %u\n", profile_p->writecache_flushed_writes[SYNC_FLUSH]);
- d_printf("flushed_writes[SIZECHANGE]: %u\n", profile_p->writecache_flushed_writes[SIZECHANGE_FLUSH]);
- d_printf("num_perfect_writes: %u\n", profile_p->writecache_num_perfect_writes);
- d_printf("num_write_caches: %u\n", profile_p->writecache_num_write_caches);
- d_printf("allocated_write_caches: %u\n", profile_p->writecache_allocated_write_caches);
- d_printf("************************ SMB Calls *******************************\n");
- d_printf("mkdir_count: %u\n", profile_p->SMBmkdir_count);
- d_printf("mkdir_time: %u\n", profile_p->SMBmkdir_time);
- d_printf("rmdir_count: %u\n", profile_p->SMBrmdir_count);
- d_printf("rmdir_time: %u\n", profile_p->SMBrmdir_time);
- d_printf("open_count: %u\n", profile_p->SMBopen_count);
- d_printf("open_time: %u\n", profile_p->SMBopen_time);
- d_printf("create_count: %u\n", profile_p->SMBcreate_count);
- d_printf("create_time: %u\n", profile_p->SMBcreate_time);
- d_printf("close_count: %u\n", profile_p->SMBclose_count);
- d_printf("close_time: %u\n", profile_p->SMBclose_time);
- d_printf("flush_count: %u\n", profile_p->SMBflush_count);
- d_printf("flush_time: %u\n", profile_p->SMBflush_time);
- d_printf("unlink_count: %u\n", profile_p->SMBunlink_count);
- d_printf("unlink_time: %u\n", profile_p->SMBunlink_time);
- d_printf("mv_count: %u\n", profile_p->SMBmv_count);
- d_printf("mv_time: %u\n", profile_p->SMBmv_time);
- d_printf("getatr_count: %u\n", profile_p->SMBgetatr_count);
- d_printf("getatr_time: %u\n", profile_p->SMBgetatr_time);
- d_printf("setatr_count: %u\n", profile_p->SMBsetatr_count);
- d_printf("setatr_time: %u\n", profile_p->SMBsetatr_time);
- d_printf("read_count: %u\n", profile_p->SMBread_count);
- d_printf("read_time: %u\n", profile_p->SMBread_time);
- d_printf("write_count: %u\n", profile_p->SMBwrite_count);
- d_printf("write_time: %u\n", profile_p->SMBwrite_time);
- d_printf("lock_count: %u\n", profile_p->SMBlock_count);
- d_printf("lock_time: %u\n", profile_p->SMBlock_time);
- d_printf("unlock_count: %u\n", profile_p->SMBunlock_count);
- d_printf("unlock_time: %u\n", profile_p->SMBunlock_time);
- d_printf("ctemp_count: %u\n", profile_p->SMBctemp_count);
- d_printf("ctemp_time: %u\n", profile_p->SMBctemp_time);
- d_printf("mknew_count: %u\n", profile_p->SMBmknew_count);
- d_printf("mknew_time: %u\n", profile_p->SMBmknew_time);
- d_printf("chkpth_count: %u\n", profile_p->SMBchkpth_count);
- d_printf("chkpth_time: %u\n", profile_p->SMBchkpth_time);
- d_printf("exit_count: %u\n", profile_p->SMBexit_count);
- d_printf("exit_time: %u\n", profile_p->SMBexit_time);
- d_printf("lseek_count: %u\n", profile_p->SMBlseek_count);
- d_printf("lseek_time: %u\n", profile_p->SMBlseek_time);
- d_printf("lockread_count: %u\n", profile_p->SMBlockread_count);
- d_printf("lockread_time: %u\n", profile_p->SMBlockread_time);
- d_printf("writeunlock_count: %u\n", profile_p->SMBwriteunlock_count);
- d_printf("writeunlock_time: %u\n", profile_p->SMBwriteunlock_time);
- d_printf("readbraw_count: %u\n", profile_p->SMBreadbraw_count);
- d_printf("readbraw_time: %u\n", profile_p->SMBreadbraw_time);
- d_printf("readBmpx_count: %u\n", profile_p->SMBreadBmpx_count);
- d_printf("readBmpx_time: %u\n", profile_p->SMBreadBmpx_time);
- d_printf("readBs_count: %u\n", profile_p->SMBreadBs_count);
- d_printf("readBs_time: %u\n", profile_p->SMBreadBs_time);
- d_printf("writebraw_count: %u\n", profile_p->SMBwritebraw_count);
- d_printf("writebraw_time: %u\n", profile_p->SMBwritebraw_time);
- d_printf("writeBmpx_count: %u\n", profile_p->SMBwriteBmpx_count);
- d_printf("writeBmpx_time: %u\n", profile_p->SMBwriteBmpx_time);
- d_printf("writeBs_count: %u\n", profile_p->SMBwriteBs_count);
- d_printf("writeBs_time: %u\n", profile_p->SMBwriteBs_time);
- d_printf("writec_count: %u\n", profile_p->SMBwritec_count);
- d_printf("writec_time: %u\n", profile_p->SMBwritec_time);
- d_printf("setattrE_count: %u\n", profile_p->SMBsetattrE_count);
- d_printf("setattrE_time: %u\n", profile_p->SMBsetattrE_time);
- d_printf("getattrE_count: %u\n", profile_p->SMBgetattrE_count);
- d_printf("getattrE_time: %u\n", profile_p->SMBgetattrE_time);
- d_printf("lockingX_count: %u\n", profile_p->SMBlockingX_count);
- d_printf("lockingX_time: %u\n", profile_p->SMBlockingX_time);
- d_printf("trans_count: %u\n", profile_p->SMBtrans_count);
- d_printf("trans_time: %u\n", profile_p->SMBtrans_time);
- d_printf("transs_count: %u\n", profile_p->SMBtranss_count);
- d_printf("transs_time: %u\n", profile_p->SMBtranss_time);
- d_printf("ioctl_count: %u\n", profile_p->SMBioctl_count);
- d_printf("ioctl_time: %u\n", profile_p->SMBioctl_time);
- d_printf("ioctls_count: %u\n", profile_p->SMBioctls_count);
- d_printf("ioctls_time: %u\n", profile_p->SMBioctls_time);
- d_printf("copy_count: %u\n", profile_p->SMBcopy_count);
- d_printf("copy_time: %u\n", profile_p->SMBcopy_time);
- d_printf("move_count: %u\n", profile_p->SMBmove_count);
- d_printf("move_time: %u\n", profile_p->SMBmove_time);
- d_printf("echo_count: %u\n", profile_p->SMBecho_count);
- d_printf("echo_time: %u\n", profile_p->SMBecho_time);
- d_printf("writeclose_count: %u\n", profile_p->SMBwriteclose_count);
- d_printf("writeclose_time: %u\n", profile_p->SMBwriteclose_time);
- d_printf("openX_count: %u\n", profile_p->SMBopenX_count);
- d_printf("openX_time: %u\n", profile_p->SMBopenX_time);
- d_printf("readX_count: %u\n", profile_p->SMBreadX_count);
- d_printf("readX_time: %u\n", profile_p->SMBreadX_time);
- d_printf("writeX_count: %u\n", profile_p->SMBwriteX_count);
- d_printf("writeX_time: %u\n", profile_p->SMBwriteX_time);
- d_printf("trans2_count: %u\n", profile_p->SMBtrans2_count);
- d_printf("trans2_time: %u\n", profile_p->SMBtrans2_time);
- d_printf("transs2_count: %u\n", profile_p->SMBtranss2_count);
- d_printf("transs2_time: %u\n", profile_p->SMBtranss2_time);
- d_printf("findclose_count: %u\n", profile_p->SMBfindclose_count);
- d_printf("findclose_time: %u\n", profile_p->SMBfindclose_time);
- d_printf("findnclose_count: %u\n", profile_p->SMBfindnclose_count);
- d_printf("findnclose_time: %u\n", profile_p->SMBfindnclose_time);
- d_printf("tcon_count: %u\n", profile_p->SMBtcon_count);
- d_printf("tcon_time: %u\n", profile_p->SMBtcon_time);
- d_printf("tdis_count: %u\n", profile_p->SMBtdis_count);
- d_printf("tdis_time: %u\n", profile_p->SMBtdis_time);
- d_printf("negprot_count: %u\n", profile_p->SMBnegprot_count);
- d_printf("negprot_time: %u\n", profile_p->SMBnegprot_time);
- d_printf("sesssetupX_count: %u\n", profile_p->SMBsesssetupX_count);
- d_printf("sesssetupX_time: %u\n", profile_p->SMBsesssetupX_time);
- d_printf("ulogoffX_count: %u\n", profile_p->SMBulogoffX_count);
- d_printf("ulogoffX_time: %u\n", profile_p->SMBulogoffX_time);
- d_printf("tconX_count: %u\n", profile_p->SMBtconX_count);
- d_printf("tconX_time: %u\n", profile_p->SMBtconX_time);
- d_printf("dskattr_count: %u\n", profile_p->SMBdskattr_count);
- d_printf("dskattr_time: %u\n", profile_p->SMBdskattr_time);
- d_printf("search_count: %u\n", profile_p->SMBsearch_count);
- d_printf("search_time: %u\n", profile_p->SMBsearch_time);
- d_printf("ffirst_count: %u\n", profile_p->SMBffirst_count);
- d_printf("ffirst_time: %u\n", profile_p->SMBffirst_time);
- d_printf("funique_count: %u\n", profile_p->SMBfunique_count);
- d_printf("funique_time: %u\n", profile_p->SMBfunique_time);
- d_printf("fclose_count: %u\n", profile_p->SMBfclose_count);
- d_printf("fclose_time: %u\n", profile_p->SMBfclose_time);
- d_printf("nttrans_count: %u\n", profile_p->SMBnttrans_count);
- d_printf("nttrans_time: %u\n", profile_p->SMBnttrans_time);
- d_printf("nttranss_count: %u\n", profile_p->SMBnttranss_count);
- d_printf("nttranss_time: %u\n", profile_p->SMBnttranss_time);
- d_printf("ntcreateX_count: %u\n", profile_p->SMBntcreateX_count);
- d_printf("ntcreateX_time: %u\n", profile_p->SMBntcreateX_time);
- d_printf("ntcancel_count: %u\n", profile_p->SMBntcancel_count);
- d_printf("ntcancel_time: %u\n", profile_p->SMBntcancel_time);
- d_printf("splopen_count: %u\n", profile_p->SMBsplopen_count);
- d_printf("splopen_time: %u\n", profile_p->SMBsplopen_time);
- d_printf("splwr_count: %u\n", profile_p->SMBsplwr_count);
- d_printf("splwr_time: %u\n", profile_p->SMBsplwr_time);
- d_printf("splclose_count: %u\n", profile_p->SMBsplclose_count);
- d_printf("splclose_time: %u\n", profile_p->SMBsplclose_time);
- d_printf("splretq_count: %u\n", profile_p->SMBsplretq_count);
- d_printf("splretq_time: %u\n", profile_p->SMBsplretq_time);
- d_printf("sends_count: %u\n", profile_p->SMBsends_count);
- d_printf("sends_time: %u\n", profile_p->SMBsends_time);
- d_printf("sendb_count: %u\n", profile_p->SMBsendb_count);
- d_printf("sendb_time: %u\n", profile_p->SMBsendb_time);
- d_printf("fwdname_count: %u\n", profile_p->SMBfwdname_count);
- d_printf("fwdname_time: %u\n", profile_p->SMBfwdname_time);
- d_printf("cancelf_count: %u\n", profile_p->SMBcancelf_count);
- d_printf("cancelf_time: %u\n", profile_p->SMBcancelf_time);
- d_printf("getmac_count: %u\n", profile_p->SMBgetmac_count);
- d_printf("getmac_time: %u\n", profile_p->SMBgetmac_time);
- d_printf("sendstrt_count: %u\n", profile_p->SMBsendstrt_count);
- d_printf("sendstrt_time: %u\n", profile_p->SMBsendstrt_time);
- d_printf("sendend_count: %u\n", profile_p->SMBsendend_count);
- d_printf("sendend_time: %u\n", profile_p->SMBsendend_time);
- d_printf("sendtxt_count: %u\n", profile_p->SMBsendtxt_count);
- d_printf("sendtxt_time: %u\n", profile_p->SMBsendtxt_time);
- d_printf("invalid_count: %u\n", profile_p->SMBinvalid_count);
- d_printf("invalid_time: %u\n", profile_p->SMBinvalid_time);
- d_printf("************************ Pathworks Calls *************************\n");
- d_printf("setdir_count: %u\n", profile_p->pathworks_setdir_count);
- d_printf("setdir_time: %u\n", profile_p->pathworks_setdir_time);
- d_printf("************************ Trans2 Calls ****************************\n");
- d_printf("open_count: %u\n", profile_p->Trans2_open_count);
- d_printf("open_time: %u\n", profile_p->Trans2_open_time);
- d_printf("findfirst_count: %u\n", profile_p->Trans2_findfirst_count);
- d_printf("findfirst_time: %u\n", profile_p->Trans2_findfirst_time);
- d_printf("findnext_count: %u\n", profile_p->Trans2_findnext_count);
- d_printf("findnext_time: %u\n", profile_p->Trans2_findnext_time);
- d_printf("qfsinfo_count: %u\n", profile_p->Trans2_qfsinfo_count);
- d_printf("qfsinfo_time: %u\n", profile_p->Trans2_qfsinfo_time);
- d_printf("setfsinfo_count: %u\n", profile_p->Trans2_setfsinfo_count);
- d_printf("setfsinfo_time: %u\n", profile_p->Trans2_setfsinfo_time);
- d_printf("qpathinfo_count: %u\n", profile_p->Trans2_qpathinfo_count);
- d_printf("qpathinfo_time: %u\n", profile_p->Trans2_qpathinfo_time);
- d_printf("setpathinfo_count: %u\n", profile_p->Trans2_setpathinfo_count);
- d_printf("setpathinfo_time: %u\n", profile_p->Trans2_setpathinfo_time);
- d_printf("qfileinfo_count: %u\n", profile_p->Trans2_qfileinfo_count);
- d_printf("qfileinfo_time: %u\n", profile_p->Trans2_qfileinfo_time);
- d_printf("setfileinfo_count: %u\n", profile_p->Trans2_setfileinfo_count);
- d_printf("setfileinfo_time: %u\n", profile_p->Trans2_setfileinfo_time);
- d_printf("fsctl_count: %u\n", profile_p->Trans2_fsctl_count);
- d_printf("fsctl_time: %u\n", profile_p->Trans2_fsctl_time);
- d_printf("ioctl_count: %u\n", profile_p->Trans2_ioctl_count);
- d_printf("ioctl_time: %u\n", profile_p->Trans2_ioctl_time);
- d_printf("findnotifyfirst_count: %u\n", profile_p->Trans2_findnotifyfirst_count);
- d_printf("findnotifyfirst_time: %u\n", profile_p->Trans2_findnotifyfirst_time);
- d_printf("findnotifynext_count: %u\n", profile_p->Trans2_findnotifynext_count);
- d_printf("findnotifynext_time: %u\n", profile_p->Trans2_findnotifynext_time);
- d_printf("mkdir_count: %u\n", profile_p->Trans2_mkdir_count);
- d_printf("mkdir_time: %u\n", profile_p->Trans2_mkdir_time);
- d_printf("session_setup_count: %u\n", profile_p->Trans2_session_setup_count);
- d_printf("session_setup_time: %u\n", profile_p->Trans2_session_setup_time);
- d_printf("get_dfs_referral_count: %u\n", profile_p->Trans2_get_dfs_referral_count);
- d_printf("get_dfs_referral_time: %u\n", profile_p->Trans2_get_dfs_referral_time);
- d_printf("report_dfs_inconsistancy_count: %u\n", profile_p->Trans2_report_dfs_inconsistancy_count);
- d_printf("report_dfs_inconsistancy_time: %u\n", profile_p->Trans2_report_dfs_inconsistancy_time);
- d_printf("************************ NT Transact Calls ***********************\n");
- d_printf("create_count: %u\n", profile_p->NT_transact_create_count);
- d_printf("create_time: %u\n", profile_p->NT_transact_create_time);
- d_printf("ioctl_count: %u\n", profile_p->NT_transact_ioctl_count);
- d_printf("ioctl_time: %u\n", profile_p->NT_transact_ioctl_time);
- d_printf("set_security_desc_count: %u\n", profile_p->NT_transact_set_security_desc_count);
- d_printf("set_security_desc_time: %u\n", profile_p->NT_transact_set_security_desc_time);
- d_printf("notify_change_count: %u\n", profile_p->NT_transact_notify_change_count);
- d_printf("notify_change_time: %u\n", profile_p->NT_transact_notify_change_time);
- d_printf("rename_count: %u\n", profile_p->NT_transact_rename_count);
- d_printf("rename_time: %u\n", profile_p->NT_transact_rename_time);
- d_printf("query_security_desc_count: %u\n", profile_p->NT_transact_query_security_desc_count);
- d_printf("query_security_desc_time: %u\n", profile_p->NT_transact_query_security_desc_time);
- d_printf("************************ ACL Calls *******************************\n");
- d_printf("get_nt_acl_count: %u\n", profile_p->get_nt_acl_count);
- d_printf("get_nt_acl_time: %u\n", profile_p->get_nt_acl_time);
- d_printf("fget_nt_acl_count: %u\n", profile_p->fget_nt_acl_count);
- d_printf("fget_nt_acl_time: %u\n", profile_p->fget_nt_acl_time);
- d_printf("set_nt_acl_count: %u\n", profile_p->set_nt_acl_count);
- d_printf("set_nt_acl_time: %u\n", profile_p->set_nt_acl_time);
- d_printf("fset_nt_acl_count: %u\n", profile_p->fset_nt_acl_count);
- d_printf("fset_nt_acl_time: %u\n", profile_p->fset_nt_acl_time);
- d_printf("chmod_acl_count: %u\n", profile_p->chmod_acl_count);
- d_printf("chmod_acl_time: %u\n", profile_p->chmod_acl_time);
- d_printf("fchmod_acl_count: %u\n", profile_p->fchmod_acl_count);
- d_printf("fchmod_acl_time: %u\n", profile_p->fchmod_acl_time);
- d_printf("************************ NMBD Calls ****************************\n");
- d_printf("name_release_count: %u\n", profile_p->name_release_count);
- d_printf("name_release_time: %u\n", profile_p->name_release_time);
- d_printf("name_refresh_count: %u\n", profile_p->name_refresh_count);
- d_printf("name_refresh_time: %u\n", profile_p->name_refresh_time);
- d_printf("name_registration_count: %u\n", profile_p->name_registration_count);
- d_printf("name_registration_time: %u\n", profile_p->name_registration_time);
- d_printf("node_status_count: %u\n", profile_p->node_status_count);
- d_printf("node_status_time: %u\n", profile_p->node_status_time);
- d_printf("name_query_count: %u\n", profile_p->name_query_count);
- d_printf("name_query_time: %u\n", profile_p->name_query_time);
- d_printf("host_announce_count: %u\n", profile_p->host_announce_count);
- d_printf("host_announce_time: %u\n", profile_p->host_announce_time);
- d_printf("workgroup_announce_count: %u\n", profile_p->workgroup_announce_count);
- d_printf("workgroup_announce_time: %u\n", profile_p->workgroup_announce_time);
- d_printf("local_master_announce_count: %u\n", profile_p->local_master_announce_count);
- d_printf("local_master_announce_time: %u\n", profile_p->local_master_announce_time);
- d_printf("master_browser_announce_count: %u\n", profile_p->master_browser_announce_count);
- d_printf("master_browser_announce_time: %u\n", profile_p->master_browser_announce_time);
- d_printf("lm_host_announce_count: %u\n", profile_p->lm_host_announce_count);
- d_printf("lm_host_announce_time: %u\n", profile_p->lm_host_announce_time);
- d_printf("get_backup_list_count: %u\n", profile_p->get_backup_list_count);
- d_printf("get_backup_list_time: %u\n", profile_p->get_backup_list_time);
- d_printf("reset_browser_count: %u\n", profile_p->reset_browser_count);
- d_printf("reset_browser_time: %u\n", profile_p->reset_browser_time);
- d_printf("announce_request_count: %u\n", profile_p->announce_request_count);
- d_printf("announce_request_time: %u\n", profile_p->announce_request_time);
- d_printf("lm_announce_request_count: %u\n", profile_p->lm_announce_request_count);
- d_printf("lm_announce_request_time: %u\n", profile_p->lm_announce_request_time);
- d_printf("domain_logon_count: %u\n", profile_p->domain_logon_count);
- d_printf("domain_logon_time: %u\n", profile_p->domain_logon_time);
- d_printf("sync_browse_lists_count: %u\n", profile_p->sync_browse_lists_count);
- d_printf("sync_browse_lists_time: %u\n", profile_p->sync_browse_lists_time);
- d_printf("run_elections_count: %u\n", profile_p->run_elections_count);
- d_printf("run_elections_time: %u\n", profile_p->run_elections_time);
- d_printf("election_count: %u\n", profile_p->election_count);
- d_printf("election_time: %u\n", profile_p->election_time);
-#else /* WITH_PROFILE */
- fprintf(stderr, "Profile data unavailable\n");
-#endif /* WITH_PROFILE */
-
- return 0;
-}
-
-
static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
struct connections_data crec;
@@ -602,7 +243,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
int main(int argc, char *argv[])
{
int c;
- static int profile_only = 0;
+ int profile_only = 0;
TDB_CONTEXT *tdb;
BOOL show_processes, show_locks, show_shares;
poptContext pc;
@@ -614,9 +255,8 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
{"shares", 'S', POPT_ARG_NONE, &shares_only, 'S', "Show shares only" },
{"user", 'u', POPT_ARG_STRING, &username, 'u', "Switch to user" },
{"brief", 'b', POPT_ARG_NONE, &brief, 'b', "Be brief" },
-#ifdef WITH_PROFILE
- {"profile", 'P', POPT_ARG_NONE, &profile_only, 'P', "Do profiling" },
-#endif /* WITH_PROFILE */
+ {"profile", 'P', POPT_ARG_NONE, NULL, 'P', "Do profiling" },
+ {"profile-rates", 'R', POPT_ARG_NONE, NULL, 'R', "Show call rates" },
{"byterange", 'B', POPT_ARG_NONE, &show_brl, 'B', "Include byte range locks"},
{"numeric", 'n', POPT_ARG_NONE, &numeric_only, 'n', "Numeric uid/gid"},
POPT_COMMON_SAMBA
@@ -643,6 +283,9 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
case 'u':
Ucrit_addUid(nametouid(poptGetOptArg(pc)));
break;
+ case 'P':
+ case 'R':
+ profile_only = c;
}
}
@@ -663,11 +306,18 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
return (-1);
}
-
- if (profile_only) {
- return profile_dump();
+
+ switch (profile_only) {
+ case 'P':
+ /* Dump profile data */
+ return status_profile_dump(verbose);
+ case 'R':
+ /* Continuously display rate-converted data */
+ return status_profile_rates(verbose);
+ default:
+ break;
}
-
+
if ( show_processes ) {
tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
if (!tdb) {
diff --git a/source3/utils/status_profile.c b/source3/utils/status_profile.c
new file mode 100644
index 0000000000..fc5b5e10ff
--- /dev/null
+++ b/source3/utils/status_profile.c
@@ -0,0 +1,544 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * status reporting
+ * Copyright (C) Andrew Tridgell 1994-1998
+ * Copyright (C) James Peach 2005-2006
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+
+static void profile_separator(const char * title)
+{
+ char line[79 + 1];
+ char * end;
+
+ snprintf(line, sizeof(line), "**** %s ", title);
+
+ for (end = line + strlen(line); end < &line[sizeof(line) -1]; ++end) {
+ *end = '*';
+ }
+
+ line[sizeof(line) - 1] = '\0';
+ d_printf("%s\n", line);
+}
+
+/*******************************************************************
+ dump the elements of the profile structure
+ ******************************************************************/
+BOOL status_profile_dump(BOOL verbose)
+{
+#ifdef WITH_PROFILE
+ if (!profile_setup(True)) {
+ fprintf(stderr,"Failed to initialise profile memory\n");
+ return False;
+ }
+
+ d_printf("smb_count: %u\n", profile_p->smb_count);
+ d_printf("uid_changes: %u\n", profile_p->uid_changes);
+
+ profile_separator("System Calls");
+ d_printf("opendir_count: %u\n", profile_p->syscall_opendir_count);
+ d_printf("opendir_time: %u\n", profile_p->syscall_opendir_time);
+ d_printf("readdir_count: %u\n", profile_p->syscall_readdir_count);
+ d_printf("readdir_time: %u\n", profile_p->syscall_readdir_time);
+ d_printf("mkdir_count: %u\n", profile_p->syscall_mkdir_count);
+ d_printf("mkdir_time: %u\n", profile_p->syscall_mkdir_time);
+ d_printf("rmdir_count: %u\n", profile_p->syscall_rmdir_count);
+ d_printf("rmdir_time: %u\n", profile_p->syscall_rmdir_time);
+ d_printf("closedir_count: %u\n", profile_p->syscall_closedir_count);
+ d_printf("closedir_time: %u\n", profile_p->syscall_closedir_time);
+ d_printf("open_count: %u\n", profile_p->syscall_open_count);
+ d_printf("open_time: %u\n", profile_p->syscall_open_time);
+ d_printf("close_count: %u\n", profile_p->syscall_close_count);
+ d_printf("close_time: %u\n", profile_p->syscall_close_time);
+ d_printf("read_count: %u\n", profile_p->syscall_read_count);
+ d_printf("read_time: %u\n", profile_p->syscall_read_time);
+ d_printf("read_bytes: %u\n", profile_p->syscall_read_bytes);
+ d_printf("write_count: %u\n", profile_p->syscall_write_count);
+ d_printf("write_time: %u\n", profile_p->syscall_write_time);
+ d_printf("write_bytes: %u\n", profile_p->syscall_write_bytes);
+ d_printf("pread_count: %u\n", profile_p->syscall_pread_count);
+ d_printf("pread_time: %u\n", profile_p->syscall_pread_time);
+ d_printf("pread_bytes: %u\n", profile_p->syscall_pread_bytes);
+ d_printf("pwrite_count: %u\n", profile_p->syscall_pwrite_count);
+ d_printf("pwrite_time: %u\n", profile_p->syscall_pwrite_time);
+ d_printf("pwrite_bytes: %u\n", profile_p->syscall_pwrite_bytes);
+#ifdef WITH_SENDFILE
+ d_printf("sendfile_count: %u\n", profile_p->syscall_sendfile_count);
+ d_printf("sendfile_time: %u\n", profile_p->syscall_sendfile_time);
+ d_printf("sendfile_bytes: %u\n", profile_p->syscall_sendfile_bytes);
+#endif
+ d_printf("lseek_count: %u\n", profile_p->syscall_lseek_count);
+ d_printf("lseek_time: %u\n", profile_p->syscall_lseek_time);
+ d_printf("rename_count: %u\n", profile_p->syscall_rename_count);
+ d_printf("rename_time: %u\n", profile_p->syscall_rename_time);
+ d_printf("fsync_count: %u\n", profile_p->syscall_fsync_count);
+ d_printf("fsync_time: %u\n", profile_p->syscall_fsync_time);
+ d_printf("stat_count: %u\n", profile_p->syscall_stat_count);
+ d_printf("stat_time: %u\n", profile_p->syscall_stat_time);
+ d_printf("fstat_count: %u\n", profile_p->syscall_fstat_count);
+ d_printf("fstat_time: %u\n", profile_p->syscall_fstat_time);
+ d_printf("lstat_count: %u\n", profile_p->syscall_lstat_count);
+ d_printf("lstat_time: %u\n", profile_p->syscall_lstat_time);
+ d_printf("unlink_count: %u\n", profile_p->syscall_unlink_count);
+ d_printf("unlink_time: %u\n", profile_p->syscall_unlink_time);
+ d_printf("chmod_count: %u\n", profile_p->syscall_chmod_count);
+ d_printf("chmod_time: %u\n", profile_p->syscall_chmod_time);
+ d_printf("fchmod_count: %u\n", profile_p->syscall_fchmod_count);
+ d_printf("fchmod_time: %u\n", profile_p->syscall_fchmod_time);
+ d_printf("chown_count: %u\n", profile_p->syscall_chown_count);
+ d_printf("chown_time: %u\n", profile_p->syscall_chown_time);
+ d_printf("fchown_count: %u\n", profile_p->syscall_fchown_count);
+ d_printf("fchown_time: %u\n", profile_p->syscall_fchown_time);
+ d_printf("chdir_count: %u\n", profile_p->syscall_chdir_count);
+ d_printf("chdir_time: %u\n", profile_p->syscall_chdir_time);
+ d_printf("getwd_count: %u\n", profile_p->syscall_getwd_count);
+ d_printf("getwd_time: %u\n", profile_p->syscall_getwd_time);
+ d_printf("utime_count: %u\n", profile_p->syscall_utime_count);
+ d_printf("utime_time: %u\n", profile_p->syscall_utime_time);
+ d_printf("ftruncate_count: %u\n", profile_p->syscall_ftruncate_count);
+ d_printf("ftruncate_time: %u\n", profile_p->syscall_ftruncate_time);
+ d_printf("fcntl_lock_count: %u\n", profile_p->syscall_fcntl_lock_count);
+ d_printf("fcntl_lock_time: %u\n", profile_p->syscall_fcntl_lock_time);
+ d_printf("readlink_count: %u\n", profile_p->syscall_readlink_count);
+ d_printf("readlink_time: %u\n", profile_p->syscall_readlink_time);
+ d_printf("symlink_count: %u\n", profile_p->syscall_symlink_count);
+ d_printf("symlink_time: %u\n", profile_p->syscall_symlink_time);
+
+ profile_separator("Stat Cache");
+ d_printf("lookups: %u\n", profile_p->statcache_lookups);
+ d_printf("misses: %u\n", profile_p->statcache_misses);
+ d_printf("hits: %u\n", profile_p->statcache_hits);
+
+ profile_separator("Write Cache");
+ d_printf("read_hits: %u\n", profile_p->writecache_read_hits);
+ d_printf("abutted_writes: %u\n", profile_p->writecache_abutted_writes);
+ d_printf("total_writes: %u\n", profile_p->writecache_total_writes);
+ d_printf("non_oplock_writes: %u\n", profile_p->writecache_non_oplock_writes);
+ d_printf("direct_writes: %u\n", profile_p->writecache_direct_writes);
+ d_printf("init_writes: %u\n", profile_p->writecache_init_writes);
+ d_printf("flushed_writes[SEEK]: %u\n", profile_p->writecache_flushed_writes[SEEK_FLUSH]);
+ d_printf("flushed_writes[READ]: %u\n", profile_p->writecache_flushed_writes[READ_FLUSH]);
+ d_printf("flushed_writes[WRITE]: %u\n", profile_p->writecache_flushed_writes[WRITE_FLUSH]);
+ d_printf("flushed_writes[READRAW]: %u\n", profile_p->writecache_flushed_writes[READRAW_FLUSH]);
+ d_printf("flushed_writes[OPLOCK_RELEASE]: %u\n", profile_p->writecache_flushed_writes[OPLOCK_RELEASE_FLUSH]);
+ d_printf("flushed_writes[CLOSE]: %u\n", profile_p->writecache_flushed_writes[CLOSE_FLUSH]);
+ d_printf("flushed_writes[SYNC]: %u\n", profile_p->writecache_flushed_writes[SYNC_FLUSH]);
+ d_printf("flushed_writes[SIZECHANGE]: %u\n", profile_p->writecache_flushed_writes[SIZECHANGE_FLUSH]);
+ d_printf("num_perfect_writes: %u\n", profile_p->writecache_num_perfect_writes);
+ d_printf("num_write_caches: %u\n", profile_p->writecache_num_write_caches);
+ d_printf("allocated_write_caches: %u\n", profile_p->writecache_allocated_write_caches);
+
+ profile_separator("SMB Calls");
+ d_printf("mkdir_count: %u\n", profile_p->SMBmkdir_count);
+ d_printf("mkdir_time: %u\n", profile_p->SMBmkdir_time);
+ d_printf("rmdir_count: %u\n", profile_p->SMBrmdir_count);
+ d_printf("rmdir_time: %u\n", profile_p->SMBrmdir_time);
+ d_printf("open_count: %u\n", profile_p->SMBopen_count);
+ d_printf("open_time: %u\n", profile_p->SMBopen_time);
+ d_printf("create_count: %u\n", profile_p->SMBcreate_count);
+ d_printf("create_time: %u\n", profile_p->SMBcreate_time);
+ d_printf("close_count: %u\n", profile_p->SMBclose_count);
+ d_printf("close_time: %u\n", profile_p->SMBclose_time);
+ d_printf("flush_count: %u\n", profile_p->SMBflush_count);
+ d_printf("flush_time: %u\n", profile_p->SMBflush_time);
+ d_printf("unlink_count: %u\n", profile_p->SMBunlink_count);
+ d_printf("unlink_time: %u\n", profile_p->SMBunlink_time);
+ d_printf("mv_count: %u\n", profile_p->SMBmv_count);
+ d_printf("mv_time: %u\n", profile_p->SMBmv_time);
+ d_printf("getatr_count: %u\n", profile_p->SMBgetatr_count);
+ d_printf("getatr_time: %u\n", profile_p->SMBgetatr_time);
+ d_printf("setatr_count: %u\n", profile_p->SMBsetatr_count);
+ d_printf("setatr_time: %u\n", profile_p->SMBsetatr_time);
+ d_printf("read_count: %u\n", profile_p->SMBread_count);
+ d_printf("read_time: %u\n", profile_p->SMBread_time);
+ d_printf("write_count: %u\n", profile_p->SMBwrite_count);
+ d_printf("write_time: %u\n", profile_p->SMBwrite_time);
+ d_printf("lock_count: %u\n", profile_p->SMBlock_count);
+ d_printf("lock_time: %u\n", profile_p->SMBlock_time);
+ d_printf("unlock_count: %u\n", profile_p->SMBunlock_count);
+ d_printf("unlock_time: %u\n", profile_p->SMBunlock_time);
+ d_printf("ctemp_count: %u\n", profile_p->SMBctemp_count);
+ d_printf("ctemp_time: %u\n", profile_p->SMBctemp_time);
+ d_printf("mknew_count: %u\n", profile_p->SMBmknew_count);
+ d_printf("mknew_time: %u\n", profile_p->SMBmknew_time);
+ d_printf("chkpth_count: %u\n", profile_p->SMBchkpth_count);
+ d_printf("chkpth_time: %u\n", profile_p->SMBchkpth_time);
+ d_printf("exit_count: %u\n", profile_p->SMBexit_count);
+ d_printf("exit_time: %u\n", profile_p->SMBexit_time);
+ d_printf("lseek_count: %u\n", profile_p->SMBlseek_count);
+ d_printf("lseek_time: %u\n", profile_p->SMBlseek_time);
+ d_printf("lockread_count: %u\n", profile_p->SMBlockread_count);
+ d_printf("lockread_time: %u\n", profile_p->SMBlockread_time);
+ d_printf("writeunlock_count: %u\n", profile_p->SMBwriteunlock_count);
+ d_printf("writeunlock_time: %u\n", profile_p->SMBwriteunlock_time);
+ d_printf("readbraw_count: %u\n", profile_p->SMBreadbraw_count);
+ d_printf("readbraw_time: %u\n", profile_p->SMBreadbraw_time);
+ d_printf("readBmpx_count: %u\n", profile_p->SMBreadBmpx_count);
+ d_printf("readBmpx_time: %u\n", profile_p->SMBreadBmpx_time);
+ d_printf("readBs_count: %u\n", profile_p->SMBreadBs_count);
+ d_printf("readBs_time: %u\n", profile_p->SMBreadBs_time);
+ d_printf("writebraw_count: %u\n", profile_p->SMBwritebraw_count);
+ d_printf("writebraw_time: %u\n", profile_p->SMBwritebraw_time);
+ d_printf("writeBmpx_count: %u\n", profile_p->SMBwriteBmpx_count);
+ d_printf("writeBmpx_time: %u\n", profile_p->SMBwriteBmpx_time);
+ d_printf("writeBs_count: %u\n", profile_p->SMBwriteBs_count);
+ d_printf("writeBs_time: %u\n", profile_p->SMBwriteBs_time);
+ d_printf("writec_count: %u\n", profile_p->SMBwritec_count);
+ d_printf("writec_time: %u\n", profile_p->SMBwritec_time);
+ d_printf("setattrE_count: %u\n", profile_p->SMBsetattrE_count);
+ d_printf("setattrE_time: %u\n", profile_p->SMBsetattrE_time);
+ d_printf("getattrE_count: %u\n", profile_p->SMBgetattrE_count);
+ d_printf("getattrE_time: %u\n", profile_p->SMBgetattrE_time);
+ d_printf("lockingX_count: %u\n", profile_p->SMBlockingX_count);
+ d_printf("lockingX_time: %u\n", profile_p->SMBlockingX_time);
+ d_printf("trans_count: %u\n", profile_p->SMBtrans_count);
+ d_printf("trans_time: %u\n", profile_p->SMBtrans_time);
+ d_printf("transs_count: %u\n", profile_p->SMBtranss_count);
+ d_printf("transs_time: %u\n", profile_p->SMBtranss_time);
+ d_printf("ioctl_count: %u\n", profile_p->SMBioctl_count);
+ d_printf("ioctl_time: %u\n", profile_p->SMBioctl_time);
+ d_printf("ioctls_count: %u\n", profile_p->SMBioctls_count);
+ d_printf("ioctls_time: %u\n", profile_p->SMBioctls_time);
+ d_printf("copy_count: %u\n", profile_p->SMBcopy_count);
+ d_printf("copy_time: %u\n", profile_p->SMBcopy_time);
+ d_printf("move_count: %u\n", profile_p->SMBmove_count);
+ d_printf("move_time: %u\n", profile_p->SMBmove_time);
+ d_printf("echo_count: %u\n", profile_p->SMBecho_count);
+ d_printf("echo_time: %u\n", profile_p->SMBecho_time);
+ d_printf("writeclose_count: %u\n", profile_p->SMBwriteclose_count);
+ d_printf("writeclose_time: %u\n", profile_p->SMBwriteclose_time);
+ d_printf("openX_count: %u\n", profile_p->SMBopenX_count);
+ d_printf("openX_time: %u\n", profile_p->SMBopenX_time);
+ d_printf("readX_count: %u\n", profile_p->SMBreadX_count);
+ d_printf("readX_time: %u\n", profile_p->SMBreadX_time);
+ d_printf("writeX_count: %u\n", profile_p->SMBwriteX_count);
+ d_printf("writeX_time: %u\n", profile_p->SMBwriteX_time);
+ d_printf("trans2_count: %u\n", profile_p->SMBtrans2_count);
+ d_printf("trans2_time: %u\n", profile_p->SMBtrans2_time);
+ d_printf("transs2_count: %u\n", profile_p->SMBtranss2_count);
+ d_printf("transs2_time: %u\n", profile_p->SMBtranss2_time);
+ d_printf("findclose_count: %u\n", profile_p->SMBfindclose_count);
+ d_printf("findclose_time: %u\n", profile_p->SMBfindclose_time);
+ d_printf("findnclose_count: %u\n", profile_p->SMBfindnclose_count);
+ d_printf("findnclose_time: %u\n", profile_p->SMBfindnclose_time);
+ d_printf("tcon_count: %u\n", profile_p->SMBtcon_count);
+ d_printf("tcon_time: %u\n", profile_p->SMBtcon_time);
+ d_printf("tdis_count: %u\n", profile_p->SMBtdis_count);
+ d_printf("tdis_time: %u\n", profile_p->SMBtdis_time);
+ d_printf("negprot_count: %u\n", profile_p->SMBnegprot_count);
+ d_printf("negprot_time: %u\n", profile_p->SMBnegprot_time);
+ d_printf("sesssetupX_count: %u\n", profile_p->SMBsesssetupX_count);
+ d_printf("sesssetupX_time: %u\n", profile_p->SMBsesssetupX_time);
+ d_printf("ulogoffX_count: %u\n", profile_p->SMBulogoffX_count);
+ d_printf("ulogoffX_time: %u\n", profile_p->SMBulogoffX_time);
+ d_printf("tconX_count: %u\n", profile_p->SMBtconX_count);
+ d_printf("tconX_time: %u\n", profile_p->SMBtconX_time);
+ d_printf("dskattr_count: %u\n", profile_p->SMBdskattr_count);
+ d_printf("dskattr_time: %u\n", profile_p->SMBdskattr_time);
+ d_printf("search_count: %u\n", profile_p->SMBsearch_count);
+ d_printf("search_time: %u\n", profile_p->SMBsearch_time);
+ d_printf("ffirst_count: %u\n", profile_p->SMBffirst_count);
+ d_printf("ffirst_time: %u\n", profile_p->SMBffirst_time);
+ d_printf("funique_count: %u\n", profile_p->SMBfunique_count);
+ d_printf("funique_time: %u\n", profile_p->SMBfunique_time);
+ d_printf("fclose_count: %u\n", profile_p->SMBfclose_count);
+ d_printf("fclose_time: %u\n", profile_p->SMBfclose_time);
+ d_printf("nttrans_count: %u\n", profile_p->SMBnttrans_count);
+ d_printf("nttrans_time: %u\n", profile_p->SMBnttrans_time);
+ d_printf("nttranss_count: %u\n", profile_p->SMBnttranss_count);
+ d_printf("nttranss_time: %u\n", profile_p->SMBnttranss_time);
+ d_printf("ntcreateX_count: %u\n", profile_p->SMBntcreateX_count);
+ d_printf("ntcreateX_time: %u\n", profile_p->SMBntcreateX_time);
+ d_printf("ntcancel_count: %u\n", profile_p->SMBntcancel_count);
+ d_printf("ntcancel_time: %u\n", profile_p->SMBntcancel_time);
+ d_printf("splopen_count: %u\n", profile_p->SMBsplopen_count);
+ d_printf("splopen_time: %u\n", profile_p->SMBsplopen_time);
+ d_printf("splwr_count: %u\n", profile_p->SMBsplwr_count);
+ d_printf("splwr_time: %u\n", profile_p->SMBsplwr_time);
+ d_printf("splclose_count: %u\n", profile_p->SMBsplclose_count);
+ d_printf("splclose_time: %u\n", profile_p->SMBsplclose_time);
+ d_printf("splretq_count: %u\n", profile_p->SMBsplretq_count);
+ d_printf("splretq_time: %u\n", profile_p->SMBsplretq_time);
+ d_printf("sends_count: %u\n", profile_p->SMBsends_count);
+ d_printf("sends_time: %u\n", profile_p->SMBsends_time);
+ d_printf("sendb_count: %u\n", profile_p->SMBsendb_count);
+ d_printf("sendb_time: %u\n", profile_p->SMBsendb_time);
+ d_printf("fwdname_count: %u\n", profile_p->SMBfwdname_count);
+ d_printf("fwdname_time: %u\n", profile_p->SMBfwdname_time);
+ d_printf("cancelf_count: %u\n", profile_p->SMBcancelf_count);
+ d_printf("cancelf_time: %u\n", profile_p->SMBcancelf_time);
+ d_printf("getmac_count: %u\n", profile_p->SMBgetmac_count);
+ d_printf("getmac_time: %u\n", profile_p->SMBgetmac_time);
+ d_printf("sendstrt_count: %u\n", profile_p->SMBsendstrt_count);
+ d_printf("sendstrt_time: %u\n", profile_p->SMBsendstrt_time);
+ d_printf("sendend_count: %u\n", profile_p->SMBsendend_count);
+ d_printf("sendend_time: %u\n", profile_p->SMBsendend_time);
+ d_printf("sendtxt_count: %u\n", profile_p->SMBsendtxt_count);
+ d_printf("sendtxt_time: %u\n", profile_p->SMBsendtxt_time);
+ d_printf("invalid_count: %u\n", profile_p->SMBinvalid_count);
+ d_printf("invalid_time: %u\n", profile_p->SMBinvalid_time);
+
+ profile_separator("Pathworks Calls");
+ d_printf("setdir_count: %u\n", profile_p->pathworks_setdir_count);
+ d_printf("setdir_time: %u\n", profile_p->pathworks_setdir_time);
+
+ profile_separator("Trans2 Calls");
+ d_printf("open_count: %u\n", profile_p->Trans2_open_count);
+ d_printf("open_time: %u\n", profile_p->Trans2_open_time);
+ d_printf("findfirst_count: %u\n", profile_p->Trans2_findfirst_count);
+ d_printf("findfirst_time: %u\n", profile_p->Trans2_findfirst_time);
+ d_printf("findnext_count: %u\n", profile_p->Trans2_findnext_count);
+ d_printf("findnext_time: %u\n", profile_p->Trans2_findnext_time);
+ d_printf("qfsinfo_count: %u\n", profile_p->Trans2_qfsinfo_count);
+ d_printf("qfsinfo_time: %u\n", profile_p->Trans2_qfsinfo_time);
+ d_printf("setfsinfo_count: %u\n", profile_p->Trans2_setfsinfo_count);
+ d_printf("setfsinfo_time: %u\n", profile_p->Trans2_setfsinfo_time);
+ d_printf("qpathinfo_count: %u\n", profile_p->Trans2_qpathinfo_count);
+ d_printf("qpathinfo_time: %u\n", profile_p->Trans2_qpathinfo_time);
+ d_printf("setpathinfo_count: %u\n", profile_p->Trans2_setpathinfo_count);
+ d_printf("setpathinfo_time: %u\n", profile_p->Trans2_setpathinfo_time);
+ d_printf("qfileinfo_count: %u\n", profile_p->Trans2_qfileinfo_count);
+ d_printf("qfileinfo_time: %u\n", profile_p->Trans2_qfileinfo_time);
+ d_printf("setfileinfo_count: %u\n", profile_p->Trans2_setfileinfo_count);
+ d_printf("setfileinfo_time: %u\n", profile_p->Trans2_setfileinfo_time);
+ d_printf("fsctl_count: %u\n", profile_p->Trans2_fsctl_count);
+ d_printf("fsctl_time: %u\n", profile_p->Trans2_fsctl_time);
+ d_printf("ioctl_count: %u\n", profile_p->Trans2_ioctl_count);
+ d_printf("ioctl_time: %u\n", profile_p->Trans2_ioctl_time);
+ d_printf("findnotifyfirst_count: %u\n", profile_p->Trans2_findnotifyfirst_count);
+ d_printf("findnotifyfirst_time: %u\n", profile_p->Trans2_findnotifyfirst_time);
+ d_printf("findnotifynext_count: %u\n", profile_p->Trans2_findnotifynext_count);
+ d_printf("findnotifynext_time: %u\n", profile_p->Trans2_findnotifynext_time);
+ d_printf("mkdir_count: %u\n", profile_p->Trans2_mkdir_count);
+ d_printf("mkdir_time: %u\n", profile_p->Trans2_mkdir_time);
+ d_printf("session_setup_count: %u\n", profile_p->Trans2_session_setup_count);
+ d_printf("session_setup_time: %u\n", profile_p->Trans2_session_setup_time);
+ d_printf("get_dfs_referral_count: %u\n", profile_p->Trans2_get_dfs_referral_count);
+ d_printf("get_dfs_referral_time: %u\n", profile_p->Trans2_get_dfs_referral_time);
+ d_printf("report_dfs_inconsistancy_count: %u\n", profile_p->Trans2_report_dfs_inconsistancy_count);
+ d_printf("report_dfs_inconsistancy_time: %u\n", profile_p->Trans2_report_dfs_inconsistancy_time);
+
+ profile_separator("NT Transact Calls");
+ d_printf("create_count: %u\n", profile_p->NT_transact_create_count);
+ d_printf("create_time: %u\n", profile_p->NT_transact_create_time);
+ d_printf("ioctl_count: %u\n", profile_p->NT_transact_ioctl_count);
+ d_printf("ioctl_time: %u\n", profile_p->NT_transact_ioctl_time);
+ d_printf("set_security_desc_count: %u\n", profile_p->NT_transact_set_security_desc_count);
+ d_printf("set_security_desc_time: %u\n", profile_p->NT_transact_set_security_desc_time);
+ d_printf("notify_change_count: %u\n", profile_p->NT_transact_notify_change_count);
+ d_printf("notify_change_time: %u\n", profile_p->NT_transact_notify_change_time);
+ d_printf("rename_count: %u\n", profile_p->NT_transact_rename_count);
+ d_printf("rename_time: %u\n", profile_p->NT_transact_rename_time);
+ d_printf("query_security_desc_count: %u\n", profile_p->NT_transact_query_security_desc_count);
+ d_printf("query_security_desc_time: %u\n", profile_p->NT_transact_query_security_desc_time);
+
+ profile_separator("ACL Calls");
+ d_printf("get_nt_acl_count: %u\n", profile_p->get_nt_acl_count);
+ d_printf("get_nt_acl_time: %u\n", profile_p->get_nt_acl_time);
+ d_printf("fget_nt_acl_count: %u\n", profile_p->fget_nt_acl_count);
+ d_printf("fget_nt_acl_time: %u\n", profile_p->fget_nt_acl_time);
+ d_printf("set_nt_acl_count: %u\n", profile_p->set_nt_acl_count);
+ d_printf("set_nt_acl_time: %u\n", profile_p->set_nt_acl_time);
+ d_printf("fset_nt_acl_count: %u\n", profile_p->fset_nt_acl_count);
+ d_printf("fset_nt_acl_time: %u\n", profile_p->fset_nt_acl_time);
+ d_printf("chmod_acl_count: %u\n", profile_p->chmod_acl_count);
+ d_printf("chmod_acl_time: %u\n", profile_p->chmod_acl_time);
+ d_printf("fchmod_acl_count: %u\n", profile_p->fchmod_acl_count);
+ d_printf("fchmod_acl_time: %u\n", profile_p->fchmod_acl_time);
+
+ profile_separator("NMBD Calls");
+ d_printf("name_release_count: %u\n", profile_p->name_release_count);
+ d_printf("name_release_time: %u\n", profile_p->name_release_time);
+ d_printf("name_refresh_count: %u\n", profile_p->name_refresh_count);
+ d_printf("name_refresh_time: %u\n", profile_p->name_refresh_time);
+ d_printf("name_registration_count: %u\n", profile_p->name_registration_count);
+ d_printf("name_registration_time: %u\n", profile_p->name_registration_time);
+ d_printf("node_status_count: %u\n", profile_p->node_status_count);
+ d_printf("node_status_time: %u\n", profile_p->node_status_time);
+ d_printf("name_query_count: %u\n", profile_p->name_query_count);
+ d_printf("name_query_time: %u\n", profile_p->name_query_time);
+ d_printf("host_announce_count: %u\n", profile_p->host_announce_count);
+ d_printf("host_announce_time: %u\n", profile_p->host_announce_time);
+ d_printf("workgroup_announce_count: %u\n", profile_p->workgroup_announce_count);
+ d_printf("workgroup_announce_time: %u\n", profile_p->workgroup_announce_time);
+ d_printf("local_master_announce_count: %u\n", profile_p->local_master_announce_count);
+ d_printf("local_master_announce_time: %u\n", profile_p->local_master_announce_time);
+ d_printf("master_browser_announce_count: %u\n", profile_p->master_browser_announce_count);
+ d_printf("master_browser_announce_time: %u\n", profile_p->master_browser_announce_time);
+ d_printf("lm_host_announce_count: %u\n", profile_p->lm_host_announce_count);
+ d_printf("lm_host_announce_time: %u\n", profile_p->lm_host_announce_time);
+ d_printf("get_backup_list_count: %u\n", profile_p->get_backup_list_count);
+ d_printf("get_backup_list_time: %u\n", profile_p->get_backup_list_time);
+ d_printf("reset_browser_count: %u\n", profile_p->reset_browser_count);
+ d_printf("reset_browser_time: %u\n", profile_p->reset_browser_time);
+ d_printf("announce_request_count: %u\n", profile_p->announce_request_count);
+ d_printf("announce_request_time: %u\n", profile_p->announce_request_time);
+ d_printf("lm_announce_request_count: %u\n", profile_p->lm_announce_request_count);
+ d_printf("lm_announce_request_time: %u\n", profile_p->lm_announce_request_time);
+ d_printf("domain_logon_count: %u\n", profile_p->domain_logon_count);
+ d_printf("domain_logon_time: %u\n", profile_p->domain_logon_time);
+ d_printf("sync_browse_lists_count: %u\n", profile_p->sync_browse_lists_count);
+ d_printf("sync_browse_lists_time: %u\n", profile_p->sync_browse_lists_time);
+ d_printf("run_elections_count: %u\n", profile_p->run_elections_count);
+ d_printf("run_elections_time: %u\n", profile_p->run_elections_time);
+ d_printf("election_count: %u\n", profile_p->election_count);
+ d_printf("election_time: %u\n", profile_p->election_time);
+#else /* WITH_PROFILE */
+ fprintf(stderr, "Profile data unavailable\n");
+#endif /* WITH_PROFILE */
+
+ return True;
+}
+
+#ifdef WITH_PROFILE
+
+static void sample_delay(int delay_msec)
+{
+ poll(NULL, 0, delay_msec);
+}
+
+/* Convert microseconds to milliseconds. */
+#define usec_to_msec(s) ((s) / 1000)
+/* Convert microseconds to seconds. */
+#define usec_to_sec(s) ((s) / 1000000)
+/* One second in microseconds. */
+#define one_second_usec (1000000)
+
+#define sample_interval_usec one_second_usec
+
+#define percent_time(used, period) ((double)(used) / (double)(period) * 100.0 )
+
+static int print_count_samples(
+ const struct profile_stats * const current,
+ const struct profile_stats * const last,
+ SMB_BIG_UINT delta_usec)
+{
+ int i;
+ int count = 0;
+ unsigned step;
+ SMB_BIG_UINT spent;
+ int delta_sec;
+ const char * name;
+ char buf[40];
+
+ if (delta_usec == 0) {
+ return 0;
+ }
+
+ buf[0] = '\0';
+ delta_sec = usec_to_sec(delta_usec);
+
+ for (i = 0; i < PR_VALUE_MAX; ++i) {
+ step = current->count[i] - last->count[i];
+ spent = current->time[i] - last->time[i];
+
+ if (step) {
+ ++count;
+
+ name = profile_value_name(i);
+
+ if (buf[0] == '\0') {
+ snprintf(buf, sizeof(buf),
+ "%s %d/sec (%.2f%%)",
+ name, step / delta_sec,
+ percent_time(spent, delta_usec));
+ } else {
+ printf("%-40s %s %d/sec (%.2f%%)\n",
+ buf, name, step / delta_sec,
+ percent_time(spent, delta_usec));
+ buf[0] = '\0';
+ }
+ }
+ }
+
+ return count;
+}
+
+static struct profile_stats sample_data[2];
+static SMB_BIG_UINT sample_time[2];
+
+BOOL status_profile_rates(BOOL verbose)
+{
+ SMB_BIG_UINT remain_usec;
+ SMB_BIG_UINT next_usec;
+ SMB_BIG_UINT delta_usec;
+
+ int last = 0;
+ int current = 1;
+ int tmp;
+
+ if (verbose) {
+ fprintf(stderr, "Sampling stats at %d sec intervals\n",
+ usec_to_sec(sample_interval_usec));
+ }
+
+ if (!profile_setup(True)) {
+ fprintf(stderr,"Failed to initialise profile memory\n");
+ return False;
+ }
+
+ memcpy(&sample_data[last], profile_p, sizeof(*profile_p));
+ for (;;) {
+ sample_time[current] = profile_timestamp();
+ next_usec = sample_time[current] + sample_interval_usec;
+
+ /* Take a sample. */
+ memcpy(&sample_data[current], profile_p, sizeof(*profile_p));
+
+ /* Rate convert some values and print results. */
+ delta_usec = sample_time[current] - sample_time[last];
+
+ if (print_count_samples(&sample_data[current],
+ &sample_data[last], delta_usec)) {
+ printf("\n");
+ }
+
+ /* Swap sampling buffers. */
+ tmp = last;
+ last = current;
+ current = tmp;
+
+ /* Delay until next sample time. */
+ remain_usec = next_usec - profile_timestamp();
+ if (remain_usec > sample_interval_usec) {
+ fprintf(stderr, "eek! falling behind sampling rate!\n");
+ } else {
+ if (verbose) {
+ fprintf(stderr,
+ "delaying for %lu msec\n",
+ (unsigned long )usec_to_msec(remain_usec));
+ }
+
+ sample_delay(usec_to_msec(remain_usec));
+ }
+
+ }
+
+ return True;
+}
+
+#else /* WITH_PROFILE */
+
+BOOL status_profile_rates(BOOL verbose)
+{
+ fprintf(stderr, "Profile data unavailable\n");
+ return False;
+}
+
+#endif /* WITH_PROFILE */
+