From da17a03c192fb2668a32ca222862a38d9b934dd5 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 10 Sep 2002 22:18:36 +0000 Subject: Added thread statements and lstat64 check for large file support git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@193 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/cmodule.c | 28 ++++++++++++++++++++++++++-- rdiff-backup/src/cmodule.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/rdiff-backup/rdiff_backup/cmodule.c b/rdiff-backup/rdiff_backup/cmodule.c index 9d8c62b..f76d73e 100644 --- a/rdiff-backup/rdiff_backup/cmodule.c +++ b/rdiff-backup/rdiff_backup/cmodule.c @@ -19,6 +19,20 @@ #include #include +/* choose the appropriate stat and fstat functions and return structs */ +/* This code taken from Python's posixmodule.c */ +#undef STAT +#if defined(MS_WIN64) || defined(MS_WIN32) +# define STAT _stati64 +# define FSTAT _fstati64 +# define STRUCT_STAT struct _stati64 +#else +# define STAT stat +# define FSTAT fstat +# define STRUCT_STAT struct stat +#endif + + static PyObject *UnknownFileTypeError; static PyObject *c_make_file_dict(PyObject *self, PyObject *args); static PyObject *long2str(PyObject *self, PyObject *args); @@ -33,11 +47,21 @@ static PyObject *c_make_file_dict(self, args) { PyObject *size, *inode, *mtime, *atime, *devloc, *return_val; char *filename, filetype[5]; - struct stat sbuf; + STRUCT_STAT sbuf; long int mode, perms; + int res; if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; - if (lstat(filename, &sbuf) != 0) { + + Py_BEGIN_ALLOW_THREADS +#if HAVE_LARGEFILE_SUPPORT + res = lstat64(filename, &sbuf); +#else + res = lstat(filename, &sbuf); +#endif + Py_END_ALLOW_THREADS + + if (res != 0) { if (errno == ENOENT || errno == ENOTDIR) return Py_BuildValue("{s:s}", "type", NULL); else { diff --git a/rdiff-backup/src/cmodule.c b/rdiff-backup/src/cmodule.c index 9d8c62b..f76d73e 100644 --- a/rdiff-backup/src/cmodule.c +++ b/rdiff-backup/src/cmodule.c @@ -19,6 +19,20 @@ #include #include +/* choose the appropriate stat and fstat functions and return structs */ +/* This code taken from Python's posixmodule.c */ +#undef STAT +#if defined(MS_WIN64) || defined(MS_WIN32) +# define STAT _stati64 +# define FSTAT _fstati64 +# define STRUCT_STAT struct _stati64 +#else +# define STAT stat +# define FSTAT fstat +# define STRUCT_STAT struct stat +#endif + + static PyObject *UnknownFileTypeError; static PyObject *c_make_file_dict(PyObject *self, PyObject *args); static PyObject *long2str(PyObject *self, PyObject *args); @@ -33,11 +47,21 @@ static PyObject *c_make_file_dict(self, args) { PyObject *size, *inode, *mtime, *atime, *devloc, *return_val; char *filename, filetype[5]; - struct stat sbuf; + STRUCT_STAT sbuf; long int mode, perms; + int res; if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; - if (lstat(filename, &sbuf) != 0) { + + Py_BEGIN_ALLOW_THREADS +#if HAVE_LARGEFILE_SUPPORT + res = lstat64(filename, &sbuf); +#else + res = lstat(filename, &sbuf); +#endif + Py_END_ALLOW_THREADS + + if (res != 0) { if (errno == ENOENT || errno == ENOTDIR) return Py_BuildValue("{s:s}", "type", NULL); else { -- cgit v1.2.1