o get lib worwq

king
This commit is contained in:
david 2009-05-26 11:35:06 +02:00
parent a6aade11c4
commit 0fd42d7b1d
5 changed files with 22 additions and 35 deletions

View File

@ -18,12 +18,6 @@ $(bin): $(objs)
clean:
rm -rf $(bin) *.o
image32:
dd if=/dev/zero of=disk00.vfat bs=1M count=64
sudo mkfs.vfat -F 32 -v disk00.vfat
image_parted:
dd if=/dev/zero of=disk00.vfat bs=1M count=256
fdisk -H 32 -S 32 -C 500 disk00.vfat
@ -48,19 +42,11 @@ image_not_parted:
sudo umount disk
sudo losetup -d /dev/loop0
image_no_fdisk:
dd if=/dev/zero of=disk00.vfat bs=1M count=256
sudo mkfs.vfat -I -f 2 -F 16 -v disk00.vfat
sudo mount -o loop disk00.vfat disk
sudo cp /var/log/*log disk/
sudo umount disk
image_no_dd:
image:
rm -fv disk00.vfat
mkfs.vfat -F 32 -v -C disk00.vfat 256000
sudo mount -o loop,check=s disk00.vfat disk
sudo cp -v /var/log/*log disk/
mkfs.vfat -I -F 16 -v -C disk00.vfat 256000
sudo mount -o loop disk00.vfat disk
sudo cp -v /var/log/*.log disk/
sudo umount disk
mount:
@ -71,3 +57,8 @@ umount:
sudo umount disk
sudo losetup -d /dev/loop0
test:
echo "fi\nfs\nfl" | ./fftest
run:
rlwrap ./fftest

View File

@ -75,11 +75,12 @@ return 1 byte
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <string.h>
#define IMAGE_NAME "disk00.vfat"
int *image_addr;
char *image_addr;
DSTATUS disk_initialize (BYTE drv) {
if (drv) return STA_NOINIT; /* Supports only single drive */
@ -98,15 +99,15 @@ DSTATUS disk_initialize (BYTE drv) {
int size = lseek(fd,0,SEEK_END);
lseek(fd,0,SEEK_SET);
printf("Open Image (size %i)\n",size);
//image_addr = mmap(0,fd,)
image_addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (image_addr == MAP_FAILED) {
close(fd);
perror("Error mmapping the file");
exit(EXIT_FAILURE);
}
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
return Stat;
}
@ -137,10 +138,10 @@ DRESULT disk_read (
if (drv || !count) return RES_PARERR;
if (Stat & STA_NOINIT) return RES_NOTRDY;
DWORD offset = sector * 512;
DWORD offset = sector * 512;
int size = count * 512;
printf("disk_read: sector=%li count=%i addr=%p size=%i\n",sector,count,image_addr + offset,size);
printf("disk_read: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
memcpy(buff,image_addr + offset,size);
//printf("%x %x %x %x\n",buff[0],buff[1],buff[2],buff[3]);
@ -166,16 +167,11 @@ DRESULT disk_write (
if (drv || !count) return RES_PARERR;
if (Stat & STA_NOINIT) return RES_NOTRDY;
/* Issue Write Setor(s) command */
/*
write_ata(REG_COUNT, count);
write_ata(REG_SECTOR, (BYTE)sector);
write_ata(REG_CYLL, (BYTE)(sector >> 8));
write_ata(REG_CYLH, (BYTE)(sector >> 16));
write_ata(REG_DEV, ((BYTE)(sector >> 24) & 0x0F) | LBA);
write_ata(REG_COMMAND, CMD_WRITE);
*/
DWORD offset = sector * 512;
int size = count * 512;
printf("disk_write: sector=%li count=%i addr=%p off=%li size=%i\n",sector,count,image_addr + offset,offset,size);
memcpy(image_addr + offset,buff,size);
return RES_OK;
}
#endif /* _READONLY */

View File

@ -25,7 +25,7 @@
#ifndef _FATFS
#define _FATFS
#define _WORD_ACCESS 1
#define _WORD_ACCESS 0
/* The _WORD_ACCESS option defines which access method is used to the word
/ data in the FAT structure.
/
@ -60,7 +60,7 @@
/ data transfer. This reduces memory consumption 512 bytes each file object. */
#define _USE_STRFUNC 1
#define _USE_STRFUNC 0
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */

Binary file not shown.

View File

@ -118,7 +118,7 @@ FRESULT scan_files (char* path)
if ((res = f_opendir(&dirs, path)) == FR_OK) {
i = strlen(path);
printf("Ok\n");
//printf("Ok\n");
while (((res = f_readdir(&dirs, &finfo)) == FR_OK) && finfo.fname[0]) {
if (finfo.fattrib & AM_DIR) {
acc_dirs++;