#593964 [glocalfileoutputstream] Fallback for filesystems that don't support renames on open files

Package:
libglib2.0-0
Source:
glib2.0
Description:
GLib library of C routines
Submitter:
Matthijs Melchior
Date:
2010-08-24 07:57:05 UTC
Severity:
wishlist
#593964#5
Date:
2010-08-22 16:46:07 UTC
From:
To:
*** Please type your report below this line ***

This bug occures with gedit running in Debian Linux in VirtualBox on
WinXP with an NTFS filesystem.

Editing a file on the host filesysten and saving it gives the following
error in a red bar on the screen:

Could not save the file /C/Temp/test-gedit.
Unexpected error: Error renaming temporary file: Text file busy

** (gedit:20691): WARNING **: Hit unhandled case 0 (Error renaming
temporary file: Text file busy) in parse_error.

The condensed strace output for this error is as follows:

20724 open("/C/Temp/test-gedit", O_RDWR|O_CREAT|O_LARGEFILE, 0666
<unfinished ...>
20724 <... open resumed> )              = 25
20724 open("/C/Temp/.goutputstream-P3PXHV",
O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0666 <unfinished ...>
20724 <... open resumed> )              = 26
20724 write(26, "hallo\nhallo\nhallo\n\n\n", 20 <unfinished ...>
20724 <... write resumed> )             = 20
20724 unlink("/C/Temp/test-gedit~" <unfinished ...>
20724 <... unlink resumed> )            = 0
20724 link("/C/Temp/test-gedit", "/C/Temp/test-gedit~") = -1 EPERM
(Operation not permitted)
20724 rename("/C/Temp/test-gedit", "/C/Temp/test-gedit~" <unfinished ...>
20724 <... rename resumed> )            = 0
20724 rename("/C/Temp/.goutputstream-P3PXHV", "/C/Temp/test-gedit"
<unfinished ...>
20724 <... rename resumed> )            = -1 ETXTBSY (Text file busy)
20724 close(26 <unfinished ...>

This suggests the reason for the problem:
The .goutputstream-P3PXHV file is being renamed before it is closed.
I believe this is a problem on NTFS...


This also suggests a workaround: make sure the 'Create backup copy'
editor mode is checked,
                  and do the save twice (ignoring the error on the first...)

Please change gedit and/or glib to aviod this error.

#593964#10
Date:
2010-08-23 08:41:36 UTC
From:
To:
Le dimanche 22 août 2010 à 18:46 +0200, Matthijs Melchior a écrit :

I’m afraid that renaming the file before closing it is the appropriate
behavior. I don’t think we should change this behavior because of one
broken filesystem implementation.

What kind of filesystem is /C in VirtualBox, anyway? I guess it is not
directly mounted as NTFS.

Cheers,

#593964#15
Date:
2010-08-23 21:17:09 UTC
From:
To:
$ df -hT /C
Filesystem    Type    Size  Used Avail Use% Mounted on
C_DRIVE     vboxsf    233G   46G  188G  20% /C

The error can be handled more graceful:
After the ETXTBSY error, the file can be saved to its original name
(which has been moved away to its backup name already) and after that
is successful remove the temporary file. This is not an efficient way
to save a file, but it does not change behavior on sane filesystems
and is expected work on the VBox shared folders...

#593964#20
Date:
2010-08-24 07:47:55 UTC
From:
To:
clone 593964 -1
retitle 593964 [glocalfileoutputstream] Fallback for filesystems that don’t support renames on open files
severity 593964 wishlist
reassign 593964 libglib2.0-0
retitle -1 [vboxsf] Cannot rename an open file
reassign -1 virtualbox-ose-guest-utils
thanks

Le lundi 23 août 2010 à 23:17 +0200, Matthijs Melchior a écrit :

Feel free to raise the issue to upstream developers. I personally
consider this is an issue in the vboxsf implementation.

Note that SUSv3 allows rename() to fail when the directory is busy, but
not when the file itself is busy. The ETXTBUSY error code is for another
case which is irrelevant on Linux: “The file to be renamed is a pure
procedure (shared text) file that is being executed.”

Cheers,