当前位置: 首页>>代码示例>>C++>>正文


C++ ViceLog函数代码示例

本文整理汇总了C++中ViceLog函数的典型用法代码示例。如果您正苦于以下问题:C++ ViceLog函数的具体用法?C++ ViceLog怎么用?C++ ViceLog使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ViceLog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fs_stateMapFile

static int
fs_stateMapFile(struct fs_dump_state * state, int preserve_flag )
{
    int ret = 0, flags;

    switch(state->mode) {
    case FS_STATE_LOAD_MODE:
	flags = PROT_READ | PROT_WRITE;   /* loading involves a header invalidation */
	break;
    case FS_STATE_DUMP_MODE:
	flags = PROT_WRITE;
	break;
    default:
	ViceLog(0, ("fs_stateMapFile: invalid dump state mode\n"));
	return 1;
    }

    state->mmap.map = afs_mmap(NULL,
			       state->file_len,
			       flags,
			       MAP_SHARED,
			       state->fd,
			       0);

    if (state->mmap.map == MAP_FAILED) {
	state->mmap.size = 0;
	state->mmap.map = NULL;
	ViceLog(0, ("fs_stateMapFile: failed to memory map file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    state->mmap.size = state->file_len;
    state->mmap.cursor = state->mmap.map;

    if (preserve_flag) {
	/* don't lose track of where we are during a file resize */
	afs_foff_t curr_offset = state->mmap.offset;

	state->mmap.offset = 0;
	fs_stateIncCursor(state, curr_offset);
    } else {		/* reset offset */
	state->mmap.offset = 0;
    }
    /* for state loading, accesses will be sequential, so let's give
     * the VM subsystem a heads up */
    if (state->mode == FS_STATE_LOAD_MODE) {
	/* XXX madvise may not exist on all platforms, so
	 * we may need to add some ifdefs at some point... */
	flags = MADV_SEQUENTIAL | MADV_WILLNEED;
#ifdef AFS_SUN510_ENV
	flags |= MADV_ACCESS_LWP;   /* added in solaris 9 12/02 */
#endif
	madvise(state->mmap.map, state->mmap.size, flags);
    }

 done:
    return ret;
}
开发者ID:adeason,项目名称:openafs,代码行数:60,代码来源:serialize_state.c

示例2: fs_stateWrite

int
fs_stateWrite(struct fs_dump_state * state,
	      void * buf, size_t len)
{
    int ret = 0;

#ifdef FS_STATE_USE_MMAP
    if (fs_stateCheckIOSafety(state, len)) {
	if (fs_stateResizeFile(state, len)) {
	    ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n",
			state->fn));
	    ret = 1;
	    goto done;
	}
    }

    memcpy(state->mmap.cursor, buf, len);
    fs_stateIncCursor(state, len);
#else
    if (write(state->fd, buf, len) != len) {
	ViceLog(0, ("fs_stateWrite: write failed\n"));
	ret = 1;
	goto done;
    }
#endif

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:29,代码来源:serialize_state.c

示例3: ReallyWrite

/* returns 0 on success, errno on failure */
int
ReallyWrite(DirHandle * file, int block, char *data)
{
    ssize_t count;
    FdHandle_t *fdP;
    afs_ino_str_t stmp;

    fdP = IH_OPEN(file->dirh_handle);
    if (fdP == NULL) {
	ViceLog(0,
		("ReallyWrite(): open failed device %X inode %s errno %d\n",
		 file->dirh_handle->ih_dev, PrintInode(stmp,
						       file->dirh_handle->
						       ih_ino), errno));
	lpErrno = errno;
	return 0;
    }
    if ((count = FDH_PWRITE(fdP, data, PAGESIZE, ((afs_foff_t)block) * PAGESIZE)) != PAGESIZE) {
	ViceLog(0,
		("ReallyWrite(): write failed device %X inode %s errno %d\n",
		 file->dirh_handle->ih_dev, PrintInode(stmp,
						       file->dirh_handle->
						       ih_ino), errno));
	lpCount = count;
	lpErrno = errno;
	FDH_REALLYCLOSE(fdP);
	return 0;
    }
    FDH_CLOSE(fdP);
    return 0;
}
开发者ID:sanchit-matta,项目名称:openafs,代码行数:32,代码来源:physio.c

示例4: fs_stateReadV

int
fs_stateReadV(struct fs_dump_state * state,
	      struct iovec * iov, int niov)
{
    int i, ret = 0;
    size_t len = 0;

    for (i=0; i < niov; i++) {
	len += iov[i].iov_len;
    }

#ifdef FS_STATE_USE_MMAP
    if (fs_stateCheckIOSafety(state, len)) {
	ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    for (i=0; i < niov; i++) {
	memcpy(iov[i].iov_base, state->mmap.cursor, iov[i].iov_len);
	fs_stateIncCursor(state, iov[i].iov_len);
    }
#else
    if (readv(state->fd, iov, niov) != len) {
	ViceLog(0, ("fs_stateReadV: read failed\n"));
	ret = 1;
	goto done;
    }
#endif

 done:
    return ret;
}
开发者ID:stevenjenkins,项目名称:openafs,代码行数:34,代码来源:serialize_state.c

示例5: fs_stateRead

int
fs_stateRead(struct fs_dump_state * state,
	     void * buf, size_t len)
{
    int ret = 0;

#ifdef FS_STATE_USE_MMAP
    if (fs_stateCheckIOSafety(state, len)) {
	ViceLog(0, ("fs_stateRead: read beyond EOF for dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    memcpy(buf, state->mmap.cursor, len);
    fs_stateIncCursor(state, len);
#else
    if (read(state->fd, buf, len) != len) {
	ViceLog(0, ("fs_stateRead: read failed\n"));
	ret = 1;
	goto done;
    }
#endif

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:27,代码来源:serialize_state.c

示例6: fs_stateInvalidateDump

static int
fs_stateInvalidateDump(struct fs_dump_state * state)
{
    afs_uint64 z;
    int ret = 0;
    struct fs_state_header hdr;

#ifdef FS_STATE_USE_MMAP
    if (state->mmap.map == NULL) {
	return 1;
    }
#endif

    memcpy(&hdr, state->hdr, sizeof(hdr));
    hdr.valid = 0;
    ZeroInt64(z);

    /* write a bogus header to flag dump in progress */
    if (fs_stateWriteHeader(state, &z, &hdr, sizeof(hdr))) {
	ViceLog(0, ("fs_stateInvalidateDump: failed to invalidate old dump file header '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }
    if (fs_stateSync(state)) {
	ViceLog(0, ("fs_stateInvalidateDump: failed to sync changes to disk\n"));
	ret = 1;
	goto done;
    }

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:33,代码来源:serialize_state.c

示例7: fs_stateResizeFile

static int
fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
{
    int ret = 0;
    afs_foff_t inc;

    fs_stateUnmapFile(state);

    inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
    state->file_len += inc;

    if (afs_ftruncate(state->fd, state->file_len) != 0) {
	ViceLog(0, ("fs_stateResizeFile: truncate failed\n"));
	ret = 1;
	goto done;
    }

    if (fs_stateMapFile(state)) {
	ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
	ret = 1;
	goto done;
    }

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:26,代码来源:serialize_state.c

示例8: _VVGC_UnlinkHeader

/**
 * unlink a faulty volume header found by VWalkVolumeHeaders.
 *
 * @param[in] dp   the disk partition (unused)
 * @param[in] name the full path to the .vol header
 * @param[in] hdr  the header data (unused)
 * @param[in] rock unused
 */
static void
_VVGC_UnlinkHeader(struct DiskPartition64 *dp, const char *name,
                   struct VolumeDiskHeader *hdr, void *rock)
{
    ViceLog(0, ("%s is not a legitimate volume header file; deleted\n", name));
    if (unlink(name)) {
	ViceLog(0, ("Unable to unlink %s (errno = %d)\n",
	            name, errno));
    }
}
开发者ID:adeason,项目名称:openafs,代码行数:18,代码来源:vg_scan.c

示例9: fs_stateLoadDump

static int
fs_stateLoadDump(struct fs_dump_state * state)
{
    afs_uint64 z;
    int fd, ret = 0;
    struct afs_stat status;
    afs_int32 now = FT_ApproxTime();

    ZeroInt64(z);

    if ((fd = afs_open(state->fn, O_RDWR)) == -1 ||
	(afs_fstat(fd, &status) == -1)) {
	ViceLog(0, ("fs_stateLoadDump: failed to load state dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }
    state->fd = fd;
    state->mode = FS_STATE_LOAD_MODE;
    state->file_len = status.st_size;

#ifdef FS_STATE_USE_MMAP
    if (fs_stateMapFile(state)) {
	ViceLog(0, ("fs_stateLoadDump: failed to memory map state dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }
#endif

    if (fs_stateReadHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
	ViceLog(0, ("fs_stateLoadDump: failed to read header from dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    /* check the validity of the header */
    if (fs_stateCheckHeader(state->hdr)) {
	ViceLog(1, ("fs_stateLoadDump: header failed validity checks; not restoring '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    if ((state->hdr->timestamp + HOST_STATE_VALID_WINDOW) >= now) {
	state->flags.do_host_restore = 1;
    } else {
	ViceLog(0, ("fs_stateLoadDump: warning: dump is too old for host and callback restore; skipping those steps\n"));
    }

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:54,代码来源:serialize_state.c

示例10: DebugOn

static void*
DebugOn(void *param)
{
    int loglevel = (intptr_t)param;
    if (loglevel == 0) {
	ViceLog(0, ("Reset Debug levels to 0\n"));
    } else {
	ViceLog(0, ("Set Debug On level = %d\n", loglevel));
    }
    return 0;
}				/*DebugOn */
开发者ID:sanchit-matta,项目名称:openafs,代码行数:11,代码来源:serverLog.c

示例11: fs_stateCommitDump

static int
fs_stateCommitDump(struct fs_dump_state * state)
{
    afs_uint64 z;
    int ret = 0;

    ZeroInt64(z);

#ifdef FS_STATE_USE_MMAP
    if (fs_stateTruncateFile(state)) {
	ViceLog(0, ("fs_stateCommitDump: failed to truncate dump file to proper size\n"));
	ret = 1;
	goto done;
    }
#endif

    /* ensure that all pending data I/Os for the state file have been committed
     * _before_ we make the metadata I/Os */
    if (fs_stateSync(state)) {
	ViceLog(0, ("fs_stateCommitDump: failed to sync changes to disk\n"));
	ret = 1;
	goto done;
    }

#ifdef FS_STATE_USE_MMAP
    /* XXX madvise may not exist on all platforms, so
     * we may need to add some ifdefs at some point... */
    {
	madvise((((char *)state->mmap.map) + sizeof(struct fs_state_header)),
		state->mmap.size - sizeof(struct fs_state_header),
		MADV_DONTNEED);
    }
#endif

    /* build the header, and write it to disk */
    fs_stateFillHeader(state->hdr);
    if (state->bail) {
	state->hdr->valid = 0;
    }
    if (fs_stateWriteHeader(state, &z, state->hdr, sizeof(struct fs_state_header))) {
	ViceLog(0, ("fs_stateCommitDump: failed to write header to dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }
    if (fs_stateSync(state)) {
	ViceLog(0, ("fs_stateCommitDump: failed to sync new header to disk\n"));
	ret = 1;
	goto done;
    }

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:54,代码来源:serialize_state.c

示例12: do_eval_policy

static afs_int32 do_eval_policy( unsigned int policyIndex, afs_uint64 size,
		    char *fileName, afs_int32 (*evalclient)(void*, afs_int32), void *client,
		     afs_uint32 *props)
{
    osddb_policy *pol = get_pol(policyIndex);
    afs_int32 tcode;
    int r;

    if ( !pol ) {
	ViceLog(0, ("failed to lookup policy %d\n", policyIndex));
	return ENOENT;
    }

    for ( r = 0 ; r < pol->rules.pol_ruleList_len ; r++ ) {
	pol_rule rule = pol->rules.pol_ruleList_val[r];
	int matched = 1;
	if ( rule.used_policy ) {
	    ViceLog(2, ("recursively evaluating policy %d\n", rule.used_policy));
	    tcode = do_eval_policy(
	    		rule.used_policy, size, fileName, evalclient, client, props);
	    ViceLog(2, ("recursion done, props are now 0x%x\n", *props));
	    if ( ( tcode && tcode != ENOENT ) || POLPROP_FORCE(*props) )
		return tcode;
	}
	else {
	    tcode = eval_condtree(&rule.condition, size, fileName, 
				    evalclient, client, &matched);
	    if ( tcode == EINVAL ) {
		ViceLog(0, ("policy %d may contain unknown predicate type\n",
								policyIndex));
	    }
	    if ( tcode )
		return tcode;
	    if ( matched ) {
		ViceLog(2, ("updating: props 0x%x with 0x%x\n", *props, rule.properties));
		UPDATE(POLPROP_LOCATION, POLICY_LOCATION_MASK);
		UPDATE(POLPROP_NSTRIPES, POLICY_NSTRIPES_MASK);
		UPDATE(POLPROP_SSTRIPES, POLICY_SSTRIPES_MASK);
		UPDATE(POLPROP_NCOPIES, POLICY_NCOPIES_MASK);
		UPDATE(POLPROP_FORCE, POLICY_CONT_OP_MASK);
		if ( POLPROP_FORCE(rule.properties) ) {
		    TRACE_POLICY(2);
		    return 0;
		}
	    }
	}
    }

    TRACE_POLICY(2);
    return 0;
}
开发者ID:kcbehler,项目名称:openafs-osd,代码行数:51,代码来源:osddbpolicy.c

示例13: fs_stateCheckHeader

static int
fs_stateCheckHeader(struct fs_state_header * hdr)
{
    int ret = 0;

    if (!hdr->valid) {
	ViceLog(0, ("fs_stateCheckHeader: dump was previously flagged invalid\n"));
	ret = 1;
    }
#ifdef WORDS_BIGENDIAN
    else if (!hdr->endianness) {
	ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
	ret = 1;
    }
#else /* AFSLITTLE_ENDIAN */
    else if (hdr->endianness) {
	ViceLog(0, ("fs_stateCheckHeader: wrong endianness\n"));
	ret = 1;
    }
#endif /* AFSLITTLE_ENDIAN */

    else if (hdr->stamp.magic != FS_STATE_MAGIC) {
	ViceLog(0, ("fs_stateCheckHeader: invalid dump header\n"));
	ret = 1;
    }
    else if (hdr->stamp.version != FS_STATE_VERSION) {
	ViceLog(0, ("fs_stateCheckHeader: unknown dump format version number\n"));
	ret = 1;
    }

    else if (!hdr->stats_detailed) {
	ViceLog(0, ("fs_stateCheckHeader: wrong config flags\n"));
	ret = 1;
    }

    else if (!afs_uuid_equal(&hdr->server_uuid, &FS_HostUUID)) {
	ViceLog(0, ("fs_stateCheckHeader: server UUID does not match this server's UUID\n"));
	ret = 1;
    }

    /* the cml_version_string is included for informational purposes only.  If someone ever
     * wants to limit state dump reloading based upon the contents of this string, just
     * uncomment the following code.  uncommenting this code is _strongly discouraged_ because
     * we already make use of the version stamps in the various dump headers to deal with
     * data structure version incompatabilities.
    else if (strncmp(hdr->server_version_string, cml_version_number,
		     sizeof(hdr->server_version_string)) != 0) {
	ViceLog(0, ("fs_stateCheckHeader: dump from different server version\n"));
	ret = 1;
    }
    */

    else if (strncmp(hdr->server_version_string, cml_version_number,
		     sizeof(hdr->server_version_string)) != 0) {
	ViceLog(0, ("fs_stateCheckHeader: dump from different server version ; attempting state reload anyway\n"));
    }


    return ret;
}
开发者ID:bagdxk,项目名称:openafs,代码行数:60,代码来源:serialize_state.c

示例14: fs_stateCreateDump

static int
fs_stateCreateDump(struct fs_dump_state * state)
{
    int fd, ret = 0;
    char savedump[MAXPATHLEN];
    struct afs_stat status;

    afs_snprintf(savedump, sizeof(savedump), "%s.old", state->fn);

    if (afs_stat(state->fn, &status) == 0) {
	renamefile(state->fn, savedump);
    }

    if (((fd = afs_open(state->fn,
			O_RDWR | O_CREAT | O_TRUNC,
			S_IRUSR | S_IWUSR)) == -1) ||
	(afs_fstat(fd, &status) == -1)) {
	ViceLog(0, ("fs_stateCreateDump: failed to create state dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    state->fd = fd;
    state->mode = FS_STATE_DUMP_MODE;
    memset(state->hdr, 0, sizeof(struct fs_state_header));
    fs_stateIncEOF(state, sizeof(struct fs_state_header));

#ifdef FS_STATE_USE_MMAP
    if (fs_stateSizeFile(state)) {
	ViceLog(0, ("fs_stateCreateDump: failed to resize state dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }

    if (fs_stateMapFile(state)) {
	ViceLog(0, ("fs_stateCreateDump: failed to memory map state dump file '%s'\n",
		    state->fn));
	ret = 1;
	goto done;
    }
#endif

    ret = fs_stateInvalidateDump(state);

 done:
    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:49,代码来源:serialize_state.c

示例15: fs_stateFillHeader

static int
fs_stateFillHeader(struct fs_state_header * hdr)
{
    hdr->stamp.magic = FS_STATE_MAGIC;
    hdr->stamp.version = FS_STATE_VERSION;
#ifdef SYS_NAME_ID
    hdr->sys_name = SYS_NAME_ID;
#else
    hdr->sys_name = 0xFFFFFFFF;
#endif
    hdr->timestamp = FT_ApproxTime();
    hdr->server_uuid = FS_HostUUID;
    hdr->valid = 1;
#ifdef WORDS_BIGENDIAN
    hdr->endianness = 1;
#else
    hdr->endianness = 0;
#endif
#ifdef FS_STATS_DETAILED
    hdr->stats_detailed = 1;
#else
    hdr->stats_detailed = 0;
#endif
    if (strlcpy(hdr->server_version_string, cml_version_number, sizeof(hdr->server_version_string))
	>= sizeof(hdr->server_version_string)) {
	ViceLog(0, ("fs_stateFillHeader: WARNING -- cml_version_number field truncated\n"));
    }
    return 0;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:29,代码来源:serialize_state.c


注:本文中的ViceLog函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。