/* This function will return a file descriptor structure according to file descriptor. */
struct dfs_file* fdt_get_file(struct dfs_fdtable *fdt, int fd)
/* This function will return a file descriptor structure according to file descriptor. */
struct dfs_file* fdt_get_file(struct dfs_fdtable *fdt, int fd)
{
    struct dfs_file *f;
    if (fd < 0 || fd >= (int)fdt->maxfd)
    {
        return NULL;
    }
    f = fdt->fds[fd];
    if ((f == NULL) || (f->magic != DFS_FD_MAGIC))
    {
        return NULL;
    }
    return f;
}