static int v7fs_mountfs(struct vnode *devvp, struct mount *mp, int endian) { struct v7fs_mount *v7fsmount; int error; struct v7fs_mount_device mount; DPRINTF("%d\n",endian); v7fsmount = kmem_zalloc(sizeof(*v7fsmount), KM_SLEEP); if (v7fsmount == NULL) { return ENOMEM; } v7fsmount->devvp = devvp; v7fsmount->mountp = mp; mount.device.vnode = devvp; mount.endian = endian; if ((error = v7fs_io_init(&v7fsmount->core, &mount, V7FS_BSIZE))) { goto err_exit; } struct v7fs_self *fs = v7fsmount->core; if ((error = v7fs_superblock_load(fs))) { v7fs_io_fini(fs); goto err_exit; } LIST_INIT(&v7fsmount->v7fs_node_head); mp->mnt_data = v7fsmount; mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)devvp->v_rdev; mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_V7FS); mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0]; mp->mnt_stat.f_namemax = V7FS_NAME_MAX; mp->mnt_flag |= MNT_LOCAL; mp->mnt_dev_bshift = V7FS_BSHIFT; mp->mnt_fs_bshift = V7FS_BSHIFT; return 0; err_exit: kmem_free(v7fsmount, sizeof(*v7fsmount)); return error; }
static int partition_check(struct v7fs_self *fs) { struct v7fs_superblock *sb = &fs->superblock; int error; if ((error = v7fs_superblock_load(fs))) { if (error != EINVAL) { /* Invalid superblock information is OK. */ warnx("Can't read superblock sector."); } } sb->modified = 1; if ((error = v7fs_superblock_writeback(fs))) { if (errno == EROFS) { warnx("Overwriting disk label? "); } warnx("Can't write superblock sector."); } return error; }