Annotation of prex-old/usr/server/fs/arfs/arfs_vfsops.c, Revision 1.1
1.1 ! nbrk 1: /*
! 2: * Copyright (c) 2006-2007, Kohsuke Ohtani
! 3: * All rights reserved.
! 4: *
! 5: * Redistribution and use in source and binary forms, with or without
! 6: * modification, are permitted provided that the following conditions
! 7: * are met:
! 8: * 1. Redistributions of source code must retain the above copyright
! 9: * notice, this list of conditions and the following disclaimer.
! 10: * 2. Redistributions in binary form must reproduce the above copyright
! 11: * notice, this list of conditions and the following disclaimer in the
! 12: * documentation and/or other materials provided with the distribution.
! 13: * 3. Neither the name of the author nor the names of any co-contributors
! 14: * may be used to endorse or promote products derived from this software
! 15: * without specific prior written permission.
! 16: *
! 17: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
! 18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 20: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
! 21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 27: * SUCH DAMAGE.
! 28: */
! 29:
! 30: #include <sys/vnode.h>
! 31: #include <sys/mount.h>
! 32: #include <sys/param.h>
! 33: #include <sys/buf.h>
! 34:
! 35: #include <stdlib.h>
! 36: #include <string.h>
! 37: #include <errno.h>
! 38: #include <ar.h>
! 39:
! 40: #include "arfs.h"
! 41:
! 42: extern struct vnops arfs_vnops;
! 43:
! 44:
! 45: static int arfs_mount(mount_t mp, char *dev, int flags, void *data);
! 46: static int arfs_unmount(mount_t mp);
! 47: #define arfs_sync ((vfsop_sync_t)vfs_nullop)
! 48: #define arfs_vget ((vfsop_vget_t)vfs_nullop)
! 49: #define arfs_statfs ((vfsop_statfs_t)vfs_nullop)
! 50:
! 51: /*
! 52: * File system operations
! 53: */
! 54: const struct vfsops arfs_vfsops = {
! 55: arfs_mount, /* mount */
! 56: arfs_unmount, /* unmount */
! 57: arfs_sync, /* sync */
! 58: arfs_vget, /* vget */
! 59: arfs_statfs, /* statfs */
! 60: &arfs_vnops, /* vnops */
! 61: };
! 62:
! 63: /*
! 64: * Mount a file system.
! 65: */
! 66: static int
! 67: arfs_mount(mount_t mp, char *dev, int flags, void *data)
! 68: {
! 69: size_t size;
! 70: char *buf;
! 71: int err = 0;
! 72:
! 73: dprintf("arfs_mount: dev=%s\n", dev);
! 74:
! 75: if ((buf = malloc(BSIZE)) == NULL)
! 76: return ENOMEM;
! 77:
! 78: /* Read first block */
! 79: size = BSIZE;
! 80: err = device_read((device_t)mp->m_dev, buf, &size, 0);
! 81: if (err) {
! 82: dprintf("arfs_mount: read error=%d\n", err);
! 83: goto out;
! 84: }
! 85:
! 86: /* Check if the device includes valid archive image. */
! 87: if (strncmp(buf, ARMAG, SARMAG)) {
! 88: dprintf("invalid archive image!\n");
! 89: err = EINVAL;
! 90: goto out;
! 91: }
! 92:
! 93: /* Ok, we find the archive */
! 94: mp->m_flags |= MNT_RDONLY;
! 95: out:
! 96: free(buf);
! 97: return err;
! 98: }
! 99:
! 100: static int
! 101: arfs_unmount(mount_t mp)
! 102: {
! 103: return 0;
! 104: }
CVSweb