How to assign needed file descriptor to a file
Let's imagine we have opened a file and want it to have some exact descriptor number, not the one kernel gave to us.
The information we have is
struct fd {
struct file *file;
int tgt_fd;
} *fd;
and we've just done the
int fd; fd = open_a_file(fd->file);
what's next?