# Support for ISCSI

## ANAS

Hello, 

I'm new to gentoo and I hope my problem is very simple to be solved.

I want to install ISCSI support, I'm following this HowTo: http://gentoo-wiki.com/HOWTO_iscsi. When I do the emerge I get the following output:

```
make: *** [kernel] Error 2

 * 

 * ERROR: sys-block/iscsitarget-0.4.15 failed.

 * Call stack:

 *   ebuild.sh, line 1654:   Called dyn_compile

 *   ebuild.sh, line 990:   Called qa_call 'src_compile'

 *   ebuild.sh, line 44:   Called src_compile

 *   iscsitarget-0.4.15.ebuild, line 36:   Called die

 * 

 * failed to build module

 * If you need support, post the topmost build error, and the call stack if relevant.

 * A complete build log is located at '/var/tmp/portage/sys-block/iscsitarget-0.4.15/temp/build.log'.

 * 

 * Messages for package sys-block/iscsitarget-0.4.15:

 * 

 * ERROR: sys-block/iscsitarget-0.4.15 failed.

 * Call stack:

 *   ebuild.sh, line 1654:   Called dyn_compile

 *   ebuild.sh, line 990:   Called qa_call 'src_compile'

 *   ebuild.sh, line 44:   Called src_compile

 *   iscsitarget-0.4.15.ebuild, line 36:   Called die

 * 

 * failed to build module

 * If you need support, post the topmost build error, and the call stack if relevant.

 * A complete build log is located at '/var/tmp/portage/sys-block/iscsitarget-0.4.15/temp/build.log'.

 * 

```

And here is the complete build log:

```
 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/2.6.22-gentoo-r8/build

 * Found sources for kernel version:

 *     2.6.22-gentoo-r8

 * Checking for suitable kernel configuration options...                  [ ok ]

>>> Unpacking source...

>>> Unpacking iscsitarget-0.4.15.tar.gz to /var/tmp/portage/sys-block/iscsitarget-0.4.15/work

 * Applying iscsitarget-0.4.13-usrbuildfix.patch ...                      [ ok ]

 * Converting iscsitarget-0.4.15/Makefile to use M= instead of SUBDIRS=   [ ok ]

>>> Source unpacked.

>>> Compiling source in /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15 ...

 * Building userspace

make -C usr

make[1]: Entering directory `/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/usr'

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o ietd.o ietd.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o iscsid.o iscsid.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o conn.o conn.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o session.o session.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o target.o target.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o message.o message.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o ctldev.o ctldev.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o log.o log.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o chap.o chap.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o event.o event.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o param.o param.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o plain.o plain.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o isns.o isns.c

cc  -O2 -march=i686 -pipe -fomit-frame-pointer -Wall -Wstrict-prototypes -I../include   -c -o ietadm.o ietadm.c

cc ietd.o iscsid.o conn.o session.o target.o message.o ctldev.o log.o chap.o event.o param.o plain.o isns.o -o ietd -lcrypto

cc ietadm.o param.o -o ietadm

make[1]: Leaving directory `/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/usr'

 * Building kernel modules

make -C /usr/src/linux M=/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel modules

make[1]: Entering directory `/usr/src/linux-2.6.22-gentoo-r8'

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/tio.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/iscsi.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/nthread.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/wthread.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/config.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/digest.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/conn.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/session.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/target.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/volume.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/iotype.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/file-io.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/null-io.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/target_disk.o

  CC [M]  /var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/event.o

/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/event.c: In function 'event_init':

/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/event.c:98: warning: passing argument 4 of 'netlink_kernel_create' from incompatible pointer type

/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/event.c:98: error: too few arguments to function 'netlink_kernel_create'

make[2]: *** [/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel/event.o] Error 1

make[2]: *** Waiting for unfinished jobs....

make[1]: *** [_module_/var/tmp/portage/sys-block/iscsitarget-0.4.15/work/iscsitarget-0.4.15/kernel] Error 2

make[1]: Leaving directory `/usr/src/linux-2.6.22-gentoo-r8'

make: *** [kernel] Error 2

 * 

 * ERROR: sys-block/iscsitarget-0.4.15 failed.

 * Call stack:

 *   ebuild.sh, line 1654:   Called dyn_compile

 *   ebuild.sh, line 990:   Called qa_call 'src_compile'

 *   ebuild.sh, line 44:   Called src_compile

 *   iscsitarget-0.4.15.ebuild, line 36:   Called die

 * 

 * failed to build module

 * If you need support, post the topmost build error, and the call stack if relevant.

 * A complete build log is located at '/var/tmp/portage/sys-block/iscsitarget-0.4.15/temp/build.log'.

 * 

```

Someone has pointed me to the following patch that should be applied to the kernel -as he said-:

https://bugs.gentoo.org/show_bug.cgi?id=191313

When I tried to patch the file as described in the guide here: http://gentoo-wiki.com/HOWTO_Install_a_Kernel_Patch

```
patch -p1 < iscsitarget-0.4.15-2.6.22.patch
```

I get: 

```
can't find file to patch at input line 3

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|--- iscsitarget-0.4.15/kernel/event.c.orig     2007-10-23 14:47:09 +0000

|+++ iscsitarget-0.4.15/kernel/event.c  2007-10-23 14:47:50 +0000

--------------------------

File to patch: iscsitarget-0.4.15-2.6.22.patch

patching file iscsitarget-0.4.15-2.6.22.patch

patch: **** malformed patch at line 11:                         return -ENOMEM;

```

Please help, is the problem with the way I patch? Or with the patch file itself? Or there is no need for that patch at all and the problem lies somewhere else?   :Rolling Eyes: 

----------

## NeddySeagoon

ANAS,

The patch failing to apply is your problem.  The patch is easy to apply by hand, as its only a one line change. The patch is

```
--- iscsitarget-0.4.15/kernel/event.c.orig   2007-10-23 14:47:09 +0000

+++ iscsitarget-0.4.15/kernel/event.c   2007-10-23 14:47:50 +0000

@@ -95,7 +95,8 @@

 

 int event_init(void)

 {

-   nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, THIS_MODULE);

+   nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, NULL,

+                              THIS_MODULE);

    if (!nl)

       return -ENOMEM;

    else    

```

proceed as follows :-

Find the  kernel/event.c file in your kernel source. Check that at line 95 you have the code 

```

 

 int event_init(void)

 {

   nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, THIS_MODULE);

    if (!nl)

       return -ENOMEM;

    else
```

Thats 7 lines, starting with an empty line. Note the @@ -95,7 in the patch.

Remove the line

```
    nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, THIS_MODULE);
```

and in its place insert

```
   nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, NULL,

                              THIS_MODULE);
```

that gets you the @@ -95,8 from the patch header.

If you use copy and paste be sure to remove the + symbols from the

```
+   nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, NULL,

+                              THIS_MODULE);
```

they are instructions to the parch program to insert lines, not part of the code.

Since you got a malformed patch error, did you copy all of the context to your patch file?

Patches have a minimum of 3 lines of unchanged code before and after each change to provide some context, to the patch can still apply ening if there have been other changes to the code. Empty lines in the context are important.

[edited several times to fix the code quotes]

----------

## happel

Hello,

I'm encountering the same problem as ANAS, so I tried to apply the patch by hand. I then discovered the file kernel/event.c doesn't exist in the kernel source. Only some event.c files in various driver folders. (kernel 2.6.22-gentoo-r5) Kernel 2.6.22-gentoo-8 again doesn't have a kernel/event.c file, so that one doesn't work either. too bad. 

I did find a kernel/event.c  including the malfunctioning code in the source of iscsitarget, I guess we should apply the patch on that one... 

Greetz

----------

## ANAS

NeddySeagoon

Thank you very much I really appreciate your help.

happel

You have to apply the patch to iscsitarget source code NOT TO KERNEL SOURCE

CODE.

Do the following:

```
cd /usr/portage/sys-block/iscsitarget/

ebuild iscsitarget-0.4.15.ebuild clean

ebuild iscsitarget-0.4.15.ebuild unpack
```

------------------ change source code from batch file:

https://bugs.gentoo.org/show_bug.cgi?id=191313

```

cd /var/tmp/portage/sys-block/iscsitarget-0.4.15/work

wget http://bugs.gentoo.org/attachment.cgi?id=134176&action=view

mv attachment.cgi\?id\=134176 p.patch

patch -p0 < p.patch

patching file iscsitarget-0.4.15/kernel/event.c

backup work # cd /usr/portage/sys-block/iscsitarget/
```

------------------ continue merging

```
ebuild iscsitarget-0.4.15.ebuild compile

ebuild iscsitarget-0.4.15.ebuild merge
```

----------

## richard.scott

I convereted these notes into a script that worked for me:

```
#!/bin/bash

cd /usr/portage/sys-block/iscsitarget/

ebuild iscsitarget-0.4.15.ebuild clean

ebuild iscsitarget-0.4.15.ebuild unpack

cd /var/tmp/portage/sys-block/iscsitarget-0.4.15/work

wget -O p.patch "http://bugs.gentoo.org/attachment.cgi?id=134176&action=view"

patch -p0 < p.patch

cd /usr/portage/sys-block/iscsitarget/

ebuild iscsitarget-0.4.15.ebuild compile

ebuild iscsitarget-0.4.15.ebuild merge
```

 :Smile: 

----------

