mirror of
https://github.com/Thesola10/umd-livepatch.git
synced 2025-04-18 21:43:22 +00:00
figuring out librsync API
This commit is contained in:
parent
721789813d
commit
78e8bcc861
6
patch.c
6
patch.c
@ -1,16 +1,16 @@
|
||||
#include "io_funcs.h"
|
||||
#include "patch.h"
|
||||
|
||||
lp_UMDiffCommand cmd_buffer[CMD_BUFFER_SIZE];
|
||||
umdiff_Command cmd_buffer[CMD_BUFFER_SIZE];
|
||||
|
||||
lp_UMDiffFile
|
||||
umdiff_File
|
||||
lp_PatchSet_open(const char *path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
lp_PatchSet_covered(lp_UMDiffCommand *ps, u32 offset)
|
||||
lp_PatchSet_covered(umdiff_Command *ps, u32 offset)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,24 @@
|
||||
|
||||
#include "usage.rl.h"
|
||||
|
||||
int
|
||||
umdiff_delta(char *source, char *target, char *output)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
umdiff_patch(char *source, char *umdiff, char *output)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
umdiff_fromRdiff(char *rdiff, char *output)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int res;
|
||||
@ -25,6 +43,13 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (opts.delta)
|
||||
return umdiff_delta(opts.source_file, opts.target_file, opts.output_file);
|
||||
else if (opts.patch)
|
||||
return umdiff_patch(opts.source_file, opts.umdiff_file, opts.output_file);
|
||||
else if (opts.fromrdiff)
|
||||
return umdiff_fromRdiff(opts.rdiff_file, opts.output_file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,67 @@
|
||||
* and convert it in-memory into the UMDiff format.
|
||||
*/
|
||||
|
||||
#include "umdiff.h"
|
||||
|
||||
#include <librsync.h>
|
||||
|
||||
#define ISO_SECTOR_SIZE 2048
|
||||
|
||||
typedef union {
|
||||
int fd;
|
||||
void *opaque;
|
||||
} _impl_umdiff_OpaqueFd;
|
||||
|
||||
rs_signature_t *workSignatures;
|
||||
|
||||
rs_result
|
||||
_impl_umdiff_sigJobSink(rs_job_t *job, rs_buffers_t *buf, void *dest)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
rs_result
|
||||
_impl_umdiff_sigJobSource(rs_job_t *job, rs_buffers_t *buf, void *fd_)
|
||||
{
|
||||
_impl_umdiff_OpaqueFd fd = { .opaque = fd_ };
|
||||
}
|
||||
|
||||
rs_result
|
||||
_impl_umdiff_deltaJobSink(rs_job_t *job, rs_buffers_t *buf, void *unk)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
rs_result
|
||||
_impl_umdiff_deltaJobSource(rs_job_t *job, rs_buffers_t *buf, void *fd_)
|
||||
{
|
||||
_impl_umdiff_OpaqueFd fd = { .opaque = fd_ };
|
||||
}
|
||||
|
||||
|
||||
umdiff_File *
|
||||
umdiff_File_fromCompare(int source_fd, int target_fd)
|
||||
{
|
||||
_impl_umdiff_OpaqueFd source_fd_ = { .fd = source_fd };
|
||||
_impl_umdiff_OpaqueFd target_fd_ = { .fd = target_fd };
|
||||
umdiff_File *resultFile;
|
||||
|
||||
rs_buffers_t buffers;
|
||||
rs_job_t *sigJob, *deltaJob;
|
||||
|
||||
sigJob = rs_sig_begin(ISO_SECTOR_SIZE,
|
||||
RS_DEFAULT_MIN_STRONG_LEN,
|
||||
RS_RK_BLAKE2_SIG_MAGIC);
|
||||
deltaJob = rs_delta_begin(workSignatures);
|
||||
|
||||
rs_job_drive(sigJob, &buffers,
|
||||
_impl_umdiff_sigJobSource, source_fd_.opaque,
|
||||
_impl_umdiff_sigJobSink, workSignatures);
|
||||
rs_job_drive(deltaJob, &buffers,
|
||||
_impl_umdiff_deltaJobSource, target_fd_.opaque,
|
||||
_impl_umdiff_deltaJobSink, resultFile);
|
||||
|
||||
return resultFile;
|
||||
}
|
||||
|
||||
// vim: ft=c.doxygen
|
||||
|
@ -25,16 +25,27 @@
|
||||
* Pointers spanning past the end of the disc are undefined and shall not be
|
||||
* used.
|
||||
*/
|
||||
typedef long lp_UMDiffIndex[2048];
|
||||
typedef long umdiff_CmdIndex[1024];
|
||||
|
||||
/**
|
||||
* @brief UMDiff file header structure.
|
||||
*
|
||||
* This is the format for a UMDiff file header. The commands index is included,
|
||||
* as with the constrained memory of the PSP, reading the index in full is
|
||||
* mandatory.
|
||||
*
|
||||
* With the tradeoff of an O(n) space and O(n) time conversion process on PC,
|
||||
* we gain a worst-case patch application process in O(1) space and O(log(n))
|
||||
* time on PSP.
|
||||
*/
|
||||
typedef struct
|
||||
__attribute__((packed)) {
|
||||
char magic[7]; /* = 0x7f 'UMDiff' */
|
||||
char version;
|
||||
long cmd_len;
|
||||
long data_start;
|
||||
lp_UMDiffIndex index;
|
||||
} lp_UMDiffHeader;
|
||||
umdiff_CmdIndex index;
|
||||
} umdiff_Header;
|
||||
|
||||
/**
|
||||
* @brief Definition for a single patch command.
|
||||
@ -62,15 +73,15 @@ typedef struct {
|
||||
long patch_sector_count; /* if < sector_count, repeat */
|
||||
|
||||
long data_source; /* 0 = patchfile, 1 = source */
|
||||
} lp_UMDiffCommand;
|
||||
} umdiff_Command;
|
||||
|
||||
// Commands shall start immediately after the full header
|
||||
#define UMDIFF_COMMANDS_START (sizeof lp_UMDiffHeader)
|
||||
|
||||
typedef struct {
|
||||
lp_UMDiffHeader *hdr;
|
||||
lp_UMDiffCommand *commands;
|
||||
} lp_UMDiffFile;
|
||||
umdiff_Header *hdr;
|
||||
umdiff_Command *commands;
|
||||
} umdiff_File;
|
||||
|
||||
#endif //__UMDIFF_H
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user