Skip to content
Permalink
1139b72d5e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
155 lines (134 sloc) 3.08 KB
/*
* (C) 2001 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include "pvfs2.h"
#include "pvfs2-vis.h"
#include "pvfs2-mgmt.h"
#include "pvfs2-internal.h"
#ifndef PVFS2_VERSION
#define PVFS2_VERSION "Unknown"
#endif
struct options
{
char* mnt_point;
int mnt_point_set;
};
static struct options* parse_args(int argc, char* argv[]);
static void usage(int argc, char** argv);
static struct options* user_opts = NULL;
int main(int argc, char **argv)
{
int ret = -1;
int counter = 5;
/* look at command line arguments */
user_opts = parse_args(argc, argv);
if(!user_opts)
{
fprintf(stderr, "Error: failed to parse command line arguments.\n");
usage(argc, argv);
return(-1);
}
ret = pvfs2_vis_start(user_opts->mnt_point, 1000);
if(ret < 0)
{
PVFS_perror("pvfs2_vis_start", ret);
return(-1);
}
while(counter--)
{
pthread_mutex_lock(&pint_vis_mutex);
pthread_cond_wait(&pint_vis_cond, &pint_vis_mutex);
if(pint_vis_error)
{
return(-1);
}
printf("%lld\n", lld(pint_vis_shared.io_perf_matrix[0][pint_vis_shared.io_depth-1].read));
pthread_mutex_unlock(&pint_vis_mutex);
}
pvfs2_vis_stop();
return(0);
}
/* parse_args()
*
* parses command line arguments
*
* returns pointer to options structure on success, NULL on failure
*/
static struct options* parse_args(int argc, char* argv[])
{
char flags[] = "vm:";
int one_opt = 0;
int len = 0;
struct options* tmp_opts = NULL;
int ret = -1;
/* create storage for the command line options */
tmp_opts = (struct options*)malloc(sizeof(struct options));
if(!tmp_opts){
return(NULL);
}
memset(tmp_opts, 0, sizeof(struct options));
/* look at command line arguments */
while((one_opt = getopt(argc, argv, flags)) != EOF){
switch(one_opt)
{
case('v'):
printf("%s\n", PVFS2_VERSION);
exit(0);
case('m'):
len = strlen(optarg)+1;
tmp_opts->mnt_point = (char*)malloc(len+1);
if(!tmp_opts->mnt_point)
{
free(tmp_opts);
return(NULL);
}
memset(tmp_opts->mnt_point, 0, len+1);
ret = sscanf(optarg, "%s", tmp_opts->mnt_point);
if(ret < 1){
free(tmp_opts);
return(NULL);
}
/* TODO: dirty hack... fix later. The remove_dir_prefix()
* function expects some trailing segments or at least
* a slash off of the mount point
*/
strcat(tmp_opts->mnt_point, "/");
tmp_opts->mnt_point_set = 1;
break;
case('?'):
usage(argc, argv);
exit(EXIT_FAILURE);
}
}
if(!tmp_opts->mnt_point_set)
{
free(tmp_opts);
return(NULL);
}
return(tmp_opts);
}
static void usage(int argc, char** argv)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage : %s -m [fs_mount_point]\n",
argv[0]);
fprintf(stderr, "Example: %s -m /mnt/pvfs2\n",
argv[0]);
return;
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/