@@ -4582,19 +4582,52 @@ posix_pipe(PyObject *self, PyObject *args)
45824582
45834583#ifdef HAVE_MKFIFO
45844584static char posix_mkfifo__doc__ [] =
4585- "mkfifo(file , [, mode=0666]) -> None\n\
4585+ "mkfifo(filename , [, mode=0666]) -> None\n\
45864586Create a FIFO (a POSIX named pipe)." ;
45874587
45884588static PyObject *
45894589posix_mkfifo (PyObject * self , PyObject * args )
45904590{
4591- char * file ;
4591+ char * filename ;
45924592 int mode = 0666 ;
45934593 int res ;
4594- if (!PyArg_ParseTuple (args , "s|i:mkfifo" , & file , & mode ))
4594+ if (!PyArg_ParseTuple (args , "s|i:mkfifo" , & filename , & mode ))
45954595 return NULL ;
45964596 Py_BEGIN_ALLOW_THREADS
4597- res = mkfifo (file , mode );
4597+ res = mkfifo (filename , mode );
4598+ Py_END_ALLOW_THREADS
4599+ if (res < 0 )
4600+ return posix_error ();
4601+ Py_INCREF (Py_None );
4602+ return Py_None ;
4603+ }
4604+ #endif
4605+
4606+
4607+ #ifdef HAVE_MKNOD
4608+ static char posix_mknod__doc__ [] =
4609+ "mknod(filename, [, mode=0600, major, minor]) -> None\n\
4610+ Create a filesystem node (file, device special file or named pipe)\n\
4611+ named filename. mode specifies both the permissions to use and the\n\
4612+ type of node to be created, being combined (bitwise OR) with one of\n\
4613+ S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. For S_IFCHR and S_IFBLK,\n\
4614+ major and minor define the newly created device special file, otherwise\n\
4615+ they are ignored." ;
4616+
4617+
4618+ static PyObject *
4619+ posix_mknod (PyObject * self , PyObject * args )
4620+ {
4621+ char * filename ;
4622+ int mode = 0600 ;
4623+ int major = 0 ;
4624+ int minor = 0 ;
4625+ int res ;
4626+ if (!PyArg_ParseTuple (args , "s|iii:mknod" , & filename ,
4627+ & mode , & major , & minor ))
4628+ return NULL ;
4629+ Py_BEGIN_ALLOW_THREADS
4630+ res = mknod (filename , mode , makedev (major , minor ));
45984631 Py_END_ALLOW_THREADS
45994632 if (res < 0 )
46004633 return posix_error ();
@@ -6336,6 +6369,9 @@ static PyMethodDef posix_methods[] = {
63366369#ifdef HAVE_MKFIFO
63376370 {"mkfifo" , posix_mkfifo , METH_VARARGS , posix_mkfifo__doc__ },
63386371#endif
6372+ #ifdef HAVE_MKNOD
6373+ {"mknod" , posix_mknod , METH_VARARGS , posix_mknod__doc__ },
6374+ #endif
63396375#ifdef HAVE_FTRUNCATE
63406376 {"ftruncate" , posix_ftruncate , METH_VARARGS , posix_ftruncate__doc__ },
63416377#endif
0 commit comments