Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 109717 Details for
Bug 166205
net-dialup/mgetty - Adds support for handhelds and usb phones that only create device nodes when initated from device
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for latest mgetty to support palm and nodevsleep option
mgetty-1.1.35-hotsync.patch (text/plain), 15.48 KB, created by
Luke McKee
on 2007-02-10 14:27:17 UTC
(
hide
)
Description:
Patch for latest mgetty to support palm and nodevsleep option
Filename:
MIME Type:
Creator:
Luke McKee
Created:
2007-02-10 14:27:17 UTC
Size:
15.48 KB
patch
obsolete
>diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/conf_mg.c mgetty-1.1.35/conf_mg.c >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/conf_mg.c 2006-01-02 04:13:18.000000000 +1100 >+++ mgetty-1.1.35/conf_mg.c 2007-02-11 09:38:37.000000000 +1100 >@@ -57,6 +57,7 @@ > { "switchbd", {FAX_RECV_SWITCHBD}, CT_INT, C_PRESET }, > { "direct", {FALSE}, CT_BOOL, C_PRESET }, > { "blocking", {FALSE}, CT_BOOL, C_PRESET }, >+ { "nodevsleep", FALSE, CT_BOOL, C_PRESET }, > > { "port-owner", {(p_int) DEVICE_OWNER}, CT_STRING, C_PRESET }, > #ifdef DEVICE_GROUP >diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/conf_mg.h mgetty-1.1.35/conf_mg.h >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/conf_mg.h 2005-11-25 03:57:58.000000000 +1100 >+++ mgetty-1.1.35/conf_mg.h 2007-02-11 09:18:57.000000000 +1100 >@@ -10,6 +10,7 @@ > switchbd, /* speed switch for fax rec.*/ > direct_line, /* direct lines */ > blocking, /* do blocking open */ >+ nodev_sleep, /* sleep when open() returns ENODEV */ > > port_owner, /* "uucp" */ > port_group, /* "modem" */ >diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/config.c mgetty-1.1.35/config.c >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/config.c 1999-03-01 06:17:55.000000000 +1100 >+++ mgetty-1.1.35/config.c 2007-02-11 09:40:33.000000000 +1100 >@@ -373,8 +373,22 @@ > case CT_STRING: > if ( ( cp->d.p = malloc( strlen( line ) +1 ) ) == NULL ) > errflag ++; >- else >- strcpy( cp->d.p, line ); >+ else { >+ char *linep = line; >+ int empty = 1; >+ strcpy( cp->d.p, line ); >+ while ( *linep ) { >+ if ( *linep != '\r' && *linep != '\n' && !isspace(*linep)) { >+ empty = 0; >+ break; >+ } >+ linep ++; >+ } >+ if (empty) { >+ *(char *)cp->d.p = 0; >+ cp->flags = C_EMPTY; >+ } >+ } > break; > case CT_CHAT: > if ( ( cp->d.p = conf_get_chat( line ) ) == NULL ) >diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/logname.c mgetty-1.1.35/logname.c >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/logname.c 2005-11-25 03:58:32.000000000 +1100 >+++ mgetty-1.1.35/logname.c 2007-02-11 09:37:11.000000000 +1100 >@@ -24,6 +24,9 @@ > #include <string.h> > #include <signal.h> > #include <sys/types.h> >+#ifdef AUTO_HOTSYNC >+#include <sys/socket.h> >+#endif > #include <time.h> > #include <ctype.h> > #ifndef sunos4 >@@ -258,6 +261,144 @@ > timeouts++; > } > >+#ifdef AUTO_HOTSYNC >+#define BUF_SIZE 8192 >+#define STDOUT 0 >+static int child_exited = 0; >+int mg_dump; >+ >+static void sig_child(int signal) >+{ >+ child_exited = 1; >+} >+ >+int read_to_ring(int fromh, char *buf, char **tail_ptr, char *head) >+{ >+ char *tail = *tail_ptr; >+ int ret = 1; >+ >+ if ((tail + 1 - buf) % BUF_SIZE == (head - buf) % BUF_SIZE) { >+ /* buffer full */ >+ ret = 0; >+ } >+ else { >+ if ( tail < head ) { >+ ret = read(fromh, tail, head - tail - 1); >+ } >+ else { >+ if ( head == buf ) { >+ ret = read(fromh, tail, buf + BUF_SIZE - tail - 1); >+ } >+ else { >+ ret = read(fromh, tail, buf + BUF_SIZE - tail); >+ if ( ret == buf + BUF_SIZE - tail ) { >+ /* read more */ >+ struct timeval tv; >+ fd_set fds; >+ int got; >+ >+ FD_ZERO(&fds); >+ FD_SET(fromh, &fds); >+ tv.tv_sec = 0; >+ tv.tv_usec = 0; >+ got = select(fromh + 1, &fds, NULL, NULL, &tv); >+ if ( got < 0 ) { >+ lprintf(L_FATAL, "read_to_ring: select error %d, %s", >+ errno, strerror(errno)); >+ exit(errno); >+ } >+ else if (got > 0) { >+ got = read(fromh, buf, head - buf - 1); >+ if ( got < 0 ) { >+ ret = got; >+ } >+ else { >+ FD_ZERO(&fds); >+ FD_SET(fromh, &fds); >+ tv.tv_sec = 0; >+ tv.tv_usec = 0; >+ if ( got == head - buf -1 && >+ select(fromh + 1, &fds, NULL, NULL, >+ &tv) > 0) { >+ >+ lprintf(L_WARN, "read_to_ring: " >+ "buffer full reise BUF_SIZE " >+ "& recompile mgetty"); >+ } >+ ret += got; >+ } >+ } >+ } >+ } >+ } >+ if (ret < 0 ) { >+ ret = -errno; >+ } >+ else { >+ tail = buf + (tail - buf + ret) % BUF_SIZE; >+ } >+ } >+ >+ *tail_ptr = tail; >+ >+ return ret; >+} >+ >+int write_from_ring(int tofh, char *buf, char *tail, char **head_ptr) >+{ >+ char *head = *head_ptr; >+ int ret = 1; >+ >+ if ( head == tail ) { >+ /* buffer empty */ >+ ret = 0; >+ } >+ else { >+ if ( tail > head ) { >+ ret = write(tofh, head, tail - head); >+ } >+ else { >+ ret = write(tofh, head, buf + BUF_SIZE - head); >+ if ( ret == buf + BUF_SIZE - head ) { >+ /* write more? */ >+ struct timeval tv; >+ fd_set fds; >+ int got; >+ >+ FD_ZERO(&fds); >+ FD_SET(tofh, &fds); >+ tv.tv_sec = 0; >+ tv.tv_usec = 0; >+ got = select(tofh + 1, NULL, &fds, NULL, &tv); >+ if ( got < 0 ) { >+ lprintf(L_FATAL, "write_from_ring: select error %d, %s", >+ errno, strerror(errno)); >+ exit(errno); >+ } >+ else if ( got > 0 ) { >+ got = write(tofh, buf, tail - head); >+ if ( got < 0 ) { >+ ret = got; >+ } >+ else { >+ ret += got; >+ } >+ } >+ } >+ } >+ if ( ret < 0 ) { >+ ret = -errno; >+ } >+ else { >+ head = buf + (head + ret - buf) % BUF_SIZE; >+ } >+ } >+ >+ *head_ptr = head; >+ return ret; >+} >+#endif >+ > /* getlogname() > * > * read the login name into "char buf[]", maximum length "maxsize". >@@ -282,6 +423,20 @@ > static int ppp_level = 0, ppp_escaped = 0; > char ppp_ch; > #endif >+#ifdef AUTO_HOTSYNC >+ int pipefd[2]; >+ int pid; >+ int sel; >+ struct timeval tv; >+ fd_set fds, pipefds; >+ char pipebuf[BUF_SIZE] = {HOTSYNC}; >+ char devbuf[BUF_SIZE]; >+ char *pipe_tail = pipebuf + 1; >+ char *pipe_head = pipebuf; >+ char *dev_tail = devbuf; >+ char *dev_head = devbuf; >+ int devr = 0, devw = 0, piper = 0, pipew = 0; >+#endif > > /* read character by character! */ > tio_save = *tio; >@@ -315,7 +470,8 @@ > newlogin_noemsi: > #endif > >- printf( "\r\n%s", final_prompt ); >+ if (*final_prompt) >+ printf( "%s", final_prompt ); > > if ( ferror( stdin ) ) > { >@@ -427,6 +583,120 @@ > ppp_escaped = 0; > } > #endif >+#ifdef AUTO_HOTSYNC >+ if (ch == (char) HOTSYNC) { >+ strcpy(buf, "/HotSync/"); >+ i = 9; /* Length of magic word /HotSync/ */ >+ ch = '\n'; >+ >+ if (socketpair(PF_UNIX, SOCK_STREAM, 0, pipefd) < 0 ) { >+ lprintf(L_FATAL, "getlogname: pipe error %d, %s", >+ errno, strerror(errno)); >+ return -1; >+ } >+ >+ signal(SIGCHLD, sig_child); >+ >+ pid = fork(); >+ >+ if ( pid < 0 ) { >+ lprintf( L_FATAL, "getlogname: unable to fork %d, %s", >+ errno, strerror(errno)); >+ return -1; >+ } >+ else if (pid > 0) { >+/* parent */ >+ do { >+ tv.tv_usec = 0; >+ tv.tv_sec = 10; >+ FD_ZERO(&fds); >+ FD_ZERO(&pipefds); >+ >+ FD_SET(pipefd[1], &pipefds); >+ FD_SET(STDOUT, &pipefds); >+ >+ FD_SET(STDIN, &fds); >+ FD_SET(pipefd[1], &fds); >+ sel = select(pipefd[1] + 1, &fds, &pipefds, NULL, &tv); >+ if ( sel > 0 ) { >+ >+ /* Checking read descriptors in fds */ >+ if ( FD_ISSET(STDIN, &fds) ) { >+ sel = read_to_ring(STDIN, pipebuf, &pipe_tail, pipe_head); >+ devr += sel; >+ if ( sel == 0 ) { >+ lprintf(L_WARN, "getlogname: no space in pipebuf"); >+ } >+ else if ( sel < 0 ) { >+ lprintf(L_FATAL, >+ "getlogname: stdin read error %d, %s", >+ -sel, strerror(-sel)); >+ exit(-sel); >+ } >+ } >+ if ( FD_ISSET(pipefd[1], &fds) ) { >+ sel = read_to_ring(pipefd[1], devbuf, &dev_tail, dev_head); >+ piper += sel; >+ if ( sel == 0 ) { >+ lprintf(L_WARN, "getlogname: no space in devbuf"); >+ } >+ else if ( sel < 0 ) { >+ lprintf(L_FATAL, >+ "getlogname: pipe read error %d, %s", >+ -sel, strerror(-sel)); >+ exit(-sel); >+ } >+ } >+ >+ /* Checking write descriptors in pipefds */ >+ if ( FD_ISSET(pipefd[1], &pipefds) ) { >+ sel = write_from_ring(pipefd[1], pipebuf, pipe_tail, &pipe_head); >+ pipew += sel; >+ if ( sel == 0 ) { >+ lprintf(L_NOISE, "getlogname: pipe buffer empty"); >+ } >+ else if ( sel < 0 ) { >+ lprintf(L_FATAL, >+ "getlogname: pipe write error %d, %s", >+ -sel, strerror(-sel)); >+ exit(-sel); >+ } >+ } >+ if ( FD_ISSET(STDOUT, &pipefds) ) { >+ sel = write_from_ring(STDOUT, devbuf, dev_tail, &dev_head); >+ devw += sel; >+ if ( sel == 0 ) { >+ lprintf(L_NOISE, "getlogname: stdout buffer empty"); >+ } >+ else if ( sel < 0 ) { >+ lprintf(L_FATAL, >+ "getlogname: stdout write error %d, %s", >+ -sel, strerror(-sel)); >+ exit(-sel); >+ } >+ } >+ } >+ else if ( sel < 0 ) { >+ lprintf(L_FATAL, "getlogname: select error %d, %s", >+ errno, strerror(errno)); >+ exit(errno); >+ } >+ else { >+ lprintf(L_WARN, "getlogname: select timeout"); >+ } >+ } while ( !child_exited ); >+ >+ lprintf(L_AUDIT, "getlogname: child exited, device r/w: %d/%d, pipe r/w: %d/%d", >+ devr, devw, piper, pipew); >+ >+ exit(0); >+ } >+ >+/* child (pid == 0) */ >+ dup2(pipefd[0], STDIN); >+ return 0; >+ } >+#endif > > #ifdef JANUS > /* ignore ^X as first character, some JANUS programs send it first >diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/mg_m_init.c mgetty-1.1.35/mg_m_init.c >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/mg_m_init.c 2006-01-03 21:15:37.000000000 +1100 >+++ mgetty-1.1.35/mg_m_init.c 2007-02-11 09:18:57.000000000 +1100 >@@ -240,19 +240,32 @@ > * getting the line as controlling tty > */ > >+extern int mg_dump; > >-int mg_open_device _P2 ( (devname, blocking), >- char * devname, boolean blocking ) >+int mg_open_device _P3 ( (devname, blocking, nodev_sleep), >+ char * devname, boolean blocking, >+ boolean nodev_sleep) > { > int fd; > > if ( ! blocking ) > { >+ again2: > fd = open(devname, O_RDWR | O_NDELAY | O_NOCTTY ); > if ( fd < 0 ) > { >- lprintf( L_FATAL, "mod: cannot open line %s", devname ); >- return ERROR; >+ if (nodev_sleep && >+ (errno == ENODEV || errno == ENOENT || errno == ENXIO)) >+ { >+ lprintf( L_NOISE, "mod: no device %s, errno %d, sleeping", devname, errno); >+ sleep(5); >+ goto again2; >+ } >+ else >+ { >+ lprintf( L_FATAL, "mod: cannot open line %s", devname ); >+ return ERROR; >+ } > } > > /* unset O_NDELAY (otherwise waiting for characters */ >@@ -268,7 +281,13 @@ > > if ( fd < 0) > { >- if ( errno == EAGAIN ) goto again; >+ if ( errno == EAGAIN || ( nodev_sleep >+ && ( errno == ENODEV || errno == ENOENT || errno == ENXIO ))) >+ { >+ lprintf(L_NOISE, "mod: no device %s, errno %d, sleeping", devname, errno); >+ sleep(5); >+ goto again; >+ } > > lprintf( L_FATAL, "mod: cannot open line %s", devname ); > return ERROR; >@@ -295,7 +314,7 @@ > > (void) close(1); > (void) close(2); >- >+ > if (dup(0) != 1) > { > lprintf( L_FATAL, "mod: cannot dup to stdout"); return ERROR; >@@ -391,12 +410,12 @@ > * if first init fails, try again: on Linux and SunOS, the port isn't > * able anymore after carrier drop, but after reopening it, it is. > */ >-int mg_get_device _P5( (devname, blocking_open, >- toggle_dtr, toggle_dtr_waittime, portspeed ), >+int mg_get_device _P6( (devname, blocking_open, >+ toggle_dtr, toggle_dtr_waittime, portspeed, nodev_sleep ), > > char * devname, boolean blocking_open, > boolean toggle_dtr, int toggle_dtr_waittime, >- unsigned int portspeed) >+ unsigned int portspeed, boolean nodev_sleep) > { > boolean first_try = TRUE; > int rs_lines; >@@ -408,7 +427,7 @@ > > /* open device, make it stdin/out/err */ > try_again: >- if ( mg_open_device( devname, blocking_open ) == ERROR ) >+ if ( mg_open_device( devname, blocking_open, nodev_sleep ) == ERROR ) > { > lprintf( L_FATAL, "open device %s failed", devname ); > return ERROR; >diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/mgetty.c mgetty-1.1.35/mgetty.c >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/mgetty.c 2006-01-02 04:13:18.000000000 +1100 >+++ mgetty-1.1.35/mgetty.c 2007-02-11 09:18:57.000000000 +1100 >@@ -169,7 +169,7 @@ > lprintf( L_MESG, "Got callback signal from pid=%d!", pid ); > > /* reopen device */ >- if ( mg_open_device( devname, FALSE ) == ERROR ) >+ if ( mg_open_device( devname, FALSE, FALSE ) == ERROR ) > { > lprintf( L_FATAL, "stsc: can't reopen device" ); > exit(0); >@@ -443,23 +443,24 @@ > /* open + initialize device (mg_m_init.c) */ > if ( mg_get_device( devname, c_bool(blocking), > c_bool(toggle_dtr), c_int(toggle_dtr_waittime), >- c_int(speed) ) == ERROR ) >+ c_int(speed), >+ c_bool(nodev_sleep)) == ERROR ) > { > lprintf( L_FATAL, "cannot get terminal line dev=%s, exiting", Device); > exit(30); > } > >- /* drain input - make sure there are no leftover "NO CARRIER"s >- * or "ERROR"s lying around from some previous dial-out >- */ >- clean_line( STDIN, 1); >- > /* do modem initialization, normal stuff first, then fax > */ > if ( c_bool(direct_line) ) > Connect = "DIRECT"; /* for "\I" in issue/prompt */ > else > { >+ /* drain input - make sure there are no leftover "NO CARRIER"s >+ * or "ERROR"s lying around from some previous dial-out >+ */ >+ clean_line( STDIN, 1); >+ > /* initialize data part */ > if ( mg_init_data( STDIN, c_chat(init_chat), c_bool(need_dsr), > c_chat(force_init_chat) ) == FAIL ) >@@ -519,7 +520,8 @@ > /* wait .3s for line to clear (some modems send a \n after "OK", > this may confuse the "call-chat"-routines) */ > >- clean_line( STDIN, 3); >+ if ( !c_bool(direct_line) ) >+ clean_line( STDIN, 3); > > /* remove locks, so any other process can dial-out. When waiting > for "RING" we check for foreign lockfiles, if there are any, we >@@ -960,7 +962,8 @@ > be sent by the modem, on a non-MNP-Modem the MNP-request > string sent by a calling MNP-Modem is discarded here, too) */ > >- clean_line( STDIN, 3); >+ if (!c_bool(direct_line)) >+ clean_line( STDIN, 3); > > tio_get( STDIN, &tio ); > /* honor carrier now: terminate if modem hangs up prematurely >@@ -1004,7 +1007,7 @@ > NeXT_repair_line(STDIN); > #endif > >- fputc('\r', stdout); /* just in case */ >+ /* fputc('\r', stdout); */ /* just in case */ > > if (c_isset(issue_file)) > { >diff -urN /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/mgetty.h mgetty-1.1.35/mgetty.h >--- /opt/tmp/portage/net-dialup/mgetty-1.1.35-r2/work/mgetty-1.1.35/mgetty.h 2006-01-02 04:13:18.000000000 +1100 >+++ mgetty-1.1.35/mgetty.h 2007-02-11 09:18:57.000000000 +1100 >@@ -53,6 +53,9 @@ > #define PPP_LCP_LOW 0x21 /* LCP protocol - low byte */ > #define PPP_UNESCAPE(c) ((c) ^ 0x20) /* un-escape character */ > >+/* defines for Palm HotSync */ >+#define HOTSYNC 0x90 >+ > /* stuff in logfile.c */ > > #define L_FATAL 0 >@@ -262,13 +265,13 @@ > boolean fax_only, int fax_max_speed )); > int mg_init_voice _PROTO(( int fd )); > void faxpoll_server_init _PROTO(( int fd, char * fax_server_file )); >-int mg_open_device _PROTO(( char * devname, boolean blocking )); >+int mg_open_device _PROTO(( char * devname, boolean blocking, boolean nodev_sleep )); > int mg_init_device _PROTO(( int fd, boolean toggle_dtr, > int toggle_dtr_waittime, > unsigned int portspeed )); > int mg_get_device _PROTO(( char * devname, boolean blocking, > boolean toggle_dtr, int toggle_dtr_waittime, >- unsigned int portspeed )); >+ unsigned int portspeed, boolean nodev_sleep )); > int mg_get_ctty _PROTO(( int fd, char * devname )); > int mg_drop_ctty _PROTO(( int fd )); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 166205
: 109717 |
109718