fdisk_assign_device() contains 'readonly' parameter to indicate how to open the device. Assigned device 'readonly' must be false (0) in order to write in-memory changes to it.