libblkid: don't require udev symlinks verification for non-root users

There is noway how to verify LABEL/UUID for non-root users, we have to
follow udev symlinks or use cached information from blkid.tab. Use
unverified symlinks is faster.

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2009-06-17 00:30:51 +02:00
parent 0fae284a7a
commit e9799b6d29
1 changed files with 7 additions and 2 deletions

View File

@ -42,6 +42,7 @@ static int verify_tag(const char *devname, const char *name, const char *value)
int fd = -1, rc = -1;
size_t len;
const char *data;
int errsv = 0;
pr = blkid_new_probe();
if (!pr)
@ -50,8 +51,10 @@ static int verify_tag(const char *devname, const char *name, const char *value)
blkid_probe_set_request(pr, BLKID_PROBREQ_LABEL | BLKID_PROBREQ_UUID);
fd = open(devname, O_RDONLY);
if (fd < 0)
if (fd < 0) {
errsv = errno;
goto done;
}
if (blkid_probe_set_device(pr, fd, 0, 0))
goto done;
rc = blkid_do_safeprobe(pr);
@ -66,7 +69,9 @@ done:
if (fd >= 0)
close(fd);
blkid_free_probe(pr);
return rc;
/* for non-root users we use unverified udev links */
return errsv == EACCES ? 0 : rc;
}
/**