int CreateStriped( const char * path, const stripe_info_t * old_stripe, int overwrite ) { int rc; /* try to restripe using previous pool name */ if ( !EMPTY_STRING( old_stripe->pool_name ) ) rc = llapi_file_create_pool( path, old_stripe->stripe_size, -1, old_stripe->stripe_count, 0, (char *)old_stripe->pool_name ); else rc = llapi_file_create( path, old_stripe->stripe_size, -1, old_stripe->stripe_count, 0 ); if ((rc == -EEXIST) && overwrite) { if (unlink(path)) { rc = -errno; DisplayLog( LVL_MAJOR, TAG_CR_STRIPE, "Can't remove previous entry %s: %s", path, strerror(-rc)); return rc; } return CreateStriped(path, old_stripe, false /*target not expected to exist*/); } else if ( rc != 0 && rc != -EEXIST ) { DisplayLog( LVL_MAJOR, TAG_CR_STRIPE, "Error %d creating '%s' with stripe.", rc, path ); } return rc; }
int File_CreateSetStripe( const char * path, const stripe_info_t * old_stripe ) { int rc; /* try to restripe using previous pool name */ if ( !EMPTY_STRING( old_stripe->pool_name ) ) { rc = llapi_file_create_pool( path, old_stripe->stripe_size, -1, old_stripe->stripe_count, 0, (char *)old_stripe->pool_name ); if ( rc == 0 || rc == -EEXIST ) return rc; else { DisplayLog( LVL_MAJOR, TAG_CR_STRIPE, "Error %d creating '%s' in pool '%s': %s", rc, path, old_stripe->pool_name, strerror(-rc) ); DisplayLog( LVL_MAJOR, TAG_CR_STRIPE, "Trying to create it without pool information..." ); } } rc = llapi_file_create( path, old_stripe->stripe_size, -1, old_stripe->stripe_count, 0 ); if ( rc != 0 || rc == -EEXIST ) DisplayLog( LVL_MAJOR, TAG_CR_STRIPE, "Error %d creating '%s' with stripe. Trying to create it without specific stripe...", rc, path ); return rc; }