Lines Matching refs:fd
51 int fd; in get_random_fd() local
54 fd = ((int) random()) % MAXFDS; in get_random_fd()
55 if (fd > 2) in get_random_fd()
56 return fd; in get_random_fd()
60 unsigned int get_inode_num(int fd) in get_inode_num() argument
64 if (fstat(fd, &st) < 0) { in get_inode_num()
75 int fd; in create_random_file() local
84 fd = open(template, O_RDONLY, 0600); in create_random_file()
86 template, fd); in create_random_file()
89 fd = open(template, O_CREAT|O_RDWR, 0600); in create_random_file()
90 write(fd, data_buffer, size); in create_random_file()
92 template, fd, size); in create_random_file()
94 state_array[fd].isdir = isdir; in create_random_file()
95 if (fd < 0) in create_random_file()
97 state_array[fd].isdir = isdir; in create_random_file()
98 state_array[fd].state = STATE_CREATED; in create_random_file()
99 strcpy(state_array[fd].name, template); in create_random_file()
102 void truncate_file(int fd) in truncate_file() argument
108 if (state_array[fd].isdir) in truncate_file()
111 ftruncate(fd, size); in truncate_file()
113 state_array[fd].name, fd, get_inode_num(fd), size); in truncate_file()
117 void unlink_file(int fd) in unlink_file() argument
119 char *filename = state_array[fd].name; in unlink_file()
121 printf("Deleting %s, fd = %d, ino = %u\n", filename, fd, in unlink_file()
122 get_inode_num(fd)); in unlink_file()
124 if (state_array[fd].isdir) in unlink_file()
128 state_array[fd].state = STATE_DELETED; in unlink_file()
131 void close_file(int fd) in close_file() argument
133 char *filename = state_array[fd].name; in close_file()
135 printf("Closing %s, fd = %d, ino = %u\n", filename, fd, in close_file()
136 get_inode_num(fd)); in close_file()
138 close(fd); in close_file()
139 state_array[fd].state = STATE_CLEAR; in close_file()
145 int i, fd; in main() local
152 fd = get_random_fd(); in main()
153 switch (state_array[fd].state) { in main()
158 if ((state_array[fd].isdir == 0) && in main()
160 truncate_file(fd); in main()
162 unlink_file(fd); in main()
165 close_file(fd); in main()