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.
Constant | Description |
---|---|
POSIX_S_IFREG | Normal file |
POSIX_S_IFCHR | Character special file |
POSIX_S_IFBLK | Block special file |
POSIX_S_IFIFO | FIFO (named pipe) special file |
POSIX_S_IFSOCK | Socket |
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
Links
POSIX
- posix_access
- posix_ctermid
- posix_eaccess
- posix_errno
- posix_fpathconf
- posix_get_last_error
- posix_getcwd
- posix_getegid
- posix_geteuid
- posix_getgid
- posix_getgrgid
- posix_getgrnam
- posix_getgroups
- posix_getlogin
- posix_getpgid
- posix_getpgrp
- posix_getpid
- posix_getppid
- posix_getpwnam
- posix_getpwuid
- posix_getrlimit
- posix_getsid
- posix_getuid
- posix_initgroups
- posix_isatty
- posix_kill
- posix_mkfifo
- posix_pathconf
- posix_setegid
- posix_seteuid
- posix_setgid
- posix_setpgid
- posix_setrlimit
- posix_setsid
- posix_setuid
- posix_strerror
- posix_sysconf
- posix_times
- posix_ttyname
- posix_uname