xv6/userfs.c

53 lines
961 B
C
Raw Normal View History

#include "user.h"
2006-08-08 18:07:37 +00:00
#include "types.h"
#include "fs.h"
2006-07-10 16:27:15 +00:00
// file system tests
char buf[1024];
char *echo_args[] = { "echo", "hello", "goodbye", 0 };
char *cat_args[] = { "cat", "README", 0 };
2006-07-10 16:27:15 +00:00
int
2006-07-17 01:25:22 +00:00
main(void)
2006-07-10 16:27:15 +00:00
{
2006-07-29 09:35:02 +00:00
int fd;
2006-07-11 01:07:40 +00:00
puts("userfs running\n");
2006-07-10 16:27:15 +00:00
block();
2006-08-08 18:07:37 +00:00
if (mknod ("console", T_DEV, 1, 1) < 0)
puts ("mknod failed\n");
else
puts ("made a node\n");
fd = open("console", 1);
if(fd >= 0){
puts("open console ok\n");
close(fd);
} else {
puts("open console failed!\n");
}
if (write (fd, "hello\n", 6) != 6) {
puts ("write to console failed\n");
}
close (fd);
2006-08-08 18:07:37 +00:00
2006-07-29 09:35:02 +00:00
fd = open("echo", 0);
if(fd >= 0){
puts("open echo ok\n");
close(fd);
} else {
puts("open echo failed!\n");
}
fd = open("doesnotexist", 0);
if(fd >= 0){
puts("open doesnotexist succeeded!\n");
close(fd);
} else {
puts("open doesnotexist failed\n");
}
//exec("echo", echo_args);
exec("cat", cat_args);
return 0;
2006-07-10 16:27:15 +00:00
}