1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Temporary device_exists() fixes.

This commit is contained in:
Alasdair Kergon 2006-02-03 19:44:59 +00:00
parent 4206c3db2e
commit d8f0eeb039

View File

@ -311,13 +311,23 @@ static int storepid(int lf)
return 1; return 1;
} }
/* FIXME This is unreliable: should use DM_DEVICE_INFO ioctl instead. */
/* Check, if a device exists. */ /* Check, if a device exists. */
static int device_exists(char *device) static int device_exists(char *device)
{ {
struct stat st_buf; struct stat st_buf;
char path2[PATH_MAX];
return !stat(device, &st_buf) && S_ISBLK(st_buf.st_mode); if (!device)
return 0;
if (device[0] == '/') /* absolute path */
return !stat(device, &st_buf) && S_ISBLK(st_buf.st_mode);
if (PATH_MAX <= snprintf(path2, PATH_MAX, "%s/%s", dm_dir(), device))
return 0;
return !stat(path2, &st_buf) && S_ISBLK(st_buf.st_mode);
} }
/* /*