diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | include/sysdeps.h (renamed from usr/sysdeps.h) | 0 | ||||
-rw-r--r-- | usr/Makefile | 7 | ||||
-rw-r--r-- | usr/idbm.c | 12 | ||||
-rw-r--r-- | utils/fwparam_ibft/Makefile | 3 | ||||
-rw-r--r-- | utils/fwparam_ibft/fwparam_ibft_sysfs.c | 11 | ||||
-rw-r--r-- | utils/fwparam_ibft/fwparam_ppc.c | 11 | ||||
-rw-r--r-- | utils/sysdeps/Makefile | 15 | ||||
-rw-r--r-- | utils/sysdeps/sysdeps.c (renamed from usr/sysdeps.c) | 2 |
9 files changed, 41 insertions, 22 deletions
@@ -27,6 +27,7 @@ IFACEFILES = etc/iface.example all: user kernel user: ; + $(MAKE) -C utils/sysdeps $(MAKE) -C utils/fwparam_ibft $(MAKE) -C usr $(MAKE) -C utils @@ -50,6 +51,7 @@ kernel: force force: ; clean: + $(MAKE) -C utils/sysdeps clean $(MAKE) -C utils/fwparam_ibft clean $(MAKE) -C utils clean $(MAKE) -C usr clean diff --git a/usr/sysdeps.h b/include/sysdeps.h index 2f18e3b..2f18e3b 100644 --- a/usr/sysdeps.h +++ b/include/sysdeps.h diff --git a/usr/Makefile b/usr/Makefile index 6ff7ca6..7ce0025 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -33,8 +33,10 @@ WARNFLAGS ?= -Wall -Wstrict-prototypes CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../include -I. -D$(OSNAME) $(IPC_CFLAGS) PROGRAMS = iscsid iscsiadm iscsistart +# libc compat files +SYSDEPS_SRCS = $(wildcard ../utils/sysdeps/*.o) # sources shared between iscsid, iscsiadm and iscsistart -ISCSI_LIB_SRCS = util.o io.o auth.o login.o log.o md5.o sha1.o iface.o idbm.o sysdeps.o sysfs.o session_info.o iscsi_sysfs.o +ISCSI_LIB_SRCS = util.o io.o auth.o login.o log.o md5.o sha1.o iface.o idbm.o sysfs.o session_info.o iscsi_sysfs.o $(SYSDEPS_SRCS) # sources shared between iscsid and iscsiadm COMMON_SRCS = $(ISCSI_LIB_SRCS) # core initiator files @@ -53,9 +55,8 @@ iscsiadm: $(COMMON_SRCS) $(FW_BOOT_SRCS) strings.o discovery.o iscsiadm.o iscsistart: $(IPC_OBJ) $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \ iscsistart.o statics.o $(CC) $(CFLAGS) -static $^ -o $@ - clean: - rm -f *.o $(PROGRAMS) .depend + rm -f *.o $(PROGRAMS) .depend $(LIBSYS) depend: gcc $(CFLAGS) -M `ls *.c` > .depend @@ -888,8 +888,8 @@ static FILE *idbm_open_rec_r(char *portal, char *config) } if (S_ISDIR(statb.st_mode)) { - strncat(portal, "/", PATH_MAX); - strncat(portal, config, PATH_MAX); + strlcat(portal, "/", PATH_MAX); + strlcat(portal, config, PATH_MAX); } return fopen(portal, "r"); } @@ -1458,8 +1458,8 @@ mkdir_portal: } } - strncat(portal, "/", PATH_MAX); - strncat(portal, config, PATH_MAX); + strlcat(portal, "/", PATH_MAX); + strlcat(portal, config, PATH_MAX); f = fopen(portal, "w"); if (!f) log_error("Could not open %s err %d\n", portal, errno); @@ -1978,8 +1978,8 @@ int idbm_delete_discovery(discovery_rec_t *drec) } if (S_ISDIR(statb.st_mode)) { - strncat(portal, "/", PATH_MAX); - strncat(portal, ST_CONFIG_NAME, PATH_MAX); + strlcat(portal, "/", PATH_MAX); + strlcat(portal, ST_CONFIG_NAME, PATH_MAX); } if (unlink(portal)) diff --git a/utils/fwparam_ibft/Makefile b/utils/fwparam_ibft/Makefile index 7a2f67c..c160e0b 100644 --- a/utils/fwparam_ibft/Makefile +++ b/utils/fwparam_ibft/Makefile @@ -21,7 +21,8 @@ # "Prasanna Mumbai" <mumbai.prasanna@gmail.com> # -OBJS := fw_entry.o fwparam_ibft_sysfs.o +SYSDEPS_OBJS = $(wildcard ../sysdeps/*.o) +OBJS := fw_entry.o fwparam_ibft_sysfs.o $(SYSDEPS_OBJS) OBJS += prom_lex.o prom_parse.tab.o fwparam_ppc.o CLEANFILES = $(OBJS) *.output *~ diff --git a/utils/fwparam_ibft/fwparam_ibft_sysfs.c b/utils/fwparam_ibft/fwparam_ibft_sysfs.c index 3ce1b74..dc83d6d 100644 --- a/utils/fwparam_ibft/fwparam_ibft_sysfs.c +++ b/utils/fwparam_ibft/fwparam_ibft_sysfs.c @@ -32,6 +32,7 @@ #include "sysfs.h" #include "fw_context.h" #include "fwparam.h" +#include "sysdeps.h" #define IBFT_MAX 255 #define IBFT_SYSFS_ROOT "/sys/firmware/ibft/" @@ -116,7 +117,7 @@ static int get_iface_from_device(char *id, struct boot_context *context) return rc; /* If not found try again with newer kernel networkdev sysfs layout */ - strncat(dev_dir, "/net", FILENAMESZ - strlen(dev_dir)); + strlcat(dev_dir, "/net", FILENAMESZ); if (!file_exist(dev_dir)) return rc; @@ -274,8 +275,8 @@ int fwparam_ibft_sysfs_boot_info(struct boot_context *context) int nic_idx = -1, tgt_idx = -1; memset(&initiator_dir, 0 , FILENAMESZ); - strncat(initiator_dir, IBFT_SYSFS_ROOT, FILENAMESZ); - strncat(initiator_dir, "initiator", FILENAMESZ); + strlcat(initiator_dir, IBFT_SYSFS_ROOT, FILENAMESZ); + strlcat(initiator_dir, "initiator", FILENAMESZ); if (file_exist(initiator_dir)) { /* Find the target's and the ethernet's */ @@ -308,8 +309,8 @@ int fwparam_ibft_sysfs_get_targets(struct list_head *list) char initiator_dir[FILENAMESZ]; memset(&initiator_dir, 0 , FILENAMESZ); - strncat(initiator_dir, IBFT_SYSFS_ROOT, FILENAMESZ); - strncat(initiator_dir, "initiator", FILENAMESZ); + strlcat(initiator_dir, IBFT_SYSFS_ROOT, FILENAMESZ); + strlcat(initiator_dir, "initiator", FILENAMESZ); if (!file_exist(initiator_dir)) return ENODEV; diff --git a/utils/fwparam_ibft/fwparam_ppc.c b/utils/fwparam_ibft/fwparam_ppc.c index 17b4ade..8cae710 100644 --- a/utils/fwparam_ibft/fwparam_ppc.c +++ b/utils/fwparam_ibft/fwparam_ppc.c @@ -29,6 +29,7 @@ #include "fw_context.h" #include "iscsi_obp.h" #include "prom_parse.h" +#include "sysdeps.h" void* yy_scan_string(const char *str); int yyparse(struct ofw_dev *ofwdev); @@ -428,7 +429,6 @@ int fwparam_ppc_boot_info(struct boot_context *context) { char filename[FILENAMESZ]; int error; - int fplen = 0; char *devtree; /* @@ -438,8 +438,8 @@ int fwparam_ppc_boot_info(struct boot_context *context) * systems that can support iscsi are the ones that provide * the appropriate FCODE with a load method. */ - strncat(filename, DT_TOP, FILENAMESZ); - strncat(filename + fplen, BOOTPATH, FILENAMESZ - fplen); + strlcat(filename, DT_TOP, FILENAMESZ); + strlcat(filename, BOOTPATH, FILENAMESZ); if (debug) fprintf(stderr, "%s: file:%s; debug:%d\n", __func__, filename, @@ -501,7 +501,6 @@ int fwparam_ppc_get_targets(struct list_head *list) char filename[FILENAMESZ]; struct boot_context *context; int error; - int fplen = 0; char *devtree; /* @@ -511,8 +510,8 @@ int fwparam_ppc_get_targets(struct list_head *list) * systems that can support iscsi are the ones that provide * the appropriate FCODE with a load method. */ - strncat(filename, DT_TOP, FILENAMESZ); - strncat(filename + fplen, BOOTPATH, FILENAMESZ - fplen); + strlcat(filename, DT_TOP, FILENAMESZ); + strlcat(filename, BOOTPATH, FILENAMESZ); if (debug) fprintf(stderr, "%s: file:%s; debug:%d\n", __func__, filename, diff --git a/utils/sysdeps/Makefile b/utils/sysdeps/Makefile new file mode 100644 index 0000000..53c10e5 --- /dev/null +++ b/utils/sysdeps/Makefile @@ -0,0 +1,15 @@ +# This Makefile will work only with GNU make. + +CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -O2 -fno-inline -Wall -Wstrict-prototypes -g + +SYSDEPS_OBJS=sysdeps.o + +all: $(SYSDEPS_OBJS) + +clean: + rm -f *.o .depend + +depend: + gcc $(CFLAGS) -M `ls *.c` > .depend + +-include .depend diff --git a/usr/sysdeps.c b/utils/sysdeps/sysdeps.c index f2f7657..e39730d 100644 --- a/usr/sysdeps.c +++ b/utils/sysdeps/sysdeps.c @@ -61,7 +61,7 @@ size_t strlcat(char *dst, const char *src, size_t size) while ((ch = *p++)) { if (bytes+1 < size) - *q++ = ch; + *q++ = ch; bytes++; } |