Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Show First 20 Lines • Show All 3,648 Lines • ▼ Show 20 Lines | if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) { | ||||
return (SET_ERROR(ENOTSUP)); | return (SET_ERROR(ENOTSUP)); | ||||
} | } | ||||
error = spa_history_log(spa, message); | error = spa_history_log(spa, message); | ||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef __FreeBSD__ | /* | ||||
static const zfs_ioc_key_t zfs_keys_nextboot[] = { | * This ioctl is used to set the bootenv configuration on the current | ||||
{"command", DATA_TYPE_STRING, 0}, | * pool. This configuration is stored in the second padding area of the label, | ||||
* and it is used by the GRUB bootloader used on Linux to store the contents | |||||
* of the grubenv file. The file is stored as raw ASCII, and is protected by | |||||
* an embedded checksum. By default, GRUB will check if the boot filesystem | |||||
* supports storing the environment data in a special location, and if so, | |||||
* will invoke filesystem specific logic to retrieve it. This can be overriden | |||||
* by a variable, should the user so desire. | |||||
*/ | |||||
/* ARGSUSED */ | |||||
static const zfs_ioc_key_t zfs_keys_set_bootenv[] = { | |||||
{"<keys>", DATA_TYPE_ANY, ZK_OPTIONAL | ZK_WILDCARDLIST}, | |||||
}; | }; | ||||
static int | static int | ||||
zfs_ioc_nextboot(const char *unused, nvlist_t *innvl, nvlist_t *outnvl) | zfs_ioc_set_bootenv(const char *name, nvlist_t *innvl, nvlist_t *outnvl) | ||||
{ | { | ||||
char name[MAXNAMELEN]; | |||||
spa_t *spa; | |||||
vdev_t *vd; | |||||
char *command; | |||||
uint64_t pool_guid; | |||||
uint64_t vdev_guid; | |||||
int error; | int error; | ||||
spa_t *spa; | |||||
if (nvlist_lookup_uint64(innvl, | if ((error = spa_open(name, &spa, FTAG)) != 0) | ||||
ZPOOL_CONFIG_POOL_GUID, &pool_guid) != 0) | return (error); | ||||
return (EINVAL); | spa_vdev_state_enter(spa, SCL_ALL); | ||||
if (nvlist_lookup_uint64(innvl, | error = vdev_label_write_bootenv(spa->spa_root_vdev, innvl); | ||||
ZPOOL_CONFIG_GUID, &vdev_guid) != 0) | (void) spa_vdev_state_exit(spa, NULL, 0); | ||||
return (EINVAL); | spa_close(spa, FTAG); | ||||
command = fnvlist_lookup_string(innvl, "command"); | return (error); | ||||
} | |||||
mutex_enter(&spa_namespace_lock); | static const zfs_ioc_key_t zfs_keys_get_bootenv[] = { | ||||
spa = spa_by_guid(pool_guid, vdev_guid); | /* no nvl keys */ | ||||
if (spa != NULL) | }; | ||||
strcpy(name, spa_name(spa)); | |||||
mutex_exit(&spa_namespace_lock); | |||||
if (spa == NULL) | |||||
return (ENOENT); | |||||
/* ARGSUSED */ | |||||
static int | |||||
zfs_ioc_get_bootenv(const char *name, nvlist_t *innvl, nvlist_t *outnvl) | |||||
{ | |||||
spa_t *spa; | |||||
int error; | |||||
if ((error = spa_open(name, &spa, FTAG)) != 0) | if ((error = spa_open(name, &spa, FTAG)) != 0) | ||||
return (error); | return (error); | ||||
spa_vdev_state_enter(spa, SCL_ALL); | spa_vdev_state_enter(spa, SCL_ALL); | ||||
vd = spa_lookup_by_guid(spa, vdev_guid, B_TRUE); | error = vdev_label_read_bootenv(spa->spa_root_vdev, outnvl); | ||||
if (vd == NULL) { | (void) spa_vdev_state_exit(spa, NULL, 0); | ||||
(void) spa_vdev_state_exit(spa, NULL, ENXIO); | |||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
return (ENODEV); | return (error); | ||||
} | } | ||||
error = vdev_label_write_pad2(vd, command, strlen(command)); | |||||
#ifdef __FreeBSD__ | |||||
static const zfs_ioc_key_t zfs_keys_nextboot[] = { | |||||
{"command", DATA_TYPE_STRING, 0}, | |||||
}; | |||||
static int | |||||
zfs_ioc_nextboot(const char *name, nvlist_t *innvl, nvlist_t *outnvl) | |||||
{ | |||||
spa_t *spa; | |||||
int error; | |||||
if ((error = spa_open(name, &spa, FTAG)) != 0) | |||||
return (error); | |||||
spa_vdev_state_enter(spa, SCL_ALL); | |||||
error = vdev_label_write_bootenv(spa->spa_root_vdev, innvl); | |||||
(void) spa_vdev_state_exit(spa, NULL, 0); | (void) spa_vdev_state_exit(spa, NULL, 0); | ||||
txg_wait_synced(spa->spa_dsl_pool, 0); | |||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* The dp_config_rwlock must not be held when calling this, because the | * The dp_config_rwlock must not be held when calling this, because the | ||||
* unmount may need to write out data. | * unmount may need to write out data. | ||||
▲ Show 20 Lines • Show All 2,850 Lines • ▼ Show 20 Lines | zfs_ioctl_init(void) | ||||
zfs_ioctl_register("sync", ZFS_IOC_POOL_SYNC, | zfs_ioctl_register("sync", ZFS_IOC_POOL_SYNC, | ||||
zfs_ioc_pool_sync, zfs_secpolicy_none, POOL_NAME, | zfs_ioc_pool_sync, zfs_secpolicy_none, POOL_NAME, | ||||
POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_FALSE, | POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_FALSE, | ||||
zfs_keys_pool_sync, ARRAY_SIZE(zfs_keys_pool_sync)); | zfs_keys_pool_sync, ARRAY_SIZE(zfs_keys_pool_sync)); | ||||
zfs_ioctl_register("reopen", ZFS_IOC_POOL_REOPEN, zfs_ioc_pool_reopen, | zfs_ioctl_register("reopen", ZFS_IOC_POOL_REOPEN, zfs_ioc_pool_reopen, | ||||
zfs_secpolicy_config, POOL_NAME, POOL_CHECK_SUSPENDED, B_TRUE, | zfs_secpolicy_config, POOL_NAME, POOL_CHECK_SUSPENDED, B_TRUE, | ||||
B_TRUE, zfs_keys_pool_reopen, ARRAY_SIZE(zfs_keys_pool_reopen)); | B_TRUE, zfs_keys_pool_reopen, ARRAY_SIZE(zfs_keys_pool_reopen)); | ||||
zfs_ioctl_register("set_bootenv", ZFS_IOC_SET_BOOTENV, | |||||
zfs_ioc_set_bootenv, zfs_secpolicy_config, POOL_NAME, | |||||
POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_TRUE, | |||||
zfs_keys_set_bootenv, ARRAY_SIZE(zfs_keys_set_bootenv)); | |||||
zfs_ioctl_register("get_bootenv", ZFS_IOC_GET_BOOTENV, | |||||
zfs_ioc_get_bootenv, zfs_secpolicy_none, POOL_NAME, | |||||
POOL_CHECK_SUSPENDED, B_FALSE, B_TRUE, | |||||
zfs_keys_get_bootenv, ARRAY_SIZE(zfs_keys_get_bootenv)); | |||||
/* IOCTLS that use the legacy function signature */ | /* IOCTLS that use the legacy function signature */ | ||||
zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze, | zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze, | ||||
zfs_secpolicy_config, NO_NAME, B_FALSE, POOL_CHECK_READONLY); | zfs_secpolicy_config, NO_NAME, B_FALSE, POOL_CHECK_READONLY); | ||||
zfs_ioctl_register_pool(ZFS_IOC_POOL_CREATE, zfs_ioc_pool_create, | zfs_ioctl_register_pool(ZFS_IOC_POOL_CREATE, zfs_ioc_pool_create, | ||||
zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE); | zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE); | ||||
▲ Show 20 Lines • Show All 1,054 Lines • Show Last 20 Lines |