[PATCH 05/17] Util: get device size from id
am 29.10.2010 16:19:50 von anna.czarnowskaFrom c0bbe01f5f73d123af899338e838d45df1a4abee Mon Sep 17 00:00:00 2001
From: Anna Czarnowska
Date: Fri, 22 Oct 2010 13:23:15 +0200
Subject: [PATCH 05/17] Util: get device size from id
Signed-off-by: Anna Czarnowska
---
mdadm.h | 1 +
util.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index 450fb11..66363fb 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -745,6 +745,7 @@ static inline struct supertype *guess_super(int fd) {
}
extern struct supertype *dup_super(struct supertype *st);
extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
+extern int dev_size_from_id(unsigned id, unsigned long long *size);
extern void get_one_disk(int mdfd, mdu_array_info_t *ainf,
mdu_disk_info_t *disk);
void wait_for(char *dev, int fd);
diff --git a/util.c b/util.c
index bb85253..e340600 100644
--- a/util.c
+++ b/util.c
@@ -1160,6 +1160,24 @@ int get_dev_size(int fd, char *dname, unsigned long long *sizep)
return 1;
}
+int dev_size_from_id(unsigned id, unsigned long long *size)
+{
+ char *dv;
+ int fd;
+
+ dv = map_dev(major(id), minor(id), 1);
+ if (!dv)
+ return 0;
+ fd = open(dv, O_RDONLY);
+ if (fd < 0)
+ return 0;
+ if (get_dev_size(fd, dv, size)) {
+ close(fd);
+ return 1;
+ }
+ close(fd);
+ return 0;
+}
/* Sets endofpart parameter to the last block used by the last GPT partition on the device.
* Returns: 1 if successful
--
1.6.4.2
------------------------------------------------------------ ---------
Intel Technology Poland sp. z o.o.
z siedziba w Gdansku
ul. Slowackiego 173
80-298 Gdansk
Sad Rejonowy Gdansk Polnoc w Gdansku,
VII Wydzial Gospodarczy Krajowego Rejestru Sadowego,
numer KRS 101882
NIP 957-07-52-316
Kapital zakladowy 200.000 zl
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html