Tuesday 15 May 2012

filesystems - How to change/fake the 'file size' on the fly in C code -



filesystems - How to change/fake the 'file size' on the fly in C code -

i working on user level filesystem using fuse , requirement :

when issue read file a, want superimpose contents of file (say file b) , nowadays contents of file b file a's contents. i have achieved buffer modifications capturing in fuse read , internally reading file b , copying buffer contents passed in buffer file a , not doing actual read phone call file a. so, file a phone call returns file b's contents copied in buffer. also, file a of smaller size compared file b.

when checked using debugger, file a buffer contents fine (contains whole of file b contents), when gets displayed (say vi) file a, able see many characters file a's size, file b size more, whole info never gets shown if returned buffer file a (the file b info copied) has more display. because file a size smaller , display terminates when character count reached file a's filesize.

i tried looking struct stat, read-only thing shows me size of file a smaller compared file b.

struct stat stat1; stat(filea, &stat1);

so, question how fake/change size of file a on-the-fly, able display whole info (which got superimposed because file b bigger).

you won't able because many applications request file size before reading file , read reported amount of data.

c filesystems size filesize stat

No comments:

Post a Comment