Content-type: text/html Man page of fd

fd

Section: Devices and Network Interfaces (4)
Index Return to Main Contents
 

NAME

fd - file descriptor files  

DESCRIPTION

The /dev/fd file system is a pseudo-file system layered beneath the Virtual File System (VFS). The file descriptor files (fd*) are those files that are accessible through file descriptors. The file descriptors use the naming convention /dev/fd/0, /dev/fd/1, /dev/fd/2 and so on up to any number.

To make the /dev/fd file system known to the operating system, you must create the directory with the correct privileges, then you must mount the file system. The following steps describe how to create the directory, mount the file system both manually and automatically, and how to dismount the file system: Create the directory using the mkdir and chmod commands: mkdir /dev/fd; chmod 777 /dev/fd Mount the file system manually using the mount command: mount -t fdfs /dev/fd /dev/fd Mount the file system automatically by editing either the /etc/fstab file or the /sbin/bcheckrc file.

Add the following entry to the /etc/fstab file: /dev/fd /dev/fd fdfs rw 0 0 This entry mounts the pseudodevice /dev/fd on the /dev/fd directory with read/write privileges. The file system type is fdfs and the zeros (0) in the remaining fields specify that the file system is not to be backed up nor can file system checks be performed by the fsck command as this is a virtual file system.
Add the following entry to the /sbin/bcheckrc file: # # mount fdfs # echo 'Mounting /dev/fd filesystem' /sbin/mount -a -v -t fdfs Again, the /dev/fd file system should not be mounted in this manner if an entire system is to be backed up starting from the root directory. Dismount the file system using the umount command: umount /dev/fd For correct truncate() behavior on fd files, you must load your program using the -lsys5 flag.
 

RESTRICTIONS

The /dev/fd file descriptors should not be exported.  

EXAMPLES

The following example show how the open and dup functions have the same effect if file descriptor n is opened:

fd = open("/dev/fd/n", mode);
fd = dup(n);

In the above example, the open function is equal to the creat function and mode is ignored. Using the dup function, subsequent reads or writes on the fd file descriptor files fail unless the original file descriptor enables the operation.  

ERRORS

The following error condition exists: The file descriptor is not valid.  

RELATED INFORMATION

Commands: chmod(1), mkdir(1), mount(8).

Functions: creat(2), dup(2), open(2). delim off


 

Index

NAME
DESCRIPTION
RESTRICTIONS
EXAMPLES
ERRORS
RELATED INFORMATION

This document was created by man2html, using the manual pages.
Time: 02:40:07 GMT, October 02, 2010