Getting the filename from a file discriptor

Robert Side rside at uvicctr.UUCP
Mon Aug 29 14:11:53 AEST 1988


In a previous article I asked for information about checkpointing
and the rollback of processes under UNIX (tm). The general concensus
was the saving of the data segment, stack segment, and registers was
fairly easy. I have currently written two routines for the checkpointing
and restoring a process to file and they seem to work.

***The problem is open files***.

Basic Question: Is there a way to find the filename of an open file
given just the file descriptor?

I understand there was a discussion on this subject BIGON time ago
(Before I Got On the Net). Can somebody mail me a summary. I understand
that given an inode one can find the name of the file; however,
this will not work if there is more then one file server.
So is there a simple (or complex) solution.

Detail discription: During a checkpoint, I would like to save the
open file's name, current file position, any flags, the open mode,
and anything else that is needed.  When a rollback occurs, the
files will be restored to the state during the checkpoint.  I need
the file names so that if a file has been closed I can re-open it.

The other thing is I might have to do is save the whole file to a 
temporary location if it has been opened for writing.  I also understand
that it may not be able to recover all the files and this should
cause some sort of error handling to occur.

Limitations: No kernel or system library changes. The main body
of the process does not now that a checkpoint or rollback is
occuring but the checkpoint and rollback routines are within
the process.

My Simple Minded Solution: Have an include file that redefines
all routines that can open a file or file description (ie open,
fopen, dup, fcntl, ...), save the file name and then call
the proper routine. I now this is a very poor solution because
so many things can change and it is so easy to miss a routine
that might cause a change to a file discriptor.

So what is the real solution.

Thank you very much in advanced. Please email (But I do
read these newsgroups) and I will summarize

Rob Side
-- 
Robert Side <rside at uvunix.uvic.cdn>
UUCP:	...!{ubc-vision,uw-beaver,ssc-vax}!uvicctr!rside
BITNET:	rside at uvunix.bitnet



More information about the Comp.unix.wizards mailing list