|
|
003ee8 |
From eb927155680f75e570dc7375514e344a936a3fb5 Mon Sep 17 00:00:00 2001
|
|
|
003ee8 |
From: "Brian C. Lane" <bcl@redhat.com>
|
|
|
003ee8 |
Date: Mon, 1 May 2017 17:05:01 -0700
|
|
|
003ee8 |
Subject: [PATCH 70/75] Add support for RAM drives
|
|
|
003ee8 |
|
|
|
003ee8 |
Recognize RAM drives, so "parted -s /dev/ram0 p" now prints
|
|
|
003ee8 |
"RAM Drive (brd)" instead of "Model: Unknown (unknown)".
|
|
|
003ee8 |
|
|
|
003ee8 |
In order for a device to be recognized as RAM drive, it has to
|
|
|
003ee8 |
have major number 1. Also the BLKFLSBUF ioctl shouldn't be used
|
|
|
003ee8 |
on RAM drives as it is used to zero the device.
|
|
|
003ee8 |
|
|
|
003ee8 |
* NEWS: Mention the change
|
|
|
003ee8 |
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_RAM.
|
|
|
003ee8 |
* libparted/arch/linux.c(RAM_MAJOR): New define.
|
|
|
003ee8 |
* libparted/arch/linux.c(_device_probe_type): Recognize RAM drives.
|
|
|
003ee8 |
* libparted/arch/linux.c(linux_new): Handle RAM drives.
|
|
|
003ee8 |
* libparted/arch/linux.c(_flush_cache): Skip RAM drives.
|
|
|
003ee8 |
* parted/parted.c(do_print): Add "brd" to list of transports.
|
|
|
003ee8 |
|
|
|
003ee8 |
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
|
|
003ee8 |
---
|
|
|
003ee8 |
include/parted/device.in.h | 3 ++-
|
|
|
003ee8 |
libparted/arch/linux.c | 12 ++++++++++--
|
|
|
003ee8 |
parted/parted.c | 2 +-
|
|
|
003ee8 |
3 files changed, 13 insertions(+), 4 deletions(-)
|
|
|
003ee8 |
|
|
|
003ee8 |
diff --git a/include/parted/device.in.h b/include/parted/device.in.h
|
|
|
003ee8 |
index d38db44..1b6e7b8 100644
|
|
|
003ee8 |
--- a/include/parted/device.in.h
|
|
|
003ee8 |
+++ b/include/parted/device.in.h
|
|
|
003ee8 |
@@ -50,7 +50,8 @@ typedef enum {
|
|
|
003ee8 |
PED_DEVICE_AOE = 16,
|
|
|
003ee8 |
PED_DEVICE_MD = 17,
|
|
|
003ee8 |
PED_DEVICE_LOOP = 18,
|
|
|
003ee8 |
- PED_DEVICE_NVME = 19
|
|
|
003ee8 |
+ PED_DEVICE_NVME = 19,
|
|
|
003ee8 |
+ PED_DEVICE_RAM = 20
|
|
|
003ee8 |
} PedDeviceType;
|
|
|
003ee8 |
|
|
|
003ee8 |
typedef struct _PedDevice PedDevice;
|
|
|
003ee8 |
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
|
|
003ee8 |
index 2058697..c2fdab0 100644
|
|
|
003ee8 |
--- a/libparted/arch/linux.c
|
|
|
003ee8 |
+++ b/libparted/arch/linux.c
|
|
|
003ee8 |
@@ -279,6 +279,7 @@ struct blkdev_ioctl_param {
|
|
|
003ee8 |
#define LOOP_MAJOR 7
|
|
|
003ee8 |
#define MD_MAJOR 9
|
|
|
003ee8 |
#define BLKEXT_MAJOR 259
|
|
|
003ee8 |
+#define RAM_MAJOR 1
|
|
|
003ee8 |
|
|
|
003ee8 |
#define SCSI_BLK_MAJOR(M) ( \
|
|
|
003ee8 |
(M) == SCSI_DISK0_MAJOR \
|
|
|
003ee8 |
@@ -701,6 +702,8 @@ _device_probe_type (PedDevice* dev)
|
|
|
003ee8 |
dev->type = PED_DEVICE_MD;
|
|
|
003ee8 |
} else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
|
|
|
003ee8 |
dev->type = PED_DEVICE_NVME;
|
|
|
003ee8 |
+ } else if (dev_major == RAM_MAJOR) {
|
|
|
003ee8 |
+ dev->type = PED_DEVICE_RAM;
|
|
|
003ee8 |
} else {
|
|
|
003ee8 |
dev->type = PED_DEVICE_UNKNOWN;
|
|
|
003ee8 |
}
|
|
|
003ee8 |
@@ -1547,6 +1550,11 @@ linux_new (const char* path)
|
|
|
003ee8 |
goto error_free_arch_specific;
|
|
|
003ee8 |
break;
|
|
|
003ee8 |
|
|
|
003ee8 |
+ case PED_DEVICE_RAM:
|
|
|
003ee8 |
+ if (!init_generic (dev, _("RAM Drive")))
|
|
|
003ee8 |
+ goto error_free_arch_specific;
|
|
|
003ee8 |
+ break;
|
|
|
003ee8 |
+
|
|
|
003ee8 |
default:
|
|
|
003ee8 |
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
|
|
|
003ee8 |
PED_EXCEPTION_CANCEL,
|
|
|
003ee8 |
@@ -1619,9 +1627,9 @@ _flush_cache (PedDevice* dev)
|
|
|
003ee8 |
{
|
|
|
003ee8 |
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
|
|
|
003ee8 |
int i;
|
|
|
003ee8 |
- int lpn = _device_get_partition_range(dev);
|
|
|
003ee8 |
+ int lpn = _device_get_partition_range(dev);
|
|
|
003ee8 |
|
|
|
003ee8 |
- if (dev->read_only)
|
|
|
003ee8 |
+ if (dev->read_only || dev->type == PED_DEVICE_RAM)
|
|
|
003ee8 |
return;
|
|
|
003ee8 |
dev->dirty = 0;
|
|
|
003ee8 |
|
|
|
003ee8 |
diff --git a/parted/parted.c b/parted/parted.c
|
|
|
003ee8 |
index f767bec..a7fcd3b 100644
|
|
|
003ee8 |
--- a/parted/parted.c
|
|
|
003ee8 |
+++ b/parted/parted.c
|
|
|
003ee8 |
@@ -979,7 +979,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
|
|
|
003ee8 |
"cpqarray", "file", "ataraid", "i2o",
|
|
|
003ee8 |
"ubd", "dasd", "viodasd", "sx8", "dm",
|
|
|
003ee8 |
"xvd", "sd/mmc", "virtblk", "aoe",
|
|
|
003ee8 |
- "md", "loopback", "nvme"};
|
|
|
003ee8 |
+ "md", "loopback", "nvme", "brd"};
|
|
|
003ee8 |
|
|
|
003ee8 |
char* start = ped_unit_format (dev, 0);
|
|
|
003ee8 |
PedUnit default_unit = ped_unit_get_default ();
|
|
|
003ee8 |
--
|
|
|
003ee8 |
2.9.3
|
|
|
003ee8 |
|