[Fwd: [PATCH] libvolume_id fixes for solaris]

Artem Kachitchkine Artem.Kachitchkin at Sun.COM
Sat Feb 25 13:08:50 PST 2006


Gentle reminder. Thank you.

-Artem.

-------- Original Message --------
Subject: [PATCH] libvolume_id fixes for solaris
Date: Mon, 20 Feb 2006 12:49:40 -0800
From: Artem Kachitchkine <Artem.Kachitchkin at Sun.COM>
To: HAL Development List <hal at freedesktop.org>


Changes required for libvolume_id to compile and work correctly on Solaris:

- Sun compiler uses pragma instead of __attribute__ for packed structs;
- if configure detects absense of strnlen(), utils.c will provide a local
implementation;
- different byteorder functions;
- some filesystems are called differently.

Sorry there isn't a more elegant way to conditionally insert pragmas 
than ifdefs in each file. Actually gcc seems to recognize #pragma 
pack(), but I hear it might not be present in all gcc versions/platforms 
and I wasn't completely comfortable changing Linux code.

-Artem.


-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvs/hal/hal/configure.in,v
retrieving revision 1.118
diff -u -r1.118 configure.in
--- configure.in	13 Feb 2006 07:29:44 -0000	1.118
+++ configure.in	20 Feb 2006 19:20:58 -0000
@@ -297,6 +297,8 @@
   esac
 fi
 
+AC_CHECK_FUNCS(strnlen)
+
 # DocBook Documentation
 
 AC_PATH_PROG(DOCBOOK, docbook2html, no)
Index: volume_id/cramfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/cramfs.c,v
retrieving revision 1.6
diff -u -r1.6 cramfs.c
--- volume_id/cramfs.c	15 Nov 2005 03:32:36 -0000	1.6
+++ volume_id/cramfs.c	20 Feb 2006 19:20:59 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct cramfs_super {
 	uint8_t		magic[4];
 	uint32_t	size;
@@ -42,6 +46,10 @@
 	uint8_t		name[16];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 int volume_id_probe_cramfs(struct volume_id *id, uint64_t off)
 {
 	struct cramfs_super *cs;
Index: volume_id/ext.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ext.c,v
retrieving revision 1.7
diff -u -r1.7 ext.c
--- volume_id/ext.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/ext.c	20 Feb 2006 19:20:59 -0000
@@ -27,6 +27,10 @@
 #include "util.h"
 #include "logging.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct ext2_super_block {
 	uint32_t	s_inodes_count;
 	uint32_t	s_blocks_count;
@@ -63,6 +67,10 @@
 	uint8_t		s_volume_name[16];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define EXT_SUPER_MAGIC				0xEF53
 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL		0x00000004
 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x00000008
Index: volume_id/fat.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/fat.c,v
retrieving revision 1.10
diff -u -r1.10 fat.c
--- volume_id/fat.c	21 Nov 2005 17:55:13 -0000	1.10
+++ volume_id/fat.c	20 Feb 2006 19:20:59 -0000
@@ -35,6 +35,10 @@
 #define FAT_ATTR_MASK			0x3f
 #define FAT_ENTRY_FREE			0xe5
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct vfat_super_block {
 	uint8_t		boot_jump[3];
 	uint8_t		sysid[8];
@@ -91,6 +95,10 @@
 	uint32_t	size;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 static uint8_t *get_attr_volume_id(struct vfat_dir_entry *dir, unsigned int count)
 {
 	unsigned int i;
@@ -344,7 +352,11 @@
 
 found:
 	volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
+#ifndef sun
 	id->type = "vfat";
+#else
+	id->type = "pcfs";
+#endif
 
 	return 0;
 }
Index: volume_id/hfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/hfs.c,v
retrieving revision 1.7
diff -u -r1.7 hfs.c
--- volume_id/hfs.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/hfs.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct hfs_finder_info{
 	uint32_t	boot_folder;
 	uint32_t	start_app;
@@ -134,6 +138,10 @@
 	struct hfsplus_fork start_file;
 } __attribute__((__packed__)) *hfsplus;
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define HFS_SUPERBLOCK_OFFSET		0x400
 #define HFS_NODE_LEAF			0xff
 #define HFSPLUS_POR_CNID		1
Index: volume_id/highpoint.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/highpoint.c,v
retrieving revision 1.8
diff -u -r1.8 highpoint.c
--- volume_id/highpoint.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/highpoint.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct hpt37x_meta {
 	uint8_t		filler1[32];
 	uint32_t	magic;
@@ -36,6 +40,10 @@
 	uint32_t	magic;
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define HPT37X_CONFIG_OFF		0x1200
 #define HPT37X_MAGIC_OK			0x5a7816f0
 #define HPT37X_MAGIC_BAD		0x5a7816fd
Index: volume_id/hpfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/hpfs.c,v
retrieving revision 1.6
diff -u -r1.6 hpfs.c
--- volume_id/hpfs.c	15 Nov 2005 03:32:36 -0000	1.6
+++ volume_id/hpfs.c	20 Feb 2006 19:21:00 -0000
@@ -27,12 +27,20 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct hpfs_super
 {
 	uint8_t		magic[4];
 	uint8_t		version;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define HPFS_SUPERBLOCK_OFFSET			0x2000
 
 int volume_id_probe_hpfs(struct volume_id *id, uint64_t off)
Index: volume_id/iso9660.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/iso9660.c,v
retrieving revision 1.8
diff -u -r1.8 iso9660.c
--- volume_id/iso9660.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/iso9660.c	20 Feb 2006 19:21:00 -0000
@@ -35,6 +35,10 @@
 #define ISO_VD_END			0xff
 #define ISO_VD_MAX			16
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct iso_volume_descriptor {
 	uint8_t		vd_type;
 	uint8_t		vd_id[5];
@@ -54,6 +58,10 @@
 	uint8_t		version;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 int volume_id_probe_iso9660(struct volume_id *id, uint64_t off)
 {
 	uint8_t *buf;
Index: volume_id/isw_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/isw_raid.c,v
retrieving revision 1.6
diff -u -r1.6 isw_raid.c
--- volume_id/isw_raid.c	15 Nov 2005 03:32:36 -0000	1.6
+++ volume_id/isw_raid.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct isw_meta {
 	uint8_t		sig[32];
 	uint32_t	check_sum;
@@ -35,6 +39,10 @@
 	uint32_t	generation_num;
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define ISW_SIGNATURE		"Intel Raid ISM Cfg Sig. "
 
 
Index: volume_id/jfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/jfs.c,v
retrieving revision 1.7
diff -u -r1.7 jfs.c
--- volume_id/jfs.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/jfs.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct jfs_super_block {
 	uint8_t		magic[4];
 	uint32_t	version;
@@ -40,6 +44,10 @@
 	uint8_t		loguuid[16];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define JFS_SUPERBLOCK_OFFSET			0x8000
 
 int volume_id_probe_jfs(struct volume_id *id, uint64_t off)
Index: volume_id/linux_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/linux_raid.c,v
retrieving revision 1.8
diff -u -r1.8 linux_raid.c
--- volume_id/linux_raid.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/linux_raid.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct mdp_super_block {
 	uint32_t	md_magic;
 	uint32_t	major_version;
@@ -46,6 +50,10 @@
 	uint32_t	set_uuid3;
 } __attribute__((packed)) *mdp;
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define MD_RESERVED_BYTES		0x10000
 #define MD_MAGIC			0xa92b4efc
 
Index: volume_id/linux_swap.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/linux_swap.c,v
retrieving revision 1.7
diff -u -r1.7 linux_swap.c
--- volume_id/linux_swap.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/linux_swap.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct swap_header_v1_2 {
 	uint8_t		bootbits[1024];
 	uint32_t	version;
@@ -36,6 +40,10 @@
 	uint8_t		volume_name[16];
 } __attribute__((__packed__)) *sw;
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define LARGEST_PAGESIZE			0x4000
 
 int volume_id_probe_linux_swap(struct volume_id *id, uint64_t off)
Index: volume_id/lsi_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/lsi_raid.c,v
retrieving revision 1.5
diff -u -r1.5 lsi_raid.c
--- volume_id/lsi_raid.c	15 Nov 2005 03:32:36 -0000	1.5
+++ volume_id/lsi_raid.c	20 Feb 2006 19:21:00 -0000
@@ -27,10 +27,18 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct lsi_meta {
 	uint8_t		sig[6];
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 #define LSI_SIGNATURE		"$XIDE$"
 
 int volume_id_probe_lsi_mega_raid(struct volume_id *id, uint64_t off, uint64_t size)
Index: volume_id/luks.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/luks.c,v
retrieving revision 1.8
diff -u -r1.8 luks.c
--- volume_id/luks.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/luks.c	20 Feb 2006 19:21:00 -0000
@@ -42,6 +42,10 @@
 #define LUKS_PHDR_SIZE (sizeof(struct luks_phdr)/SECTOR_SIZE+1)
 #define UUID_STRING_L 40
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct luks_phdr {
 	uint8_t		magic[LUKS_MAGIC_L];
 	uint16_t	version;
@@ -63,6 +67,10 @@
 	} keyblock[LUKS_NUMKEYS];
 };
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 int volume_id_probe_luks(struct volume_id *id, uint64_t off)
 {
 	struct luks_phdr *header;
Index: volume_id/lvm.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/lvm.c,v
retrieving revision 1.8
diff -u -r1.8 lvm.c
--- volume_id/lvm.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/lvm.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct lvm1_super_block {
 	uint8_t	id[2];
 } __attribute__((packed));
@@ -39,6 +43,10 @@
 	uint8_t		type[8];
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define LVM1_SB_OFF			0x400
 #define LVM1_MAGIC			"HM"
 
Index: volume_id/mac.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/mac.c,v
retrieving revision 1.8
diff -u -r1.8 mac.c
--- volume_id/mac.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/mac.c	20 Feb 2006 19:21:00 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct mac_driver_desc {
 	uint8_t		signature[2];
 	uint16_t	block_size;
@@ -43,6 +47,10 @@
 	uint8_t		type[32];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 int volume_id_probe_mac_partition_map(struct volume_id *id, uint64_t off)
 {
 	const uint8_t *buf;
Index: volume_id/minix.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/minix.c,v
retrieving revision 1.5
diff -u -r1.5 minix.c
--- volume_id/minix.c	15 Nov 2005 03:32:36 -0000	1.5
+++ volume_id/minix.c	20 Feb 2006 19:21:01 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct minix_super_block
 {
 	uint16_t	s_ninodes;
@@ -41,6 +45,10 @@
 	uint32_t	s_zones;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define MINIX_SUPERBLOCK_OFFSET			0x400
 
 int volume_id_probe_minix(struct volume_id *id, uint64_t off)
Index: volume_id/msdos.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/msdos.c,v
retrieving revision 1.7
diff -u -r1.7 msdos.c
--- volume_id/msdos.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/msdos.c	20 Feb 2006 19:21:01 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct msdos_partition_entry {
 	uint8_t		boot_ind;
 	uint8_t		head;
@@ -40,6 +44,10 @@
 	uint32_t	nr_sects;
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define MSDOS_MAGIC			"\x55\xaa"
 #define MSDOS_PARTTABLE_OFFSET		0x1be
 #define MSDOS_SIG_OFF			0x1fe
Index: volume_id/ntfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ntfs.c,v
retrieving revision 1.8
diff -u -r1.8 ntfs.c
--- volume_id/ntfs.c	15 Nov 2005 03:32:36 -0000	1.8
+++ volume_id/ntfs.c	20 Feb 2006 19:21:01 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct ntfs_super_block {
 	uint8_t		jump[3];
 	uint8_t		oem_id[8];
@@ -85,6 +89,10 @@
 	uint8_t		minor_ver;
 } __attribute__((__packed__)) *info;
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define MFT_RECORD_VOLUME			3
 #define MFT_RECORD_ATTR_VOLUME_NAME		0x60
 #define MFT_RECORD_ATTR_VOLUME_INFO		0x70
Index: volume_id/nvidia_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/nvidia_raid.c,v
retrieving revision 1.5
diff -u -r1.5 nvidia_raid.c
--- volume_id/nvidia_raid.c	15 Nov 2005 03:32:36 -0000	1.5
+++ volume_id/nvidia_raid.c	20 Feb 2006 19:21:01 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct nvidia_meta {
 	uint8_t		vendor[8];
 	uint32_t	size;
@@ -34,6 +38,10 @@
 	uint16_t	version;
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define NVIDIA_SIGNATURE		"NVIDIA"
 
 int volume_id_probe_nvidia_raid(struct volume_id *id, uint64_t off, uint64_t size)
Index: volume_id/ocfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ocfs.c,v
retrieving revision 1.2
diff -u -r1.2 ocfs.c
--- volume_id/ocfs.c	15 Nov 2005 03:32:36 -0000	1.2
+++ volume_id/ocfs.c	20 Feb 2006 19:21:01 -0000
@@ -28,6 +28,9 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
 
 struct ocfs1_super_block_header {
 	uint32_t	minor_version;
@@ -127,6 +130,10 @@
 	uint8_t		s_uuid[16];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 int volume_id_probe_ocfs1(struct volume_id *id, uint64_t off)
 {
 	const uint8_t *buf;
Index: volume_id/promise_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/promise_raid.c,v
retrieving revision 1.5
diff -u -r1.5 promise_raid.c
--- volume_id/promise_raid.c	15 Nov 2005 03:32:36 -0000	1.5
+++ volume_id/promise_raid.c	20 Feb 2006 19:21:01 -0000
@@ -27,10 +27,18 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct promise_meta {
 	uint8_t	sig[24];
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define PDC_CONFIG_OFF		0x1200
 #define PDC_SIGNATURE		"Promise Technology, Inc."
 
Index: volume_id/reiserfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/reiserfs.c,v
retrieving revision 1.9
diff -u -r1.9 reiserfs.c
--- volume_id/reiserfs.c	15 Nov 2005 03:32:36 -0000	1.9
+++ volume_id/reiserfs.c	20 Feb 2006 19:21:01 -0000
@@ -28,6 +28,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct reiserfs_super_block {
 	uint32_t	blocks_count;
 	uint32_t	free_blocks;
@@ -52,6 +56,10 @@
 	uint64_t	dummy2;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define REISERFS1_SUPERBLOCK_OFFSET		0x2000
 #define REISERFS_SUPERBLOCK_OFFSET		0x10000
 
Index: volume_id/romfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/romfs.c,v
retrieving revision 1.7
diff -u -r1.7 romfs.c
--- volume_id/romfs.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/romfs.c	20 Feb 2006 19:21:01 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct romfs_super {
 	uint8_t magic[8];
 	uint32_t size;
@@ -34,6 +38,10 @@
 	uint8_t name[0];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 int volume_id_probe_romfs(struct volume_id *id, uint64_t off)
 {
 	struct romfs_super *rfs;
Index: volume_id/silicon_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/silicon_raid.c,v
retrieving revision 1.5
diff -u -r1.5 silicon_raid.c
--- volume_id/silicon_raid.c	15 Nov 2005 03:32:36 -0000	1.5
+++ volume_id/silicon_raid.c	20 Feb 2006 19:21:01 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct silicon_meta {
 	uint8_t		unknown0[0x2E];
 	uint8_t		ascii_version[0x36 - 0x2E];
@@ -46,6 +50,10 @@
 	uint16_t	major_ver;
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define SILICON_MAGIC		0x2F000000
 
 int volume_id_probe_silicon_medley_raid(struct volume_id *id, uint64_t off, uint64_t size)
Index: volume_id/sysv.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/sysv.c,v
retrieving revision 1.7
diff -u -r1.7 sysv.c
--- volume_id/sysv.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/sysv.c	20 Feb 2006 19:21:01 -0000
@@ -30,6 +30,10 @@
 #define SYSV_NICINOD			100
 #define SYSV_NICFREE			50
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct sysv_super
 {
 	uint16_t	s_isize;
@@ -84,6 +88,10 @@
 	uint32_t	s_type;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define SYSV_SUPERBLOCK_BLOCK			0x01
 #define SYSV_MAGIC				0xfd187e20
 #define XENIX_SUPERBLOCK_BLOCK			0x18
Index: volume_id/udf.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/udf.c,v
retrieving revision 1.7
diff -u -r1.7 udf.c
--- volume_id/udf.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/udf.c	20 Feb 2006 19:21:02 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct volume_descriptor {
 	struct descriptor_tag {
 		uint16_t	id;
@@ -60,6 +64,10 @@
 	uint8_t		version;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define UDF_VSD_OFFSET			0x8000
 
 int volume_id_probe_udf(struct volume_id *id, uint64_t off)
@@ -173,7 +181,11 @@
 
 found:
 	volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
+#ifndef sun
 	id->type = "udf";
+#else
+	id->type = "udfs";
+#endif
 
 	return 0;
 }
Index: volume_id/ufs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ufs.c,v
retrieving revision 1.7
diff -u -r1.7 ufs.c
--- volume_id/ufs.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/ufs.c	20 Feb 2006 19:21:02 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct ufs_super_block {
 	uint32_t	fs_link;
 	uint32_t	fs_rlink;
@@ -164,6 +168,10 @@
 	uint8_t		fs_space[1];
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define UFS_MAGIC			0x00011954
 #define UFS2_MAGIC			0x19540119
 #define UFS_MAGIC_FEA			0x00195612
Index: volume_id/util.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/util.c,v
retrieving revision 1.8
diff -u -r1.8 util.c
--- volume_id/util.c	23 Oct 2005 20:11:00 -0000	1.8
+++ volume_id/util.c	20 Feb 2006 19:21:02 -0000
@@ -274,3 +274,18 @@
 		id->seekbuf_len = 0;
 	}
 }
+
+#ifndef HAVE_STRNLEN
+size_t strnlen(const char *s, size_t n)
+{
+        char *ptr;
+
+        if (s == NULL)
+                return (n);
+        ptr = memchr(s, 0, n);
+        if (ptr == NULL)
+                return (n);
+
+        return ((ptr - s) + 1);
+}
+#endif
Index: volume_id/util.h
===================================================================
RCS file: /cvs/hal/hal/volume_id/util.h,v
retrieving revision 1.9
diff -u -r1.9 util.h
--- volume_id/util.h	15 Nov 2005 03:32:36 -0000	1.9
+++ volume_id/util.h	20 Feb 2006 19:21:02 -0000
@@ -19,16 +19,34 @@
 #  include <config.h>
 #endif
 
+#ifdef sun
+#include <sys/byteorder.h>
+#define bswap8  BSWAP_8
+#define bswap16 BSWAP_16
+#define bswap32 BSWAP_32
+#define bswap64 BSWAP_64
+#else
 #include <endian.h>
 #include <byteswap.h>
+#endif
+
+#ifdef __SUNPRO_C
+#define __FUNCTION__ __func__
+#define	NO_STRUCT_ATTRIBUTE
+#endif
+
+#ifdef NO_STRUCT_ATTRIBUTE
+#define __attribute__(x)
+#define __attribute(x)
+#endif
 
 /* size of superblock buffer, reiserfs block is at 64k */
 #define SB_BUFFER_SIZE				0x11000
 /* size of seek buffer, FAT cluster is 32k max */
 #define SEEK_BUFFER_SIZE			0x10000
 
-#ifdef __BYTE_ORDER
-#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+#if defined(__BYTE_ORDER) ||  defined (_BIG_ENDIAN) || defined (_LITTLE_ENDIAN)
+#if (__BYTE_ORDER == __LITTLE_ENDIAN) || defined (_LITTLE_ENDIAN)
 #define le16_to_cpu(x) (x)
 #define le32_to_cpu(x) (x)
 #define le64_to_cpu(x) (x)
@@ -37,7 +55,7 @@
 #define cpu_to_le16(x) (x)
 #define cpu_to_le32(x) (x)
 #define cpu_to_be32(x) bswap_32(x)
-#elif (__BYTE_ORDER == __BIG_ENDIAN)
+#elif (__BYTE_ORDER == __BIG_ENDIAN) || defined (_BIG_ENDIAN)
 #define le16_to_cpu(x) bswap_16(x)
 #define le32_to_cpu(x) bswap_32(x)
 #define le64_to_cpu(x) bswap_64(x)
@@ -72,5 +90,9 @@
 extern uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len);
 extern void volume_id_free_buffer(struct volume_id *id);
 
+#ifndef HAVE_STRNLEN
+size_t strnlen(const char *s, size_t n);
+#endif
+
 #endif /* _VOLUME_ID_UTIL_ */
 
Index: volume_id/via_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/via_raid.c,v
retrieving revision 1.5
diff -u -r1.5 via_raid.c
--- volume_id/via_raid.c	15 Nov 2005 03:32:36 -0000	1.5
+++ volume_id/via_raid.c	20 Feb 2006 19:21:02 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct via_meta {
 	uint16_t	signature;
 	uint8_t		version_number;
@@ -41,6 +45,10 @@
 	uint8_t		checksum;
 } __attribute__((packed));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 #define VIA_SIGNATURE		0xAA55
 
 int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size)
Index: volume_id/vxfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/vxfs.c,v
retrieving revision 1.2
diff -u -r1.2 vxfs.c
--- volume_id/vxfs.c	15 Nov 2005 03:32:36 -0000	1.2
+++ volume_id/vxfs.c	20 Feb 2006 19:21:02 -0000
@@ -29,11 +29,19 @@
 
 #define VXFS_SUPER_MAGIC	0xa501FCF5
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct vxfs_super {
 	uint32_t		vs_magic;
 	int32_t			vs_version;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 int volume_id_probe_vxfs(struct volume_id *id, uint64_t off)
 {
 	struct vxfs_super *vxs;
Index: volume_id/xfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/xfs.c,v
retrieving revision 1.7
diff -u -r1.7 xfs.c
--- volume_id/xfs.c	15 Nov 2005 03:32:36 -0000	1.7
+++ volume_id/xfs.c	20 Feb 2006 19:21:03 -0000
@@ -27,6 +27,10 @@
 #include "logging.h"
 #include "util.h"
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack(1)
+#endif
+
 struct xfs_super_block {
 	uint8_t	magic[4];
 	uint32_t	blocksize;
@@ -42,6 +46,10 @@
 	uint64_t	fdblocks;
 } __attribute__((__packed__));
 
+#ifdef NO_STRUCT_ATTRIBUTE
+#pragma pack()
+#endif
+
 int volume_id_probe_xfs(struct volume_id *id, uint64_t off)
 {
 	struct xfs_super_block *xs;

-------------- next part --------------
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal



More information about the hal mailing list