fs.c 428 B

1234567891011121314151617181920212223
  1. #include <errno.h>
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <unistd.h>
  7. int main() {
  8. int fd = open("test.open.file", O_CREAT | O_RDWR, S_IRWXU);
  9. int fd2 = open("fs.manifest", O_RDONLY);
  10. char* buf = malloc(4096);
  11. int ret;
  12. while ((ret = read(fd2, buf, 4096)) > 0) {
  13. write(1, buf, ret);
  14. write(fd, buf, ret);
  15. }
  16. close(fd);
  17. return 0;
  18. }