diff --git a/src/fiob.c b/src/fiob.c index cbaf14b72018aa978977afbfdc114323beb393b0..f22059714ac76ca0e1e11e379d6ee70eccb53a07 100644 --- a/src/fiob.c +++ b/src/fiob.c @@ -218,7 +218,11 @@ fiob_write(void *cookie, const char *buf, size_t len) assert(f->bfill == f->bsize); ssize_t res = fiob_writef(f, f->buf, f->bsize); if (res < 0) +#if defined(HAVE_FUNOPEN) return res; +#else + return 0; +#endif tocopy = f->bsize > bytes_left ? bytes_left : f->bsize; /* * We must memcpy because O_DIRECT requires diff --git a/test/unit/fiob.c b/test/unit/fiob.c index 09b9e5197dcb261127ab2b5896a051cc146c8caf..e43782aacde339fbbc88e1c8d7ed599eefcd3884 100644 --- a/test/unit/fiob.c +++ b/test/unit/fiob.c @@ -22,7 +22,7 @@ -#define PLAN 65 +#define PLAN 68 #define ITEMS 7 @@ -229,7 +229,18 @@ main(void) is(fclose(f), 0, "fclose"); } - + { + FILE *f = fiob_open("/dev/full", "wd"); + setvbuf(f, NULL, _IONBF, 0); + isnt(f, NULL, "fopen for writing"); + errno = 0; + fputs("test\n", f); + /* flush buffer */ + int r = fseek(f, 0, SEEK_SET); + is(errno, ENOSPC, "fwrite failed"); + is(r, EOF, "fwrite failed"); + fclose(f); + } if (fork() == 0) execl("/bin/rm", "/bin/rm", "-fr", td, NULL); diff --git a/test/unit/fiob.result b/test/unit/fiob.result index fe92099582ff021b02aed06e2bbec22e318ddc33..7a572d5034b98fb5fe8473d7ecb7722d7ae22f9b 100644 --- a/test/unit/fiob.result +++ b/test/unit/fiob.result @@ -1,4 +1,4 @@ -1..65 +1..68 ok 1 - tempdir is created ok 2 - common open ok 3 - Hello world is written (12 bytes) @@ -64,3 +64,6 @@ ok 62 - all records were written properly ok 63 - eof ok 64 - feof ok 65 - fclose +ok 66 - fopen for writing +ok 67 - fwrite failed +ok 68 - fwrite failed