#
-# Makefile for the Linux kernel device drivers.
+# Makefile for iSCSI-SCST
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
SCST_DIR := $(shell pwd)/../scst/src
SUBDIRS := $(shell pwd)
KDIR ?= /lib/modules/$(KVER)/build
endif
-all: progs mods
+all: include/iscsi_scst_itf_ver.h progs mods
mods: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/kernel modules
progs:
$(MAKE) -C usr
-install: all kernel/iscsi-scst.ko usr/iscsi-scstd usr/iscsi-scst-adm
+include/iscsi_scst_itf_ver.h: include/iscsi_scst.h
+ echo "/* Autogenerated, don't edit */" >include/iscsi_scst_itf_ver.h
+ echo "" >>include/iscsi_scst_itf_ver.h
+ echo -n "#define ISCSI_SCST_INTERFACE_VERSION " >>include/iscsi_scst_itf_ver.h
+ echo "\"`sha1sum include/iscsi_scst.h|awk '{printf $$1}'`\"" >>include/iscsi_scst_itf_ver.h
+
+install: all
@install -vD usr/iscsi-scstd $(DISTDIR)/usr/local/sbin/iscsi-scstd
- @install -vD usr/iscsi-scst-adm $(DISTDIR)/usr/local/sbin/iscsi-scst-adm
+ -@install -vD usr/iscsi-scst-adm $(DISTDIR)/usr/local/sbin/iscsi-scst-adm
if [ -f /etc/debian_version ]; then \
install -vD -m 755 etc/initd/initd.debian $(DISTDIR)/etc/init.d/iscsi-scst; \
elif [ -f /etc/redhat-release ]; then \
$(MAKE) -C usr clean
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/kernel clean
rm -f kernel/Modules.symvers kernel/Module.symvers \
- kernel/Module.markers kernel/modules.order
+ kernel/Module.markers kernel/modules.order \
+ include/iscsi_scst_itf_ver.h
extraclean: clean
Basically as in README-IET, where file names are changed as specified
above.
+If during compilation you see message like "*** No rule to make target
+`xxx.h', needed by `yyy.o'. Stop.", then your autogenerated
+dependencies don't match your compiler configuration anymore. You should
+run "make extraclean" to remove them. On the next compilation they will
+be regenerated.
+
If you experience problems during kernel module load or running, check
your system and/or kernel logs (or run dmesg command for the few most
recent kernel messages).
* GNU General Public License for more details.
*/
-#ifndef _ISCSI_U_H
-#define _ISCSI_U_H
+#ifndef _ISCSI_SCST_U_H
+#define _ISCSI_SCST_U_H
#ifndef __KERNEL__
#include <sys/uio.h>
#endif
-#define ISCSI_VERSION_STRING "0.9.6/0.4.15r148"
+#include "iscsi_scst_ver.h"
+#include "iscsi_scst_itf_ver.h"
/* The maximum length of 223 bytes in the RFC. */
-#define ISCSI_NAME_LEN 256
+#define ISCSI_NAME_LEN 256
#define ISCSI_LISTEN_PORT 3260
-#define SCSI_ID_LEN 24
+#define SCSI_ID_LEN 24
#ifndef aligned_u64
#define aligned_u64 uint64_t __attribute__((aligned(8)))
u32 exp_cmd_sn;
};
-#define DIGEST_ALL (DIGEST_NONE | DIGEST_CRC32C)
+#define DIGEST_ALL (DIGEST_NONE | DIGEST_CRC32C)
#define DIGEST_NONE (1 << 0)
#define DIGEST_CRC32C (1 << 1)
#define NETLINK_ISCSI_SCST 25
-#define ADD_TARGET _IOW('i', 0, struct target_info)
-#define DEL_TARGET _IOW('i', 1, struct target_info)
-#define ADD_SESSION _IOW('i', 2, struct session_info)
-#define DEL_SESSION _IOW('i', 3, struct session_info)
-#define GET_SESSION_INFO _IOWR('i', 4, struct session_info)
-#define ADD_CONN _IOW('i', 5, struct conn_info)
-#define DEL_CONN _IOW('i', 6, struct conn_info)
-#define GET_CONN_INFO _IOWR('i', 7, struct conn_info)
-#define ISCSI_PARAM_SET _IOW('i', 8, struct iscsi_param_info)
-#define ISCSI_PARAM_GET _IOWR('i', 9, struct iscsi_param_info)
+#define REGISTER_USERD _IOW('s', 0, const char*)
+#define ADD_TARGET _IOW('s', 1, struct target_info)
+#define DEL_TARGET _IOW('s', 2, struct target_info)
+#define ADD_SESSION _IOW('s', 3, struct session_info)
+#define DEL_SESSION _IOW('s', 4, struct session_info)
+#define GET_SESSION_INFO _IOWR('s', 5, struct session_info)
+#define ADD_CONN _IOW('s', 6, struct conn_info)
+#define DEL_CONN _IOW('s', 7, struct conn_info)
+#define GET_CONN_INFO _IOWR('s', 8, struct conn_info)
+#define ISCSI_PARAM_SET _IOW('s', 9, struct iscsi_param_info)
+#define ISCSI_PARAM_GET _IOWR('s', 10, struct iscsi_param_info)
static inline int iscsi_is_key_declarative(int key)
{
--- /dev/null
+/*
+ * Copyright (C) 2007 Vladislav Bolkhovitin
+ * Copyright (C) 2007 CMS Distribution Limited
+ *
+ * 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.
+ */
+
+#define ISCSI_VERSION_STRING "0.9.6/0.4.15r148"
return err;
}
+static int iscsi_check_version(unsigned long arg)
+{
+ char ver[sizeof(ISCSI_SCST_INTERFACE_VERSION)+1];
+ int res;
+
+ res = copy_from_user(ver, (void*)arg, sizeof(ver));
+ if (res < 0) {
+ PRINT_ERROR("%s", "Unable to get version string");
+ goto out;
+ }
+ ver[sizeof(ver)-1] = '\0';
+
+ if (strcmp(ver, ISCSI_SCST_INTERFACE_VERSION) != 0) {
+ PRINT_ERROR("Incorrect version of user space %s (needed %s)",
+ ver, ISCSI_SCST_INTERFACE_VERSION);
+ res = -EINVAL;
+ goto out;
+ }
+
+out:
+ return res;
+}
+
static long ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct iscsi_target *target = NULL;
long err;
u32 id;
+ if (cmd == REGISTER_USERD) {
+ err = iscsi_check_version(arg);
+ goto out;
+ }
+
if ((err = get_user(id, (u32 *) arg)) != 0)
goto out;
case GET_CONN_INFO:
err = get_conn_info(target, arg);
break;
-
+
default:
PRINT_ERROR("invalid ioctl cmd %x", cmd);
err = -EINVAL;
+ break;
}
mutex_unlock(&target->target_mutex);
*/
#include <net/tcp.h>
-#include "iscsi_u.h"
+#include "iscsi_scst.h"
#include "iscsi.h"
static struct sock *nl;
#include <scst.h>
#include "iscsi_hdr.h"
-#include "iscsi_u.h"
+#include "iscsi_scst.h"
#include "iscsi_dbg.h"
char devname[256];
char buf[256];
int devn;
- int ctlfd;
+ int ctlfd = -1;
+ int err;
if (!(f = fopen("/proc/devices", "r"))) {
perror("Cannot open control path to the driver\n");
- return -1;
+ goto out;
}
devn = 0;
fclose(f);
if (!devn) {
- printf
- ("cannot find iscsictl in /proc/devices - "
+ printf("cannot find iscsictl in /proc/devices - "
"make sure the module is loaded\n");
- return -1;
+ goto out;
}
unlink(CTL_DEVICE);
if (mknod(CTL_DEVICE, (S_IFCHR | 0600), (devn << 8))) {
printf("cannot create %s %d\n", CTL_DEVICE, errno);
- return -1;
+ goto out;
}
ctlfd = open(CTL_DEVICE, O_RDWR);
if (ctlfd < 0) {
printf("cannot open %s %d\n", CTL_DEVICE, errno);
- return -1;
+ goto out;
+ }
+
+ err = ioctl(ctlfd, REGISTER_USERD, ISCSI_SCST_INTERFACE_VERSION);
+ if (err < 0) {
+ log_error("Unable to register: %s\n", strerror(errno));
+ close(ctlfd);
+ ctlfd = -1;
+ goto out;
}
+out:
return ctlfd;
}
exit(-1);
};
- if ((ctrl_fd = ki->ctldev_open()) < 0) {
- perror("ctldev fd\n");
+ if ((ctrl_fd = ki->ctldev_open()) < 0)
exit(-1);
- }
if ((ipc_fd = iscsi_adm_request_listen()) < 0) {
perror("ipc fd\n");
#include "types.h"
#include "iscsi_hdr.h"
-#include "iscsi_u.h"
+#include "iscsi_scst.h"
#include "param.h"
#include "config.h"
#include "misc.h"