Home | History | Annotate | Download | only in progs

Lines Matching defs:fd

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