diff options
author | Dima Dorfman <dd@FreeBSD.org> | 2001-06-05 05:07:53 +0000 |
---|---|---|
committer | Dima Dorfman <dd@FreeBSD.org> | 2001-06-05 05:07:53 +0000 |
commit | ddf5b79683713d343d3b2cb2b4e5ac492f9304a8 (patch) | |
tree | a1b37cc52c6254099ebc9a7f8e9bedef895a8383 /sys/dev/snp/snp.c | |
parent | f09f49f136dce15e5647354db7a4811b77c3bf71 (diff) | |
download | src-ddf5b79683713d343d3b2cb2b4e5ac492f9304a8.tar.gz src-ddf5b79683713d343d3b2cb2b4e5ac492f9304a8.zip |
Add a line discipline close routine which restores some functionality
I accidently nuked in rev. 1.54. Also rework the error handling in
snplwrite a little.
Notes
Notes:
svn path=/head/; revision=77749
Diffstat (limited to 'sys/dev/snp/snp.c')
-rw-r--r-- | sys/dev/snp/snp.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 9755ef73ab9b..3a8e57651d22 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -26,6 +26,7 @@ #include <sys/snoop.h> #include <sys/vnode.h> +static l_close_t snplclose; static l_write_t snplwrite; static d_open_t snpopen; static d_close_t snpclose; @@ -52,7 +53,7 @@ static struct cdevsw snp_cdevsw = { }; static struct linesw snpdisc = { - ttyopen, ttylclose, ttread, snplwrite, + ttyopen, snplclose, ttread, snplwrite, l_nullioctl, ttyinput, ttstart, ttymodem }; @@ -72,6 +73,22 @@ static int snp_in __P((struct snoop *snp, char *buf, int n)); static int snp_modevent __P((module_t mod, int what, void *arg)); static int +snplclose(tp, flag) + struct tty *tp; + int flag; +{ + struct snoop *snp; + int error; + + snp = tp->t_sc; + error = snp_down(snp); + if (error != 0) + return (error); + error = ttylclose(tp, flag); + return (error); +} + +static int snplwrite(tp, uio, flag) struct tty *tp; struct uio *uio; @@ -84,12 +101,11 @@ snplwrite(tp, uio, flag) char ibuf[512]; snp = tp->t_sc; - error = 0; while (uio->uio_resid > 0) { ilen = imin(sizeof(ibuf), uio->uio_resid); error = uiomove(ibuf, ilen, uio); if (error != 0) - break; + return (error); snp_in(snp, ibuf, ilen); /* Hackish, but probably the least of all evils. */ iov.iov_base = ibuf; @@ -103,9 +119,9 @@ snplwrite(tp, uio, flag) uio2.uio_procp = uio->uio_procp; error = ttwrite(tp, &uio2, flag); if (error != 0) - break; + return (error); } - return (error); + return (0); } static struct tty * |