summaryrefslogtreecommitdiff
path: root/rdiff-backup
diff options
context:
space:
mode:
Diffstat (limited to 'rdiff-backup')
-rw-r--r--rdiff-backup/CHANGELOG2
-rw-r--r--rdiff-backup/rdiff_backup/cmodule.c28
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py9
3 files changed, 16 insertions, 23 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index 39c474f..4b53dc1 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,6 +1,8 @@
New in v1.1.17 (????/??/??)
---------------------------
+Use the Python os.lstat() on Windows. (Patch from Josh Nisly)
+
Support for Windows ACLs. (Patch from Josh Nisly and Fred Gansevles)
Fix user_group.py to run on native Windows, which lacks grp and pwd Python
diff --git a/rdiff-backup/rdiff_backup/cmodule.c b/rdiff-backup/rdiff_backup/cmodule.c
index 36915a6..ed82ed4 100644
--- a/rdiff-backup/rdiff_backup/cmodule.c
+++ b/rdiff-backup/rdiff_backup/cmodule.c
@@ -48,10 +48,6 @@
/* This code taken from Python's posixmodule.c */
#undef STAT
#if defined(MS_WIN64) || defined(MS_WIN32)
-# define LSTAT _stati64
-# define STAT _stati64
-# define FSTAT _fstati64
-# define STRUCT_STAT struct _stati64
# define SYNC _flushall
#else
# define LSTAT lstat
@@ -77,15 +73,6 @@
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#endif
-#if defined(MS_WIN64) || defined(MS_WIN32)
-#define S_ISSOCK(mode) (0)
-#define S_ISFIFO(mode) (0)
-#define S_ISLNK(mode) (0)
-#define S_ISLNK(mode) (0)
-#define S_ISCHR(mode) (0)
-#define S_ISBLK(mode) (0)
-#endif
-
static PyObject *UnknownFileTypeError;
static PyObject *c_make_file_dict(PyObject *self, PyObject *args);
static PyObject *long2str(PyObject *self, PyObject *args);
@@ -98,6 +85,10 @@ static PyObject *c_make_file_dict(self, args)
PyObject *self;
PyObject *args;
{
+#if defined(MS_WINDOWS)
+ PyErr_SetString(PyExc_AttributeError, "This function is not implemented on Windows.");
+ return NULL;
+#else
PyObject *size, *inode, *mtime, *atime, *ctime, *devloc, *return_val;
char *filename, filetype[5];
STRUCT_STAT sbuf;
@@ -118,10 +109,7 @@ static PyObject *c_make_file_dict(self, args)
return NULL;
}
}
-#if defined(MS_WINDOWS)
- size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size);
- inode = PyLong_FromLongLong((PY_LONG_LONG)-1);
-#else
+
#ifdef HAVE_LARGEFILE_SUPPORT
size = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_size);
inode = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_ino);
@@ -129,10 +117,9 @@ static PyObject *c_make_file_dict(self, args)
size = PyInt_FromLong(sbuf.st_size);
inode = PyInt_FromLong((long)sbuf.st_ino);
#endif /* HAVE_LARGEFILE_SUPPORT */
-#endif /* defined(MS_WINDOWS) */
mode = (long)sbuf.st_mode;
perms = mode & 07777;
-#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
+#if defined(HAVE_LONG_LONG)
devloc = PyLong_FromLongLong((PY_LONG_LONG)sbuf.st_dev);
#else
devloc = PyInt_FromLong((long)sbuf.st_dev);
@@ -189,7 +176,7 @@ static PyObject *c_make_file_dict(self, args)
} else if (S_ISCHR(mode) || S_ISBLK(mode)) {
/* Device files */
char devtype[2];
-#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
+#if defined(HAVE_LONG_LONG)
PY_LONG_LONG devnums = (PY_LONG_LONG)sbuf.st_rdev;
PyObject *major_num = PyLong_FromLongLong(major(devnums));
#else
@@ -223,6 +210,7 @@ static PyObject *c_make_file_dict(self, args)
Py_DECREF(atime);
Py_DECREF(ctime);
return return_val;
+#endif /* defined(MS_WINDOWS) */
}
/* Convert python long into 7 byte string */
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index 2acfc32..8871f47 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -246,7 +246,7 @@ def rename(rp_source, rp_dest):
if not rp_source.lstat(): rp_dest.delete()
else:
if rp_dest.lstat() and rp_source.getinode() == rp_dest.getinode() and \
- rp_source.getinode() != -1:
+ rp_source.getinode() != 0:
log.Log("Warning: Attempt to rename over same inode: %s to %s"
% (rp_source.path, rp_dest.path), 2)
# You can't rename one hard linked file over another
@@ -824,10 +824,13 @@ class RPath(RORPath):
def setdata(self):
"""Set data dictionary using C extension"""
- self.data = self.conn.C.make_file_dict(self.path)
+ try:
+ self.data = self.conn.C.make_file_dict(self.path)
+ except AttributeError:
+ self.data = self.make_file_dict_python()
if self.lstat(): self.conn.rpath.setdata_local(self)
- def make_file_dict_old(self):
+ def make_file_dict_python(self):
"""Create the data dictionary"""
statblock = self.conn.rpath.tupled_lstat(self.path)
if statblock is None: