Whamcloud - gitweb
Fix XFS superblock definition. Add support to
[tools/e2fsprogs.git] / lib / blkid / probe.h
index 8e22b19..8ab8d72 100644 (file)
@@ -2,7 +2,7 @@
  * probe.h - constants and on-disk structures for extracting device data
  *
  * Copyright (C) 1999 by Andries Brouwer
- * Copyright (C) 1999, 2000 by Theodore Ts'o
+ * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
  * Copyright (C) 2001 by Andreas Dilger
  *
  * %Begin-Header%
@@ -18,9 +18,8 @@
 
 struct blkid_magic;
 
-typedef int (*blkid_probe_t)(int fd, blkid_dev *dev_p, const char *devname,
-                            struct blkid_magic *id, unsigned char *buf,
-                            blkid_loff_t size);
+typedef int (*blkid_probe_t)(int fd, blkid_cache cache, blkid_dev dev, 
+                            struct blkid_magic *id, unsigned char *buf);
 
 struct blkid_magic {
        const char      *bim_type;      /* type name for this magic */
@@ -28,8 +27,6 @@ struct blkid_magic {
        unsigned        bim_sboff;      /* byte offset within superblock */
        unsigned        bim_len;        /* length of magic */
        const char      *bim_magic;     /* magic string */
-       unsigned        bim_align;      /* byte alignment of superblock */
-       unsigned        bim_kbsize;     /* size of superblock in kilobytes */
        blkid_probe_t   bim_probe;      /* probe function */
 };
 
@@ -66,7 +63,7 @@ struct xfs_super_block {
        __u32           xs_blocksize;
        __u64           xs_dblocks;
        __u64           xs_rblocks;
-       __u32           xs_dummy1[8];
+       __u32           xs_dummy1[2];
        unsigned char   xs_uuid[16];
        __u32           xs_dummy2[15];
        char            xs_fname[12];
@@ -92,6 +89,25 @@ struct reiserfs_super_block {
        char            rs_label[16];
 };
 
+struct jfs_super_block {
+       unsigned char   js_magic[4];
+       __u32           js_version;
+       __u64           js_size;
+       __u32           js_bsize;
+       __u32           js_dummy1;
+       __u32           js_pbsize;
+       __u32           js_dummy2[27];
+       unsigned char   js_uuid[16];
+       unsigned char   js_label[16];
+       unsigned char   js_loguuid[16];
+};
+
+struct romfs_super_block {
+       unsigned char   ros_magic[8];
+       __u32           ros_dummy1[2];
+       unsigned char   ros_volume[16];
+};
+
 /* Yucky misaligned values */
 struct vfat_super_block {
 /* 00*/        unsigned char   vs_ignored[3];
@@ -193,36 +209,91 @@ struct hfs_super_block {
        __u32   h_blksize;
 };
 
-#ifndef le32_to_cpu    /* Assume if one is defined, all are defined */
-#define X16_to_cpu(x) ((__u16)((((__u16)(x) & 0x00ffU) << 8) | \
-                              (((__u16)(x) & 0xff00U) >> 8)))
-#define X32_to_cpu(x) ((__u32)((((__u32)(x) & 0x000000ffU) << 24) | \
-                              (((__u32)(x) & 0x0000ff00U) << 8) | \
-                              (((__u32)(x) & 0x00ff0000U) >> 8) | \
-                              (((__u32)(x) & 0xff000000U) >> 24)))
-#define X64_to_cpu(x) ((__u64)((((__u64)(x) & 0x00000000000000ffULL) << 56) | \
-                              (((__u64)(x) & 0x000000000000ff00ULL) << 40) | \
-                              (((__u64)(x) & 0x0000000000ff0000ULL) << 24) | \
-                              (((__u64)(x) & 0x00000000ff000000ULL) <<  8) | \
-                              (((__u64)(x) & 0x000000ff00000000ULL) >>  8) | \
-                              (((__u64)(x) & 0x0000ff0000000000ULL) >> 24) | \
-                              (((__u64)(x) & 0x00ff000000000000ULL) >> 40) | \
-                              (((__u64)(x) & 0xff00000000000000ULL) >> 56)))
-#if  __BYTE_ORDER == __BIG_ENDIAN
-#define le16_to_cpu(x) X16_to_cpu(x)
-#define le32_to_cpu(x) X32_to_cpu(x)
-#define le64_to_cpu(x) X64_to_cpu(x)
-#define be16_to_cpu(x) (x)
-#define be32_to_cpu(x) (x)
-#define be64_to_cpu(x) (x)
+/*
+ * Byte swap functions
+ */
+#ifdef __GNUC__
+#define _INLINE_ static __inline__
+#else                          /* For Watcom C */
+#define _INLINE_ static inline
+#endif
+
+static __u16 blkid_swab16(__u16 val);
+static __u32 blkid_swab32(__u32 val);
+static __u64 blkid_swab64(__u64 val);
+
+#if ((defined __GNUC__) && \
+     (defined(__i386__) || defined(__i486__) || defined(__i586__)))
+
+#define _BLKID_HAVE_ASM_BITOPS_
+
+_INLINE_ __u32 blkid_swab32(__u32 val)
+{
+#ifdef EXT2FS_REQUIRE_486
+       __asm__("bswap %0" : "=r" (val) : "0" (val));
 #else
-#define le16_to_cpu(x) (x)
-#define le32_to_cpu(x) (x)
-#define le64_to_cpu(x) (x)
-#define be16_to_cpu(x) X16_to_cpu(x)
-#define be32_to_cpu(x) X32_to_cpu(x)
-#define be64_to_cpu(x) X64_to_cpu(x)
+       __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
+               "rorl $16,%0\n\t"       /* swap words           */
+               "xchgb %b0,%h0"         /* swap higher bytes    */
+               :"=q" (val)
+               : "0" (val));
 #endif
+       return val;
+}
+
+_INLINE_ __u16 blkid_swab16(__u16 val)
+{
+       __asm__("xchgb %b0,%h0"         /* swap bytes           */ \
+               : "=q" (val) \
+               :  "0" (val)); \
+               return val;
+}
+
+_INLINE_ __u64 blkid_swab64(__u64 val)
+{
+       return (blkid_swab32(val >> 32) |
+               (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
+}
+#endif
+
+#if !defined(_BLKID_HAVE_ASM_BITOPS_)
+
+_INLINE_  __u16 blkid_swab16(__u16 val)
+{
+       return (val >> 8) | (val << 8);
+}
+
+_INLINE_ __u32 blkid_swab32(__u32 val)
+{
+       return ((val>>24) | ((val>>8)&0xFF00) |
+               ((val<<8)&0xFF0000) | (val<<24));
+}
+
+_INLINE_ __u64 blkid_swab64(__u64 val)
+{
+       return (blkid_swab32(val >> 32) |
+               (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
+}
+#endif 
+
+
+
+#if  __BYTE_ORDER == __BIG_ENDIAN
+#define blkid_le16(x) blkid_swab16(x)
+#define blkid_le32(x) blkid_swab32(x)
+#define blkid_le64(x) blkid_swab64(x)
+#define blkid_be16(x) (x)
+#define blkid_be32(x) (x)
+#define blkid_be64(x) (x)
+#else
+#define blkid_le16(x) (x)
+#define blkid_le32(x) (x)
+#define blkid_le64(x) (x)
+#define blkid_be16(x) blkid_swab16(x)
+#define blkid_be32(x) blkid_swab32(x)
+#define blkid_be64(x) blkid_swab64(x)
 #endif
 
+#undef _INLINE_
+
 #endif /* _BLKID_PROBE_H */