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; }
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; }
/* 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; }
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; }
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; }
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; }
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; }
/** * 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)); } }
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; }
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 */
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; }
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; }
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; }
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; }
/** * add an entry to the hash table. * * @param[in] dp disk partition object * @param[in] volid volume id * @param[in] ent volume group object * @param[out] hash_out address in which to store pointer to hash entry * * @pre VOL_LOCK held * * @return operation status * @retval 0 success * @retval EEXIST hash entry for volid already exists, and it points to * a different VG entry * * @internal */ static int _VVGC_hash_entry_add(struct DiskPartition64 * dp, VolumeId volid, VVGCache_entry_t * ent, VVGCache_hash_entry_t ** hash_out) { int code = 0; VVGCache_hash_entry_t * hent; int hash = VVGC_HASH(volid); VVGCache_entry_t *nent; code = _VVGC_lookup(dp, volid, &nent, hash_out); if (!code) { if (ent != nent) { ViceLog(0, ("_VVGC_hash_entry_add: tried to add a duplicate " " nonmatching entry for vol %lu: original " "(%"AFS_PTR_FMT",%lu) new (%"AFS_PTR_FMT",%lu)\n", afs_printable_uint32_lu(volid), nent, afs_printable_uint32_lu(nent->rw), ent, afs_printable_uint32_lu(ent->rw))); return EEXIST; } ViceLog(1, ("_VVGC_hash_entry_add: tried to add duplicate " "hash entry for vol %lu, VG %lu", afs_printable_uint32_lu(volid), afs_printable_uint32_lu(ent->rw))); /* accept attempts to add matching duplicate entries; just * pretend we added it */ return 0; } code = _VVGC_hash_entry_alloc(&hent); if (code) { goto done; } hent->entry = ent; hent->dp = dp; hent->volid = volid; queue_Append(&VVGCache_hash_table.hash_buckets[hash], hent); done: if (hash_out) { *hash_out = hent; } return code; }
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; }
struct pol_info *make_pol_info(osddb_policy *pol, afs_uint32 id, char *name, struct pol_info *dest) { int r; if ( !dest ) { /* osd calls without allocating space */ dest = malloc(sizeof(struct pol_info)); memset(dest, 0, sizeof(struct pol_info)); } dest->pol = malloc(sizeof(osddb_policy)); *dest->pol = *pol; for ( r = 0 ; r < pol->rules.pol_ruleList_len ; r++ ) { pol_rule *rule = &pol->rules.pol_ruleList_val[r]; if ( rule->condition.type == POLCOND_TRUE ) continue; annotate_condition(dest, &rule->condition); } dest->id = id; if ( dest->uses_file_name ) ViceLog(1, ("policy %d needs file names\n", id)); strncpy(dest->name, name, OSDDB_MAXNAMELEN-1); return dest; }
static int convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_uint32 *myHost, afs_uint32 *serverList) { int i; char hostname[64]; struct hostent *th; /* get this host */ gethostname(hostname, sizeof(hostname)); th = gethostbyname(hostname); if (!th) { ViceLog(0, ("kaserver: couldn't get address of this host.\n")); exit(1); } memcpy(myHost, th->h_addr, sizeof(afs_uint32)); for (i = 0; i < cellinfo->numServers; i++) if (cellinfo->hostAddr[i].sin_addr.s_addr != *myHost) { /* omit my host from serverList */ *serverList++ = cellinfo->hostAddr[i].sin_addr.s_addr; } *serverList = 0; /* terminate list */ return 0; }
/** * flush all cache entries for a given disk partition. * * @param[in] part disk partition object * * @pre VOL_LOCK held * * @return operation status * @retval 0 success * * @internal */ int _VVGC_flush_part_r(struct DiskPartition64 * part) { int code = 0, res; int i; VVGCache_hash_entry_t * ent, * nent; for (i = 0; i < VolumeHashTable.Size; i++) { for (queue_Scan(&VVGCache_hash_table.hash_buckets[i], ent, nent, VVGCache_hash_entry)) { if (ent->dp == part) { VolumeId volid = ent->volid; res = _VVGC_hash_entry_del(ent); if (res) { ViceLog(0, ("_VVGC_flush_part_r: error %d deleting hash entry for %lu\n", res, afs_printable_uint32_lu(volid))); code = res; } } } } return code; }
int fs_stateWriteV(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)) { if (fs_stateResizeFile(state, len)) { ViceLog(0, ("fs_stateWrite: could not resize dump file '%s'\n", state->fn)); ret = 1; goto done; } } for (i=0; i < niov; i++) { memcpy(state->mmap.cursor, iov[i].iov_base, iov[i].iov_len); fs_stateIncCursor(state, iov[i].iov_len); } #else #ifndef AFS_NT40_ENV if (writev(state->fd, iov, niov) != len) { ViceLog(0, ("fs_stateWriteV: write failed\n")); ret = 1; goto done; } #else /* AFS_NT40_ENV */ for (i=0; i < niov; i++) { if (write(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) { ViceLog(0, ("fs_stateWriteV: write failed\n")); ret = 1; goto done; } } #endif /* AFS_NT40_ENV */ #endif done: return ret; }
/** * put back a reference to an entry. * * @param[in] dp disk partition object * @param[in] entry cache entry * * @pre VOL_LOCK held * * @warning do not attempt to deref pointer after calling this interface * * @return operation status * @retval 0 success * * @note dp is needed to lookup the RW hash entry to unlink, if we are * putting back the final reference and freeing * * @internal */ static int _VVGC_entry_put(struct DiskPartition64 * dp, VVGCache_entry_t * entry) { int code = 0; osi_Assert(entry->refcnt > 0); if (--entry->refcnt == 0) { VVGCache_entry_t *nentry; VVGCache_hash_entry_t *hentry; /* first, try to delete the RW id hash entry pointing to this * entry */ code = _VVGC_lookup(dp, entry->rw, &nentry, &hentry); if (!code) { if (nentry != entry) { /* looking up the rw of this entry points to a different * entry; should not happen */ ViceLog(0, ("VVGC_entry_put: error: entry lookup for entry %lu " "found different entry than was passed", afs_printable_uint32_lu(entry->rw))); code = -1; } else { code = _VVGC_hash_entry_unlink(hentry); hentry = NULL; } } else if (code == ENOENT) { /* ignore ENOENT; this shouldn't happen, since the RW hash * entry should always exist if the entry does... but we * were going to delete it anyway, so try to continue */ ViceLog(0, ("VVGC_entry_put: warning: tried to unlink entry for " "vol %lu, but RW hash entry doesn't exist; continuing " "anyway...\n", afs_printable_uint32_lu(entry->rw))); code = 0; } /* now, just free the entry itself */ if (!code) { code = _VVGC_entry_free(entry); } } return code; }
/* returns 0 on success, errno on failure */ int ReallyRead(DirHandle * file, int block, char *data) { int code; FdHandle_t *fdP; fdP = IH_OPEN(file->dirh_handle); if (fdP == NULL) { code = errno; ViceLog(0, ("ReallyRead(): open failed device %X inode %s errno %d\n", file->dirh_handle->ih_dev, PrintInode(NULL, file->dirh_handle-> ih_ino), code)); return code; } if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) { code = errno; ViceLog(0, ("ReallyRead(): lseek failed device %X inode %s errno %d\n", file->dirh_handle->ih_dev, PrintInode(NULL, file->dirh_handle-> ih_ino), code)); FDH_REALLYCLOSE(fdP); return code; } code = FDH_READ(fdP, data, PAGESIZE); if (code != PAGESIZE) { if (code < 0) code = errno; else code = EIO; ViceLog(0, ("ReallyRead(): read failed device %X inode %s errno %d\n", file->dirh_handle->ih_dev, PrintInode(NULL, file->dirh_handle-> ih_ino), code)); FDH_REALLYCLOSE(fdP); return code; } FDH_CLOSE(fdP); return 0; }
void FillPolicyTable(void) { struct OsdList l; afs_int32 code; afs_uint32 db_revision; if (!osddb_client) { #ifdef BUILDING_CLIENT_COMMAND osddb_client = init_osddb_client(cellPtr, 0); #else osddb_client = init_osddb_client(NULL); #endif if (!osddb_client) return; } code = ubik_Call((int(*)(struct rx_connection*,...))OSDDB_GetPoliciesRevision, osddb_client, 0, &db_revision); if (code == RXGEN_OPCODE) code = ubik_Call((int(*)(struct rx_connection*,...))OSDDB_GetPoliciesRevision68, osddb_client, 0, &db_revision); if ( code ) { ViceLog(0, ("failed to query for policy revision, error %d\n", code)); return; } ViceLog(1, ("OSDDB policy revision: %d, local revision: %d\n", db_revision, policies_revision)); if ( db_revision == policies_revision ) return; l.OsdList_len = 0; l.OsdList_val = 0; code = ubik_Call((int(*)(struct rx_connection*,...))OSDDB_PolicyList, osddb_client, 0, &l); if (code == RXGEN_OPCODE) code = ubik_Call((int(*)(struct rx_connection*,...))OSDDB_PolicyList66, osddb_client, 0, &l); if (!code) { buildPolicyIndex(&l); /* the very policy structures are in the new index now */ if ( l.OsdList_val) free(l.OsdList_val); OSDDB_LOCK; policies_revision = db_revision; OSDDB_UNLOCK; } }
void free_policy(struct osddb_policy *policy) { int r; XDR xdr; for ( r = 0 ; r < policy->rules.pol_ruleList_len ; r++ ) free_regexes(&policy->rules.pol_ruleList_val[r].condition); xdrmem_create(&xdr, NULL, 0, XDR_FREE); if ( !xdr_osddb_policy(&xdr, policy) ) ViceLog(0, ("XDR_FREE of policy at 0x%p failed\n", policy)); }
void kalog_Init(void) { OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */ SetupLogSignals(); kalog_db = dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT, KALOG_DB_MODE); if (!kalog_db) ViceLog(0, ("Cannot open dbm database - no DB logging possible\n")); }
/*@printflike@*/ void Abort(const char *format, ...) { va_list args; ViceLog(0, ("Program aborted: ")); va_start(args, format); vViceLog(0, (format, args)); va_end(args); abort(); }
/** * add a volid to the entry's child list. * * @param[in] ent volume group object * @param[in] volid volume id * * @return operation status * @retval 0 success * @retval -1 child table is full * * @internal */ static int _VVGC_entry_cl_add(VVGCache_entry_t * ent, VolumeId volid) { int code = 0, i; int empty_idx = -1; /* search table to avoid duplicates */ for (i = 0; i < VOL_VG_MAX_VOLS; i++) { if (ent->children[i] == volid) { ViceLog(1, ("VVGC_entry_cl_add: tried to add duplicate vol " "%lu to VG %lu\n", afs_printable_uint32_lu(volid), afs_printable_uint32_lu(ent->rw))); goto done; } if (empty_idx == -1 && !ent->children[i]) { empty_idx = i; /* don't break; make sure we go through all children so we don't * add a duplicate entry */ } } /* verify table isn't full */ if (empty_idx == -1) { code = -1; ViceLog(0, ("VVGC_entry_cl_add: tried to add vol %lu to VG %lu, but VG " "is full\n", afs_printable_uint32_lu(volid), afs_printable_uint32_lu(ent->rw))); goto done; } /* add entry */ ent->children[empty_idx] = volid; /* inc refcount */ code = _VVGC_entry_get(ent); done: return code; }
/* returns 0 on success, errno on failure */ int ReallyWrite(DirHandle * file, int block, char *data) { afs_int32 count; FdHandle_t *fdP; 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(NULL, file->dirh_handle-> ih_ino), errno)); lpErrno = errno; return 0; } if (FDH_SEEK(fdP, block * PAGESIZE, SEEK_SET) < 0) { ViceLog(0, ("ReallyWrite(): lseek failed device %X inode %s errno %d\n", file->dirh_handle->ih_dev, PrintInode(NULL, file->dirh_handle-> ih_ino), errno)); lpErrno = errno; FDH_REALLYCLOSE(fdP); return 0; } if ((count = FDH_WRITE(fdP, data, PAGESIZE)) != PAGESIZE) { ViceLog(0, ("ReallyWrite(): write failed device %X inode %s errno %d\n", file->dirh_handle->ih_dev, PrintInode(NULL, file->dirh_handle-> ih_ino), errno)); lpCount = count; lpErrno = errno; FDH_REALLYCLOSE(fdP); return 0; } FDH_CLOSE(fdP); return 0; }
/*! * Write the single-DES deprecation warning to the log. */ void LogDesWarning(void) { /* The blank newlines help this stand out a bit more in the log. */ ViceLog(0, ("\n")); ViceLog(0, ("WARNING: You are using single-DES keys in a KeyFile. Using single-DES\n")); ViceLog(0, ("WARNING: long-term keys is considered insecure, and it is strongly\n")); ViceLog(0, ("WARNING: recommended that you migrate to stronger encryption. See\n")); ViceLog(0, ("WARNING: OPENAFS-SA-2013-003 on http://www.openafs.org/security/\n")); ViceLog(0, ("WARNING: for details.\n")); ViceLog(0, ("\n")); }
int fs_stateReadHeader(struct fs_dump_state * state, afs_uint64 * offset, void * hdr, size_t len) { int ret = 0; if (fs_stateSeek(state, offset)) { ViceLog(0, ("fs_stateReadHeader: could not seek to correct position in dump file '%s'\n", state->fn)); ret = 1; goto done; } if (fs_stateRead(state, hdr,len)) { ViceLog(0, ("fs_stateReadHeader: read failed\n")); ret = 1; goto done; } done: return ret; }