提交 01f4a4a0 编写于 作者: J John Ferlan

storage: Introduce virStoragePoolObjBuildTempFilePath

Create a function to return a temporary file path to be used in a mkostemp
type call using the path to the stateDir + pool->def->name + vol->name
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 03308482
......@@ -3602,3 +3602,27 @@ virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
storageDriverUnlock();
return pool;
}
/*
* virStoragePoolObjBuildTempFilePath
* @pool: pool object pointer
* @vol: volume definition
*
* Generate a name for a temporary file using the driver stateDir
* as a path, the pool name, and the volume name to be used as input
* for a mkostemp
*
* Returns a string pointer on success, NULL on failure
*/
char *
virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
{
char *tmp = NULL;
ignore_value(virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX",
driver->stateDir, pool->def->name, vol->name));
return tmp;
}
......@@ -65,6 +65,10 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
const char *path)
ATTRIBUTE_NONNULL(2);
char *virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int storageRegister(void);
#endif /* __VIR_STORAGE_DRIVER_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册