Skip to content

Commit

Permalink
Merge pull request #378 from vojtechtrefny/master_udf-part-type
Browse files Browse the repository at this point in the history
Set corrent part type/id and GUID for UDF formatted partitions
  • Loading branch information
vojtechtrefny authored Aug 16, 2017
2 parents 3ccdeb8 + 60af176 commit 82417ff
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/tests/dbus-tests/test_60_partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,80 @@ def test_create_with_format(self):
_ret, sys_fstype = self.run_command('lsblk -d -no FSTYPE /dev/%s' % part_name)
self.assertEqual(sys_fstype, 'xfs')

def _have_udftools(self):
ret, _out = self.run_command('type mkudffs')
return ret == 0

def test_create_with_format_auto_type_mbr(self):
if not self._have_udftools():
self.skipTest('Udftools needed to check automatic partition type update.')

disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
self.assertIsNotNone(disk)

# create msdos partition table
self._create_format(disk, 'dos')

self.addCleanup(self._remove_format, disk)

# create partition with udf format and automatically set partition type
# it should be 0x07
d = dbus.Dictionary(signature='sv')
d['update-partition-type'] = True
path = disk.CreatePartitionAndFormat(dbus.UInt64(1024**2), dbus.UInt64(100 * 1024**2), '', '',
self.no_options, 'udf', d,
dbus_interface=self.iface_prefix + '.PartitionTable')

part = self.bus.get_object(self.iface_prefix, path)
self.assertIsNotNone(part)

self.addCleanup(self._remove_partition, part)
self.addCleanup(self._remove_format, part)

# check dbus properties
dbus_type = self.get_property(part, '.Partition', 'Type')
dbus_type.assertEqual('0x07')

# check system values
part_name = path.split('/')[-1]
_ret, sys_type = self.run_command('blkid /dev/%s -p -o value -s PART_ENTRY_TYPE' % part_name)
self.assertEqual(sys_type, '0x7')

def test_create_with_format_auto_type_gpt(self):
if not self._have_udftools():
self.skipTest('Udftools needed to check automatic partition type update.')

disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
self.assertIsNotNone(disk)

# create msdos partition table
self._create_format(disk, 'gpt')

self.addCleanup(self._remove_format, disk)

# create partition with udf format and automatically set partition type
# it should be ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
d = dbus.Dictionary(signature='sv')
d['update-partition-type'] = True
path = disk.CreatePartitionAndFormat(dbus.UInt64(1024**2), dbus.UInt64(100 * 1024**2), '', '',
self.no_options, 'udf', d,
dbus_interface=self.iface_prefix + '.PartitionTable')

part = self.bus.get_object(self.iface_prefix, path)
self.assertIsNotNone(part)

self.addCleanup(self._remove_partition, part)
self.addCleanup(self._remove_format, part)

# check dbus properties
dbus_type = self.get_property(part, '.Partition', 'Type')
dbus_type.assertEqual('ebd0a0a2-b9e5-4433-87c0-68b6b72699c7')

# check system values
part_name = path.split('/')[-1]
_ret, sys_type = self.run_command('blkid /dev/%s -p -o value -s PART_ENTRY_TYPE' % part_name)
self.assertEqual(sys_type, 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7')


class UdisksPartitionTest(udiskstestcase.UdisksTestCase):
'''This is a basic partition test suite'''
Expand Down
2 changes: 2 additions & 0 deletions src/udiskslinuxblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@ static const struct
{"dos", "xfs", "0x83"},
{"dos", "btrfs", "0x83"},
{"dos", "crypto_LUKS", "0x83"}, /* TODO: perhaps default to LUKS-specific type */
{"dos", "udf", "0x07"},

{"gpt", "vfat", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"}, /* Microsoft Basic Data */
{"gpt", "ntfs", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"},
Expand All @@ -2360,6 +2361,7 @@ static const struct
{"gpt", "xfs", "0fc63daf-8483-4772-8e79-3d69d8477de4"},
{"gpt", "btrfs", "0fc63daf-8483-4772-8e79-3d69d8477de4"},
{"gpt", "crypto_LUKS", "0fc63daf-8483-4772-8e79-3d69d8477de4"}, /* TODO: perhaps default to LUKS-specific type */
{"gpt", "udf", "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7"},
};


Expand Down

0 comments on commit 82417ff

Please sign in to comment.