00001 #include "drms.h"
00002 #include <printk.h>
00003 #ifdef __linux__
00004 #include <sched.h>
00005 #endif
00006
00007 ModuleArgs_t module_args[] =
00008 {
00009 {ARG_INT, "sunum", NULL , "SU number", ""},
00010 {ARG_INT, "size", NULL, "Size in bytes of the SU", ""},
00011 {ARG_END}
00012 };
00013
00014 ModuleArgs_t *gModArgs = module_args;
00015 CmdParams_t cmdparams;
00016
00017 int main(int argc, char *argv[])
00018 {
00019
00020 long long sunum = 0;
00021 uint64_t size = 0;
00022 char *sudir = (char *) NULL;
00023 SUM_t *sum = (SUM_t *) NULL;
00024 int status = 0;
00025
00026 if ((status = cmdparams_parse(&cmdparams, argc, argv)) < CMDPARAMS_SUCCESS)
00027 {
00028 fprintf(stderr,"Error: Command line parsing failed. Aborting. [%d]\n", status);
00029 return -1;
00030 }
00031
00032 sunum = cmdparams_get_int64(&cmdparams, "sunum", NULL);
00033 size = cmdparams_get_int64(&cmdparams, "size", NULL);
00034
00035 if ((sum = SUM_open(NULL, NULL, printkerr)) == NULL)
00036 {
00037 fprintf(stderr,"ERROR: drms_open: Failed to connect to SUMS.\n");
00038 fflush(stdout);
00039 return -2;
00040 }
00041
00042 sum->reqcnt = 1;
00043 sum->bytes = size;
00044
00045
00046 if ((status = SUM_alloc2(sum, sunum, printkerr)))
00047 {
00048 fprintf(stderr, "ERROR: SUM_alloc2 RPC call failed with "
00049 "error code %d\n", status);
00050
00051 if (sum)
00052 {
00053 SUM_close(sum, printkerr);
00054 }
00055
00056 return -3;
00057 }
00058
00059 sudir = strdup(sum->wd[0]);
00060 fprintf(stdout, "sunum:%llu;size:%llu;sudir:%s\n",(unsigned long long)sunum,(unsigned long long)size,sudir);
00061
00062
00063 SUM_close(sum, printkerr);
00064
00065 if (sum->wd[0]) {
00066 free(sum->wd[0]);
00067 }
00068
00069 if (sudir) {
00070 free(sudir);
00071 }
00072
00073
00074 return 0;
00075 }
00076