storage: Add witness for checking storage volume use in security driver

With my intended use of storage driver assist to chown files on remote
storage we will need a witness that will tell us whether the given
storage volume supports operations needed by the storage driver.
This commit is contained in:
Peter Krempa 2014-07-09 16:52:06 +02:00
parent 50f09651df
commit 222860cd36
2 changed files with 33 additions and 0 deletions

View File

@ -2357,6 +2357,37 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
backend->storageFileAccess;
}
/**
* virStorageFileSupportsSecurityDriver:
*
* @src: a storage file structure
*
* Check if a storage file supports operations needed by the security
* driver to perform labelling
*/
bool
virStorageFileSupportsSecurityDriver(virStorageSourcePtr src)
{
int actualType = virStorageSourceGetActualType(src);
virStorageFileBackendPtr backend;
if (!src)
return false;
if (src->drv) {
backend = src->drv->backend;
} else {
if (!(backend = virStorageFileBackendForTypeInternal(actualType,
src->protocol,
false)))
return false;
}
return !!backend->storageFileChown;
}
void
virStorageFileDeinit(virStorageSourcePtr src)
{

View File

@ -45,6 +45,8 @@ const char *virStorageFileGetUniqueIdentifier(virStorageSourcePtr src);
int virStorageFileAccess(virStorageSourcePtr src, int mode);
int virStorageFileChown(virStorageSourcePtr src, uid_t uid, gid_t gid);
bool virStorageFileSupportsSecurityDriver(virStorageSourcePtr src);
int virStorageFileGetMetadata(virStorageSourcePtr src,
uid_t uid, gid_t gid,
bool allow_probe)