X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=7a9a2afed29b34d345e1628156c2d3ac6848163c;hp=faeefaf308fa3e32107375fed6ac68faf65fe594;hb=f29b25a370598d387e539c3dcae126274c6cbf4d;hpb=660a1cb5fb9843ec09a04337714e78d63cd557e7 diff --git a/filesetup.c b/filesetup.c index faeefaf3..7a9a2afe 100644 --- a/filesetup.c +++ b/filesetup.c @@ -474,8 +474,7 @@ void close_files(struct thread_data *td) unsigned int i; for_each_file(td, f, i) { - if ((f->flags & FIO_FILE_UNLINK) && - f->filetype == FIO_TYPE_FILE) + if (td->o.unlink && f->filetype == FIO_TYPE_FILE) unlink(f->file_name); td_io_close_file(td, f); @@ -514,7 +513,7 @@ static void get_file_type(struct fio_file *f) } } -void add_file(struct thread_data *td, const char *fname) +int add_file(struct thread_data *td, const char *fname) { int cur_files = td->files_index; char file_name[PATH_MAX]; @@ -544,10 +543,13 @@ void add_file(struct thread_data *td, const char *fname) td->files_index++; if (f->filetype == FIO_TYPE_FILE) td->nr_normal_files++; + + return cur_files; } void get_file(struct fio_file *f) { + assert(f->flags & FIO_FILE_OPEN); f->references++; } @@ -645,3 +647,28 @@ void dup_files(struct thread_data *td, struct thread_data *org) f->file_name = strdup(f->file_name); } } + +/* + * Returns the index that matches the filename, or -1 if not there + */ +int get_fileno(struct thread_data *td, const char *fname) +{ + struct fio_file *f; + unsigned int i; + + for_each_file(td, f, i) + if (!strcmp(f->file_name, fname)) + return i; + + return -1; +} + +/* + * For log usage, where we add/open/close files automatically + */ +void free_release_files(struct thread_data *td) +{ + close_files(td); + td->files_index = 0; + td->nr_normal_files = 0; +}