Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / vfs / 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: src/sys/coda/coda_fbsd.c,v 1.18 1999/09/25 18:23:43 phk Exp $
31  * $DragonFly: src/sys/vfs/coda/Attic/coda_fbsd.c,v 1.2 2003/06/17 04:28:19 dillon Exp $
32  * 
33  */
34
35 #include "vcoda.h"
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/proc.h>
41 #include <sys/malloc.h>
42 #include <sys/fcntl.h>
43 #include <sys/ucred.h>
44 #include <sys/vnode.h>
45 #include <sys/conf.h>
46
47 #include <vm/vm.h>
48 #include <vm/vnode_pager.h>
49
50 #include <coda/coda.h>
51 #include <coda/cnode.h>
52 #include <coda/coda_vnops.h>
53 #include <coda/coda_psdev.h>
54
55 /* 
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
60
61    > Also I need a character device major number. (and might want to reserve
62    > a block of 10 syscalls.)
63
64    Just one char device number?  No block devices?  Very well, cdev 93 is yours!
65 */
66
67 #define VC_DEV_NO      93
68
69 static struct cdevsw codadevsw = {
70         /* open */      vc_nb_open,
71         /* close */     vc_nb_close,
72         /* read */      vc_nb_read,
73         /* write */     vc_nb_write,
74         /* ioctl */     vc_nb_ioctl,
75         /* poll */      vc_nb_poll,
76         /* mmap */      nommap,
77         /* strategy */  nostrategy,
78         /* name */      "Coda",
79         /* maj */       VC_DEV_NO,
80         /* dump */      nodump,
81         /* psize */     nopsize,
82         /* flags */     0,
83         /* bmaj */      -1
84 };
85
86 int     vcdebug = 1;
87 #define VCDEBUG if (vcdebug) printf
88
89 static int
90 codadev_modevent(module_t mod, int type, void *data)
91 {
92
93         switch (type) {
94         case MOD_LOAD:
95                 cdevsw_add(&codadevsw);
96                 break;
97         case MOD_UNLOAD:
98                 break;
99         default:
100                 break;
101         }
102         return 0;
103 }
104 static moduledata_t codadev_mod = {
105         "codadev",
106         codadev_modevent,
107         NULL
108 };
109 DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO);
110
111 int
112 coda_fbsd_getpages(v)
113         void *v;
114 {
115     struct vop_getpages_args *ap = v;
116     int ret = 0;
117
118 #if     1
119         /* ??? a_offset */
120         ret = vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
121                 ap->a_reqpage);
122         return ret;
123 #else
124   {
125     struct vnode *vp = ap->a_vp;
126     struct cnode *cp = VTOC(vp);
127     struct vnode *cfvp = cp->c_ovp;
128     int opened_internally = 0;
129     struct ucred *cred = (struct ucred *) 0;
130     struct proc *p = curproc;
131     int error = 0;
132         
133     if (IS_CTL_VP(vp)) {
134         return(EINVAL);
135     }
136
137     /* Redirect the request to UFS. */
138
139     if (cfvp == NULL) {
140         opened_internally = 1;
141
142         error = VOP_OPEN(vp, FREAD,  cred, p);
143 printf("coda_getp: Internally Opening %p\n", vp);
144
145         if (error) {
146             printf("coda_getpage: VOP_OPEN on container failed %d\n", error);
147                 return (error);
148         }
149         if (vp->v_type == VREG) {
150             error = vfs_object_create(vp, p, cred);
151             if (error != 0) {
152                 printf("coda_getpage: vfs_object_create() returns %d\n", error);
153                 vput(vp);
154                 return(error);
155             }
156         }
157
158         cfvp = cp->c_ovp;
159     } else {
160 printf("coda_getp: has container %p\n", cfvp);
161     }
162
163 printf("coda_fbsd_getpages: using container ");
164 /*
165     error = vnode_pager_generic_getpages(cfvp, ap->a_m, ap->a_count,
166         ap->a_reqpage);
167 */
168     error = VOP_GETPAGES(cfvp, ap->a_m, ap->a_count,
169         ap->a_reqpage, ap->a_offset);
170 printf("error = %d\n", error);
171
172     /* Do an internal close if necessary. */
173     if (opened_internally) {
174         (void)VOP_CLOSE(vp, FREAD, cred, p);
175     }
176
177     return(error);
178   }
179 #endif
180 }
181
182 int
183 coda_fbsd_putpages(v)
184         void *v;
185 {
186         struct vop_putpages_args *ap = v;
187
188         /*??? a_offset */
189         return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
190                 ap->a_sync, ap->a_rtvals);
191 }