Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mknod.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mknod.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mknod.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mknod.html on line 8
Make a new filesystem entry point
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
int mknod( const char * path,
mode_t mode,
dev_t dev );
- path
- The pathname that you want to use for the file.
- mode
- A set of bits that define the file type and access permissions that you
want to use.
The valid file types are:
- S_IFDIR — create a directory.
- S_IFIFO — create a FIFO.
For more information, see
“Access permissions”
in the documentation for stat().
- dev
- Ignored.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The mknod() makes a file, named path,
using the file type encoded in the mode argument.
Supported file types are directories and FIFOs.
|
This function is included to enhance portability with software written for Unix-compatible operating systems.
For POSIX portability, use
mkdir()
or
mkfifo()
instead. |
To make a directory with read-write-execute permissions for everyone,
you could use the following:
mknod (name, S_IFDIR | 0777, 0);
- 0
- Success.
- -1
- An error occurred (errno is set).
- EACCES
- A component of the path prefix denies search permission,
or write permission is denied for the parent directory.
- EEXIST
- The named file already exists.
- ELOOP
- Too many levels of symbolic links or prefixes.
- EMLINK
- The link count of the parent directory would exceed LINK_MAX.
- ENAMETOOLONG
- The length of the path string exceeds
PATH_MAX, or a pathname component is longer than NAME_MAX.
- ENOENT
- A component of the path prefix doesn't exist,
or the path arguments points to an empty string.
- ENOSPC
- The directory that would contain the new file cannot be extended or
the filesystem is out of file allocation resources
(that is, the disk is full).
- ENOSYS
- The mknod() function isn't implemented for the filesystem specified in path.
- ENOTDIR
- A component of the path prefix isn't a directory.
- EROFS
- The named file resides on a read-only filesystem.
/*
* Create special files as a directory or FIFO
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
int main( int argc, char** argv )
{
int c;
mode_t mode = 0666;
int ecode = 0;
if( argc == 1 ) {
printf( "Use: %s [-d directory] ... [-f fifo] ... \n",
argv[0] );
return( 0 );
}
while(( c = getopt( argc, argv, "d:f:" )) != -1 ) {
switch( c ) {
case 'd': mode = S_IFDIR | 0666; break;
case 'f': mode = S_IFIFO | 0666; break;
}
if( mknod( optarg, mode, 0 ) != 0 ) {
perror( optarg );
++ecode;
}
}
return( ecode );
}
POSIX 1003.1 XSI
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
errno,
mkdir(),
mkfifo()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mknod.html on line 273
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mknod.html on line 273