From: "Carsten Otte" <COTTE@de.ibm.com>
To: linux-kernel@vger.kernel.org, rgooch@ras.ucalgary.ca
Subject: [PATCH] linux-2.417 devfs 64bit portablility issue
Date: Mon, 11 Feb 2002 14:00:06 +0100 [thread overview]
Message-ID: <OFA3A51DAC.14854039-ONC1256B5D.0045F62F@de.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1153 bytes --]
Hi Richard, Hi List-Readers!
In linux-2.4.17/fs/devfs/util.c, I found the following code:
struct major_list
{
spinlock_t lock;
__u32 bits[8];
};
/* Block majors already assigned:
0-3, 7-9, 11-63, 65-99, 101-113, 120-127, 199, 201, 240-255
Total free: 122
*/
static struct major_list block_major_list =
{SPIN_LOCK_UNLOCKED,
{0xfffffb8f, /* Majors 0 to 31 */
0xffffffff, /* Majors 32 to 63 */
0xfffffffe, /* Majors 64 to 95 */
0xff03ffef, /* Majors 96 to 127 */
0x00000000, /* Majors 128 to 159 */
0x00000000, /* Majors 160 to 191 */
0x00000280, /* Majors 192 to 223 */
0xffff0000} /* Majors 224 to 255 */
};
Afterwards, the block_major_list.bits is processed using
find_first_zero_bit & set_bit out of asm/bitops.h.
Since bitops are only defined for the datatype long, this does
only work on 32-bit architectures (on 64 bit data gets
incorrectly alligned -not on 8byte boundary & the ordering of
the data is incorrect).
I attached a patch that should fix it for all architectures.
(See attached file: linux-2.4.17-devfs_fixup.diff)
with kind regards
Carsten Otte
[-- Attachment #2: linux-2.4.17-devfs_fixup.diff --]
[-- Type: application/octet-stream, Size: 3992 bytes --]
diff -ruN linux-2.4.17/fs/devfs/base.c linux-2.4.17-fixup/fs/devfs/base.c
--- linux-2.4.17/fs/devfs/base.c Thu Dec 27 19:53:05 2001
+++ linux-2.4.17-fixup/fs/devfs/base.c Wed Feb 6 17:49:00 2002
@@ -2318,6 +2318,7 @@
if (*str != ',') return 0; /* No more options */
++str;
}
+ devfs_init_major_lists();
return 1;
} /* End Function devfs_setup */
diff -ruN linux-2.4.17/fs/devfs/util.c linux-2.4.17-fixup/fs/devfs/util.c
--- linux-2.4.17/fs/devfs/util.c Fri Oct 26 20:00:52 2001
+++ linux-2.4.17-fixup/fs/devfs/util.c Wed Feb 6 18:02:29 2002
@@ -185,42 +185,88 @@
struct major_list
{
- spinlock_t lock;
- __u32 bits[8];
+ spinlock_t lock;
+ long bits[32/sizeof(long)];
};
+typedef struct _major_preallocated_entry
+{
+ int first_major;
+ int last_major;
+} major_preallocated_entry_t;
+
/* Block majors already assigned:
0-3, 7-9, 11-63, 65-99, 101-113, 120-127, 199, 201, 240-255
Total free: 122
*/
+
+static major_preallocated_entry_t block_major_preassigned_list[]=
+{
+ {0,3},
+ {7,9},
+ {11,63},
+ {65,99},
+ {101,113},
+ {120,127},
+ {199,199},
+ {201,201},
+ {240,255},
+ {-1,-1} /* end of list marker */
+};
+
+
static struct major_list block_major_list =
-{SPIN_LOCK_UNLOCKED,
- {0xfffffb8f, /* Majors 0 to 31 */
- 0xffffffff, /* Majors 32 to 63 */
- 0xfffffffe, /* Majors 64 to 95 */
- 0xff03ffef, /* Majors 96 to 127 */
- 0x00000000, /* Majors 128 to 159 */
- 0x00000000, /* Majors 160 to 191 */
- 0x00000280, /* Majors 192 to 223 */
- 0xffff0000} /* Majors 224 to 255 */
+{SPIN_LOCK_UNLOCKED,
};
/* Char majors already assigned:
0-7, 9-151, 154-158, 160-211, 216-221, 224-230, 240-255
Total free: 19
*/
+
+static major_preallocated_entry_t char_major_preassigned_list[]=
+{
+ {0,7},
+ {9,151},
+ {154,158},
+ {160,211},
+ {224,230},
+ {240,255},
+ {-1,-1} /* end of list marker */
+};
+
static struct major_list char_major_list =
{SPIN_LOCK_UNLOCKED,
- {0xfffffeff, /* Majors 0 to 31 */
- 0xffffffff, /* Majors 32 to 63 */
- 0xffffffff, /* Majors 64 to 95 */
- 0xffffffff, /* Majors 96 to 127 */
- 0x7cffffff, /* Majors 128 to 159 */
- 0xffffffff, /* Majors 160 to 191 */
- 0x3f0fffff, /* Majors 192 to 223 */
- 0xffff007f} /* Majors 224 to 255 */
};
+/**
+ * devfs_init_major_lists - Initialize major used bitmaps
+ *
+ */
+void devfs_init_major_lists (void)
+{
+ int i;
+ major_preallocated_entry_t* entry;
+ // clear all bits
+ for (i=0; i<(32/sizeof(long)) ; i++) {
+ block_major_list.bits[i] = 0;
+ char_major_list.bits[i] = 0;
+ }
+ // set bits in block_major_list and char_major_list of preassigned majors
+ for (entry=&char_major_preassigned_list[0];
+ (entry->first_major!=-1) && (entry->last_major!=-1);
+ entry++) {
+ for (i=entry->first_major; i<=entry->last_major; i++)
+ __set_bit (i, char_major_list.bits);
+ }
+ // set bits in block_major_list and char_major_list of preassigned majors
+ for (entry=&block_major_preassigned_list[0];
+ (entry->first_major!=-1) && (entry->last_major!=-1);
+ entry++) {
+ for (i=entry->first_major; i<=entry->last_major; i++)
+ __set_bit (i, block_major_list.bits);
+ }
+}
/**
* devfs_alloc_major - Allocate a major number.
diff -ruN linux-2.4.17/include/linux/devfs_fs_kernel.h linux-2.4.17-fixup/include/linux/devfs_fs_kernel.h
--- linux-2.4.17/include/linux/devfs_fs_kernel.h Thu Dec 27 19:53:07 2001
+++ linux-2.4.17-fixup/include/linux/devfs_fs_kernel.h Thu Feb 7 15:58:00 2002
@@ -115,6 +115,7 @@
unsigned int flags, unsigned int major,
unsigned int minor_start,
umode_t mode, void *ops, void *info);
+extern void devfs_init_major_lists (void);
extern int devfs_alloc_major (char type);
extern void devfs_dealloc_major (char type, int major);
extern kdev_t devfs_alloc_devnum (char type);
next reply other threads:[~2002-02-11 15:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-11 13:00 Carsten Otte [this message]
2002-02-11 16:12 ` Russell King
2002-02-11 21:05 ` Anton Blanchard
2002-02-12 0:33 ` David S. Miller
2002-02-18 1:02 ` Richard Gooch
2002-02-12 11:18 Carsten Otte
2002-02-18 10:01 Carsten Otte
2002-02-18 17:56 ` Richard Gooch
2002-02-21 14:48 Carsten Otte
2002-03-20 12:27 Carsten Otte
2002-03-25 2:28 ` Richard Gooch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OFA3A51DAC.14854039-ONC1256B5D.0045F62F@de.ibm.com \
--to=cotte@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rgooch@ras.ucalgary.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®