[DRBD-cvs] r1612 - in branches/drbd-0.7/drbd: . linux
svn at svn.drbd.org
svn at svn.drbd.org
Mon Oct 25 16:52:40 CEST 2004
Author: lars
Date: 2004-10-25 16:52:38 +0200 (Mon, 25 Oct 2004)
New Revision: 1612
Added:
branches/drbd-0.7/drbd/drbd_sizeof_sanity_check.c
Modified:
branches/drbd-0.7/drbd/Makefile-2.4
branches/drbd-0.7/drbd/Makefile-2.6
branches/drbd-0.7/drbd/drbd_main.c
branches/drbd-0.7/drbd/linux/drbd.h
Log:
oh the wonders of kernel build.
added drbd_sizeof_sanity_check.c
which is compiled with -Wpadded -Werror
removed the __attribute__((packed)) from the ioctl structs again,
to avoid forcing misaligned longs for example.
Modified: branches/drbd-0.7/drbd/Makefile-2.4
===================================================================
--- branches/drbd-0.7/drbd/Makefile-2.4 2004-10-24 11:20:13 UTC (rev 1611)
+++ branches/drbd-0.7/drbd/Makefile-2.4 2004-10-25 14:52:38 UTC (rev 1612)
@@ -1,6 +1,9 @@
-drbd-objs := drbd_buildtag.o drbd_bitmap.o drbd_fs.o drbd_proc.o \
- drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o \
- lru_cache.o mempool-2.4.o drbd_main.o
+CFLAGS_drbd_sizeof_sanity_check.o = -Wpadded -Werror
+
+drbd-objs := drbd_sizeof_sanity_check.o \
+ drbd_buildtag.o drbd_bitmap.o drbd_fs.o drbd_proc.o \
+ drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o \
+ lru_cache.o mempool-2.4.o drbd_main.o
obj-$(CONFIG_BLK_DEV_DRBD) += drbd.o
list-multi := drbd.o
Modified: branches/drbd-0.7/drbd/Makefile-2.6
===================================================================
--- branches/drbd-0.7/drbd/Makefile-2.6 2004-10-24 11:20:13 UTC (rev 1611)
+++ branches/drbd-0.7/drbd/Makefile-2.6 2004-10-25 14:52:38 UTC (rev 1612)
@@ -1,4 +1,7 @@
-drbd-objs := drbd_buildtag.o drbd_bitmap.o drbd_fs.o drbd_proc.o \
- drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o \
- lru_cache.o drbd_main.o
+CFLAGS_drbd_sizeof_sanity_check.o = -Wpadded -Werror
+
+drbd-objs := drbd_sizeof_sanity_check.o \
+ drbd_buildtag.o drbd_bitmap.o drbd_fs.o drbd_proc.o \
+ drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o \
+ lru_cache.o drbd_main.o
obj-$(CONFIG_BLK_DEV_DRBD) += drbd.o
Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c 2004-10-24 11:20:13 UTC (rev 1611)
+++ branches/drbd-0.7/drbd/drbd_main.c 2004-10-25 14:52:38 UTC (rev 1612)
@@ -1685,6 +1685,7 @@
printk(KERN_INFO DEVICE_NAME": module cleanup done.\n");
}
+int sizeof_drbd_structs_sanity_check(void);
int __init drbd_init(void)
{
int i,err;
@@ -1723,6 +1724,9 @@
": never change the size or layout of the HandShake packet.\n");
return -EINVAL;
}
+ if (sizeof_drbd_structs_sanity_check()) {
+ return -EINVAL;
+ }
if (use_nbd_major) {
major_nr = NBD_MAJOR;
Added: branches/drbd-0.7/drbd/drbd_sizeof_sanity_check.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_sizeof_sanity_check.c 2004-10-24 11:20:13 UTC (rev 1611)
+++ branches/drbd-0.7/drbd/drbd_sizeof_sanity_check.c 2004-10-25 14:52:38 UTC (rev 1612)
@@ -0,0 +1,26 @@
+#include <linux/drbd.h>
+#include <linux/linkage.h>
+
+/* from linux/kernel.h */
+asmlinkage int printk(const char * fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+#define SZO(type,size) \
+ if (sizeof(type) != size) { \
+ printk("<3>sizeof(" #type ") != %d; " \
+ "ioctls won't work, aborting\n", size); \
+ return -1; \
+ }
+
+int sizeof_drbd_structs_sanity_check(void)
+{
+ SZO(struct disk_config, 24)
+ SZO(struct net_config, 300)
+ SZO(struct syncer_config, 20)
+ SZO(struct ioctl_disk_config, 28)
+ SZO(struct ioctl_net_config, 304)
+ SZO(struct ioctl_syncer_config, 24)
+ SZO(struct ioctl_wait, 12)
+ SZO(struct ioctl_get_config, 428)
+ return 0;
+}
Modified: branches/drbd-0.7/drbd/linux/drbd.h
===================================================================
--- branches/drbd-0.7/drbd/linux/drbd.h 2004-10-24 11:20:13 UTC (rev 1611)
+++ branches/drbd-0.7/drbd/linux/drbd.h 2004-10-25 14:52:38 UTC (rev 1612)
@@ -64,7 +64,7 @@
};
-struct __attribute__((packed)) disk_config {
+struct disk_config {
IN __u64 disk_size;
IN int lower_device;
IN enum io_error_handler on_io_error;
@@ -78,7 +78,7 @@
FreezeIO
};
-struct __attribute__((packed)) net_config {
+struct net_config {
IN char my_addr[MAX_SOCK_ADDR];
IN char other_addr[MAX_SOCK_ADDR];
IN int my_addr_len;
@@ -94,7 +94,7 @@
IN enum disconnect_handler on_disconnect;
};
-struct __attribute__((packed)) syncer_config {
+struct syncer_config {
int rate; /* KB/sec */
int use_csums; /* use checksum based syncing*/
int skip;
@@ -124,22 +124,22 @@
LDDeviceTooLarge,
};
-struct __attribute__((packed)) ioctl_disk_config {
+struct ioctl_disk_config {
struct disk_config config;
OUT enum ret_codes ret_code;
};
-struct __attribute__((packed)) ioctl_net_config {
+struct ioctl_net_config {
struct net_config config;
OUT enum ret_codes ret_code;
};
-struct __attribute__((packed)) ioctl_syncer_config {
+struct ioctl_syncer_config {
struct syncer_config config;
OUT enum ret_codes ret_code;
};
-struct __attribute__((packed)) ioctl_wait {
+struct ioctl_wait {
IN int wfc_timeout;
IN int degr_wfc_timeout;
OUT int ret_code;
@@ -191,7 +191,7 @@
# define BDEVNAME_SIZE 32
#endif
-struct __attribute__((packed)) ioctl_get_config {
+struct ioctl_get_config {
OUT __u64 disk_size_user;
OUT char lower_device_name[BDEVNAME_SIZE];
OUT char meta_device_name[BDEVNAME_SIZE];
More information about the drbd-cvs
mailing list