#endif /* defined(_ATFILE_SOURCE)
|| _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L */
-
+ #endif /* HAVE_UTIMENSAT */
-#ifdef linux /* and likely others */
+static PyObject *stat_struct_to_py(const struct stat *st)
+{
+ /* Enforce the current timespec nanosecond range expectations. */
+ if (st->st_atim.tv_nsec < 0 || st->st_atim.tv_nsec > 999999999)
+ {
+ PyErr_SetString(PyExc_ValueError, "invalid atime timespec nanoseconds");
+ return NULL;
+ }
+ if (st->st_mtim.tv_nsec < 0 || st->st_mtim.tv_nsec > 999999999)
+ {
+ PyErr_SetString(PyExc_ValueError, "invalid mtime timespec nanoseconds");
+ return NULL;
+ }
+ if (st->st_ctim.tv_nsec < 0 || st->st_ctim.tv_nsec > 999999999)
+ {
+ PyErr_SetString(PyExc_ValueError, "invalid ctime timespec nanoseconds");
+ return NULL;
+ }
+
+ return Py_BuildValue("kkkkkkkk(Ll)(Ll)(Ll)",
+ (unsigned long) st->st_mode,
+ (unsigned long) st->st_ino,
+ (unsigned long) st->st_dev,
+ (unsigned long) st->st_nlink,
+ (unsigned long) st->st_uid,
+ (unsigned long) st->st_gid,
+ (unsigned long) st->st_rdev,
+ (unsigned long) st->st_size,
+ (long long) st->st_atime,
+ (long) st->st_atim.tv_nsec,
+ (long long) st->st_mtime,
+ (long) st->st_mtim.tv_nsec,
+ (long long) st->st_ctime,
+ (long) st->st_ctim.tv_nsec);
+}
+
-#define HAVE_BUP_STAT 1
static PyObject *bup_stat(PyObject *self, PyObject *args)
{
int rc;
# Public License as described in the bup LICENSE file.
import errno, os, sys, stat, pwd, grp, struct, re
from cStringIO import StringIO
-from bup import vint
+from bup import vint, xstat
from bup.drecurse import recursive_dirlist
- from bup.helpers import add_error, mkdirp, log
- from bup.xstat import utime, lutime
+ from bup.helpers import add_error, mkdirp, log, is_superuser
-from bup.xstat import utime, lutime, lstat, FSTime
++from bup.xstat import utime, lutime, lstat
import bup._helpers as _helpers
try: