Rick Lake wrote:
Thank you for this suggestion. Is this in theory or have you or someone
else actually done this?
No, this is real (from a local disk-caching server I wrote called
“shadow”). Of course that was 4-5 years ago and I am fuzzy on details.
If did work though (would copy remote files to your local disk as you
accessed them - if not already cached - and then redirect to that
local/faster copy, let writes go through to the original and invalidate
local copy, and periodically re-check the local copies for being stale).
Also, am I correct in assuming that by attaching to “/” you will get
_IO_OPEN messages to ALL resource managers? (I.e. also those directed to
Socket for NFS mounted directories, Dev for “/dev/*” devices, etc, and
also the pseudo paths created using the “prefix” util.)
QNX4 does longest-prefix matching, so attached paths like “/dev” (or
anything output by “prefix”) will go direct to that server, not you.
QNX4 only allows a single server to attach to a unique pathname, so you
will have to do something; either put your disk at “/hd” and attach
yourself to “/”, or (my preference, but trickier) leave your disk at “/”
and attach to a subset of that which you will be mirroring ("/mirror").
This depends if you need notification of the entire disk, or if your
application is structured so that you are interested only in a subset
(or can be so arranged that you will work on only such a subset).
And also (please forgive me if this is an RTFM), can you give me a hint
as to what the “EMORE/symlink” trick is?
Something like this:
uselen = strlen(usepath),
pathlen = strlen(msg.hdr.open.path) + 1;
msg.hdr.open.type = EMORE;
msg.hdr.open.version_cycle = 0x80, msg.hdr.open.eflag = 0;
memmove(&msg.hdr.open.path[uselen + 1], &msg.hdr.open.path[0], pathlen);
memcpy(&msg.hdr.open.path[0], usepath, uselen);
msg.hdr.open.path[uselen] = (pathlen > 1) ? ‘/’ : ‘\0’;
bytes = &msg.hdr.open,
nbytes = sizeof(msg.hdr.open) + uselen + 1 + pathlen;
Basically you would construct a new pathname, made up of where you put
your hard disk mount (“usepath” in above example), plus the incoming
pathname, and EMORE says to the pathname resolver that it was a symlink
and you have supplied the new path (of course it possibly wasn’t a
symlink, but you have given a new path off to the real disk file; the
_IO_OPEN message will now get re-sent to that server (Fsys)).