diff options
author | green <green@FreeBSD.org> | 1999-09-19 17:00:25 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 1999-09-19 17:00:25 +0000 |
commit | 140cb4ff83b0061eeba0756f708f3f7c117e76e5 (patch) | |
tree | dbfb58e46547ab96401ba9719626c5b12448fbfd /sys/compat/svr4/svr4_ttold.c | |
parent | c171f3b18205ec5324a32cba54aff58ae5594701 (diff) | |
download | FreeBSD-src-140cb4ff83b0061eeba0756f708f3f7c117e76e5.zip FreeBSD-src-140cb4ff83b0061eeba0756f708f3f7c117e76e5.tar.gz |
This is what was "fdfix2.patch," a fix for fd sharing. It's pretty
far-reaching in fd-land, so you'll want to consult the code for
changes. The biggest change is that now, you don't use
fp->f_ops->fo_foo(fp, bar)
but instead
fo_foo(fp, bar),
which increments and decrements the fp refcount upon entry and exit.
Two new calls, fhold() and fdrop(), are provided. Each does what it
seems like it should, and if fdrop() brings the refcount to zero, the
fd is freed as well.
Thanks to peter ("to hell with it, it looks ok to me.") for his review.
Thanks to msmith for keeping me from putting locks everywhere :)
Reviewed by: peter
Diffstat (limited to 'sys/compat/svr4/svr4_ttold.c')
-rw-r--r-- | sys/compat/svr4/svr4_ttold.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c index d597691..699d44d 100644 --- a/sys/compat/svr4/svr4_ttold.c +++ b/sys/compat/svr4/svr4_ttold.c @@ -196,8 +196,6 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) caddr_t data; { int error; - int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) = - fp->f_ops->fo_ioctl; *retval = 0; @@ -206,8 +204,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) { pid_t pid; - if ((error = (*ctl)(fp, TIOCGPGRP, - (caddr_t) &pid, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGPGRP, (caddr_t) &pid, p)) != 0) return error; DPRINTF(("TIOCGPGRP %d\n", pid)); @@ -226,15 +223,14 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) DPRINTF(("TIOCSPGRP %d\n", pid)); - return (*ctl)(fp, TIOCSPGRP, (caddr_t) &pid, p); + return fo_ioctl(fp, TIOCSPGRP, (caddr_t) &pid, p); } case SVR4_TIOCGSID: { #if defined(TIOCGSID) pid_t pid; - if ((error = (*ctl)(fp, TIOCGSID, - (caddr_t) &pid, p)) != 0) + if ((error = fo_ioctl(fp, TIOCGSID, (caddr_t) &pid, p)) != 0) return error; DPRINTF(("TIOCGSID %d\n", pid)); @@ -251,7 +247,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) struct sgttyb bs; struct svr4_sgttyb ss; - error = (*ctl)(fp, TIOCGETP, (caddr_t) &bs, p); + error = fo_ioctl(fp, TIOCGETP, (caddr_t) &bs, p); if (error) return error; @@ -276,7 +272,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss); #endif /* DEBUG_SVR4 */ cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN; - return (*ctl)(fp, cmd, (caddr_t) &bs, p); + return fo_ioctl(fp, cmd, (caddr_t) &bs, p); } case SVR4_TIOCGETC: @@ -284,7 +280,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) struct tchars bt; struct svr4_tchars st; - error = (*ctl)(fp, TIOCGETC, (caddr_t) &bt, p); + error = fo_ioctl(fp, TIOCGETC, (caddr_t) &bt, p); if (error) return error; @@ -307,7 +303,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) #ifdef DEBUG_SVR4 print_svr4_tchars("SVR4_TIOCSETC", &st); #endif /* DEBUG_SVR4 */ - return (*ctl)(fp, TIOCSETC, (caddr_t) &bt, p); + return fo_ioctl(fp, TIOCSETC, (caddr_t) &bt, p); } case SVR4_TIOCGLTC: @@ -315,7 +311,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) struct ltchars bl; struct svr4_ltchars sl; - error = (*ctl)(fp, TIOCGLTC, (caddr_t) &bl, p); + error = fo_ioctl(fp, TIOCGLTC, (caddr_t) &bl, p); if (error) return error; @@ -338,14 +334,13 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) #ifdef DEBUG_SVR4 print_svr4_ltchars("SVR4_TIOCSLTC", &sl); #endif /* DEBUG_SVR4 */ - return (*ctl)(fp, TIOCSLTC, (caddr_t) &bl, p); + return fo_ioctl(fp, TIOCSLTC, (caddr_t) &bl, p); } case SVR4_TIOCLGET: { int flags; - if ((error = (*ctl)(fp, TIOCLGET, - (caddr_t) &flags, p)) != 0) + if ((error = fo_ioctl(fp, TIOCLGET, (caddr_t) &flags, p)) != 0) return error; DPRINTF(("SVR4_TIOCLGET %o\n", flags)); return copyout(&flags, data, sizeof(flags)); @@ -373,7 +368,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data) } DPRINTF(("SVR4_TIOCL{SET,BIS,BIC} %o\n", flags)); - return (*ctl)(fp, cmd, (caddr_t) &flags, p); + return fo_ioctl(fp, cmd, (caddr_t) &flags, p); } default: |