mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Initial s390-tools-2.0.0 import
This commit is based on the s390-tools-1.39.0 version. Changes on top of s390-tools-1.39.0: - Add MIT license to all source files - Add LICENSE file - Transform REAMDE to README.md (markdown) - Add AUTHORS.md file - Add CONTRIBUTING.md file - Move changelog from README to CHANGELOG.md file Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
238
zdev/include/attrib.h
Normal file
238
zdev/include/attrib.h
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ATTRIB_H
|
||||
#define ATTRIB_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
struct setting;
|
||||
|
||||
/**
|
||||
* enum val_type_t - Enumeration of acceptable value definition types
|
||||
* @VAL_NUM: A single integer number
|
||||
* @VAL_NUM_GE: Any integer number with a lower limit
|
||||
* @VAL_RANGE: A range of integer numbers
|
||||
* @VAL_STRING: A single text string
|
||||
* @VAL_FUNC: A function that checks the input
|
||||
* @VAL_NONE: Value to indicate the end of a struct value_accept list
|
||||
*/
|
||||
typedef enum {
|
||||
VAL_NONE = 0,
|
||||
VAL_NUM,
|
||||
VAL_NUM_GE,
|
||||
VAL_RANGE,
|
||||
VAL_STRING,
|
||||
VAL_FUNC,
|
||||
/* Array delimiter. */
|
||||
} val_type_t;
|
||||
|
||||
/**
|
||||
* struct notation - Define acceptable notations for a number
|
||||
* dec: Decimal numbers are acceptable
|
||||
* hex: Hexadecimal numbers are acceptable
|
||||
* oct: Octal numbers are acceptable
|
||||
*/
|
||||
struct notation {
|
||||
unsigned int dec:1;
|
||||
unsigned int hex:1;
|
||||
unsigned int oct:1;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct val_number - Define parameters for an acceptable integer
|
||||
* val: Acceptable value
|
||||
* notation: Acceptable notations in which the number can be presented
|
||||
*/
|
||||
struct val_number {
|
||||
long long val;
|
||||
struct notation notation;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct val_range - Define parameters for acceptable integers within a range
|
||||
* from: Minimum acceptable value
|
||||
* to: Maximum acceptable value
|
||||
* notation: Acceptable notations in which the number can be presented
|
||||
*/
|
||||
struct val_range {
|
||||
long long from;
|
||||
long long to;
|
||||
struct notation notation;
|
||||
};
|
||||
|
||||
struct attrib;
|
||||
|
||||
/**
|
||||
* union accept_def_content - Content of an attribute value definition
|
||||
* @number: Define an acceptable integer or lower limit (VAL_NUM+VAL_NUM_GE)
|
||||
* @range: Define a range of acceptable integers (VAL_RANGE)
|
||||
* @string: Define an acceptable string (VAL_STRING)
|
||||
* @func: Define a function that checks for acceptable values (VAL_FUNC)
|
||||
*/
|
||||
union accept_def_content {
|
||||
struct val_number number;
|
||||
struct val_range range;
|
||||
const char *string;
|
||||
int (*func)(struct attrib *, const char *);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct accept_def - Define an acceptable attribute value
|
||||
* @type: Basic value type
|
||||
*/
|
||||
struct accept_def {
|
||||
val_type_t type;
|
||||
union accept_def_content content;
|
||||
};
|
||||
|
||||
/* Helpers to more easily define acceptable attribute values. */
|
||||
|
||||
/* Accept decimal integer value equal to NUM. */
|
||||
#define ACCEPT_NUM(num) \
|
||||
{ \
|
||||
.type = VAL_NUM, \
|
||||
.content = { \
|
||||
.number = { \
|
||||
.val = (num), \
|
||||
.notation = { \
|
||||
.dec = 1 \
|
||||
}, \
|
||||
}, \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Accept decimal integer values greater than or equal to NUM. */
|
||||
#define ACCEPT_NUM_GE(num) \
|
||||
{ \
|
||||
.type = VAL_NUM_GE, \
|
||||
.content = { \
|
||||
.number = { \
|
||||
.val = (num), \
|
||||
.notation = { \
|
||||
.dec = 1 \
|
||||
}, \
|
||||
}, \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Accept decimal integer values from START to END. */
|
||||
#define ACCEPT_RANGE(start, end) \
|
||||
{ \
|
||||
.type = VAL_RANGE, \
|
||||
.content = { \
|
||||
.range = { \
|
||||
.from = (start), \
|
||||
.to = (end), \
|
||||
.notation = { \
|
||||
.dec = 1 \
|
||||
}, \
|
||||
}, \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Accept string value STR. */
|
||||
#define ACCEPT_STR(str) \
|
||||
{ \
|
||||
.type = VAL_STRING, \
|
||||
.content = { \
|
||||
.string = (str) \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Start a list of ACCEPT_* macros and terminate with VAL_NONE element. */
|
||||
#define ACCEPT_ARRAY(...) \
|
||||
((struct accept_def[]) { __VA_ARGS__, { .type = VAL_NONE } })
|
||||
|
||||
#define ATTRIB_TITLE_LEN 50
|
||||
|
||||
#define ATTRIB_ARRAY(...) \
|
||||
((struct attrib *[]) { __VA_ARGS__ NULL })
|
||||
|
||||
/**
|
||||
* struct value_map - Define a value mapping for an attribute
|
||||
* @from: Value which should be replaced when read in the active config
|
||||
* @to: Target value for mapping
|
||||
*/
|
||||
struct value_map {
|
||||
const char *from;
|
||||
const char *to;
|
||||
};
|
||||
|
||||
#define VALUE_MAP(a, b) { .from = (a), .to = (b) }
|
||||
#define VALUE_MAP_ARRAY(...) \
|
||||
((struct value_map []) { __VA_ARGS__, { .from = NULL, .to = NULL }, })
|
||||
|
||||
/**
|
||||
* struct attrib - Define an attribute
|
||||
* @name: Attribute name
|
||||
* @title: Short, one-line attribute description (max 50 characters)
|
||||
* @desc: Detailed, multi-line attribute description
|
||||
* @multi: This attribute accepts multiple values
|
||||
* @activeonly: This attribute should only be changed in the active config
|
||||
* @unstable: The value read is not the last value written
|
||||
* @writeonly: This attribute cannot be read from
|
||||
* @rewrite: Writing the same value multiple times has side-effects
|
||||
* @mandatory: This attribute cannot be removed from a configured device
|
||||
* @newline: There must be a newline when writing to this attribute
|
||||
* @activerem: This attribute can be removed in the active configuration
|
||||
* @defunset: There is no difference between not set and set to default value
|
||||
* in the persistent configuration
|
||||
* @nounload: (Device type attributes only) This attribute can be set while
|
||||
* the corresponding kernel module remains loaded.
|
||||
* @order: A number indicating the order in which to apply attribute
|
||||
* @order_cmp: A function determining if a setting for this attribute should
|
||||
* be applied before (-1) or after (1) another setting, or
|
||||
* if there are no ordering requirements (0).
|
||||
* @check: Check if settings for this attribute are compatible with
|
||||
* settings of another attribute.
|
||||
* @defval: Default attribue value (optional)
|
||||
* @accept: List of acceptable settings (optional)
|
||||
* @map: List of values read in the active config that should be replaced
|
||||
* @st_data: Subtype specific attribute data (optional)
|
||||
*/
|
||||
struct attrib {
|
||||
const char *name;
|
||||
const char title[ATTRIB_TITLE_LEN + 1];
|
||||
const char *desc;
|
||||
|
||||
/* Flags */
|
||||
unsigned int multi :1;
|
||||
unsigned int activeonly :1;
|
||||
unsigned int unstable :1;
|
||||
unsigned int writeonly :1;
|
||||
unsigned int rewrite :1;
|
||||
unsigned int mandatory :1;
|
||||
unsigned int newline :1;
|
||||
unsigned int activerem :1;
|
||||
unsigned int defunset :1;
|
||||
unsigned int nounload :1;
|
||||
|
||||
/* Optional */
|
||||
int order;
|
||||
int (*order_cmp)(struct setting *, struct setting *);
|
||||
bool (*check)(struct setting *, struct setting *, config_t);
|
||||
const char *defval;
|
||||
struct accept_def *accept;
|
||||
struct value_map *map;
|
||||
void *st_data;
|
||||
};
|
||||
|
||||
bool attrib_check_value(struct attrib *, const char *);
|
||||
void attrib_print_acceptable(struct attrib *, int);
|
||||
bool attrib_match_default(struct attrib *, const char *);
|
||||
struct attrib *attrib_find(struct attrib **, const char *);
|
||||
const char *attrib_map_value(struct attrib *, const char *);
|
||||
bool attrib_match_prefix(const char *, const char *);
|
||||
const char *attrib_rem_prefix(const char *, const char *);
|
||||
|
||||
#endif /* ATTRIB_H */
|
||||
24
zdev/include/blkinfo.h
Normal file
24
zdev/include/blkinfo.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef BLKINFO_H
|
||||
#define BLKINFO_H
|
||||
|
||||
struct util_list;
|
||||
struct devnode;
|
||||
|
||||
void blkinfo_exit(void);
|
||||
|
||||
struct util_list *blkinfo_get_ancestor_devnodes(struct devnode *);
|
||||
struct util_list *blkinfo_get_same_uuid_devnodes(struct devnode *);
|
||||
struct devnode *blkinfo_get_devnode_by_path(const char *);
|
||||
void blkinfo_add_mountpoints(struct util_list *);
|
||||
void blkinfo_add_swap_devnodes(struct util_list *);
|
||||
|
||||
#endif /* BLKINFO_H */
|
||||
123
zdev/include/ccw.h
Normal file
123
zdev/include/ccw.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef CCW_H
|
||||
#define CCW_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "lib/ccw.h"
|
||||
|
||||
#include "devtype.h"
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
#include "setting.h"
|
||||
#include "subtype.h"
|
||||
|
||||
#define CCW_BUS_NAME "ccw"
|
||||
#define CCW_CHPID_NUM 8
|
||||
#define CCW_CHPID_MASK(i) (1 << (CCW_CHPID_NUM - (i) - 1))
|
||||
#define CCW_CHPID_MAX 255
|
||||
|
||||
struct attrib;
|
||||
struct namespace;
|
||||
struct subtype;
|
||||
|
||||
/**
|
||||
* ccw_chpid - Channel-Path ID
|
||||
* @cssid: Channel Subsystem ID
|
||||
* @id: CHPID number
|
||||
*/
|
||||
struct ccw_chpid {
|
||||
uint8_t cssid;
|
||||
uint8_t id;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/**
|
||||
* ccw_devinfo - CCW device information
|
||||
* @devid: CCW device ID
|
||||
* @chpids: CHPID list
|
||||
* @pim: Path-Installed-Mask
|
||||
* @exists: Non-zero if CCW device exists
|
||||
*/
|
||||
struct ccw_devinfo {
|
||||
struct ccw_devid devid;
|
||||
struct ccw_chpid chpids[CCW_CHPID_NUM];
|
||||
unsigned int cutype:16;
|
||||
unsigned int devtype:16;
|
||||
unsigned int cumodel:8;
|
||||
unsigned int devmodel:8;
|
||||
unsigned int pim:8;
|
||||
unsigned int exists:1;
|
||||
unsigned int grouped:1;
|
||||
};
|
||||
|
||||
/**
|
||||
* ccw_subtype_data - CCW subtype specific information
|
||||
* @ccwdrv: The name of the CCW device driver for this subtype
|
||||
* @mod: The name of the main kernel module for this subtype
|
||||
*/
|
||||
struct ccw_subtype_data {
|
||||
const char *ccwdrv;
|
||||
const char *mod;
|
||||
};
|
||||
|
||||
extern struct attrib ccw_attr_online;
|
||||
extern struct attrib ccw_attr_online_force;
|
||||
extern struct attrib ccw_attr_cmb_enable;
|
||||
|
||||
/* CCW device ID namespace. */
|
||||
extern struct namespace ccw_namespace;
|
||||
|
||||
/* CCW device subtype. */
|
||||
extern struct subtype ccw_subtype;
|
||||
|
||||
/* Attribute related. */
|
||||
int ccw_online_only_order_cmp(struct setting *, struct setting *);
|
||||
bool ccw_online_only_check(struct setting *, struct setting *, config_t);
|
||||
int ccw_offline_only_order_cmp(struct setting *, struct setting *);
|
||||
bool ccw_offline_only_check(struct setting *, struct setting *, config_t);
|
||||
|
||||
/* Misc. */
|
||||
void ccw_exit(void);
|
||||
void cio_settle(int);
|
||||
bool ccw_exists(const char *, const char *, const char *);
|
||||
void ccw_get_ids(const char *, const char *, struct util_list *);
|
||||
char *ccw_get_driver(struct ccw_devid *);
|
||||
exit_code_t ccw_unbind_device(struct ccw_devid *);
|
||||
exit_code_t ccw_bind_device(struct ccw_devid *, const char *);
|
||||
|
||||
/* ID handling. */
|
||||
exit_code_t ccw_parse_devid(struct ccw_devid *, const char *, err_t);
|
||||
bool ccw_parse_devid_simple(struct ccw_devid *, const char *);
|
||||
bool ccw_is_id_similar(const char *);
|
||||
char *ccw_normalize_id(const char *);
|
||||
char *ccw_devid_to_str(struct ccw_devid *);
|
||||
int ccw_cmp_devids(struct ccw_devid *, struct ccw_devid *);
|
||||
int ccw_devid_distance(struct ccw_devid *, struct ccw_devid *);
|
||||
bool ccw_devid_in_range(struct ccw_devid *, struct ccw_devid *,
|
||||
struct ccw_devid *);
|
||||
struct ccw_devid *ccw_copy_devid(struct ccw_devid *);
|
||||
|
||||
/* Blacklist handling. */
|
||||
bool ccw_is_blacklist_active(void);
|
||||
bool ccw_is_id_blacklisted(const char *);
|
||||
bool ccw_is_id_range_blacklisted(const char *);
|
||||
void ccw_unblacklist_id(const char *);
|
||||
void ccw_unblacklist_id_range(const char *);
|
||||
exit_code_t ccw_blacklist_persist(void);
|
||||
|
||||
/* CCW device information handling. */
|
||||
void ccw_devinfo_print(struct ccw_devinfo *, int);
|
||||
struct ccw_devinfo *ccw_devinfo_get(struct ccw_devid *, int);
|
||||
int ccw_devinfo_chpids_cmp(struct ccw_devinfo *, struct ccw_devinfo *);
|
||||
int ccw_devinfo_cutype_cmp(struct ccw_devinfo *, struct ccw_devinfo *);
|
||||
int ccw_devinfo_devtype_cmp(struct ccw_devinfo *, struct ccw_devinfo *);
|
||||
|
||||
#endif /* CCW_H */
|
||||
67
zdev/include/ccwgroup.h
Normal file
67
zdev/include/ccwgroup.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef CCWGROUP_H
|
||||
#define CCWGROUP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "ccw.h"
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define CCWGROUP_BUS "ccwgroup"
|
||||
#define CCWGROUP_MAX_DEVIDS 3
|
||||
|
||||
struct ns_range_iterator;
|
||||
struct subtype;
|
||||
struct attrib;
|
||||
|
||||
struct ccwgroup_devid {
|
||||
struct ccw_devid devid[CCWGROUP_MAX_DEVIDS];
|
||||
unsigned int num;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/**
|
||||
* ccwgroup_subtype_data - CCWGROUP subtype specific information
|
||||
* @ccwgroupdrv: The name of the CCWGROUP device driver for this subtype
|
||||
* @ccwdrv: The name of the CCW device driver for this subtype
|
||||
* @rootdrv: The name used by the driver in root_device_register.
|
||||
* @mod: The name of the main kernel module for this subtype
|
||||
* @num_devs: Number of CCW devices that are combined to form one device
|
||||
*/
|
||||
struct ccwgroup_subtype_data {
|
||||
const char *ccwgroupdrv;
|
||||
const char *ccwdrv;
|
||||
const char *rootdrv;
|
||||
const char *mod;
|
||||
unsigned int num_devs;
|
||||
};
|
||||
|
||||
extern struct subtype ccwgroup_subtype;
|
||||
|
||||
extern struct attrib ccwgroup_attr_online;
|
||||
|
||||
/* ID handling. */
|
||||
exit_code_t ccwgroup_parse_devid(struct ccwgroup_devid *, const char *, err_t);
|
||||
bool ccwgroup_parse_devid_simple(struct ccwgroup_devid *, const char *);
|
||||
bool ccwgroup_is_id_similar(const char *);
|
||||
char *ccwgroup_devid_to_str(struct ccwgroup_devid *);
|
||||
int ccwgroup_cmp_ids(const char *, const char *);
|
||||
int ccwgroup_cmp_parsed_ids(const void *, const void *);
|
||||
int ccwgroup_qsort_cmp(const void *, const void *);
|
||||
struct ccwgroup_devid *ccwgroup_copy_devid(struct ccwgroup_devid *);
|
||||
char *ccwgroup_get_partial_id(const char *);
|
||||
bool ccwgroup_is_id_in_range(const char *id, const char *range);
|
||||
|
||||
/* Namespace helpers. */
|
||||
void ccwgroup_range_next(struct ns_range_iterator *);
|
||||
bool ccwgroup_compatible_namespace(struct namespace *);
|
||||
|
||||
#endif /* CCWGROUP_H */
|
||||
31
zdev/include/ctc.h
Normal file
31
zdev/include/ctc.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef CTC_H
|
||||
#define CTC_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CTC_MOD_NAME "ctcm"
|
||||
#define CTC_CCWGROUPDRV_NAME "ctcm"
|
||||
#define CTC_CCWDRV_NAME "ctcm"
|
||||
#define CTC_ROOTDRV_NAME "ctcm"
|
||||
#define CTC_NUM_DEVS 2
|
||||
|
||||
struct devtype;
|
||||
struct namespace;
|
||||
struct ccw_devid;
|
||||
|
||||
extern struct devtype ctc_devtype;
|
||||
extern struct namespace ctc_namespace;
|
||||
|
||||
void ctc_exit(void);
|
||||
bool ctc_confirm(struct ccw_devid *);
|
||||
|
||||
#endif /* CTC_H */
|
||||
25
zdev/include/ctc_auto.h
Normal file
25
zdev/include/ctc_auto.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef CTC_AUTO_H
|
||||
#define CTC_AUTO_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
struct ccwgroup_devid;
|
||||
struct ccw_devid;
|
||||
|
||||
void ctc_auto_add_ids(struct util_list *);
|
||||
exit_code_t ctc_auto_get_devid(struct ccwgroup_devid *, struct ccw_devid *,
|
||||
err_t);
|
||||
exit_code_t ctc_auto_is_possible(struct ccwgroup_devid *, err_t);
|
||||
|
||||
#endif /* CTC_AUTO_H */
|
||||
17
zdev/include/dasd.h
Normal file
17
zdev/include/dasd.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef DASD_H
|
||||
#define DASD_H
|
||||
|
||||
struct devtype;
|
||||
|
||||
extern struct devtype dasd_devtype;
|
||||
|
||||
#endif /* DASD_H */
|
||||
98
zdev/include/device.h
Normal file
98
zdev/include/device.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef DEVICE_H
|
||||
#define DEVICE_H
|
||||
|
||||
#include "lib/util_list.h"
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "hash.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct subtype;
|
||||
struct setting_list;
|
||||
|
||||
/**
|
||||
* struct device_state - Represent the state of a device in a configuration
|
||||
* @settings: List of attribute settings
|
||||
* @exists: Device exists
|
||||
* @modified: Device state has been modified
|
||||
* @deconfigured: Device has been deconfigured
|
||||
* @definable: Device can be defined
|
||||
* @blacklisted: Device is on the blacklist
|
||||
*/
|
||||
struct device_state {
|
||||
struct setting_list *settings;
|
||||
unsigned int exists:1;
|
||||
unsigned int modified:1;
|
||||
unsigned int deconfigured:1;
|
||||
unsigned int definable:1;
|
||||
unsigned int blacklisted:1;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct device - Represent a device configuration
|
||||
* @subtype: Pointer to device subtype definition
|
||||
* @id: Textual device ID
|
||||
* @devid: Parsed device ID
|
||||
* @node: Node for adding this device to a list
|
||||
* @active: Device state in the active configuration
|
||||
* @persistent: Device state in the persistent configuration
|
||||
* @errors: A strlist of error and warning messages issued for the device
|
||||
* @processed: Device has been processed
|
||||
*/
|
||||
struct device {
|
||||
/* Static data */
|
||||
struct subtype *subtype;
|
||||
char *id;
|
||||
void *devid;
|
||||
|
||||
/* Dynamic data */
|
||||
struct util_list_node node;
|
||||
|
||||
struct device_state active;
|
||||
struct device_state persistent;
|
||||
|
||||
unsigned int processed:1;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct device_list - A list of devices
|
||||
* @hash: Hash for maintaining a list of devices
|
||||
* @modified: Indication of whether this list was modified
|
||||
*/
|
||||
struct device_list {
|
||||
struct hash hash;
|
||||
unsigned int modified:1;
|
||||
};
|
||||
|
||||
struct device *device_new(struct subtype *, const char *);
|
||||
void device_free(struct device *);
|
||||
void device_reset(struct device *, config_t);
|
||||
void device_print(struct device *, int);
|
||||
|
||||
bool device_needs_writing(struct device *, config_t);
|
||||
exit_code_t device_apply_strlist(struct device *, config_t, struct util_list *);
|
||||
exit_code_t device_apply_settings(struct device *, config_t,
|
||||
struct util_list *);
|
||||
void device_add_modules(struct util_list *, struct device *);
|
||||
char *device_read_active_attrib(struct device *, const char *);
|
||||
void device_read_active_settings(struct device *, read_scope_t);
|
||||
exit_code_t device_write_active_settings(struct device *);
|
||||
exit_code_t device_check_settings(struct device *, config_t, err_t);
|
||||
|
||||
struct device_list *device_list_new(struct subtype *);
|
||||
void device_list_free(struct device_list *);
|
||||
void device_list_add(struct device_list *, struct device *);
|
||||
struct device *device_list_find(struct device_list *, const char *,
|
||||
struct device *);
|
||||
void device_list_print(struct device_list *, int);
|
||||
|
||||
#endif /* DEVICE_H */
|
||||
46
zdev/include/devnode.h
Normal file
46
zdev/include/devnode.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef DEVNODE_H
|
||||
#define DEVNODE_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
|
||||
typedef enum {
|
||||
BLOCKDEV,
|
||||
CHARDEV,
|
||||
NETDEV,
|
||||
} devnode_t;
|
||||
|
||||
struct devnode {
|
||||
devnode_t type;
|
||||
|
||||
unsigned int major;
|
||||
unsigned int minor;
|
||||
|
||||
char name[];
|
||||
};
|
||||
|
||||
struct devnode *devnode_new(devnode_t, unsigned int, unsigned int,
|
||||
const char *);
|
||||
struct devnode *devnode_copy(struct devnode *);
|
||||
void devnode_print(struct devnode *, int);
|
||||
|
||||
struct devnode *devnode_from_node(const char *, err_t);
|
||||
struct devnode *devnode_from_devfile(const char *, const char *, devnode_t);
|
||||
struct devnode *devnode_from_path(const char *path);
|
||||
|
||||
int devnode_cmp(struct devnode *, struct devnode *);
|
||||
int devnode_add_block_from_sysfs(struct util_list *, const char *);
|
||||
int devnode_add_net_from_sysfs(struct util_list *, const char *);
|
||||
char *devnode_readlink(struct devnode *);
|
||||
|
||||
#endif /* DEVNODE_H */
|
||||
110
zdev/include/devtype.h
Normal file
110
zdev/include/devtype.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef DEVTYPE_H
|
||||
#define DEVTYPE_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define DEVTYPE_TITLE_LEN 60
|
||||
|
||||
struct devtype;
|
||||
struct device;
|
||||
struct devnode;
|
||||
struct namespace;
|
||||
struct selected_dev_node;
|
||||
struct subtype;
|
||||
struct util_list;
|
||||
|
||||
/* NULL-terminated list of device types. */
|
||||
extern struct devtype *devtypes[];
|
||||
|
||||
/* Define a NULL-terminated list of struct subtypes */
|
||||
#define SUBTYPE_ARRAY(...) ((struct subtype *[]) { __VA_ARGS__ NULL })
|
||||
|
||||
/**
|
||||
* struct devtype - Definition of a device type
|
||||
* @name: Short name of this device type
|
||||
* @title: Short description of this device type (max. 60 characters).
|
||||
* devtypes with empty title will not be shown with --list-types.
|
||||
* @devname: Short name for devices of this device type
|
||||
* @modules: (Optional) Array of kernel modules required for this devtype
|
||||
* @subtypes: Array of subtypes
|
||||
* @type_attribs: Array of device type attributes (may point to empty array)
|
||||
* @unknown_type_attribs: Allow specification of unknown device type attributes
|
||||
* @processed: Set if device type has already been processed
|
||||
*
|
||||
* @active_settings: Device type settings from the active configuration
|
||||
* @persistent_settings: Device type settings from the persistent configuration
|
||||
* @active_exists: Devtype configuration exists in active configuration
|
||||
* @persistent_exists: Devtype configuration exists in persistent configuration
|
||||
*
|
||||
* @init: Initialize device type
|
||||
* @exit: Release dynamically allocated resources associated with this type
|
||||
* @read_settings: Retrieve device type settings from specified configuration
|
||||
* @write_settings: Apply device type settings to specified configuration
|
||||
*/
|
||||
struct devtype {
|
||||
/* Static data */
|
||||
const char *name;
|
||||
const char title[DEVTYPE_TITLE_LEN + 1];
|
||||
const char *devname;
|
||||
const char **modules;
|
||||
|
||||
struct subtype **subtypes;
|
||||
struct attrib **type_attribs;
|
||||
unsigned int unknown_type_attribs:1;
|
||||
|
||||
/* Dynamic data */
|
||||
struct setting_list *active_settings;
|
||||
struct setting_list *persistent_settings;
|
||||
unsigned int active_exists:1;
|
||||
unsigned int persistent_exists:1;
|
||||
unsigned int processed:1;
|
||||
|
||||
/* Methods */
|
||||
void (*init)(struct devtype *);
|
||||
void (*exit)(struct devtype *);
|
||||
|
||||
/* Devtype settings. */
|
||||
exit_code_t (*read_settings)(struct devtype *, config_t);
|
||||
exit_code_t (*write_settings)(struct devtype *, config_t);
|
||||
};
|
||||
|
||||
void devtypes_init(void);
|
||||
void devtypes_exit(void);
|
||||
|
||||
void devtype_print(struct devtype *, int);
|
||||
|
||||
struct devtype *devtype_find(const char *);
|
||||
struct attrib *devtype_find_type_attrib(struct devtype *, const char *);
|
||||
struct attrib *devtype_find_dev_attrib(struct devtype *, const char *);
|
||||
|
||||
exit_code_t devtype_apply_settings(struct devtype *, config_t,
|
||||
struct util_list *);
|
||||
exit_code_t devtype_apply_strlist(struct devtype *, config_t,
|
||||
struct util_list *);
|
||||
|
||||
bool devtype_is_id_valid(struct devtype *, const char *);
|
||||
bool devtype_is_id_range_valid(struct devtype *, const char *);
|
||||
bool devtype_needs_writing(struct devtype *, config_t);
|
||||
|
||||
void devtype_add_modules(struct util_list *, struct devtype *, int);
|
||||
bool devtype_is_module_loaded(struct devtype *);
|
||||
int devtype_count_namespaces(struct devtype *);
|
||||
int devtype_count_subtypes(struct devtype *);
|
||||
|
||||
struct namespace *devtype_most_similar_namespace(struct devtype *,
|
||||
struct subtype *,
|
||||
const char *id);
|
||||
|
||||
#endif /* DEVTYPE_H */
|
||||
62
zdev/include/exit_code.h
Normal file
62
zdev/include/exit_code.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef EXIT_CODE_H
|
||||
#define EXIT_CODE_H
|
||||
|
||||
/* Program exit codes. */
|
||||
typedef enum {
|
||||
EXIT_OK = 0, /* Program finished successfully */
|
||||
|
||||
/* Usage related */
|
||||
EXIT_USAGE_ERROR = 1, /* Usage error */
|
||||
EXIT_UNKNOWN_DEVTYPE = 2, /* Unknown device type specified */
|
||||
EXIT_DEVICE_NOT_FOUND = 3, /* Device not found */
|
||||
EXIT_ATTRIB_NOT_FOUND = 4, /* Attribute not found */
|
||||
EXIT_INVALID_DEVTYPE = 5, /* Invalid device type specified */
|
||||
EXIT_INVALID_SETTING = 6, /* Invalid attribute value specified */
|
||||
EXIT_SETTING_NOT_FOUND = 7, /* Setting not found */
|
||||
EXIT_EMPTY_SELECTION = 8, /* Empty selection */
|
||||
EXIT_INVALID_CONFIG = 9, /* Invalid configuration */
|
||||
EXIT_INVALID_ID = 10, /* Invalid device ID specified */
|
||||
EXIT_INCOMPLETE_ID = 11, /* Incomplete device ID specified */
|
||||
EXIT_NO_DATA = 12, /* Configuration data not found */
|
||||
EXIT_UNKNOWN_COLUMN = 13, /* Unknown column specified */
|
||||
EXIT_INCOMPLETE_TYPE = 14, /* None or incomplete type specified */
|
||||
|
||||
/* Run-time related */
|
||||
EXIT_RUNTIME_ERROR = 15, /* A run-time error occurred */
|
||||
EXIT_ABORTED = 16, /* Operation aborted on user request */
|
||||
EXIT_SETTING_FAILED = 17, /* Error while applying setting */
|
||||
EXIT_FORMAT_ERROR = 18, /* File format error */
|
||||
EXIT_MOD_BUSY = 19, /* Module is in use */
|
||||
EXIT_MOD_UNLOAD_FAILED = 20, /* Module could not be unloaded */
|
||||
EXIT_MOD_LOAD_FAILED = 21, /* Module could not be loaded */
|
||||
EXIT_OUT_OF_MEMORY = 22, /* Not enough available memory */
|
||||
|
||||
/* zfcp related */
|
||||
EXIT_ZFCP_FCP_NOT_FOUND = 23, /* FCP device not found */
|
||||
EXIT_ZFCP_INVALID_WWPN = 24, /* Invalid WWPN specified */
|
||||
EXIT_ZFCP_WWPN_NOT_FOUND = 25, /* WWPN not found */
|
||||
EXIT_ZFCP_INVALID_LUN = 26, /* Invalid LUN specified */
|
||||
EXIT_ZFCP_SCSI_NOT_FOUND = 27, /* SCSI device not found */
|
||||
|
||||
/* ccwgroup related */
|
||||
EXIT_GROUP_NOT_FOUND = 28, /* CCW device not found */
|
||||
EXIT_GROUP_INVALID = 29, /* CCW devices are not a valid group */
|
||||
EXIT_GROUP_ALREADY = 30, /* CCW device already grouped */
|
||||
EXIT_GROUP_FAILED = 31, /* CCW group device grouping failed */
|
||||
EXIT_UNGROUP_FAILED = 32, /* CCW group device ungrouping failed */
|
||||
|
||||
EXIT_INTERNAL_ERROR = 99, /* An internal error occurred */
|
||||
} exit_code_t;
|
||||
|
||||
const char *exit_code_to_str(exit_code_t);
|
||||
|
||||
#endif /* EXIT_CODE_H */
|
||||
38
zdev/include/export.h
Normal file
38
zdev/include/export.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef EXPORT_H
|
||||
#define EXPORT_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct device;
|
||||
struct devtype;
|
||||
|
||||
typedef enum {
|
||||
export_device,
|
||||
export_devtype,
|
||||
} export_t;
|
||||
|
||||
struct export_object {
|
||||
export_t type;
|
||||
union {
|
||||
struct devtype *dt;
|
||||
struct device *dev;
|
||||
} ptr;
|
||||
};
|
||||
|
||||
exit_code_t export_write_device(FILE *, struct device *, config_t, int *);
|
||||
exit_code_t export_write_devtype(FILE *, struct devtype *, config_t, int *);
|
||||
exit_code_t export_read(FILE *, const char *, struct util_list *);
|
||||
|
||||
#endif /* EXPORT_H */
|
||||
17
zdev/include/findmnt.h
Normal file
17
zdev/include/findmnt.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef FINDMNT_H
|
||||
#define FINDMNT_H
|
||||
|
||||
struct util_list;
|
||||
|
||||
struct util_list *findmnt_get_devnodes_by_path(const char *path);
|
||||
|
||||
#endif /* FINDMNT_H */
|
||||
17
zdev/include/generic_ccw.h
Normal file
17
zdev/include/generic_ccw.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef GENERIC_CCW_H
|
||||
#define GENERIC_CCW_H
|
||||
|
||||
struct devtype;
|
||||
|
||||
extern struct devtype generic_ccw_devtype;
|
||||
|
||||
#endif /* GENERIC_CCW_H */
|
||||
65
zdev/include/hash.h
Normal file
65
zdev/include/hash.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef HASH_H
|
||||
#define HASH_H
|
||||
|
||||
#include "lib/util_list.h"
|
||||
|
||||
/* A hash is a list of entries. Each entry provides an ID. A hashing function
|
||||
* maps the ID to an integer bucket number. When adding entries to a hash, the
|
||||
* entry is stored in a list associated with this bucket number. This approach
|
||||
* can greatly reduce the effort needed to find an entry in a hash by ID. */
|
||||
|
||||
/* Return the ID of an entry. */
|
||||
typedef const void *(*hash_id_fn_t)(void *);
|
||||
|
||||
/* Check if two IDs are identical. */
|
||||
typedef int (*hash_cmp_fn_t)(const void *, const void *);
|
||||
|
||||
/* Return the bucket number for an ID. */
|
||||
typedef int (*hash_fn_t)(const void *);
|
||||
|
||||
/**
|
||||
* hash - A hash supported list
|
||||
* @list: Sequential list of entries
|
||||
* @buckets: Number of hash buckets
|
||||
* @get_id: Return the ID of an entry
|
||||
* @cmp_id: Return 0 if two IDs are identical
|
||||
* @get_hash: Function that returns a hash index for an ID
|
||||
* @hash: Lists per hash index
|
||||
*/
|
||||
struct hash {
|
||||
struct util_list list;
|
||||
int buckets;
|
||||
hash_id_fn_t get_id;
|
||||
hash_cmp_fn_t cmp_id;
|
||||
hash_fn_t get_hash;
|
||||
struct util_list **hash;
|
||||
};
|
||||
|
||||
#define hash_init(hash, buckets, get_id, cmp_id, get_hash, type, member) \
|
||||
_hash_init((hash), (buckets), (get_id), (cmp_id), (get_hash), \
|
||||
offsetof(type, member))
|
||||
#define hash_new(buckets, get_id, cmp_id, get_hash, type, member) \
|
||||
_hash_new((buckets), (get_id), (cmp_id), (get_hash), \
|
||||
offsetof(type, member))
|
||||
|
||||
void _hash_init(struct hash *hash, int buckets, hash_id_fn_t get_id,
|
||||
hash_cmp_fn_t cmp_id, hash_fn_t get_hash, unsigned long offset);
|
||||
struct hash *_hash_new(int buckets, hash_id_fn_t get_id, hash_cmp_fn_t cmp_id,
|
||||
hash_fn_t get_hash, unsigned long offset);
|
||||
void hash_clear(struct hash *hash, void (*free_fn)(void *));
|
||||
void hash_free(struct hash *hash, void (*free_fn)(void *));
|
||||
void hash_add(struct hash *hash, void *entry);
|
||||
void hash_remove(struct hash *hash, void *entry);
|
||||
void *hash_find_by_id(struct hash *hash, const void *id);
|
||||
void hash_print(struct hash *hash, int ind);
|
||||
|
||||
#endif /* HASH_H */
|
||||
19
zdev/include/inuse.h
Normal file
19
zdev/include/inuse.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef INUSE_H
|
||||
#define INUSE_H
|
||||
|
||||
struct util_list;
|
||||
struct device;
|
||||
|
||||
void inuse_exit(void);
|
||||
struct util_list *inuse_get_resources(struct device *dev);
|
||||
|
||||
#endif /* INUSE_H */
|
||||
17
zdev/include/iscsi.h
Normal file
17
zdev/include/iscsi.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ISCSI_H
|
||||
#define ISCSI_H
|
||||
|
||||
struct devnode;
|
||||
|
||||
struct devnode *iscsi_get_net_devnode(struct devnode *);
|
||||
|
||||
#endif /* ISCSI_H */
|
||||
25
zdev/include/lcs.h
Normal file
25
zdev/include/lcs.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef LCS_H
|
||||
#define LCS_H
|
||||
|
||||
#define LCS_MOD_NAME "lcs"
|
||||
#define LCS_CCWGROUPDRV_NAME "lcs"
|
||||
#define LCS_CCWDRV_NAME "lcs"
|
||||
#define LCS_ROOTDRV_NAME "lcs"
|
||||
#define LCS_NUM_DEVS 2
|
||||
|
||||
struct devtype;
|
||||
struct namespace;
|
||||
|
||||
extern struct devtype lcs_devtype;
|
||||
extern struct namespace lcs_namespace;
|
||||
|
||||
#endif /* LCS_H */
|
||||
24
zdev/include/lcs_auto.h
Normal file
24
zdev/include/lcs_auto.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef LCS_AUTO_H
|
||||
#define LCS_AUTO_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
struct ccwgroup_devid;
|
||||
struct ccw_devid;
|
||||
|
||||
void lcs_auto_add_ids(struct util_list *);
|
||||
exit_code_t lcs_auto_get_devid(struct ccwgroup_devid *, struct ccw_devid *,
|
||||
err_t);
|
||||
exit_code_t lcs_auto_is_possible(struct ccwgroup_devid *, err_t);
|
||||
|
||||
#endif /* LCS_AUTO_H */
|
||||
233
zdev/include/misc.h
Normal file
233
zdev/include/misc.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lib/util_list.h"
|
||||
#include "exit_code.h"
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define SCOPE_ACTIVE(x) (((x) == config_active) || ((x) == config_all))
|
||||
#define SCOPE_PERSISTENT(x) (((x) == config_persistent) || \
|
||||
((x) == config_all))
|
||||
|
||||
#define DELAY_INDENT 4
|
||||
|
||||
#define RANGE_LIMIT 256
|
||||
|
||||
/* Define a NULL-terminated list of strings. */
|
||||
#define STRING_ARRAY(...) ((const char *[]) { __VA_ARGS__, NULL })
|
||||
|
||||
#define YESNO(x) ((x) ? "yes" : "no")
|
||||
|
||||
#define EVEN(x) (((x) & 1) == 0)
|
||||
|
||||
/* Enumeration of configuration sets. */
|
||||
typedef enum {
|
||||
config_active,
|
||||
config_persistent,
|
||||
config_all,
|
||||
} config_t;
|
||||
|
||||
typedef enum {
|
||||
err_ignore,
|
||||
err_print,
|
||||
err_delayed_print,
|
||||
err_delayed_forceable,
|
||||
} err_t;
|
||||
|
||||
/**
|
||||
* read_scope_t - Define the scope of device attributes to read
|
||||
* @scope_mandatory: Read only mandatory attribute settings.
|
||||
* @scope_known: Read settings of all known attributes.
|
||||
* @scope_all: Read settings of all attributes.
|
||||
*/
|
||||
typedef enum {
|
||||
scope_mandatory,
|
||||
scope_known,
|
||||
scope_all,
|
||||
} read_scope_t;
|
||||
|
||||
/* A string that can be added to a struct util_list. */
|
||||
struct strlist_node {
|
||||
struct util_list_node node;
|
||||
char str[];
|
||||
};
|
||||
|
||||
/* A pointer that can be added to a struct util_list. */
|
||||
struct ptrlist_node {
|
||||
struct util_list_node node;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
/* A dry-run file buffer. */
|
||||
struct dryrun_file {
|
||||
char *filename;
|
||||
FILE *file;
|
||||
char *buffer;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
extern const char *toolname;
|
||||
extern int verbose;
|
||||
extern int debug_enabled;
|
||||
extern int quiet;
|
||||
extern int force;
|
||||
extern int yes;
|
||||
extern int dryrun;
|
||||
extern int found_forceable;
|
||||
extern int stdout_data;
|
||||
extern int delayed_errors;
|
||||
extern int delayed_warnings;
|
||||
|
||||
extern unsigned long longrun_total;
|
||||
extern unsigned long longrun_current;
|
||||
|
||||
void misc_exit(void);
|
||||
void indent(unsigned int, const char *, ...);
|
||||
void error(const char *, ...);
|
||||
#define err_t_print(err, ...) \
|
||||
do { \
|
||||
switch (err) { \
|
||||
case err_print: \
|
||||
error(__VA_ARGS__); \
|
||||
break; \
|
||||
case err_delayed_print: \
|
||||
delayed_err(__VA_ARGS__); \
|
||||
break; \
|
||||
case err_delayed_forceable: \
|
||||
delayed_forceable(__VA_ARGS__); \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
void __attribute__((noreturn)) fatal(exit_code_t rc, const char *format, ...);
|
||||
#define internal(...) \
|
||||
fatal(EXIT_INTERNAL_ERROR, \
|
||||
"An internal error occurred in %s:%d: %s\n", __FILE__, __LINE__, \
|
||||
__VA_ARGS__)
|
||||
void forceable(const char *, ...);
|
||||
void forceable_warn(const char *, ...);
|
||||
void syntax(const char *, ...);
|
||||
void _warn(const char *, ...);
|
||||
#define warn(...) do { \
|
||||
if (debug_enabled) \
|
||||
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
|
||||
_warn(__VA_ARGS__); \
|
||||
} while (0)
|
||||
#define info(...) do { if (!quiet) fprintf(stdout_data ? stderr : stdout, \
|
||||
__VA_ARGS__); } while (0)
|
||||
#define verb(...) do { if (verbose) fprintf(stdout_data ? stderr : stdout, \
|
||||
__VA_ARGS__); } while (0)
|
||||
#define debug(...) do { \
|
||||
if (debug_enabled) \
|
||||
fprintf(stderr, "DEBUG: " __VA_ARGS__); \
|
||||
if (debug_enabled > 1) \
|
||||
print_trace(); \
|
||||
} while (0)
|
||||
void oom(void);
|
||||
|
||||
void delayed_err(const char *, ...);
|
||||
void delayed_warn(const char *, ...);
|
||||
void delayed_info(const char *, ...);
|
||||
void delayed_forceable(const char *, ...);
|
||||
void delayed_forceable_warn(const char *, ...);
|
||||
void delayed_print(int);
|
||||
void delayed_clear(void);
|
||||
bool delayed_messages_available(void);
|
||||
|
||||
bool confirm(const char *format, ...);
|
||||
void set_stdout_data(void);
|
||||
char *misc_strdup(const char *);
|
||||
void *misc_malloc(size_t);
|
||||
char *misc_asprintf(const char *, ...);
|
||||
int misc_system(err_t, const char *, ...);
|
||||
bool misc_read_dir(const char *, struct util_list *,
|
||||
bool (*)(const char *, void *), void *);
|
||||
bool path_exists(const char *);
|
||||
bool file_exists(const char *);
|
||||
bool file_writable(const char *);
|
||||
bool dir_exists(const char *);
|
||||
bool file_is_devnode(const char *);
|
||||
exit_code_t remove_file(const char *);
|
||||
char *misc_read_text_file(const char *, int, err_t);
|
||||
char *misc_read_cmd_output(const char *, int, err_t);
|
||||
char *config_read_cmd_output(const char *, int, err_t);
|
||||
exit_code_t misc_write_text_file(const char *, const char *, err_t);
|
||||
exit_code_t misc_write_text_file_retry(const char *, const char *, err_t);
|
||||
exit_code_t misc_mktemp(char **, int *);
|
||||
char *misc_readlink(const char *path);
|
||||
config_t get_config(int, int);
|
||||
bool is_zvm(void);
|
||||
bool is_terminal(void);
|
||||
const char *config_to_str(config_t);
|
||||
bool str_to_config(const char *, config_t *);
|
||||
char *quote_str(const char *, int);
|
||||
char *unquote_str(const char *);
|
||||
char *shrink_str(const char *);
|
||||
|
||||
struct util_list *strlist_new(void);
|
||||
void strlist_free(struct util_list *);
|
||||
struct util_list *strlist_copy(struct util_list *);
|
||||
void strlist_add(struct util_list *, const char *, ...);
|
||||
bool strlist_add_unique(struct util_list *, const char *, ...);
|
||||
void strlist_add_multi(struct util_list *, const char *, const char *, int);
|
||||
struct strlist_node *strlist_find(struct util_list *, const char *);
|
||||
char *strlist_flatten(struct util_list *, const char *);
|
||||
void strlist_sort_unique(struct util_list *,
|
||||
int (*)(const void *, const void *));
|
||||
int str_cmp(const void *, const void *);
|
||||
|
||||
struct util_list *ptrlist_new(void);
|
||||
void ptrlist_free(struct util_list *, int);
|
||||
void ptrlist_add(struct util_list *, void *);
|
||||
void ptrlist_add_after(struct util_list *, struct ptrlist_node *, void *);
|
||||
void ptrlist_add_before(struct util_list *, struct ptrlist_node *, void *);
|
||||
void ptrlist_add_unique(struct util_list *, void *);
|
||||
void ptrlist_remove(struct util_list *, void *);
|
||||
void ptrlist_move(struct util_list *, struct util_list *,
|
||||
struct ptrlist_node *);
|
||||
|
||||
struct dryrun_file *dryrun_open(const char *, FILE **);
|
||||
void dryrun_close(struct dryrun_file *);
|
||||
void dryrun_active(const char *, ...);
|
||||
void dryrun_persistent(const char *, ...);
|
||||
|
||||
bool starts_with(const char *, const char *);
|
||||
bool starts_with_nocase(const char *, const char *);
|
||||
bool ends_with(const char *, const char *);
|
||||
|
||||
void line_split(const char *, int *, char ***);
|
||||
void line_free(int, char **);
|
||||
|
||||
void print_trace(void);
|
||||
|
||||
int get_columns(void);
|
||||
|
||||
FILE *misc_fopen(const char *, const char *);
|
||||
FILE *misc_popen(const char *, const char *);
|
||||
int misc_fclose(FILE *);
|
||||
int misc_pclose(FILE *);
|
||||
|
||||
void longrun_start(const char *, int);
|
||||
void longrun_stop(void);
|
||||
|
||||
char *skip_comp(char *);
|
||||
void byte_swap(uint8_t *, unsigned int *, unsigned);
|
||||
bool valid_hex(const char *);
|
||||
void debug_init(int, char **);
|
||||
|
||||
#endif /* MISC_H */
|
||||
24
zdev/include/modprobe.h
Normal file
24
zdev/include/modprobe.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef MODPROBE_H
|
||||
#define MODPROBE_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct attrib;
|
||||
struct setting_list;
|
||||
|
||||
exit_code_t modprobe_read_settings(const char *, const char *,
|
||||
struct attrib **, struct setting_list **);
|
||||
exit_code_t modprobe_write_settings(const char *, const char *,
|
||||
struct setting_list *);
|
||||
|
||||
#endif /* MODPROBE_H */
|
||||
31
zdev/include/module.h
Normal file
31
zdev/include/module.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef MODULE_H
|
||||
#define MODULE_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct setting_list;
|
||||
struct attrib;
|
||||
|
||||
void module_exit(void);
|
||||
|
||||
void module_load_suppress(int);
|
||||
|
||||
bool module_loaded(const char *);
|
||||
exit_code_t module_load(const char *, const char **, struct setting_list *,
|
||||
err_t);
|
||||
exit_code_t module_get_params(const char *, struct attrib **,
|
||||
struct setting_list **);
|
||||
bool module_set_params(const char *, struct setting_list *);
|
||||
void module_try_load_once(const char *, const char *);
|
||||
|
||||
#endif /* MODULE_H */
|
||||
129
zdev/include/namespace.h
Normal file
129
zdev/include/namespace.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef NAMESPACE_H
|
||||
#define NAMESPACE_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct ns_range_iterator {
|
||||
void *devid;
|
||||
void *devid_last;
|
||||
char *id;
|
||||
};
|
||||
|
||||
/**
|
||||
* ns_range_for_each - Loop over all valid IDs in a range
|
||||
* @ns: The namespace for the IDs
|
||||
* @range: The range in text form
|
||||
* @it: The range iterator object. This must be allocated using
|
||||
* ns_range_iterator_new(). After the loop it must be freed using
|
||||
* ns_range_iterator_free(). During the loop, the ID field of the
|
||||
* iterator object contains the current ID as a string.
|
||||
*/
|
||||
#define ns_range_for_each(ns, range, it) \
|
||||
for ((ns)->range_start((it), (range)); (it)->id; \
|
||||
(ns)->range_next((it)))
|
||||
|
||||
struct namespace;
|
||||
struct subtype;
|
||||
|
||||
/* NULL-terminated list of namespaces. */
|
||||
#define NUM_NAMESPACES 5
|
||||
extern struct namespace *namespaces[NUM_NAMESPACES + 1];
|
||||
|
||||
/* struct namespace - Definition of a device ID namespace
|
||||
* @devname: Short name for devices of this namespace
|
||||
* @is_id_valid: Check if string is a valid device ID and print corresponding
|
||||
* error messages if requested.
|
||||
* @is_id_similar: Optional: Check if an ID looks similar to a namespace ID.
|
||||
* ID doesn't have to be a valid ID.
|
||||
* @cmp_ids: Compare two device IDs (same return codes as strcmp)
|
||||
* @normalize_id: Return a newly allocated string containing a normalized ID
|
||||
* @parse_id: Return a newly allocated parsed device ID object. Display
|
||||
* warnings for invalid IDs if specified.
|
||||
* @cmp_parsed_ids: Compare two parsed device IDs (same return codes as strcmp)
|
||||
* @qsort_cmp: Compare two device IDs for strlist_sort_unique
|
||||
*
|
||||
* @hash_buckets: Optional: Number of hash buckets to use for device ID hashes
|
||||
* @hash_parsed_id: Optional: Return hash bucket for specified ID in parsed
|
||||
* format
|
||||
*
|
||||
* @is_id_range_valid: Check if string is a valid range of device IDs
|
||||
* @num_ids_in_range: Return the number of device IDs in the specified range
|
||||
* @is_id_in_range: Check if the specified ID is within the range
|
||||
* @range_start: If the specified range is a valid range in this namespace
|
||||
* allocate and return a corresponding range iterator object,
|
||||
* otherwise return NULL.
|
||||
* @range_next: Move the range iterator to the next device ID in range. If
|
||||
* there is no next device ID in range, release the range iterator
|
||||
* object and return false.
|
||||
*
|
||||
* @is_blacklist_active: Optional callback: Check if a blacklist is active.
|
||||
* @is_id_blacklisted: Optional callback: Check if specified ID is on the
|
||||
* blacklist.
|
||||
* @is_id_range_blacklisted: Optional callback: Check if at least one ID of
|
||||
* the specified ID range is on the blacklist.
|
||||
* @unblacklist_id: Optional callback: Remove specified ID from blacklist.
|
||||
* @unblacklist_id_range: Optional callback: Remove specified ID range from
|
||||
* blacklist.
|
||||
* @blacklist_persist: Optional callback: Persistently remove all configured
|
||||
* devices of this namespace from blacklist.
|
||||
*/
|
||||
struct namespace {
|
||||
const char * devname;
|
||||
|
||||
/* IDs. */
|
||||
exit_code_t (*is_id_valid)(const char *, err_t);
|
||||
bool (*is_id_similar)(const char *);
|
||||
int (*cmp_ids)(const char *, const char *);
|
||||
char * (*normalize_id)(const char *);
|
||||
void * (*parse_id)(const char *, err_t);
|
||||
int (*cmp_parsed_ids)(const void *, const void *);
|
||||
int (*qsort_cmp)(const void *, const void *);
|
||||
|
||||
/* ID Hash. */
|
||||
int hash_buckets;
|
||||
int (*hash_parsed_id)(const void *);
|
||||
|
||||
/* Ranges. */
|
||||
exit_code_t (*is_id_range_valid)(const char *, err_t);
|
||||
unsigned long (*num_ids_in_range)(const char *);
|
||||
bool (*is_id_in_range)(const char *, const char *);
|
||||
|
||||
void (*range_start)(struct ns_range_iterator *,
|
||||
const char *);
|
||||
void (*range_next)(struct ns_range_iterator *);
|
||||
|
||||
/* Blacklist. */
|
||||
bool (*is_blacklist_active)(void);
|
||||
bool (*is_id_blacklisted)(const char *);
|
||||
bool (*is_id_range_blacklisted)(const char *);
|
||||
void (*unblacklist_id)(const char *);
|
||||
void (*unblacklist_id_range)(const char *);
|
||||
exit_code_t (*blacklist_persist)(void);
|
||||
};
|
||||
|
||||
exit_code_t namespace_exit(void);
|
||||
void namespace_set_modified(struct namespace *);
|
||||
|
||||
int namespaces_index(struct namespace *);
|
||||
bool namespaces_is_id_valid(const char *);
|
||||
bool namespaces_is_id_range_valid(const char *);
|
||||
bool namespaces_device_exists(struct namespace *, const char *,
|
||||
config_t, struct subtype **);
|
||||
|
||||
struct ns_range_iterator *ns_range_iterator_new(void);
|
||||
void ns_range_iterator_free(struct ns_range_iterator *);
|
||||
|
||||
bool ns_is_id_valid(struct namespace *, const char *);
|
||||
bool ns_is_id_range_valid(struct namespace *, const char *);
|
||||
|
||||
#endif /* NAMESPACE_H */
|
||||
22
zdev/include/net.h
Normal file
22
zdev/include/net.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef NET_H
|
||||
#define NET_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct util_list;
|
||||
struct devnode;
|
||||
|
||||
bool net_add_linked_devnodes(struct util_list *, struct devnode *);
|
||||
bool net_add_vlan_base(struct util_list *, struct devnode *);
|
||||
bool net_add_bonding_base(struct util_list *, struct devnode *);
|
||||
|
||||
#endif /* NET_H */
|
||||
42
zdev/include/nic.h
Normal file
42
zdev/include/nic.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef NIC_H
|
||||
#define NIC_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
enum nic_type {
|
||||
nic_qdio,
|
||||
nic_hipers,
|
||||
nic_iedn,
|
||||
nic_inmn,
|
||||
};
|
||||
|
||||
enum nic_target {
|
||||
nic_vswitch,
|
||||
nic_lan,
|
||||
};
|
||||
|
||||
#define NIC_OWNER_LEN 9
|
||||
#define NIC_NAME_LEN 9
|
||||
|
||||
struct nic_data {
|
||||
enum nic_type type;
|
||||
enum nic_target target;
|
||||
char owner[NIC_OWNER_LEN];
|
||||
char name[NIC_NAME_LEN];
|
||||
};
|
||||
|
||||
bool nic_data_get(const char *, struct nic_data *);
|
||||
void nic_data_print(struct nic_data *, int);
|
||||
bool nic_vswitch_get_layer2(const char *, int *);
|
||||
bool nic_lan_get_layer2(const char *, const char *, int *);
|
||||
|
||||
#endif /* NIC_H */
|
||||
29
zdev/include/opts.h
Normal file
29
zdev/include/opts.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef OPTS_H
|
||||
#define OPTS_H
|
||||
|
||||
#include "exit_code.h"
|
||||
|
||||
#define OPTS_MAX 255
|
||||
#define OPTS_CONFLICT(x, ...) { .op = (x), \
|
||||
.conflicts = ((int []) { __VA_ARGS__, 0 })}
|
||||
|
||||
struct opts_conflict {
|
||||
int op;
|
||||
int *conflicts;
|
||||
};
|
||||
|
||||
struct option;
|
||||
|
||||
exit_code_t opts_check_conflict(int, int[OPTS_MAX + 1], struct opts_conflict *,
|
||||
const struct option *);
|
||||
|
||||
#endif /* OPTS_H */
|
||||
71
zdev/include/path.h
Normal file
71
zdev/include/path.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef PATH_H
|
||||
#define PATH_H PATH_H
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define MODPROBE_PREFIX "s390x"
|
||||
#define UDEV_PREFIX "41"
|
||||
#define UDEV_SUFFIX ".rules"
|
||||
|
||||
#define PATH_MODPROBE_CONF "/etc/modprobe.d"
|
||||
#define PATH_MODPROBE "/usr/sbin/modprobe"
|
||||
#define PATH_CCW_BUS "/sys/bus/ccw"
|
||||
#define PATH_CCWGROUP_BUS "/sys/bus/ccwgroup"
|
||||
#define PATH_UDEV_RULES "/etc/udev/rules.d"
|
||||
#define PATH_PROC "/proc"
|
||||
|
||||
#define PATH_UDEVADM "udevadm"
|
||||
#define PATH_VMCP "/usr/sbin/vmcp"
|
||||
#define PATH_IP "ip"
|
||||
|
||||
#define PATH_ROOT "/"
|
||||
#define PATH_ROOT_SCRIPT TOOLS_LIBDIR "/zdev-root-update"
|
||||
|
||||
struct devtype;
|
||||
struct zfcp_lun_devid;
|
||||
struct util_list;
|
||||
|
||||
void path_exit(void);
|
||||
void path_set_base(struct util_list *);
|
||||
|
||||
exit_code_t path_create(const char *);
|
||||
char *path_get(const char *, ...);
|
||||
char *path_get_modprobe_conf(struct devtype *);
|
||||
char *path_get_sys_module(const char *);
|
||||
char *path_get_sys_module_param(const char *, const char *);
|
||||
char *path_get_sys_block_dev(const char *);
|
||||
char *path_get_sys_dev_block(unsigned int, unsigned int);
|
||||
char *path_get_sys_dev_char(unsigned int, unsigned int);
|
||||
char *path_get_sys_dev_char_devices(void);
|
||||
char *path_get_sys_class(const char *, const char *);
|
||||
char *path_get_modprobe(void);
|
||||
char *path_get_ccw_device(const char *, const char *);
|
||||
char *path_get_ccw_devices(const char *);
|
||||
char *path_get_ccwgroup_device(const char *, const char *);
|
||||
char *path_get_ccwgroup_devices(const char *);
|
||||
char *path_get_udev_rule(const char *, const char *);
|
||||
char *path_get_udev_rules(void);
|
||||
char *path_get_proc(const char *);
|
||||
char *path_get_sys_bus_dev(const char *, const char *);
|
||||
char *path_get_sys_bus_drv(const char *, const char *);
|
||||
char *path_get_zfcp_lun_dev(struct zfcp_lun_devid *);
|
||||
char *path_get_zfcp_port_dev(struct zfcp_lun_devid *);
|
||||
char *path_get_scsi_hctl_dev(const char *);
|
||||
|
||||
exit_code_t path_for_each(const char *,
|
||||
exit_code_t (*callback)(const char *, const char *,
|
||||
void *), void *);
|
||||
|
||||
#endif /* PATH_H */
|
||||
25
zdev/include/qeth.h
Normal file
25
zdev/include/qeth.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef QETH_H
|
||||
#define QETH_H
|
||||
|
||||
#define QETH_MOD_NAME "qeth"
|
||||
#define QETH_CCWGROUPDRV_NAME "qeth"
|
||||
#define QETH_CCWDRV_NAME "qeth"
|
||||
#define QETH_ROOTDRV_NAME "qeth"
|
||||
#define QETH_NUM_DEVS 3
|
||||
|
||||
struct devtype;
|
||||
struct namespace;
|
||||
|
||||
extern struct devtype qeth_devtype;
|
||||
extern struct namespace qeth_namespace;
|
||||
|
||||
#endif /* QETH_H */
|
||||
24
zdev/include/qeth_auto.h
Normal file
24
zdev/include/qeth_auto.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef QETH_AUTO_H
|
||||
#define QETH_AUTO_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
struct ccwgroup_devid;
|
||||
struct ccw_devid;
|
||||
|
||||
void qeth_auto_add_ids(struct util_list *);
|
||||
exit_code_t qeth_auto_get_devid(struct ccwgroup_devid *, struct ccw_devid *,
|
||||
err_t);
|
||||
exit_code_t qeth_auto_is_possible(struct ccwgroup_devid *, err_t);
|
||||
|
||||
#endif /* QETH_AUTO_H */
|
||||
17
zdev/include/root.h
Normal file
17
zdev/include/root.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ROOT_H
|
||||
#define ROOT_H
|
||||
|
||||
#include "exit_code.h"
|
||||
|
||||
exit_code_t root_check(void);
|
||||
|
||||
#endif /* ROOT_H */
|
||||
32
zdev/include/scsi.h
Normal file
32
zdev/include/scsi.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef SCSI_H
|
||||
#define SCSI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct zfcp_lun_devid;
|
||||
struct util_list;
|
||||
|
||||
/* HCTL = Host:Channel:Target:LUN tuple for identifying a SCSI device. */
|
||||
|
||||
void scsi_exit(void);
|
||||
void scsi_reread(void);
|
||||
uint64_t scsi_lun_to_fcp_lun(uint64_t);
|
||||
uint64_t scsi_lun_from_fcp_lun(uint64_t);
|
||||
char *scsi_hctl_to_zfcp_lun_id(const char *);
|
||||
char *scsi_hctl_from_zfcp_lun_devid(struct zfcp_lun_devid *);
|
||||
char *scsi_hctl_from_zfcp_lun_id(const char *);
|
||||
bool scsi_hctl_exists(const char *);
|
||||
void scsi_hctl_add_zfcp_lun_ids(struct util_list *);
|
||||
char *scsi_hctl_from_devpath(const char *);
|
||||
|
||||
#endif /* SCSI_H */
|
||||
88
zdev/include/select.h
Normal file
88
zdev/include/select.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef SELECT_H
|
||||
#define SELECT_H
|
||||
|
||||
#include "lib/util_list.h"
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct device;
|
||||
struct devtype;
|
||||
struct subtype;
|
||||
struct devnode;
|
||||
|
||||
struct select_opts {
|
||||
struct devtype *devtype;
|
||||
struct subtype *subtype;
|
||||
unsigned int all:1;
|
||||
unsigned int configured:1;
|
||||
unsigned int existing:1;
|
||||
unsigned int online:1;
|
||||
unsigned int offline:1;
|
||||
unsigned int failed:1;
|
||||
struct util_list devids; /* List of struct strlist_node */
|
||||
struct util_list by_path; /* List of struct strlist_node */
|
||||
struct util_list by_node; /* List of struct strlist_node */
|
||||
struct util_list by_if; /* List of struct strlist_node */
|
||||
struct util_list by_attr; /* List of struct strlist_node */
|
||||
};
|
||||
|
||||
/** selected_dev_node - Represents a selected device ID
|
||||
* dt: Devtype of selected device
|
||||
* st: Subtype of selected device
|
||||
* id: ID if selected device
|
||||
* param: Command line parameter that resulted in device selection
|
||||
* rc: Per-device selection exit code (%EXIT_OK if all went well)
|
||||
*/
|
||||
struct selected_dev_node {
|
||||
struct util_list_node node;
|
||||
struct devtype *dt;
|
||||
struct subtype *st;
|
||||
char *id;
|
||||
char *param;
|
||||
exit_code_t rc;
|
||||
};
|
||||
|
||||
struct select_opts *select_opts_new(void);
|
||||
void select_opts_free(struct select_opts *);
|
||||
bool select_opts_dev_specified(struct select_opts *);
|
||||
|
||||
struct util_list *selected_dev_list_new(void);
|
||||
void selected_dev_free(struct selected_dev_node *);
|
||||
void selected_dev_list_free(struct util_list *);
|
||||
struct selected_dev_node *selected_dev_list_add(struct util_list *,
|
||||
struct devtype *,
|
||||
struct subtype *, const char *,
|
||||
const char *, exit_code_t);
|
||||
void selected_dev_print(struct selected_dev_node *, int);
|
||||
|
||||
exit_code_t select_devices(struct select_opts *, struct util_list *, int, int,
|
||||
int, config_t, read_scope_t, err_t);
|
||||
|
||||
exit_code_t select_by_devnode(struct select_opts *, struct util_list *,
|
||||
config_t, read_scope_t, struct devtype *,
|
||||
struct subtype *, struct devnode *, const char *,
|
||||
err_t);
|
||||
exit_code_t select_by_node(struct select_opts *, struct util_list *,
|
||||
config_t, read_scope_t, struct devtype *,
|
||||
struct subtype *, const char *, err_t err);
|
||||
exit_code_t select_by_path(struct select_opts *, struct util_list *, config_t,
|
||||
read_scope_t, struct devtype *, struct subtype *,
|
||||
const char *, err_t);
|
||||
exit_code_t select_by_interface(struct select_opts *, struct util_list *,
|
||||
config_t, read_scope_t, struct devtype *,
|
||||
struct subtype *, const char *, err_t);
|
||||
|
||||
bool select_match_state(struct device *, struct select_opts *);
|
||||
void selected_dev_list_print(struct util_list *, int);
|
||||
|
||||
#endif /* SELECT_H */
|
||||
100
zdev/include/setting.h
Normal file
100
zdev/include/setting.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef SETTING_H
|
||||
#define SETTING_H
|
||||
|
||||
#include "lib/util_list.h"
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct attrib;
|
||||
|
||||
/**
|
||||
* struct setting - An attribute setting
|
||||
* @node: List node for adding to list
|
||||
* @attrib: Attribute definition - optional for unknown attribute settings
|
||||
* @name: Attribute name
|
||||
* @value: Attribute value
|
||||
* @values: List of values for multi-value attributes
|
||||
* @actual_value: Current attribute value
|
||||
* @actual_values: List of current values for multi-value attributes
|
||||
* @modified: Setting was modified or is new
|
||||
* @specified: User specified a value for this setting
|
||||
* @derived: The actual value was not read from the configuration
|
||||
* @removed: Setting was removed
|
||||
* @readonly: Setting cannot be written to
|
||||
*/
|
||||
struct setting {
|
||||
struct util_list_node node;
|
||||
struct attrib *attrib;
|
||||
char *name;
|
||||
char *value;
|
||||
struct util_list *values;
|
||||
char *actual_value;
|
||||
struct util_list *actual_values;
|
||||
unsigned int modified:1;
|
||||
unsigned int specified:1;
|
||||
unsigned int removed:1;
|
||||
unsigned int derived:1;
|
||||
unsigned int readonly:1;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct setting_list - A list of attribute settings
|
||||
* @list: List for maintaining settings
|
||||
* @modified: Indication of whether this list was modified
|
||||
*/
|
||||
struct setting_list {
|
||||
struct util_list list;
|
||||
unsigned int modified:1;
|
||||
};
|
||||
|
||||
struct setting *setting_new(struct attrib *, const char *, const char *);
|
||||
struct setting *setting_copy(const struct setting *);
|
||||
bool setting_is_set(struct setting *);
|
||||
exit_code_t setting_write(const char *, struct setting *s);
|
||||
void setting_print(struct setting *, int);
|
||||
|
||||
struct setting_list *setting_list_new(void);
|
||||
void setting_list_free(struct setting_list *);
|
||||
void setting_list_clear(struct setting_list *);
|
||||
void setting_list_add(struct setting_list *, struct setting *);
|
||||
struct setting *setting_list_find(struct setting_list *, const char *);
|
||||
void setting_list_get_bool_state(struct setting_list *, const char *, int *,
|
||||
int *);
|
||||
struct setting *setting_list_apply(struct setting_list *, struct attrib *,
|
||||
const char *, const char *);
|
||||
struct setting *setting_list_apply_specified(struct setting_list *,
|
||||
struct attrib *, const char *,
|
||||
const char *);
|
||||
|
||||
struct setting *setting_list_apply_actual(struct setting_list *,
|
||||
struct attrib *, const char *,
|
||||
const char *);
|
||||
|
||||
bool setting_list_modified(struct setting_list *);
|
||||
char *setting_list_flatten(struct setting_list *);
|
||||
void setting_list_print(struct setting_list *, int);
|
||||
struct util_list *setting_list_get_sorted(struct setting_list *);
|
||||
bool setting_list_check_conflict(struct setting_list *, config_t, err_t);
|
||||
|
||||
void setting_list_apply_defaults(struct setting_list *, struct attrib **, bool);
|
||||
void setting_list_merge(struct setting_list *, struct setting_list *, bool,
|
||||
bool);
|
||||
struct setting_list *setting_list_copy(struct setting_list *);
|
||||
void setting_list_map_values(struct setting_list *);
|
||||
void setting_list_mark_default_derived(struct setting_list *);
|
||||
int setting_list_count_set(struct setting_list *);
|
||||
void setting_list_remove_derived(struct setting_list *);
|
||||
char *setting_get_changes(struct setting_list *, struct setting_list *);
|
||||
bool setting_match_value(struct setting *, const char *);
|
||||
|
||||
#endif /* SETTING_H */
|
||||
297
zdev/include/subtype.h
Normal file
297
zdev/include/subtype.h
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef SUBTYPE_H
|
||||
#define SUBTYPE_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define SUBTYPE_TITLE_LEN 60
|
||||
|
||||
struct devtype;
|
||||
struct device;
|
||||
struct devnode;
|
||||
struct namespace;
|
||||
struct selected_dev_node;
|
||||
struct subtype;
|
||||
struct util_list;
|
||||
|
||||
extern struct subtype subtype_base;
|
||||
|
||||
/**
|
||||
* subtype_cb_t - Callback for subtype.for_each_id()
|
||||
* @subtype: Subtype
|
||||
* @id: Device ID
|
||||
* @config: Configuration specified to subtype.for_each_id()
|
||||
* @data: Private data pointer passed to subtype.for_each_id()
|
||||
*
|
||||
* This callback is called once for each device ID of a device that exists
|
||||
* in any of the configuration sets specified to subtype.for_each_id().
|
||||
* If the callback returns a value other than EXIT_OK, the loop is aborted
|
||||
* and the exit code is returned to the caller of subtype.for_each_id().
|
||||
*/
|
||||
typedef exit_code_t (*subtype_cb_t)(struct subtype *st, const char *id,
|
||||
config_t config, void *data);
|
||||
|
||||
/**
|
||||
* struct subtype - Definition of a sub-type
|
||||
* @super: Use methods of the super subtype if this subtype does not implement
|
||||
* a method.
|
||||
* @devtype: Pointer to device type
|
||||
* @name: Short name of this sub-type. Must be unique within this devtype.
|
||||
* May be the same as the devtype name.
|
||||
* @title: Short description of this sub-type (max. 60 characters)
|
||||
* @devname: Short name for devices of this sub-type
|
||||
* @modules: (Optional) Array of kernel modules required for this subtype
|
||||
* @namespace: Namespace for devices of this device type
|
||||
* @data: Arbitrary data used by subtype methods
|
||||
* @dev_attribs: Array of device attributes
|
||||
* @prefix: Array of device attribut prefixes that are searched for
|
||||
* attributes not listed in @dev_attribs. Trailing slashes must not be
|
||||
* included.
|
||||
* @unknown_dev_attribs: Allow specification of unknown device attributes
|
||||
* @support_definable: Allow definition of devices
|
||||
* @generic: This is a generic subtype that is intended as a fallback only
|
||||
*
|
||||
* @devices: Devices of this subtype
|
||||
*
|
||||
* @init: Initialize subtype
|
||||
* @exit: Release dynamically allocated resources associated with this type
|
||||
*
|
||||
* @exists_active: Check if device exists in active configuration
|
||||
* @exists_persistent: Check if device exists in persistent configuration
|
||||
*
|
||||
* @add_active_ids: Add IDs of all devices existing in active configuration to
|
||||
* specified strlist
|
||||
* @add_persistent_ids: Add IDs of all devices existing in persistent
|
||||
* configuration to specified strlist
|
||||
*
|
||||
* @read_active: Read device configuration from active configuration
|
||||
* @read_persistent: Read device configuration from persistent configuration
|
||||
*
|
||||
* @configure_active: Apply configuration to active configuration
|
||||
* @configure_persistent: Apply configuration to persistent configuration
|
||||
*
|
||||
* @check_pre_write: Optional: Determine if the given configuration is valid
|
||||
* for the specified device. If not, emit warning messages
|
||||
* and return an exit code other than EXIT_OK. This function
|
||||
* is called before writing the device configuration.
|
||||
* @check_post_write: Optional: Determine if the given configuration is valid
|
||||
* for the specified device. If not, emit warning messages
|
||||
* and return an exit code other than EXIT_OK. This function
|
||||
* is called after writing the device configuration.
|
||||
*
|
||||
* @online_set: Optional: Set the online state of a device
|
||||
* @online_get: Optional: Retrieve device online state (0=offline, 1=online,
|
||||
* -1=not set)
|
||||
* @online_specified: Optional: Check if online setting was specified
|
||||
*
|
||||
* @add_errors: Optional: Add textual summaries of known error conditions
|
||||
* found for the specified device to the strlist.
|
||||
*
|
||||
* @add_devnodes: Optional: Add struct devnodes to specified ptrlist for each
|
||||
* Linux device node or network interface that is provided by
|
||||
* the device with the specified ID.
|
||||
* @resolve_devnode: Optional: Attempt to find the device ID of the device
|
||||
* providing the specified devnode. The result is a newly
|
||||
* allocated device ID string or %NULL.
|
||||
* @add_prereqs: Optional: For devices that require the configuration of
|
||||
* other devices first, add corresponding selected_dev_nodes
|
||||
* to list.
|
||||
* @add_modules: Optional: Add list of kernel module names required by
|
||||
* device to strlist.
|
||||
* @remove_combined: Optional: For devices that combine multiple devices into
|
||||
* one "group" device, remove the IDs of devices that are
|
||||
* combined in the specified group device from the
|
||||
* selected_dev_nodes list.
|
||||
* @get_active_attrib_path: Optional: Return the absolute path to the specified
|
||||
* device attribute or device attribute prefix.
|
||||
* @get_active_attrib: Optional: Return the value of the specified device
|
||||
* attribute.
|
||||
*
|
||||
* @is_definable: Optional: Check if device can be defined
|
||||
* @detect_definable: Optional: Detect configuration of definable device
|
||||
* @device_define: Optional: Define a device (e.g. group CCWGROUP device)
|
||||
* @device_undefine: Optional: Undefine a device
|
||||
* @add_definable_ids: Optional: Add IDs of all devices that can be defined to
|
||||
* specified strlist
|
||||
*/
|
||||
struct subtype {
|
||||
/* Static data. */
|
||||
struct subtype *super;
|
||||
|
||||
struct devtype *devtype;
|
||||
const char *name;
|
||||
const char title[SUBTYPE_TITLE_LEN + 1];
|
||||
const char *devname;
|
||||
const char **modules;
|
||||
struct namespace *namespace;
|
||||
void *data;
|
||||
|
||||
struct attrib **dev_attribs;
|
||||
const char **prefixes;
|
||||
unsigned int unknown_dev_attribs:1;
|
||||
unsigned int support_definable:1;
|
||||
unsigned int generic:1;
|
||||
|
||||
/* Dynamic data. */
|
||||
struct device_list *devices;
|
||||
|
||||
/* Methods */
|
||||
void (*init)(struct subtype *);
|
||||
void (*exit)(struct subtype *);
|
||||
|
||||
bool (*exists_active)(struct subtype *, const char *);
|
||||
bool (*exists_persistent)(struct subtype *, const char *);
|
||||
|
||||
void (*add_active_ids)(struct subtype *, struct util_list *);
|
||||
void (*add_persistent_ids)(struct subtype *,
|
||||
struct util_list *);
|
||||
|
||||
exit_code_t (*read_active)(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
exit_code_t (*read_persistent)(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
|
||||
exit_code_t (*configure_active)(struct subtype *, struct device *);
|
||||
exit_code_t (*configure_persistent)(struct subtype *,
|
||||
struct device *);
|
||||
|
||||
exit_code_t (*deconfigure_active)(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t (*deconfigure_persistent)(struct subtype *,
|
||||
struct device *);
|
||||
|
||||
exit_code_t (*check_pre_configure)(struct subtype *,
|
||||
struct device *, int, config_t);
|
||||
exit_code_t (*check_post_configure)(struct subtype *,
|
||||
struct device *, int, config_t);
|
||||
|
||||
void (*online_set)(struct subtype *, struct device *, int,
|
||||
config_t);
|
||||
int (*online_get)(struct subtype *, struct device *,
|
||||
config_t);
|
||||
bool (*online_specified)(struct subtype *, struct device *,
|
||||
config_t);
|
||||
|
||||
void (*add_errors)(struct subtype *, const char *,
|
||||
struct util_list *);
|
||||
|
||||
void (*add_devnodes)(struct subtype *, const char *,
|
||||
struct util_list *);
|
||||
char *(*resolve_devnode)(struct subtype *, struct devnode *);
|
||||
void (*add_prereqs)(struct subtype *, const char *,
|
||||
struct util_list *);
|
||||
void (*add_modules)(struct subtype *, struct device *,
|
||||
struct util_list *);
|
||||
void (*rem_combined)(struct subtype *, struct device *,
|
||||
struct selected_dev_node *,
|
||||
struct util_list *);
|
||||
char *(*get_active_attrib_path)(struct subtype *,
|
||||
struct device *,
|
||||
const char *);
|
||||
char *(*get_active_attrib)(struct subtype *, struct device *,
|
||||
const char *);
|
||||
|
||||
/* Optional methods for definable devices. */
|
||||
exit_code_t (*is_definable)(struct subtype *, const char *, err_t);
|
||||
exit_code_t (*detect_definable)(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t (*device_define)(struct subtype *, struct device *);
|
||||
exit_code_t (*device_undefine)(struct subtype *, struct device *);
|
||||
void (*add_definable_ids)(struct subtype *,
|
||||
struct util_list *);
|
||||
};
|
||||
|
||||
/* Subtype method accessor functions. */
|
||||
|
||||
void subtype_init(struct subtype *);
|
||||
void subtype_exit(struct subtype *);
|
||||
|
||||
bool subtype_device_exists_active(struct subtype *, const char *);
|
||||
bool subtype_device_exists_persistent(struct subtype *, const char *);
|
||||
|
||||
void subtype_add_active_ids(struct subtype *, struct util_list *);
|
||||
void subtype_add_persistent_ids(struct subtype *, struct util_list *);
|
||||
|
||||
exit_code_t subtype_device_read_active(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
exit_code_t subtype_device_read_persistent(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
|
||||
exit_code_t subtype_device_configure_active(struct subtype *, struct device *);
|
||||
exit_code_t subtype_device_configure_persistent(struct subtype *,
|
||||
struct device *);
|
||||
|
||||
exit_code_t subtype_device_deconfigure_active(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t subtype_device_deconfigure_persistent(struct subtype *st,
|
||||
struct device *);
|
||||
|
||||
exit_code_t subtype_check_pre_configure(struct subtype *, struct device *, int,
|
||||
config_t);
|
||||
exit_code_t subtype_check_post_configure(struct subtype *, struct device *, int,
|
||||
config_t);
|
||||
|
||||
void subtype_online_set(struct subtype *, struct device *, int, config_t);
|
||||
int subtype_online_get(struct subtype *, struct device *, config_t);
|
||||
bool subtype_online_specified(struct subtype *, struct device *, config_t);
|
||||
|
||||
void subtype_add_errors(struct subtype *, const char *, struct util_list *);
|
||||
struct util_list *subtype_get_errors(struct subtype *st, const char *);
|
||||
|
||||
void subtype_add_modules(struct subtype *, struct device *, struct util_list *);
|
||||
void subtype_add_devnodes(struct subtype *, const char *, struct util_list *);
|
||||
char *subtype_resolve_devnode(struct subtype *, struct devnode *);
|
||||
char *subtype_get_devnodes_str(struct subtype *, const char *, int, int, int,
|
||||
int);
|
||||
void subtype_add_prereqs(struct subtype *, const char *, struct util_list *);
|
||||
void subtype_rem_combined(struct subtype *, struct device *,
|
||||
struct selected_dev_node *, struct util_list *);
|
||||
char *subtype_get_active_attrib_path(struct subtype *, struct device *,
|
||||
const char *);
|
||||
char *subtype_get_active_attrib(struct subtype *, struct device *,
|
||||
const char *);
|
||||
|
||||
exit_code_t subtype_device_is_definable(struct subtype *, const char *, err_t);
|
||||
exit_code_t subtype_detect_definable(struct subtype *, struct device *);
|
||||
exit_code_t subtype_device_define(struct subtype *, struct device *);
|
||||
exit_code_t subtype_device_undefine(struct subtype *, struct device *);
|
||||
void subtype_add_definable_ids(struct subtype *, struct util_list *);
|
||||
|
||||
/* Subtype helper functions. */
|
||||
bool subtype_device_exists(struct subtype *st, const char *id,
|
||||
config_t config);
|
||||
exit_code_t subtype_for_each_id(struct subtype *st, config_t config,
|
||||
subtype_cb_t cb, void *data);
|
||||
struct util_list *subtype_get_devnodes(struct subtype *st, const char *id);
|
||||
exit_code_t subtype_read_device(struct subtype *st, const char *id,
|
||||
config_t config, read_scope_t,
|
||||
struct device **dev_ptr);
|
||||
exit_code_t subtype_reread_device(struct subtype *st, const char *id,
|
||||
config_t config, read_scope_t,
|
||||
struct device **dev_ptr);
|
||||
exit_code_t subtype_write_device(struct subtype *st, struct device *dev,
|
||||
config_t config);
|
||||
|
||||
/* Generic helper functions. */
|
||||
struct subtype *subtype_find(const char *name);
|
||||
struct attrib *subtype_find_dev_attrib(struct subtype *st, const char *str);
|
||||
exit_code_t subtype_read_all_devices(struct subtype *st, config_t config,
|
||||
read_scope_t);
|
||||
bool subtypes_find_by_devnode(struct devnode *devnode,
|
||||
struct subtype **st_ptr, char **id_ptr);
|
||||
void subtype_devices_print_all(void);
|
||||
void subtype_add_static_modules(struct util_list *, struct subtype *);
|
||||
unsigned long subtype_count_ids(struct subtype *, config_t);
|
||||
|
||||
void subtype_print(struct subtype *st, int indent);
|
||||
|
||||
#endif /* SUBTYPE_H */
|
||||
74
zdev/include/table.h
Normal file
74
zdev/include/table.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef TABLE_H
|
||||
#define TABLE_H
|
||||
|
||||
#include "exit_code.h"
|
||||
|
||||
#define COLUMN(a, b, c, d, e) \
|
||||
{ \
|
||||
.name = (a), \
|
||||
.align = (b), \
|
||||
.id = (c), \
|
||||
.def = (d), \
|
||||
.desc = (e), \
|
||||
}
|
||||
|
||||
#define COLUMN_ARRAY(...) \
|
||||
((struct column[]) { __VA_ARGS__, { .name = NULL } })
|
||||
|
||||
/* Alignment of table cell text. */
|
||||
typedef enum {
|
||||
align_right,
|
||||
align_left,
|
||||
} align_t;
|
||||
|
||||
/**
|
||||
* column - Definition of a table column
|
||||
* @name: Name of column. A name ending with ':' indicates that it can be
|
||||
* followed by arbitrary text (e.g. ATTR:online)
|
||||
* @desc: Description of column
|
||||
* @align: Alignment of column values.
|
||||
* @id: ID of column. This value is passed to get_value_cb_t
|
||||
* @def: If set, include column in default table
|
||||
*/
|
||||
struct column {
|
||||
const char *name;
|
||||
const char *desc;
|
||||
align_t align;
|
||||
int id;
|
||||
unsigned int def:1;
|
||||
};
|
||||
|
||||
struct util_list;
|
||||
|
||||
/**
|
||||
* table_value_cb_t - Retrieve table cell value
|
||||
* @item: Item for which a cell value should be retrieved
|
||||
* @id: Column ID of the column to retrieve for the item
|
||||
* @heading: The full heading of the column
|
||||
* @data: Arbitrary data pointer passed to table_print()
|
||||
*
|
||||
* This callback function should retrieve the specified table cell value
|
||||
* and return it as a newly allocated string to the caller. It may return
|
||||
* %NULL if no value of the specified type is defined for the specified item.
|
||||
*/
|
||||
typedef char *(*table_value_cb_t)(void *item, int id, const char *heading,
|
||||
void *data);
|
||||
|
||||
struct column *table_get_column(struct column *, const char *);
|
||||
exit_code_t table_print(struct column *, table_value_cb_t, void *,
|
||||
struct util_list *, struct util_list *, int, int, int,
|
||||
int);
|
||||
exit_code_t table_check_columns(struct column *, struct util_list *);
|
||||
void table_print_columns(struct column *, struct util_list *, int, int);
|
||||
void table_set_default(struct column *, int, int);
|
||||
|
||||
#endif /* TABLE_H */
|
||||
29
zdev/include/table_attribs.h
Normal file
29
zdev/include/table_attribs.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef TABLE_ATTRIBS_H
|
||||
#define TABLE_ATTRIBS_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
struct devtype;
|
||||
struct subtype;
|
||||
struct attrib;
|
||||
|
||||
struct table_attrib {
|
||||
struct subtype *st;
|
||||
struct attrib *attrib;
|
||||
};
|
||||
|
||||
struct table_attrib *table_attrib_new(struct subtype *, struct attrib *);
|
||||
void table_attribs_show(struct util_list *, int, int, struct devtype *);
|
||||
void table_attribs_show_details(struct util_list *, struct devtype *);
|
||||
|
||||
#endif /* TABLE_ATTRIBS_H */
|
||||
19
zdev/include/table_types.h
Normal file
19
zdev/include/table_types.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef TABLE_TYPES_H
|
||||
#define TABLE_TYPES_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
|
||||
exit_code_t table_types_show(struct util_list *, int, int);
|
||||
|
||||
#endif /* TABLE_TYPES_H */
|
||||
47
zdev/include/udev.h
Normal file
47
zdev/include/udev.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef UDEV_H
|
||||
#define UDEV_H
|
||||
|
||||
#include "lib/util_list.h"
|
||||
#include "exit_code.h"
|
||||
|
||||
extern int udev_need_settle;
|
||||
|
||||
/* Single key-operator-value entry in a udev rule line.*/
|
||||
struct udev_entry_node {
|
||||
struct util_list_node node;
|
||||
char *key;
|
||||
char *op;
|
||||
char *value;
|
||||
};
|
||||
|
||||
/* Single udev line in a udev rule file. */
|
||||
struct udev_line_node {
|
||||
struct util_list_node node;
|
||||
struct util_list entries;
|
||||
char *line;
|
||||
};
|
||||
|
||||
/* Udev rule file. */
|
||||
struct udev_file {
|
||||
struct util_list lines;
|
||||
};
|
||||
|
||||
exit_code_t udev_read_file(const char *, struct udev_file **);
|
||||
void udev_free_file(struct udev_file *);
|
||||
void udev_file_print(struct udev_file *);
|
||||
|
||||
void udev_get_device_ids(const char *, struct util_list *);
|
||||
exit_code_t udev_remove_rule(const char *, const char *);
|
||||
|
||||
void udev_settle(void);
|
||||
|
||||
#endif /* UDEV_H */
|
||||
23
zdev/include/udev_ccw.h
Normal file
23
zdev/include/udev_ccw.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef UDEV_CCW_H
|
||||
#define UDEV_CCW_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct device;
|
||||
|
||||
bool udev_ccw_exists(const char *, const char *);
|
||||
exit_code_t udev_ccw_read_device(struct device *);
|
||||
exit_code_t udev_ccw_write_device(struct device *);
|
||||
exit_code_t udev_ccw_write_cio_ignore(const char *);
|
||||
|
||||
#endif /* UDEV_CCW_H */
|
||||
25
zdev/include/udev_ccwgroup.h
Normal file
25
zdev/include/udev_ccwgroup.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef UDEV_CCWGROUP_H
|
||||
#define UDEV_CCWGROUP_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct device;
|
||||
struct util_list;
|
||||
|
||||
bool udev_ccwgroup_exists(const char *, const char *);
|
||||
exit_code_t udev_ccwgroup_read_device(struct device *);
|
||||
exit_code_t udev_ccwgroup_write_device(struct device *);
|
||||
void udev_ccwgroup_add_device_ids(const char *, struct util_list *);
|
||||
exit_code_t udev_ccwgroup_remove_rule(const char *, const char *);
|
||||
|
||||
#endif /* UDEV_CCWGROUP_H */
|
||||
24
zdev/include/udev_zfcp_lun.h
Normal file
24
zdev/include/udev_zfcp_lun.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef UDEV_ZFCP_LUN_H
|
||||
#define UDEV_ZFCP_LUN_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct device;
|
||||
|
||||
void udev_zfcp_lun_add_device_ids(struct util_list *);
|
||||
bool udev_zfcp_lun_exists(const char *);
|
||||
exit_code_t udev_zfcp_lun_read_device(struct device *);
|
||||
exit_code_t udev_zfcp_lun_write_device(struct device *);
|
||||
exit_code_t udev_zfcp_lun_remove_rule(const char *);
|
||||
|
||||
#endif /* UDEV_ZFCP_LUN_H */
|
||||
25
zdev/include/zfcp.h
Normal file
25
zdev/include/zfcp.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ZFCP_H
|
||||
#define ZFCP_H
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define ZFCP_MOD_NAME "zfcp"
|
||||
#define ZFCP_CCWDRV_NAME "zfcp"
|
||||
|
||||
struct devtype;
|
||||
|
||||
extern struct devtype zfcp_devtype;
|
||||
|
||||
exit_code_t zfcp_check_allow_lun_scan(int *, config_t);
|
||||
|
||||
#endif /* ZFCP_H */
|
||||
21
zdev/include/zfcp_host.h
Normal file
21
zdev/include/zfcp_host.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ZFCP_HOST_H
|
||||
#define ZFCP_HOST_H
|
||||
|
||||
#include "exit_code.h"
|
||||
|
||||
struct subtype;
|
||||
|
||||
extern struct subtype zfcp_host_subtype;
|
||||
|
||||
exit_code_t zfcp_host_check_npiv(const char *, int *);
|
||||
|
||||
#endif /* ZFCP_HOST_H */
|
||||
35
zdev/include/zfcp_lun.h
Normal file
35
zdev/include/zfcp_lun.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2016, 2017
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ZFCP_LUN_H
|
||||
#define ZFCP_LUN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ccw.h"
|
||||
|
||||
#define ZFCP_LUN_NAME "zfcp-lun"
|
||||
#define SCSI_ATTR_PREFIX "scsi_dev"
|
||||
|
||||
struct subtype;
|
||||
struct namespace;
|
||||
|
||||
extern struct subtype zfcp_lun_subtype;
|
||||
extern struct namespace zfcp_lun_namespace;
|
||||
|
||||
struct zfcp_lun_devid {
|
||||
struct ccw_devid fcp_dev;
|
||||
uint64_t wwpn;
|
||||
uint64_t lun;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
exit_code_t zfcp_lun_parse_devid(struct zfcp_lun_devid *, const char *, err_t);
|
||||
int zfcp_lun_cmp_devids(struct zfcp_lun_devid *, struct zfcp_lun_devid *);
|
||||
char *zfcp_lun_devid_to_str(struct zfcp_lun_devid *);
|
||||
|
||||
#endif /* ZFCP_LUN_H */
|
||||
Reference in New Issue
Block a user