Update extended partition handling
PATCH 19/21 Update extended partition handling
Currently we don't handle extended partitions at all.
This patch implements a proper handling for extended partitions so that we first create the dm device for the extended partitions and then the logical partitions as dm devices on top of the device for the extended partition.
Signed-off-by Hannes Reinecke <[email protected]>
--- kpartx/devmapper.c | 29 ++++++++++ kpartx/devmapper.h | 1 + kpartx/dos.c | 7 +-- kpartx/kpartx.c | 153 ++++++++++++++++++++++++++++++++++++++++----------- kpartx/kpartx.h | 3 + 5 files changed, 156 insertions(+), 37 deletions(-)
kpartx/devmapper.c +29 -0
@@ -219,3 +219,32 @@ out:dm_task_destroy (dmt);return uuid; } + +int +dm_devn (char * mapname,int *major,int *minor) +{ +int r =1 ; +struct dm_task *dmt; +struct dm_info info; + +if (!(dmt =dm_task_create (DM_DEVICE_INFO ))) +return 0 ; + +if (!dm_task_set_name (dmt, mapname)) + goto out; + +if (!dm_task_run (dmt)) + goto out; + +if (!dm_task_get_info (dmt, &info)) + goto out; + + *major = info.major; + *minor = info.minor; + + r =0 ; +out: +dm_task_destroy (dmt); +return r; +} +
kpartx/devmapper.h +1 -0
@@ -6,3 +6,4 @@ int dm_map_present (char *);char *dm_mapname (int major,int minor);dev_t dm_get_first_dep (char *devname);char *dm_mapuuid (int major,int minor); +int dm_devn (char * mapname,int *major,int *minor);
kpartx/dos.c +3 -4
@@ -16,7 +16,7 @@ is_extended(int type) { }static int -read_extended_partition (int fd,struct partition *ep, +read_extended_partition (int fd,struct partition *ep,int en,struct slice *sp,int ns) {struct partition p;
@@ -53,6 +53,7 @@ read_extended_partition(int fd, struct pif (n < ns) { sp[n].start = here +le32_to_cpu (p.start_sect); sp[n].size =le32_to_cpu (p.nr_sects); + sp[n].container = en +1 ; n++; }else { fprintf(stderr,
@@ -97,9 +98,7 @@ read_dos_pt(int fd, struct slice all, stbreak ; }if (is_extended (p.sys_type)) { - n +=read_extended_partition (fd, &p, sp+n, ns-n); -/* hide the extended partition itself */ - sp[i].size =0 ; + n +=read_extended_partition (fd, &p, i, sp+n, ns-n); } }return n;
kpartx/kpartx.c +120 -33
249 lines not on this page · raw message
kpartx/kpartx.h +3 -0
@@ -22,6 +22,9 @@struct slice {unsigned long start;unsigned long size; +int container; +int major; +int minor; };typedef int (ptreader )(int fd,struct slice all,struct slice *sp,int ns);
Signature · 1 line
1.4.3.4