|
Packit |
2ba279 |
GQuark bd_nvdimm_error_quark (void) {
|
|
Packit |
2ba279 |
return g_quark_from_static_string ("g-bd-nvdimm-error-quark");
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* BDNVDIMMNamespaceInfo:
|
|
Packit |
2ba279 |
* @dev: namespace device name ("namespaceX.Y")
|
|
Packit |
2ba279 |
* @mode: mode of the namespace (BDNVDIMMNamespaceMode)
|
|
Packit |
2ba279 |
* @size: size of the namespace
|
|
Packit |
2ba279 |
* @uuid: UUID of the namespace
|
|
Packit |
2ba279 |
* @sector_size: sector size of the namespace (0 for non-sector namespaces)
|
|
Packit |
2ba279 |
* @blockdev: name of the block device for the namespace
|
|
Packit |
2ba279 |
* @enabled: whether the namespace is enabled or not
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_info_free: (skip)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Frees @info.
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
void bd_nvdimm_namespace_info_free (BDNVDIMMNamespaceInfo *info) {
|
|
Packit |
2ba279 |
if (info == NULL)
|
|
Packit |
2ba279 |
return;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
g_free (info->dev);
|
|
Packit |
2ba279 |
g_free (info->uuid);
|
|
Packit |
2ba279 |
g_free (info->blockdev);
|
|
Packit |
2ba279 |
g_free (info);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_info_copy: (skip)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Creates a new copy of @info.
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
BDNVDIMMNamespaceInfo* bd_nvdimm_namespace_info_copy (BDNVDIMMNamespaceInfo *info) {
|
|
Packit |
2ba279 |
if (info == NULL)
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
BDNVDIMMNamespaceInfo *new_info = g_new0 (BDNVDIMMNamespaceInfo, 1);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
new_info->dev = info->dev;
|
|
Packit |
2ba279 |
new_info->mode = info->mode;
|
|
Packit |
2ba279 |
new_info->size = info->size;
|
|
Packit |
2ba279 |
new_info->uuid = g_strdup (info->uuid);
|
|
Packit |
2ba279 |
new_info->sector_size = info->sector_size;
|
|
Packit |
2ba279 |
new_info->blockdev = g_strdup (info->blockdev);
|
|
Packit |
2ba279 |
new_info->enabled = info->enabled;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
return new_info;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
GType bd_nvdimm_namespace_info_get_type () {
|
|
Packit |
2ba279 |
static GType type = 0;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
if (G_UNLIKELY(type == 0)) {
|
|
Packit |
2ba279 |
type = g_boxed_type_register_static("BDNVDIMMNamespaceInfo",
|
|
Packit |
2ba279 |
(GBoxedCopyFunc) bd_nvdimm_namespace_info_copy,
|
|
Packit |
2ba279 |
(GBoxedFreeFunc) bd_nvdimm_namespace_info_free);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
return type;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean bd_nvdimm_is_tech_avail_stub (BDNVDIMMTech tech, guint64 mode, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_is_tech_avail' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_is_tech_avail' called, but not implemented!");
|
|
Packit |
2ba279 |
return FALSE;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean (*_bd_nvdimm_is_tech_avail) (BDNVDIMMTech tech, guint64 mode, GError **error) = bd_nvdimm_is_tech_avail_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_is_tech_avail:
|
|
Packit |
2ba279 |
* @tech: the queried tech
|
|
Packit |
2ba279 |
* @mode: a bit mask of queried modes of operation (#BDNVDIMMTechMode) for @tech
|
|
Packit |
2ba279 |
* @error: (out): place to store error (details about why the @tech-@mode combination is not available)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: whether the @tech-@mode combination is available -- supported by the
|
|
Packit |
2ba279 |
* plugin implementation and having all the runtime dependencies available
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
gboolean bd_nvdimm_is_tech_avail (BDNVDIMMTech tech, guint64 mode, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_is_tech_avail (tech, mode, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static BDNVDIMMNamespaceMode bd_nvdimm_namespace_get_mode_from_str_stub (const gchar *mode_str, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_get_mode_from_str' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_get_mode_from_str' called, but not implemented!");
|
|
Packit |
2ba279 |
return 0;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static BDNVDIMMNamespaceMode (*_bd_nvdimm_namespace_get_mode_from_str) (const gchar *mode_str, GError **error) = bd_nvdimm_namespace_get_mode_from_str_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_get_mode_from_str:
|
|
Packit |
2ba279 |
* @mode_str: string representation of mode
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: mode matching the @mode_str given or %BD_NVDIMM_NAMESPACE_MODE_UNKNOWN in case of no match
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: always available
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
BDNVDIMMNamespaceMode bd_nvdimm_namespace_get_mode_from_str (const gchar *mode_str, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_get_mode_from_str (mode_str, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static const gchar* bd_nvdimm_namespace_get_mode_str_stub (BDNVDIMMNamespaceMode mode, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_get_mode_str' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_get_mode_str' called, but not implemented!");
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static const gchar* (*_bd_nvdimm_namespace_get_mode_str) (BDNVDIMMNamespaceMode mode, GError **error) = bd_nvdimm_namespace_get_mode_str_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_get_mode_str:
|
|
Packit |
2ba279 |
* @mode: mode to get string representation of
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: (transfer none): string representation of @mode or %NULL in case of error
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: always available
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
const gchar* bd_nvdimm_namespace_get_mode_str (BDNVDIMMNamespaceMode mode, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_get_mode_str (mode, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gchar* bd_nvdimm_namespace_get_devname_stub (const gchar *device, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_get_devname' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_get_devname' called, but not implemented!");
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gchar* (*_bd_nvdimm_namespace_get_devname) (const gchar *device, GError **error) = bd_nvdimm_namespace_get_devname_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_get_devname:
|
|
Packit |
2ba279 |
* @device: name or path of a block device (e.g. "/dev/pmem0")
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: (transfer full): namespace device name (e.g. "namespaceX.Y") for @device
|
|
Packit |
2ba279 |
* or %NULL if @device is not a NVDIMM namespace
|
|
Packit |
2ba279 |
* (@error may be set to indicate error)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
gchar* bd_nvdimm_namespace_get_devname (const gchar *device, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_get_devname (device, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean bd_nvdimm_namespace_enable_stub (const gchar *namespace, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_enable' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_enable' called, but not implemented!");
|
|
Packit |
2ba279 |
return FALSE;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean (*_bd_nvdimm_namespace_enable) (const gchar *namespace, const BDExtraArg **extra, GError **error) = bd_nvdimm_namespace_enable_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_enable:
|
|
Packit |
2ba279 |
* @namespace: name of the namespace to enable
|
|
Packit |
2ba279 |
* @extra: (allow-none) (array zero-terminated=1): extra options (currently unused)
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: whether the @namespace was successfully enabled or not
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_ACTIVATE_DEACTIVATE
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
gboolean bd_nvdimm_namespace_enable (const gchar *namespace, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_enable (namespace, extra, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean bd_nvdimm_namespace_disable_stub (const gchar *namespace, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_disable' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_disable' called, but not implemented!");
|
|
Packit |
2ba279 |
return FALSE;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean (*_bd_nvdimm_namespace_disable) (const gchar *namespace, const BDExtraArg **extra, GError **error) = bd_nvdimm_namespace_disable_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_disable:
|
|
Packit |
2ba279 |
* @namespace: name of the namespace to disable
|
|
Packit |
2ba279 |
* @extra: (allow-none) (array zero-terminated=1): extra options (currently unused)
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: whether the @namespace was successfully disabled or not
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_ACTIVATE_DEACTIVATE
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
gboolean bd_nvdimm_namespace_disable (const gchar *namespace, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_disable (namespace, extra, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static BDNVDIMMNamespaceInfo* bd_nvdimm_namespace_info_stub (const gchar *namespace, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_info' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_info' called, but not implemented!");
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static BDNVDIMMNamespaceInfo* (*_bd_nvdimm_namespace_info) (const gchar *namespace, const BDExtraArg **extra, GError **error) = bd_nvdimm_namespace_info_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_info:
|
|
Packit |
2ba279 |
* @namespace: namespace to get information about
|
|
Packit |
2ba279 |
* @extra: (allow-none) (array zero-terminated=1): extra options (currently unused)
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: (transfer full): information about given namespace or %NULL if no such
|
|
Packit |
2ba279 |
* namespace was found (@error may be set to indicate error)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
BDNVDIMMNamespaceInfo* bd_nvdimm_namespace_info (const gchar *namespace, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_info (namespace, extra, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static BDNVDIMMNamespaceInfo** bd_nvdimm_list_namespaces_stub (const gchar *bus, const gchar *region, gboolean idle, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_list_namespaces' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_list_namespaces' called, but not implemented!");
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static BDNVDIMMNamespaceInfo** (*_bd_nvdimm_list_namespaces) (const gchar *bus, const gchar *region, gboolean idle, const BDExtraArg **extra, GError **error) = bd_nvdimm_list_namespaces_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_list_namespaces:
|
|
Packit |
2ba279 |
* @bus: (allow-none): return only namespaces on given bus (specified by name),
|
|
Packit |
2ba279 |
* %NULL may be specified to return namespaces from all buses
|
|
Packit |
2ba279 |
* @region: (allow-none): return only namespaces on given region (specified by regionX name or region id),
|
|
Packit |
2ba279 |
* %NULL may be specified to return namespaces from all regions
|
|
Packit |
2ba279 |
* @idle: whether to list idle (not enabled) namespaces too
|
|
Packit |
2ba279 |
* @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now
|
|
Packit |
2ba279 |
* passed to the 'ndctl' utility)
|
|
Packit |
2ba279 |
* @error: (out): place to store error (if any)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: (array zero-terminated=1): information about the namespaces on @bus and @region or
|
|
Packit |
2ba279 |
* %NULL if no namespaces were found (@error may be set to indicate error)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
BDNVDIMMNamespaceInfo** bd_nvdimm_list_namespaces (const gchar *bus, const gchar *region, gboolean idle, const BDExtraArg **extra, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_list_namespaces (bus, region, idle, extra, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean bd_nvdimm_namespace_reconfigure_stub (const gchar* namespace, BDNVDIMMNamespaceMode mode, gboolean force, const BDExtraArg **extra, GError** error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namespace_reconfigure' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namespace_reconfigure' called, but not implemented!");
|
|
Packit |
2ba279 |
return FALSE;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean (*_bd_nvdimm_namespace_reconfigure) (const gchar* namespace, BDNVDIMMNamespaceMode mode, gboolean force, const BDExtraArg **extra, GError** error) = bd_nvdimm_namespace_reconfigure_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namespace_reconfigure:
|
|
Packit |
2ba279 |
* @namespace: name of the namespace to recofigure
|
|
Packit |
2ba279 |
* @mode: mode type to set (memory/sector/raw/dax)
|
|
Packit |
2ba279 |
* @error: (out): place to store error if any
|
|
Packit |
2ba279 |
* @extra: (allow-none) (array zero-terminated=1): extra options for the creation (right now
|
|
Packit |
2ba279 |
* passed to the 'ndctl' utility)
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: whether @namespace was successfully reconfigured or not
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
gboolean bd_nvdimm_namespace_reconfigure (const gchar* namespace, BDNVDIMMNamespaceMode mode, gboolean force, const BDExtraArg **extra, GError** error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namespace_reconfigure (namespace, mode, force, extra, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static const guint64 * bd_nvdimm_namepace_get_supported_sector_sizes_stub (BDNVDIMMNamespaceMode mode, GError **error) {
|
|
Packit |
2ba279 |
g_critical ("The function 'bd_nvdimm_namepace_get_supported_sector_sizes' called, but not implemented!");
|
|
Packit |
2ba279 |
g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
|
|
Packit |
2ba279 |
"The function 'bd_nvdimm_namepace_get_supported_sector_sizes' called, but not implemented!");
|
|
Packit |
2ba279 |
return 0;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static const guint64 * (*_bd_nvdimm_namepace_get_supported_sector_sizes) (BDNVDIMMNamespaceMode mode, GError **error) = bd_nvdimm_namepace_get_supported_sector_sizes_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
/**
|
|
Packit |
2ba279 |
* bd_nvdimm_namepace_get_supported_sector_sizes:
|
|
Packit |
2ba279 |
* @mode: namespace mode
|
|
Packit |
2ba279 |
* @error: (out): place to store error if any
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Returns: (transfer none) (array zero-terminated=1): list of supported sector sizes for @mode
|
|
Packit |
2ba279 |
*
|
|
Packit |
2ba279 |
* Tech category: %BD_NVDIMM_TECH_NAMESPACE-%BD_NVDIMM_TECH_MODE_QUERY
|
|
Packit |
2ba279 |
*/
|
|
Packit |
2ba279 |
const guint64 * bd_nvdimm_namepace_get_supported_sector_sizes (BDNVDIMMNamespaceMode mode, GError **error) {
|
|
Packit |
2ba279 |
return _bd_nvdimm_namepace_get_supported_sector_sizes (mode, error);
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gpointer load_nvdimm_from_plugin(const gchar *so_name) {
|
|
Packit |
2ba279 |
void *handle = NULL;
|
|
Packit |
2ba279 |
char *error = NULL;
|
|
Packit |
2ba279 |
gboolean (*check_fn) (void) = NULL;
|
|
Packit |
2ba279 |
gboolean (*init_fn) (void) = NULL;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
handle = dlopen(so_name, RTLD_LAZY);
|
|
Packit |
2ba279 |
if (!handle) {
|
|
Packit |
2ba279 |
g_warning("failed to load module nvdimm: %s", dlerror());
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&check_fn) = dlsym(handle, "bd_nvdimm_check_deps");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_debug("failed to load the check() function for nvdimm: %s", error);
|
|
Packit |
2ba279 |
/* coverity[dead_error_condition] */
|
|
Packit |
2ba279 |
if (!g_getenv ("LIBBLOCKDEV_SKIP_DEP_CHECKS") && check_fn && !check_fn()) {
|
|
Packit |
2ba279 |
dlclose(handle);
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
check_fn = NULL;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&init_fn) = dlsym(handle, "bd_nvdimm_init");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_debug("failed to load the init() function for nvdimm: %s", error);
|
|
Packit |
2ba279 |
/* coverity[dead_error_condition] */
|
|
Packit |
2ba279 |
if (init_fn && !init_fn()) {
|
|
Packit |
2ba279 |
dlclose(handle);
|
|
Packit |
2ba279 |
return NULL;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
init_fn = NULL;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_is_tech_avail) = dlsym(handle, "bd_nvdimm_is_tech_avail");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_is_tech_avail: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_get_mode_from_str) = dlsym(handle, "bd_nvdimm_namespace_get_mode_from_str");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_get_mode_from_str: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_get_mode_str) = dlsym(handle, "bd_nvdimm_namespace_get_mode_str");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_get_mode_str: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_get_devname) = dlsym(handle, "bd_nvdimm_namespace_get_devname");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_get_devname: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_enable) = dlsym(handle, "bd_nvdimm_namespace_enable");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_enable: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_disable) = dlsym(handle, "bd_nvdimm_namespace_disable");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_disable: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_info) = dlsym(handle, "bd_nvdimm_namespace_info");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_info: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_list_namespaces) = dlsym(handle, "bd_nvdimm_list_namespaces");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_list_namespaces: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namespace_reconfigure) = dlsym(handle, "bd_nvdimm_namespace_reconfigure");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namespace_reconfigure: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&_bd_nvdimm_namepace_get_supported_sector_sizes) = dlsym(handle, "bd_nvdimm_namepace_get_supported_sector_sizes");
|
|
Packit |
2ba279 |
if ((error = dlerror()) != NULL)
|
|
Packit |
2ba279 |
g_warning("failed to load bd_nvdimm_namepace_get_supported_sector_sizes: %s", error);
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
return handle;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
static gboolean unload_nvdimm (gpointer handle) {
|
|
Packit |
2ba279 |
char *error = NULL;
|
|
Packit |
2ba279 |
gboolean (*close_fn) (void) = NULL;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
_bd_nvdimm_is_tech_avail = bd_nvdimm_is_tech_avail_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_get_mode_from_str = bd_nvdimm_namespace_get_mode_from_str_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_get_mode_str = bd_nvdimm_namespace_get_mode_str_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_get_devname = bd_nvdimm_namespace_get_devname_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_enable = bd_nvdimm_namespace_enable_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_disable = bd_nvdimm_namespace_disable_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_info = bd_nvdimm_namespace_info_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_list_namespaces = bd_nvdimm_list_namespaces_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namespace_reconfigure = bd_nvdimm_namespace_reconfigure_stub;
|
|
Packit |
2ba279 |
_bd_nvdimm_namepace_get_supported_sector_sizes = bd_nvdimm_namepace_get_supported_sector_sizes_stub;
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
dlerror();
|
|
Packit |
2ba279 |
* (void**) (&close_fn) = dlsym(handle, "bd_nvdimm_close");
|
|
Packit |
2ba279 |
if (((error = dlerror()) != NULL) || !close_fn)
|
|
Packit |
2ba279 |
g_debug("failed to load the close_plugin() function for nvdimm: %s", error);
|
|
Packit |
2ba279 |
/* coverity[dead_error_condition] */
|
|
Packit |
2ba279 |
if (close_fn) {
|
|
Packit |
2ba279 |
close_fn();
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|
|
Packit |
2ba279 |
return dlclose(handle) == 0;
|
|
Packit |
2ba279 |
}
|
|
Packit |
2ba279 |
|