本文整理汇总了C++中check_pool_memory_size函数的典型用法代码示例。如果您正苦于以下问题:C++ check_pool_memory_size函数的具体用法?C++ check_pool_memory_size怎么用?C++ check_pool_memory_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_pool_memory_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: newPlugin
/*
* The following entry points are accessed through the function pointers we supplied to Bareos.
* Each plugin type (dir, fd, sd) has its own set of entry points that the plugin must define.
*
* Create a new instance of the plugin i.e. allocate our private storage
*/
static bRC newPlugin(bpContext *ctx)
{
plugin_ctx *p_ctx;
p_ctx = (plugin_ctx *)malloc(sizeof(plugin_ctx));
if (!p_ctx) {
return bRC_Error;
}
memset(p_ctx, 0, sizeof(plugin_ctx));
ctx->pContext = (void *)p_ctx; /* set our context pointer */
/*
* Allocate some internal memory for:
* - The current working dir.
* - The file we are processing
* - The link target of a symbolic link.
* - The list of xattrs.
*/
p_ctx->cwd = get_pool_memory(PM_FNAME);
p_ctx->next_filename = get_pool_memory(PM_FNAME);
p_ctx->link_target = get_pool_memory(PM_FNAME);
p_ctx->xattr_list = get_pool_memory(PM_MESSAGE);
/*
* Resize all buffers for PATH like names to CEPHFS_PATH_MAX.
*/
p_ctx->cwd = check_pool_memory_size(p_ctx->cwd, CEPHFS_PATH_MAX);
p_ctx->next_filename = check_pool_memory_size(p_ctx->next_filename, CEPHFS_PATH_MAX);
p_ctx->link_target = check_pool_memory_size(p_ctx->link_target, CEPHFS_PATH_MAX);
/*
* This is a alist that holds the stack of directories we have open.
* We push the current directory onto this stack the moment we start
* processing a sub directory and pop it from this list when we are
* done processing that sub directory.
*/
p_ctx->dir_stack = new alist(10, owned_by_alist);
/*
* Only register the events we are really interested in.
*/
bfuncs->registerBareosEvents(ctx,
7,
bEventLevel,
bEventSince,
bEventRestoreCommand,
bEventBackupCommand,
bEventPluginCommand,
bEventEndRestoreJob,
bEventNewPluginOptions);
return bRC_OK;
}
开发者ID:debfx,项目名称:bareos,代码行数:59,代码来源:cephfs-fd.c
示例2: split_path_and_file
/*
* Given a full filename, split it into its path
* and filename parts. They are returned in pool memory
* in the mdb structure.
*/
void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname)
{
const char *p, *f;
/* Find path without the filename.
* I.e. everything after the last / is a "filename".
* OK, maybe it is a directory name, but we treat it like
* a filename. If we don't find a / then the whole name
* must be a path name (e.g. c:).
*/
for (p=f=fname; *p; p++) {
if (IsPathSeparator(*p)) {
f = p; /* set pos of last slash */
}
}
if (IsPathSeparator(*f)) { /* did we find a slash? */
f++; /* yes, point to filename */
} else {
f = p; /* no, whole thing must be path name */
}
/* If filename doesn't exist (i.e. root directory), we
* simply create a blank name consisting of a single
* space. This makes handling zero length filenames
* easier.
*/
mdb->fnl = p - f;
if (mdb->fnl > 0) {
mdb->fname = check_pool_memory_size(mdb->fname, mdb->fnl+1);
memcpy(mdb->fname, f, mdb->fnl); /* copy filename */
mdb->fname[mdb->fnl] = 0;
} else {
mdb->fname[0] = 0;
mdb->fnl = 0;
}
mdb->pnl = f - fname;
if (mdb->pnl > 0) {
mdb->path = check_pool_memory_size(mdb->path, mdb->pnl+1);
memcpy(mdb->path, fname, mdb->pnl);
mdb->path[mdb->pnl] = 0;
} else {
Mmsg1(&mdb->errmsg, _("Path length is zero. File=%s\n"), fname);
Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
mdb->path[0] = 0;
mdb->pnl = 0;
}
Dmsg2(500, "split path=%s file=%s\n", mdb->path, mdb->fname);
}
开发者ID:debfx,项目名称:bareos,代码行数:55,代码来源:sql.c
示例3: do_messages
void do_messages(UAContext *ua, const char *cmd)
{
char msg[2000];
int mlen;
bool do_truncate = false;
Pw(con_lock);
pthread_cleanup_push(con_lock_release, (void *)NULL);
rewind(con_fd);
while (fgets(msg, sizeof(msg), con_fd)) {
mlen = strlen(msg);
ua->UA_sock->msg = check_pool_memory_size(ua->UA_sock->msg, mlen+1);
strcpy(ua->UA_sock->msg, msg);
ua->UA_sock->msglen = mlen;
ua->UA_sock->send();
do_truncate = true;
}
if (do_truncate) {
(void)ftruncate(fileno(con_fd), 0L);
}
console_msg_pending = FALSE;
ua->user_notified_msg_pending = FALSE;
pthread_cleanup_pop(0);
Vw(con_lock);
}
开发者ID:eneuhauss,项目名称:bareos,代码行数:25,代码来源:ua_output.c
示例4: match_kw
/* Match a regexp and add the result to the items list
* This function is recursive
*/
static void match_kw(regex_t *preg, const char *what, int len, POOLMEM **buf)
{
int rc, size;
int nmatch=20;
regmatch_t pmatch[20];
if (len <= 0) {
return;
}
rc = regexec(preg, what, nmatch, pmatch, 0);
if (rc == 0) {
#if 0
Pmsg1(0, "\n\n%s\n0123456789012345678901234567890123456789\n 10 20 30\n", what);
Pmsg2(0, "%i-%i\n", pmatch[0].rm_so, pmatch[0].rm_eo);
Pmsg2(0, "%i-%i\n", pmatch[1].rm_so, pmatch[1].rm_eo);
Pmsg2(0, "%i-%i\n", pmatch[2].rm_so, pmatch[2].rm_eo);
Pmsg2(0, "%i-%i\n", pmatch[3].rm_so, pmatch[3].rm_eo);
#endif
size = pmatch[1].rm_eo - pmatch[1].rm_so;
*buf = check_pool_memory_size(*buf, size + 1);
memcpy(*buf, what+pmatch[1].rm_so, size);
(*buf)[size] = 0;
items->list.append(bstrdup(*buf));
/* We search for the next keyword in the line */
match_kw(preg, what + pmatch[1].rm_eo, len - pmatch[1].rm_eo, buf);
}
}
开发者ID:patito,项目名称:bareos,代码行数:31,代码来源:console.c
示例5: dir_update_file_attributes
/**
* Update File Attribute data
* We do the following:
* 1. expand the bsock buffer to be large enough
* 2. Write a "header" into the buffer with serialized data
* VolSessionId
* VolSeesionTime
* FileIndex
* Stream
* data length that follows
* start of raw byte data from the Device record.
* Note, this is primarily for Attribute data, but can
* also handle any device record. The Director must know
* the raw byte data format that is defined for each Stream.
* Now Restore Objects pass through here STREAM_RESTORE_OBJECT
*/
bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec)
{
JCR *jcr = dcr->jcr;
BSOCK *dir = jcr->dir_bsock;
ser_declare;
#ifdef NO_ATTRIBUTES_TEST
return true;
#endif
dir->msg = check_pool_memory_size(dir->msg, sizeof(FileAttributes) +
MAX_NAME_LENGTH + sizeof(DEV_RECORD) + rec->data_len + 1);
dir->msglen = bsnprintf(dir->msg, sizeof(FileAttributes) +
MAX_NAME_LENGTH + 1, FileAttributes, jcr->Job);
ser_begin(dir->msg + dir->msglen, 0);
ser_uint32(rec->VolSessionId);
ser_uint32(rec->VolSessionTime);
ser_int32(rec->FileIndex);
ser_int32(rec->Stream);
ser_uint32(rec->data_len);
ser_bytes(rec->data, rec->data_len);
dir->msglen = ser_length(dir->msg);
Dmsg1(1800, ">dird %s\n", dir->msg); /* Attributes */
return dir->send();
}
开发者ID:AlD,项目名称:bareos,代码行数:41,代码来源:askdir.c
示例6: pm_strcpy
int pm_strcpy(POOLMEM *&pm, POOL_MEM &str)
{
int len = strlen(str.c_str()) + 1;
pm = check_pool_memory_size(pm, len);
memcpy(pm, str.c_str(), len);
return len - 1;
}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:8,代码来源:mem_pool.c
示例7: split_path_and_filename
static void split_path_and_filename(UAContext *ua, RESTORE_CTX *rx, char *name)
{
char *p, *f;
/* Find path without the filename.
* I.e. everything after the last / is a "filename".
* OK, maybe it is a directory name, but we treat it like
* a filename. If we don't find a / then the whole name
* must be a path name (e.g. c:).
*/
for (p=f=name; *p; p++) {
if (IsPathSeparator(*p)) {
f = p; /* set pos of last slash */
}
}
if (IsPathSeparator(*f)) { /* did we find a slash? */
f++; /* yes, point to filename */
} else { /* no, whole thing must be path name */
f = p;
}
/* If filename doesn't exist (i.e. root directory), we
* simply create a blank name consisting of a single
* space. This makes handling zero length filenames
* easier.
*/
rx->fnl = p - f;
if (rx->fnl > 0) {
rx->fname = check_pool_memory_size(rx->fname, 2*(rx->fnl)+1);
db_escape_string(ua->jcr, ua->db, rx->fname, f, rx->fnl);
} else {
rx->fname[0] = 0;
rx->fnl = 0;
}
rx->pnl = f - name;
if (rx->pnl > 0) {
rx->path = check_pool_memory_size(rx->path, 2*(rx->pnl)+1);
db_escape_string(ua->jcr, ua->db, rx->path, name, rx->pnl);
} else {
rx->path[0] = 0;
rx->pnl = 0;
}
Dmsg2(100, "split path=%s file=%s\n", rx->path, rx->fname);
}
开发者ID:gearsforwork,项目名称:bareos,代码行数:46,代码来源:ua_restore.c
示例8: pm_strcat
int pm_strcat(POOLMEM *&pm, POOL_MEM &str)
{
int pmlen = strlen(pm);
int len = strlen(str.c_str()) + 1;
pm = check_pool_memory_size(pm, pmlen + len);
memcpy(pm+pmlen, str.c_str(), len);
return pmlen + len - 1;
}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:9,代码来源:mem_pool.c
示例9: create_volume_label_record
/*
* create_volume_label_record
* Serialize label (from dev->VolHdr structure) into device record.
* Assumes that the dev->VolHdr structure is properly
* initialized.
*/
static void create_volume_label_record(DCR *dcr, DEVICE *dev, DEV_RECORD *rec)
{
ser_declare;
struct date_time dt;
JCR *jcr = dcr->jcr;
char buf[100];
/* Serialize the label into the device record. */
rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Volume_Label);
ser_begin(rec->data, SER_LENGTH_Volume_Label);
ser_string(dev->VolHdr.Id);
ser_uint32(dev->VolHdr.VerNum);
if (dev->VolHdr.VerNum >= 11) {
ser_btime(dev->VolHdr.label_btime);
dev->VolHdr.write_btime = get_current_btime();
ser_btime(dev->VolHdr.write_btime);
dev->VolHdr.write_date = 0;
dev->VolHdr.write_time = 0;
} else {
/* OLD WAY DEPRECATED */
ser_float64(dev->VolHdr.label_date);
ser_float64(dev->VolHdr.label_time);
get_current_time(&dt);
dev->VolHdr.write_date = dt.julian_day_number;
dev->VolHdr.write_time = dt.julian_day_fraction;
}
ser_float64(dev->VolHdr.write_date); /* 0 if VerNum >= 11 */
ser_float64(dev->VolHdr.write_time); /* 0 if VerNum >= 11 */
ser_string(dev->VolHdr.VolumeName);
ser_string(dev->VolHdr.PrevVolumeName);
ser_string(dev->VolHdr.PoolName);
ser_string(dev->VolHdr.PoolType);
ser_string(dev->VolHdr.MediaType);
ser_string(dev->VolHdr.HostName);
ser_string(dev->VolHdr.LabelProg);
ser_string(dev->VolHdr.ProgVersion);
ser_string(dev->VolHdr.ProgDate);
ser_end(rec->data, SER_LENGTH_Volume_Label);
bstrncpy(dcr->VolumeName, dev->VolHdr.VolumeName, sizeof(dcr->VolumeName));
rec->data_len = ser_length(rec->data);
rec->FileIndex = dev->VolHdr.LabelType;
rec->VolSessionId = jcr->VolSessionId;
rec->VolSessionTime = jcr->VolSessionTime;
rec->Stream = jcr->NumWriteVolumes;
rec->maskedStream = jcr->NumWriteVolumes;
Dmsg2(150, "Created Vol label rec: FI=%s len=%d\n",
FI_to_ascii(buf, rec->FileIndex), rec->data_len);
}
开发者ID:janstadler,项目名称:bareos,代码行数:60,代码来源:label.c
示例10: create_session_label
/*
* Create session label
* The pool memory must be released by the calling program
*/
void create_session_label(DCR *dcr, DEV_RECORD *rec, int label)
{
JCR *jcr = dcr->jcr;
ser_declare;
rec->VolSessionId = jcr->VolSessionId;
rec->VolSessionTime = jcr->VolSessionTime;
rec->Stream = jcr->JobId;
rec->maskedStream = jcr->JobId;
rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Session_Label);
ser_begin(rec->data, SER_LENGTH_Session_Label);
if (me->compatible) {
ser_string(OldBaculaId);
ser_uint32(OldCompatibleBareosTapeVersion1);
} else {
ser_string(BareosId);
ser_uint32(BareosTapeVersion);
}
ser_uint32(jcr->JobId);
/* Changed in VerNum 11 */
ser_btime(get_current_btime());
ser_float64(0);
ser_string(dcr->pool_name);
ser_string(dcr->pool_type);
ser_string(jcr->job_name); /* base Job name */
ser_string(jcr->client_name);
/* Added in VerNum 10 */
ser_string(jcr->Job); /* Unique name of this Job */
ser_string(jcr->fileset_name);
ser_uint32(jcr->getJobType());
ser_uint32(jcr->getJobLevel());
/* Added in VerNum 11 */
ser_string(jcr->fileset_md5);
if (label == EOS_LABEL) {
ser_uint32(jcr->JobFiles);
ser_uint64(jcr->JobBytes);
ser_uint32(dcr->StartBlock);
ser_uint32(dcr->EndBlock);
ser_uint32(dcr->StartFile);
ser_uint32(dcr->EndFile);
ser_uint32(jcr->JobErrors);
/* Added in VerNum 11 */
ser_uint32(jcr->JobStatus);
}
ser_end(rec->data, SER_LENGTH_Session_Label);
rec->data_len = ser_length(rec->data);
}
开发者ID:janstadler,项目名称:bareos,代码行数:58,代码来源:label.c
示例11: unser_volume_label
/* unser_volume_label
*
* Unserialize the Bareos Volume label into the device Volume_Label
* structure.
*
* Assumes that the record is already read.
*
* Returns: false on error
* true on success
*/
bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
{
ser_declare;
char buf1[100], buf2[100];
if (rec->FileIndex != VOL_LABEL && rec->FileIndex != PRE_LABEL) {
Mmsg3(dev->errmsg, _("Expecting Volume Label, got FI=%s Stream=%s len=%d\n"),
FI_to_ascii(buf1, rec->FileIndex),
stream_to_ascii(buf2, rec->Stream, rec->FileIndex),
rec->data_len);
if (!forge_on) {
return false;
}
}
dev->VolHdr.LabelType = rec->FileIndex;
dev->VolHdr.LabelSize = rec->data_len;
/* Unserialize the record into the Volume Header */
rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Volume_Label);
ser_begin(rec->data, SER_LENGTH_Volume_Label);
unser_string(dev->VolHdr.Id);
unser_uint32(dev->VolHdr.VerNum);
if (dev->VolHdr.VerNum >= 11) {
unser_btime(dev->VolHdr.label_btime);
unser_btime(dev->VolHdr.write_btime);
} else { /* old way */
unser_float64(dev->VolHdr.label_date);
unser_float64(dev->VolHdr.label_time);
}
unser_float64(dev->VolHdr.write_date); /* Unused with VerNum >= 11 */
unser_float64(dev->VolHdr.write_time); /* Unused with VerNum >= 11 */
unser_string(dev->VolHdr.VolumeName);
unser_string(dev->VolHdr.PrevVolumeName);
unser_string(dev->VolHdr.PoolName);
unser_string(dev->VolHdr.PoolType);
unser_string(dev->VolHdr.MediaType);
unser_string(dev->VolHdr.HostName);
unser_string(dev->VolHdr.LabelProg);
unser_string(dev->VolHdr.ProgVersion);
unser_string(dev->VolHdr.ProgDate);
ser_end(rec->data, SER_LENGTH_Volume_Label);
Dmsg0(190, "unser_vol_label\n");
if (debug_level >= 190) {
dump_volume_label(dev);
}
return true;
}
开发者ID:janstadler,项目名称:bareos,代码行数:63,代码来源:label.c
示例12: strlen
accurate_payload *B_ACCURATE_LMDB::lookup_payload(JCR *jcr, char *fname)
{
int result;
int lstat_length;
MDB_val key, data;
accurate_payload *payload = NULL;
key.mv_data = fname;
key.mv_size = strlen(fname) + 1;
result = mdb_get(m_db_ro_txn, m_db_dbi, &key, &data);
switch (result) {
case 0:
/*
* Success.
*
* We need to make a private copy of the LDMB data as we are not
* allowed to change its content and we need to update the lstat
* and chksum pointer to point to the actual lstat and chksum that
* is stored behind the accurate_payload structure in the LMDB.
*/
m_pay_load = check_pool_memory_size(m_pay_load, data.mv_size);
payload = (accurate_payload *)m_pay_load;
memcpy(payload, data.mv_data, data.mv_size);
payload->lstat = (char *)payload + sizeof(accurate_payload);
lstat_length = strlen(payload->lstat);
payload->chksum = (char *)payload->lstat + lstat_length + 1;
/*
* We keep the transaction as short a possible so after a lookup
* and copying the actual data out we reset the read transaction
* and do a renew of the read transaction for a new run.
*/
mdb_txn_reset(m_db_ro_txn);
result = mdb_txn_renew(m_db_ro_txn);
if (result != 0) {
Jmsg1(jcr, M_FATAL, 0, _("Unable to renew read transaction: %s\n"), mdb_strerror(result));
return NULL;
}
break;
case MDB_NOTFOUND:
/*
* Failed to find the given key.
*/
break;
default:
break;
}
return payload;
}
开发者ID:AlD,项目名称:bareos,代码行数:52,代码来源:accurate_lmdb.c
示例13: add_str
/*
* Add a character to the current string
*/
static void add_str(LEX *lf, int ch)
{
/*
* The default config string is sized to 256 bytes.
* If we need longer config strings its increased with 256 bytes each time.
*/
if ((lf->str_len + 3) >= lf->str_max_len) {
lf->str = check_pool_memory_size(lf->str, lf->str_max_len + 256);
lf->str_max_len = sizeof_pool_memory(lf->str);
}
lf->str[lf->str_len++] = ch;
lf->str[lf->str_len] = 0;
}
开发者ID:gearsforwork,项目名称:bareos,代码行数:17,代码来源:lex.c
示例14: db_add_digest_to_file_record
/* Update the attributes record by adding the file digest */
bool db_add_digest_to_file_record(JCR *jcr, B_DB *mdb,
FileId_t FileId,
char *digest, int type)
{
bool retval;
char ed1[50];
int len = strlen(digest);
db_lock(mdb);
mdb->esc_name = check_pool_memory_size(mdb->esc_name, len*2+1);
mdb->db_escape_string(jcr, mdb->esc_name, digest, len);
Mmsg(mdb->cmd, "UPDATE File SET MD5='%s' WHERE FileId=%s", mdb->esc_name,
edit_int64(FileId, ed1));
retval = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return retval;
}
开发者ID:NilByMouth,项目名称:bareos,代码行数:18,代码来源:sql_update.c
示例15: unser_session_label
bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec)
{
ser_declare;
rec->data = check_pool_memory_size(rec->data, SER_LENGTH_Session_Label);
unser_begin(rec->data, SER_LENGTH_Session_Label);
unser_string(label->Id);
unser_uint32(label->VerNum);
unser_uint32(label->JobId);
if (label->VerNum >= 11) {
unser_btime(label->write_btime);
} else {
unser_float64(label->write_date);
}
unser_float64(label->write_time);
unser_string(label->PoolName);
unser_string(label->PoolType);
unser_string(label->JobName);
unser_string(label->ClientName);
if (label->VerNum >= 10) {
unser_string(label->Job); /* Unique name of this Job */
unser_string(label->FileSetName);
unser_uint32(label->JobType);
unser_uint32(label->JobLevel);
}
if (label->VerNum >= 11) {
unser_string(label->FileSetMD5);
} else {
label->FileSetMD5[0] = 0;
}
if (rec->FileIndex == EOS_LABEL) {
unser_uint32(label->JobFiles);
unser_uint64(label->JobBytes);
unser_uint32(label->StartBlock);
unser_uint32(label->EndBlock);
unser_uint32(label->StartFile);
unser_uint32(label->EndFile);
unser_uint32(label->JobErrors);
if (label->VerNum >= 11) {
unser_uint32(label->JobStatus);
} else {
label->JobStatus = JS_Terminated; /* kludge */
}
}
return true;
}
开发者ID:janstadler,项目名称:bareos,代码行数:46,代码来源:label.c
示例16: sizeof_pool_memory
/*
* BAREOS's implementation of fgets(). The difference is that it handles
* being interrupted by a signal (e.g. a SIGCHLD) and it has a
* different calling sequence which implements input lines of
* up to a million characters.
*/
char *bfgets(POOLMEM *&s, FILE *fd)
{
int ch;
int soft_max;
int i = 0;
s[0] = 0;
soft_max = sizeof_pool_memory(s) - 10;
for ( ;; ) {
do {
errno = 0;
ch = fgetc(fd);
} while (ch == EOF && ferror(fd) && (errno == EINTR || errno == EAGAIN));
if (ch == EOF) {
if (i == 0) {
return NULL;
} else {
return s;
}
}
if (i > soft_max) {
/* Insanity check */
if (soft_max > 1000000) {
return s;
}
s = check_pool_memory_size(s, soft_max+10000);
soft_max = sizeof_pool_memory(s) - 10;
}
s[i++] = ch;
s[i] = 0;
if (ch == '\r') { /* Support for Mac/Windows file format */
ch = fgetc(fd);
if (ch != '\n') { /* Mac (\r only) */
(void)ungetc(ch, fd); /* Push next character back to fd */
}
s[i-1] = '\n';
break;
}
if (ch == '\n') {
break;
}
}
return s;
}
开发者ID:pstray,项目名称:bareos,代码行数:50,代码来源:bsys.c
示例17: db_update_ndmp_level_mapping
/**
* Update NDMP level mapping
*
* Returns: false on failure
* true on success
*/
bool db_update_ndmp_level_mapping(JCR *jcr, B_DB *mdb, JOB_DBR *jr, char *filesystem, int level)
{
bool retval;
char ed1[50], ed2[50], ed3[50];
db_lock(mdb);
mdb->esc_name = check_pool_memory_size(mdb->esc_name, strlen(filesystem) * 2 + 1);
db_escape_string(jcr, mdb, mdb->esc_name, filesystem, strlen(filesystem));
Mmsg(mdb->cmd,
"UPDATE NDMPLevelMap SET DumpLevel='%s' WHERE "
"ClientId='%s' AND FileSetId='%s' AND FileSystem='%s'",
edit_uint64(level, ed1), edit_uint64(jr->ClientId, ed2),
edit_uint64(jr->FileSetId, ed3), mdb->esc_name);
retval = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return retval;
}
开发者ID:NilByMouth,项目名称:bareos,代码行数:27,代码来源:sql_update.c
示例18: open_bootstrap_file
/*
* Open the bootstrap file and find the first Storage=
* Returns ok if able to open
*
* It fills the storage name (should be the first line)
* and the file descriptor to the bootstrap file,
* it should be used for next operations, and need to be
* closed at the end.
*/
bool open_bootstrap_file(JCR *jcr, bootstrap_info &info)
{
FILE *bs;
UAContext *ua;
info.bs = NULL;
info.ua = NULL;
if (!jcr->RestoreBootstrap) {
return false;
}
bstrncpy(info.storage, jcr->res.rstore->name(), MAX_NAME_LENGTH);
bs = fopen(jcr->RestoreBootstrap, "rb");
if (!bs) {
berrno be;
Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
jcr->RestoreBootstrap, be.bstrerror());
jcr->setJobStatus(JS_ErrorTerminated);
return false;
}
ua = new_ua_context(jcr);
ua->cmd = check_pool_memory_size(ua->cmd, UA_CMD_SIZE + 1);
while (!fgets(ua->cmd, UA_CMD_SIZE, bs)) {
parse_ua_args(ua);
if (ua->argc != 1) {
continue;
}
if (bstrcasecmp(ua->argk[0], "Storage")) {
bstrncpy(info.storage, ua->argv[0], MAX_NAME_LENGTH);
break;
}
}
info.bs = bs;
info.ua = ua;
fseek(bs, 0, SEEK_SET); /* return to the top of the file */
return true;
}
开发者ID:aussendorf,项目名称:bareos,代码行数:47,代码来源:bsr.c
示例19: decompress_with_zlib
static bool decompress_with_zlib(JCR *jcr,
const char *last_fname,
char **data,
uint32_t *length,
bool sparse,
bool with_header,
bool want_data_stream)
{
char ec1[50]; /* Buffer printing huge values */
uLong compress_len;
const unsigned char *cbuf;
char *wbuf;
int status, real_compress_len;
/*
* NOTE! We only use uLong and Byte because they are
* needed by the zlib routines, they should not otherwise
* be used in Bareos.
*/
if (sparse && want_data_stream) {
wbuf = jcr->compress.inflate_buffer + OFFSET_FADDR_SIZE;
compress_len = jcr->compress.inflate_buffer_size - OFFSET_FADDR_SIZE;
} else {
wbuf = jcr->compress.inflate_buffer;
compress_len = jcr->compress.inflate_buffer_size;
}
/*
* See if this is a compressed stream with the new compression header or an old one.
*/
if (with_header) {
cbuf = (const unsigned char*)*data + sizeof(comp_stream_header);
real_compress_len = *length - sizeof(comp_stream_header);
} else {
cbuf = (const unsigned char*)*data;
real_compress_len = *length;
}
Dmsg2(400, "Comp_len=%d msglen=%d\n", compress_len, *length);
while ((status = uncompress((Byte *)wbuf, &compress_len, (const Byte *)cbuf, (uLong)real_compress_len)) == Z_BUF_ERROR) {
/*
* The buffer size is too small, try with a bigger one
*/
jcr->compress.inflate_buffer_size = jcr->compress.inflate_buffer_size + (jcr->compress.inflate_buffer_size >> 1);
jcr->compress.inflate_buffer = check_pool_memory_size(jcr->compress.inflate_buffer, jcr->compress.inflate_buffer_size);
if (sparse && want_data_stream) {
wbuf = jcr->compress.inflate_buffer + OFFSET_FADDR_SIZE;
compress_len = jcr->compress.inflate_buffer_size - OFFSET_FADDR_SIZE;
} else {
wbuf = jcr->compress.inflate_buffer;
compress_len = jcr->compress.inflate_buffer_size;
}
Dmsg2(400, "Comp_len=%d msglen=%d\n", compress_len, *length);
}
if (status != Z_OK) {
Qmsg(jcr, M_ERROR, 0, _("Uncompression error on file %s. ERR=%s\n"), last_fname, zlib_strerror(status));
return false;
}
/*
* We return a decompressed data stream with the fileoffset encoded when this was a sparse stream.
*/
if (sparse && want_data_stream) {
memcpy(jcr->compress.inflate_buffer, *data, OFFSET_FADDR_SIZE);
}
*data = jcr->compress.inflate_buffer;
*length = compress_len;
Dmsg2(400, "Write uncompressed %d bytes, total before write=%s\n", compress_len, edit_uint64(jcr->JobBytes, ec1));
return true;
}
开发者ID:AlD,项目名称:bareos,代码行数:76,代码来源:compression.c
示例20: update_attribute
/*
* Note, we receive the whole attribute record, but we select out only the stat
* packet, VolSessionId, VolSessionTime, FileIndex, file type, and file name to
* store in the catalog.
*/
static void update_attribute(JCR *jcr, char *msg, int32_t msglen)
{
unser_declare;
uint32_t VolSessionId, VolSessionTime;
int32_t Stream;
uint32_t FileIndex;
char *p;
int len;
char *fname, *attr;
ATTR_DBR *ar = NULL;
uint32_t reclen;
/*
* Start transaction allocates jcr->attr and jcr->ar if needed
*/
db_start_transaction(jcr, jcr->db); /* start transaction if not already open */
ar = jcr->ar;
/*
* Start by scanning directly in the message buffer to get Stream
* there may be a cached attr so we cannot yet write into
* jcr->attr or jcr->ar
*/
p = msg;
skip_nonspaces(&p); /* UpdCat */
skip_spaces(&p);
skip_nonspaces(&p); /* Job=nnn */
skip_spaces(&p);
skip_nonspaces(&p); /* "FileAttributes" */
p += 1;
/*
* The following "SD header" fields are serialized
*/
unser_begin(p, 0);
unser_uint32(VolSessionId); /* VolSessionId */
unser_uint32(VolSessionTime); /* VolSessionTime */
unser_int32(FileIndex); /* FileIndex */
unser_int32(Stream); /* Stream */
unser_uint32(reclen); /* Record length */
p += unser_length(p); /* Raw record follows */
/**
* At this point p points to the raw record, which varies according
* to what kind of a record (Stream) was sent. Note, the integer
* fields at the beginning of these "raw" records are in ASCII with
* spaces between them so one can use scanf or manual scanning to
* extract the fields.
*
* File Attributes
* File_index
* File type
* Filename (full path)
* Encoded attributes
* Link name (if type==FT_LNK or FT_LNKSAVED)
* Encoded extended-attributes (for Win32)
* Delta sequence number (32 bit int)
*
* Restore Object
* File_index
* File_type
* Object_index
* Object_len (possibly compressed)
* Object_full_len (not compressed)
* Object_compression
* Plugin_name
* Object_name
* Binary Object data
*/
Dmsg1(400, "UpdCat msg=%s\n", msg);
Dmsg5(400, "UpdCat VolSessId=%d VolSessT=%d FI=%d Strm=%d reclen=%d\n",
VolSessionId, VolSessionTime, FileIndex, Stream, reclen);
jcr->SDJobBytes += reclen; /* update number of bytes transferred for quotas */
/*
* Depending on the stream we are handling dispatch.
*/
switch (Stream) {
case STREAM_UNIX_ATTRIBUTES:
case STREAM_UNIX_ATTRIBUTES_EX:
if (jcr->cached_attribute) {
Dmsg2(400, "Cached attr. Stream=%d fname=%s\n", ar->Stream, ar->fname);
if (!db_create_attributes_record(jcr, jcr->db, ar)) {
Jmsg1(jcr, M_FATAL, 0, _("Attribute create error: ERR=%s"), db_strerror(jcr->db));
}
jcr->cached_attribute = false;
}
/*
* Any cached attr is flushed so we can reuse jcr->attr and jcr->ar
*/
jcr->attr = check_pool_memory_size(jcr->attr, msglen);
memcpy(jcr->attr, msg, msglen);
//.........这里部分代码省略.........
开发者ID:NilByMouth,项目名称:bareos,代码行数:101,代码来源:catreq.c
注:本文中的check_pool_memory_size函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论