summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2004-11-01 04:49:34 +0000
committerNeil Brown <neilb@suse.de>2004-11-01 04:49:34 +0000
commitb5e64645037e99b5f05c9499b27b422ae60d23a9 (patch)
treef0999c8649d1488a367ee3d9442aff538ae366a8 /util.c
parente5329c3747a4e9eb7addbfaa59b8d5e8688ce2a1 (diff)
downloadmdadm-b5e64645037e99b5f05c9499b27b422ae60d23a9.tar.gz
mdadm-b5e64645037e99b5f05c9499b27b422ae60d23a9.tar.xz
mdadm-b5e64645037e99b5f05c9499b27b422ae60d23a9.zip
mdadm-1.8.0mdadm-1.8.0
Diffstat (limited to 'util.c')
-rw-r--r--util.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/util.c b/util.c
index 5ef59c0..121ddbb 100644
--- a/util.c
+++ b/util.c
@@ -212,15 +212,23 @@ int load_super(int fd, mdp_super_t *super)
* 6 - wrong major version
*/
unsigned long size;
+ unsigned long long dsize;
unsigned long long offset;
- if (ioctl(fd, BLKGETSIZE, &size))
- return 1;
+#ifdef BLKGETSIZE64
+ if (ioctl(fd, BLKGETSIZE64, &dsize) != 0)
+#endif
+ {
+ if (ioctl(fd, BLKGETSIZE, &size))
+ return 1;
+ else
+ dsize = size << 9;
+ }
- if (size < MD_RESERVED_SECTORS*2)
+ if (dsize < MD_RESERVED_SECTORS*2)
return 2;
- offset = MD_NEW_SIZE_SECTORS(size);
+ offset = MD_NEW_SIZE_SECTORS(dsize>>9);
offset *= 512;
@@ -242,16 +250,25 @@ int load_super(int fd, mdp_super_t *super)
int store_super(int fd, mdp_super_t *super)
{
- long size;
+ unsigned long size;
+ unsigned long long dsize;
+
long long offset;
- if (ioctl(fd, BLKGETSIZE, &size))
- return 1;
+#ifdef BLKGETSIZE64
+ if (ioctl(fd, BLKGETSIZE64, &dsize) != 0)
+#endif
+ {
+ if (ioctl(fd, BLKGETSIZE, &size))
+ return 1;
+ else
+ dsize = ((unsigned long long)size) << 9;
+ }
- if (size < MD_RESERVED_SECTORS*2)
+ if (dsize < MD_RESERVED_SECTORS*2)
return 2;
- offset = MD_NEW_SIZE_SECTORS(size);
+ offset = MD_NEW_SIZE_SECTORS(dsize>>9);
offset *= 512;