Tuesday, May 10, 2011

Diff and Patch a file in Linux

Yesterday i ran into an Problem, i needed to Burn an DVD+R DL and the file i needed to burn was at 300Mbytes and an DVD+R DL got a capacity of 8,4 Gbytes. So i used the standard GROWISOFS command to start a normal Burn i selected the file and i told me the following weird message:


growisofs: :( more than 50% of space will be *wasted*!
                      go use single layer disc for this!


My mind was, what the hack ?! Linux is Open Source but i never thought it is  ecofriendly, so tried a few commands but no way, it wont let me burn a DVD when about 50% of space will be wasted ...


 A search later i found an PATCH to apply to get rid of this problem. As follows this is the patch file needed to apply on the original growisofs_mmc.cpp before compiling the whole program.

T

--- growisofs_mmc.cpp.orig      Mon Dec 28 02:58:51 2009
+++ growisofs_mmc.cpp   Mon Dec 28 03:00:12 2009
@@ -1622,11 +1622,6 @@ static void plus_r_dl_split (Scsi_Command &cmd,off64_t
     blocks = size/2048;
     blocks += 15, blocks &= ~15;

-    if (blocks <= split)
-       fprintf (stderr,":-( more than 50%% of space will be *wasted*!\n"
-                       "    use single layer media for this recording\n"),
-       exit (FATAL_START(EMEDIUMTYPE));
-
     blocks /= 16;
     blocks += 1;
     blocks /= 2;
@@ -2059,10 +2054,6 @@ pwrite64_t poor_mans_setup (void *fd,off64_t leadout)
                layer_size |= dvd_10[4+14]<<8,
                layer_size |= dvd_10[4+15];

-               if (data_size <= layer_size)
-                   fprintf (stderr,":-( more than 50%% of space will be *wasted*!\n"
-                                   "    use single layer media for this recording\n"),
-                   exit(FATAL_START(EMEDIUMTYPE));
            }
            if (is_dao && leadout)
                minus_r_reserve_track(cmd,leadout);


So to apply this simple patch file to our  growisofs_mmc.cpp we need to use the Program "patch" or "diff"
first i will guide you trough this patch file.

First Part:
--- growisofs_mmc.cpp.orig      Mon Dec 28 02:58:51 2009
+++ growisofs_mmc.cpp   Mon Dec 28 03:00:12 2009 

@@ -1622,11 +1622,6 @@ static void plus_r_dl_split (Scsi_Command &cmd,off64_t 

is the Description and some Info for the file itself, called lines of context...

Part Two:
the lines with an - in front of them are going to be deleted, the others are going to be changed.


So long we apply this patch with ->
patch growisofs_mmc.cpp < patch.txt
 
And voila this sould be the mesasge you'll get:
 
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- growisofs_mmc.cpp Sun Feb 26 19:35:43 2006
|+++ growisofs_mmc.cpp Sun Feb 26 19:35:14 2006
--------------------------
Patching file patchtest using Plan A...
Hunk #1 succeeded at 2.
done 

The Google Patch :)


 No im able to waste Disks on my linux machine :D

13 comments:

  1. i did a little bit of linux back in the days.. but it was 2 hard for me :<

    ReplyDelete
  2. I'm so lost right now. I'm assuming that eventually I'll get the hang of this. Cool layout btw.

    Cheers

    ReplyDelete
  3. @Gaston thanks for that :) its not perfect already but it becomes

    ReplyDelete
  4. save the whales and the 8gb dvd's !!!

    ReplyDelete
  5. Been a lonnng time since I've been able to mess around with this.

    ReplyDelete
  6. Awesome post man! keep up the good work!

    ReplyDelete
  7. i prefer windows, anyways..thanks for the post

    ReplyDelete
  8. You're so smart haha. I got Windows and yet to have a problem like that.

    ReplyDelete
  9. Meh, too dumb for linux. Anyway keep it up man,

    ReplyDelete
  10. Yeah, no me understand linux.

    ReplyDelete
  11. Crazy to think it will stop you from wasting dvd's. Would think they would want you to use them up and have to buy more

    ReplyDelete
  12. I just realized I had read this already and went through it and again felt stupid :(

    lol

    dammit

    ReplyDelete