[Python-Dev] mkdev, major, st_rdev, etc

Gustavo Niemeyer niemeyer@conectiva.com
Sat, 15 Jun 2002 19:21:46 -0300

Hello Martin!

> > - mkdev would be able to use the standard posix format, and would
> >   work regardless of makedev's availability (mkdev is being
> >   introduced in 2.3).
> Notice that the this interface is *not* part of the Posix spec.

Please, notice that what I said is that *mknod* would be able to
use the standard posix format. In other words, instead of

mknod(name, mode, major, minor)

It can become:

mknod(name, mode, device)

Which *is* posix compliant, so your note seems to be another reason
for us to use the new proposed system.

> http://www.opengroup.org/onlinepubs/007904975/functions/mknod.html
> says that the only portable use of mknod is to create FIFOs; any use
> where dev is not null is unspecified. Furthermore, major and minor are
> not part of Posix.

Indeed. But I think we need this functionality nevertheless, since
that's the only way to create special devices in Linux and other
systems. Otherwise we won't be able to have modules like tarfile.py
which have to rebuild them. Besides that, os is meant to have
operating system specific functionality, isn't it?

> > - TYPES.py is already trying to provide them, but it's broken
> >   (indeed, it's more broken than that. h2py should use cpp to
> >   preprocess the files, but that's something for another occasion).
> That cannot work: the preprocessor will eat the macro definition, and
> you have no way to find out what its body was.

That's what I meant:

[niemeyer@ibook dist]$ cpp -dM /usr/include/sys/types.h 
#define __LITTLE_ENDIAN 1234 
#define powerpc 1 
#define __linux__ 1 
#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp) 

> > A patch providing these functions is available at
> > http://www.python.org/sf/569139
> I wonder whether the additional TRY_COMPILE test is really
> necessary. Isn't it sufficient to restrict attention to systems on
> which major and minor are macros, and use
> #ifdef major
> inside posixmodule.c?

I'm not sure if these functions are macros in every system. If that's
true, and makedev is always available with major, you're completely
right. My purpose to include a TRY_COMPILE was a safe approach, and
was based on a review on the way autoconf checks if makedev is

Martin, thanks for your review!

Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]