Merge ~dbungert/curtin:generic-kname into curtin:master

Proposed by Dan Bungert
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: e16420f6ca536ccc8a874978f649d58a8148560a
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~dbungert/curtin:generic-kname
Merge into: curtin:master
Diff against target: 37 lines (+9/-6)
2 files modified
curtin/block/__init__.py (+4/-5)
tests/unittests/test_block.py (+5/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
curtin developers Pending
Review via email: mp+427643@code.launchpad.net

Commit message

block: genericize kname generation

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Not logged in on my phone so can't mark approved but this looks good. If
you could put in a comment and a link to the kernel code that would be even
better :)

On Sat, 30 Jul 2022, 09:22 Dan Bungert, <email address hidden>
wrote:

> Dan Bungert has proposed merging ~dbungert/curtin:generic-kname into
> curtin:master.
>
> Commit message:
> block: genericize kname generation
>
> Requested reviews:
> curtin developers (curtin-dev)
>
> For more details, see:
> https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/427643
> --
> You are subscribed to branch curtin:master.
>

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
2index 49b062f..a46c8ec 100644
3--- a/curtin/block/__init__.py
4+++ b/curtin/block/__init__.py
5@@ -132,11 +132,10 @@ def partition_kname(disk_kname, partition_number):
6 os.path.realpath('%s-part%s' % (disk_link,
7 partition_number)))
8
9- for dev_type in ['bcache', 'nvme', 'mmcblk', 'cciss', 'mpath', 'md',
10- 'loop']:
11- if disk_kname.startswith(dev_type):
12- partition_number = "p%s" % partition_number
13- break
14+ # follow the same rules the kernel check_partition() does
15+ # https://github.com/torvalds/linux/blob/0fac198/block/partitions/core.c#L141
16+ if disk_kname[-1:].isdigit():
17+ partition_number = "p%s" % partition_number
18 return "%s%s" % (disk_kname, partition_number)
19
20
21diff --git a/tests/unittests/test_block.py b/tests/unittests/test_block.py
22index 7a73b69..bb7205e 100644
23--- a/tests/unittests/test_block.py
24+++ b/tests/unittests/test_block.py
25@@ -457,7 +457,11 @@ class TestBlockKnames(CiTestCase):
26 (('cciss!c0d0', 1), 'cciss!c0d0p1'),
27 (('dm-0', 1), 'dm-1'),
28 (('md0', 1), 'md0p1'),
29- (('mpath1', 2), 'mpath1p2')]
30+ (('mpath1', 2), 'mpath1p2'),
31+ (('pmem0', 1), 'pmem0p1'),
32+ (('asdf7', 3), 'asdf7p3'),
33+ (('zdc', 4), 'zdc4'),
34+ ]
35 for ((disk_kname, part_number), part_kname) in part_knames:
36 self.assertEqual(part_kname,
37 block.partition_kname(disk_kname, part_number))

Subscribers

People subscribed via source and target branches