Index: libvirt-0.5.1/src/storage_backend_fs.c =================================================================== --- libvirt-0.5.1.orig/src/storage_backend_fs.c +++ libvirt-0.5.1/src/storage_backend_fs.c @@ -381,6 +381,8 @@ 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, @@ -389,14 +391,26 @@ 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; } @@ -735,12 +749,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; }