open-iscsi: add package open-iscsi

iscsi initiator utilities

Signed-off-by: Lucian Cristian <lucian.cristian@gmail.com>
This commit is contained in:
Lucian Cristian
2020-04-12 03:06:23 +03:00
parent a4bb706918
commit a636c85eda
15 changed files with 1667 additions and 0 deletions
@@ -0,0 +1,54 @@
From 97071360caa6868c21a161047ed471790c405efb Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Tue, 13 Aug 2013 10:59:44 -0700
Subject: [PATCH] idmb_rec_write, check for tpgt first
Factor out the check for a tpgt to a single place, before going crazy on
the rec files. Makes flow of this function easier to follow, and preps
for splitting it up.
---
usr/idbm.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/usr/idbm.c b/usr/idbm.c
index be4d4e3..a7da540 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2078,6 +2078,10 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
goto free_portal;
}
+ if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
+ /* drop down to old style portal as config */
+ goto open_conf;
+
rc = stat(portal, &statb);
if (rc) {
rc = 0;
@@ -2086,22 +2090,10 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
* set the tgpt. In new versions you must pass all the info in
* from the start
*/
- if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
- /* drop down to old style portal as config */
- goto open_conf;
- else
- goto mkdir_portal;
+ goto mkdir_portal;
}
if (!S_ISDIR(statb.st_mode)) {
- /*
- * older iscsiadm versions had you create the config then set
- * set the tgpt. In new versions you must pass all the info in
- * from the start
- */
- if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
- /* drop down to old style portal as config */
- goto open_conf;
/*
* Old style portal as a file, but with tpgt. Let's update it.
*/
--
2.21.0
@@ -0,0 +1,193 @@
From 4c6e7c0fcc6da66cf81c0714bf907762194eedf2 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Tue, 13 Aug 2013 11:34:31 -0700
Subject: [PATCH] idbm_rec_write, seperate old and new style writes
Duplicates a small bit of code, but easier to understand and extened.
---
usr/idbm.c | 129 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 86 insertions(+), 43 deletions(-)
diff --git a/usr/idbm.c b/usr/idbm.c
index a7da540..2f5e309 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2030,12 +2030,7 @@ mkdir_portal:
return f;
}
-/*
- * When the disable_lock param is true, the idbm_lock/idbm_unlock needs
- * to be holt by the caller, this will avoid overwriting each other in
- * case of updating(read-modify-write) the recs in parallel.
- */
-static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
+static int idbm_rec_write_new(node_rec_t *rec)
{
struct stat statb;
FILE *f;
@@ -2048,39 +2043,8 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
return ISCSI_ERR_NOMEM;
}
- snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR);
- if (access(portal, F_OK) != 0) {
- if (mkdir(portal, 0660) != 0) {
- log_error("Could not make %s: %s", portal,
- strerror(errno));
- rc = ISCSI_ERR_IDBM;
- goto free_portal;
- }
- }
-
- snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name);
- if (access(portal, F_OK) != 0) {
- if (mkdir(portal, 0660) != 0) {
- log_error("Could not make %s: %s", portal,
- strerror(errno));
- rc = ISCSI_ERR_IDBM;
- goto free_portal;
- }
- }
-
snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
rec->name, rec->conn[0].address, rec->conn[0].port);
- log_debug(5, "Looking for config file %s", portal);
-
- if (!disable_lock) {
- rc = idbm_lock();
- if (rc)
- goto free_portal;
- }
-
- if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
- /* drop down to old style portal as config */
- goto open_conf;
rc = stat(portal, &statb);
if (rc) {
@@ -2101,11 +2065,11 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
log_error("Could not convert %s: %s", portal,
strerror(errno));
rc = ISCSI_ERR_IDBM;
- goto unlock;
+ goto free_portal;
}
} else {
rc = ISCSI_ERR_INVAL;
- goto unlock;
+ goto free_portal;
}
mkdir_portal:
@@ -2116,24 +2080,103 @@ mkdir_portal:
log_error("Could not make dir %s: %s",
portal, strerror(errno));
rc = ISCSI_ERR_IDBM;
- goto unlock;
+ goto free_portal;
}
}
snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
rec->iface.name);
-open_conf:
+
f = fopen(portal, "w");
if (!f) {
log_error("Could not open %s: %s", portal, strerror(errno));
rc = ISCSI_ERR_IDBM;
- goto unlock;
+ goto free_portal;
}
idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
fclose(f);
-unlock:
+free_portal:
+ free(portal);
+ return rc;
+}
+
+static int idbm_rec_write_old(node_rec_t *rec)
+{
+ FILE *f;
+ char *portal;
+ int rc = 0;
+
+ portal = malloc(PATH_MAX);
+ if (!portal) {
+ log_error("Could not alloc portal");
+ return ISCSI_ERR_NOMEM;
+ }
+ snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
+ rec->name, rec->conn[0].address, rec->conn[0].port);
+
+ f = fopen(portal, "w");
+ if (!f) {
+ log_error("Could not open %s: %sd", portal, strerror(errno));
+ rc = ISCSI_ERR_IDBM;
+ goto free_portal;
+ }
+ idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
+ fclose(f);
+free_portal:
+ free(portal);
+ return rc;
+}
+
+/*
+ * When the disable_lock param is true, the idbm_lock/idbm_unlock needs
+ * to be holt by the caller, this will avoid overwriting each other in
+ * case of updating(read-modify-write) the recs in parallel.
+ */
+static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
+{
+ char *portal;
+ int rc = 0;
+
+ portal = malloc(PATH_MAX);
+ if (!portal) {
+ log_error("Could not alloc portal");
+ return ISCSI_ERR_NOMEM;
+ }
+
+ snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR);
+ if (access(portal, F_OK) != 0) {
+ if (mkdir(portal, 0660) != 0) {
+ log_error("Could not make %s: %s", portal,
+ strerror(errno));
+ rc = ISCSI_ERR_IDBM;
+ goto free_portal;
+ }
+ }
+
+ snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name);
+ if (access(portal, F_OK) != 0) {
+ if (mkdir(portal, 0660) != 0) {
+ log_error("Could not make %s: %s", portal,
+ strerror(errno));
+ rc = ISCSI_ERR_IDBM;
+ goto free_portal;
+ }
+ }
+
+ if (!disable_lock) {
+ rc = idbm_lock();
+ if (rc)
+ goto free_portal;
+ }
+
+ if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
+ /* old style portal as config */
+ rc = idbm_rec_write_old(rec);
+ else
+ rc = idbm_rec_write_new(rec);
+
if (!disable_lock)
idbm_unlock();
free_portal:
--
2.21.0
@@ -0,0 +1,87 @@
From 351ee477f713730d1c53cf26b6fb87706d268a5f Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Tue, 13 Aug 2013 12:39:07 -0700
Subject: [PATCH 1/1] idbw_rec_write, pick tpgt from existing record
On a static add (-m node -o new) without a user specified tpgt, looks
for existing new style records with tpgt before creating an old style
record without. If one exists, take the tpgt from it an write an
updated new style record instead.
---
usr/idbm.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/usr/idbm.c b/usr/idbm.c
index b6193e7..2208c4a 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -28,6 +28,7 @@
#include <dirent.h>
#include <limits.h>
#include <fcntl.h>
+#include <glob.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <inttypes.h>
@@ -202,6 +203,8 @@ static struct int_list_tbl {
{ "SHA3-256", AUTH_CHAP_ALG_SHA3_256 },
};
+static int idbm_remove_disc_to_node_link(node_rec_t *rec, char *portal);
+
static void
idbm_recinfo_discovery(discovery_rec_t *r, recinfo_t *ri)
{
@@ -2206,12 +2209,49 @@ static int idbm_rec_write_old(node_rec_t *rec)
FILE *f;
char *portal;
int rc = 0;
+ glob_t globbuf;
+ size_t i;
+ int tpgt = PORTAL_GROUP_TAG_UNKNOWN;
portal = malloc(PATH_MAX);
if (!portal) {
log_error("Could not alloc portal");
return ISCSI_ERR_NOMEM;
}
+
+ /* check for newer portal dir with tpgt */
+ snprintf(portal, PATH_MAX, "%s/%s/%s,%d,*", NODE_CONFIG_DIR,
+ rec->name, rec->conn[0].address, rec->conn[0].port);
+ rc = glob(portal, GLOB_ONLYDIR, NULL, &globbuf);
+ if (!rc) {
+ if (globbuf.gl_pathc > 1)
+ log_warning("multiple tpg records for portal "
+ "%s/%s:%d found", rec->name,
+ rec->conn[0].address, rec->conn[0].port);
+ /* set pattern for sscanf matching of tpgt */
+ snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%%u", NODE_CONFIG_DIR,
+ rec->name, rec->conn[0].address, rec->conn[0].port);
+ for (i = 0; i < globbuf.gl_pathc; i++) {
+ rc = sscanf(globbuf.gl_pathv[i], portal, &tpgt);
+ if (rc == 1)
+ break;
+ }
+ if (tpgt == PORTAL_GROUP_TAG_UNKNOWN)
+ log_warning("glob match on existing records, "
+ "but no valid tpgt found");
+ }
+ globfree(&globbuf);
+ rc = 0;
+
+ /* if a tpgt was selected from an old record, write entry in new format */
+ if (tpgt != PORTAL_GROUP_TAG_UNKNOWN) {
+ log_warning("using tpgt %u from existing record", tpgt);
+ rec->tpgt = tpgt;
+ rc = idbm_remove_disc_to_node_link(rec, portal);
+ free(portal);
+ return idbm_rec_write_new(rec);
+ }
+
snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
rec->name, rec->conn[0].address, rec->conn[0].port);
--
2.21.1
@@ -0,0 +1,45 @@
From d0689253c9e2eb78fc5296adb109aba4d35a13fd Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Mon, 19 Nov 2012 17:09:24 -0800
Subject: [PATCH] remove the offload boot supported ifdef
---
usr/iface.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/usr/iface.c b/usr/iface.c
index 645b0b8..9cd07fd 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -993,6 +993,7 @@ int iface_setup_from_boot_context(struct iface_rec *iface,
{
struct iscsi_transport *t = NULL;
uint32_t hostno;
+ int rc;
if (strlen(context->initiatorname))
strlcpy(iface->iname, context->initiatorname,
@@ -1006,10 +1007,7 @@ int iface_setup_from_boot_context(struct iface_rec *iface,
return 0;
}
} else if (strlen(context->iface)) {
-/* this ifdef is only temp until distros and firmwares are updated */
-#ifdef OFFLOAD_BOOT_SUPPORTED
char transport_name[ISCSI_TRANSPORT_NAME_MAXLEN];
- int rc;
memset(transport_name, 0, ISCSI_TRANSPORT_NAME_MAXLEN);
/* make sure offload driver is loaded */
@@ -1035,9 +1033,6 @@ int iface_setup_from_boot_context(struct iface_rec *iface,
}
strlcpy(iface->netdev, context->iface, sizeof(iface->netdev));
-#else
- return 0;
-#endif
} else
return 0;
--
2.21.0
@@ -0,0 +1,114 @@
From ad8c3353b8e482575ff2208182290cf35b624dde Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Wed, 5 Jun 2019 09:08:39 -0700
Subject: [PATCH 1/1] Coverity scan fixes
---
iscsiuio/src/unix/libs/qedi.c | 2 +-
iscsiuio/src/unix/main.c | 3 +++
libopeniscsiusr/idbm.c | 11 +++++------
usr/idbm.c | 10 ++++------
usr/initiator.c | 2 +-
usr/iscsid.c | 2 +-
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/iscsiuio/src/unix/libs/qedi.c b/iscsiuio/src/unix/libs/qedi.c
index 3414cb5..a359700 100644
--- a/iscsiuio/src/unix/libs/qedi.c
+++ b/iscsiuio/src/unix/libs/qedi.c
@@ -1023,7 +1023,7 @@ static int qedi_read(nic_t *nic, packet_t *pkt)
LOG_DEBUG(PFX "%s:hw_prod %d bd_prod %d, rx_pkt_idx %d, rxlen %d",
nic->log_name, hw_prod, bd_prod, rx_bd->rx_pkt_index, len);
- LOG_DEBUG(PFX "%s: sw_con %d bd_cons %d num BD %d",
+ LOG_DEBUG(PFX "%s: sw_con %d bd_cons %d num BD %lu",
nic->log_name, sw_cons, bd_cons, QEDI_NUM_RX_BD);
if (bd_cons != bd_prod) {
diff --git a/iscsiuio/src/unix/main.c b/iscsiuio/src/unix/main.c
index 0c9ad49..f83f305 100644
--- a/iscsiuio/src/unix/main.c
+++ b/iscsiuio/src/unix/main.c
@@ -391,6 +391,9 @@ int main(int argc, char *argv[])
sigaddset(&set, SIGTERM);
sigaddset(&set, SIGUSR1);
rc = pthread_sigmask(SIG_SETMASK, &set, NULL);
+ if (rc != 0) {
+ LOG_ERR("Failed to set thread signal mask");
+ }
/* Spin off the signal handling thread */
pthread_attr_init(&attr);
diff --git a/libopeniscsiusr/idbm.c b/libopeniscsiusr/idbm.c
index 7bc2381..7d4c338 100644
--- a/libopeniscsiusr/idbm.c
+++ b/libopeniscsiusr/idbm.c
@@ -321,12 +321,11 @@ int _idbm_lock(struct iscsi_context *ctx)
return 0;
}
- if (access(LOCK_DIR, F_OK) != 0) {
- if (mkdir(LOCK_DIR, 0660) != 0) {
- _error(ctx, "Could not open %s: %d %s", LOCK_DIR, errno,
- _strerror(errno, strerr_buff));
- return LIBISCSI_ERR_IDBM;
- }
+ if (((mkdir(LOCK_DIR, 0660) != 0) && (errno != EEXIST)) ||
+ (access(LOCK_DIR, F_OK) != 0)) {
+ _error(ctx, "Could not open %s: %d %s", LOCK_DIR, errno,
+ _strerror(errno, strerr_buff));
+ return LIBISCSI_ERR_IDBM;
}
fd = open(LOCK_FILE, O_RDWR | O_CREAT, 0666);
diff --git a/usr/idbm.c b/usr/idbm.c
index d5e16cb..a210c88 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -1438,12 +1438,10 @@ int idbm_lock(void)
return 0;
}
- if (access(LOCK_DIR, F_OK) != 0) {
- if (mkdir(LOCK_DIR, 0660) != 0) {
- log_error("Could not open %s: %s", LOCK_DIR,
- strerror(errno));
- return ISCSI_ERR_IDBM;
- }
+ if (((mkdir(LOCK_DIR, 0660) != 0) && (errno != EEXIST)) ||
+ (access(LOCK_DIR, F_OK) != 0)) {
+ log_error("Could not open %s: %s", LOCK_DIR, strerror(errno));
+ return ISCSI_ERR_IDBM;
}
fd = open(LOCK_FILE, O_RDWR | O_CREAT, 0666);
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 99d27ab..dbb0900 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -490,8 +490,8 @@ int main(int argc, char *argv[])
log_close(log_pid);
exit(ISCSI_ERR);
}
+ close(fd);
}
- close(fd);
if ((control_fd = ipc->ctldev_open()) < 0) {
log_close(log_pid);
diff --git a/usr/initiator.c b/usr/initiator.c
index a07f9aa..a06760c 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -580,7 +580,7 @@ __session_conn_reopen(iscsi_conn_t *conn, queue_task_t *qtask, int do_stop,
int redirected)
{
iscsi_session_t *session = conn->session;
- uint32_t delay;
+ uint32_t delay = 0;
log_debug(1, "re-opening session %d (reopen_cnt %d)", session->id,
session->reopen_cnt);
--
2.21.1
@@ -0,0 +1,62 @@
From d4ed4972df1ffe9381e33f2800f8e574f632948c Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Mon, 2 Mar 2020 15:21:30 -0800
Subject: [PATCH 1/1] iscsi_if.h replace zero-length array with flexible-array
member
---
include/iscsi_if.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index 2d46214..e8cee0d 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -337,7 +337,7 @@ enum iscsi_param_type {
struct iscsi_param_info {
uint32_t len; /* Actual length of the param value */
uint16_t param; /* iscsi param */
- uint8_t value[0]; /* length sized value follows */
+ uint8_t value[]; /* length sized value follows */
} __attribute__((__packed__));
struct iscsi_iface_param_info {
@@ -346,7 +346,7 @@ struct iscsi_iface_param_info {
uint16_t param; /* iscsi param value */
uint8_t iface_type; /* IPv4 or IPv6 */
uint8_t param_type; /* iscsi_param_type */
- uint8_t value[0]; /* length sized value follows */
+ uint8_t value[]; /* length sized value follows */
} __attribute__((__packed__));
/*
@@ -723,7 +723,7 @@ enum iscsi_flashnode_param {
struct iscsi_flashnode_param_info {
uint32_t len; /* Actual length of the param */
uint16_t param; /* iscsi param value */
- uint8_t value[0]; /* length sized value follows */
+ uint8_t value[]; /* length sized value follows */
} __attribute__((__packed__));
enum iscsi_discovery_parent_type {
@@ -841,7 +841,7 @@ struct iscsi_stats {
* up to ISCSI_STATS_CUSTOM_MAX
*/
uint32_t custom_length;
- struct iscsi_stats_custom custom[0]
+ struct iscsi_stats_custom custom[]
__attribute__ ((aligned (sizeof(uint64_t))));
};
@@ -972,7 +972,7 @@ struct iscsi_offload_host_stats {
* up to ISCSI_HOST_STATS_CUSTOM_MAX
*/
uint32_t custom_length;
- struct iscsi_host_stats_custom custom[0]
+ struct iscsi_host_stats_custom custom[]
__attribute__ ((aligned (sizeof(uint64_t))));
};
--
2.21.1
@@ -0,0 +1,65 @@
From b32f59619c32ed6cd136194d92c649b74926c6f2 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Wed, 25 Mar 2020 18:00:50 -0700
Subject: [PATCH] Fix issue where "iscsi-iname -p" core dumps.
While I was at it, I made the usage message a function
and made it print to stderr insted of stdout.
---
utils/Makefile | 2 +-
utils/iscsi-iname.c | 17 +++++++++++++----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/utils/Makefile b/utils/Makefile
index f65f1e79..aed3bb0a 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -1,7 +1,7 @@
# This Makefile will work only with GNU make.
CFLAGS ?= -O2 -fno-inline -g
-CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wall -Wextra -Wstrict-prototypes
PROGRAMS = iscsi-iname
all: $(PROGRAMS)
diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c
index da850dca..0f587e1e 100644
--- a/utils/iscsi-iname.c
+++ b/utils/iscsi-iname.c
@@ -40,6 +40,13 @@
* a seperator and 12 characters (6 random bytes in hex representation) */
#define PREFIX_MAX_LEN 210
+static void usage(void)
+{
+ fprintf(stderr, "Usage: iscsi-iname [-h | --help | -p <prefix>]\n");
+ fprintf(stderr, "where <prefix> has max length of %d\n",
+ PREFIX_MAX_LEN);
+}
+
int
main(int argc, char *argv[])
{
@@ -68,15 +75,17 @@ main(int argc, char *argv[])
"on every invocation.\n");
exit(0);
} else if ( strcmp(prefix, "-p") == 0 ) {
+ if (argc != 3) {
+ usage();
+ exit(1);
+ }
prefix = argv[2];
if (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) {
- printf("Error: Prefix cannot exceed %d "
- "characters.\n", PREFIX_MAX_LEN);
+ usage();
exit(1);
}
} else {
- printf("\nUsage: iscsi-iname [-h | --help | "
- "-p <prefix>]\n");
+ usage();
exit(0);
}
} else {
@@ -0,0 +1,173 @@
From 6ed14d48f6e9a8dfb37cc68472b04cfb3673b7bd Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Fri, 27 Mar 2020 17:50:41 -0700
Subject: [PATCH 1/3] Change include of <sys/poll.h> to <poll.h>
The proper local is <poll.h>.
---
iscsiuio/src/unix/nic_nl.c | 2 +-
usr/discovery.c | 2 +-
usr/event_poll.c | 2 +-
usr/io.c | 2 +-
usr/netlink.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/iscsiuio/src/unix/nic_nl.c b/iscsiuio/src/unix/nic_nl.c
index f8306563..dee462e7 100644
--- a/iscsiuio/src/unix/nic_nl.c
+++ b/iscsiuio/src/unix/nic_nl.c
@@ -50,7 +50,7 @@
#include <linux/netlink.h>
#include <iscsi_if.h>
#include <sys/ioctl.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/socket.h>
diff --git a/usr/discovery.c b/usr/discovery.c
index 9ce122e1..7dec696f 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -25,7 +25,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/time.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/usr/event_poll.c b/usr/event_poll.c
index 4cf4ce2b..ffd12a37 100644
--- a/usr/event_poll.c
+++ b/usr/event_poll.c
@@ -23,7 +23,7 @@
*/
#include <stdlib.h>
#include <errno.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/signalfd.h>
diff --git a/usr/io.c b/usr/io.c
index 210a10ad..a46c9f8c 100644
--- a/usr/io.c
+++ b/usr/io.c
@@ -24,7 +24,7 @@
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/ioctl.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
diff --git a/usr/netlink.c b/usr/netlink.c
index d42ca4fb..22cad834 100644
--- a/usr/netlink.c
+++ b/usr/netlink.c
@@ -30,7 +30,7 @@
#include <asm/types.h>
#include <sys/socket.h>
#include <sys/types.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <linux/netlink.h>
#include "types.h"
From fbe6c1c766a88edccb0d7f4168d2d87a3cdb4660 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Fri, 27 Mar 2020 17:57:52 -0700
Subject: [PATCH 2/3] Fix type mismatch under musl.
It complains about rl.rlim_cur and rl.rlim_max being
long long unsigned, so cast them, since it's debug
messages anyway.
---
usr/iscsi_util.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c
index fd8fc0cf..db1dc377 100644
--- a/usr/iscsi_util.c
+++ b/usr/iscsi_util.c
@@ -152,7 +152,9 @@ int increase_max_files(void)
log_debug(1, "Could not get file limit (err %d)", errno);
return errno;
}
- log_debug(1, "Max file limits %lu %lu", rl.rlim_cur, rl.rlim_max);
+ log_debug(1, "Max file limits %lu %lu",
+ (long unsigned)rl.rlim_cur,
+ (long unsigned)rl.rlim_max);
if (rl.rlim_cur < ISCSI_MAX_FILES)
rl.rlim_cur = ISCSI_MAX_FILES;
@@ -162,7 +164,8 @@ int increase_max_files(void)
err = setrlimit(RLIMIT_NOFILE, &rl);
if (err) {
log_debug(1, "Could not set file limit to %lu/%lu (err %d)",
- rl.rlim_cur, rl.rlim_max, errno);
+ (long unsigned)rl.rlim_cur,
+ (long unsigned)rl.rlim_max, errno);
return errno;
}
From a93c2f1cf5a55887074bdda65aa6ad6c533191f0 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Sun, 29 Mar 2020 11:01:07 -0700
Subject: [PATCH 3/3] More changes for musl.
Clean up some code that musl complains about. The
changes all seem like a good idea in general, and
should not effect functionality.
---
usr/iscsistart.c | 1 -
usr/mgmt_ipc.c | 1 +
usr/statics.c | 3 +--
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/usr/iscsistart.c b/usr/iscsistart.c
index 00a9c78a..ee810f7a 100644
--- a/usr/iscsistart.c
+++ b/usr/iscsistart.c
@@ -30,7 +30,6 @@
#include <time.h>
#include <sys/mman.h>
#include <sys/utsname.h>
-#include <sys/signal.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index 51267c13..c292161f 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <pwd.h>
#include <sys/un.h>
+#include <string.h>
#include "iscsid.h"
#include "idbm.h"
diff --git a/usr/statics.c b/usr/statics.c
index 59fb044d..f59729ba 100644
--- a/usr/statics.c
+++ b/usr/statics.c
@@ -1,6 +1,6 @@
#include <unistd.h>
#include <pwd.h>
-#include <sys/errno.h>
+#include <errno.h>
#include <sys/types.h>
static struct passwd root_pw = {
@@ -17,4 +17,3 @@ getpwuid(uid_t uid)
return 0;
}
}
-
@@ -0,0 +1,25 @@
From 16d4899d52b3b88774ac6d9b3cc0f5626f4705da Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Tue, 19 Nov 2019 07:54:41 -0800
Subject: [PATCH] Ignore iface.example in iface match checks
Just a cleanup, as looking at the example file
didn't hurt anything, but did waste our time.
---
usr/iface.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/usr/iface.c b/usr/iface.c
index 323f1675..11f3d2ac 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -905,6 +905,9 @@ int iface_for_each_iface(void *data, int skip_def, int *nr_found,
!strcmp(iface_dent->d_name, ".."))
continue;
+ if (!strcmp(iface_dent->d_name, "iface.example"))
+ continue;
+
log_debug(5, "iface_for_each_iface found %s",
iface_dent->d_name);
iface = iface_alloc(iface_dent->d_name, &err);