-1

I am working on user level filesystem using FUSE and my requirement is that :

  • When I issue read for File A, I want to superimpose the contents of another file (say File B) and present the contents of File B as File A's contents.
  • I have already achieved it by buffer modifications by capturing it in my fuse read and internally reading File B and copying the buffer contents to the passed in buffer for File A and not doing any actual read call for File A. So, File A call returns with File B's contents copied in its buffer.
  • Also, File A is of smaller size compared to File B.

When checked using debugger, File A buffer contents look fine (contains whole of File B contents), but when it gets displayed (say with Vi) for File A, I am able to see only those many characters as the File A's size, but as File B size is more, the whole data never gets shown even if the returned buffer to File A (the File B data copied) has more to display. This is because File A size is smaller and the display terminates when character count is reached for File A's filesize.

I tried looking into struct stat, but it is a read-only thing which shows me the size of File A which is smaller compared to File B.

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

So, my question is that how do I fake/change the size of File A on-the-fly, so that it is able to display whole the data (which got superimposed because File B was bigger).

n0p
  • 3,399
  • 2
  • 29
  • 50
Rohan
  • 47
  • 3
  • 9

1 Answers1

0

You won't be able to do this because many applications request file size before reading the file and then read only the reported amount of data.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121