summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parschauer <sparschauer@suse.de>2017-03-14 16:40:00 +0100
committerBrian C. Lane <bcl@redhat.com>2017-05-01 15:04:24 -0700
commit21131f62c6f508a5d0c080e025cf7db5df43fc7d (patch)
treeaa4ff99a76c8f70853b6db21d6af3d43ba0ed6a7
parent5a61f15b7003cba73e6517ac22204bafd9a3cb8e (diff)
downloadparted-21131f62c6f508a5d0c080e025cf7db5df43fc7d.tar.gz
Add support for RAM drives
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>
-rw-r--r--NEWS2
-rw-r--r--include/parted/device.in.h3
-rw-r--r--libparted/arch/linux.c12
-rw-r--r--parted/parted.c2
4 files changed, 14 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 5a8db48..b6aeb89 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
GNU parted NEWS -*- outline -*-
- Parted now recognizes NVMe devices
+ Parted now recognizes NVMe devices and RAM drives
* Noteworthy changes in release ?.? (????-??-??) [?]
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
index d38db44..1b6e7b8 100644
--- a/include/parted/device.in.h
+++ b/include/parted/device.in.h
@@ -50,7 +50,8 @@ typedef enum {
PED_DEVICE_AOE = 16,
PED_DEVICE_MD = 17,
PED_DEVICE_LOOP = 18,
- PED_DEVICE_NVME = 19
+ PED_DEVICE_NVME = 19,
+ PED_DEVICE_RAM = 20
} PedDeviceType;
typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index d87fe9c..9886d6e 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -279,6 +279,7 @@ struct blkdev_ioctl_param {
#define LOOP_MAJOR 7
#define MD_MAJOR 9
#define BLKEXT_MAJOR 259
+#define RAM_MAJOR 1
#define SCSI_BLK_MAJOR(M) ( \
(M) == SCSI_DISK0_MAJOR \
@@ -701,6 +702,8 @@ _device_probe_type (PedDevice* dev)
dev->type = PED_DEVICE_MD;
} else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
dev->type = PED_DEVICE_NVME;
+ } else if (dev_major == RAM_MAJOR) {
+ dev->type = PED_DEVICE_RAM;
} else {
dev->type = PED_DEVICE_UNKNOWN;
}
@@ -1547,6 +1550,11 @@ linux_new (const char* path)
goto error_free_arch_specific;
break;
+ case PED_DEVICE_RAM:
+ if (!init_generic (dev, _("RAM Drive")))
+ goto error_free_arch_specific;
+ break;
+
default:
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
@@ -1619,9 +1627,9 @@ _flush_cache (PedDevice* dev)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
int i;
- int lpn = _device_get_partition_range(dev);
+ int lpn = _device_get_partition_range(dev);
- if (dev->read_only)
+ if (dev->read_only || dev->type == PED_DEVICE_RAM)
return;
dev->dirty = 0;
diff --git a/parted/parted.c b/parted/parted.c
index 59ad59e..6722dc9 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -980,7 +980,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
"cpqarray", "file", "ataraid", "i2o",
"ubd", "dasd", "viodasd", "sx8", "dm",
"xvd", "sd/mmc", "virtblk", "aoe",
- "md", "loopback", "nvme"};
+ "md", "loopback", "nvme", "brd"};
char* start = ped_unit_format (dev, 0);
PedUnit default_unit = ped_unit_get_default ();