Re: Patches for mc-4.5.51



Frédéric L. W. Meunier wrote:
Anyway, if I was a programmer I'd contribute to HEAD, not fork
and have my ideas used by a few people.

Here is my favourite one, resume support for ftp (& others), I am using
it for about a year, and don't think anymore that this feature will ever
get into "official" mc :)

I appreciate the efforts regarding the code cleanups, but maybe the mc
development should be a _bit_ more liberal. It's nice that the current
mc has a much cleaner codebase, but the things which pissed me off (ftp
resume, operations which sometimes have to be cancelled by ctrl-z kill
-9 mc - mainly Viewer and Find File) three years ago are still there and
there's no sign they'll go away anytime soon.

And yes, I sent patches addressing these issues, with no reply. Maybe
they are crappy, because I don't know the mc code much, but at least
"your patch sucks because of this and that" would be appreciated.

Regards,
--
Jindrich Makovicka

Index: src/file.c
===================================================================
RCS file: /cvsroot/mc/mc/src/file.c,v
retrieving revision 1.104
diff -u -b -B -r1.104 file.c
--- src/file.c	29 Aug 2003 22:45:04 -0000	1.104
+++ src/file.c	9 Sep 2003 20:41:03 -0000
@@ -597,22 +597,20 @@
 
     gettimeofday (&tv_transfer_start, (struct timezone *) NULL);
 
-    while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0) {
+    while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR, ctx->do_reget)) < 0) {
 	return_status =
 	    file_error (_(" Cannot open source file \"%s\" \n %s "),
 			src_path);
 	if (return_status == FILE_RETRY)
 	    continue;
-	ctx->do_append = 0;
-	return return_status;
-    }
-
     if (ctx->do_reget) {
-	if (mc_lseek (src_desc, ctx->do_reget, SEEK_SET) != ctx->do_reget) {
 	    message_1s (1, _("Warning"),
 			_(" Reget failed, about to overwrite file "));
 	    ctx->do_reget = ctx->do_append = 0;
+	    continue;
 	}
+	ctx->do_append = 0;
+	return return_status;
     }
 
     while (mc_fstat (src_desc, &sb)) {
@@ -770,11 +768,11 @@
 	    file_progress_set_stalled_label (ctx, stalled_msg);
 	    return_status =
 		file_progress_show_bytes (ctx,
-					  *progress_bytes + n_read_total,
+					  *progress_bytes + n_read_total + ctx->do_reget,
 					  ctx->progress_bytes);
 	    if (return_status == FILE_CONT) {
 		return_status =
-		    file_progress_show (ctx, n_read_total, file_size);
+		    file_progress_show (ctx, n_read_total + ctx->do_reget, file_size);
 	    }
 	    mc_refresh ();
 	    if (return_status != FILE_CONT)
Index: src/fileopctx.h
===================================================================
RCS file: /cvsroot/mc/mc/src/fileopctx.h,v
retrieving revision 1.9
diff -u -b -B -r1.9 fileopctx.h
--- src/fileopctx.h	2 Jun 2003 19:26:55 -0000	1.9
+++ src/fileopctx.h	9 Sep 2003 20:41:03 -0000
@@ -47,7 +47,7 @@
 	int recursive_result;
 
 	/* Whether to do a reget */
-	int do_reget;
+	off_t do_reget;
 
 	/* Controls appending to files */
 	int do_append;
Index: vfs/direntry.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/direntry.c,v
retrieving revision 1.59
diff -u -b -B -r1.59 direntry.c
--- vfs/direntry.c	29 Aug 2003 22:48:25 -0000	1.59
+++ vfs/direntry.c	9 Sep 2003 20:41:03 -0000
@@ -735,7 +735,7 @@
 }
 
 void *
-vfs_s_open (vfs *me, char *file, int flags, int mode)
+vfs_s_open (vfs *me, char *file, int flags, int mode, off_t offset)
 {
     int was_changed = 0;
     struct vfs_s_fh *fh;
@@ -787,12 +787,12 @@
     if (IS_LINEAR(flags)) {
 	if (MEDATA->linear_start) {
 	    print_vfs_message (_("Starting linear transfer..."));
-	    if (!MEDATA->linear_start (me, fh, 0)){
+	    if (!MEDATA->linear_start (me, fh, offset)){
 		g_free(fh);
 		return NULL;
 	    }
 	}
-    } else if ((MEDATA->fh_open) && (MEDATA->fh_open (me, fh, flags, mode))){
+    } else if ((MEDATA->fh_open) && (MEDATA->fh_open (me, fh, flags, mode))) {
 	    g_free(fh);
 	    return NULL;
 	}
@@ -803,7 +803,15 @@
 	    g_free(fh);
 	    ERRNOR (errno, NULL);
 	}
+	if (IS_LINEAR(flags) && (offset > 0)) {
+	    if (lseek(fh->handle, offset, SEEK_SET) != offset) {
+		close(fh->handle);
+		g_free(fh);
+		return NULL;
+	    }
     }
+    }
+
 
      /* i.e. we had no open files and now we have one */
     vfs_rmstamp (me, (vfsid) super, 1);
Index: vfs/extfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/extfs.c,v
retrieving revision 1.71
diff -u -b -B -r1.71 extfs.c
--- vfs/extfs.c	29 Aug 2003 22:48:25 -0000	1.71
+++ vfs/extfs.c	9 Sep 2003 20:41:03 -0000
@@ -633,7 +633,7 @@
 }
 
 static void *
-extfs_open (vfs *me, char *file, int flags, int mode)
+extfs_open (vfs *me, char *file, int flags, int mode, off_t offset)
 {
     struct pseudofile *extfs_info;
     struct archive *archive;
@@ -690,6 +690,13 @@
     if (local_handle == -1)
 	ERRNOR (EIO, NULL);
 
+    if (IS_LINEAR(flags) && (offset > 0)) {
+	if (lseek(local_handle, offset, SEEK_SET) != offset) {
+	    close(local_handle);
+	    return 0;
+	}
+    }
+
     extfs_info = g_new (struct pseudofile, 1);
     extfs_info->archive = archive;
     extfs_info->entry = entry;
@@ -1251,7 +1258,7 @@
 static char *extfs_getlocalcopy (vfs *me, char *path)
 {
     struct pseudofile *fp = 
-        (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
+        (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0, 0);
     char *p;
     
     if (fp == NULL)
@@ -1269,7 +1276,7 @@
 static int extfs_ungetlocalcopy (vfs *me, char *path, char *local, int has_changed)
 {
     struct pseudofile *fp = 
-        (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
+        (struct pseudofile *) extfs_open (me, path, O_RDONLY, 0, 0);
     
     if (fp == NULL)
         return 0;
Index: vfs/local.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/local.c,v
retrieving revision 1.14
diff -u -b -B -r1.14 local.c
--- vfs/local.c	23 Sep 2002 06:45:33 -0000	1.14
+++ vfs/local.c	9 Sep 2003 20:41:03 -0000
@@ -17,7 +17,7 @@
  * */
     
 static void *
-local_open (vfs *me, char *file, int flags, int mode)
+local_open (vfs *me, char *file, int flags, int mode, off_t offset)
 {
     int *local_info;
     int fd;
@@ -25,6 +25,13 @@
     fd = open (file, NO_LINEAR(flags), mode);
     if (fd == -1)
 	return 0;
+
+    if (IS_LINEAR(flags) && (offset > 0)) {
+	if (lseek(fd, offset, SEEK_SET) != offset) {
+	    close(fd);
+	    return 0;
+	}
+    }
 
     local_info = g_new (int, 1);
     *local_info = fd;
Index: vfs/mcfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/mcfs.c,v
retrieving revision 1.43
diff -u -b -B -r1.43 mcfs.c
--- vfs/mcfs.c	29 Aug 2003 22:48:25 -0000	1.43
+++ vfs/mcfs.c	9 Sep 2003 20:41:03 -0000
@@ -511,7 +511,7 @@
 
 /* The callbacks */
 static void *
-mcfs_open (vfs *me, char *file, int flags, int mode)
+mcfs_open (vfs *me, char *file, int flags, int mode, off_t offset)
 {
     char *remote_file;
     mcfs_connection *mc;
@@ -535,6 +535,13 @@
     remote_handle = g_new (mcfs_handle, 2);
     remote_handle->handle = result;
     remote_handle->conn = mc;
+
+    if (IS_LINEAR(flags) && (offset > 0)) {
+	if (mcfs_lseek(remote_handle, offset, SEEK_SET) != offset) {
+	    mcfs_close(remote_handle);
+	    return 0;
+	}
+    }
 
     return remote_handle;
 }
Index: vfs/sfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/sfs.c,v
retrieving revision 1.42
diff -u -b -B -r1.42 sfs.c
--- vfs/sfs.c	22 Jun 2003 09:18:12 -0000	1.42
+++ vfs/sfs.c	9 Sep 2003 20:41:03 -0000
@@ -148,7 +148,7 @@
 }
 
 static void *
-sfs_open (vfs *me, char *path, int flags, int mode)
+sfs_open (vfs *me, char *path, int flags, int mode, off_t offset)
 {
     int *sfs_info;
     int fd;
@@ -157,6 +157,13 @@
     fd = open (path, NO_LINEAR(flags), mode);
     if (fd == -1)
 	return 0;
+
+    if (IS_LINEAR(flags) && (offset > 0)) {
+	if (lseek(fd, offset, SEEK_SET) != offset) {
+	    close(fd);
+	    return 0;
+	}
+    }
 
     sfs_info = g_new (int, 1);
     *sfs_info = fd;
Index: vfs/smbfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/smbfs.c,v
retrieving revision 1.57
diff -u -b -B -r1.57 smbfs.c
--- vfs/smbfs.c	3 Apr 2003 10:45:03 -0000	1.57
+++ vfs/smbfs.c	9 Sep 2003 20:41:03 -0000
@@ -1782,7 +1782,7 @@
 }
 
 static void *
-smbfs_open (vfs *me, char *file, int flags, int mode)
+smbfs_open (vfs *me, char *file, int flags, int mode, off_t offset)
 {
     char *remote_file, *p;
     void *ret;
@@ -1805,8 +1805,16 @@
     ret = open_readwrite (remote_handle, remote_file, flags, mode);
 
     g_free (remote_file);
-    if (!ret)
+    if (!ret) {
 	g_free (remote_handle);
+    } else {
+	if (IS_LINEAR(flags) && (offset > 0)) {
+	    if (smbfs_lseek(remote_handle, offset, SEEK_SET) != offset) {
+		smbfs_close(remote_handle);
+		return 0;
+	    }
+	}
+    }
 
     return ret;
 }
Index: vfs/undelfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/undelfs.c,v
retrieving revision 1.23
diff -u -b -B -r1.23 undelfs.c
--- vfs/undelfs.c	8 Dec 2002 01:12:31 -0000	1.23
+++ vfs/undelfs.c	9 Sep 2003 20:41:03 -0000
@@ -368,12 +368,16 @@
 
 /* We do not support lseek */
 static void *
-undelfs_open (vfs *me, char *fname, int flags, int mode)
+undelfs_open (vfs *me, char *fname, int flags, int mode, off_t offset)
 {
     char *file, *f;
     ext2_ino_t  inode, i;
     undelfs_file *p = NULL;
     
+    if (offset > 0) {
+	return 0;
+    }
+
     /* Only allow reads on this file system */
     undelfs_get_path (fname, &file, &f);
     if (!file)
Index: vfs/vfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/vfs.c,v
retrieving revision 1.110
diff -u -b -B -r1.110 vfs.c
--- vfs/vfs.c	6 Jun 2003 00:50:22 -0000	1.110
+++ vfs/vfs.c	9 Sep 2003 20:41:03 -0000
@@ -386,6 +386,7 @@
 {
     int  handle;
     int  mode;
+    off_t offset = 0;
     void *info;
     va_list ap;
 
@@ -394,7 +395,12 @@
 
     /* Get the mode flag */	/* FIXME: should look if O_CREAT is present */
     va_start (ap, flags);
+    if (flags & O_CREAT) {
     mode = va_arg (ap, int);
+    }
+    if (flags & O_LINEAR) {
+	offset = va_arg (ap, off_t);
+    }
     va_end (ap);
     
     if (!vfs->open) {
@@ -402,7 +408,7 @@
 	return -1;
     }
 
-    info = (*vfs->open) (vfs, file, flags, mode);	/* open must be supported */
+    info = (*vfs->open) (vfs, file, flags, mode, offset);	/* open must be supported */
     g_free (file);
     if (!info){
 	errno = ferrno (vfs);
Index: vfs/vfs.h
===================================================================
RCS file: /cvsroot/mc/mc/vfs/vfs.h,v
retrieving revision 1.75
diff -u -b -B -r1.75 vfs.h
--- vfs/vfs.h	23 Jul 2003 03:22:33 -0000	1.75
+++ vfs/vfs.h	9 Sep 2003 20:41:03 -0000
@@ -43,7 +43,7 @@
 			       
         int   (*which)         (vfs *me, char *path);
 			       
-	void  *(*open) 	       (vfs *me, char *fname, int flags, int mode);
+	void  *(*open) 	       (vfs *me, char *fname, int flags, int mode, off_t offset);
 	int   (*close) 	       (void *vfs_info);
 	int   (*read)  	       (void *vfs_info, char *buffer, int count);
 	int   (*write) 	       (void *vfs_info, char *buf, int count);
Index: vfs/xdirentry.h
===================================================================
RCS file: /cvsroot/mc/mc/vfs/xdirentry.h,v
retrieving revision 1.25
diff -u -b -B -r1.25 xdirentry.h
--- vfs/xdirentry.h	29 Aug 2003 22:32:22 -0000	1.25
+++ vfs/xdirentry.h	9 Sep 2003 20:41:03 -0000
@@ -224,7 +224,7 @@
 int vfs_s_lstat (vfs *me, char *path, struct stat *buf);
 int vfs_s_fstat (void *fh, struct stat *buf);
 int vfs_s_readlink (vfs *me, char *path, char *buf, int size);
-void *vfs_s_open (vfs *me, char *file, int flags, int mode);
+void *vfs_s_open (vfs *me, char *file, int flags, int mode, off_t offset);
 int vfs_s_read (void *fh, char *buffer, int count);
 int vfs_s_write (void *fh, char *buffer, int count);
 int vfs_s_lseek (void *fh, off_t offset, int whence);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]