Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

14.10 Making Special Files

The mknod function is the primitive for making special files, such as files that correspond to devices. The GNU library includes this function for compatibility with BSD.

The prototype for mknod is declared in sys/stat.h.

— Function: int mknod (const char *filename, int mode, int dev)

The mknod function makes a special file with name filename. The mode specifies the mode of the file, and may include the various special file bits, such as S_IFCHR (for a character special file) or S_IFBLK (for a block special file). See Testing File Type.

The dev argument specifies which device the special file refers to. Its exact interpretation depends on the kind of special file being created.

The return value is 0 on success and -1 on error. In addition to the usual file name errors (see File Name Errors), the following errno error conditions are defined for this function:

EPERM
The calling process is not privileged. Only the superuser can create special files.
ENOSPC
The directory or file system that would contain the new file is full and cannot be extended.
EROFS
The directory containing the new file can't be modified because it's on a read-only file system.
EEXIST
There is already a file named filename. If you want to replace this file, you must remove the old file explicitly first.


 
 
  Published under the terms of the GNU General Public License Design by Interspire