Main Page | Modules | Data Structures | File List | Data Fields | Globals

test/shared/test-common.c File Reference

Implementation of the test-common wrapper functions. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <limits.h>
#include <getopt.h>
#include <assert.h>
#include "test-common.h"
#include "libgen.h"

Functions

void display_common_usage (char *exeName)
int set_util_path (const char *utility_path)
int create_pvfs2tab_file (char *pvfs2tab_name, int len, const int port, const char *networkProto, const char *hostname, const char *fsname, const char *fs_file)
int destroy_pvfs2tab_file (const char *pvfs2tab_name)
int initialize (const int use_pvfs2_lib, const int verbose)
int is_pvfs2 (const char *fileName, PVFS_fs_id *cur_fs, char *relativeName, const int relativeNameSize, const int use_pvfs2_lib, const int verbose)
int finalize (int use_pvfs2_lib)
int close_file (struct file_ref *stFileRef, const int use_pvfs2_lib, const int verbose)
int stat_file (const char *fileName, struct stat *fileStats, const int followLink, const int use_pvfs2_lib, const int verbose)
int open_file (const char *fileName, const int accessFlags, const int mode, const int use_pvfs2_lib, const int verbose, const int followLink, struct file_ref *pstFileRef)
int create_file (const char *fileName, const int mode, const int use_pvfs2_lib, const int verbose)
int create_directory (const char *directory, const int mode, const int use_pvfs2_lib, const int verbose)
int remove_directory (const char *directory, const int use_pvfs2_lib, const int verbose)
int remove_symlink (const char *linkName, const int use_pvfs2_lib, const int verbose)
int remove_file (const char *fileName, const int use_pvfs2_lib, const int verbose)
int change_mode (const char *fileName, const int mode, int *error_code, const int use_pvfs2_lib, const int verbose)
int change_owner (const char *fileName, const char *ownerName, const uid_t owner_id, const char *groupName, const gid_t group_id, const int use_pvfs2_lib, const int verbose)
int change_group (const char *fileName, const uid_t group_id, const int use_pvfs2_lib, const int verbose)
void print_stats (const struct stat stats, const int verbose)
int pvfs2_open (const char *fileName, const int accessFlags, const int mode, const int verbose, const int followLink, struct file_ref *pstFileRef)
int pvfs2_create_file (const char *fileName, const PVFS_fs_id fs_id, const PVFS_credentials *credentials, const int mode, const int verbose, struct file_ref *pstFileRef)
int lookup_parent (char *filename, PVFS_fs_id fs_id, PVFS_credentials *credentials, PVFS_handle *handle, int verbose)
int get_base_dir (char *pathName, char *baseDir, int baseDirSize)
int remove_base_dir (char *pathName, char *baseDir, int baseDirSize)
int create_symlink (const char *linkName, const char *linkTarget, const int use_pvfs2_lib, const int verbose)
int parse_common_args (int argc, char **argv, struct common_options *opts)


Detailed Description

Implementation of the test-common wrapper functions.


Function Documentation

int change_group const char *  fileName,
const uid_t  group_id,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
fileName  Target Name
group_id  The gid of the new group
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int change_mode const char *  fileName,
const int  mode,
int *  error_code,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
fileName  Target Name
mode  Mode to set
error_code  Not implemented, should be return code from call
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int change_owner const char *  fileName,
const char *  ownerName,
const uid_t  owner_id,
const char *  groupName,
const gid_t  group_id,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
fileName  Target Name
ownerName  Owner Name to change to
owner_id  The uid of the new owner
groupName  group Name to change to
group_id  The uid of the new group
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int close_file struct file_ref stFileRef,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
stFileRef  File descriptor (or handle) for an open file
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int create_directory const char *  directory,
const int  mode,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
directory  Directory Name
mode  directory permissions
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int create_file const char *  fileName,
const int  mode,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
fileName  File Name
mode  directory permissions
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

Here is the call graph for this function:

int create_pvfs2tab_file char *  pvfs2tab_name,
int  len,
const int  port,
const char *  networkProto,
const char *  hostname,
const char *  fsname,
const char *  fs_file
 

creates the pvfs2tab file and sets the environment variable appropriately for you to use the PVFS2 API.

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
pvfs2tab_name  Placeholder for file name of file created
len  Maximum length of pvfs2tab_name
port  Port number for PVFS2 file system
networkProto  Network Protocol, i.e. tcp
hostname  Hostname of main metaserver
fsname  file system name in pvfs2 configuration
fs_file  fs_file as defined in fstab (mount point)

int create_symlink const char *  linkName,
const char *  linkTarget,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
linkName  The link name to create
linkTarget  The string the link will contain
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int destroy_pvfs2tab_file const char *  pvfs2tab_name  ) 
 

Deletes the pvfstab file and un-sets the environment variable PVFS2TAB_FILE.

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
pvfs2tab_name  name of file to delete

void display_common_usage char *  exeName  )  [static]
 

Displays common argument lists.

int finalize int  use_pvfs2_lib  ) 
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
use_pvfs2_lib  determines use of pvfs2 library

int get_base_dir char *  pathName,
char *  baseDir,
int  baseDirSize
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Note:
Example inputs and outputs/return values:
pathname: /tmp - out_base_dir: / - returns 0 pathname: /tmp/foo - out_base_dir: /tmp - returns 0 pathname: /tmp/foo/bar - out_base_dir: /tmp/foo - returns 0

invalid pathname input examples: pathname: / - out_base_dir: undefined - returns -1 pathname: NULL - out_base_dir: undefined - returns -1 pathname: foo - out_base_dir: undefined - returns -1

Parameters:
pathName  absolute path name
baseDir  pointer to memory to place discovered base directory
baseDirSize  maximum size base directory could be

int initialize const int  use_pvfs2_lib,
const int  verbose
 

Initializes the PVFS2 API.

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int is_pvfs2 const char *  fileName,
PVFS_fs_id cur_fs,
char *  relativeName,
const int  relativeNameSize,
const int  use_pvfs2_lib,
const int  verbose
 

Note:
initialize must be called prior to this function. This function will fill in the cur_fs and relativeName on success
Return values:
TEST_COMMON_SUCCESS Success (PVFS2 file)
TEST_COMMON_FAIL Failure (NOT PVFS2 file)
Parameters:
fileName  Null terminated file name
cur_fs  container for return value for fs_id
relativeName  container for return value for relative path
relativeNameSize  size of relativeName
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int lookup_parent char *  filename,
PVFS_fs_id  fs_id,
PVFS_credentials credentials,
PVFS_handle handle,
int  verbose
 

Return values:
0 SUCCESS
-1 Generic FAILURE
-errno FAILURE using PVFS2 API
Parameters:
filename  File Name
fs_id  PVFS2 files sytem ID for the fileName parm
credentials  Struct with user/group permissions for operation
handle  PVFS2 handle
verbose  Turns on verbose prints if set to non-zero value

Here is the call graph for this function:

int open_file const char *  fileName,
const int  accessFlags,
const int  mode,
const int  use_pvfs2_lib,
const int  verbose,
const int  followLink,
struct file_ref pstFileRef
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
fileName  File Name
accessFlags  open access flags
mode  open mode flags
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value
followLink  Follow symbolic link to target?
pstFileRef  File descriptor (or handle) for an open file

Here is the call graph for this function:

int parse_common_args int  argc,
char **  argv,
struct common_options *  opts
 

Parses command line options for the most common arguments /retval TEST_COMMON_SUCCESS Indicates successfull return /retval TEST_COMMON_FAIL Indicates failure return.

Parameters:
argc  Number of arguments
argv  argument list
opts  structure to hold the common arguments

Here is the call graph for this function:

void print_stats const struct stat  stats,
const int  verbose
 

Parameters:
stats  Structure contains file stats
verbose  Turns on verbose prints if set to non-zero value

int pvfs2_create_file const char *  fileName,
const PVFS_fs_id  fs_id,
const PVFS_credentials credentials,
const int  mode,
const int  verbose,
struct file_ref pstFileRef
 

Return values:
0 SUCCESS
-errno FAILURE using PVFS2 API
Parameters:
fileName  File Name
fs_id  PVFS2 files sytem ID for the fileName parm
credentials  Struct with user/group permissions for operation
mode  open mode flags
verbose  Turns on verbose prints if set to non-zero value
pstFileRef  File descriptor (or handle) for an open file

int pvfs2_open const char *  fileName,
const int  accessFlags,
const int  mode,
const int  verbose,
const int  followLink,
struct file_ref pstFileRef
 

Return values:
0 SUCCESS
-errno FAILURE using PVFS2 API
Parameters:
fileName  File Name
accessFlags  open LDAP access flags
mode  open LDAP mode flags
verbose  Turns on verbose prints if set to non-zero value
followLink  Follow symbolic link to target
pstFileRef  File descriptor (or handle) for an open file

Here is the call graph for this function:

int remove_base_dir char *  pathName,
char *  baseDir,
int  baseDirSize
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Note:
Example inputs and outputs/return values:
pathname: /tmp/foo - out_base_dir: foo - returns 0 pathname: /tmp/foo/bar - out_base_dir: bar - returns 0

invalid pathname input examples: pathname: / - out_base_dir: undefined - returns -1 pathname: NULL - out_base_dir: undefined - returns -1 pathname: foo - out_base_dir: undefined - returns -1

Parameters:
pathName  absolute path name
baseDir  pointer to memory to place discovered base directory
baseDirSize  maximum size base directory could be

int remove_directory const char *  directory,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
directory  Directory Name
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int remove_file const char *  fileName,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
fileName  File Name
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

int remove_symlink const char *  linkName,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
0 SUCCESS
errno FAILURE using VFS layer
-ENODATA FAILURE using PVFS2 API
Parameters:
linkName  Symlink Name
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value

Here is the call graph for this function:

int set_util_path const char *  utility_path  ) 
 

Sets a local char array containing the path to prefix all pvfs2 utilities.

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
utility_path  NULL terminated path. MUST end with "/"

int stat_file const char *  fileName,
struct stat *  fileStats,
const int  followLink,
const int  use_pvfs2_lib,
const int  verbose
 

Return values:
TEST_COMMON_SUCCESS Success
TEST_COMMON_FAIL Failure
Parameters:
fileName  File Name
fileStats  stat structure to place results from stat call
followLink  Determines whether to stat link or link target
use_pvfs2_lib  determines use of pvfs2 library
verbose  Turns on verbose prints if set to non-zero value


Generated on Sat Feb 4 02:46:03 2012 for PVFS by doxygen 1.3.5