int
virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
- unsigned long long *allocation,
- unsigned long long *capacity,
bool withBlockVolFormat,
unsigned int openflags)
{
goto cleanup;
fd = ret;
- if ((ret = virStorageBackendUpdateVolTargetInfoFD(target,
- fd,
- &sb,
- allocation,
- capacity)) < 0)
+ if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb)) < 0)
goto cleanup;
if (withBlockVolFormat) {
int
virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
- bool withCapacity,
bool withBlockVolFormat,
unsigned int openflags)
{
int ret;
if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
- &vol->target.allocation,
- withCapacity ? &vol->target.capacity : NULL,
withBlockVolFormat,
openflags)) < 0)
return ret;
if (vol->backingStore.path &&
(ret = virStorageBackendUpdateVolTargetInfo(&vol->backingStore,
- NULL, NULL,
withBlockVolFormat,
VIR_STORAGE_VOL_OPEN_DEFAULT)) < 0)
return ret;
int
virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
int fd,
- struct stat *sb,
- unsigned long long *allocation,
- unsigned long long *capacity)
+ struct stat *sb)
{
#if WITH_SELINUX
security_context_t filecon = NULL;
#endif
- if (allocation) {
- if (S_ISREG(sb->st_mode)) {
+ if (S_ISREG(sb->st_mode)) {
#ifndef WIN32
- *allocation = (unsigned long long)sb->st_blocks *
- (unsigned long long)DEV_BSIZE;
+ target->allocation = (unsigned long long)sb->st_blocks *
+ (unsigned long long)DEV_BSIZE;
#else
- *allocation = sb->st_size;
+ target->allocation = sb->st_size;
#endif
- /* Regular files may be sparse, so logical size (capacity) is not same
- * as actual allocation above
- */
- if (capacity)
- *capacity = sb->st_size;
- } else if (S_ISDIR(sb->st_mode)) {
- *allocation = 0;
- if (capacity)
- *capacity = 0;
-
- } else if (fd >= 0) {
- off_t end;
- /* XXX this is POSIX compliant, but doesn't work for CHAR files,
- * only BLOCK. There is a Linux specific ioctl() for getting
- * size of both CHAR / BLOCK devices we should check for in
- * configure
- */
- end = lseek(fd, 0, SEEK_END);
- if (end == (off_t)-1) {
- virReportSystemError(errno,
- _("cannot seek to end of file '%s'"),
- target->path);
- return -1;
- }
- *allocation = end;
- if (capacity)
- *capacity = end;
+ /* Regular files may be sparse, so logical size (capacity) is not same
+ * as actual allocation above
+ */
+ target->capacity = sb->st_size;
+ } else if (S_ISDIR(sb->st_mode)) {
+ target->allocation = 0;
+ target->capacity = 0;
+ } else if (fd >= 0) {
+ off_t end;
+ /* XXX this is POSIX compliant, but doesn't work for CHAR files,
+ * only BLOCK. There is a Linux specific ioctl() for getting
+ * size of both CHAR / BLOCK devices we should check for in
+ * configure
+ */
+ end = lseek(fd, 0, SEEK_END);
+ if (end == (off_t)-1) {
+ virReportSystemError(errno,
+ _("cannot seek to end of file '%s'"),
+ target->path);
+ return -1;
}
+ target->allocation = end;
+ target->capacity = end;
}
if (!target->perms && VIR_ALLOC(target->perms) < 0)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
- bool withCapacity,
bool withBlockVolFormat,
unsigned int openflags);
int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
- unsigned long long *allocation,
- unsigned long long *capacity,
bool withBlockVolFormat,
unsigned int openflags);
int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
int fd,
- struct stat *sb,
- unsigned long long *allocation,
- unsigned long long *capacity);
+ struct stat *sb);
char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
const char *devpath,
}
/* Refresh allocation/capacity/perms */
- if (virStorageBackendUpdateVolInfo(vol, true, false,
+ if (virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
return -1;
virStorageBackendProbeTarget(virStorageSourcePtr target,
char **backingStore,
int *backingStoreFormat,
- unsigned long long *allocation,
- unsigned long long *capacity,
virStorageEncryptionPtr *encryption)
{
int fd = -1;
goto error; /* Take care to propagate ret, it is not always -1 */
fd = ret;
- if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb,
- allocation,
- capacity)) < 0) {
+ if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb)) < 0) {
goto error;
}
ret = 0;
}
- if (capacity && meta && meta->capacity)
- *capacity = meta->capacity;
+ if (meta && meta->capacity)
+ target->capacity = meta->capacity;
if (encryption && meta && meta->encrypted) {
if (VIR_ALLOC(*encryption) < 0)
if ((ret = virStorageBackendProbeTarget(&vol->target,
&backingStore,
&backingStoreFormat,
- &vol->target.allocation,
- &vol->target.capacity,
&vol->target.encryption)) < 0) {
if (ret == -2) {
/* Silently ignore non-regular files,
vol->backingStore.format = backingStoreFormat;
if (virStorageBackendUpdateVolTargetInfo(&vol->backingStore,
- NULL, NULL, false,
+ false,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
/* The backing file is currently unavailable, the capacity,
* allocation, owner, group and mode are unknown. Just log the
int ret;
/* Refresh allocation / permissions info in case its changed */
- ret = virStorageBackendUpdateVolInfo(vol, false, false,
+ ret = virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_FS_OPEN_FLAGS);
if (ret < 0)
return ret;
if (VIR_ALLOC(vol) < 0)
goto cleanup;
- if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st,
- &vol->target.allocation,
- &vol->target.capacity) < 0)
+ if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st) < 0)
goto cleanup;
if (virStorageBackendGlusterSetMetadata(state, vol, name) < 0)
if (!vol->key && VIR_STRDUP(vol->key, groups[2]) < 0)
goto cleanup;
- if (virStorageBackendUpdateVolInfo(vol, true, false,
+ if (virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
goto cleanup;
if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0)
goto cleanup;
- if (virStorageBackendUpdateVolInfo(vol, true, true,
+ if (virStorageBackendUpdateVolInfo(vol, true,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
goto cleanup;
}
goto free_vol;
}
- if (virStorageBackendUpdateVolInfo(vol, true, true,
+ if (virStorageBackendUpdateVolInfo(vol, true,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to update volume for '%s'"),