Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
dbe3f762
Commit
dbe3f762
authored
Oct 10, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #569139: Implementation of major, minor and makedev.
parent
3e3e1296
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
450 additions
and
17 deletions
+450
-17
Doc/lib/libos.tex
Doc/lib/libos.tex
+25
-6
Modules/posixmodule.c
Modules/posixmodule.c
+59
-8
configure
configure
+336
-3
configure.in
configure.in
+19
-0
pyconfig.h.in
pyconfig.h.in
+11
-0
No files found.
Doc/lib/libos.tex
View file @
dbe3f762
...
@@ -700,13 +700,32 @@ the client opens it for writing. Note that \function{mkfifo()}
...
@@ -700,13 +700,32 @@ the client opens it for writing. Note that \function{mkfifo()}
doesn't open the FIFO --- it just creates the rendezvous point.
doesn't open the FIFO --- it just creates the rendezvous point.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
mknod
}{
path
\optional
{
, mode=0600,
major, minor
}}
\begin{funcdesc}
{
mknod
}{
path
\optional
{
, mode=0600,
device
}}
Create a filesystem node (file, device special file or named pipe)
Create a filesystem node (file, device special file or named pipe)
named filename. mode specifies both the permissions to use and the
named filename.
\var
{
mode
}
specifies both the permissions to use and
type of node to be created, being combined (bitwise OR) with one of
the type of node to be created, being combined (bitwise OR) with one
S
_
IFREG, S
_
IFCHR, S
_
IFBLK, and S
_
IFIFO (those constants are available
of S
_
IFREG, S
_
IFCHR, S
_
IFBLK, and S
_
IFIFO (those constants are
in
\module
{
stat
}
). For S
_
IFCHR and S
_
IFBLK, major and minor define the
available in
\module
{
stat
}
). For S
_
IFCHR and S
_
IFBLK,
\var
{
device
}
newly created device special file, otherwise they are ignored.
defines the newly created device special file (probably using
\function
{
os.makedev()
}
), otherwise it is ignored.
\versionadded
{
2.3
}
\end{funcdesc}
\begin{funcdesc}
{
major
}{
device
}
Extracts a device major number from a raw device number.
\versionadded
{
2.3
}
\end{funcdesc}
\begin{funcdesc}
{
minor
}{
device
}
Extracts a device minor number from a raw device number.
\versionadded
{
2.3
}
\end{funcdesc}
\begin{funcdesc}
{
makedev
}{
major, minor
}
Composes a raw device number from the major and minor device numbers.
\versionadded
{
2.3
}
\versionadded
{
2.3
}
\end{funcdesc}
\end{funcdesc}
...
...
Modules/posixmodule.c
View file @
dbe3f762
...
@@ -277,9 +277,16 @@ extern int lstat(const char *, struct stat *);
...
@@ -277,9 +277,16 @@ extern int lstat(const char *, struct stat *);
# define STRUCT_STAT struct stat
# define STRUCT_STAT struct stat
#endif
#endif
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#else
#if defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H)
#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H)
#include <sys/mkdev.h>
#include <sys/mkdev.h>
#endif
#endif
#endif
/* Return a dictionary corresponding to the POSIX environment table */
/* Return a dictionary corresponding to the POSIX environment table */
#ifdef WITH_NEXT_FRAMEWORK
#ifdef WITH_NEXT_FRAMEWORK
...
@@ -5081,13 +5088,13 @@ posix_mkfifo(PyObject *self, PyObject *args)
...
@@ -5081,13 +5088,13 @@ posix_mkfifo(PyObject *self, PyObject *args)
#if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)
#if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)
PyDoc_STRVAR
(
posix_mknod__doc__
,
PyDoc_STRVAR
(
posix_mknod__doc__
,
"mknod(filename, [, mode=0600,
major, minor
])
\n\n
\
"mknod(filename, [, mode=0600,
device
])
\n\n
\
Create a filesystem node (file, device special file or named pipe)
\n
\
Create a filesystem node (file, device special file or named pipe)
\n
\
named filename. mode specifies both the permissions to use and the
\n
\
named filename. mode specifies both the permissions to use and the
\n
\
type of node to be created, being combined (bitwise OR) with one of
\n
\
type of node to be created, being combined (bitwise OR) with one of
\n
\
S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. For S_IFCHR and S_IFBLK,
\n
\
S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. For S_IFCHR and S_IFBLK,
\n
\
major and minor define the newly created device special file, otherwise
\n
\
device defines the newly created device special file (probably using
\n
\
they are
ignored."
);
os.makedev()), otherwise it is
ignored."
);
static
PyObject
*
static
PyObject
*
...
@@ -5095,14 +5102,12 @@ posix_mknod(PyObject *self, PyObject *args)
...
@@ -5095,14 +5102,12 @@ posix_mknod(PyObject *self, PyObject *args)
{
{
char
*
filename
;
char
*
filename
;
int
mode
=
0600
;
int
mode
=
0600
;
int
major
=
0
;
int
device
=
0
;
int
minor
=
0
;
int
res
;
int
res
;
if
(
!
PyArg_ParseTuple
(
args
,
"s|iii:mknod"
,
&
filename
,
if
(
!
PyArg_ParseTuple
(
args
,
"s|iii:mknod"
,
&
filename
,
&
mode
,
&
device
))
&
mode
,
&
major
,
&
minor
))
return
NULL
;
return
NULL
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
res
=
mknod
(
filename
,
mode
,
makedev
(
major
,
minor
)
);
res
=
mknod
(
filename
,
mode
,
device
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
if
(
res
<
0
)
if
(
res
<
0
)
return
posix_error
();
return
posix_error
();
...
@@ -5111,6 +5116,47 @@ posix_mknod(PyObject *self, PyObject *args)
...
@@ -5111,6 +5116,47 @@ posix_mknod(PyObject *self, PyObject *args)
}
}
#endif
#endif
#ifdef HAVE_DEVICE_MACROS
PyDoc_STRVAR
(
posix_major__doc__
,
"major(device) -> major number
\n
\
Extracts a device major number from a raw device number."
);
static
PyObject
*
posix_major
(
PyObject
*
self
,
PyObject
*
args
)
{
int
device
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:major"
,
&
device
))
return
NULL
;
return
PyInt_FromLong
((
long
)
major
(
device
));
}
PyDoc_STRVAR
(
posix_minor__doc__
,
"minor(device) -> minor number
\n
\
Extracts a device minor number from a raw device number."
);
static
PyObject
*
posix_minor
(
PyObject
*
self
,
PyObject
*
args
)
{
int
device
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:minor"
,
&
device
))
return
NULL
;
return
PyInt_FromLong
((
long
)
minor
(
device
));
}
PyDoc_STRVAR
(
posix_makedev__doc__
,
"makedev(major, minor) -> device number
\n
\
Composes a raw device number from the major and minor device numbers."
);
static
PyObject
*
posix_makedev
(
PyObject
*
self
,
PyObject
*
args
)
{
int
major
,
minor
;
if
(
!
PyArg_ParseTuple
(
args
,
"ii:makedev"
,
&
major
,
&
minor
))
return
NULL
;
return
PyInt_FromLong
((
long
)
makedev
(
major
,
minor
));
}
#endif
/* device macros */
#ifdef HAVE_FTRUNCATE
#ifdef HAVE_FTRUNCATE
PyDoc_STRVAR
(
posix_ftruncate__doc__
,
PyDoc_STRVAR
(
posix_ftruncate__doc__
,
...
@@ -6905,6 +6951,11 @@ static PyMethodDef posix_methods[] = {
...
@@ -6905,6 +6951,11 @@ static PyMethodDef posix_methods[] = {
#if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)
#if defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)
{
"mknod"
,
posix_mknod
,
METH_VARARGS
,
posix_mknod__doc__
},
{
"mknod"
,
posix_mknod
,
METH_VARARGS
,
posix_mknod__doc__
},
#endif
#endif
#ifdef HAVE_DEVICE_MACROS
{
"major"
,
posix_major
,
METH_VARARGS
,
posix_major__doc__
},
{
"minor"
,
posix_minor
,
METH_VARARGS
,
posix_minor__doc__
},
{
"makedev"
,
posix_makedev
,
METH_VARARGS
,
posix_makedev__doc__
},
#endif
#ifdef HAVE_FTRUNCATE
#ifdef HAVE_FTRUNCATE
{
"ftruncate"
,
posix_ftruncate
,
METH_VARARGS
,
posix_ftruncate__doc__
},
{
"ftruncate"
,
posix_ftruncate
,
METH_VARARGS
,
posix_ftruncate__doc__
},
#endif
#endif
...
...
configure
View file @
dbe3f762
This diff is collapsed.
Click to expand it.
configure.in
View file @
dbe3f762
...
@@ -621,6 +621,7 @@ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
...
@@ -621,6 +621,7 @@ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
sys/un.h sys/utsname.h sys/wait.h pty.h term.h wctype.h libutil.h \
sys/un.h sys/utsname.h sys/wait.h pty.h term.h wctype.h libutil.h \
sys/resource.h netpacket/packet.h)
sys/resource.h netpacket/packet.h)
AC_HEADER_DIRENT
AC_HEADER_DIRENT
AC_HEADER_MAJOR
# checks for typedefs
# checks for typedefs
was_it_defined=no
was_it_defined=no
...
@@ -1716,6 +1717,24 @@ AC_CHECK_FUNCS(gettimeofday,
...
@@ -1716,6 +1717,24 @@ AC_CHECK_FUNCS(gettimeofday,
)
)
)
)
AC_MSG_CHECKING(for major, minor, and makedev)
AC_TRY_COMPILE([
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#else
#include <sys/types.h>
#endif
],[
makedev(major(0),minor(0));
],[
AC_DEFINE(HAVE_DEVICE_MACROS, 1,
[Define to 1 if you have the device macros.])
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
])
# On OSF/1 V5.1, getaddrinfo is available, but a define
# On OSF/1 V5.1, getaddrinfo is available, but a define
# for [no]getaddrinfo in netdb.h.
# for [no]getaddrinfo in netdb.h.
...
...
pyconfig.h.in
View file @
dbe3f762
...
@@ -57,6 +57,9 @@
...
@@ -57,6 +57,9 @@
/* Define to 1 if you have the `ctermid_r' function. */
/* Define to 1 if you have the `ctermid_r' function. */
#undef HAVE_CTERMID_R
#undef HAVE_CTERMID_R
/* Define to 1 if you have the device macros. */
#undef HAVE_DEVICE_MACROS
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
*/
#undef HAVE_DIRENT_H
#undef HAVE_DIRENT_H
...
@@ -604,6 +607,14 @@
...
@@ -604,6 +607,14 @@
/* Define if you are using Mach cthreads under mach / */
/* Define if you are using Mach cthreads under mach / */
#undef MACH_C_THREADS
#undef MACH_C_THREADS
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
#undef MAJOR_IN_MKDEV
/* Define to 1 if `major', `minor', and `makedev' are declared in
<sysmacros.h>. */
#undef MAJOR_IN_SYSMACROS
/* Define if malloc(0) returns a NULL pointer. */
/* Define if malloc(0) returns a NULL pointer. */
#undef MALLOC_ZERO_RETURNS_NULL
#undef MALLOC_ZERO_RETURNS_NULL
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment