Subversion Repositories shark

Rev

Rev 1655 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 giacomo 1
/*
2
 *
3
 *
4
 *
5
 */
6
 
7
#include <kernel/func.h>
8
 
9
#include <fs/bdevinit.h>
10
#include <fs/fsinit.h>
11
#include <fs/bdev.h>
12
 
13
#include <drivers/keyb.h>
14
 
15
#include <sys/mount.h>
16
#include <sys/types.h>
17
#include <fcntl.h>
18
#include <unistd.h>
19
#include <errno.h>
20
#include <string.h>
21
 
22
#include "common.h"
23
 
24
#define FILENAME "/TEMP/TESTW1.TXT"
25
 
26
int scrivi(int h,char *buffer,int len)
27
{
28
  int res;
29
  cprintf("WRITING...\n");
30
  res=write(h,buffer,len);
31
  cprintf("WRITTEN %i bytes\n",res);
32
  if (res>0) {
33
    buffer[res]='\0';
34
    cprintf("(%s)\n",buffer);
35
  } else cprintf("errno: %i '%s'\n",errno,strerror(errno));
36
  return res;
37
}
38
 
39
extern dev_t temp_device;
40
 
41
int main(int argc,char *argv[])
42
{
43
  int res;
44
  int h;
45
 
46
  showmessage("Try to create and overwriting a file.\n");
47
 
48
  cprintf("OPENING %s\n",FILENAME);  
49
  h=open(FILENAME,O_CREAT|O_WRONLY|O_TRUNC);
50
 
51
  if (h>=0) {
52
    cprintf("OPENED fd=%i!\n",h);
53
 
54
    scrivi(h,"ABC ",3);
55
 
56
    scrivi(h,"abcdefghilmnopqrstuvz ",21);
57
 
58
    res=close(h);
59
    if (res!=0) {
60
      cprintf("CLOSE FAILED!\n");
61
      cprintf("errno: %i '%s'\n",errno,strerror(errno));
62
    }
63
  } else {
64
    cprintf("FAILED!\n");
65
    cprintf("errno: %i '%s'\n",errno,strerror(errno));
66
  }
67
 
68
  waitend();
69
 
70
  return 0;
71
}