0

I asked a more general question in my previous post, but I'm re-posting to make the question more specific.

Does anybody know another way to redirect hard-drive I/O? I need to be able to direct a read/write operation on disk to another path without disrupting the system calls.

There HAS to be another way.

I think one way to do it is to copy/move the targeted file to another path AFTER the write. However, I still need to redirect read access to that file. Is there any way to perhaps mount a file over another file, so the physical head of the hard-drive accesses the moved/copied file instead?

Thanks for any feedback.

3
  • Ok, so I just read about hardlinks. This might be a way to go...but will it speed up read access? In other words, does the disk head have to position itself over the hardlink and then reposition over the actual file before actually reading the file data? Are Linux hardlinks stored in a filesystem data structure (in RAM with O(1) access time, like an array) with an address of the actual file so that the disk head can directly access the addressed file? Commented Sep 12, 2011 at 2:55
  • I found out five hours ago that I can't create hardlinks across partitions. There may be a work-around using UnionFS to create the hardlinks or something similar. Does anybody know about this? Commented Sep 12, 2011 at 9:31
  • I set up this new thread. It's about unionfs. I need some help to modify some of its code. If anybody can offer advice, I'd appreciate it. Commented Sep 19, 2011 at 3:12

1 Answer 1

2

The simplest way to do what you want is probably to implement a filesystem that overlays another filesystem.

Your filesystem will be the first port of call for all read and write calls for files within it, and it can redirect them as it sees fit. This would work in a similar way to overlay / union filesystems (although it should be simpler, because you don't need to try to deal with more than one underlying filesystem).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the input. Actually, I figured out that I could use wrapfs to do exactly what you said. However, I was thinking that maybe union filesystems are a better way to do it. I could just create a hard link from one partition to the target file in the other partition, and that would handle in the "redirecting" for me. Would you know if there is a union file system that can do this? Thanks again! :)
@rb3: I don't think that will work - processes that opened the file before and after your hardlink was created would have different files open, which breaks the semantics expected of a filesystem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.