return 1;
}
- if (td_read(td)) {
- if (!td->file_size || (st.st_size > td->file_size))
- td->file_size = st.st_size;
- } else {
- if (!td->file_size)
- td->file_size = 1024 * 1024 * 1024;
- }
+ if (!td->file_size)
+ td->file_size = st.st_size;
return 0;
}
return 1;
}
- if (!td->file_size || (bytes > td->file_size))
+ /*
+ * no extend possibilities, so limit size to device size if too large
+ */
+ if (!td->file_size || td->file_size > bytes)
td->file_size = bytes;
return 0;
}
if (create_file(td, td->file_size, 0))
return 1;
- } else if (st.st_size < td->file_size) {
- if (create_file(td, td->file_size - st.st_size, 1))
- return 1;
+ } else if (td->filetype == FIO_TYPE_FILE) {
+ if (st.st_size < td->file_size) {
+ if (create_file(td, td->file_size - st.st_size, 1))
+ return 1;
+ }
}
if (td->odirect)
if (td_read(td))
td->fd = open(td->file_name, flags | O_RDONLY);
else {
- if (!td->overwrite)
- flags |= O_TRUNC;
+ if (td->filetype == FIO_TYPE_FILE) {
+ if (!td->overwrite)
+ flags |= O_TRUNC;
+
+ flags |= O_CREAT;
+ }
if (td->sync_io)
flags |= O_SYNC;
flags |= O_RDWR;
- td->fd = open(td->file_name, flags | O_CREAT, 0600);
+ td->fd = open(td->file_name, flags, 0600);
}
if (td->fd == -1) {
if (get_file_size(td))
return 1;
- if (td_write(td) && ftruncate(td->fd, td->file_size) == -1) {
- td->error = errno;
- return 1;
- }
-
if (!td->use_mmap)
return setup_file_plain(td);
else