Dear Barak,

Please find the split patches attached (hopefully there are no syntax errors 
inside)

BTW, it seem the hunk concerning "tmp" variable (char tmp[50];) is not 
necessary. I believe I changed it sometime for some debugging.

Best regards

Le jeudi 25 janvier 2018, 17:28:19 CET Barak A. Pearlmutter a écrit :
> Thanks for the vobcopy patch.
> 
> I'm happy to merge it, but if you could break it into those four
> separate hunks I'd appreciate it. If that's a hassle I can do it
> myself, but I'm worried I might get the boundaries wrong.
> 
> Cheers,
> 
> --Barak.

Description: <short summary of the patch>
 * Add support for DVD directories mounted from ISO image with fuseiso
 
Index: vobcopy-1.2.0/dvd.c
===================================================================
--- vobcopy-1.2.0.orig/dvd.c
+++ vobcopy-1.2.0/dvd.c
@@ -109,6 +109,7 @@ int get_device( char *path, char *device
 
 #if ( !defined( __sun ) )
   FILE	*tmp_streamin;
+  FILE	*tmp_streamin_fuseiso;
   char	tmp_bufferin[ MAX_STRING ];
   char  tmp_path[ 256 ];
   int   l = 0;
@@ -117,6 +118,8 @@ int get_device( char *path, char *device
 
 #if (defined(__linux__))
   struct mntent* lmount_entry;
+  struct mntent* lmount_entry_fuseiso;
+
 #endif
 
 #if ( defined( __sun ) )
@@ -257,6 +260,30 @@ this is the code for the other-OSs, not
 	    }
 	}
 	endmntent(tmp_streamin);
+        
+        if (strcmp(lmount_entry->mnt_fsname, "fuseiso") == 0) {
+          fprintf ( stderr, "[Info] Fuseiso detected. I'm looking for the iso file\n");
+          // The directory is mounted by fuseiso. Here we try get the name & path of the ISO
+          char *homedir;
+          if ((homedir = getenv("HOME")) == NULL) {
+              // TODO
+              //homedir = getpwuid(getuid())->pw_dir;
+          }
+          
+          if ((tmp_streamin_fuseiso = setmntent(strcat(homedir,"/.mtab.fuseiso"), "r"))){
+            while ((lmount_entry_fuseiso = getmntent(tmp_streamin_fuseiso))){
+              if (strcmp(lmount_entry_fuseiso->mnt_dir, path) == 0){
+                /* Found the mount point */
+                fprintf ( stderr, "[Info] Device %s mounted on %s\n", lmount_entry_fuseiso->mnt_fsname, lmount_entry_fuseiso->mnt_dir);
+                strcpy(device, lmount_entry_fuseiso->mnt_fsname);
+                mounted = TRUE;
+                break; 
+              }
+            }
+            endmntent(tmp_streamin_fuseiso);
+          }
+        }
+
 	if (mounted) 
             {
 		/* device was set from /etc/mtab, no need to further check
Description: <short summary of the patch>
 * Fix issue when filesname on DVD are suffixed by ;? or similar 
 
Index: vobcopy-1.2.0/vobcopy.c
===================================================================
--- vobcopy-1.2.0.orig/vobcopy.c
+++ vobcopy-1.2.0/vobcopy.c
@@ -1026,10 +1026,16 @@ next: /*for the goto - ugly, I know... *
                 }
               else
                 {
-                  if( strstr( d_name, ";?" ) )
-                    {
-                      fprintf( stderr, _("\n[Hint] File on dvd ends in \";?\" (%s)\n"), d_name );
-                      strncat( output_file, d_name, strlen( d_name ) - 2 );
+                  if( strstr( d_name, ";" ) )
+                  {
+                      char * pch;
+                      int position_from_end;
+                      pch = strrchr(d_name, ';');
+                      position_from_end = strlen( d_name ) - (pch - d_name);
+                      if ( position_from_end < 4 ) {
+                        fprintf( stderr, _("\n[Hint] File on dvd ends in \";?\" (%s)\n"), d_name );
+                        strncat( output_file, d_name, strlen( d_name ) - position_from_end );
+                      }
                     }
                   else
                     {
@@ -1274,8 +1280,15 @@ next: /*for the goto - ugly, I know... *
 
                       for( a = 1; a < subvob; a++ )
                         {
-                          if( strstr( input_file, ";?" ) )
-                            input_file[ strlen( input_file ) - 7 ] = ( a + 48 );
+                          if( strstr( input_file, ";" ) )
+                            {
+                              char * pch;
+                              int position_from_end;
+                              pch = strrchr( input_file, ';' );
+                              position_from_end = strlen( input_file ) - ( pch - input_file );
+                              if ( position_from_end < 4 )
+                                input_file[ strlen( input_file ) - 5 - position_from_end ] = ( a + 48 );
+                            } 
                           else
                             input_file[ strlen( input_file ) - 5 ] = ( a + 48 );
 
Description: <short summary of the patch>
 * Support the -b and -e parameters also when using -O parameter

Index: vobcopy-1.2.0/vobcopy.c
===================================================================
--- vobcopy-1.2.0.orig/vobcopy.c
+++ vobcopy-1.2.0/vobcopy.c
@@ -1307,13 +1320,13 @@ next: /*for the goto - ugly, I know... *
                     fprintf( stderr, _("[Info] Start of %s at %d blocks \n"), output_file, start );
                   file_block_count = block_count;
 		  starttime = time(NULL);
-                  for( i = start; ( i - start ) * DVD_VIDEO_LB_LEN < file_size; i += file_block_count)
+                  for( i = start + seek_start*2048/DVD_VIDEO_LB_LEN; ( i - start ) * DVD_VIDEO_LB_LEN < file_size - stop_before_end*2048 ; i += file_block_count)
                     {
 		      int tries = 0, skipped_blocks = 0; 
                       /* Only read and write as many blocks as there are left in the file */
-                      if ( ( i - start + file_block_count ) * DVD_VIDEO_LB_LEN > file_size )
+                      if ( ( i - start + file_block_count ) * DVD_VIDEO_LB_LEN > file_size - stop_before_end*2048 )
                         {
-                          file_block_count = ( file_size / DVD_VIDEO_LB_LEN ) - ( i - start );
+                          file_block_count = ( (file_size - stop_before_end*2048 )/ DVD_VIDEO_LB_LEN ) - ( i - start );
                         }
 
                       /*		      DVDReadBlocks( dvd_file, i, 1, bufferin );this has to be wrong with the 1 there...*/
Description: <short summary of the patch>
 * Fix regression on seek_start
 
Index: vobcopy-1.2.0/vobcopy.c
===================================================================
--- vobcopy-1.2.0.orig/vobcopy.c
+++ vobcopy-1.2.0/vobcopy.c
@@ -237,7 +237,7 @@ and potentially fatal."  - Thanks Leigh!
               break;
             }
           /* 	  sscanf( optarg, "%lli", &temp_var ); */
-          seek_start = temp_var;
+          seek_start = temp_var / 2048;
           cut_flag = TRUE;
           break;
 

Reply via email to