This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: File IO under Linux synthetic target
- To: <bartv at redhat dot com>
- Subject: Re: [ECOS] File IO under Linux synthetic target
- From: rob dot wj dot jansen at philips dot com
- Date: Thu, 31 May 2001 16:28:40 +0200
- Cc: <ecos-discuss at sources dot redhat dot com>
Bart,
> File I/O is not yet available on the synthetic target - at least, not
> using the eCos functionality. With the current release sources it is
> possible to make some Linux system calls to perform file I/O, for
> example by calling cyg_hal_sys_open() and cyg_hal_sys_read(), but
> obviously those will have the Linux semantics rather than the eCos
> ones.
thanks.
I now just read a file into memory and access this as if it were my flash region.
Works great, I use mount in a similar way as in the ROM FS and for the linux target the fs_mount
function now reads a file containing the flash image into memory as below.
---###---
externC int cyg_hal_sys_open(const char *, int, unsigned int);
externC int cyg_hal_sys_close(int);
externC unsigned long cyg_hal_sys_read(int, void *, long);
externC unsigned long cyg_hal_sys_lseek(int, unsigned long, int);
#define O_RDONLY 0
#define SEEK_END 2
#define SEEK_SET 0
fd = cyg_hal_sys_open(pDevice, O_RDONLY, 0); // Open the FATFS file
if(fd) {
fsize = cyg_hal_sys_lseek(fd, 0, SEEK_END); // Determine size
pMedium->base = malloc(fsize); // Allocate mem
cyg_hal_sys_lseek(fd, 0, SEEK_SET); // Rewind
cyg_hal_sys_read(fd, pMedium->base, fsize); // Read complete file
cyg_hal_sys_close(fd);
pMedium->offset = 0;
} else {
pMedium->base = NULL;
}
---###---
This could also work for the ROM FS package.
Regards,
Rob Jansen
Software Engineer
Competence Center Platforms
BU Mobile Communications
Meijhorst 60-10, 6537 KT Nijmegen, The Netherlands
Tel: +31-24-353-6329
Fax: +31-24-353-3613
mailto:Rob.WJ.Jansen@philips.com