libc get filename from fd FILE*

Getting the File Name from a File Descriptor (fd) or a File Pointer (FILE *)

Submitted by Eus
on September 2, 2009 - 9:51pm

While developing the logger for GNU/Linux Anywhere USB Controller (https://savannah.nongnu.org/projects/awusb/), I created the following function that will store a `FILE *' into a global table for a later retrieval:

static int
save_open_file (FILE *log_file);

I thought I could take the name of the file through `FILE *' or its fd (file descriptor) using a libc (C library) function like `fstat'. But, I was badly mistaken.