Hello,
i'm trying to create a file and read from it.The creation is working fine. When 
i'm trying to read the file, i get an error when i call the "pvfs_sys_read"
invalid (NULL) required argumentPVFS_isys_io call: Invalid 
argumentPVFS_sys_read : Invalid argument (error class: 0)

The problem is in the following line:" ret = PVFS_sys_read(resp_create.ref, 
file_req, 0,buffer, mem_req, &credentials, &resp_io, hints);"I can't understand 
which one of the arguments is causing the problem,can you understand?How can i 
solve it?
The program is as follows:
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include 
<limits.h>#include <string.h>#include <sys/time.h>#include 
<sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <time.h>#include 
<libgen.h>#include <getopt.h>#include "pvfs2.h"

#include "str-utils.h"#include "pint-sysint-utils.h"#include "pvfs2-internal.h"
#include "pvfs2-hint.h"

int main(void) {
    int ret = -1;

    PVFS_sys_layout layout;
    layout.algorithm = PVFS_SYS_LAYOUT_ROUND_ROBIN;    layout.server_list.count 
= 0;    layout.server_list.servers = NULL;
    /* Initialize the pvfs2 server */    ret = PVFS_util_init_defaults();    
if(ret < 0)    {       PVFS_perror("PVFS_util_init_defaults", ret);        
return -1;    }
        int rc;        int num_segs;        char *working_file = "test2.txt";
        char directory[PVFS_NAME_MAX] = "/mnt/pvfs2/testDir/";        char 
filename[PVFS_SEGMENT_MAX];
        layout.algorithm = PVFS_SYS_LAYOUT_ROUND_ROBIN;        
layout.server_list.count = 0;        if(layout.server_list.servers)        {    
        free(layout.server_list.servers);        }       
layout.server_list.servers = NULL;
        char pvfs_path[PVFS_NAME_MAX] = {0};        PVFS_fs_id cur_fs;        
PVFS_sysresp_lookup resp_lookup;        PVFS_sysresp_create resp_create;        
PVFS_credentials credentials;        PVFS_object_ref parent_ref;        
PVFS_sys_attr attr;
        /* Translate path into pvfs2 relative path */        rc = 
PINT_get_base_dir(working_file, directory, PVFS_NAME_MAX);        num_segs = 
PINT_string_count_segments(working_file);        rc = 
PINT_get_path_element(working_file, num_segs - 1,filename, PVFS_SEGMENT_MAX);
        if (rc)        {            fprintf(stderr, "Unknown path format: 
%s\n", working_file);            ret = -1;
        }
       rc = PVFS_util_resolve(directory, &cur_fs,pvfs_path, PVFS_NAME_MAX);     
   if (rc)        {            PVFS_perror("PVFS_util_resolve", rc);            
ret = -1;
        }
        PVFS_util_gen_credentials(&credentials);
        memset(&resp_lookup, 0, sizeof(PVFS_sysresp_lookup));        rc = 
PVFS_sys_lookup(cur_fs, pvfs_path, &credentials,&resp_lookup, 
PVFS2_LOOKUP_LINK_NO_FOLLOW, NULL);        if (rc)        {            
PVFS_perror("PVFS_sys_lookup", rc);            ret = -1;
        }
        /* Set attributes */        imemset(&attr, 0, sizeof(PVFS_sys_attr));   
     attr.owner = credentials.uid;        attr.group = credentials.gid;        
attr.perms = 0777;        attr.atime = time(NULL);        attr.mtime = 
attr.atime;        attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;        
attr.dfile_count = 0;
        parent_ref = resp_lookup.ref;
        layout.algorithm = PVFS_SYS_LAYOUT_RANDOM;
       lrc = PVFS_sys_create(filename,                             parent_ref,  
                           attr,                             parent_ref,        
                     attr,                             &credentials,            
                 NULL,                             &resp_create,                
             &layout,                             NULL);        if (rc)        
{           fprintf(stderr, "Error: An error occurred while creating 
%s\n",working_file);            PVFS_perror("PVFS_sys_create", rc);            
ret = -1;         }
       /* Everthing fine till here! */
        PVFS_Request mem_req, file_req;        PVFS_sysresp_io resp_io;        
char * buffer;        size_t count = 100;         int64_t offset;        
PVFS_hint hints = NULL;        file_req = PVFS_BYTE;        ret = 
PVFS_Request_contiguous(count, PVFS_BYTE, &mem_req);
        if (ret < 0)        {           fprintf(stderr, "Error: 
PVFS_Request_contiguous failure\n");            return (ret);        }       
ret = PVFS_sys_read(resp_create.ref, file_req, 0,buffer, mem_req, &credentials, 
&resp_io, hints); /* problem here!!! */        if (ret == 0)        {           
PVFS_Request_free(&mem_req);
        }       else {           PVFS_perror("PVFS_sys_read === ", ret);        
    printf("ret = %d\n",ret);        }    PVFS_sys_finalize();

}


Can you understand where the problem is?Where is that NULL value that causes 
the problem?Thanks, in advance


                                          
_______________________________________________
Pvfs2-users mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-users

Reply via email to