Minor change: turn an error log message into a debug log message

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Add a target_find() helper to retrieve a target by its name

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Print the iSNS attribute value to the debug output if it is ignored

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Add interval timer functions based on timerfd

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Refresh the iSNS registration to prevent its expiration

Section 6.2.6 of the iSNS RFC says as follow:

  http://tools.ietf.org/html/rfc4171#section-6.2.6

  "The registration SHALL be removed from the iSNS database if an iSNS
   Protocol message is not received from the iSNS client before the
   registration period has expired. [...] To prevent a registration
   from expiring, the iSNS client should send an iSNS Protocol message
   to the iSNS server at intervals shorter than the registration
   period."

When registering a target, target-isns now specifies a registration
period to the iSNS server. A timer is used to refresh the registration
before it expires. The registration period is set to 5 minutes.

This patch fixes issue #4.

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Upgrade version to 0.2

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Fix bogus ARRAY_SIZE() macro

I imported the ARRAY_SIZE() macro from CCAN but I changed it a little
bit. Alas, my little changes were plain wrong because ARRAY_SIZE()
returned SIZE + 1 :/

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Use the registration period sent by the server

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
documentation: describe the iSNS registration period

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Fix erroneous handling of iSNS socket descriptors

In the code, the value 0 is used to reset the socket file descriptors
and has the semantic of "no file descriptor". However, since 0 is a
valid file descriptor, this usage causes some subtle bug like issue #8
where syslog messages are written to the iSNS socket.

This patch updates the code to use -1 to mean "no file descriptor".

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Cosmetic change: improve some log messages

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Clarify the entity protocol used for iSCSI

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Remove unused timeout from isns_handle()

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Handle SIGTERM like SIGINT and SIGQUIT

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Fix endianness of the iSNSP response status code

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Declare some configfs functions as static

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Add a SIGUSR1 handler for debugging purposes

Sending the SIGUSR1 signal to target-isns now invokes configfs_show()
to print the configfs hierarchy seen by target-isns in the logs.

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Fix target portal group not being created

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
In TPG, rename 'id' to 'tag' and add tpg_find_by_tag()

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
Add some logs around inotify

Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>