2 * Copyright (C) 2018 Facebook
4 * This file is part of libbtrfsutil.
6 * libbtrfsutil is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * libbtrfsutil is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libbtrfsutil. If not, see <http://www.gnu.org/licenses/>.
20 #include "btrfsutilpy.h"
22 PyObject
*filesystem_sync(PyObject
*self
, PyObject
*args
, PyObject
*kwds
)
24 static char *keywords
[] = {"path", NULL
};
25 struct path_arg path
= {.allow_fd
= true};
26 enum btrfs_util_error err
;
28 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&:sync", keywords
,
29 &path_converter
, &path
))
33 err
= btrfs_util_sync(path
.path
);
35 err
= btrfs_util_sync_fd(path
.fd
);
37 SetFromBtrfsUtilErrorWithPath(err
, &path
);
46 PyObject
*start_sync(PyObject
*self
, PyObject
*args
, PyObject
*kwds
)
48 static char *keywords
[] = {"path", NULL
};
49 struct path_arg path
= {.allow_fd
= true};
51 enum btrfs_util_error err
;
53 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&:start_sync", keywords
,
54 &path_converter
, &path
))
58 err
= btrfs_util_start_sync(path
.path
, &transid
);
60 err
= btrfs_util_start_sync_fd(path
.fd
, &transid
);
62 SetFromBtrfsUtilErrorWithPath(err
, &path
);
68 return PyLong_FromUnsignedLongLong(transid
);
71 PyObject
*wait_sync(PyObject
*self
, PyObject
*args
, PyObject
*kwds
)
73 static char *keywords
[] = {"path", "transid", NULL
};
74 struct path_arg path
= {.allow_fd
= true};
75 unsigned long long transid
= 0;
76 enum btrfs_util_error err
;
78 if (!PyArg_ParseTupleAndKeywords(args
, kwds
, "O&|K:wait_sync", keywords
,
79 &path_converter
, &path
, &transid
))
83 err
= btrfs_util_wait_sync(path
.path
, transid
);
85 err
= btrfs_util_wait_sync_fd(path
.fd
, transid
);
87 SetFromBtrfsUtilErrorWithPath(err
, &path
);