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…>
In-Reply-To: <1288628129-12811-1-git-send-email…>
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
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.3 ( []); Thu, 11 Nov 2010 17:11:26 +0000 (UTC)
Sender: linux-kernel-ow…
Precedence: bulk
List-ID: <>
X-Mailing-List: linux-ker…

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

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

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


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



电子邮件地址不会被公开。 必填项已用*标注