[parted-devel] [PATCH 1/3] libparted: differentiate between plain files and loop devices

Petr Uzel petr.uzel at suse.cz
Thu Sep 29 13:14:22 UTC 2011


Stop using PED_DEVICE_FILE for loopback devices since loopback
is something other than plain files.

* include/parted/device.h (PedDeviceType): add PED_DEVICE_LOOP
* libparted/arch/linux.c (_device_probe_type): detect loopback
device
* parted/parted.c (do_print): add "loopback" to list of transports
---
 include/parted/device.h |    3 ++-
 libparted/arch/linux.c  |    7 ++++++-
 parted/parted.c         |    2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/parted/device.h b/include/parted/device.h
index a04d9fc..d76854a 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -47,7 +47,8 @@ typedef enum {
         PED_DEVICE_SDMMC        = 14,
         PED_DEVICE_VIRTBLK      = 15,
         PED_DEVICE_AOE          = 16,
-        PED_DEVICE_MD           = 17
+        PED_DEVICE_MD           = 17,
+        PED_DEVICE_LOOP         = 18
 } PedDeviceType;
 
 typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index ebf5d87..8488b7f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -594,7 +594,7 @@ _device_probe_type (PedDevice* dev)
         } else if (_is_virtblk_major(dev_major)) {
                 dev->type = PED_DEVICE_VIRTBLK;
         } else if (dev_major == LOOP_MAJOR) {
-                dev->type = PED_DEVICE_FILE;
+                dev->type = PED_DEVICE_LOOP;
         } else if (dev_major == MD_MAJOR) {
                 dev->type = PED_DEVICE_MD;
         } else {
@@ -1385,6 +1385,11 @@ linux_new (const char* path)
                         goto error_free_arch_specific;
                 break;
 
+        case PED_DEVICE_LOOP:
+                if (!init_generic (dev, _("Loopback device")))
+                        goto error_free_arch_specific;
+                break;
+
         case PED_DEVICE_DM:
                 {
                   char* type;
diff --git a/parted/parted.c b/parted/parted.c
index fa62cc4..bc14322 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -846,7 +846,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *disk)
                                          "cpqarray", "file", "ataraid", "i2o",
                                          "ubd", "dasd", "viodasd", "sx8", "dm",
                                          "xvd", "sd/mmc", "virtblk", "aoe",
-                                         "md"};
+                                         "md", "loopback"};
 
         char* start = ped_unit_format (dev, 0);
         PedUnit default_unit = ped_unit_get_default ();
-- 
1.7.3.4




More information about the parted-devel mailing list