3 * Coda: an Experimental Distributed File System
6 * Copyright (c) 1987-1998 Carnegie Mellon University
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
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.
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.
29 * @(#) src/sys/cfs/cfs_fbsd.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
30 * $Id: cfs_fbsd.c,v 1.2 1998/09/02 19:09:53 rvb Exp $
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
38 #include <sys/malloc.h>
39 #include <sys/fcntl.h>
40 #include <sys/ucred.h>
41 #include <sys/vnode.h>
45 #include <vm/vnode_pager.h>
48 #include <cfs/cnode.h>
49 #include <cfs/cfs_vnodeops.h>
52 #include <sys/devfsext.h>
56 From: "Jordan K. Hubbard" <jkh@time.cdrom.com>
57 Subject: Re: New 3.0 SNAPshot CDROM about ready for production..
58 To: "Robert.V.Baron" <rvb@GLUCK.CODA.CS.CMU.EDU>
59 Date: Fri, 20 Feb 1998 15:57:01 -0800
61 > Also I need a character device major number. (and might want to reserve
62 > a block of 10 syscalls.)
64 Just one char device number? No block devices? Very well, cdev 93 is yours!
69 /* Type of device methods. */
70 extern d_open_t vc_nb_open;
71 extern d_close_t vc_nb_close;
72 extern d_read_t vc_nb_read;
73 extern d_write_t vc_nb_write;
74 extern d_ioctl_t vc_nb_ioctl;
75 extern d_poll_t vc_nb_poll;
77 static struct cdevsw vccdevsw =
79 vc_nb_open, vc_nb_close, vc_nb_read, vc_nb_write, /*93*/
80 vc_nb_ioctl, nostop, nullreset, nodevtotty,
81 vc_nb_poll, nommap, NULL, "Coda", NULL, -1
84 void vcattach __P((void));
88 #define VCDEBUG if (vcdebug) printf
94 * In case we are an LKM, set up device switch.
96 if (0 == (vccdev = makedev(VC_DEV_NO, 0)))
97 VCDEBUG("makedev returned null\n");
99 VCDEBUG("makedev OK.\n");
101 cdevsw_add(&vccdev, &vccdevsw, NULL);
102 VCDEBUG("coda: vccdevsw entry installed at %d.\n", major(vccdev));
105 static vc_devsw_installed = 0;
106 static void vc_drvinit __P((void *unused));
109 vc_drvinit(void *unused)
113 if( ! vc_devsw_installed ) {
114 dev = makedev(VC_DEV_NO, 0);
115 cdevsw_add(&dev,&vccdevsw, NULL);
116 vc_devsw_installed = 1;
121 coda_fbsd_getpages(v)
124 struct vop_getpages_args *ap = v;
125 struct vnode *vp = ap->a_vp;
126 struct cnode *cp = VTOC(vp);
131 ret = vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
136 struct vnode *vp = ap->a_vp;
137 struct cnode *cp = VTOC(vp);
138 struct vnode *cfvp = cp->c_ovp;
139 int opened_internally = 0;
140 struct ucred *cred = (struct ucred *) 0;
141 struct proc *p = curproc;
148 /* Redirect the request to UFS. */
151 opened_internally = 1;
153 error = VOP_OPEN(vp, FREAD, cred, p);
154 printf("coda_getp: Internally Opening %p\n", vp);
157 printf("coda_getpage: VOP_OPEN on container failed %d\n", error);
160 if (vp->v_type == VREG) {
161 error = vfs_object_create(vp, p, cred, 1);
163 printf("coda_getpage: vfs_object_create() returns %d\n", error);
171 printf("coda_getp: has container %p\n", cfvp);
174 printf("coda_fbsd_getpages: using container ");
176 error = vnode_pager_generic_getpages(cfvp, ap->a_m, ap->a_count,
179 error = VOP_GETPAGES(cfvp, ap->a_m, ap->a_count,
180 ap->a_reqpage, ap->a_offset);
181 printf("error = %d\n", error);
183 /* Do an internal close if necessary. */
184 if (opened_internally) {
185 (void)VOP_CLOSE(vp, FREAD, cred, p);
194 coda_fbsd_putpages(v)
197 struct vop_putpages_args *ap = v;
200 return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
201 ap->a_sync, ap->a_rtvals);
205 SYSINIT(vccdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+VC_DEV_NO,vc_drvinit,NULL)