/* Need the following definitions to avoid linking with ds_*.o and their link
dependencies */
datasink_t datasink_archive;
datasink_t datasink_xbstream;
datasink_t datasink_compress;
datasink_t datasink_tmpfile;
static int
get_options(int *argc, char ***argv)
{ int ho_error;
if ((ho_error= handle_options(argc, argv, my_long_options,
get_one_option)))
{ exit(EXIT_FAILURE);
}
return0;
}
static void
usage(void)
{
print_version();
puts("Copyright (C) 2011-2013 Percona LLC and/or its affiliates.");
puts("This software comes with ABSOLUTELY NO WARRANTY. " "This is free software,\nand you are welcome to modify and " "redistribute it under the GPL license.\n");
puts("Serialize/deserialize files in the XBSTREAM format.\n");
puts("Usage: ");
printf(" %s -c [OPTIONS...] FILES... # stream specified files to " "standard output.\n", my_progname);
printf(" %s -x [OPTIONS...] # extract files from the stream" "on the standard input.\n", my_progname);
pthread_mutex_lock(ctxt->mutex);
res = xb_stream_read_chunk(ctxt->stream, &chunk);
if (res != XB_STREAM_READ_CHUNK) {
pthread_mutex_unlock(ctxt->mutex); break;
}
/* If unknown type and ignorable flag is set, skip this chunk */ if (chunk.type == XB_CHUNK_TYPE_UNKNOWN && \
!(chunk.flags & XB_STREAM_FLAG_IGNORABLE)) {
pthread_mutex_unlock(ctxt->mutex); continue;
}
/* See if we already have this file open */
entry = (file_entry_t *) my_hash_search(ctxt->filehash,
(uchar *) chunk.path,
chunk.pathlen);
if (entry && (chunk.type == XB_CHUNK_TYPE_REMOVE ||
chunk.type == XB_CHUNK_TYPE_RENAME)) {
msg("%s: rename and remove chunks can not be applied to opened file: %s",
my_progname, chunk.path);
pthread_mutex_unlock(ctxt->mutex); break;
}
if (chunk.type == XB_CHUNK_TYPE_REMOVE) { if (ds_remove(ctxt->ds_ctxt, chunk.path)) {
msg("%s: error on file removing: %s", my_progname, chunk.path);
pthread_mutex_unlock(ctxt->mutex);
res = XB_STREAM_READ_ERROR; break;
}
pthread_mutex_unlock(ctxt->mutex); continue;
}
if (chunk.type == XB_CHUNK_TYPE_RENAME) { if (my_hash_search(ctxt->filehash, reinterpret_cast<const uchar *>(chunk.data), chunk.length)) {
msg("%s: rename chunks can not be applied to opened file: %s",
my_progname, reinterpret_cast<const uchar *>(chunk.data));
pthread_mutex_unlock(ctxt->mutex); break;
} if (ds_rename(ctxt->ds_ctxt, chunk.path, reinterpret_cast<constchar *>(chunk.data))) {
msg("%s: error on file renaming: %s to %s", my_progname, reinterpret_cast<constchar *>(chunk.data), chunk.path);
pthread_mutex_unlock(ctxt->mutex);
res = XB_STREAM_READ_ERROR; break;
}
pthread_mutex_unlock(ctxt->mutex); continue;
}
if (entry->offset != chunk.offset) {
msg("%s: out-of-order chunk: real offset = 0x%llx, " "expected offset = 0x%llx", my_progname,
chunk.offset, entry->offset);
pthread_mutex_unlock(&entry->mutex);
res = XB_STREAM_READ_ERROR; break;
}
if (ds_write(entry->file, chunk.data, chunk.length)) {
msg("%s: my_write() failed.", my_progname);
pthread_mutex_unlock(&entry->mutex);
res = XB_STREAM_READ_ERROR; break;
}
entry->offset += chunk.length;
pthread_mutex_unlock(&entry->mutex);
}
if (chunk.data)
my_free(chunk.data);
my_thread_end();
return (void *)(res);
}
static int
mode_extract(int n_threads, int argc __attribute__((unused)), char **argv __attribute__((unused)))
{
xb_rstream_t *stream = NULL;
HASH filehash;
ds_ctxt_t *ds_ctxt = NULL;
extract_ctxt_t ctxt; int i;
pthread_t *tids = NULL; void **retvals = NULL;
pthread_mutex_t mutex; int ret = 0;
if (my_hash_init(PSI_NOT_INSTRUMENTED, &filehash, &my_charset_bin,
START_FILE_HASH_SIZE, 0, 0, get_file_entry_key,
file_entry_free, MYF(0)))
{
msg("%s: failed to initialize file hash.", my_progname); return1;
}
if (pthread_mutex_init(&mutex, NULL)) {
msg("%s: failed to initialize mutex.", my_progname);
my_hash_free(&filehash); return1;
}
/* If --directory is specified, it is already set as CWD by now. */
ds_ctxt = ds_create(".", DS_TYPE_LOCAL); if (ds_ctxt == NULL) {
ret = 1; gotoexit;
}
stream = xb_stream_read_new(); if (stream == NULL) {
msg("%s: xb_stream_read_new() failed.", my_progname);
pthread_mutex_destroy(&mutex);
ret = 1; gotoexit;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.