Linking two files together

Kevin J. Cummings cummings at kjchome.homeip.net
Wed May 26 17:21:35 UTC 2010


On 05/26/2010 01:16 PM, Rector, David wrote:
> Hello,
> 
> I have studied various filesystems, and am fairly familiar with how they are structured. However, I am currently stuck on trying to do what seems like a simple thing.
> 
> I would like to join two files together without having to physically copy bytes (i.e. I have vary large files, so I don't want to use 'cat'). It seems to me that it should be possible to simply modify the file entry in the filesystem such that the last inode of the first file points to the first inode of the second file. I guess this is similar to a "hard link", but used to join files rather than simply have another pointer to one file.
> 
> I have seen 'mmv' and 'lxsplit' and they all seem to do the same thing, namely they want to physically copy the bytes in order to join two files together.
> 
> Is there any such utility in linux to perform such a hard link to join or connect two files together without having to copy bytes?

If you could guarantee that the last extent used by the first file was
completely full of data with no extraneous bytes, it might be possible
to "merge" the extent maps of the 2 files into a single file entry.  If
you cannot guarantee that, then you will have to copy bytes from the 2nd
file to the end of the first file.

You have to understand how filesystems work in general, and how the
specific filesystem that contains your files work.

> Thanks for your help.
> 
> Dave Rector
> *:^)


-- 
Kevin J. Cummings
kjchome at rcn.com
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)


More information about the users mailing list