Overview
| Artifact ID: | e0122e2ee764c10e892d45011d7b7f5e379a0699 |
|---|---|
| Ticket: | 2888099fffffffffffffffffffffffffffffffff
[close] discards buffered data when no space left on device |
| User & Date: | flatworm on 2009-10-29 00:30:18 |
Changes
- icomment:
The following C program fails at the call to fclose() to demonstrate libc+kernel handle the situation correctly: #include <stdio.h> #include <string.h> int main (int argc, char **argv) { FILE *fd; char *test = "test\n"; int len, written, res; if (argc != 2) { fprintf(stderr, "usage: %s FILENAME\n", argv[0]); return 1; } fd = fopen(argv[1], "a"); if (fd == NULL) { perror("fopen failed"); return 2; } len = strlen(test); written = fwrite(test, 1, len, fd); if (written < len) { perror("fwrite failed"); return 3; } res = fclose(fd); if (res != 0) { perror("fclose failed"); return 4; } return 0; } $ gcc -o mkfile -Wall -W -Wextra mkfile.c then in the setting described above: # /tmp/mkfile /tmp/blockdev/foo fclose failed: No space left on device - login: "flatworm"
- mimetype: "text/plain"
- username: "flatworm"