Lines Matching refs:fd

50 	int	fd;  in get_random_fd()  local
53 fd = ((int) random()) % MAXFDS; in get_random_fd()
54 if (fd > 2) in get_random_fd()
55 return fd; in get_random_fd()
59 unsigned int get_inode_num(int fd) in get_inode_num() argument
63 if (fstat(fd, &st) < 0) { in get_inode_num()
74 int fd; in create_random_file() local
83 fd = open(template, O_RDONLY, 0600); in create_random_file()
85 template, fd); in create_random_file()
88 fd = open(template, O_CREAT|O_RDWR, 0600); in create_random_file()
89 write(fd, data_buffer, size); in create_random_file()
91 template, fd, size); in create_random_file()
93 state_array[fd].isdir = isdir; in create_random_file()
94 if (fd < 0) in create_random_file()
96 state_array[fd].isdir = isdir; in create_random_file()
97 state_array[fd].state = STATE_CREATED; in create_random_file()
98 strcpy(state_array[fd].name, template); in create_random_file()
101 void truncate_file(int fd) in truncate_file() argument
107 if (state_array[fd].isdir) in truncate_file()
110 ftruncate(fd, size); in truncate_file()
112 state_array[fd].name, fd, get_inode_num(fd), size); in truncate_file()
116 void unlink_file(int fd) in unlink_file() argument
118 char *filename = state_array[fd].name; in unlink_file()
120 printf("Deleting %s, fd = %d, ino = %u\n", filename, fd, in unlink_file()
121 get_inode_num(fd)); in unlink_file()
123 if (state_array[fd].isdir) in unlink_file()
127 state_array[fd].state = STATE_DELETED; in unlink_file()
130 void close_file(int fd) in close_file() argument
132 char *filename = state_array[fd].name; in close_file()
134 printf("Closing %s, fd = %d, ino = %u\n", filename, fd, in close_file()
135 get_inode_num(fd)); in close_file()
137 close(fd); in close_file()
138 state_array[fd].state = STATE_CLEAR; in close_file()
144 int i, fd; in main() local
151 fd = get_random_fd(); in main()
152 switch (state_array[fd].state) { in main()
157 if ((state_array[fd].isdir == 0) && in main()
159 truncate_file(fd); in main()
161 unlink_file(fd); in main()
164 close_file(fd); in main()