[Gluster-devel] some questions about gfapi glfs_open

Vijay Bellur vbellur at redhat.com
Mon Jun 16 11:03:29 UTC 2014


On 06/16/2014 08:47 AM, Gong XiaoHui wrote:
> Hi
> 
>    When I use the libgfapi, I need to open and write a file, called ” 
> glfs_open(glfs, path, O_WRONLY|O_TRUNC);” return a glfs_fd_t,
> 
> before I close it ,there is a new request to read the same file,
> 
> I think the read request return NULL,

Does glfs_read() return -1? If so, this seems to be in line with
expected behavior. Is there any reason for your application to send read
on a fd that has been opened with O_WRONLY?


> but if I call “glfs_open(glfs, 
> path, O_RDONLY);”,it return a available glfs_fd_t, so what should I do 
> to resolve this problem?
> 

Opening fd with O_RDWR | O_TRUNC seems to be the right thing to do if
both read and write operations are expected on the fd.

-Vijay


More information about the Gluster-devel mailing list