linux2.6.38之后内核版本调用open_by_devnum()函数出错

linux2.6.38之后内核版本下编译内核模块,当调用open_by_devnum()函数时会出错。该问题原因在于:在linux2.6.37版本以后的内核中,已将open_by_devnum()函数去除,而用 blkdev_get_by_dev函数取代其功能。

可参考如下引用内容:

xen/blkback: Update to use blkdev_get_by_dev instead of open_by_devnum.

Subject: [PATCH 7/5] block: clean up blkdev_get() wrappers and their users
References: <1288628129-12811-1-git-send-email…@kernel.org>
In-Reply-To: <1288628129-12811-1-git-send-email…@kernel.org>
X-Enigmail-Version: 1.1.1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00
 autolearn=ham version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hera.kernel.org
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.3 (hera.kernel.org [127.0.0.1]); Thu, 11 Nov 2010 17:11:26 +0000 (UTC)
Sender: linux-kernel-ow…@vger.kernel.org
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-ker…@vger.kernel.org

After recent blkdev_get() modifications, open_by_devnum() and
open_bdev_exclusive() are simple wrappers around blkdev_get().
Replace them with blkdev_get_by_dev() and blkdev_get_by_path().

blkdev_get_by_dev() is identical to open_by_devnum().
blkdev_get_by_path() is slightly different in that it doesn't
automatically add %FMODE_EXCL to @mode.

All users are converted.  Most conversions are mechanical and don't
introduce any behavior difference.  There are several exceptions.

* btrfs now sets FMODE_EXCL in btrfs_device->mode, so there's no
  reason to or it explicitly on blkdev_put().

* gfs2, nilfs2 and the generic mount_bdev() now set FMODE_EXCL in
  sb->s_mode.

* With the above changes, sb->s_mode now always should contain
  FMODE_EXCL.  WARN_ON_ONCE() added to kill_block_super() to detect
  errors.

The new blkdev_get_*() functions are with proper docbook comments.
While at it, add function description to blkdev_get() too.

参考:
http://www.chineselinuxuniversity.net/patches/144673.shtml
http://groups.google.com/group/linux-kernel-proxy/browse_thread/thread/62e5a1922b9c835e
http://groups.google.com/group/linux-kernel-proxy/msg/a3a23a47b1b51f6c?dmode=source&output=gplain

点赞 (0)
  1. 零食说道:

    很专业的文章啊,开始我也用的linux空间,后来每次都出错,只好用WIN空间了

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code