mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: Skip socket and fifo on pool-start
If pool directory contains special files like FIFO or sockets we want to skip those on pool-start or pool-refresh otherwise open() will get an error.
This commit is contained in:
@@ -1013,9 +1013,24 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *base = last_component(path);
|
char *base = last_component(path);
|
||||||
|
|
||||||
|
if (lstat(path, &sb) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("cannot stat file '%s'"),
|
||||||
|
path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S_ISFIFO(sb.st_mode)) {
|
||||||
|
VIR_WARN("ignoring FIFO '%s'", path);
|
||||||
|
return -2;
|
||||||
|
} else if (S_ISSOCK(sb.st_mode)) {
|
||||||
|
VIR_WARN("ignoring socket '%s'", path);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
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) &&
|
if ((errno == ENOENT || errno == ELOOP) &&
|
||||||
lstat(path, &sb) == 0) {
|
S_ISLNK(sb.st_mode)) {
|
||||||
VIR_WARN("ignoring dangling symlink '%s'", path);
|
VIR_WARN("ignoring dangling symlink '%s'", path);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
@@ -1026,14 +1041,6 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(fd, &sb) < 0) {
|
|
||||||
virReportSystemError(errno,
|
|
||||||
_("cannot stat file '%s'"),
|
|
||||||
path);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (S_ISREG(sb.st_mode))
|
if (S_ISREG(sb.st_mode))
|
||||||
mode = VIR_STORAGE_VOL_OPEN_REG;
|
mode = VIR_STORAGE_VOL_OPEN_REG;
|
||||||
else if (S_ISCHR(sb.st_mode))
|
else if (S_ISCHR(sb.st_mode))
|
||||||
|
|||||||
Reference in New Issue
Block a user