| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
This adds 2 new disk type features, one for the whole disk UUID and
another for the per-partition UUID. It adds ped_disk_get_uuid and
ped_partition_get_uuid functions to retrieve them.
It adds them to the JSON output on GPT disklabeled disks as "uuid" in
the disk and partitions sections of the JSON output.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
|
|
|
| |
_PedDiskOps::get_max_primary_partition_count is always available, the
macro PT_op_function_initializers ensures it. So use
ped_disk_get_max_primary_partition_count instead of
_PedDiskOps::get_max_primary_partition_count directly.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
| |
Without this the print command keeps showing the type selected with
mkpart, which doesn't match the id/uuid set by the user. So rescan the
partition for a filesystem.
|
|
|
|
|
|
|
|
|
| |
Include the partition type-id and type-uuid in the JSON
output. Also add the the command 'type' to set them. Remove
redundant flags from DosPartitionData and use only the system
variable.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
| |
This complements commit b20227adf5 from five months ago.
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
|
| |
|
|
|
|
| |
By running make update-copyright
|
|
|
|
|
|
|
|
|
| |
This fixes some missing commands in the parted.texi file used to
generate the web manual and info document. It also removes documentation
for the never-implemented 'print NUMBER' command which only returns 1.
The parted manpage has been updated to document the available print
options, disk_set, and disk_toggle commands.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This outputs the disk's details as a JSON object. eg. a disk image with
a single partition from 1M to 100M:
{
"disk": {
"path": "/root/disk1.img",
"size": "2097152s",
"model": "",
"transport": "file",
"logical-sector-size": 512,
"physical-sector-size": 512,
"label": "gpt",
"max-partitions": 128,
"partitions": [
{
"number": 0,
"start": "34s",
"end": "2047s",
"size": "2014s",
"type": "free"
},{
"number": 1,
"start": "2048s",
"end": "200703s",
"size": "198656s",
"type": "primary",
"name": "root"
},{
"number": 0,
"start": "200704s",
"end": "2097118s",
"size": "1896415s",
"type": "free"
}
]
}
}
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
| |
This makes it possible to pass an empty string in script mode e.g. to
set no partition name (on GPT):
parted -s ./disk.img mklabel gpt mkpart '""' ext2 1 100M
Includes a new test for this feature.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
|
| |
The device path, device model, and partition name could all contain
colons or backslashes. This escapes all of these with a backslash.
Thanks to Arvin Schnell for the patch.
|
| |
|
|
|
|
| |
str_list_create calls gettext_to_wchar which makes a copy of it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use-case: VMs are booted from images that are smaller than their virtual
disk. This means that -- almost by definition -- the secondary GPT
header will be "misplaced", i.e., not at the end of the virtual disk.
Without this patch, parted cannot be used for custom/exotic partitioning
when the VM boots (e.g., in cloud-init's `bootcmd`). Specifically, it
will fail as follows:
```
$ sudo parted --script /dev/vda "mkpart 2 10GB -1"
Warning: Not all of the space available to /dev/vda appears to be used,
you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
Error: Unable to satisfy all constraints on the partition.
```
This happens because, in script mode, exceptions are usually not
resolved.
This patch adds `--fix`. This allows exceptions to be automatically
resolved with Fix. As a result, the following command will work:
```
$ sudo parted --fix --script /dev/vda "mkpart 2 10GB -1"
```
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
| |
By running make update-copyright
|
|
|
|
| |
By running make update-copyright
|
|
|
|
| |
Double the storage to 20 bytes.
|
|
|
|
|
| |
It was using PedPartitionFlag instead of PedDiskFlag when walking the
available flags.
|
|
|
|
|
|
|
| |
Resizing busy partitions is allowed, but the user is prompted, which
erases the cmdline. It is annoying to have to re-end the ending location
after answering Yes. This saves the word and pushes it back onto the
cmdline after the user agrees to resize the busy partition.
|
|
|
|
|
| |
It needs to be set to NULL, since it may not get set by the call to
command_line_get_sector
|
|
|
|
| |
By running make update-copyright
|
|
|
|
| |
Caught by make syntax-check
|
|
|
|
| |
Caught by make syntax-check
|
| |
|
|
|
|
|
|
| |
Asserts should only check logic, not wrap functions with side-effects.
When compiled with --disable-debug this causes the name field of mkpart
to be ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
parted terminates with 'stack smashing detected' when fed with a long command
line argument, and segfaults when the argument is long enough:
root # /sbin/parted /dev/sda $(perl -e 'print "a"x265')
*** stack smashing detected ***: /sbin/parted terminated
...
Aborted
root # /sbin/parted /dev/sda $(perl -e 'print "a"x328')
*** stack smashing detected ***: /sbin/parted terminated
...
Command History:
Segmentation fault
parted should be able to detect it and exit with error and usage messages.
This also makes command line buffer overflow exploit more possible. Fix it by
adding length check in the condition of the for loop where command line
arguments are copied.
Signed-off-by: Simon Xu <xu.simon@oracle.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
| |
If there was a problem with ped_device_get or ped_device_open it would not be freed.
Related: rhbz#1602652
|
|
|
|
|
|
|
| |
If command_line_get_fs_type failed it would never free it, so put a free
in both branches of the if.
Related: rhbz#1602652
|
|
|
|
|
|
| |
Fix resizepart to adjust the end to be -1 sector when using iec
power of 2 units so that the next partition can start immediately
following the new end, just like mkpart does.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The manual had long documented that negative values are
allowed for both start and end values, but until now negative
start values were rejected if FS-TYPE was not given.
Example:
# parted --script -a optimal /dev/loop0 -- mklabel gpt mkpart primary ext4 -5MiB 100%
(succeeds)
# parted --script -a optimal /dev/loop0 -- mklabel gpt mkpart primary -5MiB 100%
parted: invalid token: -5MiB
Error: Expecting a file system type.
This commit fixes the latter error.
The issue was an insufficient lookahead in command line parsing,
looking only for digits when skipping over FS-TYPE.
The fix is including the minus '-' in the lookahead.
Originally reported as Debian bug #880035:
"parted: fails to use negative start value for 'mkpart' command without specyfying FS-TYPE"
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=880035
Signed-off-by: Niklas Hambüchen <mail@nh2.me>
|
|
|
|
|
|
|
|
| |
Loop labels and file images support no flags. set and disk_set
would prompt for a flag and accept any string since the list of
flags was empty, then fail to look up an actual flag value, then
throw an exception with a null string for the name of the flag,
which would bug.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Recognize NVDIMM devices, so that "parted -s /dev/pmem7 p" now
prints "Model: NVDIMM Device (pmem)" instead of
"Model: Unknown (unknown)".
In order for a device to be recognized as NVDIMM, it has to
have a 'blkext' major number. But since this major can be
used also by other device types, we also check that the device
path contains 'pmem' as a substring.
* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_PMEM
* libparted/arch/linux.c(_device_probe_type): Recognize NVDIMM devices.
* libparted/arch/linux.c(linux_new): Handle NVDIMM devices.
* parted/parted.c(do_print): Add "pmem" to list of transports.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When some command fails, the information still exists in
command_line buffer. When in command mode or interactive mode,
if an interactive exception prompts, the remained information
will be processed as option from user. This will raise some other
information or even unexpected results. So before getting option
input from user, clean the command line buffer.
Example: When the disk label is invalid and user tries to make
new partition on the device with command like,
mkpart 0 50%. Then parted will raise an exception
telling an invalid disk label found and whether to correct it.
But at this time 0 as the input of mkpart will be
considered as the option input for the exception(yes/no).
So one more exception will raised with error information.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous function works well for the labels supporting naming
partition, but not for these which don't. If the disk label does not
support partition naming, two exceptions will be raised. Even after the first
error indicates it does not support name, parted yet asks user for
name in iteractive mode.
First check if the disk label supports partition naming and if it
does, it will continue; otherwise, it will stop and raise an
exception.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Recognize RAM drives, so "parted -s /dev/ram0 p" now prints
"RAM Drive (brd)" instead of "Model: Unknown (unknown)".
In order for a device to be recognized as RAM drive, it has to
have major number 1. Also the BLKFLSBUF ioctl shouldn't be used
on RAM drives as it is used to zero the device.
* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_RAM.
* libparted/arch/linux.c(RAM_MAJOR): New define.
* libparted/arch/linux.c(_device_probe_type): Recognize RAM drives.
* libparted/arch/linux.c(linux_new): Handle RAM drives.
* libparted/arch/linux.c(_flush_cache): Skip RAM drives.
* parted/parted.c(do_print): Add "brd" to list of transports.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
parted always reads disk information to memory before any
operations. The disk that user operates is actually
a copy of real one in memory. When the information in memory
is changed, it will commit the memory to device to update the
disk information.
Once the disk information is read, parted will never re-read it
again unless another device is loaded or the device is re-read.
Above work has been done in commit 7eac058 (parted: don't reload
partition table on every command)
Each command of parted always commits the memory when it succeeds.
Then the disk information on device and in memory are the same.
But when it fails, they might be different. User will be confused
by this, and sometimes get undesired result with the contaminated
memory. This memory should be cleaned if some command fails.
Then the command followed will re-read the disk.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the user makes a new partition, if parted fails to add the
partition to disk, it jumps to wrong error label. In this
situation, this new partition actually is not a node in disk
data structure. But in the wrong error label, it pretends this
is a node and removes it as a list node, leading to other
partition in this disk deleted. This might lead to a memory leak.
Because if there are other partitions, it just removes them from
list without releasing the resource. And this also leads to different
disk information between memory and device. This is confusing.
But when the new partition is added to disk successfully and if
any operations followed fail, this partition should be removed from
disk and destroyed.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the user makes a new partition, if parted fails to add the
partition to disk, it jumps to wrong error label. In this
situation, this new partition actually is not a node in disk
data structure. But in the wrong error label, it pretends this
is a node and removes it as a list node, leading to other
partition in this disk deleted. This might lead to a memory leak.
Because if there are other partitions, it just removes them from
list without releasing the resource. And this also leads to different
disk information between memory and device. This is confusing.
But when the new partition is added to disk successfully and if
any operations followed fail, this partition should be removed from
disk and destroyed.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
|
|
|
|
| |
The _() macro is only for translating string literals. It was
incorrectly applied to a runtime string representing the name
of a partition and this sometimes caused a gettext crash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Recognize NVMe Devices, so "parted -s /dev/nvme0n1" now prints
"NVMe Device (nvme)" instead of "Model: Unknown (unknown)".
In order for a device to be recognized as NVMe, it has to
have a 'blkext' major number. But since this major can be
used also by other device types, we also check the device
path contains 'nvme' as a substring.
* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_NVME
* libparted/arch/linux.c(BLKEXT_MAJOR): New define.
* libparted/arch/linux.c(_is_blkext_major): New function.
* libparted/arch/linux.c(_device_probe_type): Recognize NVMe devices.
* libparted/arch/linux.c(linux_new): Handle NVMe devices.
* parted/parted.c(do_print): Add "nvme" to list of transports.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When alignment for a new partition fails it isn't always obvious why it
failed. This adds printing the reason for the failure, in the form of:
start % grain != offset
This modifies align-check in interactive mode to print the alignment the
error details if it isn't aligned. Script mode behavior is unchanged.
Also cleanup pointer usage and handle asprintf failure by using a constant
string in the error report - "unknown (malloc failure)".
|
|
|
|
|
|
|
| |
The rescue command often failed to locate a filesystem due to it
leaving cylinder alignment on, which snapped the allowed bounds
of the filesystem down to the next lower cylinder boundary,
causing the detected filesystem to be rejected due to not fitting.
|
|
|
|
|
|
|
|
|
| |
* parted/ui.c(command_line_get_sector): Don't leak input string.
* parted/ui.c(command_line_prompt_words): Don't leak _def string in
opt script mode.
Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
|
|
|
|
| |
A typo (the last I think) from commit 7eac058 wasn't properly checking
the result of ped_disk_new so it could crash if there was no disklabel
on the device.
|
|
|
|
|
|
| |
Due to a typeo in commit 7eac058 "parted: don't reload partition
table on every command", the disk_set command would crash if
a disk label was not found.
|
|
|
|
|
|
| |
To make sure that older scripts trying to use the resize command do not
accidentally run the new resizepart command by mistake, this undocumented
stub command will throw an error if called.
|
|
|
|
|
|
| |
Have command_print_summary print nothing if the command summary is NULL.
This allows for a command to be registered, but not documented in the
output of help.
|
|
|
|
|
|
| |
This function was throwing a PED_EXCEPTION_ERROR with only the
PED_EXCEPTION_CANCEL option. Converted to a PED_EXCEPTION_WARNING
with the option to continue anyhow.
|
|
|
|
|
| |
Add resizepart command to resize ( change the end position ) an existing
partition. Note that it does nothing to a filesystem in the partition.
|