sudo dd if=/dev/sdc1 of=./sd bs=512 count=1
hexdump -C ./sd
00000000 eb 3c 90 4d 53 44 4f 53 35 2e 30 00 02 40 08 00 |.<.MSDOS5.0..@..|
00000010 02 00 02 00 00 f8 e8 00 3f 00 ff 00 3f 00 00 00 |........?...?...|
00000020 ad d9 39 00 80 00 29 4b 85 bd 74 4e 4f 20 4e 41 |..9...)K..tNO NA|
00000030 4d 45 20 20 20 20 46 41 54 31 36 20 20 20 33 c9 |ME FAT16 3.|
00000040 8e d1 bc f0 7b 8e d9 b8 00 20 8e c0 fc bd 00 7c |....{.... .....||
00000050 38 4e 24 7d 24 8b c1 99 e8 3c 01 72 1c 83 eb 3a |8N$}$....<.r...:|
00000060 66 a1 1c 7c 26 66 3b 07 26 8a 57 fc 75 06 80 ca |f..|&f;.&.W.u...|
00000070 02 88 56 02 80 c3 10 73 eb 33 c9 8a 46 10 98 f7 |..V....s.3..F...|
00000080 66 16 03 46 1c 13 56 1e 03 46 0e 13 d1 8b 76 11 |f..F..V..F....v.|
00000090 60 89 46 fc 89 56 fe b8 20 00 f7 e6 8b 5e 0b 03 |`.F..V.. ....^..|
000000a0 c3 48 f7 f3 01 46 fc 11 4e fe 61 bf 00 00 e8 e6 |.H...F..N.a.....|
000000b0 00 72 39 26 38 2d 74 17 60 b1 0b be a1 7d f3 a6 |.r9&8-t.`....}..|
000000c0 61 74 32 4e 74 09 83 c7 20 3b fb 72 e6 eb dc a0 |at2Nt... ;.r....|
000000d0 fb 7d b4 7d 8b f0 ac 98 40 74 0c 48 74 13 b4 0e |.}.}....@t.Ht...|
000000e0 bb 07 00 cd 10 eb ef a0 fd 7d eb e6 a0 fc 7d eb |.........}....}.|
000000f0 e1 cd 16 cd 19 26 8b 55 1a 52 b0 01 bb 00 00 e8 |.....&.U.R......|
00000100 3b 00 72 e8 5b 8a 56 24 be 0b 7c 8b fc c7 46 f0 |;.r.[.V$..|...F.|
00000110 3d 7d c7 46 f4 29 7d 8c d9 89 4e f2 89 4e f6 c6 |=}.F.)}...N..N..|
00000120 06 96 7d cb ea 03 00 00 20 0f b6 c8 66 8b 46 f8 |..}..... ...f.F.|
00000130 66 03 46 1c 66 8b d0 66 c1 ea 10 eb 5e 0f b6 c8 |f.F.f..f....^...|
00000140 4a 4a 8a 46 0d 32 e4 f7 e2 03 46 fc 13 56 fe eb |JJ.F.2....F..V..|
00000150 4a 52 50 06 53 6a 01 6a 10 91 8b 46 18 96 92 33 |JRP.Sj.j...F...3|
00000160 d2 f7 f6 91 f7 f6 42 87 ca f7 76 1a 8a f2 8a e8 |......B...v.....|
00000170 c0 cc 02 0a cc b8 01 02 80 7e 02 0e 75 04 b4 42 |.........~..u..B|
00000180 8b f4 8a 56 24 cd 13 61 61 72 0b 40 75 01 42 03 |...V$..aar.@u.B.|
00000190 5e 0b 49 75 06 f8 c3 41 bb 00 00 60 66 6a 00 eb |^.Iu...A...`fj..|
000001a0 b0 42 4f 4f 54 4d 47 52 20 20 20 20 0d 0a 52 65 |.BOOTMGR ..Re|
000001b0 6d 6f 76 65 20 64 69 73 6b 73 20 6f 72 20 6f 74 |move disks or ot|
000001c0 68 65 72 20 6d 65 64 69 61 2e ff 0d 0a 44 69 73 |her media....Dis|
000001d0 6b 20 65 72 72 6f 72 ff 0d 0a 50 72 65 73 73 20 |k error...Press |
000001e0 61 6e 79 20 6b 65 79 20 74 6f 20 72 65 73 74 61 |any key to resta|
000001f0 72 74 0d 0a 00 00 00 00 00 00 00 ac cb d8 55 aa |rt............U.|
00000200
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void main ()
{
int sdc=open("/dev/sdc1",O_RDWR);
char buf[512]={0};
int count= read(sdc,buf,sizeof(buf));
buf[3]=0;
lseek(sdc,0 ,SEEK_SET);
count = write(sdc,buf,sizeof(buf));
printf("%d %x\n",count,buf[3]);
close(sdc);
}
makefile
disk:disk.o
gcc -o $@ $^
.c.o:
gcc -g -c $< -I .
run:
sudo gdb ./disk
test:
sudo ./disk;sudo hexdump -C /dev/sdc1 -n 16