Example #1
0
void SpaceMangler::set_top_for_allocations(HeapWord* v)  {
  if (v < end()) {
    assert(!CheckZapUnusedHeapArea || is_mangled(v),
      "The high water mark is not mangled");
  }
  _top_for_allocations = v;
}
Example #2
0
/*
  try to find a 8.3 name in the cache, and if found then
  replace the string with the original long name.
*/
static bool lookup_name_from_8_3(TALLOC_CTX *ctx,
			const char *name,
			char **pp_out, /* talloced on the given context. */
			const struct share_params *p)
{
	unsigned int hash, multiplier;
	unsigned int i;
	char *prefix;
	char extension[4];

	*pp_out = NULL;

	/* make sure that this is a mangled name from this cache */
	if (!is_mangled(name, p)) {
		M_DEBUG(10,("lookup_name_from_8_3: %s -> not mangled\n", name));
		return False;
	}

	/* we need to extract the hash from the 8.3 name */
	hash = base_reverse[(unsigned char)name[7]];
	for (multiplier=36, i=5;i>=mangle_prefix;i--) {
		unsigned int v = base_reverse[(unsigned char)name[i]];
		hash += multiplier * v;
		multiplier *= 36;
	}

	/* now look in the prefix cache for that hash */
	prefix = cache_lookup(ctx, hash);
	if (!prefix) {
		M_DEBUG(10,("lookup_name_from_8_3: %s -> %08X -> not found\n",
					name, hash));
		return False;
	}

	/* we found it - construct the full name */
	if (name[8] == '.') {
		strncpy(extension, name+9, 3);
		extension[3] = 0;
	} else {
		extension[0] = 0;
	}

	if (extension[0]) {
		M_DEBUG(10,("lookup_name_from_8_3: %s -> %s.%s\n",
					name, prefix, extension));
		*pp_out = talloc_asprintf(ctx, "%s.%s", prefix, extension);
	} else {
		M_DEBUG(10,("lookup_name_from_8_3: %s -> %s\n", name, prefix));
		*pp_out = talloc_strdup(ctx, prefix);
	}

	TALLOC_FREE(prefix);

	if (!*pp_out) {
		M_DEBUG(0,("talloc_fail"));
		return False;
	}

	return True;
}
Example #3
0
int
elftc_demangle(const char *mangledname, char *buffer, size_t bufsize,
    unsigned int flags)
{
	int style, rc;
	char *rlt;

	style = flags & 0xFFFF;
	rc = flags >> 16;

	if (mangledname == NULL ||
	    ((style = is_mangled(mangledname, style)) == 0)) {
		errno = EINVAL;
		return (-1);
	}

	if ((rlt = demangle(mangledname, style, rc)) == NULL) {
		errno = EINVAL;
		return (-1);
	}

	if (buffer == NULL || bufsize < strlen(rlt) + 1) {
		free(rlt);
		errno = ENAMETOOLONG;
		return (-1);
	}

	strncpy(buffer, rlt, bufsize);
	buffer[bufsize - 1] = '\0';
	free(rlt);

	return (0);
}
Example #4
0
// Check that top, top_for_allocations and the last
// word of the space are mangled.  In a tight memory
// situation even this light weight mangling could
// cause paging by touching the end of the space.
void  SpaceMangler::check_mangled_unused_area(HeapWord* limit) {
  if (CheckZapUnusedHeapArea) {
    // This method can be called while the spaces are
    // being reshaped so skip the test if the end of the
    // space is beyond the specified limit;
    if (end() > limit) return;

    assert(top() == end() ||
           (is_mangled(top())), "Top not mangled");
    assert((top_for_allocations() < top()) ||
           (top_for_allocations() >= end()) ||
           (is_mangled(top_for_allocations())),
           "Older unused not mangled");
    assert(top() == end() ||
           (is_mangled(end() - 1)), "End not properly mangled");
    // Only does checking when DEBUG_MANGLING is defined.
    check_mangled_unused_area_complete();
  }
}
Example #5
0
/*
  try to find a 8.3 name in the cache, and if found then
  replace the string with the original long name. 
*/
static BOOL check_cache(char *name, size_t maxlen)
{
	u32 hash, multiplier;
	unsigned int i;
	const char *prefix;
	char extension[4];

	/* make sure that this is a mangled name from this cache */
	if (!is_mangled(name)) {
		M_DEBUG(10,("check_cache: %s -> not mangled\n", name));
		return False;
	}

	/* we need to extract the hash from the 8.3 name */
	hash = base_reverse[(unsigned char)name[7]];
	for (multiplier=36, i=5;i>=mangle_prefix;i--) {
		u32 v = base_reverse[(unsigned char)name[i]];
		hash += multiplier * v;
		multiplier *= 36;
	}

	/* now look in the prefix cache for that hash */
	prefix = cache_lookup(hash);
	if (!prefix) {
		M_DEBUG(10,("check_cache: %s -> %08X -> not found\n", name, hash));
		return False;
	}

	/* we found it - construct the full name */
	if (name[8] == '.') {
		strncpy(extension, name+9, 3);
		extension[3] = 0;
	} else {
		extension[0] = 0;
	}

	if (extension[0]) {
		M_DEBUG(10,("check_cache: %s -> %s.%s\n", name, prefix, extension));
		slprintf(name, maxlen, "%s.%s", prefix, extension);
	} else {
		M_DEBUG(10,("check_cache: %s -> %s\n", name, prefix));
		safe_strcpy(name, prefix, maxlen);
	}

	return True;
}
Example #6
0
// This should only be used while debugging the mangling
// because of the high cost of checking the completeness.
void  SpaceMangler::check_mangled_unused_area_complete() {
  if (CheckZapUnusedHeapArea) {
    assert(ZapUnusedHeapArea, "Not mangling unused area");
#ifdef DEBUG_MANGLING
    HeapWord* q = top();
    HeapWord* limit = end();

    bool passed = true;
    while (q < limit) {
      if (!is_mangled(q)) {
        passed = false;
        break;
      }
      q++;
    }
    assert(passed, "Mangling is not complete");
#endif
  }
}
Example #7
0
/*
  try to find a 8.3 name in the cache, and if found then
  return the original long name. 
*/
static char *check_cache(struct pvfs_mangle_context *ctx, 
			 TALLOC_CTX *mem_ctx, const char *name)
{
	uint32_t hash, multiplier;
	unsigned int i;
	const char *prefix;
	char extension[4];

	/* make sure that this is a mangled name from this cache */
	if (!is_mangled(ctx, name)) {
		M_DEBUG(10,("check_cache: %s -> not mangled\n", name));
		return NULL;
	}

	/* we need to extract the hash from the 8.3 name */
	hash = ctx->base_reverse[(unsigned char)name[7]];
	for (multiplier=36, i=5;i>=ctx->mangle_prefix;i--) {
		uint32_t v = ctx->base_reverse[(unsigned char)name[i]];
		hash += multiplier * v;
		multiplier *= 36;
	}

	/* now look in the prefix cache for that hash */
	prefix = cache_lookup(ctx, hash);
	if (!prefix) {
		M_DEBUG(10,("check_cache: %s -> %08X -> not found\n", name, hash));
		return NULL;
	}

	/* we found it - construct the full name */
	if (name[8] == '.') {
		strncpy(extension, name+9, 3);
		extension[3] = 0;
	} else {
		extension[0] = 0;
	}

	if (extension[0]) {
		return talloc_asprintf(mem_ctx, "%s.%s", prefix, extension);
	}

	return talloc_strdup(mem_ctx, prefix);
}