- some test changes in newlib/examples
This commit is contained in:
parent
a4c870deca
commit
c6a5f9390e
1 changed files with 28 additions and 3 deletions
|
@ -22,11 +22,36 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*file descriptor init*/
|
||||
#define NR_OPEN 10
|
||||
#define FS_INIT { [0 ... NR_OPEN-1] = {NULL, 0, 0} }
|
||||
|
||||
/*open flags*/
|
||||
|
||||
//#define O_RDONLY 0
|
||||
//#define O_WRONLY 1
|
||||
#define O_RDWR 2
|
||||
|
||||
#define O_CREAT 64
|
||||
#define O_EXCL 128
|
||||
//#define O_NOCTTY 256
|
||||
#define O_TRUNC 512
|
||||
#define O_APPEND 1024
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
printf("test!");
|
||||
char* teststr = malloc(sizeof(char)*100);
|
||||
int testfile = open("/bin/test", O_APPEND, "wr");
|
||||
write(testfile, "test", 4);
|
||||
lseek(testfile, 0, SEEK_SET);
|
||||
read(testfile, teststr, 100);
|
||||
printf("Gelesen aus neuer Datei: %s", teststr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return errno;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue