iscsitarget 在Linux2.6.32内核上编译 若干编译错误与解决方法(备忘)

时间:2021-05-25 14:47:43

#make
make -C usr
make[1]: Entering directory `/work/iscsitarget-0.4.16/usr'
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o ietd.o ietd.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o iscsid.o iscsid.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o conn.o conn.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o session.o session.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o target.o target.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o message.o message.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o ctldev.o ctldev.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o log.o log.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o chap.o chap.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o event.o event.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o param.o param.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o plain.o plain.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o isns.o isns.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 -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include   -c -o ietadm.o ietadm.c
cc ietadm.o param.o -o ietadm
make[1]: Leaving directory `/work/iscsitarget-0.4.16/usr'
make -C /lib/modules/2.6.32/build SUBDIRS=/work/iscsitarget-0.4.16/kernel modules
make[1]: Entering directory `/usr/src/linux-2.6.32'
  CC [M]  /work/iscsitarget-0.4.16/kernel/tio.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/iscsi.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/nthread.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/wthread.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/config.o
/work/iscsitarget-0.4.16/kernel/config.c: In function ‘iet_procfs_init’:
/work/iscsitarget-0.4.16/kernel/config.c:46: 错误:‘struct proc_dir_entry’ 没有名为 ‘owner’ 的成员
make[2]: *** [/work/iscsitarget-0.4.16/kernel/config.o] 错误 1
make[1]: *** [_module_/work/iscsitarget-0.4.16/kernel] 错误 2
make[1]: Leaving directory `/usr/src/linux-2.6.32'
make: *** [kernel] 错误 2

 

解决方法:

# vi kernel/config.c

注释掉

//      proc_iet_dir->owner = THIS_MODULE;

 

#make

make -C usr
make[1]: Entering directory `/work/iscsitarget-0.4.16/usr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/work/iscsitarget-0.4.16/usr'
make -C /lib/modules/2.6.32/build SUBDIRS=/work/iscsitarget-0.4.16/kernel modules
make[1]: Entering directory `/usr/src/linux-2.6.32'
  CC [M]  /work/iscsitarget-0.4.16/kernel/config.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/digest.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/conn.o
/work/iscsitarget-0.4.16/kernel/conn.c: In function ‘conn_info_show’:
/work/iscsitarget-0.4.16/kernel/conn.c:51: 错误:隐式声明函数 ‘NIP6’
/work/iscsitarget-0.4.16/kernel/conn.c:51: 警告:格式字符串实参太少
make[2]: *** [/work/iscsitarget-0.4.16/kernel/conn.o] 错误 1
make[1]: *** [_module_/work/iscsitarget-0.4.16/kernel] 错误 2
make[1]: Leaving directory `/usr/src/linux-2.6.32'
make: *** [kernel] 错误 2

 

解决方法:

# vi kernel/conn.c

注释掉

                case AF_INET6:
                //      snprintf(buf, sizeof(buf),
                //               "[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]",
                //               NIP6(inet6_sk(sk)->daddr));
                        break;

 

#make

make -C usr
make[1]: Entering directory `/work/iscsitarget-0.4.16/usr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/work/iscsitarget-0.4.16/usr'
make -C /lib/modules/2.6.32/build SUBDIRS=/work/iscsitarget-0.4.16/kernel modules
make[1]: Entering directory `/usr/src/linux-2.6.32'
  CC [M]  /work/iscsitarget-0.4.16/kernel/conn.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/session.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/target.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/volume.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/iotype.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/file-io.o
/work/iscsitarget-0.4.16/kernel/file-io.c: In function ‘fileio_sync’:
/work/iscsitarget-0.4.16/kernel/file-io.c:90: 错误:隐式声明函数 ‘sync_page_range’
make[2]: *** [/work/iscsitarget-0.4.16/kernel/file-io.o] 错误 1
make[1]: *** [_module_/work/iscsitarget-0.4.16/kernel] 错误 2
make[1]: Leaving directory `/usr/src/linux-2.6.32'
make: *** [kernel] 错误 2


解决方法:

#vi kernel/file-io.o

修改代码如下:

        //res = sync_page_range(inode, mapping, ppos, count);
        res = filemap_write_and_wait_range(mapping, ppos, ppos + count - 1);
        if (res) {
                eprintk("I/O error: syncing pages failed: %d/n", res);
                return -EIO;
        } else
                return 0;

 

#make

make -C usr
make[1]: Entering directory `/work/iscsitarget-0.4.16/usr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/work/iscsitarget-0.4.16/usr'
make -C /lib/modules/2.6.32/build SUBDIRS=/work/iscsitarget-0.4.16/kernel modules
make[1]: Entering directory `/usr/src/linux-2.6.32'
  CC [M]  /work/iscsitarget-0.4.16/kernel/file-io.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/null-io.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/target_disk.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/event.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/param.o
  CC [M]  /work/iscsitarget-0.4.16/kernel/block-io.o
In file included from /work/iscsitarget-0.4.16/kernel/block-io.c:12:
include/linux/parser.h:32: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘match_strl                                                         cpy’
/work/iscsitarget-0.4.16/kernel/block-io.c: In function ‘blockio_open_path’:
/work/iscsitarget-0.4.16/kernel/block-io.c:163: 错误:隐式声明函数 ‘open_bdev_excl’
/work/iscsitarget-0.4.16/kernel/block-io.c:163: 警告:赋值时将整数赋给指针,未作类型转换
/work/iscsitarget-0.4.16/kernel/block-io.c: In function ‘blockio_detach’:
/work/iscsitarget-0.4.16/kernel/block-io.c:314: 错误:隐式声明函数 ‘close_bdev_excl’
make[2]: *** [/work/iscsitarget-0.4.16/kernel/block-io.o] 错误 1
make[1]: *** [_module_/work/iscsitarget-0.4.16/kernel] 错误 2
make[1]: Leaving directory `/usr/src/linux-2.6.32'
make: *** [kernel] 错误 2

 

解决方法:

# vi kernel/block-io.c

修改代码如下:

//bdev = open_bdev_excl(path, flags, THIS_MODULE);

bdev = open_bdev_exclusive(path, flags, THIS_MODULE);
        if (IS_ERR(bdev)) {
                err = PTR_ERR(bdev);
                eprintk("Can't open device %s, error %d/n", path, err);
                bio_data->bdev = NULL;

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

//      if (bio_data->bdev)
//              close_bdev_excl(bio_data->bdev);
int flags = FMODE_READ | (LUReadonly(volume) ? 0 : FMODE_WRITE);

        if (bio_data->bdev)
                close_bdev_exclusive(bio_data->bdev, flags);

 

在文件开头的地方添加:

#include <linux/types.h>

 

 

#make

make -C usr
make[1]: Entering directory `/work/iscsitarget-0.4.16/usr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/work/iscsitarget-0.4.16/usr'
make -C /lib/modules/2.6.32/build SUBDIRS=/work/iscsitarget-0.4.16/kernel modules
make[1]: Entering directory `/usr/src/linux-2.6.32'
  CC [M]  /work/iscsitarget-0.4.16/kernel/block-io.o
  LD [M]  /work/iscsitarget-0.4.16/kernel/iscsi_trgt.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /work/iscsitarget-0.4.16/kernel/iscsi_trgt.mod.o
  LD [M]  /work/iscsitarget-0.4.16/kernel/iscsi_trgt.ko
make[1]: Leaving directory `/usr/src/linux-2.6.32'

 

#make install

 

 

========================编译OK===================