Commit Graph

36 Commits

Author SHA1 Message Date
agc fafe105c5c Clean up after moving the iSCSI initiator to src/usr.sbin/iscsi/initiator 2009-06-19 07:27:38 +00:00
wiz 3914d9bd61 Add RCS Id. Sort options. Fix xref.
XXX: virtdir(3) does not exist, but I do not know to which page the link
should point instead.
2008-05-25 19:42:22 +00:00
dholland b20bda484e MKMAN should not be set in source makefiles. Use NOMAN. 2008-03-09 22:47:11 +00:00
agc fca43256ed make sure we have an __UNCONST definition available, for portability reasons. 2008-02-10 11:02:05 +00:00
agc 5a37868bfa Define the version of the FUSE ABI we're working with specifically.
Don't hand all the argv options to fuse_main() - it's only interested
in the ones we haven't parsed ourselves.

These changes make the initiator compile and perform discovery successfully
on FreeBSD 6.3. Full login doesn't work yet due to a KSE related bug.
2008-02-07 07:33:37 +00:00
agc 5ca5718e92 Set a definitive FUSE ABI before including fuse.h, to avoid situations
where different operating ssystems default to different levels.
2008-02-07 07:21:15 +00:00
agc 755a2e55e0 Move to a resizable dynamic array for the targets that the initiator
can find.

If the initiator discovers too many targets for it to handle
(currently more than 16), then truncate to the maximum with a loud
warning message, rather than aborting.

In practice, this means that multiple targets can now be used with the
NetBSD iSCSI initiator.

% ls -laR /mnt/inspiron1300.wherever.co.uk/
total 192
drwxr-xr-x  2 agc   agc    512 Dec 11 08:53 .
drwxr-xr-x  2 root  wheel    0 Jan  1  1970 ..
drwxr-xr-x  2 agc   agc    512 Dec 11 08:53 target0
drwxr-xr-x  2 agc   agc    512 Dec 11 08:53 target1

/mnt/inspiron1300.wherever.co.uk/target0:
total 576
drwxr-xr-x  2 agc  agc        512 Dec 11 08:53 .
drwxr-xr-x  2 agc  agc        512 Dec 11 08:53 ..
lrw-r--r--  1 agc  agc         44 Dec 11 08:53 hostname -> inspiron1300.wherever.co.uk
lrw-r--r--  1 agc  agc          9 Dec 11 08:53 ip -> 10.4.0.42
lrw-r--r--  1 agc  agc         16 Dec 11 08:53 product -> NetBSD iSCSI
-rw-r--r--  1 agc  agc  104857600 Dec 11 08:53 storage
lrw-r--r--  1 agc  agc         43 Dec 11 08:53 targetname -> iqn.1994-04.org.netbsd.iscsi-target:target0
lrw-r--r--  1 agc  agc          8 Dec 11 08:53 vendor -> NetBSD
lrw-r--r--  1 agc  agc          4 Dec 11 08:53 version -> 0

/mnt/inspiron1300.wherever.co.uk/target1:
total 576
drwxr-xr-x  2 agc  agc       512 Dec 11 08:53 .
drwxr-xr-x  2 agc  agc       512 Dec 11 08:53 ..
lrw-r--r--  1 agc  agc        44 Dec 11 08:53 hostname -> inspiron1300.wherever.co.uk
lrw-r--r--  1 agc  agc         0 Dec 11 08:53 ip ->
lrw-r--r--  1 agc  agc        16 Dec 11 08:53 product -> NetBSD iSCSI
-rw-r--r--  1 agc  agc  52428800 Dec 11 08:53 storage
lrw-r--r--  1 agc  agc        43 Dec 11 08:53 targetname -> iqn.1994-04.org.netbsd.iscsi-target:target1
lrw-r--r--  1 agc  agc         8 Dec 11 08:53 vendor -> NetBSD
lrw-r--r--  1 agc  agc         4 Dec 11 08:53 version -> 0
%
2007-12-11 09:07:36 +00:00
oster 0fa5922403 Add a '-D' option to allow "Discovery" of the targets provided by a host.
Initial support for multiple targets from the same host.

Base 'MaxTargets' on a #define, rather than hard-coding.

Reviewed by: agc
2007-12-04 16:22:38 +00:00
wiz 0d78c993a2 Use more markup. Fix xrefs. Use standard headers. 2007-12-02 19:31:46 +00:00
agc 8b0e0ddc0d The iSCSI target returns the 0-based Max LBA in the READ_CAPACITY command,
and we need to add 1 to it to get the size of the LUN.

Revert Max LBA calculation when returning the Maximum LBA from the target
to the iinitiator, following an email conversation with Jonathan Kollasch,
who points out a number of things:

+ the NetBSD scsipi driver reads the value returned by the drive and adds
one to it, so that standard SCSI drives return the 0-based Max LBA in a
READ CAPACITY command.

+ it is up to the initiator to add 1 to the Max LBA to find out the size
of the LUN (Jonathan verified this by using the UNH iSCSI initiator on
to a NetBSD target)

+ an analogous change to the NetBSD target (revision 1.34 of
disk.c) is needed.
2007-11-18 23:52:13 +00:00
agc 3d98641f85 Fix from Jonathan Kollasch - avoid an intermediate 32-bit value in the
calculation of the size of the storage file.

Remove some dead code.
2007-11-17 23:35:28 +00:00
agc f2e9f627b5 Only use the bottom 20bits for an inode number to prevent the inode number creeping out of range for fts 2007-11-11 09:31:31 +00:00
agc 762d3dee18 Use the new virtual inode number, which is calculated at directory entry
insertion time, to prevent fts thinking that we have directory cycles.
2007-11-11 09:25:37 +00:00
agc 8abe1b3c75 Include a (random) inode number in the virtual directory information that
is held. Return this as part of the virtual entry information.

Prevents problems with fts code thinking that some directories create
a cycle.
2007-11-11 09:23:29 +00:00
agc 43385f0ea1 Initial import of a working iSCSI initiator, which uses reFUSE and
libpuffs.

With a round of applause to Antti Kantee for helping out with puffs
debugging, and a huge thank you to Greg Oster, who has fixed numerous
bugs over the last week (unfortunately, the bugs are all mine), and
provided enthusiasm and drive.

Right now, the initiator is fulling working for only a single target,
and should be considered to be in a state of flux.  Having said that,
Greg completed a run of build.sh with the storage on the iSCSI target,
and found times to be within 0.5% of direct attached storage.  Cache
effects apply.

The initiator should be portable to everything that uses the FUSE
interface. That's right - a portable iSCSI initiator.

Storage (LUNs exported by the target) is, at the present time,
presented as a regular file called "storage". This will likely
change in the future.

% priv obj/iscsifs -u agc inspiron1300 /mnt &
[1] 13158
inspiron1300.wherever.co.uk: 10.4.0.42:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target0
inspiron1300.wherever.co.uk: 10.4.0.42:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target1

% ls -al /mnt/inspiron1300.wherever.co.uk/target0/
total 576
drwxr-xr-x  2 agc  agc        512 Nov  8 21:07 .
drwxr-xr-x  2 agc  agc        512 Nov  8 21:07 ..
lrw-r--r--  1 agc  agc         44 Nov  8 21:07 hostname -> inspiron1300.wherever.co.uk
lrw-r--r--  1 agc  agc          9 Nov  8 21:07 ip -> 10.4.0.42
lrw-r--r--  1 agc  agc         16 Nov  8 21:07 product -> NetBSD iSCSI
-rw-r--r--  1 agc  agc  104857088 Nov  8 21:07 storage
lrw-r--r--  1 agc  agc         43 Nov  8 21:07 targetname -> iqn.1994-04.org.netbsd.iscsi-target:target0
lrw-r--r--  1 agc  agc          8 Nov  8 21:07 vendor -> NetBSD
lrw-r--r--  1 agc  agc          4 Nov  8 21:07 version -> 0

FFS needs a block device, and so vnconfig can be used to sit on top of
the regular file.

% mount -vv | grep iscsifs
/dev/puffs on /mnt type puffs|refuse:iscsifs (nosuid, nodev, fsid: 0xcb04/0x6acb, reads: sync 0 async 0, writes: sync 0 async 0)
% priv vnconfig vnd0 /mnt/inspiron1300.wherever.co.uk/target0/storage
% priv mount /dev/vnd0a /iscsi
% df
Filesystem   1K-blocks       Used      Avail %Cap Mounted on
/dev/dk0      28101396   21491182    5205146  80% /
kernfs               1          1          0 100% /kern
procfs               4          4          0 100% /proc
ptyfs                1          1          0 100% /dev/pts
/dev/puffs           0          0          0 100% /mnt
/dev/vnd0a       99214       8209      86045   8% /iscsi
% mount -vv | grep iscsi
/dev/puffs on /mnt type puffs|refuse:iscsifs (nosuid, nodev, fsid: 0xcb04/0x6acb, reads: sync 0 async 0, writes: sync 0 async 0)
/dev/vnd0a on /iscsi type ffs (local, fsid: 0xe00/0x78b, reads: sync 1 async 0, writes: sync 2 async 0)
2007-11-08 23:12:03 +00:00
wiz 68b83c64db Fix xref, sort SEE ALSO. Add RCS Id. 2007-09-11 23:26:13 +00:00
agc bb80e7775d Generalise the tests for OBJDIR and non-OBJDIR builds 2007-09-11 23:23:51 +00:00
agc 696c18a993 Generalise the tests for objdir builds, as well as none 2007-09-11 23:23:08 +00:00
agc a577a06f30 Modify the NetBSD emulation of the FreeBSD __DECONST macro to include
the cast as well. From Dag-Erling Co\xEFdan Sm\xF8rgrav.
2007-08-29 22:28:23 +00:00
agc 0920b4f20b Add a new refuse-based file system called ian - the Internet Access Node.
This utility uses FreeBSD's libfetch (updated for NetBSD, and to quieten
lint) to provide a BSD-licensed ftp/http/https file system similar to the
old alex utility. The full URL is used as the path underneath the "/ian"
mountpoint.

Sample use as follows:

	[19:09:38] agc@inspiron1300 ...examples/refuse/ian 126 > priv ian/obj/ian /ian
	[19:09:55] agc@inspiron1300 ...examples/refuse/ian 127 > cat /ian/ftp://localhost/motd
	NetBSD 4.99.27 (INSPIRON) #4: Tue Aug 7 13:04:33 BST 2007

	Welcome to NetBSD!

	This system is running a development snapshot of the NetBSD operating system,
	also known as NetBSD-current.  It is highly possible for it to contain serious
	bugs, regressions, broken features or other problems.  Please bear this in mind
	and use the system with care.

	You are encouraged to test this version as thoroughly as possible.  Should you
	encounter any problem, please report it back to the development team using the
	send-pr(1) utility (requires a working MTA).  If yours is not properly set up,
	use the web interface at: http://www.netbsd.org/support/send-pr.html

	Thank you for helping us test and improve NetBSD.

	[19:10:17] agc@inspiron1300 ...examples/refuse/ian 128 > df
	Filesystem   1K-blocks       Used      Avail %Cap Mounted on
	/dev/dk0      28101396   19491972    7204356  73% /
	kernfs               1          1          0 100% /kern
	procfs               4          4          0 100% /proc
	ptyfs                1          1          0 100% /dev/pts
	/dev/puffs           0          0          0 100% /ian
	[19:10:21] agc@inspiron1300 ...examples/refuse/ian 129 > ls -al /ian/ftp://localhost/motd
	-rw-------  1 root  wheel  705 Aug 28 19:10 /ian/ftp://localhost/motd
	[19:10:42] agc@inspiron1300 ...examples/refuse/ian 130 > ls -al ~ftp/motd
	-rw-r--r--  1 ftp  ftp  705 Aug 27 21:33 /home/ftp/motd
	[19:10:53] agc@inspiron1300 ...examples/refuse/ian 131 >
2007-08-28 19:45:02 +00:00
agc 5a236e395c Makefile for new ian file system 2007-08-28 19:39:30 +00:00
agc b143e0b001 If we're writing to a file, make sure the version we're writing is in
the topmost directory (the writable one).  If it's not there, copy the
file to there.
2007-08-20 21:55:44 +00:00
agc a08d769680 Initial import of icfs, a case-insensitive/retentive file system.
This file system is based on librefuse and puffs.

	The icfs(8) utility can be used to mount an existing directory on a
	new mount point.  icfs makes use of the virtdir(3) virtual directory
	routines.  Underneath those virtual directories, the individual
	directory entries will be displayed as an exact mirror of the original
	directory, except that any capital letters in the original entry's
	name will be substituted with an entry name consisting entirely of
	lower-case letters.

This is an unusual example of a refuse-based file system which provides
lesser functionality than the file system it sits on.
2007-06-21 22:05:28 +00:00
agc 5599c23a3d Record the root directory at initialisation time.
Add a function to "normalise" a path to condense multiple repeated '/'
characters into one.
2007-06-21 21:59:32 +00:00
agc d49e2683be Another day, another file system.
dmesgfs is another example file system, which displays the device tree
information gained from dmesg(8) as a directory hierarchy. The information
can be displayed in files, or as targets of symbolic links.

% l /mnt/mainbus0
total 320
drwxr-xr-x  2 agc   agc    512 May 21 22:21 .
drwxr-xr-x  2 root  wheel    0 Jan  1  1970 ..
drwxr-xr-x  2 agc   agc    512 May 21 22:21 acpi0
lrwxr-xr-x  1 agc   agc     41 May 21 22:21 cpu0 -> cpu0 at mainbus0 apid 0: (boot processor)
lrwxr-xr-x  1 agc   agc     40 May 21 22:21 ioapic -> ioapic at mainbus0 apid 1 not configured
drwxr-xr-x  2 agc   agc    512 May 21 22:21 pci0
% l /mnt/mainbus0/pci0/piixide0/atabus1/atapibus0
total 256
drwxr-xr-x  2 agc  agc  512 May 21 22:21 .
drwxr-xr-x  2 agc  agc  512 May 21 22:21 ..
lrwxr-xr-x  1 agc  agc   31 May 21 22:21 Description -> atapibus0 at atabus1: 2 targets
lrwxr-xr-x  1 agc  agc  104 May 21 22:21 cd0 -> cd0 at atapibus0 drive 0: <VMware Virtual IDE CDROM Drive, 1000000000000000000, 0000000> cdrom removable
%
2007-05-21 21:29:23 +00:00
agc cfb41894f8 Adapt to new signature for virtdir_add(). 2007-05-21 21:19:25 +00:00
agc 12eda41239 Add a size parameter to virtdir_add, so that binary information can be
attached to a virtual directory entry.
2007-05-21 21:15:34 +00:00
agc c048d63924 Add a function to return the virtual offset in the virtdir_t tree. 2007-05-19 06:15:38 +00:00
agc cd3ccd9b12 Add a new, trivial file system, pcifs, which shows the devices on a
pcibus (via pcictl(8)) under the mount point:

% df /mnt
Filesystem         1K-blocks      Used     Avail Capacity  Mounted on
puffs:refuse:pcifs         0         0         0   100%    /mnt
% l /mnt
total 642
drwxr-xr-x   2 root  wheel     0 Jan  1  1970 .
drwxr-xr-x  31 root  wheel  1024 May 16 20:06 ..
lrw-r--r--   1 agc   agc      65 May 16 22:05 000:00:0: -> Intel 82443BX Host Bridge/Controller (host bridge, revision 0x01)
lrw-r--r--   1 agc   agc      55 May 16 22:05 000:01:0: -> Intel 82443BX AGP Interface (PCI bridge, revision 0x01)
lrw-r--r--   1 agc   agc      64 May 16 22:05 000:07:0: -> Intel 82371AB (PIIX4) PCI-ISA Bridge (ISA bridge, revision 0x08)
lrw-r--r--   1 agc   agc      86 May 16 22:05 000:07:1: -> Intel 82371AB (PIIX4) IDE controller (IDE mass storage, interface 0x8a, revision 0x01)
lrw-r--r--   1 agc   agc      58 May 16 22:05 000:07:2: -> Intel 82371AB (PIIX4) USB Host Controller (USB serial bus)
lrw-r--r--   1 agc   agc      87 May 16 22:05 000:07:3: -> Intel 82371AB (PIIX4) Power Management Controller (miscellaneous bridge, revision 0x08)
lrw-r--r--   1 agc   agc      36 May 16 22:05 000:15:0: -> VMware Virtual SVGA II (VGA display)
lrw-r--r--   1 agc   agc      56 May 16 22:05 000:16:0: -> Symbios Logic 53c1030 (SCSI mass storage, revision 0x01)
lrw-r--r--   1 agc   agc      75 May 16 22:05 000:17:0: -> Advanced Micro Devices PCnet-PCI Ethernet (ethernet network, revision 0x10)
lrw-r--r--   1 agc   agc      53 May 16 22:05 000:18:0: -> Ensoniq AudioPCI 97 (audio multimedia, revision 0x02)
%

pcifs uses the virtdir routines, librefuse and puffs.
2007-05-16 21:44:30 +00:00
agc af7508ae15 Take advantage of the new functionality in virtdir_add() to create
intermediate directories automatically.
2007-04-18 20:33:59 +00:00
agc 9448d95472 When adding virtual directory entries, check the path to see that
intermediate directories have already been created. If not, then
create the intermediate directories. This means that callers don't
need to create the intermediate directories themselves.

When reading a virtual directory, don't return a zero-length
virtual directory entry.
2007-04-18 20:32:16 +00:00
agc 41c7d6fedc Don't allow duplicate directory entries to be created.
Correct a comment.
2007-04-17 22:51:53 +00:00
agc aac1680082 Add id3fs, a virtual file system, based on librefuse, for accessing
mp3-based files according to artist, genre or year.

Three virtual directories are made available under the mount point -

	artists/
	genre/
	year/

and then virtual directory entries (see virtdir(3)) are created under
these heading directories.

The pkgsrc/audio/id3 package is needed for this file system to function
properly.

Two shell scripts, id3info.sh and id3db.sh, are included to build up
the music database for id3fs to use to build up its virtual
directories.
2007-04-15 15:22:44 +00:00
agc 777436c8cf Add routines to manipulate virtual directory entries, for use with
librefuse-based file systems.

These are especially useful for file systems which present virtual
directory hierarchies to the caller.

The routines build up and manage an array of virtual directory
entries, indexed upon full pathname within the file system.  This is
analogous to the way refuse indexes its own entries.  Routines are
available to add, delete, and find entries.  Each entry can be one of
3 types - file ('f'), directory ('d') or symbolic link ('l').  Each
entry can also be associated with a target, which is a character
string allocated upon addition.  This can be useful for virtual
directory entries of the symbolic link type.

The virtual directory entries can be traversed as an ordered list
(the entries are ordered alphabetically), or can be accessed by
directory component, using routines analogous to opendir(3), readdir(3),
and closedir(3).
2007-04-15 15:10:56 +00:00
agc f44794b224 Add a refuse-based "fanout" file system. This is more commonly known in
the BSD world as a "union" file system.

This fanout file system takes a number of directories and makes them
available under a single mount point.

This is more of an example file sytsem than anything else, but is used
as the basis of a number of other file systems which will be forthcoming
"real soon now".
2007-03-31 21:05:56 +00:00
agc 7f4005e3b0 Add dbfs, an example (re)fuse file system which mounts a Berkeley
database as a file system.

The file was created in the first place with the following commands:

	cp /etc/passwd infile
	db -E B -w -f infile -F: -C btree bdb.db

and mounted as follows:

	./dbfs bdb.db /mnt

Example use is as follows, using a btree-based database with login
names as the key, and the rest of the passwd file entry as the value:

[21:17:20] agc@inspiron1300 ~ 142 > df -i /mnt
Filesystem        1K-blocks      Used     Avail Capacity  iused    ifree  %iused  Mounted on
puffs:refuse:dbfs        32        32         0   100%        1        0   100%   /mnt
[21:17:25] agc@inspiron1300 ~ 143 > l /mnt
total 2
drwxr-xr-x   2 root  wheel     0 Jan  1  1970 .
drwxr-xr-x  29 root  wheel  1024 Jan 31 21:14 ..
-r--r--r--   1 agc   agc      55 Feb 23 14:49 _pflogd
-r--r--r--   1 agc   agc      50 Feb 23 14:49 _proxy
-r--r--r--   1 agc   agc      46 Feb 23 14:49 _rwhod
-r--r--r--   1 agc   agc      49 Feb 23 14:49 _timedc
-r--r--r--   1 agc   agc      33 Feb 23 14:49 agc
-r--r--r--   1 agc   agc      51 Feb 23 14:49 bin
-r--r--r--   1 agc   agc      40 Feb 23 14:49 daemon
-r--r--r--   1 agc   agc      46 Feb 23 14:49 games
-r--r--r--   1 agc   agc      54 Feb 23 14:49 named
-r--r--r--   1 agc   agc      56 Feb 23 14:49 nobody
-r--r--r--   1 agc   agc      53 Feb 23 14:49 ntpd
-r--r--r--   1 agc   agc      49 Feb 23 14:49 operator
-r--r--r--   1 agc   agc      55 Feb 23 14:49 postfix
-r--r--r--   1 agc   agc      32 Feb 23 14:49 root
-r--r--r--   1 agc   agc      53 Feb 23 14:49 sshd
-r--r--r--   1 agc   agc      43 Feb 23 14:49 toor
-r--r--r--   1 agc   agc      52 Feb 23 14:49 uucp
[21:17:32] agc@inspiron1300 ~ 144 > grep nologin /mnt/*
/mnt/_pflogd:*:18:18:& pseudo-user:/var/chroot/pflogd:/sbin/nologin
/mnt/_proxy:*:21:21:Proxy Services:/nonexistent:/sbin/nologin
/mnt/_rwhod:*:19:19:& pseudo-user:/var/rwho:/sbin/nologin
/mnt/_timedc:*:22:22:& pseudo-user:/nonexistent:/sbin/nologin
/mnt/bin:*:3:7:Binaries Commands and Source:/:/sbin/nologin
/mnt/daemon:*:1:1:The devil himself:/:/sbin/nologin
/mnt/games:*:7:13:& pseudo-user:/usr/games:/sbin/nologin
/mnt/named:*:14:14:& pseudo-user:/var/chroot/named:/sbin/nologin
/mnt/nobody:*:32767:39:Unprivileged user:/nonexistent:/sbin/nologin
/mnt/ntpd:*:15:15:& pseudo-user:/var/chroot/ntpd:/sbin/nologin
/mnt/operator:*:2:5:System &:/usr/guest/operator:/sbin/nologin
/mnt/postfix:*:12:12:& pseudo-user:/var/spool/postfix:/sbin/nologin
/mnt/sshd:*:16:16:& pseudo-user:/var/chroot/sshd:/sbin/nologin
/mnt/uucp:*:66:1:UNIX-to-UNIX Copy:/nonexistent:/sbin/nologin
[21:17:37] agc@inspiron1300 ~ 145 >
2007-02-23 21:26:44 +00:00