how is the open done??

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how is the open done??

sankar raman
Hi,

Is a filesystem allowed to store the
open file descriptor or should it open
the file for each read/write.

I modified open to store the descriptors.
some times it works and some times it doesnt.
there is no memory leak.. So can anyone
clarify on this point.

Thanks
J.Sankararaman



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: how is the open done??

Terje Oseberg
It appears that Vincenzo has already answered your question. Please
read his response below.

He says, "Yes" you can store the filehandle. However, since the fuse
library is multi-threaded, you may be running into issues. You should
try using, "-s" option to see if that solves any of your problems.
The, "-s" option to fusexmp causes it to run in single threaded mode.
This will help you to debug your logic. You can then add semaphores
later to make it work multi-threaded.

Also, below Vincenzo suggest a better way to store the file handle
such that multiple programs run my different users can open the same
file, and the permissions will be enforced properly. Please read below
for a description.

Terje
               
Vincenzo Ciancia
<[hidden email]> to fuse-devel
         More options  7:15 am (0 minutes ago)
sankar raman wrote:

> But I am getting the following error:
> when I typed cat fd.c
>

If you use the version 2.2 or above of the interface (as fusexmp distributed
with the latest version of fuse does), open has an additional argument,
with type struct fuse file info *, and in its "fh" field you can store your
handle. A struct of the same type, with the fh field filled with the value
that you provided in open(), will be returned to each read(), write() ecc.
call made from the process which performed the open() call.

However, this will not reuse open files on a per-path basis (which is not
posix-compliant, but you might be interest in doing things that way) - to
do that you have to use an hashtable as you are in fact doing. At this
point, the segfault might be caused by not properly locking the hashtable,
because fuse is multithreaded by default, i.e. there can be a different
thread for each request. Try to use the "-s" option to fusexmp, and see if
the error disappears, or post your code here for more advice.

Bye

Vincenzo

On 9/22/05, sankar raman <[hidden email]> wrote:

> Hi,
>
> Is a filesystem allowed to store the
> open file descriptor or should it open
> the file for each read/write.
>
> I modified open to store the descriptors.
> some times it works and some times it doesnt.
> there is no memory leak.. So can anyone
> clarify on this point.
>
> Thanks
> J.Sankararaman
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: how is the open done??

Franco Broi
On Thu, 2005-09-22 at 02:18 -0700, Terje Oseberg wrote:

>
> If you use the version 2.2 or above of the interface (as fusexmp distributed
> with the latest version of fuse does), open has an additional argument,
> with type struct fuse file info *, and in its "fh" field you can store your
> handle. A struct of the same type, with the fh field filled with the value
> that you provided in open(), will be returned to each read(), write() ecc.
> call made from the process which performed the open() call.

Not sure I understand this next bit about "per-path basis", is he saying
that the same file opened twice has 2 file descriptors and is therefore
not POSIX compliant?

Storing the FD in the file handle certainly works for me.

>
> However, this will not reuse open files on a per-path basis (which is not
> posix-compliant, but you might be interest in doing things that way) - to
> do that you have to use an hashtable as you are in fact doing. At this
> point, the segfault might be caused by not properly locking the hashtable,
> because fuse is multithreaded by default, i.e. there can be a different
> thread for each request. Try to use the "-s" option to fusexmp, and see if
> the error disappears, or post your code here for more advice.




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: how is the open done??

Vincenzo Ciancia
Franco Broi wrote:

> Not sure I understand this next bit about "per-path basis", is he saying
> that the same file opened twice has 2 file descriptors and is therefore
> not POSIX compliant?
>
> Storing the FD in the file handle certainly works for me.

Yes of course, I said that this is the right way to do that! What I meant
not to be posix-compliant is to have a single file handle shared between
two different open() calls, by caching unix open() results "on a path
basis", i.e. using an hashtable with paths as keys and handles as values,
and checking for each open if a file handle is already associated with that
path - this is what the OP strategy looked like to me.

I think that after the first open() file permissions could have changed so
for each open() call directed to your filesystem you should check
permissions (e.g. in fusexmp this is done by the unix open() call).

However after having checked permissions one could reuse an already existing
handle opened with the same flags - I suppose - is this true or could this
cause problems?

Bye

Vincenzo

--
Please note that I do not read the e-mail address used in the from field but
I read vincenzo_ml at yahoo dot it
Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo
vincenzo_ml at yahoo dot it



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re: how is the open done??

Franco Broi
On Thu, 2005-09-22 at 12:09 -0400, Vincenzo Ciancia wrote:

> > Storing the FD in the file handle certainly works for me.
>
> Yes of course, I said that this is the right way to do that!

Yes I see that now, sorry for the confusion.



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel