forked from Imagelibrary/rtems
* libc/libio.h (rtems_filesystem_file_handlers_r, rtems_filesystem_operations_table): Added _h to all structure fields to indicate they are "handlers". * libc/libio_.h, libc/chdir.c, libc/chmod.c, libc/chown.c, libc/close.c, libc/eval.c, libc/fchdir.c, libc/fchmod.c, libc/fcntl.c, libc/fdatasync.c, libc/fstat.c, libc/fsync.c, libc/ftruncate.c, libc/getdents.c, libc/imfs_eval.c, libc/imfs_unlink.c, libc/ioctl.c, libc/ioman.c, libc/link.c, libc/lseek.c, libc/mknod.c, libc/mount.c, libc/open.c, libc/read.c, libc/readlink.c, libc/rmdir.c, libc/stat.c, libc/symlink.c, libc/unlink.c, libc/unmount.c, libc/utime.c, libc/write.c: Modified to reflect above name change.
70 lines
1.6 KiB
C
70 lines
1.6 KiB
C
/*
|
|
* mknod()
|
|
*
|
|
* This routine is not defined in the POSIX 1003.1b standard but is
|
|
* commonly supported on most UNIX and POSIX systems. It is the
|
|
* foundation for creating file system objects.
|
|
*
|
|
* COPYRIGHT (c) 1989-1999.
|
|
* On-Line Applications Research Corporation (OAR).
|
|
*
|
|
* The license and distribution terms for this file may be
|
|
* found in the file LICENSE in this distribution or at
|
|
* http://www.OARcorp.com/rtems/license.html.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "libio_.h"
|
|
|
|
int mknod(
|
|
const char *pathname,
|
|
mode_t mode,
|
|
dev_t dev
|
|
)
|
|
{
|
|
rtems_filesystem_location_info_t temp_loc;
|
|
int i;
|
|
const char *name_start;
|
|
int result;
|
|
|
|
if ( !(mode & (S_IFREG|S_IFCHR|S_IFBLK|S_IFIFO) ) )
|
|
set_errno_and_return_minus_one( EINVAL );
|
|
|
|
if ( S_ISFIFO(mode) )
|
|
set_errno_and_return_minus_one( ENOTSUP );
|
|
|
|
rtems_filesystem_get_start_loc( pathname, &i, &temp_loc );
|
|
|
|
if ( !temp_loc.ops->evalformake_h ) {
|
|
rtems_filesystem_freenode( &temp_loc );
|
|
set_errno_and_return_minus_one( ENOTSUP );
|
|
}
|
|
|
|
result = (*temp_loc.ops->evalformake_h)(
|
|
&pathname[i],
|
|
&temp_loc,
|
|
&name_start
|
|
);
|
|
if ( result != 0 )
|
|
return -1;
|
|
|
|
if ( !temp_loc.ops->mknod_h ) {
|
|
rtems_filesystem_freenode( &temp_loc );
|
|
set_errno_and_return_minus_one( ENOTSUP );
|
|
}
|
|
|
|
result = (*temp_loc.ops->mknod_h)( name_start, mode, dev, &temp_loc );
|
|
|
|
rtems_filesystem_freenode( &temp_loc );
|
|
|
|
return result;
|
|
}
|