summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-08 21:05:37 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-08 21:05:37 (GMT)
commit21142a09f373b96437bb0969f601e900766a3cb9 (patch)
tree95e45018fafe5855b7512637d2a825c4daa581c0
parent302331a3b6544c28a7c4d420fab18f397c844e80 (diff)
downloadcpython-21142a09f373b96437bb0969f601e900766a3cb9.zip
cpython-21142a09f373b96437bb0969f601e900766a3cb9.tar.gz
cpython-21142a09f373b96437bb0969f601e900766a3cb9.tar.bz2
Added fsync() and fdatasync(). Patches by Scott Cotton. Requires
HAVE_* macros set by configure script.
-rw-r--r--Modules/posixmodule.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index dd3cb72..2441237 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -401,6 +401,25 @@ static PyObject * os2_error(int code)
/* POSIX generic methods */
static PyObject *
+posix_int(args, func)
+ PyObject *args;
+ int (*func) Py_FPROTO((int));
+{
+ int fd;
+ int res;
+ if (!PyArg_Parse(args, "i", &fd))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS
+ res = (*func)(fd);
+ Py_END_ALLOW_THREADS
+ if (res < 0)
+ return posix_error();
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
posix_1str(args, func)
PyObject *args;
int (*func) Py_FPROTO((const char *));
@@ -590,6 +609,38 @@ posix_chmod(self, args)
}
+#ifdef HAVE_FSYNC
+static char posix_fsync__doc__[] =
+"fsync(fildes) -> None\n\
+force write of file with filedescriptor to disk.";
+
+static PyObject *
+posix_fsync(self, args)
+ PyObject *self;
+ PyObject *args;
+{
+
+ return posix_int(args, fsync);
+}
+#endif /* HAVE_FSYNC */
+
+#ifdef HAVE_FDATASYNC
+static char posix_fdatasync__doc__[] =
+"fdatasync(fildes) -> None\n\
+force write of file with filedescriptor to disk.\n\
+ does not force update of metadata.";
+
+static PyObject *
+posix_fdatasync(self, args)
+ PyObject *self;
+ PyObject *args;
+{
+
+ return posix_int(args, fdatasync);
+}
+#endif /* HAVE_FDATASYNC */
+
+
#ifdef HAVE_CHOWN
static char posix_chown__doc__[] =
"chown(path, uid, gid) -> None\n\
@@ -2935,6 +2986,12 @@ static PyMethodDef posix_methods[] = {
#ifdef HAVE_STRERROR
{"strerror", posix_strerror, 1, posix_strerror__doc__},
#endif
+#ifdef HAVE_FSYNC
+ {"fsync", posix_fsync, 0, posix_fsync__doc__},
+#endif
+#ifdef HAVE_FDATASYNC
+ {"fdatasync", posix_fdatasync, 0, posix_fdatasync__doc__},
+#endif
#ifdef HAVE_SYS_WAIT_H
#ifdef WIFSTOPPED
{"WIFSTOPPED", posix_WIFSTOPPED, 0, posix_WIFSTOPPED__doc__},