Rev 1085 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
*
*
*
*/
#include <kernel/func.h>
#include <fs/bdevinit.h>
#include <fs/fsinit.h>
#include <fs/bdev.h>
#include <drivers/keyb.h>
#include <sys/mount.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "common.h"
//#define FILENAME "/temp/ALFA1.TXT"
#define FILENAME "/pippo.c"
int leggi
(int h
)
{
char buffer
[124];
int len
;
memset(buffer
,'\0',sizeof(buffer
));
cprintf
("READING...\n");
len
=read
(h
,buffer
,sizeof(buffer
)-1);
cprintf
("READ %i bytes\n",len
);
cprintf
("buffer='%s'\n",buffer
);
return len
;
}
int main
(int argc
,char *argv
[])
{
int h
;
showmessage
("Try lseek() using a file for reading.");
cprintf
("OPENING %s\n",FILENAME
);
h
=open
(FILENAME
,O_RDONLY
);
if (h
>=0) {
cprintf
("OPENED!\n");
leggi
(h
);
leggi
(h
);
leggi
(h
);
cprintf
("SEEK to 16\n");
lseek
(h
,16,SEEK_SET
);
leggi
(h
);
cprintf
("SEEK to %i\n",123*3+1);
lseek
(h
,123*3+1,SEEK_SET
);
leggi
(h
);
} else
cprintf
("FAILED!\n");
waitend
();
return 0;
}