From 7a6a2e8526a4b3928779c64457ebd04d8cc7ce08108b625deff7d31ebfdc46e6 Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Mon, 3 Feb 2014 16:17:17 +0000
Subject: [PATCH 1/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=209
---
 agetty-on-s390-on-dev--3270-tty1-line.patch | 33 +++++++++++++++++++++
 util-linux.changes                          |  6 ++++
 util-linux.spec                             |  3 ++
 3 files changed, 42 insertions(+)
 create mode 100644 agetty-on-s390-on-dev--3270-tty1-line.patch

diff --git a/agetty-on-s390-on-dev--3270-tty1-line.patch b/agetty-on-s390-on-dev--3270-tty1-line.patch
new file mode 100644
index 0000000..ac8c4d1
--- /dev/null
+++ b/agetty-on-s390-on-dev--3270-tty1-line.patch
@@ -0,0 +1,33 @@
+--- term-utils/agetty.c
++++ term-utils/agetty.c	2014-02-03 16:08:55.446235045 +0000
+@@ -571,6 +571,7 @@ static void login_options_to_argv(char *
+ /* Parse command-line arguments. */
+ static void parse_args(int argc, char **argv, struct options *op)
+ {
++	char *ptr;
+ 	int c;
+ 
+ 	enum {
+@@ -745,8 +746,13 @@ static void parse_args(int argc, char **
+ 		usage(stderr);
+ 	}
+ 
++	c = asprintf(ptr, "/dev/%s", argv[optind]);
++	if (c < 0)
++		log_err(_("failed to allocate memory: %m"));
++
+ 	/* Accept "tty", "baudrate tty", and "tty baudrate". */
+-	if ('0' <= argv[optind][0] && argv[optind][0] <= '9') {
++	if (access(ptr, F_OK) < 0) {
++		errno = 0;
+ 		/* Assume BSD style speed. */
+ 		parse_speeds(op, argv[optind++]);
+ 		if (argc < optind + 1) {
+@@ -764,6 +770,7 @@ static void parse_args(int argc, char **
+ 				op->speeds[op->numspeed++] = bcode("9600");
+ 		}
+ 	}
++	free(ptr);
+ 
+ 	/* On virtual console remember the line which is used for */
+ 	if (strncmp(op->tty, "tty", 3) == 0 &&
diff --git a/util-linux.changes b/util-linux.changes
index 6fbdb18..94dec8f 100644
--- a/util-linux.changes
+++ b/util-linux.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Mon Feb  3 16:16:36 UTC 2014 - werner@suse.de
+
+- Add patch agetty-on-s390-on-dev--3270-tty1-line.patch
+  to let agetty detect /dev/3270/tty1 as device not as baud rate 
+
 -------------------------------------------------------------------
 Tue Jan 28 09:37:57 UTC 2014 - speilicke@suse.com
 
diff --git a/util-linux.spec b/util-linux.spec
index 1656e70..24dd8ef 100644
--- a/util-linux.spec
+++ b/util-linux.spec
@@ -110,6 +110,8 @@ Patch13:        blkdiscard-BLKSSZGET-fills-in-an-int.patch
 Patch14:        tty3270-on-serial-line-of-s390.patch
 # PATCH-FIX-SUSE -- Let agetty not be fooled by locked termios srtucture
 Patch15:        agetty-fooled-on-serial-line-due-plymouth.patch
+# PATCH-FIX-SUSE -- Let agetty detect /dev/3270/tty1 as device not as baud rate
+Patch16:        agetty-on-s390-on-dev--3270-tty1-line.patch
 
 # hack for boot.localfs
 Patch20:        util-linux-HACK-boot.localfs.diff
@@ -229,6 +231,7 @@ xzcat %{S:0} | %gpg_verify %{S:12} -
 %patch13 -p1
 %patch14 -p0
 %patch15 -p0
+%patch16 -p0
 #
 %patch20 -p1
 #

From 3a4700cd3386413f4a238b22b1830dab18bed0467d3b5ce091a1bb90e1088e3f Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 08:50:39 +0000
Subject: [PATCH 2/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=210
---
 agetty-on-s390-on-dev--3270-tty1-line.patch | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/agetty-on-s390-on-dev--3270-tty1-line.patch b/agetty-on-s390-on-dev--3270-tty1-line.patch
index ac8c4d1..b8ac68a 100644
--- a/agetty-on-s390-on-dev--3270-tty1-line.patch
+++ b/agetty-on-s390-on-dev--3270-tty1-line.patch
@@ -1,5 +1,5 @@
 --- term-utils/agetty.c
-+++ term-utils/agetty.c	2014-02-03 16:08:55.446235045 +0000
++++ term-utils/agetty.c	2014-02-04 08:50:09.798235374 +0000
 @@ -571,6 +571,7 @@ static void login_options_to_argv(char *
  /* Parse command-line arguments. */
  static void parse_args(int argc, char **argv, struct options *op)
@@ -8,26 +8,21 @@
  	int c;
  
  	enum {
-@@ -745,8 +746,13 @@ static void parse_args(int argc, char **
+@@ -745,8 +746,16 @@ static void parse_args(int argc, char **
  		usage(stderr);
  	}
  
-+	c = asprintf(ptr, "/dev/%s", argv[optind]);
++	c = asprintf(&ptr, "/dev/%s", argv[optind]);
 +	if (c < 0)
 +		log_err(_("failed to allocate memory: %m"));
++
++	c = access(ptr, F_OK);
++	free(ptr);
++	errno = 0;
 +
  	/* Accept "tty", "baudrate tty", and "tty baudrate". */
 -	if ('0' <= argv[optind][0] && argv[optind][0] <= '9') {
-+	if (access(ptr, F_OK) < 0) {
-+		errno = 0;
++	if (c < 0) {
  		/* Assume BSD style speed. */
  		parse_speeds(op, argv[optind++]);
  		if (argc < optind + 1) {
-@@ -764,6 +770,7 @@ static void parse_args(int argc, char **
- 				op->speeds[op->numspeed++] = bcode("9600");
- 		}
- 	}
-+	free(ptr);
- 
- 	/* On virtual console remember the line which is used for */
- 	if (strncmp(op->tty, "tty", 3) == 0 &&

From 15566fa280747929b10ecc7cbffc1f522653b112b6aaee4e8a5ff4f3c30cbcc6 Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 08:51:23 +0000
Subject: [PATCH 3/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=211
---
 ...ty1-line.patch => agetty-on-s390-on-dev-3270-tty1-line.patch | 0
 util-linux.spec                                                 | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename agetty-on-s390-on-dev--3270-tty1-line.patch => agetty-on-s390-on-dev-3270-tty1-line.patch (100%)

diff --git a/agetty-on-s390-on-dev--3270-tty1-line.patch b/agetty-on-s390-on-dev-3270-tty1-line.patch
similarity index 100%
rename from agetty-on-s390-on-dev--3270-tty1-line.patch
rename to agetty-on-s390-on-dev-3270-tty1-line.patch
diff --git a/util-linux.spec b/util-linux.spec
index 24dd8ef..49b18cb 100644
--- a/util-linux.spec
+++ b/util-linux.spec
@@ -111,7 +111,7 @@ Patch14:        tty3270-on-serial-line-of-s390.patch
 # PATCH-FIX-SUSE -- Let agetty not be fooled by locked termios srtucture
 Patch15:        agetty-fooled-on-serial-line-due-plymouth.patch
 # PATCH-FIX-SUSE -- Let agetty detect /dev/3270/tty1 as device not as baud rate
-Patch16:        agetty-on-s390-on-dev--3270-tty1-line.patch
+Patch16:        agetty-on-s390-on-dev-3270-tty1-line.patch
 
 # hack for boot.localfs
 Patch20:        util-linux-HACK-boot.localfs.diff

From 5a4575811148f62c876aaf03f40315eca2271125b9be14da7e5f8f93931cc5ef Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 09:29:53 +0000
Subject: [PATCH 4/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=212
---
 agetty-on-s390-on-dev-3270-tty1-line.patch | 35 +++++++++++-----------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/agetty-on-s390-on-dev-3270-tty1-line.patch b/agetty-on-s390-on-dev-3270-tty1-line.patch
index b8ac68a..f40d71a 100644
--- a/agetty-on-s390-on-dev-3270-tty1-line.patch
+++ b/agetty-on-s390-on-dev-3270-tty1-line.patch
@@ -1,28 +1,29 @@
 --- term-utils/agetty.c
-+++ term-utils/agetty.c	2014-02-04 08:50:09.798235374 +0000
-@@ -571,6 +571,7 @@ static void login_options_to_argv(char *
++++ term-utils/agetty.c	2014-02-04 09:28:32.564461786 +0000
+@@ -568,6 +568,8 @@ static void login_options_to_argv(char *
+ 	*argc = i;
+ }
+ 
++#define is_speed(str) (strlen((str)) == strspn((str), "0123456789,"))
++
  /* Parse command-line arguments. */
  static void parse_args(int argc, char **argv, struct options *op)
  {
-+	char *ptr;
- 	int c;
- 
- 	enum {
-@@ -745,8 +746,16 @@ static void parse_args(int argc, char **
- 		usage(stderr);
+@@ -746,7 +748,7 @@ static void parse_args(int argc, char **
  	}
  
-+	c = asprintf(&ptr, "/dev/%s", argv[optind]);
-+	if (c < 0)
-+		log_err(_("failed to allocate memory: %m"));
-+
-+	c = access(ptr, F_OK);
-+	free(ptr);
-+	errno = 0;
-+
  	/* Accept "tty", "baudrate tty", and "tty baudrate". */
 -	if ('0' <= argv[optind][0] && argv[optind][0] <= '9') {
-+	if (c < 0) {
++	if (is_speed(argv[optind])) {
  		/* Assume BSD style speed. */
  		parse_speeds(op, argv[optind++]);
  		if (argc < optind + 1) {
+@@ -758,7 +760,7 @@ static void parse_args(int argc, char **
+ 		op->tty = argv[optind++];
+ 		if (argc > optind) {
+ 			char *v = argv[optind++];
+-			if ('0' <= *v && *v <= '9')
++			if (is_speed(*v))
+ 				parse_speeds(op, v);
+ 			else
+ 				op->speeds[op->numspeed++] = bcode("9600");

From 8576e20bea02230f99dd86ceb35d3eb9cafc0ff44cf4c3832ab507b9183b0921 Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 09:33:45 +0000
Subject: [PATCH 5/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=213
---
 agetty-on-s390-on-dev-3270-tty1-line.patch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/agetty-on-s390-on-dev-3270-tty1-line.patch b/agetty-on-s390-on-dev-3270-tty1-line.patch
index f40d71a..b6c2ca3 100644
--- a/agetty-on-s390-on-dev-3270-tty1-line.patch
+++ b/agetty-on-s390-on-dev-3270-tty1-line.patch
@@ -1,5 +1,5 @@
 --- term-utils/agetty.c
-+++ term-utils/agetty.c	2014-02-04 09:28:32.564461786 +0000
++++ term-utils/agetty.c	2014-02-04 09:33:13.162735763 +0000
 @@ -568,6 +568,8 @@ static void login_options_to_argv(char *
  	*argc = i;
  }
@@ -23,7 +23,7 @@
  		if (argc > optind) {
  			char *v = argv[optind++];
 -			if ('0' <= *v && *v <= '9')
-+			if (is_speed(*v))
++			if (is_speed(v))
  				parse_speeds(op, v);
  			else
  				op->speeds[op->numspeed++] = bcode("9600");

From a77ac4b42a0b91364168050b41cfb3525bdd62a3128d830215955c69bd0408ee Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 10:24:57 +0000
Subject: [PATCH 6/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=214
---
 agetty-on-s390-on-dev-3270-tty1-line.patch | 8 ++++++++
 tty3270-on-serial-line-of-s390.patch       | 2 +-
 util-linux.changes                         | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/agetty-on-s390-on-dev-3270-tty1-line.patch b/agetty-on-s390-on-dev-3270-tty1-line.patch
index b6c2ca3..98997df 100644
--- a/agetty-on-s390-on-dev-3270-tty1-line.patch
+++ b/agetty-on-s390-on-dev-3270-tty1-line.patch
@@ -1,3 +1,11 @@
+Be aware that on s390 the 3270 terminal line is found at
+/dev/3270/tty<X>.  That is that the baud speed rate numbers
+have to be identified in a unique way. 
+
+---
+ agetty.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
 --- term-utils/agetty.c
 +++ term-utils/agetty.c	2014-02-04 09:33:13.162735763 +0000
 @@ -568,6 +568,8 @@ static void login_options_to_argv(char *
diff --git a/tty3270-on-serial-line-of-s390.patch b/tty3270-on-serial-line-of-s390.patch
index 57ae1b2..2dafaa6 100644
--- a/tty3270-on-serial-line-of-s390.patch
+++ b/tty3270-on-serial-line-of-s390.patch
@@ -32,7 +32,7 @@ is compatible with VT220.
 +		 * higher.  Whereas the second serial line on a S/390(x) is
 +		 * a real character terminal which is compatible with VT220.
 +		 */
-+		if (strcmp(op->tty, "ttyS0") == 0)
++		if (strcmp(op->tty, "ttyS0") == 0 || strncmp(op->tty, "3270/tty", 8)
 +			op->term = DEFAULT_TTYS0;
 +		else if (strcmp(op->tty, "ttyS1") == 0)
 +			op->term = DEFAULT_TTYS1;
diff --git a/util-linux.changes b/util-linux.changes
index 94dec8f..18c7ea9 100644
--- a/util-linux.changes
+++ b/util-linux.changes
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Tue Feb  4 10:24:02 UTC 2014 - werner@suse.de
+
+- Modify patch agetty-on-s390-on-dev--3270-tty1-line.patch and
+  patch tty3270-on-serial-line-of-s390.patch to handle 3270
+  terminals 
+
 -------------------------------------------------------------------
 Mon Feb  3 16:16:36 UTC 2014 - werner@suse.de
 

From 9ce9fc0bcf7ee0ccb939d558cf1d6b8bfbe6ea1f0526073ab2889d273694d2d2 Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 11:03:13 +0000
Subject: [PATCH 7/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=215
---
 tty3270-on-serial-line-of-s390.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tty3270-on-serial-line-of-s390.patch b/tty3270-on-serial-line-of-s390.patch
index 2dafaa6..20877b1 100644
--- a/tty3270-on-serial-line-of-s390.patch
+++ b/tty3270-on-serial-line-of-s390.patch
@@ -32,7 +32,7 @@ is compatible with VT220.
 +		 * higher.  Whereas the second serial line on a S/390(x) is
 +		 * a real character terminal which is compatible with VT220.
 +		 */
-+		if (strcmp(op->tty, "ttyS0") == 0 || strncmp(op->tty, "3270/tty", 8)
++		if (strcmp(op->tty, "ttyS0") == 0 || strncmp(op->tty, "3270/tty", 8))
 +			op->term = DEFAULT_TTYS0;
 +		else if (strcmp(op->tty, "ttyS1") == 0)
 +			op->term = DEFAULT_TTYS1;

From 938e8217dd0058954ad270af6b80303f7c0415e6d61128c522d63dcdc62e8ad0 Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 11:17:06 +0000
Subject: [PATCH 8/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=216
---
 tty3270-on-serial-line-of-s390.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tty3270-on-serial-line-of-s390.patch b/tty3270-on-serial-line-of-s390.patch
index 20877b1..8e5b4d2 100644
--- a/tty3270-on-serial-line-of-s390.patch
+++ b/tty3270-on-serial-line-of-s390.patch
@@ -32,7 +32,7 @@ is compatible with VT220.
 +		 * higher.  Whereas the second serial line on a S/390(x) is
 +		 * a real character terminal which is compatible with VT220.
 +		 */
-+		if (strcmp(op->tty, "ttyS0") == 0 || strncmp(op->tty, "3270/tty", 8))
++		if (strcmp(op->tty, "ttyS0") == 0 || strncmp(op->tty, "3270/tty", 8) == 0)
 +			op->term = DEFAULT_TTYS0;
 +		else if (strcmp(op->tty, "ttyS1") == 0)
 +			op->term = DEFAULT_TTYS1;

From 447cc5648ca4ea68d7ee79ce717d27f2e0f353e799b5dec6da771c37639d6a66 Mon Sep 17 00:00:00 2001
From: "Dr. Werner Fink" <werner@suse.com>
Date: Tue, 4 Feb 2014 12:04:58 +0000
Subject: [PATCH 9/9] .

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=217
---
 util-linux.changes | 1 +
 util-linux.spec    | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/util-linux.changes b/util-linux.changes
index 18c7ea9..8517585 100644
--- a/util-linux.changes
+++ b/util-linux.changes
@@ -4,6 +4,7 @@ Tue Feb  4 10:24:02 UTC 2014 - werner@suse.de
 - Modify patch agetty-on-s390-on-dev--3270-tty1-line.patch and
   patch tty3270-on-serial-line-of-s390.patch to handle 3270
   terminals 
+- Really do not verify /usr/bin/eject
 
 -------------------------------------------------------------------
 Mon Feb  3 16:16:36 UTC 2014 - werner@suse.de
diff --git a/util-linux.spec b/util-linux.spec
index 49b18cb..07fef46 100644
--- a/util-linux.spec
+++ b/util-linux.spec
@@ -512,9 +512,6 @@ for PAM_FILE in default/su pam.d/su pam.d/su-l ; do
 	fi
 done
 %endif
-%if %{with enable_eject}
-%set_permissions %{_bindir}/eject
-%endif
 
 # mount option 'code=' is now called 'codepage=' so change fstab
 if [ -f etc/fstab ]; then