Now, this question may seem weird, and it probably is, but to give some context, I've been reading this to learn about i-nodes in which the author gives an interesting example:
{
FILE *fp;
fp = fopen("some.hidden.file","w");
unlink("some.hidden.file"); /* deletes the filename part */
/* some.hidden.file no longer has a filename and is truly hidden */
fprintf(fp,"This data won't be found\n"); /* access the data part */
/*etc*/
fclose(fp); /* finally release the data part */
}
This allows to create a "hidden" temporary file.
My question here being: is there any way to recreate a filename that points to the inode held opened by fp
after the call to unlink()
?
Disclaimer: I do not intend to do this in real code; I'm merely (re)learning about i-nodes and wonder if this is possible.
I'm afraid it is not possible because the link
system call demands a valid file name (which means, an existing link) rather than an UNIX file descriptor. There is no flink
function in the Single UNIX Specification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With