Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Call file descriptor stat function via (*fp->f_ops->fo_s...



details:   https://anonhg.NetBSD.org/src/rev/0466f58bc243
branches:  trunk
changeset: 508221:0466f58bc243
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 09 09:39:09 2001 +0000

description:
Call file descriptor stat function via (*fp->f_ops->fo_stat) instead
of a switch statement and explicit call.
Sprinkle some FILE_USE()/FILE_UNUSE() as appropriate.

diffstat:

 sys/compat/netbsd32/netbsd32_fs.c |  17 ++++-------------
 sys/compat/osf1/osf1_descrip.c    |  19 +++----------------
 sys/miscfs/fdesc/fdesc_vnops.c    |   6 ++++--
 3 files changed, 11 insertions(+), 31 deletions(-)

diffs (92 lines):

diff -r 134e33d4b674 -r 0466f58bc243 sys/compat/netbsd32/netbsd32_fs.c
--- a/sys/compat/netbsd32/netbsd32_fs.c Mon Apr 09 09:29:54 2001 +0000
+++ b/sys/compat/netbsd32/netbsd32_fs.c Mon Apr 09 09:39:09 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_fs.c,v 1.2 2001/04/08 08:01:36 ross Exp $     */
+/*     $NetBSD: netbsd32_fs.c,v 1.3 2001/04/09 09:39:10 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -600,20 +600,11 @@
        if ((u_int)fd >= fdp->fd_nfiles ||
            (fp = fdp->fd_ofiles[fd]) == NULL)
                return (EBADF);
-       switch (fp->f_type) {
-
-       case DTYPE_VNODE:
-               error = vn_stat((struct vnode *)fp->f_data, &ub, p);
-               break;
 
-       case DTYPE_SOCKET:
-               error = soo_stat((struct socket *)fp->f_data, &ub, p);
-               break;
+       FILE_USE(fp);
+       error = (*fp->f_ops->fo_stat)(fp->f_data, &ub, p);
+       FILE_UNUSE(fp, p);
 
-       default:
-               panic("fstat");
-               /*NOTREACHED*/
-       }
        if (error == 0) {
                netbsd32_from___stat13(&ub, &sb32);
                error = copyout(&sb32, (caddr_t)(u_long)SCARG(uap, sb), sizeof(sb32));
diff -r 134e33d4b674 -r 0466f58bc243 sys/compat/osf1/osf1_descrip.c
--- a/sys/compat/osf1/osf1_descrip.c    Mon Apr 09 09:29:54 2001 +0000
+++ b/sys/compat/osf1/osf1_descrip.c    Mon Apr 09 09:39:09 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: osf1_descrip.c,v 1.8 2001/04/08 08:01:36 ross Exp $ */
+/* $NetBSD: osf1_descrip.c,v 1.9 2001/04/09 09:39:10 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -248,27 +248,14 @@
                return (EBADF);
 
        FILE_USE(fp);
-
-       switch (fp->f_type) {
-
-       case DTYPE_VNODE:
-               error = vn_stat((struct vnode *)fp->f_data, &ub, p);
-               break;
+       error = (*fp->f_ops->fo_stat)(fp->f_data, &ub, p);
+       FILE_UNUSE(fp, p);
 
-       case DTYPE_SOCKET:
-               error = soo_stat((struct socket *)fp->f_data, &ub, p);
-               break;
-
-       default:
-               panic("ofstat");
-               /*NOTREACHED*/
-       }
        osf1_cvt_stat_from_native(&ub, &oub);
        if (error == 0)
                error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb),
                    sizeof (oub));
 
-       FILE_UNUSE(fp, p);
        return (error);
 }
 
diff -r 134e33d4b674 -r 0466f58bc243 sys/miscfs/fdesc/fdesc_vnops.c
--- a/sys/miscfs/fdesc/fdesc_vnops.c    Mon Apr 09 09:29:54 2001 +0000
+++ b/sys/miscfs/fdesc/fdesc_vnops.c    Mon Apr 09 09:39:09 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdesc_vnops.c,v 1.60 2001/04/07 17:37:09 jdolecek Exp $        */
+/*     $NetBSD: fdesc_vnops.c,v 1.61 2001/04/09 09:39:09 jdolecek Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -488,7 +488,9 @@
                break;
 
        case DTYPE_SOCKET:
-               error = soo_stat(fp->f_data, &stb, p);
+               FILE_USE(fp);
+               error = (*fp->f_ops->fo_stat)(fp->f_data, &stb, p);
+               FILE_UNUSE(fp, p);
                if (error == 0) {
                        vattr_null(vap);
                        vap->va_type = VSOCK;



Home | Main Index | Thread Index | Old Index