]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/_helpers.c
Add offset argument to fadvise_done
[bup.git] / lib / bup / _helpers.c
index caa5c021c183d2a98f5d8f74e4fe2e44f71d4ec7..3ad766667b8d5d6b55fcde9c0000cc0ae12c42d6 100644 (file)
@@ -945,11 +945,18 @@ static PyObject *open_noatime(PyObject *self, PyObject *args)
 static PyObject *fadvise_done(PyObject *self, PyObject *args)
 {
     int fd = -1;
-    long long ofs = 0;
-    if (!PyArg_ParseTuple(args, "iL", &fd, &ofs))
+    long long llofs, lllen = 0;
+    if (!PyArg_ParseTuple(args, "iLL", &fd, &llofs, &lllen))
        return NULL;
+    off_t ofs, len;
+    if (!INTEGRAL_ASSIGNMENT_FITS(&ofs, llofs))
+        return PyErr_Format(PyExc_OverflowError,
+                            "fadvise offset overflows off_t");
+    if (!INTEGRAL_ASSIGNMENT_FITS(&len, lllen))
+        return PyErr_Format(PyExc_OverflowError,
+                            "fadvise length overflows off_t");
 #ifdef POSIX_FADV_DONTNEED
-    posix_fadvise(fd, 0, ofs, POSIX_FADV_DONTNEED);
+    posix_fadvise(fd, ofs, len, POSIX_FADV_DONTNEED);
 #endif    
     return Py_BuildValue("");
 }