/*
* virStorageBackendUpdateVolTargetInfoFD:
- * @conn: connection to report errors on
* @target: target definition ptr of volume to update
- * @fd: fd of storage volume to update, via virStorageBackendOpenVol*
+ * @fd: fd of storage volume to update, via virStorageBackendOpenVol*, or -1
+ * @sb: details about file (must match @fd, if that is provided)
* @allocation: If not NULL, updated allocation information will be stored
* @capacity: If not NULL, updated capacity info will be stored
*
if (capacity)
*capacity = 0;
- } else {
+ } 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
#if WITH_SELINUX
/* XXX: make this a security driver call */
- if (fgetfilecon_raw(fd, &filecon) == -1) {
+ if (fd >= 0 && fgetfilecon_raw(fd, &filecon) == -1) {
if (errno != ENODATA && errno != ENOTSUP) {
virReportSystemError(errno,
_("cannot get file context of '%s'"),
if (VIR_ALLOC(vol) < 0)
goto cleanup;
+
+ if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st,
+ &vol->allocation,
+ &vol->capacity) < 0)
+ goto cleanup;
+
if (VIR_STRDUP(vol->name, name) < 0)
goto cleanup;
if (virAsprintf(&vol->key, "%s%s%s", state->volname, state->dir,
/* FIXME - must open files to determine if they are non-raw */
vol->type = VIR_STORAGE_VOL_NETWORK;
vol->target.format = VIR_STORAGE_FILE_RAW;
- vol->capacity = vol->allocation = st->st_size;
*volptr = vol;
vol = NULL;