summaryrefslogtreecommitdiff
path: root/ulib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ulib.c')
-rw-r--r--ulib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ulib.c b/ulib.c
index b759f45..eaa33d3 100644
--- a/ulib.c
+++ b/ulib.c
@@ -1,3 +1,6 @@
+#include "types.h"
+#include "stat.h"
+#include "fcntl.h"
#include "user.h"
int
@@ -54,3 +57,16 @@ gets(char *buf, int max)
buf[i] = '\0';
return buf;
}
+
+int
+stat(char *n, struct stat *st)
+{
+ int fd = open(n, O_RDONLY);
+ int r;
+
+ if (fd < 0) return -1;
+
+ r = fstat(fd, st);
+ close(fd);
+ return r;
+}