* fish.c (fish_fh_open): Use vfs_mkstemps() for write buffers as

well, since the file can be reopened for reading later.
* ftpfs.c (ftpfs_fh_open): Likewise.
This commit is contained in:
Pavel Roskin 2003-10-29 01:35:36 +00:00
parent af86cebacd
commit cd644b527c
3 changed files with 16 additions and 8 deletions

View File

@ -1,5 +1,9 @@
2003-10-28 Pavel Roskin <proski@gnu.org>
* fish.c (fish_fh_open): Use vfs_mkstemps() for write buffers as
well, since the file can be reopened for reading later.
* ftpfs.c (ftpfs_fh_open): Likewise.
* utilvfs.c (vfs_mkstemps): New function - create temporary file
with the name resembling the original, but safe for scripts.
* direntry.c (vfs_s_open): Use it.

View File

@ -823,14 +823,18 @@ static int fish_rmdir (struct vfs_class *me, char *path)
POSTFIX(OPT_FLUSH);
}
static int fish_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
static int
fish_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
int mode)
{
fh->u.fish.append = 0;
/* File will be written only, so no need to retrieve it */
if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY|O_RDWR))){
if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY | O_RDWR))) {
fh->u.fish.append = flags & O_APPEND;
if (!fh->ino->localname){
int tmp_handle = mc_mkstemps (&fh->ino->localname, me->name, NULL);
if (!fh->ino->localname) {
int tmp_handle =
vfs_mkstemps (&fh->ino->localname, me->name,
fh->ino->ent->name);
if (tmp_handle == -1)
return -1;
close (tmp_handle);
@ -838,10 +842,10 @@ static int fish_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, i
return 0;
}
if (!fh->ino->localname)
if (vfs_s_retrieve_file (me, fh->ino)==-1)
if (vfs_s_retrieve_file (me, fh->ino) == -1)
return -1;
if (!fh->ino->localname)
vfs_die( "retrieve_file failed to fill in localname" );
vfs_die ("retrieve_file failed to fill in localname");
return 0;
}

View File

@ -1577,8 +1577,8 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
*/
if (FH_SUPER->u.ftp.ctl_connection_busy) {
if (!fh->ino->localname) {
int handle =
mc_mkstemps (&fh->ino->localname, me->name, NULL);
int handle = vfs_mkstemps (&fh->ino->localname, me->name,
fh->ino->ent->name);
if (handle == -1)
return -1;
close (handle);