diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-02-12 05:43:32 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-02-12 05:43:32 +0000 |
commit | ebaddd9ae89fbce54d25f289d1b7313a5a8fb47a (patch) | |
tree | 0a2e310b095d2e28926e9cb76221028a7ab8868f /fstests | |
parent | c6d7589b896a1051ed26ac362b328db70c0a834a (diff) |
Formerly fdtests.c.~2~
Diffstat (limited to 'fstests')
-rw-r--r-- | fstests/fdtests.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/fstests/fdtests.c b/fstests/fdtests.c index 6e3de6d4..00cb5f13 100644 --- a/fstests/fdtests.c +++ b/fstests/fdtests.c @@ -23,21 +23,24 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <fcntl.h> #include <errno.h> #include <unistd.h> +#include <stdio.h> -void +int main () { - int fd - char pathbuf[1024]; + int fd; + FILE *fp; + static const char string[] = "Did this get into the file?\n"; int written; stderr = stdout = mach_open_devstream (getdport (1), "w"); if (unlink (root, "CREATED") < 0 && errno != ENOENT) printf ("Error on unlink: %d\n", errno); + fd = open ("CREATED", O_WRITE | O_CREAT, 0666); if (fd < 0) - printf ("Error on open: %d\n", errno); + printf ("Error on poen: %d\n", errno); written = write (fd, string, strlen (string)); if (written < 0) printf ("Error on write: %d\n", errno); @@ -46,6 +49,24 @@ main () else if (sync ()) printf ("Error on sync: %d\n", errno); + + fp = fopen ("CREATED", "r"); + if (! fp) + perror ("fopen"); + else + { + char *line = NULL; + size_t len = 0; + ssize_t n = getline (&line, &len, fp); + if (n < 0) + perror ("getline"); + else + printf ("Read %d bytes: %.*s", n, line); + free (line); + } + printf ("All done.\n"); malloc (0); + + return 0; } |