Home | History | Annotate | Download | only in progs

Lines Matching refs:fd

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