#include "usecfs.h" #include int main(void) { int fd; int buf[40] = { }; if (usecfs_init("sEcret") < 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; } printf("%s", buf); 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; } if (usecfs_read(fd, buf, 36) != 36) { printf("error: read.\n"); return 1; } printf("%s", buf); usecfs_close(fd); fd = usecfs_creat("file2"); if (fd < 0) { printf("error: creat2.\n"); return 1; } usecfs_close(fd); fd = usecfs_creat("file3"); if (fd < 0) { printf("error: creat2.\n"); return 1; } usecfs_close(fd); return 0; }