I posted ver2 for patches that changed. I hope they apply cleanly now. Please review and if you need I can repost all of the patches. Attached the diff --stat -p Thanks Boaz
git diff --stat -p fcf171ebb3c04eb27ac1a8e2357abf672b0460bb 6d2feeaf4a63b21ccfd112617377ce3552a25a7b usr/Makefile | 1 - usr/bsd/os.c | 40 +++++++++++++++++++++++++++------------- usr/iscsi/iscsid.c | 3 +-- usr/linux/os.c | 35 +++++++++++++++++++++++++---------- usr/log.c | 2 +- usr/os.h | 12 ++++++++---- usr/tgtif.c | 7 +++---- 10 files changed, 73 insertions(+), 42 deletions(-) diff --git a/usr/Makefile b/usr/Makefile index f4e3819..ec77cd7 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -75,7 +75,6 @@ ifneq (FreeBSD,$(UNAME)) TGTD_OBJS += bs_sg.o TGTD_OBJS += linux/os.o else - CFLAGS += -D__MAKE_TGT_ON_BSD__ CFLAGS += -Ibsd/ TGTD_OBJS += bsd/epoll.o TGTD_OBJS += bsd/os.o diff --git a/usr/bsd/os.c b/usr/bsd/os.c index 6c98d15..d53d05f 100644 --- a/usr/bsd/os.c +++ b/usr/bsd/os.c @@ -1,14 +1,23 @@ /* -* os.c: OS dependent services implementation on BSD platform -* -* Description: -* Implements these services in os.h on the BSD platform -* -* Author: Boaz Harrosh <bharrosh@xxxxxxxxxxx>, (C) 2009 -* -* Copyright: See COPYING file that comes with this distribution -* -*/ + * OS dependent services implementation for BSD platform + * + * Copyright (C) 2009 Boaz Harrosh <bharrosh@xxxxxxxxxxx> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #include <errno.h> #include <stdio.h> @@ -16,6 +25,8 @@ #include <inttypes.h> #include <unistd.h> #include <netdb.h> +#include <sys/disk.h> +#include <sys/ioctl.h> #include <sys/socket.h> #include <sys/un.h> @@ -41,9 +52,7 @@ int os_oom_adjust(void) int os_blockdev_size(int fd, uint64_t *size) { - /* FIXME: how to get block-dev size in BSD */ - *size = ~0ULL; - return 0; + return ioctl(fd, DIOCGMEDIASIZE, &size); } int os_bind_ipc(int fd, struct sockaddr_un *addr, const char *ipc_name_space) @@ -73,3 +82,8 @@ int bsd_setsockopt(int s, int level, int optname, const void *optval, return setsockopt(s, level, optname, optval, optlen); } +int os_semtimedop (int __semid, struct sembuf *__sops, size_t __nsops, + __const struct timespec *__timeout) +{ + return -1; +} diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c index 3d0a976..53b231f 100644 --- a/usr/iscsi/iscsid.c +++ b/usr/iscsi/iscsid.c @@ -777,8 +777,7 @@ static void text_scan_text(struct iscsi_connection *conn) if (ret) { eprintf("getnameinfo Faild=>%d: %s\n", ret, gai_strerror(ret)); - /* Let failure show in target traces */ - strcpy(p, "getnameinfo_Faild"); + continue; } p = buf + strlen(buf); diff --git a/usr/linux/os.c b/usr/linux/os.c index 3392637..733f5d4 100644 --- a/usr/linux/os.c +++ b/usr/linux/os.c @@ -1,14 +1,23 @@ /* -* os.c: OS dependent services implementation on Linux platform -* -* Description: -* -* -* Author: Boaz Harrosh <bharrosh@xxxxxxxxxxx>, (C) 2009 -* -* Copyright: See COPYING file that comes with this distribution -* -*/ + * OS dependent services implementation for Linux platform + * + * Copyright (C) 2009 Boaz Harrosh <bharrosh@xxxxxxxxxxx> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #include <errno.h> #include <stdio.h> @@ -114,3 +123,9 @@ int os_getnameinfo_ss(struct sockaddr_storage *ss, char *host, size_t hostlen, return getnameinfo((struct sockaddr *)ss, sizeof(*ss), host, hostlen, serv, servlen, flags); } + +int os_semtimedop (int __semid, struct sembuf *__sops, size_t __nsops, + __const struct timespec *__timeout) +{ + return semtimedop (__semid, __sops, __nsops, __timeout); +} diff --git a/usr/log.c b/usr/log.c index 9154626..c1dfabb 100644 --- a/usr/log.c +++ b/usr/log.c @@ -261,7 +261,7 @@ static void dolog(int prio, const char *fmt, va_list ap) ops.sem_num = 0; ops.sem_flg = 0; ops.sem_op = -1; - if (semtimedop(la->semid, &ops, 1, &ts) < 0) { + if (os_semtimedop(la->semid, &ops, 1, &ts) < 0) { syslog(LOG_ERR, "semop up failed"); return; } diff --git a/usr/os.h b/usr/os.h index 77944b3..2061e30 100644 --- a/usr/os.h +++ b/usr/os.h @@ -1,6 +1,10 @@ #ifndef __TGT_OS_H__ #define __TGT_OS_H__ +#include <inttypes.h> +#include <sys/types.h> +#include <linux/fs.h> + #ifndef SYNC_FILE_RANGE_WAIT_BEFORE #define SYNC_FILE_RANGE_WAIT_BEFORE 1 #define SYNC_FILE_RANGE_WRITE 2 @@ -22,9 +26,9 @@ struct sockaddr_storage; int os_getnameinfo_ss(struct sockaddr_storage *ss, char *host, size_t hostlen, char *serv, size_t servlen, int flags); -#ifdef __MAKE_TGT_ON_BSD__ -#define semtimedop(semid, sops, nsops, timeout) \ - semop(semid, sops, nsops) -#endif +struct sembuf; +struct timespec; +int os_semtimedop (int __semid, struct sembuf *__sops, size_t __nsops, + __const struct timespec *__timeout); #endif /* ndef __TGT_OS_H__*/ diff --git a/usr/tgtif.c b/usr/tgtif.c index adf70a4..1419ad2 100644 --- a/usr/tgtif.c +++ b/usr/tgtif.c @@ -34,7 +34,7 @@ #include <sys/sysmacros.h> #include <linux/types.h> #ifndef aligned_u64 -#define aligned_u64 unsigned long long __attribute__((aligned(8))) +#define aligned_u64 uint64_t __attribute__((aligned(8))) #endif #include <scsi/scsi_tgt_if.h> @@ -246,9 +246,8 @@ static void kern_cmd_done(struct tgt_event *ev) } free(KCMD(cmd)); } else - eprintf("unknow command %d %llu %llu\n", tid, - (unsigned long long)ev->p.cmd_done.itn_id, - (unsigned long long)ev->p.cmd_done.tag); + eprintf("unknow command %d %" PRIu64 " %" PRIu64 "\n", + tid, ev->p.cmd_done.itn_id, ev->p.cmd_done.tag); } static int kspace_send_it_nexus_res(int host_no, uint64_t itn_id,