pr->flags &= ~BLKID_FL_PRIVATE_FD;
+ if (parent->vfs) {
+ pr->vfs = ul_vfs_copy(parent->vfs);
+ if (!pr->vfs) {
+ blkid_free_probe(pr);
+ return NULL;
+ }
+ }
+
return pr;
}
}
if ((pr->flags & BLKID_FL_PRIVATE_FD) && pr->fd >= 0)
- close(pr->fd);
+ ul_vfs_close(pr->vfs, pr->fd);
blkid_probe_reset_buffers(pr);
blkid_probe_reset_values(pr);
blkid_probe_reset_hints(pr);
blkid_free_probe(pr->disk_probe);
DBG(LOWPROBE, ul_debug("free probe"));
+ free(pr->vfs);
free(pr);
}
ssize_t ret;
struct blkid_bufinfo *bf = NULL;
- if (lseek(pr->fd, real_off, SEEK_SET) == (off_t) -1) {
+ if (ul_vfs_lseek(pr->vfs, pr->fd, real_off, SEEK_SET) == (off_t) -1) {
errno = 0;
return NULL;
}
DBG(LOWPROBE, ul_debug("\tread: off=%"PRIu64" len=%"PRIu64"",
real_off, len));
- ret = read(pr->fd, bf->data, len);
+ ret = ul_vfs_read(pr->vfs, pr->fd, bf->data, len);
if (ret != (ssize_t) len) {
DBG(LOWPROBE, ul_debug("\tread failed: %m"));
remove_buffer(bf);
#ifdef CDROM_GET_CAPABILITY
-static int is_sector_readable(int fd, uint64_t sector)
+static int is_sector_readable(blkid_probe pr, uint64_t sector)
{
char buf[512];
ssize_t sz;
- if (lseek(fd, sector * 512, SEEK_SET) == (off_t) -1)
+ if (ul_vfs_lseek(pr->vfs, pr->fd, sector * 512, SEEK_SET) == (off_t) -1)
goto failed;
- sz = read(fd, buf, sizeof(buf));
+ sz = ul_vfs_read(pr->vfs, pr->fd, buf, sizeof(buf));
if (sz != (ssize_t) sizeof(buf))
goto failed;
nsectors = (last_written+1) << 2;
for (n = nsectors - 12; n < nsectors; n++) {
- if (!is_sector_readable(pr->fd, n))
+ if (!is_sector_readable(pr, n))
goto failed;
}
blkid_probe_reset_buffers(pr);
if ((pr->flags & BLKID_FL_PRIVATE_FD) && pr->fd >= 0)
- close(pr->fd);
+ ul_vfs_close(pr->vfs, pr->fd);
if (pr->disk_probe) {
blkid_free_probe(pr->disk_probe);
"do_wipe [offset=0x%"PRIx64" (%"PRIu64"), len=%zu, chain=%s, idx=%d, dryrun=%s]\n",
offset, offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
+ if (ul_vfs_lseek(pr->vfs, fd, offset, SEEK_SET) == (off_t) -1)
return BLKID_PROBE_ERROR;
if (!dryrun && len) {
memset(buf, 0, len);
/* wipen on device */
- if (ul_write_all(fd, buf, len))
+ if (ul_vfs_write_all(pr->vfs, fd, buf, len))
return BLKID_PROBE_ERROR;
- if (fsync(fd) != 0)
+ if (ul_vfs_fsync(pr->vfs, fd) != 0)
return BLKID_PROBE_ERROR;
} else {
#ifdef HAVE_LINUX_BLKZONED_H