]> git.pld-linux.org Git - packages/util-linux.git/blame - util-linux-skipraid2.patch
- new
[packages/util-linux.git] / util-linux-skipraid2.patch
CommitLineData
5545a732
JR
1A RAID1 device cannot be mounted using its LABEL in /etc/fstab: mount says
2there's more than one partition with that label and bails out.
3
4--- util-linux-2.11y/mount/linux_fs.h.skipraid2 2002-10-07 09:08:22.000000000 -0400
5+++ util-linux-2.11y/mount/linux_fs.h 2003-01-13 14:42:57.000000000 -0500
6@@ -13,6 +13,12 @@
7 #endif
8 #endif
9
10+#include <inttypes.h>
11+#ifndef BLKGETSIZE64
12+#include <sys/ioctl.h>
13+#define BLKGETSIZE64 _IOR(0x12,114,sizeof(uint64_t))
14+#endif
15+
16 #define MINIX_SUPER_MAGIC 0x137F /* minix v1, 14 char names */
17 #define MINIX_SUPER_MAGIC2 0x138F /* minix v1, 30 char names */
18 #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2, 14 char names */
19--- util-linux-2.11y/mount/get_label_uuid.c.skipraid2 2003-01-13 14:44:04.000000000 -0500
20+++ util-linux-2.11y/mount/get_label_uuid.c 2003-01-13 14:46:34.000000000 -0500
21@@ -6,6 +6,8 @@
22 #include <unistd.h>
23 #include <stdlib.h>
24 #include <string.h>
25+#include <endian.h>
26+#include <sys/stat.h>
27
28 #include "linux_fs.h"
29 #include "get_label_uuid.h"
30@@ -19,28 +21,62 @@
31 * not on the disks that form the raid array. This test causes a lot of
32 * problems when run on my striped promise fasttrak 100 array."
33 */
34-static inline int
35-is_raid_partition(int fd) {
36-#if 0
37- struct mdp_super_block mdsb;
38- int n;
39-
40- /* hardcode 4096 here in various places, because that's
41- what it's defined to be. Note that even if we used
42- the actual kernel headers, sizeof(mdp_super_t) is
43- slightly larger in the 2.2 kernel on 64-bit archs,
44- so using that wouldn't work. */
45- lseek(fd, -4096, SEEK_END); /* Ignore possible error
46- about return value overflow */
47- n = 4096;
48- if (sizeof(mdsb) < n)
49- n = sizeof(mdsb);
50- if (read(fd, &mdsb, n) != n)
51- return 1; /* error */
52- return (mdsbmagic(mdsb) == MD_SB_MAGIC);
53+
54+#if BYTE_ORDER == BIG_ENDIAN
55+#define INT32_FROM_LE(val) ((unsigned int) ( \
56+ (((unsigned int) (val) & (unsigned int) 0x000000ffU) << 24) | \
57+ (((unsigned int) (val) & (unsigned int) 0x0000ff00U) << 8) | \
58+ (((unsigned int) (val) & (unsigned int) 0x00ff0000U) >> 8) | \
59+ (((unsigned int) (val) & (unsigned int) 0xff000000U) >> 24)))
60 #else
61- return 0;
62+#define INT32_FROM_LE(val) (val)
63+#endif
64+
65+typedef struct {
66+ unsigned int md_magic;
67+} mdp_super_t;
68+#ifndef MD_SB_MAGIC
69+#define MD_SB_MAGIC 0xa92b4efc
70+#endif
71+#ifndef MD_RESERVED_BYTES
72+#define MD_RESERVED_BYTES 65536L
73 #endif
74+#ifndef MD_NEW_SIZE_BYTES
75+#define MD_NEW_SIZE_BYTES(x) ((x & ~(MD_RESERVED_BYTES - 1L)) - MD_RESERVED_BYTES)
76+#endif
77+
78+static int
79+is_raid_partition(int fd)
80+{
81+ mdp_super_t mdsb;
82+ int n;
83+ struct stat sbuf;
84+ if(fstat(fd, &sbuf))
85+ return 2;
86+ if(!sbuf.st_size) {
87+ uint64_t bsize64;
88+ unsigned int bsize32;
89+ if(!ioctl(fd, BLKGETSIZE64, &bsize64))
90+ sbuf.st_size = bsize64;
91+ else if(!ioctl(fd, BLKGETSIZE, &bsize32))
92+ sbuf.st_size = bsize32;
93+ }
94+ if(!sbuf.st_size) return 3;
95+ /* hardcode 4096 here in various places,
96+ because that's what it's defined to be.
97+ Note that even if we used the actual kernel headers,
98+ sizeof(mdp_super_t) is slightly larger in the 2.2 kernel on 64-bit
99+ archs, so using that wouldn't work. */
100+ lseek(fd, MD_NEW_SIZE_BYTES(sbuf.st_size), SEEK_SET);
101+ n = 4096; if(sizeof(mdsb) < n) n = sizeof(mdsb);
102+ if(read(fd, &mdsb, n) != n)
103+ return 4; /* error */
104+ mdsb.md_magic = INT32_FROM_LE(mdsb.md_magic);
105+ return (mdsb.md_magic == MD_SB_MAGIC); /* If this device has a
106+ RAID superblock at
107+ the end, it must be
108+ part of a RAID
109+ array. */
110 }
111
112 /* for now, only ext2, ext3, xfs, ocfs are supported */
This page took 0.104663 seconds and 4 git commands to generate.