HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

posix_mknod

Description

The posix_mknod of POSIX for PHP creates a special or ordinary file (POSIX.1).

Syntax

posix_mknod(
    string $filename,
    int $flags,
    int $major = 0,
    int $minor = 0
): bool

Parameters

filename

The file to create

flags

This parameter is constructed by a bitwise OR between file type (one of the following constants) and permissions.

ConstantDescription
POSIX_S_IFREGNormal file
POSIX_S_IFCHRCharacter special file
POSIX_S_IFBLKBlock special file
POSIX_S_IFIFOFIFO (named pipe) special file
POSIX_S_IFSOCKSocket

major

The major device kernel identifier (required to pass when using S_IFCHR or S_IFBLK).

minor

The minor device kernel identifier.

Return

Returns true on success or false on failure.

Examples

1 · filename flags

<?

$filename = "/tmp/tmpfile";
$flags = POSIX_S_IFREG;

$return = posix_mknod($filename, $flags);

var_export($return);
true

2 · major

<?

$filename = "/tmp/tmpfile";
$flags = POSIX_S_IFBLK;
$major = 1;

$return = posix_mknod($filename, $flags, $major);

var_export($return);
true

3 · minor

<?

$filename = "/tmp/tmpfile";
$flags = POSIX_S_IFBLK;
$major = 1;
$minor = 8;

$return = posix_mknod($filename, $flags, $major, $minor);

var_export($return);
true