]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/coda/coda_fbsd.c
This commit was generated by cvs2svn to compensate for changes in r50760,
[FreeBSD/FreeBSD.git] / sys / coda / coda_fbsd.c
1 /*
2  * 
3  *             Coda: an Experimental Distributed File System
4  *                              Release 3.1
5  * 
6  *           Copyright (c) 1987-1998 Carnegie Mellon University
7  *                          All Rights Reserved
8  * 
9  * Permission  to  use, copy, modify and distribute this software and its
10  * documentation is hereby granted,  provided  that  both  the  copyright
11  * notice  and  this  permission  notice  appear  in  all  copies  of the
12  * software, derivative works or  modified  versions,  and  any  portions
13  * thereof, and that both notices appear in supporting documentation, and
14  * that credit is given to Carnegie Mellon University  in  all  documents
15  * and publicity pertaining to direct or indirect use of this code or its
16  * derivatives.
17  * 
18  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
19  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
20  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
21  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
22  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
23  * ANY DERIVATIVE WORK.
24  * 
25  * Carnegie  Mellon  encourages  users  of  this  software  to return any
26  * improvements or extensions that  they  make,  and  to  grant  Carnegie
27  * Mellon the rights to redistribute these changes without encumbrance.
28  * 
29  *      @(#) src/sys/coda/coda_fbsd.cr,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
30  * $FreeBSD$
31  * 
32  */
33
34 #include "vcoda.h"
35
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/proc.h>
40 #include <sys/malloc.h>
41 #include <sys/fcntl.h>
42 #include <sys/ucred.h>
43 #include <sys/vnode.h>
44 #include <sys/conf.h>
45
46 #include <vm/vm.h>
47 #include <vm/vnode_pager.h>
48
49 #include <coda/coda.h>
50 #include <coda/cnode.h>
51 #include <coda/coda_vnops.h>
52 #include <coda/coda_psdev.h>
53
54 /* 
55    From: "Jordan K. Hubbard" <jkh@time.cdrom.com>
56    Subject: Re: New 3.0 SNAPshot CDROM about ready for production.. 
57    To: "Robert.V.Baron" <rvb@GLUCK.CODA.CS.CMU.EDU>
58    Date: Fri, 20 Feb 1998 15:57:01 -0800
59
60    > Also I need a character device major number. (and might want to reserve
61    > a block of 10 syscalls.)
62
63    Just one char device number?  No block devices?  Very well, cdev 93 is yours!
64 */
65
66 #define VC_DEV_NO      93
67
68 static struct cdevsw codadevsw = {
69         /* open */      vc_nb_open,
70         /* close */     vc_nb_close,
71         /* read */      vc_nb_read,
72         /* write */     vc_nb_write,
73         /* ioctl */     vc_nb_ioctl,
74         /* stop */      nostop,
75         /* reset */     noreset,
76         /* devtotty */  nodevtotty,
77         /* poll */      vc_nb_poll,
78         /* mmap */      nommap,
79         /* strategy */  nostrategy,
80         /* name */      "Coda",
81         /* parms */     noparms,
82         /* maj */       VC_DEV_NO,
83         /* dump */      nodump,
84         /* psize */     nopsize,
85         /* flags */     0,
86         /* maxio */     0,
87         /* bmaj */      -1
88 };
89
90 int     vcdebug = 1;
91 #define VCDEBUG if (vcdebug) printf
92
93 static int
94 codadev_modevent(module_t mod, int type, void *data)
95 {
96
97         switch (type) {
98         case MOD_LOAD:
99                 cdevsw_add(&codadevsw);
100                 break;
101         case MOD_UNLOAD:
102                 break;
103         default:
104                 break;
105         }
106         return 0;
107 }
108 static moduledata_t codadev_mod = {
109         "codadev",
110         codadev_modevent,
111         NULL
112 };
113 DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO);
114
115 int
116 coda_fbsd_getpages(v)
117         void *v;
118 {
119     struct vop_getpages_args *ap = v;
120     int ret = 0;
121
122 #if     1
123         /* ??? a_offset */
124         ret = vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
125                 ap->a_reqpage);
126         return ret;
127 #else
128   {
129     struct vnode *vp = ap->a_vp;
130     struct cnode *cp = VTOC(vp);
131     struct vnode *cfvp = cp->c_ovp;
132     int opened_internally = 0;
133     struct ucred *cred = (struct ucred *) 0;
134     struct proc *p = curproc;
135     int error = 0;
136         
137     if (IS_CTL_VP(vp)) {
138         return(EINVAL);
139     }
140
141     /* Redirect the request to UFS. */
142
143     if (cfvp == NULL) {
144         opened_internally = 1;
145
146         error = VOP_OPEN(vp, FREAD,  cred, p);
147 printf("coda_getp: Internally Opening %p\n", vp);
148
149         if (error) {
150             printf("coda_getpage: VOP_OPEN on container failed %d\n", error);
151                 return (error);
152         }
153         if (vp->v_type == VREG) {
154             error = vfs_object_create(vp, p, cred);
155             if (error != 0) {
156                 printf("coda_getpage: vfs_object_create() returns %d\n", error);
157                 vput(vp);
158                 return(error);
159             }
160         }
161
162         cfvp = cp->c_ovp;
163     } else {
164 printf("coda_getp: has container %p\n", cfvp);
165     }
166
167 printf("coda_fbsd_getpages: using container ");
168 /*
169     error = vnode_pager_generic_getpages(cfvp, ap->a_m, ap->a_count,
170         ap->a_reqpage);
171 */
172     error = VOP_GETPAGES(cfvp, ap->a_m, ap->a_count,
173         ap->a_reqpage, ap->a_offset);
174 printf("error = %d\n", error);
175
176     /* Do an internal close if necessary. */
177     if (opened_internally) {
178         (void)VOP_CLOSE(vp, FREAD, cred, p);
179     }
180
181     return(error);
182   }
183 #endif
184 }
185
186 int
187 coda_fbsd_putpages(v)
188         void *v;
189 {
190         struct vop_putpages_args *ap = v;
191
192         /*??? a_offset */
193         return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
194                 ap->a_sync, ap->a_rtvals);
195 }