Lines Matching refs:sf

44 static int	split_openfile(struct split_file *sf);
63 split_file_destroy(struct split_file *sf) in split_file_destroy() argument
67 if (sf->filesc > 0) { in split_file_destroy()
68 for (i = 0; i < sf->filesc; i++) { in split_file_destroy()
69 free(sf->filesv[i]); in split_file_destroy()
70 free(sf->descsv[i]); in split_file_destroy()
72 free(sf->filesv); in split_file_destroy()
73 free(sf->descsv); in split_file_destroy()
75 free(sf); in split_file_destroy()
79 split_openfile(struct split_file *sf) in split_openfile() argument
84 sf->curfd = open(sf->filesv[sf->curfile], O_RDONLY); in split_openfile()
85 if (sf->curfd >= 0) in split_openfile()
87 if ((sf->curfd == -1) && (errno != ENOENT)) in split_openfile()
92 sf->descsv[sf->curfile]); in split_openfile()
96 sf->file_pos = 0; in split_openfile()
105 struct split_file *sf; in splitfs_open() local
138 sf = malloc(sizeof(struct split_file)); in splitfs_open()
139 bzero(sf, sizeof(struct split_file)); in splitfs_open()
153 sf->filesc++; in splitfs_open()
154 sf->filesv = realloc(sf->filesv, sizeof(*(sf->filesv)) * sf->filesc); in splitfs_open()
155 sf->descsv = realloc(sf->descsv, sizeof(*(sf->descsv)) * sf->filesc); in splitfs_open()
156 sf->filesv[sf->filesc - 1] = strdup(buf); in splitfs_open()
157 sf->descsv[sf->filesc - 1] = strdup(cp); in splitfs_open()
162 if (sf->filesc == 0) { in splitfs_open()
163 split_file_destroy(sf); in splitfs_open()
166 errno = split_openfile(sf); in splitfs_open()
168 split_file_destroy(sf); in splitfs_open()
173 f->f_fsdata = sf; in splitfs_open()
181 struct split_file *sf; in splitfs_close() local
183 sf = (struct split_file *)f->f_fsdata; in splitfs_close()
184 fd = sf->curfd; in splitfs_close()
185 split_file_destroy(sf); in splitfs_close()
194 struct split_file *sf; in splitfs_read() local
196 sf = (struct split_file *)f->f_fsdata; in splitfs_read()
199 nread = read(sf->curfd, buf, size - totread); in splitfs_read()
205 sf->tot_pos += nread; in splitfs_read()
206 sf->file_pos += nread; in splitfs_read()
211 if (sf->curfile == (sf->filesc - 1)) /* Last slice */ in splitfs_read()
215 if (close(sf->curfd) != 0) in splitfs_read()
218 sf->curfile++; in splitfs_read()
219 errno = split_openfile(sf); in splitfs_read()
237 struct split_file *sf; in splitfs_seek() local
239 sf = (struct split_file *)f->f_fsdata; in splitfs_seek()
244 seek_by -= sf->tot_pos; in splitfs_seek()
286 if (sf->file_pos + seek_by < 0) in splitfs_seek()
288 new_pos = lseek(sf->curfd, seek_by, SEEK_CUR); in splitfs_seek()
293 sf->tot_pos += new_pos - sf->file_pos; in splitfs_seek()
294 sf->file_pos = new_pos; in splitfs_seek()
297 return (sf->tot_pos); in splitfs_seek()
304 struct split_file *sf = (struct split_file *)f->f_fsdata; in splitfs_stat() local
307 if ((result = fstat(sf->curfd, sb)) == 0) in splitfs_stat()