Fuse and O_TRUNC

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

Fuse and O_TRUNC

Esben Nielsen
Hy,
 I am playing around with both fusesmb and SmbNetFs - both base on Fuse.
Both have problems when I edit files over emacs. When I cut stuff out of a
file and saves it magically extra lines of text appear in the end of the
file.
The problem comes from the following line in
kernel/file.c:fuse_open_common():

        inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY |
O_TRUNC);

Why are those flags removed? I the smbclient code both fusesmb and
smbnetfs is based on needs to know at least O_TRUNC.

I "fixed" the emacs problem in fusesmb by adding
 if( (fi->flags & O_ACCMODE) == O_WRONLY &&
        !(fi->flags & O_APPEND))
      fi->flags |= O_TRUNC;
before opening a file but it would have been a lot easier if fuse let them
be.

Esben





-------------------------------------------------------
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: Fuse and O_TRUNC

Miklos Szeredi
> Hy,
>  I am playing around with both fusesmb and SmbNetFs - both base on Fuse.
> Both have problems when I edit files over emacs. When I cut stuff out of a
> file and saves it magically extra lines of text appear in the end of the
> file.
> The problem comes from the following line in
> kernel/file.c:fuse_open_common():
>
> inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY |
> O_TRUNC);
>
> Why are those flags removed? I the smbclient code both fusesmb and
> smbnetfs is based on needs to know at least O_TRUNC.

The open(..., O_TRUNC) is separated into a ->truncate() and a
->open().  Similarly (depending on whether the file existed
previously), open(..., O_CREAT) is separated into ->mknod() and
->open().  Etc...

This is something done by the VFS (in the kernel) and currently
there's no way to bypass it.

> I "fixed" the emacs problem in fusesmb by adding
>  if( (fi->flags & O_ACCMODE) == O_WRONLY &&
> !(fi->flags & O_APPEND))
>       fi->flags |= O_TRUNC;
> before opening a file but it would have been a lot easier if fuse let them
> be.

The _real_ solution is to just implement the ->truncate() method.  Why
is that not implemented?  Or maybe it is implemented, but doesn't work
correctly?

Miklos


-------------------------------------------------------
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: Fuse and O_TRUNC

Esben Nielsen
On Mon, 19 Sep 2005, Miklos Szeredi wrote:

> > Hy,
> >  I am playing around with both fusesmb and SmbNetFs - both base on Fuse.
> > Both have problems when I edit files over emacs. When I cut stuff out of a
> > file and saves it magically extra lines of text appear in the end of the
> > file.
> > The problem comes from the following line in
> > kernel/file.c:fuse_open_common():
> >
> > inarg.flags = file->f_flags & ~(O_CREAT | O_EXCL | O_NOCTTY |
> > O_TRUNC);
> >
> > Why are those flags removed? I the smbclient code both fusesmb and
> > smbnetfs is based on needs to know at least O_TRUNC.
>
> The open(..., O_TRUNC) is separated into a ->truncate() and a
> ->open().  Similarly (depending on whether the file existed
> previously), open(..., O_CREAT) is separated into ->mknod() and
> ->open().  Etc...
>
> This is something done by the VFS (in the kernel) and currently
> there's no way to bypass it.
>
> > I "fixed" the emacs problem in fusesmb by adding
> >  if( (fi->flags & O_ACCMODE) == O_WRONLY &&
> > !(fi->flags & O_APPEND))
> >       fi->flags |= O_TRUNC;
> > before opening a file but it would have been a lot easier if fuse let them
> > be.
>
> The _real_ solution is to just implement the ->truncate() method.  Why
> is that not implemented?  Or maybe it is implemented, but doesn't work
> correctly?
>
I found out it was implemented in a later version ...

> Miklos
>

Esben




-------------------------------------------------------
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