1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-05 21:57:51 +03:00

s3: rpc_server/srvsvc: added routines to compute opens on share connections.

Added routines count_share_opens() and share_file_fn() to count
opens on share connections.

Signed-off-by: Shekhar Amlekar <samlekar@in.ibm.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
This commit is contained in:
Shekhar Amlekar 2014-03-25 16:30:49 +05:30 committed by Jeremy Allison
parent 992c86d715
commit e68547204f

View File

@ -61,6 +61,14 @@ struct sess_file_info {
uint32_t num_entries;
};
struct share_file_stat {
struct srvsvc_NetConnInfo1 *netconn_arr;
struct server_id *svrid_arr;
const char *in_sharepath;
uint32_t resp_entries;
uint32_t total_entries;
};
struct share_conn_stat {
TALLOC_CTX *ctx;
const char *sharename;
@ -937,6 +945,47 @@ static WERROR init_srv_sess_info_1(struct pipes_struct *p,
return WERR_OK;
}
/*******************************************************************
find the share connection on which this open exists.
********************************************************************/
static void share_file_fn(const struct share_mode_entry *e,
const char *sharepath, const char *fname,
void *data)
{
struct share_file_stat *sfs = data;
uint32_t i;
uint32_t offset = sfs->total_entries - sfs->resp_entries;
if (strequal(sharepath, sfs->in_sharepath)) {
for (i=0; i < sfs->resp_entries; i++) {
if (serverid_equal(&e->pid, &sfs->svrid_arr[offset + i])) {
sfs->netconn_arr[i].num_open ++;
return;
}
}
}
}
/*******************************************************************
count number of open files on given share connections.
********************************************************************/
static void count_share_opens(struct srvsvc_NetConnInfo1 *arr,
struct server_id *svrid_arr, char *sharepath,
uint32_t resp_entries, uint32_t total_entries)
{
struct share_file_stat sfs;
sfs.netconn_arr = arr;
sfs.svrid_arr = svrid_arr;
sfs.in_sharepath = sharepath;
sfs.resp_entries = resp_entries;
sfs.total_entries = total_entries;
share_mode_forall(share_file_fn, &sfs);
}
/****************************************************************************
process an entry from the connection db.
****************************************************************************/