# HG changeset patch # User John Tsiombikas # Date 1323179637 -7200 # Node ID 4ef83db5f4cd9185f17610963d60c3677af6b960 # Parent 8b92b0c1c220755d588187f71ef9675c1734f7a9 foo diff -r 8b92b0c1c220 -r 4ef83db5f4cd mkdiskimg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mkdiskimg Tue Dec 06 15:53:57 2011 +0200 @@ -0,0 +1,39 @@ +#!/bin/sh + +# mkdiskimg - prepare a disk image for the kernel +# usage: mkdiskimg [size in mb, default: 40] + +imgfile=disk.img +if [ -e $imgfile ]; then + echo "file '$imgfile' exists, will not overwrite, delete it first" >&2 + exit 1 +fi + +if [ -n "$1" ]; then + sizemb=$1 +else + sizemb=40 +fi + +# create the image file +echo 'creating image file ...' +dd if=/dev/zero of=$imgfile bs=1M count=$sizemb || exit 1 + +# create partition table +if ! sfdisk --version | grep linux; then + echo "failed to find the linux sfdisk program." + echo "please install it, or create a partition on the disk image ($imgfile) manually." + exit 0 +fi + +echo 'creating partition table with a single partition ...' +sfdisk -q $imgfile <&2 + exit 1 +fi + +echo +echo 'done. happy hacking!' diff -r 8b92b0c1c220 -r 4ef83db5f4cd src/ata.c --- a/src/ata.c Tue Dec 06 13:45:32 2011 +0200 +++ b/src/ata.c Tue Dec 06 15:53:57 2011 +0200 @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include "ata.h" @@ -126,8 +127,8 @@ read_data(dev, info); /* print model and serial */ - printf("- found ata drive (%d,%d): %s\n", dev->iface, dev->id, atastr(textbuf, info + 27, 40)); - printf(" s/n: %s\n", atastr(textbuf, info + 10, 20)); + printf("ata%d: %s", (dev->iface << 1) | dev->id, atastr(textbuf, info + 27, 40)); + printf(" [s/n: %s]", atastr(textbuf, info + 10, 20)); dev->nsect_lba = *(uint32_t*)(info + 60); dev->nsect_lba48 = *(uint64_t*)(info + 100) & 0xffffffffffffull; @@ -143,7 +144,7 @@ } else { size_str(dev->nsect_lba, textbuf); } - printf(" size: %s\n", textbuf); + printf(" size: %s\n", textbuf); free(info); return 0; @@ -237,7 +238,9 @@ *dptr++ = (*sptr & 0xff00) >> 8; *dptr++ = *sptr++ & 0xff; } - *dptr = 0; + + while(isspace(*--dptr)); + *++dptr = 0; return res; }