/**
 * Register VBoxFS filesystem.
 *
 * @returns IPRT status code.
 */
int VBoxVFSRegisterFilesystem(void)
{
    struct vfs_fsentry oVFsEntry;
    int rc;

    memset(&oVFsEntry, 0, sizeof(oVFsEntry));
    /* Attach filesystem operations set */
    oVFsEntry.vfe_vfsops = &g_oVBoxVFSOpts;
    /* Attach vnode operations */
    oVFsEntry.vfe_vopcnt = g_cVBoxVFSVnodeOpvDescListSize;
    oVFsEntry.vfe_opvdescs = g_VBoxVFSVnodeOpvDescList;
    /* Set flags */
    oVFsEntry.vfe_flags =
#if ARCH_BITS == 64
            VFS_TBL64BITREADY |
#endif
            VFS_TBLTHREADSAFE |
            VFS_TBLFSNODELOCK |
            VFS_TBLNOTYPENUM;

    memcpy(oVFsEntry.vfe_fsname, VBOXVBFS_NAME, MFSNAMELEN);

    rc = vfs_fsadd(&oVFsEntry, &g_oVBoxVFSHandle);
    if (rc)
    {
        PINFO("Unable to register VBoxVFS filesystem (%d)", rc);
        return VERR_GENERAL_FAILURE;
    }

    PINFO("VBoxVFS filesystem successfully registered");
    return VINF_SUCCESS;
}
Exemple #2
0
/*
 * KEXT entry point
 */
kern_return_t romfs_start (kmod_info_t * ki, void * d) {
	
	errno_t error;
	struct vfs_fsentry vfe;
	
	printf("Loading ROMFS.\n");
	
	/* VFS callbacks. */
	vfe.vfe_vfsops = &romfs_vfsops;
	
	/* We just have vnode operations for regular files and directories */
	vfe.vfe_vopcnt = 1;				
	vfe.vfe_opvdescs = romfs_vnodeop_opv_desc_list;
	strncpy(vfe.vfe_fsname, "romfs", 5);
	vfe.vfe_flags =		VFS_TBLTHREADSAFE |
	VFS_TBLNOTYPENUM |	
	VFS_TBLLOCALVOL |
	VFS_TBL64BITREADY |
	VFS_TBLNATIVEXATTR |
	VFS_TBLGENERICMNTARGS|
	VFS_TBLREADDIR_EXTENDED;
	vfe.vfe_reserv[0] = 0;
	vfe.vfe_reserv[1] = 0;
	
	/* Register. */
	error = vfs_fsadd(&vfe, &romfs_vfsconf);
	if(error)
		printf("Error registering ROMFS with VFS.\n");
	else
	    printf("Registered ROMFS with VFS.\n");
	return error ? KERN_FAILURE : KERN_SUCCESS;
}
/**
 * Start the kernel module.
 */
static kern_return_t vboxSfDwnModuleLoad(struct kmod_info *pKModInfo, void *pvData)
{
    RT_NOREF(pKModInfo, pvData);
#ifdef DEBUG
    printf("vboxSfDwnModuleLoad\n");
    RTLogBackdoorPrintf("vboxSfDwnModuleLoad\n");
#endif

    /*
     * Initialize IPRT and the ring-0 guest library.
     */
    int rc = RTR0Init(0);
    if (RT_SUCCESS(rc))
    {
        rc = VbglR0SfInit();
        if (RT_SUCCESS(rc))
        {
            /*
             * Register the file system.
             */
            rc = vfs_fsadd(&g_VBoxSfFsEntry, &g_pVBoxSfVfsTableEntry);
            if (rc == 0)
            {
                /*
                 * Try find VBoxGuest and connect to the shared folders service on the host.
                 */
                /** @todo should we just ignore the error here and retry at mount time?
                 * Technically, VBoxGuest should be available since it's one of our
                 * dependencies... */
                vboxSfDwnConnect();

                /*
                 * We're done for now.  We'll deal with
                 */
                LogRel(("VBoxSF: loaded\n"));
                return KERN_SUCCESS;
            }

            printf("VBoxSF: vfs_fsadd failed: %d\n", rc);
            RTLogBackdoorPrintf("VBoxSF: vfs_fsadd failed: %d\n", rc);
            VbglR0SfTerm();
        }
        else
        {
            printf("VBoxSF: VbglR0SfInit failed: %d\n", rc);
            RTLogBackdoorPrintf("VBoxSF: VbglR0SfInit failed: %Rrc\n", rc);
        }
        RTR0Term();
    }
    else
    {
        printf("VBoxSF: RTR0Init failed: %d\n", rc);
        RTLogBackdoorPrintf("VBoxSF: RTR0Init failed: %Rrc\n", rc);
    }
    return KERN_FAILURE;
}
Exemple #4
0
__private_extern__ kern_return_t
kext_start_9p(kmod_info_t *ki, void *d)
{
#pragma unused(ki)
#pragma unused(d)
	int e;

	TRACE();
	lck_grp_9p = lck_grp_alloc_init(VFS9PNAME, LCK_GRP_ATTR_NULL);
	if ((e=vfs_fsadd(&vfs_fsentry_9p, &vfstable_9p)))
		return KERN_FAILURE;

	return KERN_SUCCESS;
}
Exemple #5
0
int
zfs_module_start(__unused kmod_info_t *ki, __unused void *data)
{
	struct vfs_fsentry vfe;


	zfs_init();

	printf("zfs_module_start: memory footprint %d (kalloc %d, kernel %d)\n",
		zfs_footprint.current, zfs_kallocmap_size, zfs_kernelmap_size);
	
	vfe.vfe_vfsops = &zfs_vfsops_template;
	vfe.vfe_vopcnt = ZFS_VNOP_TBL_CNT;
	vfe.vfe_opvdescs = zfs_vnodeop_opv_desc_list;
#if 1
	strcpy(vfe.vfe_fsname, "zfs");
#else
	strlcpy(vfe.vfe_fsname, "zfs", sizeof(vfe.vfe_fsname));
#endif
	/*
	 * Note: must set VFS_TBLGENERICMNTARGS with VFS_TBLLOCALVOL
	 * to suppress local mount argument handling.
	 */
	vfe.vfe_flags = VFS_TBLTHREADSAFE |
	                VFS_TBLNOTYPENUM |
	                VFS_TBLLOCALVOL |
	                VFS_TBL64BITREADY |
	                VFS_TBLNATIVEXATTR |
	                VFS_TBLGENERICMNTARGS|
			VFS_TBLREADDIR_EXTENDED;
	vfe.vfe_reserv[0] = 0;
	vfe.vfe_reserv[1] = 0;
	
	if (vfs_fsadd(&vfe, &zfs_vfsconf) != 0)
		return KERN_FAILURE;
	else
		return KERN_SUCCESS;
}