On 10/3/05, Gus Wirth <[EMAIL PROTECTED]> wrote:
> At 23:37 09/30/2005 -0700, Carl Lowenstein wrote:
> >I never heard of CPM image format, neither has Google.  But I have
> >learned tonight that the ACARD controller in our CD/DVD duplicator
> >will export files from the duplicator's internal hard drive to a drive
> >on the host computer, using its USB connection.  By actual trial, I
> >have found that this exported file is the same as the original .ISO
> >file but has 2456 bytes prepended to it.  The file name defaults to
> >*.CPM.  The text at the beginning of this is "CPM Image V1."
> >
> >Oh, well, I can strip it off using dd(1) as we all have discussed at
> >great length.
>
> I wonder if there is a way to resize the file "in situ" , i.e. trim the
> head without having to make a duplicate.
>
> I had originally asked this question of carl at the installfest pertaining
> to trimming the tail of a file, but he couldn't think of a utility that did
> that. I know I could do something to reset the size and then release the
> tail blocks to the free pool, but I'm willing to bet someone has already
> done that.
>
> Anyone know of any utilities to trim files in place?
>
Search Google groups "comp.*" with key words "truncate" "file" "in place".

One learns that there is a system call "ftruncate"  (man 2 ftruncate)
that can trim the tail end of a file.  After much discussion, the
conclusion is that it isn't easy, and is not portable across different
flavors of Unix.  Nobody seems to have actually done it in a
releasable-to-others form.  And trimming the head end of a file is
more difficult than trimming the tail end, because you need to pack
everything forward to fill the "hole" at the beginning.

Unless you are trimming multi-gigabyte files on a regular basis, it is
probably best to swallow the overhead of reading and re-writing the
file, and just use dd(1).  Besides, then you aren't as vulnerable to
power failures in the middle of a long operation.

    carl
--
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to