summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO62
-rw-r--r--0002-kernel-5.0.0-access_ok.patch124
-rw-r--r--0003-kernel-5.6-proc_dir_entry-proc_ops.patch46
-rw-r--r--0004-mxloadsvr.c-disable-built-in-systemd-support.patch26
-rw-r--r--0005-kernel-5.10-async-initialized.patch18
-rw-r--r--0006-kernel-5.12-tty-low_latency.patch67
-rw-r--r--0007-tty_unregister_driver-void.patch18
-rw-r--r--0008-kernel-5.13-dropped-tty_check_change.patch17
-rw-r--r--0009-kernel-5.14-task_struct.state-unsigned-tty.patch174
-rw-r--r--0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch43
-rw-r--r--0011-kernel-5.17-change-PDE_DATA.patch15
-rw-r--r--0012-kernel-serial_UART_XMIT_SIZE.patch67
-rw-r--r--0013-kernel-6.1-set_termios-const-ktermios.patch31
-rw-r--r--0013a-kernel-6.0-set_termios-const-ktermios.patch52
-rw-r--r--0014-kernel-6.6-struct-tty_operations-size_t.patch37
-rw-r--r--PKGBUILD158
-rw-r--r--npreal2-install.sh12
-rw-r--r--npreal2.sh9
18 files changed, 944 insertions, 32 deletions
diff --git a/.SRCINFO b/.SRCINFO
index ae50d044cf53..5897da16c425 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,10 +1,8 @@
-# Generated by mksrcinfo v8
-# Wed Jul 4 18:10:17 UTC 2018
pkgbase = npreal2
pkgdesc = real tty driver for Moxa NPort serial console terminal server
- pkgver = 1.19
- pkgrel = 1
- url = https://www.moxa.com/support/sarch_result.aspx?type=soft&prod_id=237&type_id=9
+ pkgver = 5.0
+ pkgrel = 10
+ url = https://www.moxa.com/en/products/industrial-edge-connectivity/serial-device-servers/terminal-servers/nport-6100-6200-series
install = npreal2-install.sh
arch = i686
arch = x86_64
@@ -19,12 +17,56 @@ pkgbase = npreal2
depends = dkms
depends = linux-headers
backup = etc/npreal2/npreal2d.cf
- source = https://www.moxa.com/drivers/IDC_SW/DeviceServer/Driver/NPort%20Real%20TTY%20Driver%20for%20Linux/Mainline/ver1.19/npreal2_mainline_v1.19_build_17110917.tgz
- source = npreal2.sh
+ source = https://www.moxa.com/Moxa/media/PDIM/S100000217/moxa-real-tty-drivers-for-linux-5.x.x-driver-v5.0.tgz
source = 0001-mxmknod-folder-fix-and-chgrp-uucp.patch
- sha256sums = f99f38ef5618469a1d6f4824e41856616ee65ab8359069daa70d8d481f364462
- sha256sums = 7241767fa8dead2dbe4cf4db32d39f5cf9d95b08f60daf79822ae306727af372
+ source = 0002-kernel-5.0.0-access_ok.patch
+ source = 0003-kernel-5.6-proc_dir_entry-proc_ops.patch
+ source = 0004-mxloadsvr.c-disable-built-in-systemd-support.patch
+ source = 0005-kernel-5.10-async-initialized.patch
+ source = 0006-kernel-5.12-tty-low_latency.patch
+ source = 0007-tty_unregister_driver-void.patch
+ source = 0008-kernel-5.13-dropped-tty_check_change.patch
+ source = 0009-kernel-5.14-task_struct.state-unsigned-tty.patch
+ source = 0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch
+ source = 0011-kernel-5.17-change-PDE_DATA.patch
+ source = 0012-kernel-serial_UART_XMIT_SIZE.patch
+ source = 0013-kernel-6.1-set_termios-const-ktermios.patch
+ source = 0013a-kernel-6.0-set_termios-const-ktermios.patch
+ source = 0014-kernel-6.6-struct-tty_operations-size_t.patch
+ source = npreal2.sh
+ md5sums = 4ba260f2e3b2b25419bd40a5f030d926
+ md5sums = 043dac91330a15c38e41bb2e2e1d5598
+ md5sums = 9cda38abdd17b2af80475ed06bdf0889
+ md5sums = bcd835765a6451989195a3518d53088d
+ md5sums = 0c53bb8e2df459fabbca10b567981a93
+ md5sums = 7aac842974d5dd76b9bc8fd9fd4de470
+ md5sums = d8a5ab4731575a4ffe90656e1793b46b
+ md5sums = e8c288232d6e2174c165e8f5e098a05d
+ md5sums = 647a4918f3dd6ead47886d6eb0fc70b0
+ md5sums = 16504fb58a0416a26fe04e8e3d9867a7
+ md5sums = d3716370fdd8b1ad888498fc82fca9f4
+ md5sums = 9f62a0a931436bda473259832d9ebc5b
+ md5sums = 93789057c6b3f66467ed936987ed003c
+ md5sums = 9303500d793cb4ebaa79b428607d403d
+ md5sums = 2d79f7913c70bad8ae9316360bc2d13a
+ md5sums = 619a190e17180f44435468314c9eb393
+ md5sums = 90ac27b669542c11b0a9b6763f6e0d9b
+ sha256sums = 33da5d4b1ff9853e9d58c7905f1fdf09a3e284658f42437210155c4c913f4dad
sha256sums = 7039ca0740be34a641424e3f57b896902f61fdfd2bfcc26e8e954035849e9605
+ sha256sums = 211f3b0ba50452bfe6d39076eb1a60a7557dd038288fb8dcd4374886f4c2844e
+ sha256sums = c3f8502c3e7e600ccc3e778ec25875ddda3a20ed3cb62bc56505e609ac346d79
+ sha256sums = e1856e4a410af0b112dd8beee58edd2516bb5cd7607d84b06bc25133b8bd8f15
+ sha256sums = 2e913895e2c382abc8fd610faddf6bbda6b59845fb3f95a1d33136995d27cb3f
+ sha256sums = 252ce8e55b835c22e6fdf4e3c661ef906be41fdf9dfc76900d787907892e6f21
+ sha256sums = d35d49ab325a17976d26d64661a235fc5c8f0e0ce6c7e86483607654e94d5b22
+ sha256sums = df64718aee9b460e0d4f92ec577f36d1f3c54c9bc801261c6db5a07020be8fec
+ sha256sums = 7c9380a794725418015d62411f697850096b3c8a62666f5ec9e562e93ba3ee4c
+ sha256sums = d61ca42d7fe58b409c1a1c7237788d412c36042acaa61e95008e48ec580b5153
+ sha256sums = 609388af991dd4095300dec76f85d5abceb68395fde5e157fa084fb4af8cad60
+ sha256sums = 6c6abf4902c235cc1d39bcf97005de1e10962c9b42263b5ffd57a9c856be8934
+ sha256sums = 4a02f4f4963ee10da37614e3cc6a205225b8a052db71240c397d32fe48365a2b
+ sha256sums = b9b73e078fef61fae0191c9b9bba8c20560559b777014911f4298ec0367b2fcf
+ sha256sums = d1b0b1e1d4a7b9a9c67e38aa14da568b240847cd1cd33256b21828e85ac816ff
+ sha256sums = 13e297691ba1b6504f66ef98e072194343321d2a47928c3964e315160b246153
pkgname = npreal2
-
diff --git a/0002-kernel-5.0.0-access_ok.patch b/0002-kernel-5.0.0-access_ok.patch
new file mode 100644
index 000000000000..c65bdc457d2e
--- /dev/null
+++ b/0002-kernel-5.0.0-access_ok.patch
@@ -0,0 +1,124 @@
+--- npreal2.c.orig 2017-11-10 02:25:03.000000000 -0500
++++ npreal2.c 2019-03-10 21:28:04.465949059 -0400
+@@ -1317,19 +1317,25 @@ static int npreal_ioctl(struct tty_struc
+ return(retval);
+ tty_wait_until_sent(tty, 0);
+ npreal_send_break(info, arg ? arg*(HZ/10) : HZ/4);
+ return(0);
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
++#define compat_access_ok(u,v,w) access_ok(v,w)
++#else
++#define compat_access_ok(u,v,w) access_ok(u,v,w)
++#endif
++
+ case TIOCGSOFTCAR:
+- error = access_ok(VERIFY_WRITE, (void *)arg, sizeof(long))?0:-EFAULT;
++ error = compat_access_ok(VERIFY_WRITE, (void *)arg, sizeof(long))?0:-EFAULT;
+ if ( error )
+ return(error);
+ put_to_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
+ return 0;
+
+ case TIOCSSOFTCAR:
+- error = access_ok(VERIFY_READ, (void *)arg, sizeof(long))?0:-EFAULT;
++ error = compat_access_ok(VERIFY_READ, (void *)arg, sizeof(long))?0:-EFAULT;
+ if ( error )
+ return(error);
+ get_from_user(templ,(unsigned long *)arg);
+ arg = templ;
+ #if (LINUX_VERSION_CODE < VERSION_CODE(3,7,0))
+@@ -1340,25 +1346,25 @@ static int npreal_ioctl(struct tty_struc
+ (arg ? CLOCAL : 0));
+ #endif
+ return(0);
+
+ case TIOCGSERIAL:
+- error = access_ok(VERIFY_WRITE, (void *)arg,
++ error = compat_access_ok(VERIFY_WRITE, (void *)arg,
+ sizeof(struct serial_struct))?0:-EFAULT;
+ if ( error )
+ return(error);
+ return(npreal_get_serial_info(info, (struct serial_struct *)arg));
+
+ case TIOCSSERIAL:
+- error = access_ok(VERIFY_READ, (void *)arg,
++ error = compat_access_ok(VERIFY_READ, (void *)arg,
+ sizeof(struct serial_struct))?0:-EFAULT;
+ if ( error )
+ return(error);
+ return(npreal_set_serial_info(info, (struct serial_struct *)arg));
+
+ case TIOCSERGETLSR: /* Get line status register */
+- error = access_ok(VERIFY_WRITE, (void *)arg,
++ error = compat_access_ok(VERIFY_WRITE, (void *)arg,
+ sizeof(unsigned int))?0:-EFAULT;
+ if ( error )
+ return(error);
+ else
+ return(npreal_get_lsr_info(info, (unsigned int *)arg));
+@@ -1411,11 +1417,11 @@ static int npreal_ioctl(struct tty_struc
+ * Return: write counters to the user passed counter struct
+ * NB: both 1->0 and 0->1 transitions are counted except for
+ * RI where only 0->1 is counted.
+ */
+ case TIOCGICOUNT:
+- error = access_ok(VERIFY_WRITE, (void *)arg,
++ error = compat_access_ok(VERIFY_WRITE, (void *)arg,
+ sizeof(struct serial_icounter_struct))?0:-EFAULT;
+ if ( error )
+ return(error);
+ cnow = info->icount;
+ p_cuser = (struct serial_icounter_struct *)arg;
+@@ -3369,11 +3375,11 @@ npreal_net_ioctl (
+ }
+ if (nd->flag & NPREAL_NET_DO_SESSION_RECOVERY)
+ len = nd->do_session_recovery_len;
+ else
+ len = (int)nd->cmd_buffer[2] + 3;
+- rtn = access_ok( VERIFY_WRITE, (void *)arg, len)?0:-EFAULT;
++ rtn = compat_access_ok( VERIFY_WRITE, (void *)arg, len)?0:-EFAULT;
+ if ( rtn )
+ {
+ goto done;
+ }
+ if (copy_to_user( (void *)arg, (void *)nd->cmd_buffer,len ))
+@@ -3393,11 +3399,11 @@ npreal_net_ioctl (
+ if (size < 2)
+ goto done;
+ if (size > 84)
+ size = 84;
+
+- rtn = access_ok( VERIFY_READ, (void *)arg, size )?0:-EFAULT;
++ rtn = compat_access_ok( VERIFY_READ, (void *)arg, size )?0:-EFAULT;
+ if ( rtn )
+ {
+ goto done;
+ }
+ if (copy_from_user( (void *)rsp_buffer, (void *)arg,size))
+@@ -3518,11 +3524,11 @@ npreal_net_ioctl (
+ int status;
+
+ if (size != sizeof (status))
+ goto done;
+
+- rtn = access_ok( VERIFY_READ, (void *)arg, size )?0:-EFAULT;
++ rtn = compat_access_ok( VERIFY_READ, (void *)arg, size )?0:-EFAULT;
+ if ( rtn )
+ {
+ goto done;
+ }
+ status = (nd->flag & NPREAL_NET_TTY_INUSED) ? 1 : 0;
+@@ -3543,11 +3549,11 @@ npreal_net_ioctl (
+ break;
+
+ if (size != sizeof (struct server_setting_struct))
+ goto done;
+
+- rtn = access_ok( VERIFY_READ, (void *)arg, size )?0:-EFAULT;
++ rtn = compat_access_ok( VERIFY_READ, (void *)arg, size )?0:-EFAULT;
+ if ( rtn )
+ {
+ goto done;
+ }
+ if (copy_from_user( (void *)&settings, (void *)arg,size))
diff --git a/0003-kernel-5.6-proc_dir_entry-proc_ops.patch b/0003-kernel-5.6-proc_dir_entry-proc_ops.patch
new file mode 100644
index 000000000000..bdc1e66ad5f4
--- /dev/null
+++ b/0003-kernel-5.6-proc_dir_entry-proc_ops.patch
@@ -0,0 +1,46 @@
+--- npreal2.c.orig 2020-05-21 00:42:40.690229660 -0400
++++ npreal2.c 2020-05-21 00:40:48.857014581 -0400
+@@ -366,11 +366,15 @@ static struct proc_dir_entry * npvar_pr
+ * memory if large numbers of serial ports are open.
+ */
+ static unsigned char * npvar_tmp_buf;
+ static struct semaphore npvar_tmp_buf_sem;
+
++#if LINUX_VERSION_CODE >= VERSION_CODE(5,6,0)
++static struct proc_ops npreal_net_fops;
++#else
+ static struct file_operations npreal_net_fops;
++#endif
+
+ #ifdef MODULE
+ int init_module(void);
+ void cleanup_module(void);
+ #endif
+@@ -668,17 +672,26 @@ npreal_init(void)
+ put_tty_driver(DRV_VAR);
+ return -1;
+ }
+
+ /* Initialize the net node structure */
+- memset(&npreal_net_fops,0,sizeof(struct file_operations));
++ memset(&npreal_net_fops,0,sizeof(npreal_net_fops));
++#if LINUX_VERSION_CODE >= VERSION_CODE(5,6,0)
++ npreal_net_fops.proc_read = npreal_net_read;
++ npreal_net_fops.proc_write = npreal_net_write;
++ npreal_net_fops.proc_ioctl = npreal_net_ioctl;
++ npreal_net_fops.proc_open = npreal_net_open;
++ npreal_net_fops.proc_release = npreal_net_close;
++ npreal_net_fops.proc_poll = npreal_net_select;
++#else
+ npreal_net_fops.read = npreal_net_read;
+ npreal_net_fops.write = npreal_net_write;
+ npreal_net_fops.unlocked_ioctl = npreal_net_ioctl;
+ npreal_net_fops.open = npreal_net_open;
+ npreal_net_fops.release = npreal_net_close;
+ npreal_net_fops.poll = npreal_net_select;
++#endif
+ if (npreal_init_tty() != 0)
+ {
+ tty_unregister_driver(DRV_VAR);
+ DBGPRINT(MX_DEBUG_ERROR, "Couldn't install MOXA Async/NPort server family Real TTY driver !\n");
+ }
diff --git a/0004-mxloadsvr.c-disable-built-in-systemd-support.patch b/0004-mxloadsvr.c-disable-built-in-systemd-support.patch
new file mode 100644
index 000000000000..d531687a4fd3
--- /dev/null
+++ b/0004-mxloadsvr.c-disable-built-in-systemd-support.patch
@@ -0,0 +1,26 @@
+--- mxloadsvr.c.orig 2020-07-05 12:38:21.920006951 -0400
++++ mxloadsvr.c 2020-07-05 12:38:40.634029739 -0400
+@@ -424,10 +424,11 @@ int main(int arg, char *argv[])
+ system(tmpstr);
+ system("chmod +x /usr/lib/npreal2/driver/load_npreal2.sh");
+
+ f = fopen( "/usr/lib/npreal2/tmp/npreal2.service", "r+");
+ if( f == NULL ){
++ if (0) {
+ system("touch /usr/lib/npreal2/tmp/npreal2.service");
+ system("echo '[Unit]' >> /usr/lib/npreal2/tmp/npreal2.service 2>&1");
+ system("echo 'Description=Moxa NPort Driver' >> /usr/lib/npreal2/tmp/npreal2.service 2>&1");
+ system("echo 'Requires=systemd-hostnamed.service' >> /usr/lib/npreal2/tmp/npreal2.service 2>&1");
+ system("echo 'After=remote-fs.target' >> /usr/lib/npreal2/tmp/npreal2.service 2>&1");
+@@ -439,10 +440,11 @@ int main(int arg, char *argv[])
+ system("cp /usr/lib/npreal2/tmp/npreal2.service /etc/systemd/system 2>&1");
+ system("chmod 664 /etc/systemd/system/npreal2.service 2>&1");
+ system("systemctl daemon-reload > /dev/null 2>&1");
+ system("systemctl enable npreal2.service > /dev/null 2>&1");
+ system("rm -f /usr/lib/npreal2/tmp/npreal2.service > /dev/null 2>&1");
++ }
+ } else {
+ fclose(f);
+ }
+ }
+ }
diff --git a/0005-kernel-5.10-async-initialized.patch b/0005-kernel-5.10-async-initialized.patch
new file mode 100644
index 000000000000..0bb5f757f838
--- /dev/null
+++ b/0005-kernel-5.10-async-initialized.patch
@@ -0,0 +1,18 @@
+--- npreal2.c.orig 2021-06-29 10:25:28.056567394 -0400
++++ npreal2.c 2021-06-29 10:26:36.965686095 -0400
+@@ -85,10 +85,15 @@
+ #include <config/ioport.h>
+ #include <config/mm.h>
+ #include <config/proc_fs.h>
+ #endif
+
++#ifndef ASYNC_INITIALIZED
++/* ArchLinuxPatch-0005-Begin */
++/* ArchLinuxPatch-0005-End */
++#endif
++
+ #include "np_ver.h"
+
+ #if (LINUX_VERSION_CODE < VERSION_CODE(5,0,0))
+ #define ACCESS_OK(x,y,z) access_ok(x,y,z)
+ #else
diff --git a/0006-kernel-5.12-tty-low_latency.patch b/0006-kernel-5.12-tty-low_latency.patch
new file mode 100644
index 000000000000..e4b9dd51ffbd
--- /dev/null
+++ b/0006-kernel-5.12-tty-low_latency.patch
@@ -0,0 +1,67 @@
+--- npreal2.c.orig 2021-06-29 15:36:40.226223210 -0400
++++ npreal2.c 2021-06-29 15:54:46.222511683 -0400
+@@ -47,10 +47,11 @@
+ #include <linux/sched.h>
+ #include <linux/timer.h>
+ #include <linux/interrupt.h>
+ #include <linux/tty.h>
+ #include <linux/tty_flip.h>
++#include <linux/serial_core.h>
+ #include <linux/serial.h>
+ #include <linux/serial_reg.h>
+ #include <linux/major.h>
+ #include <linux/string.h>
+ #include <linux/fcntl.h>
+@@ -924,20 +925,22 @@ else
+ }
+
+ info->session = MX_SESSION();
+ info->pgrp = MX_CGRP();
+
++#if (LINUX_VERSION_CODE < VERSION_CODE(5,12,0))
+ #if (LINUX_VERSION_CODE < VERSION_CODE(3,9,0))
+ #if (LINUX_VERSION_CODE < VERSION_CODE(3,2,0))
+ /* It must be always on */
+ tty->low_latency = 1;
+ #else
+ tty->low_latency = 1; /* Read Issue */
+ #endif /* 3,2,0 */
+ #else
+ info->ttyPort.low_latency = 1;
+ #endif /* 3,9,0 */
++#endif
+ return(0);
+ }
+
+ /*
+ * This routine is called when the serial port gets closed. First, we
+@@ -3932,11 +3935,13 @@ npreal_net_write (
+ {
+ rtn = count; /* throw it away*/
+ up(&info->rx_semaphore);
+ goto done;
+ }
+-#if (LINUX_VERSION_CODE < VERSION_CODE(3,9,0))
++#if (LINUX_VERSION_CODE >= VERSION_CODE(5,12,0))
++ if(0) /* This code doesn't work without low latency support */
++#elif (LINUX_VERSION_CODE < VERSION_CODE(3,9,0))
+ if(!info->tty->low_latency)
+ #else
+ if(!info->ttyPort.low_latency)
+ #endif /* 3,9,0 */
+ {
+@@ -4207,11 +4212,13 @@ npreal_process_notify(
+ if (!(tty= info->tty))
+ {
+ up (&info->rx_semaphore);
+ return;
+ }
+-#if (LINUX_VERSION_CODE < VERSION_CODE(3,9,0))
++#if (LINUX_VERSION_CODE >= VERSION_CODE(5,12,0))
++ if(0) /* This code doesn't work without low latency support */
++#elif (LINUX_VERSION_CODE < VERSION_CODE(3,9,0))
+ if(!tty->low_latency)
+ #else
+ if(!info->ttyPort.low_latency)
+ #endif /* 3,9,0 */
+ {
diff --git a/0007-tty_unregister_driver-void.patch b/0007-tty_unregister_driver-void.patch
new file mode 100644
index 000000000000..0e8759da4bb1
--- /dev/null
+++ b/0007-tty_unregister_driver-void.patch
@@ -0,0 +1,18 @@
+--- npreal2.c.orig 2021-08-10 15:16:05.526245528 -0400
++++ npreal2.c 2021-08-10 15:16:43.473119614 -0400
+@@ -541,14 +541,11 @@ static void __exit npreal2_module_exit(v
+ #endif
+ npvar_proc_root = NULL;
+ }
+
+ DBGPRINT(MX_DEBUG_INFO, "Unloading module npreal ...\n");
+- if ((err |= tty_unregister_driver(DRV_VAR)))
+- {
+- DBGPRINT(MX_DEBUG_ERROR, "Couldn't unregister MOXA Async/NPort server family Real TTY driver\n");
+- }
++ tty_unregister_driver(DRV_VAR);
+ put_tty_driver(DRV_VAR);
+
+ DBGPRINT(MX_DEBUG_INFO, "Done.\n");
+
+ }
diff --git a/0008-kernel-5.13-dropped-tty_check_change.patch b/0008-kernel-5.13-dropped-tty_check_change.patch
new file mode 100644
index 000000000000..48e9ad8ecf94
--- /dev/null
+++ b/0008-kernel-5.13-dropped-tty_check_change.patch
@@ -0,0 +1,17 @@
+--- npreal2.c.orig 2021-08-10 15:19:53.500816830 -0400
++++ npreal2.c 2021-08-10 15:21:10.617898548 -0400
+@@ -1319,10 +1319,14 @@ static void npreal_ldisc_flush_buffer(st
+ }
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(HZ/100);
+ }
+
++#if LINUX_VERSION_CODE >= VERSION_CODE(5,10,180)
++int tty_check_change(struct tty_struct *tty);
++#endif
++
+ static int npreal_ioctl(struct tty_struct * tty,
+ unsigned int cmd, unsigned long arg)
+ {
+ int error;
+ struct npreal_struct * info = (struct npreal_struct *)tty->driver_data;
diff --git a/0009-kernel-5.14-task_struct.state-unsigned-tty.patch b/0009-kernel-5.14-task_struct.state-unsigned-tty.patch
new file mode 100644
index 000000000000..ae32fa3e2872
--- /dev/null
+++ b/0009-kernel-5.14-task_struct.state-unsigned-tty.patch
@@ -0,0 +1,174 @@
+--- npreal2.c.orig 2021-09-12 22:09:13.005831652 -0400
++++ npreal2.c 2021-09-12 22:09:48.825927630 -0400
+@@ -406,14 +406,22 @@ static int npreal_init_tty(void);
+ static void npreal_do_softint(struct work_struct *work);
+ static void npreal_flush_to_ldisc(struct work_struct *work);
+ static int npreal_open(struct tty_struct *,struct file *);
+ static void npreal_close(struct tty_struct *,struct file *);
+ static int npreal_write(struct tty_struct *,const unsigned char *,int);
++#if LINUX_VERSION_CODE >= VERSION_CODE(5,14,0)
++static unsigned int npreal_write_room(struct tty_struct *);
++#else
+ static int npreal_write_room(struct tty_struct *);
++#endif
+ static void npreal_flush_buffer(struct tty_struct *);
+ static void npreal_ldisc_flush_buffer(struct tty_struct *);
++#if LINUX_VERSION_CODE >= VERSION_CODE(5,14,0)
++static unsigned int npreal_chars_in_buffer(struct tty_struct *);
++#else
+ static int npreal_chars_in_buffer(struct tty_struct *);
++#endif
+ static void npreal_flush_chars(struct tty_struct *);
+ static int npreal_put_char(struct tty_struct *,unsigned char);
+ static int npreal_ioctl(struct tty_struct *,uint,ulong);
+ static void npreal_throttle(struct tty_struct *);
+ static void npreal_unthrottle(struct tty_struct *);
+@@ -1054,11 +1062,11 @@ npreal_close(
+ }
+ else if (ret < 0)
+ break;
+ else
+ cnt = 0;
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/100);
+ }
+ }
+ npreal_flush_buffer(tty);
+ if ( tty->ldisc->ops->flush_buffer )
+@@ -1205,11 +1213,15 @@ static void npreal_wait_until_sent(struc
+ if ((info = (struct npreal_struct *)tty->driver_data))
+ npreal_wait_oqueue(info,timeout);
+
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
++static unsigned int npreal_write_room(struct tty_struct * tty)
++#else
+ static int npreal_write_room(struct tty_struct * tty)
++#endif
+ {
+ struct npreal_struct *info = (struct npreal_struct *)tty->driver_data;
+ int ret;
+
+ DBGPRINT(MX_DEBUG_LOUD, "(Entry)\n");
+@@ -1222,11 +1234,15 @@ static int npreal_write_room(struct tty_
+ if ( ret < 0 )
+ ret = 0;
+ return(ret);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
++static unsigned int npreal_chars_in_buffer(struct tty_struct * tty)
++#else
+ static int npreal_chars_in_buffer(struct tty_struct * tty)
++#endif
+ {
+ struct npreal_struct *info = (struct npreal_struct *)tty->driver_data;
+
+ DBGPRINT(MX_DEBUG_LOUD, "(Entry)\n");
+
+@@ -1315,11 +1331,11 @@ static void npreal_ldisc_flush_buffer(st
+ nd->cmd_ready = 1;
+ if ( waitqueue_active(&nd->select_ex_wait))
+ {
+ wake_up_interruptible( &nd->select_ex_wait );
+ }
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/100);
+ }
+
+ #if LINUX_VERSION_CODE >= VERSION_CODE(5,13,0)
+ int tty_check_change(struct tty_struct *tty);
+@@ -1471,11 +1487,11 @@ static int npreal_ioctl(struct tty_struc
+ cprev = cnow;
+ // Scott: 2005-09-04 add begin
+ schedule();
+ // Scott: 2005-09-04 add end
+ }
+- current->state = TASK_RUNNING;
++ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&info->delta_msr_wait, &wait);
+ // Scott: 2005-09-04
+ // Scott break;
+ return ret;
+ }
+@@ -1807,11 +1823,11 @@ retval = -EAGAIN;
+ retval = -EIO;
+ break;
+ }
+ schedule();
+ }
+- current->state = TASK_RUNNING;
++ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&info->open_wait, &wait);
+ if ( retval )
+ return(retval);
+ info->flags |= ASYNC_NORMAL_ACTIVE;
+ return(0);
+@@ -1844,11 +1860,11 @@ static int npreal_startup(struct npreal_
+ DBGPRINT(MX_DEBUG_ERROR, "signal_pending break\n");
+ break;
+ }
+ schedule();
+ }
+- current->state = TASK_RUNNING;
++ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&nd->initialize_wait, &wait);
+
+ // Scott: 2005/07/13
+ // Set tty->driver_data before entering npreal_startup(), so that the tty driver
+ // can decrease refcount if npreal_startup() failed, by calling npreal_close().
+@@ -1991,11 +2007,11 @@ static int npreal_startup(struct npreal_
+ goto startup_err;
+ }
+
+ while ((nd->cmd_ready == 1)&&(cnt++ < 10))
+ {
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/100);
+ }
+ }
+ /*
+ * and set the speed of the serial port
+@@ -2104,11 +2120,11 @@ static void npreal_shutdown(struct nprea
+
+ while (test_and_set_bit(NPREAL_NET_DO_INITIALIZE,&nd->flag))
+ {
+ if ( signal_pending(current) )
+ break;
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/100);
+ }
+
+
+ if ( !(info->flags & ASYNC_INITIALIZED) )
+@@ -3067,11 +3083,11 @@ static void npreal_send_break(struct npr
+ if (!(nd = info->net_node))
+ return;
+
+ npreal_start_break(nd);
+
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(duration);
+
+ npreal_stop_break(nd);
+
+ }
+@@ -4095,11 +4111,11 @@ npreal_wait_and_set_command(
+ return (0);
+ }
+ else
+ {
+ up (&nd->cmd_semaphore);
+- current->state = TASK_INTERRUPTIBLE;
++ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+ }
+ }
+ }
+ /*
diff --git a/0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch b/0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch
new file mode 100644
index 000000000000..53e15d049815
--- /dev/null
+++ b/0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch
@@ -0,0 +1,43 @@
+--- npreal2.c.orig 2021-11-20 15:06:06.053095280 -0500
++++ npreal2.c 2021-11-20 15:08:15.950519353 -0500
+@@ -550,11 +550,11 @@ static void __exit npreal2_module_exit(v
+ npvar_proc_root = NULL;
+ }
+
+ DBGPRINT(MX_DEBUG_INFO, "Unloading module npreal ...\n");
+ tty_unregister_driver(DRV_VAR);
+- put_tty_driver(DRV_VAR);
++ tty_driver_kref_put(DRV_VAR);
+
+ DBGPRINT(MX_DEBUG_INFO, "Done.\n");
+
+ }
+ #endif
+@@ -643,12 +643,12 @@ npreal_init(void)
+ int ret1, ret2;
+ #if (LINUX_VERSION_CODE >= VERSION_CODE(3,7,0))
+ int i;
+ #endif
+
+- npvar_sdriver = alloc_tty_driver(NPREAL_PORTS+1);
+- if (!npvar_sdriver)
++ npvar_sdriver = tty_alloc_driver(NPREAL_PORTS+1,0);
++ if (IS_ERR(npvar_sdriver))
+ return -ENOMEM;
+ printk("MOXA Async/NPort server family Real TTY driver ttymajor %d calloutmajor %d verbose %d (%s)\n", ttymajor, calloutmajor, verbose, NPREAL_VERSION);
+
+ /* Initialize the tty_driver structure */
+ DRV_VAR_P(name) = "ttyr";
+@@ -693,11 +693,11 @@ npreal_init(void)
+ DBGPRINT(MX_DEBUG_ERROR, "Couldn't install MOXA Async/NPort server family driver !\n");
+ }
+
+ if (ret1 || ret2)
+ {
+- put_tty_driver(DRV_VAR);
++ tty_driver_kref_put(DRV_VAR);
+ return -1;
+ }
+
+ /* Initialize the net node structure */
+ memset(&npreal_net_fops,0,sizeof(npreal_net_fops));
diff --git a/0011-kernel-5.17-change-PDE_DATA.patch b/0011-kernel-5.17-change-PDE_DATA.patch
new file mode 100644
index 000000000000..1a24b9cb2b5a
--- /dev/null
+++ b/0011-kernel-5.17-change-PDE_DATA.patch
@@ -0,0 +1,15 @@
+--- npreal2.c.orig 2022-06-05 01:21:16.795161588 -0400
++++ npreal2.c 2022-06-05 01:21:50.662167567 -0400
+@@ -3387,10 +3387,12 @@ npreal_net_open (
+ rtn = -ENXIO;
+ goto done;
+ }
+
+ nd = (struct nd_struct *) de->data;
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
++ nd = pde_data(inode);
+ #else
+
+ //nd = (struct nd_struct *) &npvar_net_nodes[0];
+ nd = (struct nd_struct *) PDE_DATA(inode);
+ #endif /* 3,10,0 */
diff --git a/0012-kernel-serial_UART_XMIT_SIZE.patch b/0012-kernel-serial_UART_XMIT_SIZE.patch
new file mode 100644
index 000000000000..60f7edd9863b
--- /dev/null
+++ b/0012-kernel-serial_UART_XMIT_SIZE.patch
@@ -0,0 +1,67 @@
+--- npreal2.c 2022-12-15 12:56:21.327747314 +0100
++++ npreal2.c 2022-12-15 12:56:56.314313178 +0100
+@@ -1109,8 +1109,8 @@
+
+ while ( 1 )
+ {
+- c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
+- SERIAL_XMIT_SIZE - info->xmit_head));
++ c = MIN(count, MIN(UART_XMIT_SIZE - info->xmit_cnt - 1,
++ UART_XMIT_SIZE - info->xmit_head));
+
+ if ( c <= 0 )
+ break;
+@@ -1125,7 +1125,7 @@
+ memcpy(info->xmit_buf + info->xmit_head, buf, c);
+
+ DOWN(info->tx_lock, flags);
+- info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
++ info->xmit_head = (info->xmit_head + c) & (UART_XMIT_SIZE - 1);
+ info->xmit_cnt += c;
+ UP(info->tx_lock, flags);
+
+@@ -1171,7 +1171,7 @@
+ return 0;
+ }
+
+- if ( info->xmit_cnt >= SERIAL_XMIT_SIZE - 1 )
++ if ( info->xmit_cnt >= UART_XMIT_SIZE - 1 )
+ {
+ //up(&info->tx_semaphore);
+ UP(info->tx_lock, flags);
+@@ -1186,7 +1186,7 @@
+ }
+
+ info->xmit_buf[info->xmit_head++] = ch;
+- info->xmit_head &= SERIAL_XMIT_SIZE - 1;
++ info->xmit_head &= UART_XMIT_SIZE - 1;
+ info->xmit_cnt++;
+
+ nd->tx_ready = 1;
+@@ -1230,7 +1230,7 @@
+ if (!info)
+ return 0;
+
+- ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
++ ret = UART_XMIT_SIZE - info->xmit_cnt - 1;
+ if ( ret < 0 )
+ ret = 0;
+ return(ret);
+@@ -3836,7 +3836,7 @@
+ while ( count )
+ {
+ cnt = MIN(count, MIN( info->xmit_cnt,
+- SERIAL_XMIT_SIZE - info->xmit_tail));
++ UART_XMIT_SIZE - info->xmit_tail));
+ if ( cnt <= 0 )
+ break;
+ if (copy_to_user( buf+rtn,info->xmit_buf + info->xmit_tail,cnt ))
+@@ -3850,7 +3850,7 @@
+ DOWN(info->tx_lock, flags);
+ info->xmit_cnt -= cnt;
+ info->xmit_tail += cnt;
+- info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1);
++ info->xmit_tail = info->xmit_tail & (UART_XMIT_SIZE - 1);
+ info->icount.tx += cnt;
+ UP(info->tx_lock, flags);
+ }
diff --git a/0013-kernel-6.1-set_termios-const-ktermios.patch b/0013-kernel-6.1-set_termios-const-ktermios.patch
new file mode 100644
index 000000000000..11b11a4d0a59
--- /dev/null
+++ b/0013-kernel-6.1-set_termios-const-ktermios.patch
@@ -0,0 +1,31 @@
+--- npreal2.c 2022-12-15 12:56:56.314313178 +0100
++++ npreal2.c 2023-01-02 08:40:08.501468104 +0100
+@@ -425,8 +425,8 @@
+ static int npreal_ioctl(struct tty_struct *,uint,ulong);
+ static void npreal_throttle(struct tty_struct *);
+ static void npreal_unthrottle(struct tty_struct *);
+-static void npreal_set_termios(struct tty_struct *,struct ktermios *);
+-static int npreal_port_init(struct npreal_struct *,struct ktermios *);
++static void npreal_set_termios(struct tty_struct *,const struct ktermios *);
++static int npreal_port_init(struct npreal_struct *,const struct ktermios *);
+ static void npreal_stop(struct tty_struct *);
+ static void npreal_start(struct tty_struct *);
+ static void npreal_hangup(struct tty_struct *);
+@@ -1612,7 +1612,7 @@
+ * where old == NULL, and try to do something rational.
+ */
+ static void npreal_set_termios(struct tty_struct * tty,
+- struct ktermios * old_termios)
++ const struct ktermios * old_termios)
+ {
+ struct npreal_struct *info = (struct npreal_struct *)tty->driver_data;
+
+@@ -2174,7 +2174,7 @@
+ * set npreal serial state
+ */
+ static int npreal_port_init(struct npreal_struct *info,
+- struct ktermios *old_termios)
++ const struct ktermios *old_termios)
+ {
+ struct ktermios *termio;
+ int32_t baud,mode;
diff --git a/0013a-kernel-6.0-set_termios-const-ktermios.patch b/0013a-kernel-6.0-set_termios-const-ktermios.patch
new file mode 100644
index 000000000000..ef83b547afc1
--- /dev/null
+++ b/0013a-kernel-6.0-set_termios-const-ktermios.patch
@@ -0,0 +1,52 @@
+--- npreal2.c.orig 2023-01-02 23:02:37.555942414 -0500
++++ npreal2.c 2023-01-02 23:07:31.938419910 -0500
+@@ -423,12 +423,17 @@ static int npreal_chars_in_buffer(struct
+ static void npreal_flush_chars(struct tty_struct *);
+ static int npreal_put_char(struct tty_struct *,unsigned char);
+ static int npreal_ioctl(struct tty_struct *,uint,ulong);
+ static void npreal_throttle(struct tty_struct *);
+ static void npreal_unthrottle(struct tty_struct *);
++#if LINUX_VERSION_CODE < VERSION_CODE(6,0,0)
+ static void npreal_set_termios(struct tty_struct *,struct ktermios *);
+ static int npreal_port_init(struct npreal_struct *,struct ktermios *);
++#else
++static void npreal_set_termios(struct tty_struct *,const struct ktermios *);
++static int npreal_port_init(struct npreal_struct *,const struct ktermios *);
++#endif
+ static void npreal_stop(struct tty_struct *);
+ static void npreal_start(struct tty_struct *);
+ static void npreal_hangup(struct tty_struct *);
+ static inline void npreal_check_modem_status(struct npreal_struct *,int);
+ static int npreal_block_til_ready(struct tty_struct *,struct file *, struct npreal_struct *);
+@@ -1610,11 +1615,15 @@ static void npreal_unthrottle(struct tty
+ *
+ * Note : that a well-designed tty driver should be prepared to accept the case
+ * where old == NULL, and try to do something rational.
+ */
+ static void npreal_set_termios(struct tty_struct * tty,
++#if LINUX_VERSION_CODE < VERSION_CODE(6,0,0)
+ struct ktermios * old_termios)
++#else
++ const struct ktermios * old_termios)
++#endif
+ {
+ struct npreal_struct *info = (struct npreal_struct *)tty->driver_data;
+
+ DBGPRINT(MX_DEBUG_LOUD, "(Entry)\n");
+
+@@ -2172,11 +2181,15 @@ static void npreal_shutdown(struct nprea
+ }
+ /*
+ * set npreal serial state
+ */
+ static int npreal_port_init(struct npreal_struct *info,
++#if LINUX_VERSION_CODE < VERSION_CODE(6,0,0)
+ struct ktermios *old_termios)
++#else
++ const struct ktermios *old_termios)
++#endif
+ {
+ struct ktermios *termio;
+ int32_t baud,mode;
+ int baudIndex,modem_status;
+ struct nd_struct *nd;
diff --git a/0014-kernel-6.6-struct-tty_operations-size_t.patch b/0014-kernel-6.6-struct-tty_operations-size_t.patch
new file mode 100644
index 000000000000..7d43c4b93ff9
--- /dev/null
+++ b/0014-kernel-6.6-struct-tty_operations-size_t.patch
@@ -0,0 +1,37 @@
+diff -pNaru5 a/npreal2.c b/npreal2.c
+--- a/npreal2.c 2023-12-18 02:45:25.140042480 -0500
++++ b/npreal2.c 2023-12-18 02:47:21.607497828 -0500
+@@ -405,11 +405,15 @@ int npreal_init(void);
+ static int npreal_init_tty(void);
+ static void npreal_do_softint(struct work_struct *work);
+ static void npreal_flush_to_ldisc(struct work_struct *work);
+ static int npreal_open(struct tty_struct *,struct file *);
+ static void npreal_close(struct tty_struct *,struct file *);
++#if LINUX_VERSION_CODE < VERSION_CODE(6,6,0)
+ static int npreal_write(struct tty_struct *,const unsigned char *,int);
++#else
++static ssize_t npreal_write(struct tty_struct *,const u8 *,size_t);
++#endif
+ #if LINUX_VERSION_CODE >= VERSION_CODE(5,14,0)
+ static unsigned int npreal_write_room(struct tty_struct *);
+ #else
+ static int npreal_write_room(struct tty_struct *);
+ #endif
+@@ -1083,12 +1087,17 @@ npreal_close(
+
+ /*
+ * copy data form AP-layer to kernel-layer,
+ * and wake up net_read to read data to proc file system. (files in this folder /proc/npreal2)
+ */
++#if LINUX_VERSION_CODE < VERSION_CODE(6,6,0)
+ static int npreal_write(struct tty_struct * tty,
+ const unsigned char * buf, int count)
++#else
++static ssize_t npreal_write(struct tty_struct * tty,
++ const u8 * buf, size_t count)
++#endif
+ {
+ int c, total = 0, ret ;
+ struct npreal_struct *info = (struct npreal_struct *)tty->driver_data;
+ struct nd_struct *nd;
+ unsigned long flags;
diff --git a/PKGBUILD b/PKGBUILD
index 56f7904c1d23..8e3caba5716c 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -5,6 +5,8 @@ _opt_ttymajor=33 # default 33
_opt_calloutmajor=38 # default 38
_opt_defaultmode='666' # default: 666
+#export UNAME_R="$(basename /usr/lib/modules/5.10.*)"
+
# Some items are fixed as of 1.19 according to Moxa. I haven't tested them yet.
# Fixed? Fix mxinst to allow polling option
@@ -23,6 +25,7 @@ _opt_defaultmode='666' # default: 666
# Todo: SSL connections should auto reconnect on Moxa restart
# Todo: The default mode should be changed to 660
# Todo: mknod should be chgrp uucp
+# Todo: When characters are held upstream by a low RTS, connecting to /dev/ttyr* brings RTS high too soon. The held characters are released but never come through to ttyr*. This does not happen with a TCP connection.
# Enable and start service
# systemctl enable --now 'npreal2.service'
@@ -79,33 +82,78 @@ _opt_defaultmode='666' # default: 666
set -u
pkgname='npreal2'
#pkgver='1.18.49'; _commit='6d9ef0dbafd487595c4f5e4e5e64c1faba98d060'
-pkgver='1.19'; _build='17110917'
-pkgrel=1
+pkgver='5.0'; # _build='17110917'
+pkgrel='10'
pkgdesc='real tty driver for Moxa NPort serial console terminal server'
_pkgdescshort="Moxa NPort ${pkgname} TTY driver"
arch=('i686' 'x86_64')
-url='https://www.moxa.com/support/sarch_result.aspx?type=soft&prod_id=237&type_id=9' # Moxa NPort 5110
+url='https://www.moxa.com/en/products/industrial-edge-connectivity/serial-device-servers/terminal-servers/nport-6100-6200-series'
#url="https://github.com/rchovan/${pkgname}"
license=('GPL' 'custom')
depends=('glibc' 'gawk' 'perl' 'psmisc' 'openssl')
-#makedepends=('git')
+#makedepends+=('git')
backup=("etc/npreal2/npreal2d.cf")
install="${pkgname}-install.sh"
_srcdir='moxa'
-source=("https://www.moxa.com/drivers/IDC_SW/DeviceServer/Driver/NPort%20Real%20TTY%20Driver%20for%20Linux/Mainline/ver${pkgver}/npreal2_mainline_v${pkgver}_build_${_build}.tgz")
+#source=("https://www.moxa.com/drivers/IDC_SW/DeviceServer/Driver/NPort%20Real%20TTY%20Driver%20for%20Linux/Mainline/ver${pkgver}/npreal2_mainline_v${pkgver}_build_${_build}.tgz")
+source=(
+ "https://www.moxa.com/Moxa/media/PDIM/S100000217/moxa-real-tty-drivers-for-linux-5.x.x-driver-v${pkgver}.tgz"
+ #'0000-SSL-destroy-cf-configuration.patch'
+ '0001-mxmknod-folder-fix-and-chgrp-uucp.patch'
+ '0002-kernel-5.0.0-access_ok.patch' # https://lkml.org/lkml/2019/1/4/418
+ '0003-kernel-5.6-proc_dir_entry-proc_ops.patch'
+ '0004-mxloadsvr.c-disable-built-in-systemd-support.patch'
+ '0005-kernel-5.10-async-initialized.patch'
+ '0006-kernel-5.12-tty-low_latency.patch'
+ '0007-tty_unregister_driver-void.patch'
+ '0008-kernel-5.13-dropped-tty_check_change.patch'
+ '0009-kernel-5.14-task_struct.state-unsigned-tty.patch'
+ '0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch'
+ '0011-kernel-5.17-change-PDE_DATA.patch'
+ '0012-kernel-serial_UART_XMIT_SIZE.patch' # https://hastebin.com/bipeleyize.diff https://lore.kernel.org/linux-arm-kernel/6fb33489-946f-ad92-df35-7f608420bc7@linux.intel.com/T/
+ '0013-kernel-6.1-set_termios-const-ktermios.patch' # https://hastebin.com/rewemacese.csharp https://lore.kernel.org/linux-arm-kernel/20220816115739.10928-9-ilpo.jarvinen@linux.intel.com/T/
+ '0013a-kernel-6.0-set_termios-const-ktermios.patch'
+ '0014-kernel-6.6-struct-tty_operations-size_t.patch'
+ 'npreal2.sh'
+)
#_srcdir="${pkgname}"
#source=("git+${url}.git#commit=${_commit}")
#_srcdir="${pkgname}-${_commit}"
#source=("${pkgname}-${pkgver}.tgz::${url}/archive/${_commit}.tar.gz")
-source+=('npreal2.sh')
-_patches=(
- #'0000-SSL-destroy-cf-configuration.patch'
- '0001-mxmknod-folder-fix-and-chgrp-uucp.patch'
-)
-source+=("${_patches[@]}")
-sha256sums=('f99f38ef5618469a1d6f4824e41856616ee65ab8359069daa70d8d481f364462'
- '7241767fa8dead2dbe4cf4db32d39f5cf9d95b08f60daf79822ae306727af372'
- '7039ca0740be34a641424e3f57b896902f61fdfd2bfcc26e8e954035849e9605')
+md5sums=('4ba260f2e3b2b25419bd40a5f030d926'
+ '043dac91330a15c38e41bb2e2e1d5598'
+ '9cda38abdd17b2af80475ed06bdf0889'
+ 'bcd835765a6451989195a3518d53088d'
+ '0c53bb8e2df459fabbca10b567981a93'
+ '7aac842974d5dd76b9bc8fd9fd4de470'
+ 'd8a5ab4731575a4ffe90656e1793b46b'
+ 'e8c288232d6e2174c165e8f5e098a05d'
+ '647a4918f3dd6ead47886d6eb0fc70b0'
+ '16504fb58a0416a26fe04e8e3d9867a7'
+ 'd3716370fdd8b1ad888498fc82fca9f4'
+ '9f62a0a931436bda473259832d9ebc5b'
+ '93789057c6b3f66467ed936987ed003c'
+ '9303500d793cb4ebaa79b428607d403d'
+ '2d79f7913c70bad8ae9316360bc2d13a'
+ '619a190e17180f44435468314c9eb393'
+ '90ac27b669542c11b0a9b6763f6e0d9b')
+sha256sums=('33da5d4b1ff9853e9d58c7905f1fdf09a3e284658f42437210155c4c913f4dad'
+ '7039ca0740be34a641424e3f57b896902f61fdfd2bfcc26e8e954035849e9605'
+ '211f3b0ba50452bfe6d39076eb1a60a7557dd038288fb8dcd4374886f4c2844e'
+ 'c3f8502c3e7e600ccc3e778ec25875ddda3a20ed3cb62bc56505e609ac346d79'
+ 'e1856e4a410af0b112dd8beee58edd2516bb5cd7607d84b06bc25133b8bd8f15'
+ '2e913895e2c382abc8fd610faddf6bbda6b59845fb3f95a1d33136995d27cb3f'
+ '252ce8e55b835c22e6fdf4e3c661ef906be41fdf9dfc76900d787907892e6f21'
+ 'd35d49ab325a17976d26d64661a235fc5c8f0e0ce6c7e86483607654e94d5b22'
+ 'df64718aee9b460e0d4f92ec577f36d1f3c54c9bc801261c6db5a07020be8fec'
+ '7c9380a794725418015d62411f697850096b3c8a62666f5ec9e562e93ba3ee4c'
+ 'd61ca42d7fe58b409c1a1c7237788d412c36042acaa61e95008e48ec580b5153'
+ '609388af991dd4095300dec76f85d5abceb68395fde5e157fa084fb4af8cad60'
+ '6c6abf4902c235cc1d39bcf97005de1e10962c9b42263b5ffd57a9c856be8934'
+ '4a02f4f4963ee10da37614e3cc6a205225b8a052db71240c397d32fe48365a2b'
+ 'b9b73e078fef61fae0191c9b9bba8c20560559b777014911f4298ec0367b2fcf'
+ 'd1b0b1e1d4a7b9a9c67e38aa14da568b240847cd1cd33256b21828e85ac816ff'
+ '13e297691ba1b6504f66ef98e072194343321d2a47928c3964e315160b246153')
if [ "${_opt_DKMS}" -ne 0 ]; then
depends+=('linux' 'dkms' 'linux-headers')
@@ -141,6 +189,10 @@ prepare() {
-e 's: /lib/: /usr/lib/:g' \
-e '# Cut some of the warnings we dont want to fix' \
-e '#s:^CC+=.*$:& -Wno-misleading-indentation:g' \
+ -e '# Add back SUBDIRS= for dkms detection' \
+ -e '/ modules/ s: M=: SUBDIRS=$(PWD)&:g' \
+ -e 's:shell uname -r:UNAME_R:g' \
+ -e '1i UNAME_R?=$(shell uname -r)' \
-i 'Makefile'
! test -s 'Makefile.Arch' || echo "${}"
@@ -178,6 +230,8 @@ prepare() {
-e 's:^LINUX_DIS=:#&:g' \
-e '# Enable SSL' \
-e 's:^read check:check="Y" # &:g' \
+ -e '# Disable interactive response to kernel version mismatch' \
+ -e 's:^read any:#&:g' \
-i 'mxinst'
! test -s 'mxinst.Arch' || echo "${}"
@@ -190,6 +244,8 @@ prepare() {
-e '# Move config file in mx utils. Another sed will provide this #define' \
-e '/npreal2d.cf/ s:DRIVERPATH:CONFIGPATH:g' \
-i mx*.c
+ # force the use of systemd
+ sed -e 's:^int isinitproc:static int isinitproc() { return 0; }\nstatic &_disabled:g' -i 'mxaddsvr.c' 'mxdelsvr.c' 'mxloadsvr.c' 'mxsetsec.c'
sed -e '# Move config file in mx daemons' \
-e '/npreal2d.cf/ s:workpath:"/etc/npreal2":g' \
-e '# Move log file' \
@@ -205,7 +261,70 @@ prepare() {
-i 'nport.h'
#diff -pNau5 'mxmknod'{.orig,} > '0001-mxmknod-folder-fix-and-chgrp-uucp.patch'
- patch -Nbup0 -i "${srcdir}/0001-mxmknod-folder-fix-and-chgrp-uucp.patch"
+ patch -Nup0 -i "${srcdir}/0001-mxmknod-folder-fix-and-chgrp-uucp.patch"
+
+ #cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0002-kernel-5.0.0-access_ok.patch'
+ #patch -Nup0 -i "${srcdir}/0002-kernel-5.0.0-access_ok.patch"
+
+ #cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0003-kernel-5.6-proc_dir_entry-proc_ops.patch'
+ patch -Nup0 -i "${srcdir}/0003-kernel-5.6-proc_dir_entry-proc_ops.patch"
+
+ #cp -p 'mxloadsvr.c'{,.orig}; false
+ #diff -pNau5 'mxloadsvr.c'{.orig,} > '0004-mxloadsvr.c-disable-built-in-systemd-support.patch'
+ patch -Nup0 -i "${srcdir}/0004-mxloadsvr.c-disable-built-in-systemd-support.patch"
+
+ # Not compatible with Kernel 4.4 headers
+ #sed -n -e '/^#ifndef __KERNEL__/,/^#endif/ p' "/usr/lib/modules/$(uname -r)/build/include/uapi/linux/tty_flags.h" | sed -e 's:__KERNEL__:ASYNC_INITIALIZED:g' >> 'npreal2_kernel510.h'
+ sed -n -E -e '/ASYNCB_INITIALIZED|ASYNCB_CLOSING|ASYNCB_NORMAL_ACTIVE|ASYNCB_CHECK_CD/ p' "/usr/lib/modules/$(uname -r)/build/include/uapi/linux/tty_flags.h" >> 'npreal2_kernel510.h'
+ #cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0005-kernel-5.10-async-initialized.patch'
+ patch -Nup0 -i "${srcdir}/0005-kernel-5.10-async-initialized.patch"
+ sed -e '/ArchLinuxPatch-0005-Begin/ r npreal2_kernel510.h' -i 'npreal2.c'
+ rm 'npreal2_kernel510.h'
+
+ #cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0006-kernel-5.12-tty-low_latency.patch'
+ patch -Nup0 -i "${srcdir}/0006-kernel-5.12-tty-low_latency.patch"
+
+ #cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0007-tty_unregister_driver-void.patch'
+ patch -Nup0 -i "${srcdir}/0007-tty_unregister_driver-void.patch"
+
+ #cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0008-kernel-5.13-dropped-tty_check_change.patch'
+ patch -Nup0 -i "${srcdir}/0008-kernel-5.13-dropped-tty_check_change.patch"
+
+ # unsigned write_room https://www.spinics.net/lists/linux-serial/msg42297.html
+ # unsigned chars_in_buffer https://www.spinics.net/lists/linux-serial/msg42299.html
+ # set_current_state https://linux-kernel.vger.kernel.narkive.com/xnPfKhYP/patch-2-5-52-use-set-current-state-instead-of-current-state-take-1
+ #rm -f *.orig; cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0009-kernel-5.14-task_struct.state-unsigned-tty.patch'
+ patch -Nup0 -i "${srcdir}/0009-kernel-5.14-task_struct.state-unsigned-tty.patch"
+
+ # http://lkml.iu.edu/hypermail/linux/kernel/2107.2/08799.html [PATCH 5/8] tty: drop alloc_tty_driver
+ # http://lkml.iu.edu/hypermail/linux/kernel/2107.2/08801.html [PATCH 7/8] tty: drop put_tty_driver
+ #rm -f *.orig; cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch'
+ patch -Nup0 -i "${srcdir}/0010-kernel-5.15-alloc_tty_driver-put_tty_driver.patch"
+
+ # https://www.spinics.net/lists/linux-fsdevel/msg207433.html
+ #rm -f *.orig; cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0011-kernel-5.17-change-PDE_DATA.patch'
+ patch -Nup0 -i "${srcdir}/0011-kernel-5.17-change-PDE_DATA.patch"
+
+ # Avenger 2023-01-02 08:00 (UTC)
+ patch -Nup0 -i "${srcdir}/0012-kernel-serial_UART_XMIT_SIZE.patch"
+
+ # Avenger 2023-01-02 08:00 (UTC)
+ #rm -f *.orig; cp -p 'npreal2.c'{,.orig}; false
+ #diff -pNau5 'npreal2.c'{.orig,} > '0013a-kernel-6.0-set_termios-const-ktermios.patch'
+ patch -Nup0 -i "${srcdir}/0013a-kernel-6.0-set_termios-const-ktermios.patch"
+
+ #cd '..'; cp -pr "${_srcdir}" 'a'; ln -s "${_srcdir}" 'b'; false
+ # diff -pNaru5 'a' 'b' > '0014-kernel-6.6-struct-tty_operations-size_t.patch'
+ patch -Nup1 -i "${srcdir}/0014-kernel-6.6-struct-tty_operations-size_t.patch"
# Apply PKGBUILD options
sed -e 's:^\(ttymajor\)=.*:'"\1=${_opt_ttymajor}:g" \
@@ -285,9 +404,10 @@ package() {
# Place start stop scripts
install -Dpm744 /dev/null "${pkgdir}/etc/npreal2/rc.local" # the mx utils chmod this +x. The 0-length file triggers the configuration on the first start
- install -Dpm744 "${srcdir}/npreal2.sh" -t "${pkgdir}/etc/npreal2/"
+ install -Dpm744 "${srcdir}/npreal2.sh" -t "${pkgdir}/usr/lib/npreal2/driver/"
# Move configuration files to /etc
+ install -d "${pkgdir}/etc/npreal2/"
mv "${pkgdir}/usr/lib/npreal2/driver"/{'npreal2d.cf','config'} "${pkgdir}/etc/npreal2/"
# Place empty log file.
@@ -316,9 +436,9 @@ After=network.target
[Service]
Type=notify
-ExecStart=/etc/npreal2/npreal2.sh start
-ExecStop=/etc/npreal2/npreal2.sh stop
-ExecReload=/etc/npreal2/npreal2.sh reload
+ExecStart=/usr/bin/bash /usr/lib/npreal2/driver/npreal2.sh start
+ExecStop=/usr/bin/bash /usr/lib/npreal2/driver/npreal2.sh stop
+ExecReload=/usr/bin/bash /usr/lib/npreal2/driver/npreal2.sh reload
RemainAfterExit=yes
[Install]
diff --git a/npreal2-install.sh b/npreal2-install.sh
index e391e1d948ce..073ed9e0b77b 100644
--- a/npreal2-install.sh
+++ b/npreal2-install.sh
@@ -1,9 +1,16 @@
_tp_config="/etc/npreal2/npreal2d.cf"
_tp_configps="${_tp_config}.pacsave"
-_tp_log='/var/log/npreal2d.log'
+#_tp_log='/var/log/npreal2d.log'
+
+# It's the only way to be sure
+_nuke_it_from_orbit() {
+ # Remove broken systemd support placed by mxloadsvr.c
+ rm -f '/etc/systemd/system/npreal2.service'
+}
post_upgrade() {
set -u
+ _nuke_it_from_orbit
systemctl daemon-reload
# Handle the module update if DKMS doesn't
if [ ! -d /usr/src/npreal2-*/ ]; then
@@ -31,6 +38,7 @@ post_install() {
pre_upgrade() {
set -u
+ _nuke_it_from_orbit
if [ ! -d /usr/src/npreal2-*/ ]; then
systemctl stop 'npreal2.service' # also rmmod the module
fi
@@ -39,6 +47,7 @@ pre_upgrade() {
pre_remove() {
set -u
+ _nuke_it_from_orbit
systemctl stop 'npreal2.service' # pre_upgrade
# Unfortunately this when blank is changed after install which makes pacman think that it needs to be saved
if ! grep -q '^[0-9]' "${_tp_config}"; then
@@ -49,6 +58,7 @@ pre_remove() {
post_remove() {
set -u
+ _nuke_it_from_orbit
systemctl daemon-reload
set +u
}
diff --git a/npreal2.sh b/npreal2.sh
index 4647e1819d59..62a5cf080944 100644
--- a/npreal2.sh
+++ b/npreal2.sh
@@ -1,4 +1,7 @@
-#!/bin/sh
+#!/usr/bin/bash
+
+set -u
+set +e
case "$1" in
'start'|'restart')
@@ -24,7 +27,9 @@ case "$1" in
killall -s SIGTERM 'npreal2d' 'npreal2d_redund' # doesn't work
killall -q -s SIGINT 'npreal2d' 'npreal2d_redund'
killall -q -s SIGKILL 'npreal2d' 'npreal2d_redund'
- rmmod 'npreal2'
+ if rmmod 'npreal2'; then
+ echo 'Module removed'
+ fi
systemd-notify --ready
exit 0
;;