[patch] Fix ftpfs uploading behavior.

Andrew V. Samoilov kai at cmail.ru
Mon Mar 11 08:28:19 UTC 2002


On Thu, Mar 07, 2002 at 05:45:08PM +0400, Walery Studennikov wrote:
> On Wed, Mar 06, 2002 at 11:02:40AM +0200, Andrew V. Samoilov wrote:
> > Hi!
> > 
> > This patch fixes ftpfs uploading behavior.
> > Now if file is opened for writting only it will be not retrieved
> > to temporary file before uploading.
> > 
> > This is first approximation.
> > Test it carefully please.
> 
> Probably, I've found a bug:
> now I can't open file for edit via ftp -
> MC hangs after downloading the file for editing.
> 

Fixed, see patch below (for patched ftpfs.c).
Second approximation of this patch will be uploaded soon to

http://www.linux.zp.ua/mc/ftpfs.upload.patch

Also if your vfs/direntry.c is not from CVS,
you need patch for this one 9 lines below.


diff -u -p -u -p -r1.89 ftpfs.c
--- ftpfs.c	2002/02/01 12:21:55	1.85
+++ ftpfs.c	2002/02/06 12:08:01
@@ -1691,7 +1723,7 @@ static int ftpfs_fh_open (vfs *me, vfs_s
 
 static int ftpfs_fh_close (vfs *me, vfs_s_fh *fh)
 {
-    if (fh->handle != -1){
+    if (fh->handle != -1 && !fh->ino->localname){
 	close (fh->handle);
 	fh->handle = -1;
 	fh->changed = 0;
--- vfs/direntry.c	Tue Feb 19 10:59:23 2002
+++ vfs/direntry.c	Wed Mar  6 10:46:35 2002
@@ -832,7 +826,7 @@ vfs_s_read (void *fh, char *buffer, int 
     if (FH->linear == LS_LINEAR_OPEN)
         return MEDATA->linear_read (me, FH, buffer, count);
         
-    if (FH->handle){
+    if (FH->handle != -1){
 	n = read (FH->handle, buffer, count);
 	if (n < 0)
 	    me->verrno = errno;
@@ -852,7 +846,7 @@ vfs_s_write (void *fh, char *buffer, int
 	vfs_die ("no writing to linear files, please");
         
     FH->changed = 1;
-    if (FH->handle){
+    if (FH->handle != -1){
 	n = write (FH->handle, buffer, count);
 	if (n < 0)
 	    me->verrno = errno;
@@ -926,7 +920,7 @@ vfs_s_close (void *fh)
 	}
 	vfs_s_invalidate (me, FH_SUPER);
     }
-    if (FH->handle)
+    if (FH->handle != -1)
 	close (FH->handle);
 	
     vfs_s_free_inode (me, FH->ino);



More information about the mc-devel mailing list