spdk_dd: Create file automatically if it does not exist

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: I358b8b3977fc15773c6d354d72b8a30d4327fe76
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2965
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
Maciej Szwed 2020-06-19 10:30:12 +02:00 committed by Tomasz Zawadzki
parent 3b3f2e5d0a
commit ef72cb11b3

View File

@ -490,8 +490,14 @@ dd_output_poll(void *ctx)
static int
dd_open_file(struct dd_target *target, const char *fname, uint64_t skip_blocks, bool input)
{
int flags = O_RDWR;
if (input == false) {
flags |= O_CREAT;
}
target->type = DD_TARGET_TYPE_FILE;
target->u.aio.fd = open(fname, O_RDWR);
target->u.aio.fd = open(fname, flags, 0600);
if (target->u.aio.fd < 0) {
SPDK_ERRLOG("Could not open file %s: %s\n", fname, strerror(errno));
return target->u.aio.fd;