Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Storz <philipp.storz@bareos.com>2022-11-11 22:19:52 +0300
committerPhilipp Storz <philipp.storz@bareos.com>2022-11-11 22:26:08 +0300
commit6910cdc15b5671343b069ab77a9c86471610c204 (patch)
tree7308e4168bf1ee10ca546ef64bb49ad6e0d8f187
parent18ca01f714b30afb2cbc93e010781d0dd23f4cdf (diff)
removed do_io_in_core, now works via IOP.statusdev/pstorz/master/plugin_io_in_core
-rw-r--r--core/src/filed/fd_plugins.cc14
-rw-r--r--core/src/filed/fd_plugins.h38
-rw-r--r--core/src/plugins/filed/python/module/bareosfd.cc2
-rw-r--r--core/src/plugins/filed/python/module/bareosfd.h10
-rw-r--r--core/src/plugins/filed/python/pyfiles/BareosFdPluginLocalFileset.py9
-rw-r--r--core/src/plugins/filed/python/test/bareosfd_test.py5
-rwxr-xr-xsystemtests/tests/py2plug-fd-local-fileset-basic/testrunner2
7 files changed, 50 insertions, 30 deletions
diff --git a/core/src/filed/fd_plugins.cc b/core/src/filed/fd_plugins.cc
index 8d7a3c2ad..ca7c90d83 100644
--- a/core/src/filed/fd_plugins.cc
+++ b/core/src/filed/fd_plugins.cc
@@ -1831,18 +1831,16 @@ static int MyPluginBopen(BareosFilePacket* bfd,
errno = io.io_errno;
bfd->lerror = io.lerror;
}
- // The plugin has two options for the read/write:
- // 1.: - Set io.do_io_in_core to true, and
+ // The plugin has two options for the read/write during the IO_OPEN call:
+ // 1.: - Set io.status to IoStatus::do_io_in_core, and
// - Set the io.filedes to the filedescriptor of the file that was
// opened in the plugin. In this case the core code will read from
// write to that filedescriptor during backup and restore.
- // 2.: - Set io.do_io_in_core to false , and
- // - Set/leave the io.filedes on/to -1. In this case the plugin code
- // itself will be called for every read/write during backup and
- // restore.
-
- bfd->do_io_in_core = io.do_io_in_core;
+ // 2.: - Set io.status to IoStatus::success, and
bfd->filedes = io.filedes;
+
+ if (io.status == IoStatus::do_io_in_core) { bfd->do_io_in_core = true; }
+
if (bfd->do_io_in_core) {
if (io.filedes != -1) {
Dmsg1(
diff --git a/core/src/filed/fd_plugins.h b/core/src/filed/fd_plugins.h
index a8fe7a5d3..f75650a3e 100644
--- a/core/src/filed/fd_plugins.h
+++ b/core/src/filed/fd_plugins.h
@@ -61,6 +61,13 @@ struct BareosFilePacket;
struct FindFilesPacket;
#endif /* FILE_DAEMON */
+enum IoStatus : int
+{
+ error = -1,
+ success = 0,
+ do_io_in_core = 1,
+};
+
template <typename T> class alist;
namespace filedaemon {
@@ -138,22 +145,21 @@ enum
};
struct io_pkt {
- int32_t pkt_size; /* Size of this packet */
- int32_t func; /* Function code */
- int32_t count; /* Read/write count */
- int32_t flags; /* Open flags */
- mode_t mode; /* Permissions for created files */
- char* buf; /* Read/write buffer */
- const char* fname; /* Open filename */
- int32_t status; /* Return status */
- int32_t io_errno; /* Errno code */
- int32_t lerror; /* Win32 error code */
- int32_t whence; /* Lseek argument */
- boffset_t offset; /* Lseek argument */
- bool win32; /* Win32 GetLastError returned */
- int filedes; /* file descriptor to read/write in core */
- bool do_io_in_core; /* do io in core */
- int32_t pkt_end; /* End packet sentinel */
+ int32_t pkt_size; /* Size of this packet */
+ int32_t func; /* Function code */
+ int32_t count; /* Read/write count */
+ int32_t flags; /* Open flags */
+ mode_t mode; /* Permissions for created files */
+ char* buf; /* Read/write buffer */
+ const char* fname; /* Open filename */
+ int32_t status; /* Return status */
+ int32_t io_errno; /* Errno code */
+ int32_t lerror; /* Win32 error code */
+ int32_t whence; /* Lseek argument */
+ boffset_t offset; /* Lseek argument */
+ bool win32; /* Win32 GetLastError returned */
+ int filedes; /* file descriptor to read/write in core */
+ int32_t pkt_end; /* End packet sentinel */
};
struct acl_pkt {
diff --git a/core/src/plugins/filed/python/module/bareosfd.cc b/core/src/plugins/filed/python/module/bareosfd.cc
index cae87edc7..3e28d42b4 100644
--- a/core/src/plugins/filed/python/module/bareosfd.cc
+++ b/core/src/plugins/filed/python/module/bareosfd.cc
@@ -508,7 +508,6 @@ static inline PyIoPacket* NativeToPyIoPacket(struct io_pkt* io)
pIoPkt->whence = io->whence;
pIoPkt->offset = io->offset;
pIoPkt->filedes = io->filedes;
- pIoPkt->do_io_in_core = io->do_io_in_core;
if (io->func == IO_WRITE && io->count > 0) {
/* Only initialize the buffer with read data when we are writing and
@@ -540,7 +539,6 @@ static inline bool PyIoPacketToNative(PyIoPacket* pIoPkt, struct io_pkt* io)
io->win32 = pIoPkt->win32;
io->status = pIoPkt->status;
io->filedes = pIoPkt->filedes;
- io->do_io_in_core = pIoPkt->do_io_in_core;
if (io->func == IO_READ && io->status > 0) {
// Only copy back the data when doing a read and there is data.
diff --git a/core/src/plugins/filed/python/module/bareosfd.h b/core/src/plugins/filed/python/module/bareosfd.h
index 8e2798766..6d32140d1 100644
--- a/core/src/plugins/filed/python/module/bareosfd.h
+++ b/core/src/plugins/filed/python/module/bareosfd.h
@@ -793,6 +793,16 @@ MOD_INIT(bareosfd)
if (!pDictbIOPS) { return MOD_ERROR_VAL; }
if (PyModule_AddObject(m, bIOPS, pDictbIOPS)) { return MOD_ERROR_VAL; }
+ const char* bIOPstatus = "bIOPstatus";
+ PyObject* pDictbIOPstatus = NULL;
+ pDictbIOPstatus = PyDict_New();
+ ConstSet_StrLong(pDictbIOPstatus, io_status_error, -1);
+ ConstSet_StrLong(pDictbIOPstatus, io_status_plugin, 0);
+ ConstSet_StrLong(pDictbIOPstatus, io_status_core, 1);
+ if (!pDictbIOPstatus) { return MOD_ERROR_VAL; }
+ if (PyModule_AddObject(m, bIOPstatus, pDictbIOPstatus)) { return MOD_ERROR_VAL; }
+
+
const char* bLevels = "bLevels";
PyObject* pDictbLevels = NULL;
diff --git a/core/src/plugins/filed/python/pyfiles/BareosFdPluginLocalFileset.py b/core/src/plugins/filed/python/pyfiles/BareosFdPluginLocalFileset.py
index db3d1b608..7ea88c9ea 100644
--- a/core/src/plugins/filed/python/pyfiles/BareosFdPluginLocalFileset.py
+++ b/core/src/plugins/filed/python/pyfiles/BareosFdPluginLocalFileset.py
@@ -189,8 +189,13 @@ class BareosFdPluginLocalFileset(BareosFdPluginLocalFilesBaseclass): # noqa
self.file = open(self.FNAME, "rb")
# do io in core
- IOP.do_io_in_core = True
- IOP.filedes = self.file.fileno()
+ #IOP.filedes = self.file.fileno()
+ #IOP.status = bareosfd.io_status_core
+ ##IOP.status = 1
+
+ # do io in plugin
+ IOP.status = bareosfd.io_status_plugin
+ ##IOP.status = 0
except:
IOP.status = -1
diff --git a/core/src/plugins/filed/python/test/bareosfd_test.py b/core/src/plugins/filed/python/test/bareosfd_test.py
index e0149f6a5..cf14f2091 100644
--- a/core/src/plugins/filed/python/test/bareosfd_test.py
+++ b/core/src/plugins/filed/python/test/bareosfd_test.py
@@ -22,7 +22,10 @@ import bareosfd
import time
import types
-# print dir(bareosfd)
+#print(dir(bareosfd))
+print ("bareosfd.io_status_error: ", bareosfd.io_status_error)
+print ("bareosfd.io_status_core: ", bareosfd.io_status_core)
+print ("bareosfd.io_status_plugin: ", bareosfd.io_status_plugin)
# print "bareosfd.bJobMessageType:", str( bareosfd.bJobMessageType)
# print "bareosfd.bVariable:", str( bareosfd.bVariable)
# print "bareosfd.bEventType:", str( bareosfd.bEventType)
diff --git a/systemtests/tests/py2plug-fd-local-fileset-basic/testrunner b/systemtests/tests/py2plug-fd-local-fileset-basic/testrunner
index 0c25ff013..d0e2a29ba 100755
--- a/systemtests/tests/py2plug-fd-local-fileset-basic/testrunner
+++ b/systemtests/tests/py2plug-fd-local-fileset-basic/testrunner
@@ -36,7 +36,7 @@ setup_data
# using Python3
find ${tmp}/data/weird-files -type l -exec rm {} \;
find tmp/data/weird-files -links +1 -type f -exec rm {} \;
-
+rm tmp/data/weird-files/*utf*
print_debug "$(locale)"
start_test