Changeset View
Changeset View
Standalone View
Standalone View
stand/libsa/zfs/zfs.c
Show First 20 Lines • Show All 412 Lines • ▼ Show 20 Lines | vdev_read(vdev_t *vdev, void *priv, off_t offset, void *buf, size_t bytes) | ||||
full_sec_size = total_size; | full_sec_size = total_size; | ||||
if (head > 0) | if (head > 0) | ||||
full_sec_size -= secsz; | full_sec_size -= secsz; | ||||
if (do_tail_read) | if (do_tail_read) | ||||
full_sec_size -= secsz; | full_sec_size -= secsz; | ||||
/* Return of partial sector data requires a bounce buffer. */ | /* Return of partial sector data requires a bounce buffer. */ | ||||
if ((head > 0) || do_tail_read) { | if ((head > 0) || do_tail_read) { | ||||
bouncebuf = zfs_alloc(secsz); | bouncebuf = malloc(secsz); | ||||
if (bouncebuf == NULL) { | if (bouncebuf == NULL) { | ||||
printf("vdev_read: out of memory\n"); | printf("vdev_read: out of memory\n"); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
} | } | ||||
if (lseek(fd, start_sec * secsz, SEEK_SET) == -1) { | if (lseek(fd, start_sec * secsz, SEEK_SET) == -1) { | ||||
ret = errno; | ret = errno; | ||||
Show All 29 Lines | if (res != secsz) { | ||||
goto error; | goto error; | ||||
} | } | ||||
memcpy(outbuf, bouncebuf, secsz - tail); | memcpy(outbuf, bouncebuf, secsz - tail); | ||||
} | } | ||||
ret = 0; | ret = 0; | ||||
error: | error: | ||||
if (bouncebuf != NULL) | if (bouncebuf != NULL) | ||||
zfs_free(bouncebuf, secsz); | free(bouncebuf); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
static int | static int | ||||
zfs_dev_init(void) | zfs_dev_init(void) | ||||
{ | { | ||||
spa_t *spa; | spa_t *spa; | ||||
spa_t *next; | spa_t *next; | ||||
▲ Show 20 Lines • Show All 593 Lines • Show Last 20 Lines |