Deleted Added
sdiff udiff text old ( 12595 ) new ( 12769 )
full compact
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * John Heidemann of the UCLA Ficus project.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)null_vnops.c 8.1 (Berkeley) 6/10/93
37 *
38 * $Id: null_vnops.c,v 1.10 1995/12/03 14:54:24 bde Exp $
39 */
40
41/*
42 * Null Layer
43 *
44 * (See mount_null(8) for more information.)
45 *
46 * The null layer duplicates a portion of the file system

--- 111 unchanged lines hidden (view full) ---

158 * arbitrary operations on the lower layer. The disadvantage
159 * is that vnodes arguments must be manualy mapped.
160 *
161 */
162
163#include <sys/param.h>
164#include <sys/systm.h>
165#include <sys/kernel.h>
166#include <sys/sysctl.h>
167#include <sys/proc.h>
168#include <sys/time.h>
169#include <sys/types.h>
170#include <sys/vnode.h>
171#include <sys/mount.h>
172#include <sys/namei.h>
173#include <sys/malloc.h>
174#include <sys/buf.h>
175#include <miscfs/nullfs/null.h>
176
177static int null_bug_bypass = 0; /* for debugging: enables bypass printf'ing */
178SYSCTL_INT(_debug, OID_AUTO, nullfs_bug_bypass, CTLFLAG_RW,
179 &null_bug_bypass, 0, "");
180
181static int null_bypass __P((struct vop_generic_args *ap));
182static int null_bwrite __P((struct vop_bwrite_args *ap));
183static int null_getattr __P((struct vop_getattr_args *ap));
184static int null_inactive __P((struct vop_inactive_args *ap));
185static int null_print __P((struct vop_print_args *ap));
186static int null_reclaim __P((struct vop_reclaim_args *ap));
187static int null_strategy __P((struct vop_strategy_args *ap));
188
189/*
190 * This is the 10-Apr-92 bypass routine.
191 * This version has been optimized for speed, throwing away some
192 * safety checks. It should still always work, but it's not as
193 * robust to programmer errors.
194 * Define SAFETY to include some error checking code.
195 *

--- 10 unchanged lines hidden (view full) ---

206 * This makes the following assumptions:
207 * - only one returned vpp
208 * - no INOUT vpp's (Sun's vop_open has one of these)
209 * - the vnode operation vector of the first vnode should be used
210 * to determine what implementation of the op should be invoked
211 * - all mapped vnodes are of our vnode-type (NEEDSWORK:
212 * problems on rmdir'ing mount points and renaming?)
213 */
214static int
215null_bypass(ap)
216 struct vop_generic_args /* {
217 struct vnodeop_desc *a_desc;
218 <other random data follows, presumably>
219 } */ *ap;
220{
221 register struct vnode **this_vp_p;
222 int error;

--- 93 unchanged lines hidden (view full) ---

316 out:
317 return (error);
318}
319
320
321/*
322 * We handle getattr only to change the fsid.
323 */
324static int
325null_getattr(ap)
326 struct vop_getattr_args /* {
327 struct vnode *a_vp;
328 struct vattr *a_vap;
329 struct ucred *a_cred;
330 struct proc *a_p;
331 } */ *ap;
332{
333 int error;
334 error = null_bypass(ap);
335 if (error)
336 return (error);
337 /* Requires that arguments be restored. */
338 ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
339 return (0);
340}
341
342
343static int
344null_inactive(ap)
345 struct vop_inactive_args /* {
346 struct vnode *a_vp;
347 } */ *ap;
348{
349 /*
350 * Do nothing (and _don't_ bypass).
351 * Wait to vrele lowervp until reclaim,

--- 4 unchanged lines hidden (view full) ---

356 * the lowervp and then trying to reactivate it
357 * with capabilities (v_id)
358 * like they do in the name lookup cache code.
359 * That's too much work for now.
360 */
361 return (0);
362}
363
364static int
365null_reclaim(ap)
366 struct vop_reclaim_args /* {
367 struct vnode *a_vp;
368 } */ *ap;
369{
370 struct vnode *vp = ap->a_vp;
371 struct null_node *xp = VTONULL(vp);
372 struct vnode *lowervp = xp->null_lowervp;

--- 7 unchanged lines hidden (view full) ---

380 remque(xp);
381 FREE(vp->v_data, M_TEMP);
382 vp->v_data = NULL;
383 vrele (lowervp);
384 return (0);
385}
386
387
388static int
389null_print(ap)
390 struct vop_print_args /* {
391 struct vnode *a_vp;
392 } */ *ap;
393{
394 register struct vnode *vp = ap->a_vp;
395 printf ("\ttag VT_NULLFS, vp=%p, lowervp=%p\n", vp, NULLVPTOLOWERVP(vp));
396 return (0);
397}
398
399
400/*
401 * XXX - vop_strategy must be hand coded because it has no
402 * vnode in its arguments.
403 * This goes away with a merged VM/buffer cache.
404 */
405static int
406null_strategy(ap)
407 struct vop_strategy_args /* {
408 struct buf *a_bp;
409 } */ *ap;
410{
411 struct buf *bp = ap->a_bp;
412 int error;
413 struct vnode *savedvp;

--- 9 unchanged lines hidden (view full) ---

423}
424
425
426/*
427 * XXX - like vop_strategy, vop_bwrite must be hand coded because it has no
428 * vnode in its arguments.
429 * This goes away with a merged VM/buffer cache.
430 */
431static int
432null_bwrite(ap)
433 struct vop_bwrite_args /* {
434 struct buf *a_bp;
435 } */ *ap;
436{
437 struct buf *bp = ap->a_bp;
438 int error;
439 struct vnode *savedvp;

--- 7 unchanged lines hidden (view full) ---

447
448 return (error);
449}
450
451/*
452 * Global vfs data structures
453 */
454vop_t **null_vnodeop_p;
455static struct vnodeopv_entry_desc null_vnodeop_entries[] = {
456 { &vop_default_desc, (vop_t *)null_bypass },
457
458 { &vop_getattr_desc, (vop_t *)null_getattr },
459 { &vop_inactive_desc, (vop_t *)null_inactive },
460 { &vop_reclaim_desc, (vop_t *)null_reclaim },
461 { &vop_print_desc, (vop_t *)null_print },
462
463 { &vop_strategy_desc, (vop_t *)null_strategy },
464 { &vop_bwrite_desc, (vop_t *)null_bwrite },
465
466 { NULL, NULL }
467};
468static struct vnodeopv_desc null_vnodeop_opv_desc =
469 { &null_vnodeop_p, null_vnodeop_entries };
470
471VNODEOP_SET(null_vnodeop_opv_desc);