commit 5ae56610484b697325ad391a06254d807b7246b11d5d2b152133d677cd993854 Author: OBS User unknown Date: Wed Apr 11 02:44:39 2007 +0000 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/tgt?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/ready b/ready new file mode 100644 index 0000000..473a0f4 diff --git a/scsi_tgt_if.h b/scsi_tgt_if.h new file mode 100644 index 0000000..9f57139 --- /dev/null +++ b/scsi_tgt_if.h @@ -0,0 +1,89 @@ +/* + * SCSI target kernel/user interface + * + * Copyright (C) 2005 FUJITA Tomonori + * Copyright (C) 2005 Mike Christie + * + * 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; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ +#ifndef __SCSI_TARGET_IF_H +#define __SCSI_TARGET_IF_H + +/* user -> kernel */ +#define TGT_UEVENT_CMD_RSP 0x0001 +#define TGT_UEVENT_TSK_MGMT_RSP 0x0002 + +/* kernel -> user */ +#define TGT_KEVENT_CMD_REQ 0x1001 +#define TGT_KEVENT_CMD_DONE 0x1002 +#define TGT_KEVENT_TSK_MGMT_REQ 0x1003 + +struct tgt_event_hdr { + uint16_t version; + uint16_t status; + uint16_t type; + uint16_t len; +} __attribute__ ((aligned (sizeof(uint64_t)))); + +struct tgt_event { + struct tgt_event_hdr hdr; + + union { + /* user-> kernel */ + struct { + int host_no; + int result; + aligned_u64 tag; + aligned_u64 uaddr; + aligned_u64 sense_uaddr; + uint32_t len; + uint32_t sense_len; + uint8_t rw; + } cmd_rsp; + struct { + int host_no; + aligned_u64 mid; + int result; + } tsk_mgmt_rsp; + + + /* kernel -> user */ + struct { + int host_no; + uint32_t data_len; + uint8_t scb[16]; + uint8_t lun[8]; + int attribute; + aligned_u64 tag; + } cmd_req; + struct { + int host_no; + aligned_u64 tag; + int result; + } cmd_done; + struct { + int host_no; + int function; + aligned_u64 tag; + uint8_t lun[8]; + aligned_u64 mid; + } tsk_mgmt_req; + } p; +} __attribute__ ((aligned (sizeof(uint64_t)))); + +#define TGT_RING_SIZE (1UL << 16) + +#endif diff --git a/tgt-fix-build b/tgt-fix-build new file mode 100644 index 0000000..5da874c --- /dev/null +++ b/tgt-fix-build @@ -0,0 +1,71 @@ +diff --git a/usr/Makefile b/usr/Makefile +index 30cd34a..125274b 100644 +--- a/usr/Makefile ++++ b/usr/Makefile +@@ -1,3 +1,7 @@ ++# ++# Makefile for tgt userspace tools ++# ++ + ifneq ($(XEN),) + XEN_ROOT = ../.. + include $(XEN_ROOT)/tools/Rules.mk +@@ -6,9 +10,9 @@ INCLUDES += -I$(XEN_LIBXC) -I$(XEN_XENST + INCLUDES += -I$(LINUX_ROOT)/include -I. + LIBAIO_DIR = ../libaio/src + AIOLIBS := $(LIBAIO_DIR)/libaio.a +-CFLAGS += -I$(XEN_LIBXC) -I$(LIBAIO_DIR) +-CFLAGS += $(INCLUDES) -I. -I../../xenstore +-CFLAGS += -DXEN -DUSE_KERNEL ++INCLUDES += -I$(XEN_LIBXC) -I$(LIBAIO_DIR) ++INCLUDES += -I. -I../../xenstore ++DEFINES += -DXEN -DUSE_KERNEL + LIBS := -L. -L.. -L../lib + LIBS += -L$(XEN_LIBXC) + LIBS += -lxenctrl +@@ -16,7 +20,7 @@ LIBS += -L$(XEN_XENSTORE) -lxenstore $(A + TGTD_OBJS += $(addprefix xen/, xen.o xs_api.o xenbus.o) + TGTD_OBJS += tgtif.o bs_xen.o + else +-INCLUDES += -I../include -I$(KERNELSRC)/include ++INCLUDES += -I../include + LIBS += -laio + endif + +@@ -26,14 +30,14 @@ else + TGTD_OBJS += spt_sgv3.o + endif + +-ifneq ($(IBMVIO),) +-CFLAGS += -DIBMVIO -DUSE_KERNEL ++ifeq ($(IBMVIO),1) ++DEFINES += -DIBMVIO -DUSE_KERNEL + TGTD_OBJS += $(addprefix ibmvio/, ibmvio.o) + TGTD_OBJS += bs_mmap.o tgtif.o + endif + +-ifneq ($(ISCSI),) +-CFLAGS += -DISCSI ++ifeq ($(ISCSI),1) ++DEFINES += -DISCSI + TGTD_OBJS += $(addprefix iscsi/, conn.o param.o session.o iscsid.o target.o \ + chap.o transport.o iscsi_tcp.o) + TGTD_OBJS += bs_aio.o +@@ -41,7 +45,8 @@ LIBS += -lcrypto -lpthread + endif + + INCLUDES += -I. +-CFLAGS += -Wall -g -O2 -Wstrict-prototypes -fPIC -D_LARGEFILE64_SOURCE $(INCLUDES) ++DEFINES += -D_LARGEFILE64_SOURCE ++CFLAGS += -Wall -g -O2 -Wstrict-prototypes -fPIC + + PROGRAMS += tgtd tgtadm + TGTD_OBJS += tgtd.o mgmt.o target.o spc.o sbc.o mmc.o osd.o spt.o scsi.o log.o \ +@@ -62,3 +67,7 @@ endif + + clean: + rm -f *.o $(PROGRAMS) iscsi/*.o ibmvio/*.o xen/*.o ++ ++%.o: %.c ++ $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ ++ diff --git a/tgt-git-update b/tgt-git-update new file mode 100644 index 0000000..fd3e454 --- /dev/null +++ b/tgt-git-update @@ -0,0 +1,1361 @@ +diff -purN tgt-r849/.git/config ../git/tgt/.git/config +--- tgt-r849/.git/config 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/config 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,3 @@ ++[core] ++ repositoryformatversion = 0 ++ filemode = true +diff -purN tgt-r849/.git/description ../git/tgt/.git/description +--- tgt-r849/.git/description 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/description 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1 @@ ++Unnamed repository; edit this file to name it for gitweb. +diff -purN tgt-r849/.git/HEAD ../git/tgt/.git/HEAD +--- tgt-r849/.git/HEAD 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/HEAD 2007-04-03 15:02:25.000000000 +0200 +@@ -0,0 +1 @@ ++ref: refs/heads/master +diff -purN tgt-r849/.git/hooks/applypatch-msg ../git/tgt/.git/hooks/applypatch-msg +--- tgt-r849/.git/hooks/applypatch-msg 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/applypatch-msg 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,15 @@ ++#!/bin/sh ++# ++# An example hook script to check the commit log message taken by ++# applypatch from an e-mail message. ++# ++# The hook should exit with non-zero status after issuing an ++# appropriate message if it wants to stop the commit. The hook is ++# allowed to edit the commit message file. ++# ++# To enable this hook, make this file executable. ++ ++. git-sh-setup ++test -x "$GIT_DIR/hooks/commit-msg" && ++ exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} ++: +diff -purN tgt-r849/.git/hooks/commit-msg ../git/tgt/.git/hooks/commit-msg +--- tgt-r849/.git/hooks/commit-msg 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/commit-msg 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,18 @@ ++#!/bin/sh ++# ++# An example hook script to check the commit log message. ++# Called by git-commit with one argument, the name of the file ++# that has the commit message. The hook should exit with non-zero ++# status after issuing an appropriate message if it wants to stop the ++# commit. The hook is allowed to edit the commit message file. ++# ++# To enable this hook, make this file executable. ++ ++# This example catches duplicate Signed-off-by lines. ++ ++test "" = "$(grep '^Signed-off-by: ' "$1" | ++ sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { ++ echo >&2 Duplicate Signed-off-by lines. ++ exit 1 ++} ++ +diff -purN tgt-r849/.git/hooks/post-commit ../git/tgt/.git/hooks/post-commit +--- tgt-r849/.git/hooks/post-commit 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/post-commit 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,8 @@ ++#!/bin/sh ++# ++# An example hook script that is called after a successful ++# commit is made. ++# ++# To enable this hook, make this file executable. ++ ++: Nothing +diff -purN tgt-r849/.git/hooks/post-update ../git/tgt/.git/hooks/post-update +--- tgt-r849/.git/hooks/post-update 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/post-update 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,8 @@ ++#!/bin/sh ++# ++# An example hook script to prepare a packed repository for use over ++# dumb transports. ++# ++# To enable this hook, make this file executable by "chmod +x post-update". ++ ++exec git-update-server-info +diff -purN tgt-r849/.git/hooks/pre-applypatch ../git/tgt/.git/hooks/pre-applypatch +--- tgt-r849/.git/hooks/pre-applypatch 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/pre-applypatch 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,15 @@ ++#!/bin/sh ++# ++# An example hook script to verify what is about to be committed ++# by applypatch from an e-mail message. ++# ++# The hook should exit with non-zero status after issuing an ++# appropriate message if it wants to stop the commit. ++# ++# To enable this hook, make this file executable. ++ ++. git-sh-setup ++test -x "$GIT_DIR/hooks/pre-commit" && ++ exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} ++: ++ +diff -purN tgt-r849/.git/hooks/pre-commit ../git/tgt/.git/hooks/pre-commit +--- tgt-r849/.git/hooks/pre-commit 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/pre-commit 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,71 @@ ++#!/bin/sh ++# ++# An example hook script to verify what is about to be committed. ++# Called by git-commit with no arguments. The hook should ++# exit with non-zero status after issuing an appropriate message if ++# it wants to stop the commit. ++# ++# To enable this hook, make this file executable. ++ ++# This is slightly modified from Andrew Morton's Perfect Patch. ++# Lines you introduce should not have trailing whitespace. ++# Also check for an indentation that has SP before a TAB. ++ ++if git-rev-parse --verify HEAD 2>/dev/null ++then ++ git-diff-index -p -M --cached HEAD ++else ++ # NEEDSWORK: we should produce a diff with an empty tree here ++ # if we want to do the same verification for the initial import. ++ : ++fi | ++perl -e ' ++ my $found_bad = 0; ++ my $filename; ++ my $reported_filename = ""; ++ my $lineno; ++ sub bad_line { ++ my ($why, $line) = @_; ++ if (!$found_bad) { ++ print STDERR "*\n"; ++ print STDERR "* You have some suspicious patch lines:\n"; ++ print STDERR "*\n"; ++ $found_bad = 1; ++ } ++ if ($reported_filename ne $filename) { ++ print STDERR "* In $filename\n"; ++ $reported_filename = $filename; ++ } ++ print STDERR "* $why (line $lineno)\n"; ++ print STDERR "$filename:$lineno:$line\n"; ++ } ++ while (<>) { ++ if (m|^diff --git a/(.*) b/\1$|) { ++ $filename = $1; ++ next; ++ } ++ if (/^@@ -\S+ \+(\d+)/) { ++ $lineno = $1 - 1; ++ next; ++ } ++ if (/^ /) { ++ $lineno++; ++ next; ++ } ++ if (s/^\+//) { ++ $lineno++; ++ chomp; ++ if (/\s$/) { ++ bad_line("trailing whitespace", $_); ++ } ++ if (/^\s* /) { ++ bad_line("indent SP followed by a TAB", $_); ++ } ++ if (/^(?:[<>=]){7}/) { ++ bad_line("unresolved merge conflict", $_); ++ } ++ } ++ } ++ exit($found_bad); ++' ++ +diff -purN tgt-r849/.git/hooks/pre-rebase ../git/tgt/.git/hooks/pre-rebase +--- tgt-r849/.git/hooks/pre-rebase 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/pre-rebase 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,150 @@ ++#!/bin/sh ++# ++# Copyright (c) 2006 Junio C Hamano ++# ++ ++publish=next ++basebranch="$1" ++if test "$#" = 2 ++then ++ topic="refs/heads/$2" ++else ++ topic=`git symbolic-ref HEAD` ++fi ++ ++case "$basebranch,$topic" in ++master,refs/heads/??/*) ++ ;; ++*) ++ exit 0 ;# we do not interrupt others. ++ ;; ++esac ++ ++# Now we are dealing with a topic branch being rebased ++# on top of master. Is it OK to rebase it? ++ ++# Is topic fully merged to master? ++not_in_master=`git-rev-list --pretty=oneline ^master "$topic"` ++if test -z "$not_in_master" ++then ++ echo >&2 "$topic is fully merged to master; better remove it." ++ exit 1 ;# we could allow it, but there is no point. ++fi ++ ++# Is topic ever merged to next? If so you should not be rebasing it. ++only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort` ++only_next_2=`git-rev-list ^master ${publish} | sort` ++if test "$only_next_1" = "$only_next_2" ++then ++ not_in_topic=`git-rev-list "^$topic" master` ++ if test -z "$not_in_topic" ++ then ++ echo >&2 "$topic is already up-to-date with master" ++ exit 1 ;# we could allow it, but there is no point. ++ else ++ exit 0 ++ fi ++else ++ not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"` ++ perl -e ' ++ my $topic = $ARGV[0]; ++ my $msg = "* $topic has commits already merged to public branch:\n"; ++ my (%not_in_next) = map { ++ /^([0-9a-f]+) /; ++ ($1 => 1); ++ } split(/\n/, $ARGV[1]); ++ for my $elem (map { ++ /^([0-9a-f]+) (.*)$/; ++ [$1 => $2]; ++ } split(/\n/, $ARGV[2])) { ++ if (!exists $not_in_next{$elem->[0]}) { ++ if ($msg) { ++ print STDERR $msg; ++ undef $msg; ++ } ++ print STDERR " $elem->[1]\n"; ++ } ++ } ++ ' "$topic" "$not_in_next" "$not_in_master" ++ exit 1 ++fi ++ ++exit 0 ++ ++################################################################ ++ ++This sample hook safeguards topic branches that have been ++published from being rewound. ++ ++The workflow assumed here is: ++ ++ * Once a topic branch forks from "master", "master" is never ++ merged into it again (either directly or indirectly). ++ ++ * Once a topic branch is fully cooked and merged into "master", ++ it is deleted. If you need to build on top of it to correct ++ earlier mistakes, a new topic branch is created by forking at ++ the tip of the "master". This is not strictly necessary, but ++ it makes it easier to keep your history simple. ++ ++ * Whenever you need to test or publish your changes to topic ++ branches, merge them into "next" branch. ++ ++The script, being an example, hardcodes the publish branch name ++to be "next", but it is trivial to make it configurable via ++$GIT_DIR/config mechanism. ++ ++With this workflow, you would want to know: ++ ++(1) ... if a topic branch has ever been merged to "next". Young ++ topic branches can have stupid mistakes you would rather ++ clean up before publishing, and things that have not been ++ merged into other branches can be easily rebased without ++ affecting other people. But once it is published, you would ++ not want to rewind it. ++ ++(2) ... if a topic branch has been fully merged to "master". ++ Then you can delete it. More importantly, you should not ++ build on top of it -- other people may already want to ++ change things related to the topic as patches against your ++ "master", so if you need further changes, it is better to ++ fork the topic (perhaps with the same name) afresh from the ++ tip of "master". ++ ++Let's look at this example: ++ ++ o---o---o---o---o---o---o---o---o---o "next" ++ / / / / ++ / a---a---b A / / ++ / / / / ++ / / c---c---c---c B / ++ / / / \ / ++ / / / b---b C \ / ++ / / / / \ / ++ ---o---o---o---o---o---o---o---o---o---o---o "master" ++ ++ ++A, B and C are topic branches. ++ ++ * A has one fix since it was merged up to "next". ++ ++ * B has finished. It has been fully merged up to "master" and "next", ++ and is ready to be deleted. ++ ++ * C has not merged to "next" at all. ++ ++We would want to allow C to be rebased, refuse A, and encourage ++B to be deleted. ++ ++To compute (1): ++ ++ git-rev-list ^master ^topic next ++ git-rev-list ^master next ++ ++ if these match, topic has not merged in next at all. ++ ++To compute (2): ++ ++ git-rev-list master..topic ++ ++ if this is empty, it is fully merged to "master". +diff -purN tgt-r849/.git/hooks/update ../git/tgt/.git/hooks/update +--- tgt-r849/.git/hooks/update 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/hooks/update 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,89 @@ ++#!/bin/sh ++# ++# An example hook script to mail out commit update information. ++# It also blocks tags that aren't annotated. ++# Called by git-receive-pack with arguments: refname sha1-old sha1-new ++# ++# To enable this hook: ++# (1) change the recipient e-mail address ++# (2) make this file executable by "chmod +x update". ++# ++ ++project=$(cat $GIT_DIR/description) ++recipients="commit-list@somewhere.com commit-list@somewhereelse.com" ++ ++ref_type=$(git cat-file -t "$3") ++ ++# Only allow annotated tags in a shared repo ++# Remove this code to treat dumb tags the same as everything else ++case "$1","$ref_type" in ++refs/tags/*,commit) ++ echo "*** Un-annotated tags are not allowed in this repo" >&2 ++ echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." ++ exit 1;; ++refs/tags/*,tag) ++ echo "### Pushing version '${1##refs/tags/}' to the masses" >&2 ++ # recipients="release-announce@somwehere.com announce@somewhereelse.com" ++ ;; ++esac ++ ++# set this to 'cat' to get a very detailed listing. ++# short only kicks in when an annotated tag is added ++short='git shortlog' ++ ++# see 'date --help' for info on how to write this ++# The default is a human-readable iso8601-like format with minute ++# precision ('2006-01-25 15:58 +0100' for example) ++date_format="%F %R %z" ++ ++(if expr "$2" : '0*$' >/dev/null ++then ++ # new ref ++ case "$1" in ++ refs/tags/*) ++ # a pushed and annotated tag (usually) means a new version ++ tag="${1##refs/tags/}" ++ if [ "$ref_type" = tag ]; then ++ eval $(git cat-file tag $3 | \ ++ sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p') ++ date=$(date --date="1970-01-01 00:00:00 $ts seconds" +"$date_format") ++ echo "Tag '$tag' created by $tagger at $date" ++ git cat-file tag $3 | sed -n '5,$p' ++ echo ++ fi ++ prev=$(git describe "$3^" | sed 's/-g.*//') ++ # the first tag in a repo will yield no $prev ++ if [ -z "$prev" ]; then ++ echo "Changes since the dawn of time:" ++ git rev-list --pretty $3 | $short ++ else ++ echo "Changes since $prev:" ++ git rev-list --pretty $prev..$3 | $short ++ echo --- ++ git diff --stat $prev..$3 ++ echo --- ++ fi ++ ;; ++ ++ refs/heads/*) ++ branch="${1##refs/heads/}" ++ echo "New branch '$branch' available with the following commits:" ++ git-rev-list --pretty "$3" $(git-rev-parse --not --all) ++ ;; ++ esac ++else ++ base=$(git-merge-base "$2" "$3") ++ case "$base" in ++ "$2") ++ git diff --stat "$3" "^$base" ++ echo ++ echo "New commits:" ++ ;; ++ *) ++ echo "Rebased ref, commits from common ancestor:" ++ ;; ++ esac ++ git-rev-list --pretty "$3" "^$base" ++fi) | ++mail -s "$project: Changes to '${1##refs/heads/}'" $recipients ++exit 0 +Files tgt-r849/.git/index and ../git/tgt/.git/index differ +diff -purN tgt-r849/.git/info/exclude ../git/tgt/.git/info/exclude +--- tgt-r849/.git/info/exclude 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/info/exclude 2007-04-03 15:02:21.000000000 +0200 +@@ -0,0 +1,6 @@ ++# git-ls-files --others --exclude-from=.git/info/exclude ++# Lines that start with '#' are comments. ++# For a project mostly in C, the following would be a good set of ++# exclude patterns (uncomment them if you want to use them): ++# *.[oa] ++# *~ +Files tgt-r849/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.idx and ../git/tgt/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.idx differ +Files tgt-r849/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.pack and ../git/tgt/.git/objects/pack/pack-9a9a5f56366f6b0d7dd377fa1e6605953b356ae4.pack differ +diff -purN tgt-r849/.git/refs/heads/master ../git/tgt/.git/refs/heads/master +--- tgt-r849/.git/refs/heads/master 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/refs/heads/master 2007-04-03 15:02:25.000000000 +0200 +@@ -0,0 +1 @@ ++4ae01ba345c5593f5cdfc3d1ec1f35a605708ad4 +diff -purN tgt-r849/.git/refs/heads/origin ../git/tgt/.git/refs/heads/origin +--- tgt-r849/.git/refs/heads/origin 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/refs/heads/origin 2007-04-03 15:02:25.000000000 +0200 +@@ -0,0 +1 @@ ++4ae01ba345c5593f5cdfc3d1ec1f35a605708ad4 +diff -purN tgt-r849/.git/remotes/origin ../git/tgt/.git/remotes/origin +--- tgt-r849/.git/remotes/origin 1970-01-01 01:00:00.000000000 +0100 ++++ ../git/tgt/.git/remotes/origin 2007-04-03 15:02:25.000000000 +0200 +@@ -0,0 +1,2 @@ ++URL: git://git.kernel.org/pub/scm/linux/kernel/git/tomo/tgt.git ++Pull: refs/heads/master:refs/heads/origin +diff -purN tgt-r849/usr/bs_aio.c ../git/tgt/usr/bs_aio.c +--- tgt-r849/usr/bs_aio.c 2007-03-18 05:10:23.944393000 +0100 ++++ ../git/tgt/usr/bs_aio.c 2007-04-03 15:02:25.000000000 +0200 +@@ -115,11 +115,11 @@ static void bs_aio_handler(int fd, int e + } + + static int +-bs_aio_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size) ++bs_aio_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) + { + int ret; + struct bs_aio_info *info = +- (struct bs_aio_info *) ((char *)dev + sizeof(*dev)); ++ (struct bs_aio_info *) ((char *)lu + sizeof(*lu)); + + *fd = backed_file_open(path, O_RDWR| O_LARGEFILE, size); + if (*fd < 0) +@@ -166,36 +166,36 @@ close_dev_fd: + return -1; + } + +-static void bs_aio_close(struct tgt_device *dev) ++static void bs_aio_close(struct scsi_lu *lu) + { + struct bs_aio_info *info; + +- info = (struct bs_aio_info *) ((char *)dev + sizeof(*dev)); ++ info = (struct bs_aio_info *) ((char *)lu + sizeof(*lu)); + + pthread_cancel(info->aio_thread); + pthread_join(info->aio_thread, NULL); + io_destroy(info->ctx); +- close(dev->fd); ++ close(lu->fd); + } + + static int bs_aio_cmd_submit(struct scsi_cmd *cmd) + { +- struct tgt_device *dev = cmd->dev; +- struct bs_aio_info *info = (struct bs_aio_info *)((char *)dev + sizeof(*dev)); ++ struct scsi_lu *lu = cmd->dev; ++ struct bs_aio_info *info = (struct bs_aio_info *)((char *)lu + sizeof(*lu)); + struct iocb iocb, *io; + int ret; + + io = &iocb; + memset(io, 0, sizeof(*io)); + +- dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", dev->fd, cmd->rw, cmd->len, ++ dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", lu->fd, cmd->rw, cmd->len, + cmd->uaddr, cmd->offset, cmd); + + if (cmd->rw == READ) +- io_prep_pread(io, dev->fd, (void *)(unsigned long)cmd->uaddr, ++ io_prep_pread(io, lu->fd, (void *)(unsigned long)cmd->uaddr, + cmd->len, cmd->offset); + else +- io_prep_pwrite(io, dev->fd, (void *)(unsigned long)cmd->uaddr, ++ io_prep_pwrite(io, lu->fd, (void *)(unsigned long)cmd->uaddr, + cmd->len, cmd->offset); + + io->data = cmd; +@@ -205,7 +205,7 @@ static int bs_aio_cmd_submit(struct scsi + cmd->async = 1; + return 0; + } else { +- dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", dev->fd, cmd->rw, cmd->len, ++ dprintf("%d %d %u %" PRIx64 " %" PRIx64 " %p\n", lu->fd, cmd->rw, cmd->len, + cmd->uaddr, cmd->offset, cmd); + return 1; + } +diff -purN tgt-r849/usr/bs_mmap.c ../git/tgt/usr/bs_mmap.c +--- tgt-r849/usr/bs_mmap.c 2007-03-18 05:10:23.944393000 +0100 ++++ ../git/tgt/usr/bs_mmap.c 2007-04-03 15:02:25.000000000 +0200 +@@ -32,16 +32,16 @@ + #include "util.h" + #include "tgtd.h" + +-static int bs_mmap_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size) ++static int bs_mmap_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) + { + *fd = backed_file_open(path, O_RDWR| O_LARGEFILE, size); + + return *fd >= 0 ? 0 : *fd; + } + +-static void bs_mmap_close(struct tgt_device *dev) ++static void bs_mmap_close(struct scsi_lu *lu) + { +- close(dev->fd); ++ close(lu->fd); + } + + #define pgcnt(size, offset) ((((size) + ((offset) & (pagesize - 1))) + (pagesize - 1)) >> pageshift) +diff -purN tgt-r849/usr/bs_xen.c ../git/tgt/usr/bs_xen.c +--- tgt-r849/usr/bs_xen.c 2007-03-18 05:10:23.944393000 +0100 ++++ ../git/tgt/usr/bs_xen.c 2007-04-03 15:02:25.000000000 +0200 +@@ -37,22 +37,22 @@ + + #define O_DIRECT 040000 /* who defines this?*/ + +-static int bs_xen_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size) ++static int bs_xen_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) + { + *fd = backed_file_open(path, O_RDWR| O_LARGEFILE | O_DIRECT, size); + + return *fd >= 0 ? 0 : *fd; + } + +-static void bs_xen_close(struct tgt_device *dev) ++static void bs_xen_close(struct scsi_lu *lu) + { +- close(dev->fd); ++ close(lu->fd); + } + + /* + * Replace this with AIO readv/writev after 2.6.20. + */ +-static int bs_xen_cmd_submit(struct tgt_device *dev, uint8_t *scb, int rw, ++static int bs_xen_cmd_submit(struct scsi_lu *lu, uint8_t *scb, int rw, + uint32_t datalen, unsigned long *uaddr, + uint64_t offset, int *async, void *key) + { +@@ -65,12 +65,12 @@ static int bs_xen_cmd_submit(struct tgt_ + total += iov[cnt++].iov_len; + } while (total < datalen); + +- lseek64(dev->fd, offset, SEEK_SET); ++ lseek64(lu->fd, offset, SEEK_SET); + + if (rw == READ) +- readv(dev->fd, iov, cnt); ++ readv(lu->fd, iov, cnt); + else +- writev(dev->fd, iov, cnt); ++ writev(lu->fd, iov, cnt); + + return 0; + } +diff -purN tgt-r849/usr/ibmvio/ibmvio.c ../git/tgt/usr/ibmvio/ibmvio.c +--- tgt-r849/usr/ibmvio/ibmvio.c 2007-03-18 05:10:23.944393000 +0100 ++++ ../git/tgt/usr/ibmvio/ibmvio.c 2007-04-03 15:02:25.000000000 +0200 +@@ -185,7 +185,7 @@ static uint64_t make_lun(unsigned int bu + + static int ibmvio_report_luns(int host_no, struct scsi_cmd *cmd) + { +- struct tgt_device *dev; ++ struct scsi_lu *lu; + struct list_head *dev_list = &cmd->c_target->device_list; + uint64_t lun, *data; + int idx, alen, oalen, nr_luns, rbuflen = 4096; +@@ -219,8 +219,8 @@ static int ibmvio_report_luns(int host_n + idx = 2; + nr_luns = 1; + +- list_for_each_entry(dev, dev_list, device_siblings) { +- lun = dev->lun; ++ list_for_each_entry(lu, dev_list, device_siblings) { ++ lun = lu->lun; + lun = make_lun(0, lun & 0x003f, 0); + data[idx++] = __cpu_to_be64(lun); + if (!(alen -= 8)) +diff -purN tgt-r849/usr/iscsi/iscsid.c ../git/tgt/usr/iscsi/iscsid.c +--- tgt-r849/usr/iscsi/iscsid.c 2007-03-18 05:10:23.944393000 +0100 ++++ ../git/tgt/usr/iscsi/iscsid.c 2007-04-03 15:02:26.000000000 +0200 +@@ -740,28 +740,12 @@ static void cmnd_finish(struct iscsi_con + } + } + +-static int iscsi_cmd_rsp_build(struct iscsi_task *task) ++static void calc_residual(struct iscsi_cmd_rsp *rsp, struct iscsi_task *task) + { +- struct iscsi_connection *conn = task->conn; +- struct iscsi_cmd_rsp *rsp = (struct iscsi_cmd_rsp *) &conn->rsp.bhs; +- uint32_t residual; +- +- dprintf("%p %x\n", task, task->scmd.scb[0]); +- +- memset(rsp, 0, sizeof(*rsp)); +- rsp->opcode = ISCSI_OP_SCSI_CMD_RSP; +- rsp->itt = task->tag; +- rsp->flags = ISCSI_FLAG_CMD_FINAL; +- rsp->response = ISCSI_STATUS_CMD_COMPLETED; +- rsp->cmd_status = task->result; +- rsp->statsn = cpu_to_be32(conn->stat_sn++); +- rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn); +- rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD); ++ uint32_t residual = 0; + + /* we never have write under/over flow, no way to signal that + * back from the target currently. */ +- +- residual = 0; + if (task->dir == BIDIRECTIONAL) { + if (task->len < task->read_len) { + rsp->flags |= ISCSI_FLAG_CMD_BIDI_UNDERFLOW; +@@ -782,6 +766,26 @@ static int iscsi_cmd_rsp_build(struct is + } + rsp->residual_count = cpu_to_be32(residual); + } ++} ++ ++static int iscsi_cmd_rsp_build(struct iscsi_task *task) ++{ ++ struct iscsi_connection *conn = task->conn; ++ struct iscsi_cmd_rsp *rsp = (struct iscsi_cmd_rsp *) &conn->rsp.bhs; ++ ++ dprintf("%p %x\n", task, task->scmd.scb[0]); ++ ++ memset(rsp, 0, sizeof(*rsp)); ++ rsp->opcode = ISCSI_OP_SCSI_CMD_RSP; ++ rsp->itt = task->tag; ++ rsp->flags = ISCSI_FLAG_CMD_FINAL; ++ rsp->response = ISCSI_STATUS_CMD_COMPLETED; ++ rsp->cmd_status = task->result; ++ rsp->statsn = cpu_to_be32(conn->stat_sn++); ++ rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn); ++ rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD); ++ ++ calc_residual(rsp, task); + + return 0; + } +@@ -797,7 +801,6 @@ static int iscsi_sense_rsp_build(struct + struct iscsi_cmd_rsp *rsp = (struct iscsi_cmd_rsp *) &conn->rsp.bhs; + struct iscsi_sense_data *sense; + unsigned char sense_len; +- uint32_t residual; + + memset(rsp, 0, sizeof(*rsp)); + rsp->opcode = ISCSI_OP_SCSI_CMD_RSP; +@@ -809,28 +812,7 @@ static int iscsi_sense_rsp_build(struct + rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn); + rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD); + +- /* XXX: copied from above, consider merging these functions */ +- residual = 0; +- if (task->dir == BIDIRECTIONAL) { +- if (task->len < task->read_len) { +- rsp->flags |= ISCSI_FLAG_CMD_BIDI_UNDERFLOW; +- residual = task->read_len - task->len; +- } else if (task->len > task->read_len) { +- rsp->flags |= ISCSI_FLAG_CMD_BIDI_OVERFLOW; +- residual = task->len - task->read_len; +- } +- rsp->bi_residual_count = cpu_to_be32(residual); +- rsp->residual_count = 0; +- } else { +- if (task->len < task->read_len) { +- rsp->flags |= ISCSI_FLAG_CMD_UNDERFLOW; +- residual = task->read_len - task->len; +- } else if (task->len > task->read_len) { +- rsp->flags |= ISCSI_FLAG_CMD_OVERFLOW; +- residual = task->len - task->read_len; +- } +- rsp->residual_count = cpu_to_be32(residual); +- } ++ calc_residual(rsp, task); + + sense = (struct iscsi_sense_data *)task->scmd.sense_buffer; + sense_len = task->scmd.sense_len; +@@ -849,9 +831,8 @@ static int iscsi_data_rsp_build(struct i + { + struct iscsi_connection *conn = task->conn; + struct iscsi_data_rsp *rsp = (struct iscsi_data_rsp *) &conn->rsp.bhs; +- int datalen, exp_datalen = task->read_len; ++ int datalen; + int max_burst = conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val; +- uint32_t residual; + + memset(rsp, 0, sizeof(*rsp)); + rsp->opcode = ISCSI_OP_SCSI_DATA_IN; +@@ -861,10 +842,10 @@ static int iscsi_data_rsp_build(struct i + rsp->offset = cpu_to_be32(task->offset); + rsp->datasn = cpu_to_be32(task->exp_r2tsn++); + +- datalen = min(exp_datalen, task->len); ++ datalen = min_t(uint32_t, task->read_len, task->len); + datalen -= task->offset; + +- dprintf("%d %d %d %d %x\n", datalen, exp_datalen, task->len, max_burst, rsp->itt); ++ dprintf("%d %d %d %d %x\n", datalen, task->read_len, task->len, max_burst, rsp->itt); + + if (datalen <= max_burst) { + rsp->flags = ISCSI_FLAG_CMD_FINAL; +@@ -872,17 +853,9 @@ static int iscsi_data_rsp_build(struct i + /* collapse status into final packet if successful */ + if (task->result == 0 && task->dir != BIDIRECTIONAL) { + rsp->flags |= ISCSI_FLAG_DATA_STATUS; +- if (task->len < exp_datalen) { +- rsp->flags |= ISCSI_FLAG_CMD_UNDERFLOW; +- residual = exp_datalen - task->len; +- } else if (task->len > exp_datalen) { +- rsp->flags |= ISCSI_FLAG_CMD_OVERFLOW; +- residual = task->len - exp_datalen; +- } else +- residual = 0; + rsp->cmd_status = task->result; + rsp->statsn = cpu_to_be32(conn->stat_sn++); +- rsp->residual_count = cpu_to_be32(residual); ++ calc_residual((struct iscsi_cmd_rsp *) rsp, task); + } + } else + datalen = max_burst; +@@ -1044,7 +1017,7 @@ static int iscsi_target_cmd_queue(struct + + if (ahs_extcdb->ahstype == ISCSI_AHSTYPE_CDB) { + int extcdb_len = ntohs(ahs_extcdb->ahslength) - 1; +- char *p = (void *)task->extdata; ++ unsigned char *p = (void *)task->extdata; + + if (4 + extcdb_len > ahslen) { + eprintf("AHS len %d too short for extcdb %d\n", +@@ -1272,7 +1245,7 @@ found: + + conn->rx_buffer = task->data; + conn->rx_buffer += be32_to_cpu(req->offset); +- conn->rx_size = ntoh24(req->dlength); ++ conn->rx_size = roundup(ntoh24(req->dlength), 4); + + task->offset += ntoh24(req->dlength); + task->r2t_count -= ntoh24(req->dlength); +@@ -1386,7 +1359,7 @@ static int iscsi_noop_out_rx_start(struc + { + struct iscsi_hdr *req = (struct iscsi_hdr *) &conn->req.bhs; + struct iscsi_task *task; +- int len, err = -ENOMEM; ++ int len, err = 0; + + dprintf("%x %x %u\n", req->ttt, req->itt, ntoh24(req->dlength)); + if (req->ttt != cpu_to_be32(ISCSI_RESERVED_TAG)) { +@@ -1413,8 +1386,10 @@ static int iscsi_noop_out_rx_start(struc + task = iscsi_alloc_task(conn, len); + if (task) + conn->rx_task = task; +- else ++ else { ++ err = -ENOMEM; + goto out; ++ } + + if (len) { + conn->rx_size = len; +@@ -1495,7 +1470,7 @@ static int iscsi_task_rx_start(struct is + break; + } + +- return 0; ++ return err; + } + + static int iscsi_scsi_cmd_tx_start(struct iscsi_task *task) +diff -purN tgt-r849/usr/osd.c ../git/tgt/usr/osd.c +--- tgt-r849/usr/osd.c 2007-03-18 12:09:13.438820000 +0100 ++++ ../git/tgt/usr/osd.c 2007-04-03 15:02:26.000000000 +0200 +@@ -133,9 +133,9 @@ static int osd_varlen_cdb(int host_no, s + return cmd->c_target->bst->bs_cmd_submit(cmd); + } + +-static void device_osd_init(struct tgt_device *dev) ++static void device_osd_init(struct scsi_lu *lu) + { +- dev->d_sense = 1; ++ lu->d_sense = 1; + } + + struct device_type_template osd_template = { +diff -purN tgt-r849/usr/spc.c ../git/tgt/usr/spc.c +--- tgt-r849/usr/spc.c 2007-03-17 05:57:45.700965000 +0100 ++++ ../git/tgt/usr/spc.c 2007-04-03 15:02:26.000000000 +0200 +@@ -63,9 +63,9 @@ int spc_inquiry(int host_no, struct scsi + data[4] = 59; + data[7] = 0x02; + memset(data + 8, 0x20, 28); +- strncpy(data + 8, VENDOR_ID, 8); +- strncpy(data + 16, product_id, 16); +- strncpy(data + 32, PRODUCT_REV, 4); ++ strncpy((char *)data + 8, VENDOR_ID, 8); ++ strncpy((char *)data + 16, product_id, 16); ++ strncpy((char *)data + 32, PRODUCT_REV, 4); + data[58] = 0x03; + data[59] = 0x20; + data[60] = 0x09; +@@ -145,7 +145,7 @@ sense: + + int spc_report_luns(int host_no, struct scsi_cmd *cmd) + { +- struct tgt_device *dev; ++ struct scsi_lu *lu; + struct list_head *dev_list = &cmd->c_target->device_list; + uint64_t lun, *data; + int idx, alen, oalen, nr_luns, rbuflen = 4096, overflow; +@@ -172,13 +172,13 @@ int spc_report_luns(int host_no, struct + nr_luns = 0; + + overflow = 0; +- list_for_each_entry(dev, dev_list, device_siblings) { ++ list_for_each_entry(lu, dev_list, device_siblings) { + nr_luns++; + + if (overflow) + continue; + +- lun = dev->lun; ++ lun = lu->lun; + lun = ((lun > 0xff) ? (0x1 << 30) : 0) | ((0x3ff & lun) << 16); + data[idx++] = __cpu_to_be64(lun << 32); + if (!(alen -= 8)) +@@ -241,6 +241,6 @@ int spc_request_sense(int host_no, struc + int spc_illegal_op(int host_no, struct scsi_cmd *cmd) + { + cmd->len = 0; +- sense_data_build(cmd, ILLEGAL_REQUEST, 0x24, 0); ++ sense_data_build(cmd, ILLEGAL_REQUEST, 0x20, 0); + return SAM_STAT_CHECK_CONDITION; + } +diff -purN tgt-r849/usr/spt.c ../git/tgt/usr/spt.c +--- tgt-r849/usr/spt.c 2007-03-18 02:02:22.904616000 +0100 ++++ ../git/tgt/usr/spt.c 2007-04-03 15:02:26.000000000 +0200 +@@ -41,13 +41,13 @@ + #include "scsi.h" + #include "spc.h" + +-extern int spt_sg_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size); ++extern int spt_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size); + extern int spt_sg_perform(struct scsi_cmd *cmd); + +-static void spt_sg_close(struct tgt_device *dev) ++static void spt_sg_close(struct scsi_lu *lu) + { +- tgt_event_del(dev->fd); +- close(dev->fd); ++ tgt_event_del(lu->fd); ++ close(lu->fd); + } + + static int spt_sg_cmd_done(int do_munmap, int do_free, uint64_t uaddr, int len) +diff -purN tgt-r849/usr/spt_sgv3.c ../git/tgt/usr/spt_sgv3.c +--- tgt-r849/usr/spt_sgv3.c 2007-03-04 05:34:38.896408000 +0100 ++++ ../git/tgt/usr/spt_sgv3.c 2007-04-03 15:02:26.000000000 +0200 +@@ -48,9 +48,9 @@ static void sgv3_handler(int fd, int eve + { + int i, err; + struct sg_io_hdr hdrs[64]; +- struct tgt_device *dev = data; ++ struct scsi_lu *lu = data; + +- err = read(dev->fd, hdrs, sizeof(struct sg_io_hdr)); ++ err = read(lu->fd, hdrs, sizeof(struct sg_io_hdr)); + if (err <= 0) + return; + +@@ -71,7 +71,7 @@ static void sgv3_handler(int fd, int eve + } + } + +-int spt_sg_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size) ++int spt_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) + { + int err; + int nr_queue_cmd; +@@ -89,9 +89,9 @@ int spt_sg_open(struct tgt_device *dev, + goto close_fd; + } + +- err = tgt_event_add(*fd, EPOLLIN, sgv3_handler, dev); ++ err = tgt_event_add(*fd, EPOLLIN, sgv3_handler, lu); + if (err) { +- free(dev); ++ free(lu); + goto close_fd; + } + +diff -purN tgt-r849/usr/spt_sgv4.c ../git/tgt/usr/spt_sgv4.c +--- tgt-r849/usr/spt_sgv4.c 2007-03-10 10:54:10.506520000 +0100 ++++ ../git/tgt/usr/spt_sgv4.c 2007-04-03 15:02:26.000000000 +0200 +@@ -50,9 +50,9 @@ static void sgv4_handler(int fd, int eve + { + int i, err; + struct sg_io_v4 hdrs[64]; +- struct tgt_device *dev = data; ++ struct scsi_lu *lu = data; + +- err = read(dev->fd, hdrs, sizeof(hdrs)); ++ err = read(lu->fd, hdrs, sizeof(hdrs)); + if (err < 0) + return; + +@@ -75,7 +75,7 @@ static void sgv4_handler(int fd, int eve + } + } + +-int spt_sg_open(struct tgt_device *dev, char *path, int *fd, uint64_t *size) ++int spt_sg_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) + { + int err, maj, min; + char *sd, buf[256]; +@@ -166,9 +166,9 @@ int spt_sg_open(struct tgt_device *dev, + goto close_fd; + } + +- err = tgt_event_add(*fd, EPOLLIN, sgv4_handler, dev); ++ err = tgt_event_add(*fd, EPOLLIN, sgv4_handler, lu); + if (err) { +- free(dev); ++ free(lu); + goto close_fd; + } + +diff -purN tgt-r849/usr/target.c ../git/tgt/usr/target.c +--- tgt-r849/usr/target.c 2007-03-18 05:10:23.944393000 +0100 ++++ ../git/tgt/usr/target.c 2007-04-03 15:02:26.000000000 +0200 +@@ -117,13 +117,13 @@ int it_nexus_destroy(uint64_t nid) + return -ENOENT; + } + +-static struct tgt_device *device_lookup(struct target *target, uint64_t lun) ++static struct scsi_lu *device_lookup(struct target *target, uint64_t lun) + { +- struct tgt_device *device; ++ struct scsi_lu *lu; + +- list_for_each_entry(device, &target->device_list, device_siblings) +- if (device->lun == lun) +- return device; ++ list_for_each_entry(lu, &target->device_list, device_siblings) ++ if (lu->lun == lun) ++ return lu; + return NULL; + } + +@@ -157,7 +157,7 @@ static void tgt_cmd_queue_init(struct tg + } + + static int tgt_device_path_update(struct target *target, +- struct tgt_device *device, char *path) ++ struct scsi_lu *lu, char *path) + { + int err, dev_fd; + uint64_t size; +@@ -166,36 +166,36 @@ static int tgt_device_path_update(struct + if (!path) + return TGTADM_NOMEM; + +- err = target->bst->bs_open(device, path, &dev_fd, &size); ++ err = target->bst->bs_open(lu, path, &dev_fd, &size); + if (err) { + free(path); + return TGTADM_INVALID_REQUEST; + } + +- device->fd = dev_fd; +- device->addr = 0; +- device->size = size; +- device->path = path; ++ lu->fd = dev_fd; ++ lu->addr = 0; ++ lu->size = size; ++ lu->path = path; + + return 0; + } + +-static struct tgt_device * ++static struct scsi_lu * + __device_lookup(int tid, uint64_t lun, struct target **t) + { + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + + target = target_lookup(tid); + if (!target) + return NULL; + +- device = device_lookup(target, lun); +- if (!device) ++ lu = device_lookup(target, lun); ++ if (!lu) + return NULL; + + *t = target; +- return device; ++ return lu; + } + + int tgt_device_create(int tid, uint64_t lun, char *args) +@@ -203,7 +203,7 @@ int tgt_device_create(int tid, uint64_t + char *p; + int err; + struct target *target; +- struct tgt_device *device, *pos; ++ struct scsi_lu *lu, *pos; + + dprintf("%d %" PRIu64 "\n", tid, lun); + +@@ -211,8 +211,8 @@ int tgt_device_create(int tid, uint64_t + if (!target) + return TGTADM_NO_TARGET; + +- device = device_lookup(target, lun); +- if (device) { ++ lu = device_lookup(target, lun); ++ if (lu) { + eprintf("device %" PRIu64 " already exists\n", lun); + return TGTADM_LUN_EXIST; + } +@@ -225,31 +225,32 @@ int tgt_device_create(int tid, uint64_t + return TGTADM_INVALID_REQUEST; + p++; + +- device = zalloc(sizeof(*device) + target->bst->bs_datasize); +- if (!device) ++ lu = zalloc(sizeof(*lu) + target->bst->bs_datasize); ++ if (!lu) + return TGTADM_NOMEM; + +- err = tgt_device_path_update(target, device, p); ++ err = tgt_device_path_update(target, lu, p); + if (err) { +- free(device); ++ free(lu); + return err; + } + +- device->lun = lun; ++ lu->lun = lun; ++ lu->lu_state = SCSI_LU_RUNNING; + +- snprintf(device->scsi_id, sizeof(device->scsi_id), ++ snprintf(lu->scsi_id, sizeof(lu->scsi_id), + "deadbeaf%d:%" PRIu64, tid, lun); + +- tgt_cmd_queue_init(&device->cmd_queue); ++ tgt_cmd_queue_init(&lu->cmd_queue); + + if (target->dev_type_template.device_init) +- target->dev_type_template.device_init(device); ++ target->dev_type_template.device_init(lu); + + list_for_each_entry(pos, &target->device_list, device_siblings) { +- if (device->lun < pos->lun) ++ if (lu->lun < pos->lun) + break; + } +- list_add_tail(&device->device_siblings, &pos->device_siblings); ++ list_add_tail(&lu->device_siblings, &pos->device_siblings); + + dprintf("Add a logical unit %" PRIu64 " to the target %d\n", lun, tid); + return 0; +@@ -258,57 +259,57 @@ int tgt_device_create(int tid, uint64_t + int tgt_device_destroy(int tid, uint64_t lun) + { + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + + dprintf("%u %" PRIu64 "\n", tid, lun); + +- device = __device_lookup(tid, lun, &target); +- if (!device) { ++ lu = __device_lookup(tid, lun, &target); ++ if (!lu) { + eprintf("device %" PRIu64 " not found\n", lun); + return TGTADM_NO_LUN; + } + +- if (!list_empty(&device->cmd_queue.queue)) ++ if (!list_empty(&lu->cmd_queue.queue) || lu->cmd_queue.active_cmd) + return TGTADM_LUN_ACTIVE; + +- free(device->path); +- list_del(&device->device_siblings); ++ free(lu->path); ++ list_del(&lu->device_siblings); + +- target->bst->bs_close(device); +- free(device); ++ target->bst->bs_close(lu); ++ free(lu); + return 0; + } + + int device_reserve(uint64_t nid, uint64_t lun, uint64_t reserve_id) + { + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + +- device = __device_lookup(NID2TID(nid), lun, &target); +- if (!device) ++ lu = __device_lookup(NID2TID(nid), lun, &target); ++ if (!lu) + return -EINVAL; + +- if (device->reserve_id && device->reserve_id != reserve_id) { ++ if (lu->reserve_id && lu->reserve_id != reserve_id) { + dprintf("already reserved %" PRIu64 " %" PRIu64 "\n", +- device->reserve_id, reserve_id); ++ lu->reserve_id, reserve_id); + return -EBUSY; + } + +- device->reserve_id = reserve_id; ++ lu->reserve_id = reserve_id; + return 0; + } + + int device_release(uint64_t nid, uint64_t lun, uint64_t reserve_id, int force) + { + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + +- device = __device_lookup(NID2TID(nid), lun, &target); +- if (!device) ++ lu = __device_lookup(NID2TID(nid), lun, &target); ++ if (!lu) + return 0; + +- if (force || device->reserve_id == reserve_id) { +- device->reserve_id = 0; ++ if (force || lu->reserve_id == reserve_id) { ++ lu->reserve_id = 0; + return 0; + } + +@@ -318,10 +319,10 @@ int device_release(uint64_t nid, uint64_ + int device_reserved(uint64_t nid, uint64_t lun, uint64_t reserve_id) + { + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + +- device = __device_lookup(NID2TID(nid), lun, &target); +- if (!device || !device->reserve_id || device->reserve_id == reserve_id) ++ lu = __device_lookup(NID2TID(nid), lun, &target); ++ if (!lu || !lu->reserve_id || lu->reserve_id == reserve_id) + return 0; + return -EBUSY; + } +@@ -330,22 +331,22 @@ int tgt_device_update(int tid, uint64_t + { + int err = 0; + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + + target = target_lookup(tid); + if (!target) + return TGTADM_NO_TARGET; + +- device = device_lookup(target, dev_id); +- if (!device) { ++ lu = device_lookup(target, dev_id); ++ if (!lu) { + eprintf("device %" PRIu64 " not found\n", dev_id); + return TGTADM_NO_LUN; + } + + if (!strncmp(name, "scsi_id=", 8)) +- memcpy(device->scsi_id, name + 8, sizeof(device->scsi_id) - 1); ++ memcpy(lu->scsi_id, name + 8, sizeof(lu->scsi_id) - 1); + else if (!strncmp(name, "scsi_sn=", 8)) +- memcpy(device->scsi_sn, name + 8, sizeof(device->scsi_sn) - 1); ++ memcpy(lu->scsi_sn, name + 8, sizeof(lu->scsi_sn) - 1); + else + err = TGTADM_INVALID_REQUEST; + +@@ -412,13 +413,18 @@ int target_cmd_queue(struct scsi_cmd *cm + + cmd->c_target = target = nexus->nexus_target; + +- cmd_hlist_insert(target, cmd); +- + dev_id = scsi_get_devid(target->lid, cmd->lun); + dprintf("%p %x %" PRIx64 "\n", cmd, cmd->scb[0], dev_id); + + cmd->dev = device_lookup(target, dev_id); + ++ /* service delivery or target failure */ ++ if (target->target_state != SCSI_TARGET_RUNNING || ++ (cmd->dev && cmd->dev->lu_state != SCSI_LU_RUNNING)) ++ return -EBUSY; ++ ++ cmd_hlist_insert(target, cmd); ++ + if (cmd->dev) + q = &cmd->dev->cmd_queue; + else +@@ -998,7 +1004,7 @@ static struct { + enum scsi_target_state value; + char *name; + } target_state[] = { +- {SCSI_TARGET_SUSPENDED, "suspended"}, ++ {SCSI_TARGET_OFFLINE, "offline"}, + {SCSI_TARGET_RUNNING, "running"}, + }; + +@@ -1054,7 +1060,7 @@ int tgt_target_show_all(char *buf, int r + { + int total = 0, max = rest; + struct target *target; +- struct tgt_device *device; ++ struct scsi_lu *lu; + struct acl_entry *acl; + struct it_nexus *nexus; + +@@ -1081,18 +1087,18 @@ int tgt_target_show_all(char *buf, int r + } + + shprintf(total, buf, rest, _TAB1 "LUN information:\n"); +- list_for_each_entry(device, &target->device_list, device_siblings) ++ list_for_each_entry(lu, &target->device_list, device_siblings) + shprintf(total, buf, rest, + _TAB2 "LUN: %" PRIu64 "\n" + _TAB3 "SCSI ID: %s\n" + _TAB3 "SCSI SN: %s\n" + _TAB3 "Size: %s\n" + _TAB3 "Backing store: %s\n", +- device->lun, +- device->scsi_id, +- device->scsi_sn, +- print_disksize(device->size), +- device->path); ++ lu->lun, ++ lu->scsi_id, ++ lu->scsi_sn, ++ print_disksize(lu->size), ++ lu->path); + + if (!strcmp(tgt_drivers[target->lid]->name, "iscsi")) { + int i, aid; +@@ -1260,7 +1266,7 @@ int tgt_target_destroy(int tid) + } + + free(target->account.in_aids); +- ++ free(target->name); + free(target); + + return 0; +diff -purN tgt-r849/usr/tgtd.h ../git/tgt/usr/tgtd.h +--- tgt-r849/usr/tgtd.h 2007-03-18 02:02:22.904616000 +0100 ++++ ../git/tgt/usr/tgtd.h 2007-04-03 15:02:26.000000000 +0200 +@@ -19,17 +19,22 @@ + #define _TAB4 _TAB2 _TAB2 + + enum scsi_target_state { +- SCSI_TARGET_SUSPENDED = 1, ++ SCSI_TARGET_OFFLINE = 1, + SCSI_TARGET_RUNNING, + }; + ++enum scsi_lu_state { ++ SCSI_LU_OFFLINE = 1, ++ SCSI_LU_RUNNING, ++}; ++ + struct tgt_cmd_queue { + int active_cmd; + unsigned long state; + struct list_head queue; + }; + +-struct tgt_device { ++struct scsi_lu { + int fd; + uint64_t addr; /* persistent mapped address */ + uint64_t size; +@@ -43,6 +48,8 @@ struct tgt_device { + + struct tgt_cmd_queue cmd_queue; + ++ enum scsi_lu_state lu_state; ++ + uint64_t reserve_id; + + /* TODO: needs a structure for lots of device parameters */ +@@ -58,7 +65,7 @@ struct scsi_cmd { + uint64_t uaddr; + uint32_t len; + int mmapped; +- struct tgt_device *dev; ++ struct scsi_lu *dev; + unsigned long state; + + uint64_t cmd_nexus_id; +@@ -80,8 +87,8 @@ struct scsi_cmd { + + struct backingstore_template { + int bs_datasize; +- int (*bs_open)(struct tgt_device *dev, char *path, int *fd, uint64_t *size); +- void (*bs_close)(struct tgt_device *dev); ++ int (*bs_open)(struct scsi_lu *dev, char *path, int *fd, uint64_t *size); ++ void (*bs_close)(struct scsi_lu *dev); + int (*bs_cmd_submit)(struct scsi_cmd *cmd); + int (*bs_cmd_done) (int do_munmap, int do_free, uint64_t uaddr, int len); + }; +@@ -104,7 +111,7 @@ struct device_type_template { + char *name; + char *pid; + +- void (*device_init)(struct tgt_device *dev); ++ void (*device_init)(struct scsi_lu *dev); + + struct device_type_operations ops[256]; + }; diff --git a/tgt-ibmvio-build-local b/tgt-ibmvio-build-local new file mode 100644 index 0000000..3380175 --- /dev/null +++ b/tgt-ibmvio-build-local @@ -0,0 +1,18 @@ +diff --git a/usr/Makefile b/usr/Makefile +diff --git a/usr/ibmvio/ibmvio.c b/usr/ibmvio/ibmvio.c +diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c +diff --git a/usr/scsi.h b/usr/scsi.h +diff --git a/usr/target.c b/usr/target.c +diff --git a/usr/tgtif.c b/usr/tgtif.c +index 5ee6fe5..960d31d 100644 +--- a/usr/tgtif.c ++++ b/usr/tgtif.c +@@ -35,7 +35,7 @@ #include + #include + + #define aligned_u64 unsigned long long __attribute__((aligned(8))) +-#include ++#include "scsi_tgt_if.h" + + #include "list.h" + #include "util.h" diff --git a/tgt-mmc-read-toc-swapped-args b/tgt-mmc-read-toc-swapped-args new file mode 100644 index 0000000..a3741bf --- /dev/null +++ b/tgt-mmc-read-toc-swapped-args @@ -0,0 +1,20 @@ +--- tgt-r819/usr/mmc.c.orig 2007-04-03 16:00:16.306368493 +0200 ++++ tgt-r819/usr/mmc.c 2007-04-03 16:03:40.974528047 +0200 +@@ -155,7 +155,7 @@ static int mmc_read_toc(int host_no, str + sense_data_build(cmd, HARDWARE_ERROR, 0, 0); + return SAM_STAT_CHECK_CONDITION; + } +- memset(data, pagesize, 0); ++ memset(data, 0, pagesize); + cmd->uaddr = (unsigned long) data; + + /* forged for single session data cd only. all iso file fall into this */ +@@ -191,7 +191,7 @@ static int mmc_read_capacity(int host_no + sense_data_build(cmd, HARDWARE_ERROR, 0, 0); + return SAM_STAT_CHECK_CONDITION; + } +- memset(data, pagesize, 0); ++ memset(data, 0, pagesize); + cmd->uaddr = (unsigned long) data; + + size = cmd->dev->size >> MMC_BLK_SHIFT; diff --git a/tgt-r849.tar.bz2 b/tgt-r849.tar.bz2 new file mode 100644 index 0000000..e1b238f --- /dev/null +++ b/tgt-r849.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b3b7f24616a2fd65c616307df3dcdfb1605136696f2da6e45154325d874b15b +size 63635 diff --git a/tgt-update-scsi-header-file b/tgt-update-scsi-header-file new file mode 100644 index 0000000..0786ff9 --- /dev/null +++ b/tgt-update-scsi-header-file @@ -0,0 +1,147 @@ +diff --git a/usr/ibmvio/ibmvio.c b/usr/ibmvio/ibmvio.c +index ff91f14..c21b8e1 100644 +--- a/usr/ibmvio/ibmvio.c ++++ b/usr/ibmvio/ibmvio.c +@@ -35,9 +35,9 @@ #include + #include + #include + #include +-#include + #include + ++#include "scsi.h" + #include "list.h" + #include "util.h" + #include "tgtd.h" +diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c +index 0a2578a..4d5afb4 100644 +--- a/usr/iscsi/iscsid.c ++++ b/usr/iscsi/iscsid.c +@@ -17,9 +17,9 @@ #include + #include + #include + #include +-#include + #include + ++#include "scsi.h" + #include "iscsid.h" + #include "tgtd.h" + #include "util.h" +diff --git a/usr/scsi.h b/usr/scsi.h +index f70dfd7..d8a607a 100644 +--- a/usr/scsi.h ++++ b/usr/scsi.h +@@ -100,6 +100,9 @@ #define SAM_STAT_TASK_SET_FULL 0x28 + #define SAM_STAT_ACA_ACTIVE 0x30 + #define SAM_STAT_TASK_ABORTED 0x40 + ++/* This looks wrong */ ++#define TASK_ABORTED 0x20 ++ + #define NO_SENSE 0x00 + #define RECOVERED_ERROR 0x01 + #define NOT_READY 0x02 +@@ -133,16 +136,36 @@ #define TYPE_NO_LUN 0x7f + + #define TYPE_SPT 0xff + +-#define MSG_SIMPLE_TAG 0x20 +-#define MSG_HEAD_TAG 0x21 +-#define MSG_ORDERED_TAG 0x22 +- +-#define ABORT_TASK 0x0d ++#define COMMAND_COMPLETE 0x00 ++#define EXTENDED_MESSAGE 0x01 ++#define EXTENDED_MODIFY_DATA_POINTER 0x00 ++#define EXTENDED_SDTR 0x01 ++#define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */ ++#define EXTENDED_WDTR 0x03 ++#define EXTENDED_PPR 0x04 ++#define EXTENDED_MODIFY_BIDI_DATA_PTR 0x05 ++#define SAVE_POINTERS 0x02 ++#define RESTORE_POINTERS 0x03 ++#define DISCONNECT 0x04 ++#define INITIATOR_ERROR 0x05 + #define ABORT_TASK_SET 0x06 +-#define CLEAR_ACA 0x16 ++#define MESSAGE_REJECT 0x07 ++#define NOP 0x08 ++#define MSG_PARITY_ERROR 0x09 ++#define LINKED_CMD_COMPLETE 0x0a ++#define LINKED_FLG_CMD_COMPLETE 0x0b ++#define TARGET_RESET 0x0c ++#define ABORT_TASK 0x0d + #define CLEAR_TASK_SET 0x0e ++#define INITIATE_RECOVERY 0x0f /* SCSI-II only */ ++#define RELEASE_RECOVERY 0x10 /* SCSI-II only */ ++#define CLEAR_ACA 0x16 + #define LOGICAL_UNIT_RESET 0x17 +-#define TASK_ABORTED 0x20 +-#define SAM_STAT_TASK_ABORTED 0x40 ++#define SIMPLE_QUEUE_TAG 0x20 ++#define HEAD_OF_QUEUE_TAG 0x21 ++#define ORDERED_QUEUE_TAG 0x22 ++#define IGNORE_WIDE_RESIDUE 0x23 ++#define ACA 0x24 ++#define QAS_REQUEST 0x55 + + #endif +diff --git a/usr/target.c b/usr/target.c +index f48839e..7539daa 100644 +--- a/usr/target.c ++++ b/usr/target.c +@@ -357,26 +357,26 @@ static int cmd_enabled(struct tgt_cmd_qu + { + int enabled = 0; + +- if (cmd->attribute != MSG_SIMPLE_TAG) ++ if (cmd->attribute != SIMPLE_QUEUE_TAG) + dprintf("non simple attribute %" PRIx64 " %x %" PRIu64 " %d\n", + cmd->tag, cmd->attribute, cmd->dev ? cmd->dev->lun : UINT64_MAX, + q->active_cmd); + + switch (cmd->attribute) { +- case MSG_SIMPLE_TAG: ++ case SIMPLE_QUEUE_TAG: + if (!queue_blocked(q)) + enabled = 1; + break; +- case MSG_ORDERED_TAG: ++ case ORDERED_QUEUE_TAG: + if (!queue_blocked(q) && !queue_active(q)) + enabled = 1; + break; +- case MSG_HEAD_TAG: ++ case HEAD_OF_QUEUE_TAG: + enabled = 1; + break; + default: + eprintf("unknown command attribute %x\n", cmd->attribute); +- cmd->attribute = MSG_ORDERED_TAG; ++ cmd->attribute = ORDERED_QUEUE_TAG; + if (!queue_blocked(q) && !queue_active(q)) + enabled = 1; + } +@@ -388,8 +388,8 @@ static void cmd_post_perform(struct tgt_ + { + q->active_cmd++; + switch (cmd->attribute) { +- case MSG_ORDERED_TAG: +- case MSG_HEAD_TAG: ++ case ORDERED_QUEUE_TAG: ++ case HEAD_OF_QUEUE_TAG: + set_queue_blocked(q); + break; + } +@@ -522,8 +522,8 @@ static void __cmd_done(struct target *ta + + q->active_cmd--; + switch (cmd->attribute) { +- case MSG_ORDERED_TAG: +- case MSG_HEAD_TAG: ++ case ORDERED_QUEUE_TAG: ++ case HEAD_OF_QUEUE_TAG: + clear_queue_blocked(q); + break; + } diff --git a/tgt.changes b/tgt.changes new file mode 100644 index 0000000..4857653 --- /dev/null +++ b/tgt.changes @@ -0,0 +1,12 @@ +------------------------------------------------------------------- +Wed Apr 4 11:21:52 CEST 2007 - hare@suse.de + +- Added service definition for SUSEFirewall2 (#251679) + +------------------------------------------------------------------- +Wed Apr 4 10:26:41 CEST 2007 - hare@suse.de + +- Initial version svn r849 +- Update to latest git version +- Fixes for build on openSUSE + diff --git a/tgt.init b/tgt.init new file mode 100644 index 0000000..636e35f --- /dev/null +++ b/tgt.init @@ -0,0 +1,64 @@ +#!/bin/sh +# +# /etc/init.d/tgtd +# +### BEGIN INIT INFO +# Provides: tgtd +# Required-Start: $network +# Should-Start: +# Required-Stop: +# Should-Stop: +# Default-Start: 3 5 +# Default-Stop: +# Short-Description: Starts and stops the generic storage target daemon +# +### END INIT INFO + +# +# +# pidfile: /var/run/tgtd.pid + +DAEMON=/usr/sbin/tgtd +PIDFILE=/var/run/tgtd.pid + +# Source LSB init functions +. /etc/rc.status + +rc_reset + +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +case "$1" in + start) + echo -n "Starting SCSI target service: " + modprobe crc32c + modprobe scsi_tgt + startproc -p $PIDFILE $DAEMON + rc_status -v + ;; + stop) + echo -n "Stopping SCSI target service: " + tgtadm --op delete >/dev/null 2>/dev/null + killproc -p $PIDFILE -TERM $DAEMON + modprobe -r scsi_tgt 2>/dev/null + RETVAL=$? + modprobe -r crc32c 2>/dev/null + if [ $RETVAL != "0" ]; then + rc_failed + fi + rc_status -v + ;; + restart) + $0 stop + $0 start + ;; + status) + echo -n "Checking for SCSI target service" + checkproc -p $PIDFILE $DAEMON + rc_status -v + ;; + *) + echo $"Usage: $0 {start|stop|restart|status}" + exit 1 +esac +rc_exit diff --git a/tgt.services b/tgt.services new file mode 100644 index 0000000..7756b79 --- /dev/null +++ b/tgt.services @@ -0,0 +1,18 @@ + ## Name: iSCSI Target Daemon + ## Description: Opens ports for iSCSI Target Daemon with broadcast allowed. + + # space separated list of allowed TCP ports + TCP="iscsi-target" + + # space separated list of allowed UDP ports + UDP="iscsi-target" + + # space separated list of allowed RPC services + RPC="" + + # space separated list of allowed IP protocols + IP="" + + # space separated list of allowed UDP broadcast ports + BROADCAST="iscsi-target" + diff --git a/tgt.spec b/tgt.spec new file mode 100644 index 0000000..7b523fa --- /dev/null +++ b/tgt.spec @@ -0,0 +1,98 @@ +# +# spec file for package tgt (Version 0.1) +# +# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# norootforbuild + +Name: tgt +BuildRequires: libaio-devel openssl-devel +Obsoletes: iscsitarget +URL: http://stgt.berlios.de +License: GNU General Public License (GPL) +Group: System/Daemons +Prereq: %fillup_prereq %insserv_prereq +Autoreqprov: on +Version: 0.1 +Release: 1 +Requires: kernel +Summary: Generic Linux target framework (tgt) +Source: %{name}-r849.tar.bz2 +Source1: %{name}.init +Source2: scsi_tgt_if.h +Source3: %{name}.services +Patch1: %{name}-git-update +Patch2: %{name}-mmc-read-toc-swapped-args +Patch10: %{name}-update-scsi-header-file +Patch11: %{name}-fix-build +Patch12: %{name}-ibmvio-build-local +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +Linux target framework (tgt) aims to simplify various SCSI target +driver (iSCSI, Fibre Channel, SRP, etc) creation and maintenance. + +Tgt consists of kernel modules, user-space daemon, and user-space +tools. Some target drivers uses all of them and some use only +user-space daemon and tools (i.e. they completely runs in user space). + + + +Authors: +-------- + FUJITA Tomonori + Mike Christie + +%prep +%setup -n %{name}-r849 +%patch1 -p1 +%patch2 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +cp %{S:2} usr/scsi_tgt_if.h + +%build +cd usr +%ifarch ppc ppc64 +IBMVIO=1 +%else +IBMVIO=0 +%endif +%{__make} CFLAGS="${RPM_OPT_FLAGS}" ISCSI=1 IBMVIO=$IBMVIO + +%install +install -vD usr/tgtd ${RPM_BUILD_ROOT}/usr/sbin/tgtd +install -vD usr/tgtadm ${RPM_BUILD_ROOT}/usr/sbin/tgtadm +install -vD -m 755 %{S:1} ${RPM_BUILD_ROOT}/etc/init.d/tgtd +install -vD %{S:3} ${RPM_BUILD_ROOT}/etc/sysconfig/SuSEfirewall2.d/services/iscsitarget + +%clean +[ "${RPM_BUILD_ROOT}" != "/" -a -d ${RPM_BUILD_ROOT} ] && rm -rf ${RPM_BUILD_ROOT} +rm -f filelist + +%post +%{fillup_and_insserv tgtd} + +%postun +%{insserv_cleanup} + +%files +%attr(755,root,root)/usr/sbin/* +%attr(755,root,root)/etc/init.d/tgtd +%attr(644,root,root)/etc/sysconfig/SuSEfirewall2.d/services/iscsitarget +%defattr(-,root,root) +%doc README doc/README.iscsi doc/TODO + +%changelog +* Wed Apr 04 2007 - hare@suse.de +- Added service definition for SUSEFirewall2 (#251679) +* Wed Apr 04 2007 - hare@suse.de +- Initial version svn r849 +- Update to latest git version +- Fixes for build on openSUSE