VirtualBox

儲存庫 vbox 的更動 62694


忽略:
時間撮記:
2016-7-29 下午02:09:08 (8 年 以前)
作者:
vboxsync
訊息:

bugref:4567: Linux kernel driver maintenance: remove old code for creating vboxdrv as a non-misc character device, and for using devfs.

位置:
trunk/src/VBox/HostDrivers/Support/linux
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r62490 r62694  
    5353
    5454#include <linux/sched.h>
    55 #ifdef CONFIG_DEVFS_FS
    56 # include <linux/devfs_fs_kernel.h>
    57 #endif
    58 #ifdef CONFIG_VBOXDRV_AS_MISC
    59 # include <linux/miscdevice.h>
    60 #endif
     55#include <linux/miscdevice.h>
    6156#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    6257# include <linux/platform_device.h>
     
    7974#  endif
    8075# endif
    81 
    82 /* devfs defines */
    83 #if defined(CONFIG_DEVFS_FS) && !defined(CONFIG_VBOXDRV_AS_MISC)
    84 # ifdef VBOX_WITH_HARDENING
    85 #  define VBOX_DEV_FMASK     (S_IWUSR | S_IRUSR)
    86 # else
    87 #  define VBOX_DEV_FMASK     (S_IRUGO | S_IWUGO)
    88 # endif
    89 #endif /* CONFIG_DEV_FS && !CONFIG_VBOXDEV_AS_MISC */
    9076
    9177#ifdef CONFIG_X86_HIGH_ENTRY
     
    142128 */
    143129static SUPDRVDEVEXT         g_DevExt;
    144 
    145 #ifndef CONFIG_VBOXDRV_AS_MISC
    146 /** Module major number for vboxdrv. */
    147 #define DEVICE_MAJOR_SYS    234
    148 /** Saved major device number for vboxdrv. */
    149 static int                  g_iModuleMajorSys;
    150 /** Module major number for vboxdrvu. */
    151 #define DEVICE_MAJOR_USR    235
    152 /** Saved major device number for vboxdrvu. */
    153 static int                  g_iModuleMajorUsr;
    154 #endif /* !CONFIG_VBOXDRV_AS_MISC */
    155130
    156131/** Module parameter.
     
    220195};
    221196
    222 #ifdef CONFIG_VBOXDRV_AS_MISC
    223197/** The miscdevice structure for vboxdrv. */
    224198static struct miscdevice gMiscDeviceSys =
     
    241215# endif
    242216};
    243 #endif
    244217
    245218
     
    335308     */
    336309    printk(KERN_DEBUG "vboxdrv: Found %u processor cores\n", (unsigned)RTMpGetOnlineCount());
    337 #ifdef CONFIG_VBOXDRV_AS_MISC
    338310    rc = misc_register(&gMiscDeviceSys);
    339311    if (rc)
     
    349321        return rc;
    350322    }
    351 #else  /* !CONFIG_VBOXDRV_AS_MISC */
    352     /*
    353      * Register character devices and save the returned major numbers.
    354      */
    355     /* /dev/vboxdrv */
    356     g_iModuleMajorSys = DEVICE_MAJOR_SYS;
    357     rc = register_chrdev((dev_t)g_iModuleMajorSys, DEVICE_NAME_SYS, &gFileOpsVBoxDrvSys);
    358     if (rc < 0)
    359     {
    360         Log(("register_chrdev() failed with rc=%#x for vboxdrv!\n", rc));
    361         return rc;
    362     }
    363     if (DEVICE_MAJOR_SYS != 0)
    364         g_iModuleMajorSys = DEVICE_MAJOR_SYS;
    365     else
    366         g_iModuleMajorSys = rc;
    367 
    368     /* /dev/vboxdrvu */
    369     /** @todo Use a minor number of this bugger (not sure if this code is used
    370      *        though, so not bothering right now.) */
    371     g_iModuleMajorUsr = DEVICE_MAJOR_USR;
    372     rc = register_chrdev((dev_t)g_iModuleMajorUsr, DEVICE_NAME_USR, &gFileOpsVBoxDrvUsr);
    373     if (rc < 0)
    374     {
    375         Log(("register_chrdev() failed with rc=%#x for vboxdrv!\n", rc));
    376         return rc;
    377     }
    378     if (DEVICE_MAJOR_USR != 0)
    379         g_iModuleMajorUsr = DEVICE_MAJOR_USR;
    380     else
    381         g_iModuleMajorUsr = rc;
    382     rc = 0;
    383 
    384 # ifdef CONFIG_DEVFS_FS
    385     /*
    386      * Register a device entry
    387      */
    388     if (   devfs_mk_cdev(MKDEV(DEVICE_MAJOR_SYS, 0), S_IFCHR | VBOX_DEV_FMASK, DEVICE_NAME_SYS) != 0
    389         || devfs_mk_cdev(MKDEV(DEVICE_MAJOR_USR, 0), S_IFCHR | VBOX_DEV_FMASK, DEVICE_NAME_USR) != 0)
    390     {
    391         Log(("devfs_register failed!\n"));
    392         rc = -EINVAL;
    393     }
    394 # endif
    395 #endif /* !CONFIG_VBOXDRV_AS_MISC */
    396323    if (!rc)
    397324    {
     
    451378         * Failed, cleanup and return the error code.
    452379         */
    453 #if defined(CONFIG_DEVFS_FS) && !defined(CONFIG_VBOXDRV_AS_MISC)
    454         devfs_remove(DEVICE_NAME_SYS);
    455         devfs_remove(DEVICE_NAME_USR);
    456 #endif
    457     }
    458 #ifdef CONFIG_VBOXDRV_AS_MISC
     380    }
    459381    misc_deregister(&gMiscDeviceSys);
    460382    misc_deregister(&gMiscDeviceUsr);
    461383    Log(("VBoxDrv::ModuleInit returning %#x (minor:%d & %d)\n", rc, gMiscDeviceSys.minor, gMiscDeviceUsr.minor));
    462 #else
    463     unregister_chrdev(g_iModuleMajorUsr, DEVICE_NAME_USR);
    464     unregister_chrdev(g_iModuleMajorSys, DEVICE_NAME_SYS);
    465     Log(("VBoxDrv::ModuleInit returning %#x (major:%d & %d)\n", rc, g_iModuleMajorSys, g_iModuleMajorUsr));
    466 #endif
    467384    return rc;
    468385}
     
    485402     * opened, at least we'll blindly assume that here.
    486403     */
    487 #ifdef CONFIG_VBOXDRV_AS_MISC
    488404    misc_deregister(&gMiscDeviceUsr);
    489405    misc_deregister(&gMiscDeviceSys);
    490 #else  /* !CONFIG_VBOXDRV_AS_MISC */
    491 # ifdef CONFIG_DEVFS_FS
    492     /*
    493      * Unregister a device entry
    494      */
    495     devfs_remove(DEVICE_NAME_USR);
    496     devfs_remove(DEVICE_NAME_SYS);
    497 # endif /* devfs */
    498     unregister_chrdev(g_iModuleMajorUsr, DEVICE_NAME_USR);
    499     unregister_chrdev(g_iModuleMajorSys, DEVICE_NAME_SYS);
    500 #endif /* !CONFIG_VBOXDRV_AS_MISC */
    501406
    502407    /*
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.mod.c

    r62490 r62694  
    4949        {        0, "init_module" },
    5050        {        0, "struct_module" },
    51         {        0, "devfs_remove" },
    5251        {        0, "strpbrk" },
    5352        {        0, "__kmalloc" },
     
    6463        {        0, "rwsem_wake" },
    6564        {        0, "copy_to_user" },
    66         {        0, "devfs_mk_cdev" },
    6765        {        0, "preempt_schedule" },
    6866        {        0, "contig_page_data" },
     
    7371        {        0, "do_munmap" },
    7472        {        0, "get_user_pages" },
    75         {        0, "register_chrdev" },
    7673        {        0, "vsnprintf" },
    7774        {        0, "kfree" },
    7875        {        0, "memcpy" },
    79         {        0, "unregister_chrdev" },
    8076        {        0, "put_page" },
    8177        {        0, "__up_wakeup" },
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette