Accepting request 494630 from home:sparschauer:branches:Base:System
Add support for RAM drives (bsc#1006834) OBS-URL: https://build.opensuse.org/request/show/494630 OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=126
This commit is contained in:
parent
ef69beac35
commit
942f78ffab
95
libparted-Add-support-for-RAM-drives.patch
Normal file
95
libparted-Add-support-for-RAM-drives.patch
Normal file
@ -0,0 +1,95 @@
|
||||
From: Sebastian Parschauer <sparschauer@suse.de>
|
||||
Date: Tue, 14 Mar 2017 16:40:00 +0100
|
||||
Subject: Add support for RAM drives
|
||||
References: bsc#1006834
|
||||
Patch-mainline: v3.3
|
||||
Git-commit: 21131f62c6f508a5d0c080e025cf7db5df43fc7d
|
||||
|
||||
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>
|
||||
---
|
||||
include/parted/device.in.h | 3 ++-
|
||||
libparted/arch/linux.c | 12 ++++++++++--
|
||||
parted/parted.c | 2 +-
|
||||
3 files changed, 13 insertions(+), 4 deletions(-)
|
||||
|
||||
--- 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;
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -280,6 +280,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 \
|
||||
@@ -721,6 +722,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;
|
||||
}
|
||||
@@ -1553,6 +1556,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,
|
||||
@@ -1625,9 +1633,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;
|
||||
|
||||
--- a/parted/parted.c
|
||||
+++ b/parted/parted.c
|
||||
@@ -1035,7 +1035,7 @@ _print_disk_info (const PedDevice *dev,
|
||||
"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 ();
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu May 11 12:53:20 CEST 2017 - sparschauer@suse.de
|
||||
|
||||
- Add support for RAM drives for not erasing them when printing
|
||||
their partitions (bsc#1006834)
|
||||
- add: libparted-Add-support-for-RAM-drives.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue May 2 10:45:37 CEST 2017 - sparschauer@suse.de
|
||||
|
||||
|
@ -67,6 +67,7 @@ Patch37: libparted-dont-warn-if-no-HDIO_GET_IDENTITY.patch
|
||||
Patch38: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
|
||||
Patch39: libparted-dasd-update-and-improve-fdasd-functions.patch
|
||||
Patch40: libparted-dasd-add-new-fdasd-functions.patch
|
||||
Patch41: libparted-Add-support-for-RAM-drives.patch
|
||||
Patch100: parted-fatresize-autoconf.patch
|
||||
BuildRequires: check-devel
|
||||
BuildRequires: device-mapper-devel >= 1.02.33
|
||||
@ -150,6 +151,7 @@ to develop applications that require these.
|
||||
%patch38 -p1
|
||||
%patch39 -p1
|
||||
%patch40 -p1
|
||||
%patch41 -p1
|
||||
%patch100 -p1
|
||||
|
||||
%build
|
||||
|
Loading…
x
Reference in New Issue
Block a user