Multiuser, Capabilities and Access Controls (#54)
[lunaix-os.git] / lunaix-os / usr / cat.c
index 9f0d35b54b9ed463a9bce190304812b0733d0e62..1fe6c1610bfb12a11d9690b71290df4d24be4c7e 100644 (file)
@@ -26,13 +26,17 @@ main(int argc, const char* argv[])
             return 1;
         }
 
-        if (!(stat.mode & F_MFILE)) {
+        if (((stat.st_mode >> 16) & F_DIR)) {
             printf("%s is a directory", argv[i]);
             return 1;
         }
 
         do {
             size = read(fd, buffer, BUFSIZE);
+            if (size < 0) {
+                printf("error while reading: %d\n", size);
+                break;
+            }
             write(stdout, buffer, size);
         } while (size == BUFSIZE);