[Crash-utility] fd_init()

Dave Anderson anderson at redhat.com
Thu Dec 11 19:05:34 UTC 2008


----- "James Bradshaw" <jbradsha at enterasys.com> wrote:

> In fd_init() in filesys.c the namelist file is opened and pc->nfd is
> initialized:
> 
> 
> if ((pc->nfd = open(pc->namelist, O_RDONLY)) < 0)
>         error(FATAL, "%s: %s\n", pc->namelist, strerror(errno));
> else {
>         close(pc->nfd);
>         pc->nfd = -1;
> }
> 
> 
> In the event of a successful open the else clause is executed, and the
> file that was just opened is closed. Why?

In the case of normal crash usage, the pc->nfd is basically
a throw-away file descriptor.  It's just there to kill off the
crash session immediately if the vmlinux file cannot be opened
for whatever reason.  The crash utility itself doesn't do an
open() call on the vmlinux file, but rather it passes that
responsibility down to the embedded gdb module, which essentially
is invoked as "gdb vmlinux".

The pc->nfd descriptor used to be used by the "remote" capability
of the crash utility, where the vmcore (and perhaps the vmlinux)
files existed on a remote system.  If the vmlinux was remote, it
would be copied to a local version that was handled by that pc->nfd
during the copy operation.  But anyway, that's all deprecated
code, but I've never gotten around to ripping it all out because
it has tentacles in places other than "remote.c".  But I think that
it's most likely a (harmless) no-op at this point.

Dave

  




More information about the Crash-utility mailing list