9
int main(int argc, char **argv)
17
printf("Usage: test_truncate <path>\n");
21
fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
23
printf("error opening file\n");
26
size = write(fd , "abc" , 3);
28
printf("data not written to file");
31
if ((close(fd) != 0)) {
32
printf("error closing file");
35
fd = open(filename, O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR);
37
printf("2 error opening file\n");
40
if ((close(fd) != 0)) {
41
printf("2 error closing file");
44
fstat = malloc(sizeof(struct stat));
46
printf("Unable to allocate memory\n");
49
stat(filename, fstat);
50
if (fstat->st_size != 0) {
51
printf("test file should be 0 bytes\n");
52
printf("test file is [%d] bytes\n", fstat->st_size);
54
if (unlink(filename)) {
55
printf("error deleting file\n");
61
if (unlink(filename)) {
62
printf("error deleting file\n");