]> git.pld-linux.org Git - packages/parted.git/blame - 0070-Add-support-for-RAM-drives.patch
- release 6 (by relup.sh)
[packages/parted.git] / 0070-Add-support-for-RAM-drives.patch
CommitLineData
c886eb9d
AM
1From eb927155680f75e570dc7375514e344a936a3fb5 Mon Sep 17 00:00:00 2001
2From: "Brian C. Lane" <bcl@redhat.com>
3Date: Mon, 1 May 2017 17:05:01 -0700
4Subject: [PATCH 70/75] Add support for RAM drives
5
6Recognize RAM drives, so "parted -s /dev/ram0 p" now prints
7"RAM Drive (brd)" instead of "Model: Unknown (unknown)".
8
9In order for a device to be recognized as RAM drive, it has to
10have major number 1. Also the BLKFLSBUF ioctl shouldn't be used
11on RAM drives as it is used to zero the device.
12
13* NEWS: Mention the change
14* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_RAM.
15* libparted/arch/linux.c(RAM_MAJOR): New define.
16* libparted/arch/linux.c(_device_probe_type): Recognize RAM drives.
17* libparted/arch/linux.c(linux_new): Handle RAM drives.
18* libparted/arch/linux.c(_flush_cache): Skip RAM drives.
19* parted/parted.c(do_print): Add "brd" to list of transports.
20
21Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
22---
23 include/parted/device.in.h | 3 ++-
24 libparted/arch/linux.c | 12 ++++++++++--
25 parted/parted.c | 2 +-
26 3 files changed, 13 insertions(+), 4 deletions(-)
27
28diff --git a/include/parted/device.in.h b/include/parted/device.in.h
29index d38db44..1b6e7b8 100644
30--- a/include/parted/device.in.h
31+++ b/include/parted/device.in.h
32@@ -50,7 +50,8 @@ typedef enum {
33 PED_DEVICE_AOE = 16,
34 PED_DEVICE_MD = 17,
35 PED_DEVICE_LOOP = 18,
36- PED_DEVICE_NVME = 19
37+ PED_DEVICE_NVME = 19,
38+ PED_DEVICE_RAM = 20
39 } PedDeviceType;
40
41 typedef struct _PedDevice PedDevice;
42diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
43index 2058697..c2fdab0 100644
44--- a/libparted/arch/linux.c
45+++ b/libparted/arch/linux.c
46@@ -279,6 +279,7 @@ struct blkdev_ioctl_param {
47 #define LOOP_MAJOR 7
48 #define MD_MAJOR 9
49 #define BLKEXT_MAJOR 259
50+#define RAM_MAJOR 1
51
52 #define SCSI_BLK_MAJOR(M) ( \
53 (M) == SCSI_DISK0_MAJOR \
54@@ -701,6 +702,8 @@ _device_probe_type (PedDevice* dev)
55 dev->type = PED_DEVICE_MD;
56 } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
57 dev->type = PED_DEVICE_NVME;
58+ } else if (dev_major == RAM_MAJOR) {
59+ dev->type = PED_DEVICE_RAM;
60 } else {
61 dev->type = PED_DEVICE_UNKNOWN;
62 }
63@@ -1547,6 +1550,11 @@ linux_new (const char* path)
64 goto error_free_arch_specific;
65 break;
66
67+ case PED_DEVICE_RAM:
68+ if (!init_generic (dev, _("RAM Drive")))
69+ goto error_free_arch_specific;
70+ break;
71+
72 default:
73 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
74 PED_EXCEPTION_CANCEL,
75@@ -1619,9 +1627,9 @@ _flush_cache (PedDevice* dev)
76 {
77 LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
78 int i;
79- int lpn = _device_get_partition_range(dev);
80+ int lpn = _device_get_partition_range(dev);
81
82- if (dev->read_only)
83+ if (dev->read_only || dev->type == PED_DEVICE_RAM)
84 return;
85 dev->dirty = 0;
86
87diff --git a/parted/parted.c b/parted/parted.c
88index f767bec..a7fcd3b 100644
89--- a/parted/parted.c
90+++ b/parted/parted.c
91@@ -979,7 +979,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
92 "cpqarray", "file", "ataraid", "i2o",
93 "ubd", "dasd", "viodasd", "sx8", "dm",
94 "xvd", "sd/mmc", "virtblk", "aoe",
95- "md", "loopback", "nvme"};
96+ "md", "loopback", "nvme", "brd"};
97
98 char* start = ped_unit_format (dev, 0);
99 PedUnit default_unit = ped_unit_get_default ();
100--
1012.9.3
102
This page took 0.039551 seconds and 4 git commands to generate.