Re: [dm-devel] More dm-crypt patches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Sa, den 03.01.2004 schrieb Joe Thornber um 11:47:

> > I've folded my last changes on dm-crypt into a patchset (like Joe does).
> 
> Excellent, this makes my job a lot easier.  I presume you found the
> 'pm' tool on my webpage ?

Yes, I've seen that, looks nice. But I actually didn't use it for this.
I did play a lot with the source and kept some copies from time to time.
I then used these copies to track my changes and clean them up.

Sometimes I find out that I've got very long shell commands in my bash
history (which grow over time) and I then decide to turm them into a
useful script. I always had some that dealt with your patchsets and so I
ended up with my own little tool. ;)

Well, keeping a copy of the whole kernel around for every change isn't
really an option. I'll always use what comes in handy.

BTW: If you're interested in a tool that creates large BIOs, I've
attached a small test program that uses Direct-IO. It doesn't actually
write something useful, just some random memory.

bio-test <device> <sector> [<offset>]

If you use it on top of a striped target with large and odd sector
numbers and offsets you'll end up having all kind of BIOs, not just the
usual page sized ones with only a single bvec.

#define _GNU_SOURCE
#define _FILE_OFFSET_BITS	64

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <errno.h>

#define SECTOR_SHIFT	9

int main(int argc, char **argv)
{
	int f, r;
	unsigned long size;
	unsigned long bufsize;
	unsigned int pagesize;
	off_t offset;
	char *endptr;
	char *buffer;

	if (argc < 3)
		return 1;

	size = strtol(argv[2], &endptr, 10);
	if (*endptr || !size || size > 4096)
		return 1;
	size <<= SECTOR_SHIFT;
	bufsize = (size + pagesize - 1) & ~(pagesize - 1);

	if (argc >= 4) {
		offset = (off_t)strtoll(argv[3], &endptr, 10);
		if (*endptr)
			return 1;
		offset <<= SECTOR_SHIFT;
	} else
		offset = 0;

	f = open(argv[1], O_WRONLY | O_DIRECT | O_SYNC);
	if (f < 0) {
		perror("fopen");
		return 1;
	}

	if (offset) {
		if (lseek(f, offset, SEEK_SET) != offset) {
			perror("lseek");
			return 1;
		}
	}

	buffer = mmap(NULL, bufsize, PROT_READ | PROT_WRITE,
	              MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
	if (!buffer) {
		perror("mmap");
		close(f);
		return 1;
	}

	r = write(f, buffer, size);

	munmap(buffer, bufsize);
	close(f);

	if (r < 0) {
		perror("write");
		return 1;
	}

	printf("Result: %d\n", r);

	return 0;
}

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux