posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          讀核筆記(2) - 內核模塊

          Posted on 2008-02-10 18:53 ZelluX 閱讀(921) 評論(0)  編輯  收藏 所屬分類: LinuxSystem
          /proc文件系統不是直接從內核的存儲區中讀寫數據,二是通過回調函數實現文件讀寫的。struct proc_dir_entry有一對讀寫操作函數指針read_proc_t, write_proc_t。
          一個編寫內核模塊操作proc文件系統的例子,書上的源程序是在2.4.18下跑起來的,改了三個地方在2.6.23下成功運行。當然Makefile也按照2.6中make modules的方式寫了。

          1. 去掉MODULE_VERSION宏的定義,和頭文件沖突。
          2. 去掉MOD_INC_USE_COUNT和MOD_DEC_USE_COUNT,2.6中的改變

          Preventing premature unloading

          In 2.4 modules, the MOD_INC_USE_COUNT macro is used to prevent unloading of the module while there is an open file. The 2.6 kernel, however, knows not to unload a module that owns a character device that's currently open.

          However, this requires that the module be explicit in specifying ownership of character devices, using the THIS_MODULE macro. You also have to take out all calls to MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT.

          The 2.6 kernel considers modules that use the deprecated facility to be unsafe, and does not permit their unloading, even with rmmod -f.

          3. 去掉proc_mknod增加一個tty設備文件那部分代碼,2.6中去掉了這個函數,貌似要用udev代替,以后再看了。

          修改后代碼:

          主站蜘蛛池模板: 色达县| 涟水县| 惠水县| 彩票| 观塘区| 沈丘县| 门头沟区| 金溪县| 武夷山市| 明光市| 安庆市| 宜丰县| 珲春市| 永丰县| 吴桥县| 洛川县| 永靖县| 从江县| 治县。| 菏泽市| 抚远县| 通海县| 卫辉市| 望奎县| 芦山县| 晋中市| 永德县| 朔州市| 阳东县| 固原市| 桦甸市| 竹山县| 桑日县| 长宁区| 吉水县| 远安县| 武宁县| 福清市| 崇明县| 绥中县| 宜兰市|