The HyperNews Linux KHG Discussion Pages

Question: Passing file descriptors to the kernel

Forum: The Linux Kernel Hackers' Guide
Keywords: file descriptor userfs pipe module
Date: Tue, 30 Dec 1997 18:54:12 GMT
From: Pradeep Gore <>

I am porting a filesystem(the userfs0.9.4.2) source from the linux x86 version to another for the arm processor. The userfs filesystem has a kernel module that accepts a pair of file descriptors passed to it in a user defined structure in the mount function. The kernel module receives this structure in the read_super function of the file_system_type struct.(defined in fs.h).

now the problem.. The file descriptors passed are invalid, the values are correct but when the kernel module code tries to convert the file descriptor to a file pointer,it fails.

struct file* fdtofp(int fd)
  struct file* fp;
  fp = current->files->fd[fd]; 
  if (fp->f_inode == NULL)
     return NULL; // fp->f_inode turns out to be null and the
                  // function returns here

This code works perfectly on the x86 linux but not on the arm version.The descriptors are created successfully using the pipe function.

can anyone explain what could be going wrong?How can i debug? Is there a way to convert a file descriptor to a struct file* in a user process?

thanks for any help, 
Pradeep Gore