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
c39de5fe
Commit
c39de5fe
authored
Feb 05, 1992
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added uname. Made lstat/readlink/symlink unconditional (the latter
two raise posix.error if symlinks aren't supported).
parent
3c8ba7a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
10 deletions
+54
-10
Modules/posixmodule.c
Modules/posixmodule.c
+54
-10
No files found.
Modules/posixmodule.c
View file @
c39de5fe
...
...
@@ -31,6 +31,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef MSDOS
#define NO_LSTAT
#define NO_UNAME
#endif
#include <signal.h>
...
...
@@ -385,6 +386,37 @@ posix_unlink(self, args)
return
posix_1str
(
args
,
unlink
);
}
#ifndef NO_UNAME
#include <sys/utsname.h>
static
object
*
posix_uname
(
self
,
args
)
object
*
self
;
object
*
args
;
{
extern
int
uname
PROTO
((
struct
utsname
*
));
struct
utsname
u
;
object
*
v
;
if
(
uname
(
&
u
)
<
0
)
return
posix_error
();
v
=
newtupleobject
(
5
);
if
(
v
==
NULL
)
return
NULL
;
#define SET(i, member) settupleitem(v, i, newstringobject(u.member))
SET
(
0
,
sysname
);
SET
(
1
,
nodename
);
SET
(
2
,
release
);
SET
(
3
,
version
);
SET
(
4
,
machine
);
#undef SET
if
(
err_occurred
())
{
DECREF
(
v
);
return
NULL
;
}
return
v
;
}
#endif
/* NO_UNAME */
#ifdef UTIME_STRUCT
#include <utime.h>
#endif
...
...
@@ -574,7 +606,7 @@ posix_wait(self, args) /* Also waitpid() */
pid
=
wait
(
&
sts
);
else
{
#ifdef NO_WAITPID
err_setstr
(
Runtime
Error
,
err_setstr
(
Posix
Error
,
"posix.wait(pid, options) not supported on this system"
);
#else
int
options
;
...
...
@@ -599,13 +631,14 @@ posix_wait(self, args) /* Also waitpid() */
#endif
/* MSDOS */
#ifndef NO_LSTAT
static
object
*
posix_lstat
(
self
,
args
)
object
*
self
;
object
*
args
;
{
#ifdef NO_LSTAT
#define lstat stat
#endif
extern
int
lstat
PROTO
((
const
char
*
,
struct
stat
*
));
return
posix_do_stat
(
self
,
args
,
lstat
);
}
...
...
@@ -615,6 +648,10 @@ posix_readlink(self, args)
object
*
self
;
object
*
args
;
{
#ifdef NO_LSTAT
err_setstr
(
PosixError
,
"readlink not implemented on this system"
);
return
NULL
;
#else
char
buf
[
1024
];
/* XXX Should use MAXPATHLEN */
char
*
path
;
int
n
;
...
...
@@ -624,6 +661,7 @@ posix_readlink(self, args)
if
(
n
<
0
)
return
posix_error
();
return
newsizedstringobject
(
buf
,
n
);
#endif
}
static
object
*
...
...
@@ -631,12 +669,15 @@ posix_symlink(self, args)
object
*
self
;
object
*
args
;
{
#ifdef NO_LSTAT
err_setstr
(
PosixError
,
"symlink not implemented on this system"
);
return
NULL
;
#else
extern
int
symlink
PROTO
((
const
char
*
,
const
char
*
));
return
posix_2str
(
args
,
symlink
);
#endif
}
#endif
/* NO_LSTAT */
static
struct
methodlist
posix_methods
[]
=
{
{
"chdir"
,
posix_chdir
},
...
...
@@ -646,16 +687,23 @@ static struct methodlist posix_methods[] = {
{
"link"
,
posix_link
},
#endif
{
"listdir"
,
posix_listdir
},
{
"lstat"
,
posix_lstat
},
{
"mkdir"
,
posix_mkdir
},
{
"readlink"
,
posix_readlink
},
{
"rename"
,
posix_rename
},
{
"rmdir"
,
posix_rmdir
},
{
"stat"
,
posix_stat
},
{
"symlink"
,
posix_symlink
},
{
"system"
,
posix_system
},
#ifndef MSDOS
{
"umask"
,
posix_umask
},
#endif
#ifndef NO_UNAME
{
"uname"
,
posix_uname
},
#endif
{
"unlink"
,
posix_unlink
},
{
"utime"
,
posix_utime
},
#ifndef MSDOS
{
"_exit"
,
posix__exit
},
{
"exec"
,
posix_exec
},
...
...
@@ -667,11 +715,7 @@ static struct methodlist posix_methods[] = {
{
"popen"
,
posix_popen
},
{
"wait"
,
posix_wait
},
#endif
#ifndef NO_LSTAT
{
"lstat"
,
posix_lstat
},
{
"readlink"
,
posix_readlink
},
{
"symlink"
,
posix_symlink
},
#endif
{
NULL
,
NULL
}
/* Sentinel */
};
...
...
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