public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib/device dev-md.c
@ 2008-09-19 7:18 agk
0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2008-09-19 7:18 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2008-09-19 07:18:03
Modified files:
lib/device : dev-md.c
Log message:
.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
--- LVM2/lib/device/dev-md.c 2008/09/19 05:19:09 1.11
+++ LVM2/lib/device/dev-md.c 2008/09/19 07:18:03 1.12
@@ -171,7 +171,7 @@
goto out;
}
- log_very_verbose("Found chunksize %u for md device %s.", chunk_size,
+ log_very_verbose("Found chunksize %lu for md device %s.", chunk_size,
dev_name(dev));
out:
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib/device dev-md.c
@ 2009-07-20 18:44 snitzer
0 siblings, 0 replies; 5+ messages in thread
From: snitzer @ 2009-07-20 18:44 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2009-07-20 18:44:14
Modified files:
lib/device : dev-md.c
Log message:
Cast MINOR() in _md_sysfs_attribute_snprintf()'s dm_snprintf() call.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
--- LVM2/lib/device/dev-md.c 2009/07/20 18:33:16 1.15
+++ LVM2/lib/device/dev-md.c 2009/07/20 18:44:13 1.16
@@ -149,7 +149,7 @@
if (stat(path, &info) < 0) {
/* old sysfs structure */
ret = dm_snprintf(path, size, "%s/block/md%d/md/%s",
- sysfs_dir, MINOR(dev->dev), attribute);
+ sysfs_dir, (int)MINOR(dev->dev), attribute);
if (ret < 0) {
log_error("dm_snprintf old md %s failed", attribute);
return ret;
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib/device dev-md.c
@ 2009-07-20 18:33 snitzer
0 siblings, 0 replies; 5+ messages in thread
From: snitzer @ 2009-07-20 18:33 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2009-07-20 18:33:16
Modified files:
lib/device : dev-md.c
Log message:
Cast MAJOR() and MINOR() to int when used with "%d" in dm_snprintf() call.
Fixes SEGV in _md_sysfs_attribute_snprintf() on 32-bit systems.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
--- LVM2/lib/device/dev-md.c 2009/07/06 19:04:25 1.14
+++ LVM2/lib/device/dev-md.c 2009/07/20 18:33:16 1.15
@@ -139,8 +139,8 @@
if (!sysfs_dir || !*sysfs_dir)
return ret;
- ret = dm_snprintf(path, size, "%s/dev/block/%d:%d/md/%s",
- sysfs_dir, MAJOR(dev->dev), MINOR(dev->dev), attribute);
+ ret = dm_snprintf(path, size, "%s/dev/block/%d:%d/md/%s", sysfs_dir,
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), attribute);
if (ret < 0) {
log_error("dm_snprintf md %s failed", attribute);
return ret;
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib/device dev-md.c
@ 2007-10-24 11:24 agk
0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-10-24 11:24 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2007-10-24 11:24:24
Modified files:
lib/device : dev-md.c
Log message:
explanation of md superblock location & avoid compilation warnings
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
--- LVM2/lib/device/dev-md.c 2007/10/24 00:51:05 1.7
+++ LVM2/lib/device/dev-md.c 2007/10/24 11:24:24 1.8
@@ -22,7 +22,7 @@
/* Lifted from <linux/raid/md_p.h> because of difficulty including it */
#define MD_SB_MAGIC 0xa92b4efc
-#define MD_RESERVED_BYTES (64 * 1024)
+#define MD_RESERVED_BYTES (64 * 1024ULL)
#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) \
- MD_RESERVED_SECTORS)
@@ -40,14 +40,21 @@
return 0;
}
-/* FIXME Explain this algorithm */
-static uint64_t _v1_sb_offset(uint64_t size, int minor_version)
+/*
+ * Calculate the position of the superblock.
+ * It is always aligned to a 4K boundary and
+ * depending on minor_version, it can be:
+ * 0: At least 8K, but less than 12K, from end of device
+ * 1: At start of device
+ * 2: 4K from start of device.
+ */
+static uint64_t _v1_sb_offset(uint64_t size, unsigned minor_version)
{
uint64_t sb_offset;
switch(minor_version) {
case 0:
- sb_offset = (size - 8 * 2) & ~(4 * 2 - 1);
+ sb_offset = (size - 8 * 2) & ~(4 * 2 - 1ULL);
break;
case 1:
sb_offset = 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
* LVM2/lib/device dev-md.c
@ 2007-10-24 0:30 agk
0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-10-24 0:30 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2007-10-24 00:30:30
Modified files:
lib/device : dev-md.c
Log message:
refactor dev-md.c, separating out the magic number detection
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6
--- LVM2/lib/device/dev-md.c 2007/08/20 20:55:25 1.5
+++ LVM2/lib/device/dev-md.c 2007/10/24 00:30:30 1.6
@@ -17,6 +17,8 @@
#include "metadata.h"
#include "xlate.h"
+#ifdef linux
+
/* Lifted from <linux/raid/md_p.h> because of difficulty including it */
#define MD_SB_MAGIC 0xa92b4efc
@@ -25,6 +27,19 @@
#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) \
- MD_RESERVED_SECTORS)
+static int _dev_has_md_magic(struct device *dev, uint64_t sb_offset)
+{
+ uint32_t md_magic;
+
+ /* Version 1 is little endian; version 0.90.0 is machine endian */
+ if (dev_read(dev, sb_offset, sizeof(uint32_t), &md_magic) &&
+ ((md_magic == xlate32(MD_SB_MAGIC)) ||
+ (md_magic == MD_SB_MAGIC)))
+ return 1;
+
+ return 0;
+}
+
/*
* Returns -1 on error
*/
@@ -32,8 +47,6 @@
{
int ret = 0;
-#ifdef linux
-
uint64_t size, sb_offset;
uint32_t md_magic;
@@ -53,10 +66,7 @@
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
/* Check if it is an md component device. */
- /* Version 1 is little endian; version 0.90.0 is machine endian */
- if (dev_read(dev, sb_offset, sizeof(uint32_t), &md_magic) &&
- ((md_magic == xlate32(MD_SB_MAGIC)) ||
- (md_magic == MD_SB_MAGIC))) {
+ if (_dev_has_md_magic(dev, sb_offset)) {
if (sb)
*sb = sb_offset;
ret = 1;
@@ -65,7 +75,14 @@
if (!dev_close(dev))
stack;
-#endif
return ret;
}
+#else
+
+int dev_is_md(struct device *dev __attribute((unused)), uint64_t *sb __attribute((unused)))
+{
+ return 0;
+}
+
+#endif
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-20 18:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-19 7:18 LVM2/lib/device dev-md.c agk
-- strict thread matches above, loose matches on Subject: below --
2009-07-20 18:44 snitzer
2009-07-20 18:33 snitzer
2007-10-24 11:24 agk
2007-10-24 0:30 agk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).