[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:43:21 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit fcf4e53f577a47b4666052ad024f83eb984a658a
Author: Hannes Reinecke <hare at suse.de>
Date:   Tue Jun 21 11:23:03 2011 +0200

    iscsid: Implement --no-pid-file
    
    For root on iSCSI scenarios the /var directory might not exist.
    And we don't need the pid file anyway as the daemon is synchronized
    via the IPC connection.
    
    Signed-off-by: Hannes Reinecke <hare at suse.de>

diff --git a/doc/iscsid.8 b/doc/iscsid.8
index 1dfa1e5..92b7f81 100644
--- a/doc/iscsid.8
+++ b/doc/iscsid.8
@@ -35,6 +35,9 @@ run under user ID \fIuid\fR (default is the current user ID)
 .BI [-g|--gid=]\fIgid\fP
 run under user group ID \fIgid\fR (default is the current user group ID).
 .TP
+.BI [-n|--no-pid-file]\fP
+do not write a process ID file.
+.TP
 .BI [-p|--pid=]\fIpid\-file\fP
 write process ID to \fIpid\-file\fR rather than the default
 \fI/var/run/iscsid.pid\fR
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 3fa3295..1a37347 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -69,6 +69,7 @@ static struct option const long_options[] = {
 	{"debug", required_argument, NULL, 'd'},
 	{"uid", required_argument, NULL, 'u'},
 	{"gid", required_argument, NULL, 'g'},
+	{"no-pid-file", no_argument, NULL, 'n'},
 	{"pid", required_argument, NULL, 'p'},
 	{"help", no_argument, NULL, 'h'},
 	{"version", no_argument, NULL, 'v'},
@@ -90,6 +91,7 @@ Open-iSCSI initiator daemon.\n\
   -d, --debug debuglevel  print debugging information\n\
   -u, --uid=uid           run as uid, default is current user\n\
   -g, --gid=gid           run as gid, default is current user group\n\
+  -n, --no-pid-file       do not use a pid file\n\
   -p, --pid=pidfile       use pid file (default " PID_FILE ").\n\
   -h, --help              display this help and exit\n\
   -v, --version           display version and exit\n\
@@ -339,7 +341,7 @@ int main(int argc, char *argv[])
 	int control_fd;
 	pid_t pid;
 
-	while ((ch = getopt_long(argc, argv, "c:i:fd:u:g:p:vh", long_options,
+	while ((ch = getopt_long(argc, argv, "c:i:fd:nu:g:p:vh", long_options,
 				 &longindex)) >= 0) {
 		switch (ch) {
 		case 'c':
@@ -360,6 +362,9 @@ int main(int argc, char *argv[])
 		case 'g':
 			gid = strtoul(optarg, NULL, 10);
 			break;
+		case 'n':
+			pid_file = NULL;
+			break;
 		case 'p':
 			pid_file = optarg;
 			break;
@@ -415,13 +420,15 @@ int main(int argc, char *argv[])
 
 	if (daemonize) {
 		char buf[64];
-		int fd;
-
-		fd = open(pid_file, O_WRONLY|O_CREAT, 0644);
-		if (fd < 0) {
-			log_error("Unable to create pid file");
-			log_close(log_pid);
-			exit(ISCSI_ERR);
+		int fd = -1;
+
+		if (pid_file) {
+			fd = open(pid_file, O_WRONLY|O_CREAT, 0644);
+			if (fd < 0) {
+				log_error("Unable to create pid file");
+				log_close(log_pid);
+				exit(ISCSI_ERR);
+			}
 		}
 		pid = fork();
 		if (pid < 0) {
@@ -439,15 +446,16 @@ int main(int argc, char *argv[])
 		}
 
 		chdir("/");
-		if (lockf(fd, F_TLOCK, 0) < 0) {
-			log_error("Unable to lock pid file");
-			log_close(log_pid);
-			exit(ISCSI_ERR);
+		if (fd > 0) {
+			if (lockf(fd, F_TLOCK, 0) < 0) {
+				log_error("Unable to lock pid file");
+				log_close(log_pid);
+				exit(ISCSI_ERR);
+			}
+			ftruncate(fd, 0);
+			sprintf(buf, "%d\n", getpid());
+			write(fd, buf, strlen(buf));
 		}
-		ftruncate(fd, 0);
-		sprintf(buf, "%d\n", getpid());
-		write(fd, buf, strlen(buf));
-
 		daemon_init();
 	} else {
 		if ((control_fd = ipc->ctldev_open()) < 0) {

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list