diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-11-23 19:28:40 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-11-23 19:28:40 +0100 |
| commit | 9a13aedd4ef04711fc5139c86025272e9648cc4c (patch) | |
| tree | 49cf0f4e6923df17f023abd5dbb50bd8fa53e8e5 /userspace | |
| parent | 6b8c02a9cf4ac36e42d07c668a2be27d2bf1a733 (diff) | |
double indirect block support to ELF and check sum calc
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/Makefile | 6 | ||||
| -rw-r--r-- | userspace/checker.c | 19 |
2 files changed, 22 insertions, 3 deletions
diff --git a/userspace/Makefile b/userspace/Makefile index 7e35096..74ced40 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -1,7 +1,7 @@ CC=i686-foolos-gcc CFLAGS=-w -PROGS=shell simple brainfuck add +PROGS=shell simple brainfuck add checker ext2.img: $(PROGS) dd if=/dev/zero of=ext2.img bs=512 count=5000 @@ -13,8 +13,7 @@ ext2.img: $(PROGS) echo "hello one" > mnt/miguel/test1.txt echo "hello two" > mnt/test2.txt cp $^ mnt - cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/elfedit mnt -# cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/objdump mnt + cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt sync sudo umount mnt rm mnt -rf @@ -23,6 +22,7 @@ brainfuck: brainfuck.o shell: shell.o simple: simple.o add: add.o +checker: checker.o clean: -rm *.o $(PROGS) ext2.img diff --git a/userspace/checker.c b/userspace/checker.c new file mode 100644 index 0000000..e5352f6 --- /dev/null +++ b/userspace/checker.c @@ -0,0 +1,19 @@ +#include <stdio.h> + +int main() + +{ +FILE *fp; /* The file handle for input data */ +fp=stdin; +int ch; /* Each character read. */ +int checksum = 0; /* The checksum mod 2^16. */ +int count=0; + +while ((ch = getc(fp)) != EOF) { + checksum = (checksum >> 1) + ((checksum & 1) << 15); + checksum +=(int) ch; + checksum &= 0xffff; /* Keep it within bounds. */ + count++; +} +printf("checksum : 0x%08X for %i bytes\n",checksum,count); +} |
