Sashidhar wrote:
I may have to change the length of the files. Is there no way, like
manipulating the inode entries to reflect any changes in the length.
Ofcourse, I realize that this is specific to the linux/unix env.
The problem is a limitation of the filing system itself. The starting
position of a file is recorded as the number of the allocation unit
(block) where the first byte of the file is stored on the disk; there
is no offset to say that a file starts part-way through that block.
If you need to change a file at its start, you therefore have to end
up with the new data also starting at a block boundary. This is
possible if the change in size is an exact multiple of the block size
for your medium, in particular if the file ends up being exactly the
same size when you can simply rewrite the first few blocks of the
file and leave the allocation information unchanged. If the file
is to be shortened by, say, exactly 4K bytes (or the medium's
block size) then one or more blocks can be dropped from
the file's allocation, but particularly for text files this happy
coincidence is very unlikely, and so the entirety of the data
must be rewritten to start on a block boundary.
HTH,
Rob