Beispiel #1
0
/* Create a suited redolog header */
void make_redolog_header(redolog_header_t *header, const char* type, Bit64u size)
{
        Bit32u entries, extent_size, bitmap_size;
        Bit64u maxsize;

        // Set standard header values
        strcpy((char*)header->standard.magic, STANDARD_HEADER_MAGIC);
        strcpy((char*)header->standard.type, REDOLOG_TYPE);
        strcpy((char*)header->standard.subtype, type);
        header->standard.version = htod32(STANDARD_HEADER_VERSION);
        header->standard.header = htod32(STANDARD_HEADER_SIZE);

        entries = 512;
        bitmap_size = 1;

        // Compute #entries and extent size values
        do {
                static Bit32u flip=0;

                extent_size = 8 * bitmap_size * 512;

                header->specific.catalog = htod32(entries);
                header->specific.bitmap = htod32(bitmap_size);
                header->specific.extent = htod32(extent_size);
                
                maxsize = (Bit64u)entries * (Bit64u)extent_size;

                flip++;

                if(flip&0x01) bitmap_size *= 2;
                else entries *= 2;
        } while (maxsize < size);

        header->specific.disk = htod64(size);
}
void
mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
    uint64_t dumplen, uint32_t blksz)
{
	bzero(kdh, sizeof(*kdh));
	strncpy(kdh->magic, magic, sizeof(kdh->magic));
	strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
	kdh->version = htod32(KERNELDUMPVERSION);
	kdh->architectureversion = htod32(archver);
	kdh->dumplength = htod64(dumplen);
	kdh->dumptime = htod64(time_second);
	kdh->blocksize = htod32(blksz);
	strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
	strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
	if (panicstr != NULL)
		strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
	kdh->parity = kerneldump_parity(kdh);
}
Beispiel #3
0
void
dumpsys(struct dumperinfo *di)
{
	off_t dumplo;
	vm_offset_t a, addr;
	u_int count, left, u;
	void *va;
	int i, mb;

	printf("Dumping %ld MB\n", Maxmem / (1024*1024 / PAGE_SIZE));

	/* Fill in the kernel dump header */
	strcpy(kdh.magic, KERNELDUMPMAGIC);
	strcpy(kdh.architecture, "alpha");
	kdh.version = htod32(KERNELDUMPVERSION);
	kdh.architectureversion = htod32(KERNELDUMP_ALPHA_VERSION);
	kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE);
	kdh.dumptime = htod64(time_second);
	kdh.blocksize = htod32(di->blocksize);
	strncpy(kdh.hostname, hostname, sizeof kdh.hostname);
	strncpy(kdh.versionstring, version, sizeof kdh.versionstring);
	if (panicstr != NULL)
		strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring);
	kdh.parity = kerneldump_parity(&kdh);

	/*
	 * Check if we will have enough room to save the coredump.
	 * The partition size needed is the sum of:
	 * Memory to save + header + trailer + Room to leave untouched
	 * at partition head. (an arbitrary amount).
	 */
	if (di->mediasize <  
	    Maxmem * (off_t)PAGE_SIZE + sizeof kdh * 2 + 64*1024) {
		printf("\nDump failed. Partition too small.\n");
		return;
	}

	dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE;
	dumplo -= sizeof kdh * 2;
	i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);
	if (i)
		printf("\nDump failed writing header (%d)\n", i);
	dumplo += sizeof kdh;
	i = 0;
	addr = 0;
	va = 0;
	mb = 0;
	for (count = 0; count < Maxmem;) {
		left = Maxmem - count;
		if (left > MAXDUMPPGS)
			left = MAXDUMPPGS;
		for (u = 0; u < left; u++) {
			a = addr + u * PAGE_SIZE;
			if (!is_physical_memory(a))
				a = 0;
			va = pmap_kenter_temporary(trunc_page(a), u);
		}
		i = count / (16*1024*1024 / PAGE_SIZE);
		if (i != mb) {
			printf(" %d", count / (1024 * 1024 / PAGE_SIZE));
			mb = i;
		}
		i = di->dumper(di->priv, va, NULL, dumplo, left * PAGE_SIZE);
		if (i)
			break;
		count += left;
		dumplo += left * PAGE_SIZE;
		addr += left * PAGE_SIZE;
	}
	if (i) 
		printf("\nDump failed writing data (%d)\n", i);
	i = di->dumper(di->priv, &kdh, NULL, dumplo, sizeof kdh);
	if (i)
		printf("\nDump failed writing trailer (%d)\n", i);
	di->dumper(di->priv, NULL, NULL, 0, 0);  /* tell them we are done */
	printf("\nDump complete\n");
	return;
}