.po 1i
.TH MKNOD 2 Bell
.V 08/15/84 17:14:18
.\" @[$]mknod.2	1.8	08/15/84 17:14:18 - Zilog Inc.
.ad
.fi
.SH NAME
mknod \- make a directory or a special file
.SH SYNOPSIS
.B int mknod
.I (file, mode, dev)
.br
.B char
.I *file;
.br
.B int
.I mode, dev;
.SH DESCRIPTION
.B Mknod
creates a new 
.IR file.
The mode of the new 
.I file
(including directory and special file bits)
is initialized from
.IR mode ,
which is constructed by summing some of the following
values.
.sp
.RS
0xf000 file type: one of the following:
.br
    0x1000 fifo special
.br
    0x2000 character special
.br
    0x4000 directory
.br
    0x6000 block special
.br
    0x8000 or 0x0000 ordinary file
.sp
0x800 set user
.SM ID
on execution
.br
0x400 set group
.SM ID
on execution
.br
0x200 save text image after execution
.br
0x1ff access permissions; see 
.BR umask (2)
.RE
.PP
Values of
.I mode
other than those above are undefined
and should not be used.
.PP
The file's owner
.SM ID
is set to the process's effective
user
.SM ID\*S.
The file's group
.SM ID
is set to the process's effective group
.SM ID\*S.
.PP
The low-order 9 bits of
.I mode
are modified by
the process's file mode creation mask:
all bits set in the process's file mode creation mask are cleared.
(See
.BR umask (2)).
If
.I mode
indicates a block or character special file,
.I dev
is a configuration dependent
specification of a character or block I/O device.
If
.I mode
does not indicate a block special or character special device,
.I dev
is ignored.
.PP
.B Mknod
may be invoked only by the super-user for file types other than
.SM FIFO
special.
.SH DIAGNOSTICS
.B Mknod
will fail and the new file will not be created
if one or more of the following are true:
.IP
The process's effective user
.SM ID
is not super-user.
.SM
\%[EPERM]
.IP
A component of the
path prefix
is not a directory.
.SM
\%[ENOTDIR]
.IP
A component of the
path prefix
does not exist.
.SM
\%[ENOENT]
.IP
The directory in which the 
.I file 
is to be created
is located on a read-only file system.
.SM
\%[EROFS]
.IP
.I file
exists.
.SM
\%[EEXIST]
.IP
.I Name
points outside the process's allocated address space.
.SM
\%[EFAULT]
.SH RETURN VALUE
Upon successful completion a value of 0 is returned.
Otherwise, a value of \-1 is returned and
.B errno
is set to indicate the error.
.PP
The first block pointer of the i-node
is initialized from
.IR dev .
.SH LIMITATIONS
For ordinary files and directories,
.I dev
is normally zero.
In the case of a special file,
.I dev
specifies which special file.
.PP
.B Mknod
can be invoked only by the super-user.
.SH SEE ALSO
mkdir(1), mknod(1M), chmod(2), exec(2),
umask(2), filsys(5), mknod(M).
.SH ASSEMBLER
.nf
.na
    CONSTANT MKNOD    := 14

    ...     !* name, mode, dev in *!
            !* r0, r1, r2 respectively *!
            !* (segmented: name, mode, dev in rr0, r2, r3) *!
    clr    r4
    sc    #MKNOD
    ...     !* return value in r4 *!
            !* carry flag set if error *!
.fi
.ad
