47 lines
861 B
C
47 lines
861 B
C
|
#include "usecfs.h"
|
||
|
#include <stdio.h>
|
||
|
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
int fd;
|
||
|
int buf[36];
|
||
|
|
||
|
if (usecfs_init() < 0)
|
||
|
{
|
||
|
printf("error.\n");
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
fd = usecfs_creat("file1");
|
||
|
if (fd < 0) {
|
||
|
printf("error: creat.\n");
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
if (usecfs_write(fd, "test string file 1 content", 26) < 0) {
|
||
|
printf("error: write.\n");
|
||
|
return 1;
|
||
|
}
|
||
|
usecfs_close(fd);
|
||
|
|
||
|
fd = usecfs_open("file1");
|
||
|
if (fd < 0) {
|
||
|
printf("error: open\n");
|
||
|
return 1;
|
||
|
}
|
||
|
if (usecfs_read(fd, buf, 26) != 26) {
|
||
|
printf("error: read.\n");
|
||
|
return 1;
|
||
|
}
|
||
|
if (usecfs_write(fd, "test string2", 12) < 0) {
|
||
|
printf("error: write.\n");
|
||
|
return 1;
|
||
|
}
|
||
|
if (usecfs_seek(fd, 0, 0) != 0) {
|
||
|
printf("error: seek.\n");
|
||
|
return 1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|