|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* Copyright (C) 2017 Red Hat, Inc.
|
|
Packit |
eace71 |
*
|
|
Packit |
eace71 |
* This program is free software: you can redistribute it and/or modify
|
|
Packit |
eace71 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
eace71 |
* the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
eace71 |
* (at your option) any later version.
|
|
Packit |
eace71 |
*
|
|
Packit |
eace71 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
eace71 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
eace71 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
eace71 |
* GNU General Public License for more details.
|
|
Packit |
eace71 |
*
|
|
Packit |
eace71 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
eace71 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
eace71 |
*
|
|
Packit |
eace71 |
* Author: Gris Ge <fge@redhat.com>
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
#ifndef __ISCSI_USR_SYSFS_H__
|
|
Packit |
eace71 |
#define __ISCSI_USR_SYSFS_H__
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
#include <stdint.h>
|
|
Packit |
eace71 |
#include <stdbool.h>
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
#include "libopeniscsiusr/libopeniscsiusr_common.h"
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
#define _ISCSI_SYS_SESSION_DIR "/sys/class/iscsi_session"
|
|
Packit |
eace71 |
#define _ISCSI_SYS_CONNECTION_DIR "/sys/class/iscsi_connection"
|
|
Packit |
eace71 |
#define _ISCSI_SYS_HOST_DIR "/sys/class/iscsi_host"
|
|
Packit |
eace71 |
#define _ISCSI_SYS_IFACE_DIR "/sys/class/iscsi_iface"
|
|
Packit |
eace71 |
#define _ISCSI_SYS_TRANSPORT_DIR "/sys/class/iscsi_transport"
|
|
Packit |
eace71 |
#define _SCSI_SYS_HOST_DIR "/sys/class/scsi_host"
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* When default_value == NULL, treat no such file as LIB_BUG.
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
__DLL_LOCAL int _sysfs_prop_get_str(struct iscsi_context *ctx,
|
|
Packit |
eace71 |
const char *dir_path, const char *prop_name,
|
|
Packit |
eace71 |
char *buff, size_t buff_size,
|
|
Packit |
eace71 |
const char *default_value);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
int _sysfs_prop_get_u8(struct iscsi_context *ctx, const char *dir_path,
|
|
Packit |
eace71 |
const char *prop_name, uint8_t *val,
|
|
Packit |
eace71 |
uint8_t default_value, bool ignore_error);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
int _sysfs_prop_get_u16(struct iscsi_context *ctx, const char *dir_path,
|
|
Packit |
eace71 |
const char *prop_name, uint16_t *val,
|
|
Packit |
eace71 |
uint16_t default_value, bool ignore_error);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* When default_value == UINT32_MAX, treat no such file as LIB_BUG.
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
__DLL_LOCAL int _sysfs_prop_get_u32(struct iscsi_context *ctx,
|
|
Packit |
eace71 |
const char *dir_path, const char *prop_name,
|
|
Packit |
eace71 |
uint32_t *val, uint32_t default_value,
|
|
Packit |
eace71 |
bool ignore_error);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* When default_value == INT32_MAX, treat no such file as LIB_BUG.
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
__DLL_LOCAL int _sysfs_prop_get_i32(struct iscsi_context *ctx,
|
|
Packit |
eace71 |
const char *dir_path, const char *prop_name,
|
|
Packit |
eace71 |
int32_t *val, int32_t default_value,
|
|
Packit |
eace71 |
bool ignore_error);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
__DLL_LOCAL int _iscsi_host_id_of_session(struct iscsi_context *ctx,
|
|
Packit |
eace71 |
uint32_t sid, uint32_t *host_id);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* iface_kern_id returns an allocated (char *)[iface_count]
|
|
Packit |
eace71 |
* that needs to be freed by the caller
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
__DLL_LOCAL int _iscsi_iface_kern_ids_of_host_id(struct iscsi_context *ctx,
|
|
Packit |
eace71 |
uint32_t host_id,
|
|
Packit |
eace71 |
char ***iface_kern_ids,
|
|
Packit |
eace71 |
uint32_t *iface_count);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* The memory of (uint32_t *sids) should be freed by free().
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
__DLL_LOCAL int _iscsi_sids_get(struct iscsi_context *ctx,
|
|
Packit |
eace71 |
uint32_t **sids, uint32_t *sid_count);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
/*
|
|
Packit |
eace71 |
* The memory of (uint32_t *hids) should be freed by free().
|
|
Packit |
eace71 |
*/
|
|
Packit |
eace71 |
__DLL_LOCAL int _iscsi_hids_get(struct iscsi_context *ctx, uint32_t **hids,
|
|
Packit |
eace71 |
uint32_t *hid_count);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
__DLL_LOCAL bool _iscsi_transport_is_loaded(const char *transport_name);
|
|
Packit |
eace71 |
|
|
Packit |
eace71 |
#endif /* End of __ISCSI_USR_SYSFS_H__ */
|