Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I read this post.

Are file descriptors the same as file handle?

While trying to configure the linux kernel, it asks open by fhandle syscalls (FHANDLE) [Y/n/?].

Why is this option provided? Does it affect performance of kernel or compiling time or just to have a uniform method of accessing files?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

A FILE structure in C is typically called the file handle and is a bit of abstraction around a file descriptor:

The data type FILE is a structure that contains information about a file or specified data stream. It includes such information as a file descriptor, current position, status flags, and more. It is most often used as a pointer to a file type, as file I/O functions predominantly take pointers as parameters, not the structures themselves.


I don't have a kernel build environment at hand but there should be a help text that explains the option and according to quick search should say something like:

CONFIG_FHANDLE - open by fhandle syscalls -
If you say Y here, a user level program will be able to map file names to handle and then later use the handle for different file system operations. This is useful in implementing userspace file servers, which now track files using handles instead of names. The handle would remain the same even if file names get renamed. Enables open_by_handle_at(2) and name_to_handle_at(2) syscalls.

Basically it adds support for new/additional system calls.

share|improve this answer

You might see some information from here.

Generally, a file descriptor is an index for an entry in a kernel-resident data structure containing the details of all open files. In POSIX, this data structure is called a file descriptor table, and each process has its own file descriptor table. The user application passes the abstract key to the kernel through a system call, and the kernel will access the file on behalf of the application, based on the key. The application itself cannot read or write the file descriptor table directly.

In Unix-like systems, file descriptors can refer to files, directories, block or character devices (also called "special files"), sockets, FIFOs (also called named pipes), or unnamed pipes.

The FILE * file handle in the C standard I/O library routines is technically a pointer to a data structure managed by those library routines; one of those structures usually includes an actual low level file descriptor for the object in question on Unix-like systems. Since file handle refers to this additional layer, it is not interchangeable with file descriptor.

Some more good read can be found from here and here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.