mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 21:47:18 +00:00
storage: Ignore dangling symbolic link for filesystem pool
If there is a dangling symbolic link in filesystem pool, the pool will fail to start or refresh, this patch is to fix it by ignoring it with a warning log.
This commit is contained in:
parent
ee3efc41e6
commit
76965b800e
@ -977,7 +977,8 @@ virStorageBackendForType(int type) {
|
|||||||
/*
|
/*
|
||||||
* Allows caller to silently ignore files with improper mode
|
* Allows caller to silently ignore files with improper mode
|
||||||
*
|
*
|
||||||
* Returns -1 on error, -2 if file mode is unexpected.
|
* Returns -1 on error, -2 if file mode is unexpected or the
|
||||||
|
* volume is a dangling symbolic link.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
|
virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
|
||||||
@ -986,6 +987,12 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
|
if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
|
||||||
|
if ((errno == ENOENT || errno == ELOOP) &&
|
||||||
|
lstat(path, &sb) == 0) {
|
||||||
|
VIR_WARN("ignoring dangling symlink '%s'", path);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot open volume '%s'"),
|
_("cannot open volume '%s'"),
|
||||||
path);
|
path);
|
||||||
|
@ -651,7 +651,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
else {
|
else {
|
||||||
/* Silently ignore non-regular files,
|
/* Silently ignore non-regular files,
|
||||||
* eg '.' '..', 'lost+found' */
|
* eg '.' '..', 'lost+found', dangling symbolic link */
|
||||||
virStorageVolDefFree(vol);
|
virStorageVolDefFree(vol);
|
||||||
vol = NULL;
|
vol = NULL;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user