SHA256
1
0
forked from pool/libvirt
libvirt/fs-storage-driver.patch

62 lines
1.7 KiB
Diff
Raw Normal View History

Index: libvirt-0.4.5/src/storage_backend_fs.c
===================================================================
--- libvirt-0.4.5.orig/src/storage_backend_fs.c
+++ libvirt-0.4.5/src/storage_backend_fs.c
@@ -583,7 +583,9 @@ virStorageBackendFileSystemIsMounted(vir
virStoragePoolObjPtr pool) {
FILE *mtab;
struct mntent *ent;
-
+ char *mpoint;
+ size_t len;
+
if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot read %s: %s"),
@@ -591,14 +593,27 @@ virStorageBackendFileSystemIsMounted(vir
return -1;
}
+ if ((mpoint = strdup(pool->def->target.path)) == NULL) {
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY,
+ "%s", strerror(errno));
+ return -1;
+ }
+
+ len = strlen(mpoint);
+ if (mpoint[len-1] == '/')
+ mpoint[len-1] = NULL;
+
+
while ((ent = getmntent(mtab)) != NULL) {
- if (STREQ(ent->mnt_dir, pool->def->target.path)) {
+ if (STREQ(ent->mnt_dir, mpoint)) {
fclose(mtab);
+ free(mpoint);
return 1;
}
}
fclose(mtab);
+ free(mpoint);
return 0;
}
@@ -951,12 +966,16 @@ virStorageBackendFileSystemDelete(virCon
{
/* XXX delete all vols first ? */
+ /* target.path is never created AFAIKT, so dont delete it. */
+#if 0
+
if (unlink(pool->def->target.path) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot unlink path '%s': %s"),
pool->def->target.path, strerror(errno));
return -1;
}
+#endif
return 0;
}