summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2022-09-11 13:51:11 -0400
committerFrans Kaashoek <[email protected]>2022-09-11 13:51:11 -0400
commit4b46c0c6eb464782faa36d158246ba4e3238c970 (patch)
tree5b4d3d6bae71884b607bee744e1311a115b7e4d1
parent463ae0abc3225d6e6de4a5a1ad57e64ab76b2b6f (diff)
downloadxv6-labs-4b46c0c6eb464782faa36d158246ba4e3238c970.tar.gz
xv6-labs-4b46c0c6eb464782faa36d158246ba4e3238c970.tar.bz2
xv6-labs-4b46c0c6eb464782faa36d158246ba4e3238c970.zip
Use O_RDONLY instead of 0
-rw-r--r--user/cat.c3
-rw-r--r--user/grep.c3
-rw-r--r--user/ls.c3
-rw-r--r--user/wc.c3
4 files changed, 8 insertions, 4 deletions
diff --git a/user/cat.c b/user/cat.c
index 598f005..520dc8b 100644
--- a/user/cat.c
+++ b/user/cat.c
@@ -1,5 +1,6 @@
#include "kernel/types.h"
#include "kernel/stat.h"
+#include "kernel/fcntl.h"
#include "user/user.h"
char buf[512];
@@ -32,7 +33,7 @@ main(int argc, char *argv[])
}
for(i = 1; i < argc; i++){
- if((fd = open(argv[i], 0)) < 0){
+ if((fd = open(argv[i], O_RDONLY)) < 0){
fprintf(2, "cat: cannot open %s\n", argv[i]);
exit(1);
}
diff --git a/user/grep.c b/user/grep.c
index 2315a0c..6c33766 100644
--- a/user/grep.c
+++ b/user/grep.c
@@ -2,6 +2,7 @@
#include "kernel/types.h"
#include "kernel/stat.h"
+#include "kernel/fcntl.h"
#include "user/user.h"
char buf[1024];
@@ -51,7 +52,7 @@ main(int argc, char *argv[])
}
for(i = 2; i < argc; i++){
- if((fd = open(argv[i], 0)) < 0){
+ if((fd = open(argv[i], O_RDONLY)) < 0){
printf("grep: cannot open %s\n", argv[i]);
exit(1);
}
diff --git a/user/ls.c b/user/ls.c
index c67b84b..b32c200 100644
--- a/user/ls.c
+++ b/user/ls.c
@@ -2,6 +2,7 @@
#include "kernel/stat.h"
#include "user/user.h"
#include "kernel/fs.h"
+#include "kernel/fcntl.h"
char*
fmtname(char *path)
@@ -30,7 +31,7 @@ ls(char *path)
struct dirent de;
struct stat st;
- if((fd = open(path, 0)) < 0){
+ if((fd = open(path, O_RDONLY)) < 0){
fprintf(2, "ls: cannot open %s\n", path);
return;
}
diff --git a/user/wc.c b/user/wc.c
index 6a851ca..d8f3b2a 100644
--- a/user/wc.c
+++ b/user/wc.c
@@ -1,5 +1,6 @@
#include "kernel/types.h"
#include "kernel/stat.h"
+#include "kernel/fcntl.h"
#include "user/user.h"
char buf[512];
@@ -43,7 +44,7 @@ main(int argc, char *argv[])
}
for(i = 1; i < argc; i++){
- if((fd = open(argv[i], 0)) < 0){
+ if((fd = open(argv[i], O_RDONLY)) < 0){
printf("wc: cannot open %s\n", argv[i]);
exit(1);
}