00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <sys/file.h>
00004 #include <sys/param.h>
00005 #include <errno.h>
00006 #include <sys/stat.h>
00007 #include <string.h>
00008 #include <unistd.h>
00009 #include <sys/types.h>
00010 #include <malloc.h>
00011 #include <fcntl.h>
00012 #include <sys/vfs.h>
00013 #include <sys/stat.h>
00014 #include <sys/param.h>
00015 #include <sys/mount.h>
00016 #include "u_signed64.h"
00017 #include "hpss_api.h"
00018 #include "mvr_protocol.h"
00019 #include <sys/time.h>
00020 #include "hpss_errno.h"
00021 #include "hpss_String.h"
00022
00023 #define BUF_SIZE 1024
00024
00025
00026
00027
00028
00029 #define HPSS_USER_ID "srb"
00030 #define HPSS_KEYtAB_FILE "/users/u4/srb/hpssKeytab/ktb_srb"
00031 #define MY_COS 510
00032 #define WRITE_PATH "/users/sdsc/srb/irodsTestVault/foo1"
00033 #define READ_PATH "/users/sdsc/srb/zero/slocal_lter_120100.tar"
00034
00035 int
00036 main(int argc, char **argv)
00037 {
00038 int status;
00039 hpss_authn_mech_t mech_type;
00040 hpss_cos_hints_t HintsIn;
00041 hpss_cos_priorities_t HintsPri;
00042 int myCos;
00043 int destFd;
00044 int myFlags;
00045 long long mySize;
00046 char myBuf[BUF_SIZE];
00047 int srcFd;
00048 api_config_t api_config;
00049
00050
00051
00052
00053 status = hpss_GetConfiguration(&api_config);
00054 if(status != 0) {
00055 exit( status );
00056 }
00057
00058 api_config.AuthnMech = hpss_authn_mech_unix;
00059 api_config.Flags |= API_USE_CONFIG;
00060
00061 status = hpss_SetConfiguration(&api_config);
00062 if(status != 0) {
00063 exit( status );
00064 }
00065
00066 status = hpss_AuthnMechTypeFromString("unix", &mech_type);
00067 if(status != 0) {
00068 fprintf (stderr,
00069 "hpss_AuthnMechTypeFromString type unix failed, status = %d",
00070 status);
00071 exit (1);
00072 }
00073
00074 #if 0
00075 mech_type = hpss_authn_mech_unix;
00076 #endif
00077 status = hpss_SetLoginCred(HPSS_USER_ID, mech_type, hpss_rpc_cred_client,
00078 hpss_rpc_auth_type_keytab, HPSS_KEYtAB_FILE);
00079 if(status != 0) {
00080 fprintf (stderr,
00081 "hpss_SetLoginCred ,status = %dn", status);
00082 exit (2);
00083 }
00084
00085
00086 srcFd = hpss_Open (READ_PATH, O_RDONLY, 0, NULL, NULL, NULL);
00087 if (srcFd < 0) {
00088 fprintf (stderr,
00089 "hpss_Open for read error, status = %d\n", srcFd);
00090 exit (3);
00091 } else {
00092 fprintf (stdout,
00093 "hpss_Open for read successflly, srcFd = %d\n", srcFd);
00094 }
00095 hpss_Close (srcFd);
00096
00097
00098
00099 myFlags = O_CREAT | O_TRUNC | O_RDWR;
00100 (void) hpss_Umask((mode_t) 0000);
00101 myCos = MY_COS;
00102
00103 memset(&HintsIn, 0, sizeof HintsIn);
00104 memset(&HintsPri, 0, sizeof HintsPri);
00105 mySize = BUF_SIZE;
00106 CONVERT_LONGLONG_TO_U64(mySize, HintsIn.MinFileSize);
00107 HintsIn.MaxFileSize = HintsIn.MinFileSize;
00108 HintsPri.MaxFileSizePriority = HintsPri.MinFileSizePriority =
00109 REQUIRED_PRIORITY;
00110 destFd = hpss_Open (WRITE_PATH, myFlags, 0600, &HintsIn,
00111 &HintsPri, NULL);
00112
00113 if (destFd < 0) {
00114 fprintf (stderr,
00115 "hpss_Open error, status = %d\n", destFd);
00116 exit (3);
00117 } else {
00118 fprintf (stdout,
00119 "hpss_Open for write successflly, destFd = %d\n", destFd);
00120 }
00121
00122 status = hpss_Write (destFd, myBuf, BUF_SIZE);
00123 if(status != 0) {
00124 fprintf (stderr,
00125 "hpss_Write ,status = %dn", status);
00126 exit (4);
00127 }
00128
00129 hpss_Close (destFd);
00130
00131 exit (0);
00132 }