.gitignore updated
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ _*
|
|||||||
*.asm
|
*.asm
|
||||||
*.sym
|
*.sym
|
||||||
*.img
|
*.img
|
||||||
|
.cache
|
||||||
vectors.S
|
vectors.S
|
||||||
bootblock
|
bootblock
|
||||||
entryother
|
entryother
|
||||||
|
|||||||
22
user/cat.c
22
user/cat.c
@@ -1,39 +1,35 @@
|
|||||||
#include "kernel/types.h"
|
|
||||||
#include "kernel/stat.h"
|
|
||||||
#include "kernel/fcntl.h"
|
#include "kernel/fcntl.h"
|
||||||
|
#include "kernel/stat.h"
|
||||||
|
#include "kernel/types.h"
|
||||||
#include "user/user.h"
|
#include "user/user.h"
|
||||||
|
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
void
|
void cat(int fd) {
|
||||||
cat(int fd)
|
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
while((n = read(fd, buf, sizeof(buf))) > 0) {
|
while ((n = read(fd, buf, sizeof(buf))) > 0) {
|
||||||
if (write(1, buf, n) != n) {
|
if (write(1, buf, n) != n) {
|
||||||
fprintf(2, "cat: write error\n");
|
fprintf(2, "cat: write error\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(n < 0){
|
if (n < 0) {
|
||||||
fprintf(2, "cat: read error\n");
|
fprintf(2, "cat: read error\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main(int argc, char *argv[]) {
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int fd, i;
|
int fd, i;
|
||||||
|
|
||||||
if(argc <= 1){
|
if (argc <= 1) {
|
||||||
cat(0);
|
cat(0);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 1; i < argc; i++){
|
for (i = 1; i < argc; i++) {
|
||||||
if((fd = open(argv[i], O_RDONLY)) < 0){
|
if ((fd = open(argv[i], O_RDONLY)) < 0) {
|
||||||
fprintf(2, "cat: cannot open %s\n", argv[i]);
|
fprintf(2, "cat: cannot open %s\n", argv[i]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user