.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "File::RsyncP::FileIO 3" .TH File::RsyncP::FileIO 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME File::RsyncP::FileIO \- Perl Rsync client file system IO .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use File::RsyncP::FileIO; \& \& my $rs = File::RsyncP\->new({ \& logLevel => 1, \& rsyncCmd => ["/bin/rsh", $host, "\-l", $user, "/bin/rsync"], \& rsyncArgs => [qw( \& \-\-numeric\-ids \& \-\-perms \& \-\-owner \& \-\-group \& \-\-devices \& \-\-links \& \-\-ignore\-times \& \-\-block\-size=700 \& \-\-relative \& \-\-recursive \& \-v \& )], \& logHandler => sub { \& my($str) = @_; \& print MyHandler "log: $str\en"; \& }; \& fio => File::RsyncP::FileIO\->new({ \& logLevel => 1, \& }); \& \& }); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" File::RsyncP::FileIO contains all of the file system access functions needed by File::RsyncP. This functionality is relegated to this module so it can be subclassed or replaced by different code for applications where an rsync interface is provided for non-file system data (eg: databases). .PP File::RsyncP::FileIO provides the following functions. .SS "Setup and utility functions" .IX Subsection "Setup and utility functions" .IP "new({ options... })" 4 .IX Item "new({ options... })" Creates a new File::RsyncP::FileIO object. The single argument is a hashref of options: .RS 4 .IP blockSize 4 .IX Item "blockSize" Defaults to 700. Can be set later using the blockSize function. .IP logLevel 4 .IX Item "logLevel" Defaults to 0. Controls the verbosity of FileIO operations. .IP digest 4 .IX Item "digest" Defaults to File::RsyncP::Digest\->new. No need to override. .IP checksumSeed 4 .IX Item "checksumSeed" The checksum seed used in digest calculations. Defaults to 0. The server-side Rsync generates a checksum seed and sends it to the client. This value is usually set later, after the checksum seed is received from the remote rsync, via the checksumSeed function. .IP logHandler 4 .IX Item "logHandler" A subroutine reference to a function that handles all the log messages. The default is a subroutine that prints the messages to STDERR. .RE .RS 4 .RE .IP blockSize($value) 4 .IX Item "blockSize($value)" Set the block size to the new value, in case it wasn't set via the blockSize option to \fBnew()\fR. .IP checksumSeed($seed) 4 .IX Item "checksumSeed($seed)" Set the checksum seed used in digest calculations to the new value. Usually this value isn't known when \fBnew()\fR is called, so it is necessary to set it later via this function. .IP logHandlerSet 4 .IX Item "logHandlerSet" Set the log handler callback function. Usually this value is specified via \fBnew()\fR, but it can be changed later via this function. .ie n .IP "dirs($localDir, $remoteDir)" 4 .el .IP "dirs($localDir, \f(CW$remoteDir\fR)" 4 .IX Item "dirs($localDir, $remoteDir)" Specify the local and remote directories. .IP log(@msg) 4 .IX Item "log(@msg)" Save one (or more) messages for logging purposes. .IP statsGet 4 .IX Item "statsGet" Return an optional hashref of statistics compiled by the FileIO object. These values are opaquely passed up to File::RsyncP. .IP finish($isChild) 4 .IX Item "finish($isChild)" Do any necessary finish-up processing. The \f(CW$isChild\fR argument is true if this is the child process (remember the receiving side has two processes: the child receives the file deltas while the parent generates the block digests). .SS "Checksum computation functions" .IX Subsection "Checksum computation functions" .ie n .IP "csumStart($f, $needMD4)" 4 .el .IP "csumStart($f, \f(CW$needMD4\fR)" 4 .IX Item "csumStart($f, $needMD4)" Get ready to generate block checksums for the given file. The argument is a hashref typically returned by File::RsyncP::FileList\->get. Typically this opens the underlying file and creates a File::RsyncP::Digest object. If \f(CW$needMD4\fR is non-zero, then \fBcsumEnd()\fR will return the file MD4 digest. .ie n .IP "csumGet($num, $csumLen, $blockSize)" 4 .el .IP "csumGet($num, \f(CW$csumLen\fR, \f(CW$blockSize\fR)" 4 .IX Item "csumGet($num, $csumLen, $blockSize)" Return \f(CW$num\fR bkocks work of checksums with the MD4 checksum length of \&\f(CW$csumLen\fR (typically 2 or 16), with a block size of \f(CW$blockSize\fR. Typically this reads the file and calls File::RsyncP::Digest\->blockDigest. .IP \fBcsumEnd()\fR 4 .IX Item "csumEnd()" Finish up the checksum calculation. Typically closes the underlying file. Note that csumStart, csumGet, csumEnd are called in strict order so they don't need to be reentrant (ie: there is only one csum done at a time). If \fBcsumStart()\fR was called with \f(CW$needMD4\fR then \fBcsumEnd()\fR will return the file MD4 digest. .SS "File reading functions" .IX Subsection "File reading functions" There are used for sending files (currently sending files doesn't implement deltas; it behaves as though \-\-whole\-file was specified): .IP readStart($f) 4 .IX Item "readStart($f)" Get ready to read the given file. The argument is a hashref typically returned by File::RsyncP::FileList\->get. Typically this opens the underlying file. .IP read($num) 4 .IX Item "read($num)" Read \f(CW$num\fR bytes from the file. .IP \fBreadEnd()\fR 4 .IX Item "readEnd()" Finish up the read operation. Typically closes the underlying file. Note that readStart, readGet, readEnd are called in strict order so they don't need to be reentrant (ie: there is only one read done at a time). .SS "File operations" .IX Subsection "File operations" .IP attribGet($f) 4 .IX Item "attribGet($f)" Return the attributes for the given file as a hashref. The argument is a hashref typically returned by File::RsyncP::FileList\->get. .ie n .IP "attribSet($f, $placeHolder)" 4 .el .IP "attribSet($f, \f(CW$placeHolder\fR)" 4 .IX Item "attribSet($f, $placeHolder)" Set the attributes for the given file. The argument is a hashref typically returned by File::RsyncP::FileList\->get. If \f(CW$placeHolder\fR is true then don't do anything. Returns undef on success. .IP makePath($f) 4 .IX Item "makePath($f)" Create the directory specified by \f(CW$f\fR. The argument is a hashref typically returned by File::RsyncP::FileList\->get. Returns undef on success. .IP makeSpecial($f) 4 .IX Item "makeSpecial($f)" Create the special file specified by \f(CW$f\fR. The argument is a hashref typically returned by File::RsyncP::FileList\->get. Returns undef on success. .IP unlink($remotePath) 4 .IX Item "unlink($remotePath)" Unlink the file or directory corresponding to the given remote path. .IP ignoreAttrOnFile($f) 4 .IX Item "ignoreAttrOnFile($f)" Normally should return undef, meaning use the default setting of ignore-times. Otherwise, if this function returns zero or non-zero, the returned value overrides the setting of ignore-times for this file. The argument is a hashref typically returned by File::RsyncP::FileList\->get. See the doPartial option in File::RsyncP\->\fBnew()\fR. .SS "File delta receiving functions" .IX Subsection "File delta receiving functions" These functions are only called when we are receiving files. They are called by the child process. .ie n .IP "fileDeltaRxStart($f, $cnt, $size, $remainder)" 4 .el .IP "fileDeltaRxStart($f, \f(CW$cnt\fR, \f(CW$size\fR, \f(CW$remainder\fR)" 4 .IX Item "fileDeltaRxStart($f, $cnt, $size, $remainder)" Start the receiving of file deltas for file \f(CW$f\fR, a hashref typically returned by File::RsyncP::FileList\->get. The remaining arguments are the number of blocks, size of blocks, and size of the last (partial) block as generated by the parent on the receiving side (they are not the values the new file on the sending side). Returns undef on success. .ie n .IP "fileDeltaRxNext($blk, $newData)" 4 .el .IP "fileDeltaRxNext($blk, \f(CW$newData\fR)" 4 .IX Item "fileDeltaRxNext($blk, $newData)" This function is called repeatedly as the file is constructed. Exactly one of \f(CW$blk\fR and \f(CW$newData\fR are defined. If \f(CW$blk\fR is defined it is an integer that specifies which block of the original file should be written at this point. If \f(CW$newData\fR is defined, it is literal data (that didn't match any blocks) that should be written at this point. .IP fileDeltaRxDone($md4) 4 .IX Item "fileDeltaRxDone($md4)" Finish processing of the file deltas for this file. \f(CW$md4\fR is the MD4 digest of the sent file. It should be compared against the MD4 digest of the reconstructed file. Returns undef on success, 1 if the file's MD4 didn't agree (meaning it should be repeated for phase 2), and negative on error. .SS "File list sending function" .IX Subsection "File list sending function" .ie n .IP "fileListSend($fileList, $outputFunc)" 4 .el .IP "fileListSend($fileList, \f(CW$outputFunc\fR)" 4 .IX Item "fileListSend($fileList, $outputFunc)" Generate the file list (by calling \f(CW$fileList\fR\->encode for every file to be sent) and call the output function \f(CW$outputFunc\fR with the output data by calling .Sp .Vb 1 \& &$outputFunc($fileList\->encodeData); .Ve .SH AUTHOR .IX Header "AUTHOR" File::RsyncP::FileList was written by Craig Barratt based on rsync 2.5.5. .PP Rsync was written by Andrew Tridgell and Paul Mackerras. It is available under a GPL license. See http://rsync.samba.org .SH LICENSE .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. .PP You should have received a copy of the GNU General Public License in the LICENSE file along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111\-1307 USA. .SH "SEE ALSO" .IX Header "SEE ALSO" See for File::RsyncP's SourceForge home page. .PP See File::RsyncP, File::RsyncP::Digest, and File::RsyncP::FileList. .PP Also see BackupPC's lib/BackupPC/Xfer/RsyncFileIO.pm for an example of another implementation of File::RsyncP::FileIO, in fact one that is more tested than the default File::RsyncP::FileIO.pm.