Changeset View
Changeset View
Standalone View
Standalone View
stand/libsa/zfs/zfs.c
Show First 20 Lines • Show All 821 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Get bootonce value by key. The bootonce <key, value> pair is removed | * Get bootonce value by key. The bootonce <key, value> pair is removed | ||||
* from the bootenv nvlist and the remaining nvlist is committed back to disk. | * from the bootenv nvlist and the remaining nvlist is committed back to disk. | ||||
*/ | */ | ||||
int | int | ||||
zfs_get_bootonce(void *vdev, const char *key, char *buf, size_t size) | zfs_get_bootonce(void *vdev, const char *key, char *buf, size_t size) | ||||
{ | { | ||||
nvlist_t *benv; | spa_t *spa; | ||||
char *result = NULL; | |||||
int result_size, rv; | |||||
if ((rv = zfs_get_bootenv(vdev, &benv)) != 0) | if ((spa = spa_find_by_dev((struct zfs_devdesc *)vdev)) == NULL) | ||||
return (rv); | return (ENXIO); | ||||
if ((rv = nvlist_find(benv, key, DATA_TYPE_STRING, NULL, | return (zfs_get_bootonce_spa(spa, key, buf, size)); | ||||
&result, &result_size)) == 0) { | |||||
if (result_size == 0) { | |||||
/* ignore empty string */ | |||||
rv = ENOENT; | |||||
} else { | |||||
size = MIN((size_t)result_size + 1, size); | |||||
strlcpy(buf, result, size); | |||||
} | |||||
(void) nvlist_remove(benv, key, DATA_TYPE_STRING); | |||||
(void) zfs_set_bootenv(vdev, benv); | |||||
} | |||||
return (rv); | |||||
} | } | ||||
/* | /* | ||||
* nvstore backend. | * nvstore backend. | ||||
*/ | */ | ||||
static int zfs_nvstore_setter(void *, int, const char *, | static int zfs_nvstore_setter(void *, int, const char *, | ||||
const void *, size_t); | const void *, size_t); | ||||
▲ Show 20 Lines • Show All 1,179 Lines • Show Last 20 Lines |