From: Larry McVoy <lm@bitmover.com>
To: linux-kernel@vger.kernel.org
Subject: Re: help with next generation bkbits please
Date: Mon, 20 Sep 2004 18:25:36 -0700 [thread overview]
Message-ID: <20040921012536.GA17088@work.bitmover.com> (raw)
In-Reply-To: <20040921012208.GA16008@work.bitmover.com>
Forgot memory scrubber, here it is.
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#define unless(x) if (!(x))
#define u32 unsigned int
#define status(s) write(1, s, 1); newline = 1;
int newline;
void doit(u32 bs);
int
main(int ac, char **av)
{
if (ac != 2) {
printf("Usage: %s amount_in_MB\n", av[0]);
exit(0);
}
doit(atoi(av[1])<<20);
return (0);
}
void
bad(u32 *start, u32 *p, u32 want)
{
u32 off = (char*)p - (char*)start;
u32 got = *p;
if (newline) printf("\n");
newline = 0;
printf("WANT=0x%08x GOT=0x%08x DIFF=0x%08x OFF=0x%08x ADDR=%p\n",
want, got, want - got, off, (void*)p);
}
void
doit(u32 bs)
{
u32 *buf = malloc(bs);
u32 *end;
u32 *p;
u32 off;
fprintf(stderr, "Scrub %u bytes\n", bs);
unless (buf) {
perror("malloc");
exit(1);
}
end = (u32*)((char*)buf + bs);
bzero(buf, bs);
unless (sizeof(int) == 4) {
fprintf(stderr, "Expected 4 byte ints\n");
exit(1);
}
for (off = 0, p = buf; p < end; *p++ = off, off += 4);
for (;;) {
for (off = 0, p = buf; p < end; off += 4) {
if (*p != off) bad(buf, p, off);
*p++ = 0xdeadbeef;
}
status("d");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0xdeadbeef) bad(buf, p, 0xdeadbeef);
*p++ = 0x50505050;
}
status("5");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0x50505050) bad(buf, p, 0x50505050);
*p++ = 0x0a0a0a0a;
}
status("a");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0x0a0a0a0a) bad(buf, p, 0x0a0a0a0a);
*p++ = 0x55555555;
}
status("-");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0x55555555) bad(buf, p, 0x55555555);
*p++ = 0xaaaaaaaa;
}
status("A");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0xaaaaaaaa) bad(buf, p, 0xaaaaaaaa);
*p++ = 0x0;
}
status("0");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0x0) bad(buf, p, 0);
*p++ = 0xffffffff;
}
status("f");
for (off = 0, p = buf; p < end; off += 4) {
if (*p != 0xffffffff) bad(buf, p, 0xffffffff);
*p++ = off;
}
status("o");
}
}
next prev parent reply other threads:[~2004-09-21 1:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-21 1:22 help with next generation bkbits please Larry McVoy
2004-09-21 1:25 ` Larry McVoy [this message]
2004-09-21 8:13 ` Denis Vlasenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040921012536.GA17088@work.bitmover.com \
--to=lm@bitmover.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox