From patchwork Wed May 19 18:38:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Drewry X-Patchwork-Id: 101025 X-Patchwork-Delegate: agk@redhat.com Received: from mx01.colomx.prod.int.phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4JIihGQ012199 for ; Wed, 19 May 2010 18:45:19 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4JIgYuY027910; Wed, 19 May 2010 14:42:34 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4JIgSBv024589 for ; Wed, 19 May 2010 14:42:28 -0400 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.7]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4JIgNKp021470; Wed, 19 May 2010 14:42:23 -0400 Received: from mail-pw0-f46.google.com (mail-pw0-f46.google.com [209.85.160.46]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4JIgDHU012955; Wed, 19 May 2010 14:42:13 -0400 Received: by pwi5 with SMTP id 5so1775987pwi.33 for ; Wed, 19 May 2010 11:42:13 -0700 (PDT) Received: by 10.140.83.9 with SMTP id g9mr6693385rvb.6.1274294533359; Wed, 19 May 2010 11:42:13 -0700 (PDT) Received: from localhost.localdomain (208-191-153-102.lightspeed.austtx.sbcglobal.net [208.191.153.102]) by mx.google.com with ESMTPS id c9sm5163058rvi.2.2010.05.19.11.42.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 May 2010 11:42:12 -0700 (PDT) From: Will Drewry To: dm-devel@redhat.com, linux-kernel@vger.kernel.org Date: Wed, 19 May 2010 13:38:24 -0500 Message-Id: <1274294304-30606-3-git-send-email-wad@chromium.org> In-Reply-To: <1274294304-30606-1-git-send-email-wad@chromium.org> References: <1274294304-30606-1-git-send-email-wad@chromium.org> X-RedHat-Spam-Score: -0.011 (RCVD_IN_DNSWL_NONE,SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.7 X-loop: dm-devel@redhat.com Cc: Will Drewry , snitzer@redhat.com, agk@redhat.com Subject: [dm-devel] [PATCH v3 3/3] dm: lookup devices by path with name_to_dev_t X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 19 May 2010 18:45:19 +0000 (UTC) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index ef6a3ab..589e86a 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -434,17 +435,16 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti, int r; dev_t uninitialized_var(dev); struct dm_dev_internal *dd; - unsigned int major, minor; + char base_path[32]; /* size from name_to_dev_t */ BUG_ON(!t); - if (sscanf(path, "%u:%u", &major, &minor) == 2) { - /* Extract the major/minor numbers */ - dev = MKDEV(major, minor); - if (MAJOR(dev) != major || MINOR(dev) != minor) - return -EOVERFLOW; - } else { - /* convert the path to a device */ + /* stage the shorter path for name_to_dev_t. */ + strncpy(base_path, path, sizeof(base_path)); + + /* lookup by major:minor or registered device name */ + if (!(dev = name_to_dev_t(base_path))) { + /* convert the path to a device by finding its inode */ struct block_device *bdev = lookup_bdev(path); if (IS_ERR(bdev))