summaryrefslogtreecommitdiff
path: root/ulib.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-08-11 13:55:18 +0000
committerrtm <rtm>2006-08-11 13:55:18 +0000
commit17a856577f9db766b8ef7099d0575d378dff5dd1 (patch)
tree53d0c687d9c9bf83d097a2171c48d04a569c5a61 /ulib.c
parent5be0039ce9e22f140a29e167526c64c723c5be3c (diff)
downloadxv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.tar.gz
xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.tar.bz2
xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.zip
init creates console, opens 0/1/2, runs sh
sh accepts 0-argument commands (like userfs) reads from console
Diffstat (limited to 'ulib.c')
-rw-r--r--ulib.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/ulib.c b/ulib.c
index d7e8934..ccb9fd6 100644
--- a/ulib.c
+++ b/ulib.c
@@ -3,17 +3,7 @@
int
puts(char *s)
{
- return cons_puts(s);
-}
-
-int
-puts1(char *s)
-{
- int i;
-
- for(i = 0; s[i]; i++)
- cons_putc(s[i]);
- return i;
+ return write(1, s, strlen(s));
}
char*
@@ -26,3 +16,30 @@ strcpy(char *s, char *t)
;
return os;
}
+
+unsigned int
+strlen(char *s)
+{
+ int n = 0;
+ for(n = 0; s[n]; n++)
+ ;
+ return n;
+}
+
+char *
+gets(char *buf, int max)
+{
+ int i = 0, cc;
+ char c;
+
+ while(i+1 < max){
+ cc = read(0, &c, 1);
+ if(cc < 1)
+ break;
+ if(c == '\n' || c == '\r')
+ break;
+ buf[i++] = c;
+ }
+ buf[i] = '\0';
+ return buf;
+}