~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/target/target-export-device

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/target/target-export-device (Version linux-6.12-rc7) and /Documentation/target/target-export-device (Version linux-5.19.17)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 #                                                   2 #
  3 # This script illustrates the sequence of oper      3 # This script illustrates the sequence of operations in configfs to
  4 # create a very simple LIO iSCSI target with a      4 # create a very simple LIO iSCSI target with a file or block device
  5 # backstore.                                        5 # backstore.
  6 #                                                   6 #
  7 # (C) Copyright 2014 Christophe Vu-Brugier <cvu      7 # (C) Copyright 2014 Christophe Vu-Brugier <cvubrugier@fastmail.fm>
  8 #                                                   8 #
  9                                                     9 
 10 print_usage() {                                    10 print_usage() {
 11     cat <<EOF                                      11     cat <<EOF
 12 Usage: $(basename $0) [-p PORTAL] DEVICE|FILE      12 Usage: $(basename $0) [-p PORTAL] DEVICE|FILE
 13 Export a block device or a file as an iSCSI ta     13 Export a block device or a file as an iSCSI target with a single LUN
 14 EOF                                                14 EOF
 15 }                                                  15 }
 16                                                    16 
 17 die() {                                            17 die() {
 18     echo $1                                        18     echo $1
 19     exit 1                                         19     exit 1
 20 }                                                  20 }
 21                                                    21 
 22 while getopts "hp:" arg; do                        22 while getopts "hp:" arg; do
 23     case $arg in                                   23     case $arg in
 24         h) print_usage; exit 0;;                   24         h) print_usage; exit 0;;
 25         p) PORTAL=${OPTARG};;                      25         p) PORTAL=${OPTARG};;
 26     esac                                           26     esac
 27 done                                               27 done
 28 shift $(($OPTIND - 1))                             28 shift $(($OPTIND - 1))
 29                                                    29 
 30 DEVICE=$1                                          30 DEVICE=$1
 31 [ -n "$DEVICE" ] || die "Missing device or fil     31 [ -n "$DEVICE" ] || die "Missing device or file argument"
 32 [ -b $DEVICE -o -f $DEVICE ] || die "Invalid d     32 [ -b $DEVICE -o -f $DEVICE ] || die "Invalid device or file: ${DEVICE}"
 33 IQN="iqn.2003-01.org.linux-iscsi.$(hostname):$     33 IQN="iqn.2003-01.org.linux-iscsi.$(hostname):$(basename $DEVICE)"
 34 [ -n "$PORTAL" ] || PORTAL="0.0.0.0:3260"          34 [ -n "$PORTAL" ] || PORTAL="0.0.0.0:3260"
 35                                                    35 
 36 CONFIGFS=/sys/kernel/config                        36 CONFIGFS=/sys/kernel/config
 37 CORE_DIR=$CONFIGFS/target/core                     37 CORE_DIR=$CONFIGFS/target/core
 38 ISCSI_DIR=$CONFIGFS/target/iscsi                   38 ISCSI_DIR=$CONFIGFS/target/iscsi
 39                                                    39 
 40 # Load the target modules and mount the config     40 # Load the target modules and mount the config file system
 41 lsmod | grep -q configfs || modprobe configfs      41 lsmod | grep -q configfs || modprobe configfs
 42 lsmod | grep -q target_core_mod || modprobe ta     42 lsmod | grep -q target_core_mod || modprobe target_core_mod
 43 mount | grep -q ^configfs || mount -t configfs     43 mount | grep -q ^configfs || mount -t configfs none $CONFIGFS
 44 mkdir -p $ISCSI_DIR                                44 mkdir -p $ISCSI_DIR
 45                                                    45 
 46 # Create a backstore                               46 # Create a backstore
 47 if [ -b $DEVICE ]; then                            47 if [ -b $DEVICE ]; then
 48     BACKSTORE_DIR=$CORE_DIR/iblock_0/data          48     BACKSTORE_DIR=$CORE_DIR/iblock_0/data
 49     mkdir -p $BACKSTORE_DIR                        49     mkdir -p $BACKSTORE_DIR
 50     echo "udev_path=${DEVICE}" > $BACKSTORE_DI     50     echo "udev_path=${DEVICE}" > $BACKSTORE_DIR/control
 51 else                                               51 else
 52     BACKSTORE_DIR=$CORE_DIR/fileio_0/data          52     BACKSTORE_DIR=$CORE_DIR/fileio_0/data
 53     mkdir -p $BACKSTORE_DIR                        53     mkdir -p $BACKSTORE_DIR
 54     DEVICE_SIZE=$(du -b $DEVICE | cut -f1)         54     DEVICE_SIZE=$(du -b $DEVICE | cut -f1)
 55     echo "fd_dev_name=${DEVICE}" > $BACKSTORE_     55     echo "fd_dev_name=${DEVICE}" > $BACKSTORE_DIR/control
 56     echo "fd_dev_size=${DEVICE_SIZE}" > $BACKS     56     echo "fd_dev_size=${DEVICE_SIZE}" > $BACKSTORE_DIR/control
 57     echo 1 > $BACKSTORE_DIR/attrib/emulate_wri     57     echo 1 > $BACKSTORE_DIR/attrib/emulate_write_cache
 58 fi                                                 58 fi
 59 echo 1 > $BACKSTORE_DIR/enable                     59 echo 1 > $BACKSTORE_DIR/enable
 60                                                    60 
 61 # Create an iSCSI target and a target portal g     61 # Create an iSCSI target and a target portal group (TPG)
 62 mkdir $ISCSI_DIR/$IQN                              62 mkdir $ISCSI_DIR/$IQN
 63 mkdir $ISCSI_DIR/$IQN/tpgt_1/                      63 mkdir $ISCSI_DIR/$IQN/tpgt_1/
 64                                                    64 
 65 # Create a LUN                                     65 # Create a LUN
 66 mkdir $ISCSI_DIR/$IQN/tpgt_1/lun/lun_0             66 mkdir $ISCSI_DIR/$IQN/tpgt_1/lun/lun_0
 67 ln -s $BACKSTORE_DIR $ISCSI_DIR/$IQN/tpgt_1/lu     67 ln -s $BACKSTORE_DIR $ISCSI_DIR/$IQN/tpgt_1/lun/lun_0/data
 68 echo 1 > $ISCSI_DIR/$IQN/tpgt_1/enable             68 echo 1 > $ISCSI_DIR/$IQN/tpgt_1/enable
 69                                                    69 
 70 # Create a network portal                          70 # Create a network portal
 71 mkdir $ISCSI_DIR/$IQN/tpgt_1/np/$PORTAL            71 mkdir $ISCSI_DIR/$IQN/tpgt_1/np/$PORTAL
 72                                                    72 
 73 # Disable authentication                           73 # Disable authentication
 74 echo 0 > $ISCSI_DIR/$IQN/tpgt_1/attrib/authent     74 echo 0 > $ISCSI_DIR/$IQN/tpgt_1/attrib/authentication
 75 echo 1 > $ISCSI_DIR/$IQN/tpgt_1/attrib/generat     75 echo 1 > $ISCSI_DIR/$IQN/tpgt_1/attrib/generate_node_acls
 76                                                    76 
 77 # Allow write access for non authenticated ini     77 # Allow write access for non authenticated initiators
 78 echo 0 > $ISCSI_DIR/$IQN/tpgt_1/attrib/demo_mo     78 echo 0 > $ISCSI_DIR/$IQN/tpgt_1/attrib/demo_mode_write_protect
 79                                                    79 
 80 echo "Target ${IQN}, portal ${PORTAL} has been     80 echo "Target ${IQN}, portal ${PORTAL} has been created"
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php