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/coda/coda_fbsd.cr,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
30 * $Id: coda_fbsd.c,v 1.10 1999/01/05 18:49:49 eivind Exp $
35 #include "opt_devfs.h"
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
41 #include <sys/malloc.h>
42 #include <sys/fcntl.h>
43 #include <sys/ucred.h>
44 #include <sys/vnode.h>
48 #include <vm/vnode_pager.h>
50 #include <coda/coda.h>
51 #include <coda/cnode.h>
52 #include <coda/coda_vnops.h>
53 #include <coda/coda_psdev.h>
56 #include <sys/devfsext.h>
58 static void *cfs_devfs_token[NVCODA];
59 static void *coda_devfs_token[NVCODA];
63 From: "Jordan K. Hubbard" <jkh@time.cdrom.com>
64 Subject: Re: New 3.0 SNAPshot CDROM about ready for production..
65 To: "Robert.V.Baron" <rvb@GLUCK.CODA.CS.CMU.EDU>
66 Date: Fri, 20 Feb 1998 15:57:01 -0800
68 > Also I need a character device major number. (and might want to reserve
69 > a block of 10 syscalls.)
71 Just one char device number? No block devices? Very well, cdev 93 is yours!
76 static struct cdevsw codadevsw =
78 vc_nb_open, vc_nb_close, vc_nb_read, vc_nb_write, /*93*/
79 vc_nb_ioctl, nostop, nullreset, nodevtotty,
80 vc_nb_poll, nommap, NULL, "Coda", NULL, -1
84 #define VCDEBUG if (vcdebug) printf
87 codadev_modevent(module_t mod, int type, void *data)
93 static struct cdevsw *oldcdevsw;
97 dev = makedev(VC_DEV_NO, 0);
98 cdevsw_add(&dev,&codadevsw, &oldcdevsw);
103 for (i = 0; i < NVCODA; i++) {
105 devfs_add_devswf(&codadevsw, i,
106 DV_CHR, UID_ROOT, GID_WHEEL, 0666,
108 coda_devfs_token[i] =
109 devfs_add_devswf(&codadevsw, i,
110 DV_CHR, UID_ROOT, GID_WHEEL, 0666,
117 for (i = 0; i < NVCODA; i++) {
118 devfs_remove_dev(cfs_devfs_token[i]);
119 devfs_remove_dev(coda_devfs_token[i]);
122 cdevsw_add(&dev, oldcdevsw, NULL);
129 static moduledata_t codadev_mod = {
134 DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO);
137 coda_fbsd_getpages(v)
140 struct vop_getpages_args *ap = v;
145 ret = vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
150 struct vnode *vp = ap->a_vp;
151 struct cnode *cp = VTOC(vp);
152 struct vnode *cfvp = cp->c_ovp;
153 int opened_internally = 0;
154 struct ucred *cred = (struct ucred *) 0;
155 struct proc *p = curproc;
162 /* Redirect the request to UFS. */
165 opened_internally = 1;
167 error = VOP_OPEN(vp, FREAD, cred, p);
168 printf("coda_getp: Internally Opening %p\n", vp);
171 printf("coda_getpage: VOP_OPEN on container failed %d\n", error);
174 if (vp->v_type == VREG) {
175 error = vfs_object_create(vp, p, cred);
177 printf("coda_getpage: vfs_object_create() returns %d\n", error);
185 printf("coda_getp: has container %p\n", cfvp);
188 printf("coda_fbsd_getpages: using container ");
190 error = vnode_pager_generic_getpages(cfvp, ap->a_m, ap->a_count,
193 error = VOP_GETPAGES(cfvp, ap->a_m, ap->a_count,
194 ap->a_reqpage, ap->a_offset);
195 printf("error = %d\n", error);
197 /* Do an internal close if necessary. */
198 if (opened_internally) {
199 (void)VOP_CLOSE(vp, FREAD, cred, p);
208 coda_fbsd_putpages(v)
211 struct vop_putpages_args *ap = v;
214 return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
215 ap->a_sync, ap->a_rtvals);