1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-10-13 11:33:16 +03:00

o Remove redundant symlink-handling code.

o When opening device, return error if its cached name is incorrect (eg if
  it's changed since the cache was generated).  This prevents use until
  the cache is rebuilt (eg with vgscan).  Doesn't catch every case.
This commit is contained in:
Alasdair Kergon
2002-01-23 18:55:01 +00:00
parent 975101d7d2
commit f7912d88b1
2 changed files with 12 additions and 40 deletions

View File

@@ -64,19 +64,30 @@ int dev_get_sectsize(struct device *dev, uint32_t *size)
int dev_open(struct device *dev, int flags)
{
struct stat buf;
const char *name = dev_name(dev);
/* FIXME Check flags (eg is write now reqd?) */
if (dev->fd >= 0) {
log_error("Device '%s' has already been opened", name);
return 0;
}
if ((stat(name, &buf) < 0) || (buf.st_rdev != dev->dev)) {
log_error("%s: stat failed: Has device name changed?", name);
return 0;
}
if ((dev->fd = open(name, flags)) < 0) {
log_sys_error("open", name);
return 0;
}
if ((fstat(dev->fd, &buf) < 0) || (buf.st_rdev != dev->dev)) {
log_error("%s: fstat failed: Has device name changed?", name);
dev_close(dev->fd);
return 0;
}
return 1;
}