Hi, so here is a diff to something
Note that all of this is in a totally unacceptable state, I just thought I'd diff up the dir where I randomly patched stuff shown in gdb when the bus error hits in case someone else wants to know what is up. Kind regards T. -- Thomas Viehmann, http://thomas.viehmann.net/
diff -urN jfsutils-1.1.12~/debian/changelog jfsutils-1.1.12/debian/changelog --- jfsutils-1.1.12~/debian/changelog 2008-10-14 23:39:32.000000000 +0200 +++ jfsutils-1.1.12/debian/changelog 2008-10-14 23:37:49.000000000 +0200 @@ -1,3 +1,10 @@ +jfsutils (1.1.12-2.1) UNRELEASED; urgency=low + + * Non-maintainer upload. + * + + -- Thomas Viehmann <[EMAIL PROTECTED]> Mon, 06 Oct 2008 21:27:06 +0000 + jfsutils (1.1.12-2) unstable; urgency=low * use different linking parameter on alpha to avoid FTBFS (Closes: #490881) diff -urN jfsutils-1.1.12~/debian/rules jfsutils-1.1.12/debian/rules --- jfsutils-1.1.12~/debian/rules 2008-10-14 23:39:32.000000000 +0200 +++ jfsutils-1.1.12/debian/rules 2008-10-14 23:38:05.000000000 +0200 @@ -24,6 +24,10 @@ ifeq ($(DEB_BUILD_ARCH),alpha) LDFLAGS += -Wl,--no-relax endif +ifeq ($(DEB_BUILD_ARCH),sparc) + ## -O2 makes memcpy not work for unaligned data + CFLAGS += -O0 +endif DEB_CONFIGURE_USER_FLAGS := --sbindir=/sbin DEB_MAKE_INSTALL_TARGET := install DESTDIR=$(CURDIR)/debian/tmp diff -urN jfsutils-1.1.12~/fsck/fsckmeta.c jfsutils-1.1.12/fsck/fsckmeta.c --- jfsutils-1.1.12~/fsck/fsckmeta.c 2006-06-05 21:31:40.000000000 +0200 +++ jfsutils-1.1.12/fsck/fsckmeta.c 2008-10-14 23:37:36.000000000 +0200 @@ -3541,14 +3541,14 @@ if ((!inorecptr->selected_to_rls) && (!inorecptr->ignore_alloc_blks)) { /* no problems found in the tree yet */ - if (inoptr->di_nblocks != agg_recptr->this_inode.all_blks) { + if (__read64s_ua(inoptr->di_nblocks) != __read64s_ua(agg_recptr->this_inode.all_blks)) { /* number of blocks is wrong. tree must be bad */ #ifdef _JFS_DEBUG printf("bad num blocks: agg ino: %ld(t) " "di_nblocks = %lld(t) " "this_inode.all_blks = %lld(t)\n", - inoidx, inoptr->di_nblocks, - agg_recptr->this_inode.all_blks); + inoidx, __read64s_ua(inoptr->di_nblocks), + __read64s_ua(agg_recptr->this_inode.all_blks)); #endif inorecptr->selected_to_rls = 1; inorecptr->ignore_alloc_blks = 1; @@ -3570,8 +3570,8 @@ max_size = agg_recptr->this_inode.data_size; } - if ((inoptr->di_size > max_size) - || (inoptr->di_size < min_size)) { + if ((__read64s_ua(inoptr->di_size) > max_size) + || (__read64s_ua(inoptr->di_size) < min_size)) { /* * object size (in bytes) is wrong. * tree must be bad. @@ -3581,7 +3581,7 @@ "minsize = %lld(t) maxsize = %lld(t) " "di_size = %lld(t)\n", inoidx, min_size, max_size, - inoptr->di_size); + __read64s_ua(inoptr->di_size)); #endif inorecptr->selected_to_rls = 1; inorecptr->ignore_alloc_blks = 1; diff -urN jfsutils-1.1.12~/fsck/fsckpfs.c jfsutils-1.1.12/fsck/fsckpfs.c --- jfsutils-1.1.12~/fsck/fsckpfs.c 2007-08-23 06:01:40.000000000 +0200 +++ jfsutils-1.1.12/fsck/fsckpfs.c 2008-10-14 23:37:37.000000000 +0200 @@ -2324,6 +2324,12 @@ agg_recptr->ino_buf_1st_ino = (iag_num << L2INOSPERIAG) + (iag_extidx << L2INOSPEREXT); agg_recptr->ino_fsnum = it_number; + printf("#1, %p\n",agg_recptr); + printf("#2, %p\n",&(agg_recptr->ino_ixpxd)); + printf("#3, %p\n",iag_ptr); + printf("#4, %p\n",iag_ptr->inoext); + printf("#5, %p\n",&(iag_ptr->inoext[iag_extidx])); + memcpy((void *)&(agg_recptr->ino_ixpxd), (void *) &(iag_ptr->inoext[iag_extidx]), sizeof (pxd_t)); is_aggregate ? (agg_recptr->ino_for_aggregate = -1) : diff -urN jfsutils-1.1.12~/fsck/fsckwsp.c jfsutils-1.1.12/fsck/fsckwsp.c --- jfsutils-1.1.12~/fsck/fsckwsp.c 2006-06-05 21:31:40.000000000 +0200 +++ jfsutils-1.1.12/fsck/fsckwsp.c 2008-10-14 23:42:03.000000000 +0200 @@ -21,6 +21,9 @@ #include <time.h> #include <unistd.h> #include <errno.h> +#include <sys/types.h> +#include <jfs_types.h> +#include <jfs_byteorder.h> /* defines and includes common among the fsck.jfs modules */ #include "xfsckint.h" @@ -1163,7 +1166,7 @@ /* got the fileset IT inode */ agg_recptr->fset_imap.num_iags = - (inoptr->di_size / SIZE_OF_MAP_PAGE) - 1; + (__read64s_ua(inoptr->di_size) / SIZE_OF_MAP_PAGE) - 1; /* * a high estimate of the inodes * allocated for the fileset @@ -1473,6 +1476,7 @@ time_t Current_Time; int64_t this_device_offset = 0; int I_am_logredo = 0; + struct fsck_blk_map_hdr blkmp_ctlptr; ewbmc_rc = alloc_wrksp(sizeof (struct fsck_blk_map_hdr), dynstg_blkmap_hdr, @@ -1481,30 +1485,32 @@ if (ewbmc_rc == FSCK_OK) { /* allocated and initialized blk map ctl page */ /* fill eyecatcher */ - strncpy(agg_recptr->blkmp_ctlptr->hdr.eyecatcher, + memcpy(&blkmp_ctlptr, &agg_recptr->blkmp_ctlptr, sizeof(blkmp_ctlptr)); + strncpy(blkmp_ctlptr.hdr.eyecatcher, fbmh_eyecatcher_string, strlen(fbmh_eyecatcher_string)); - agg_recptr->blkmp_ctlptr->hdr.super_buff_addr = (char *) sb_ptr; - agg_recptr->blkmp_ctlptr->hdr.agg_record_addr = + blkmp_ctlptr.hdr.super_buff_addr = (char *) sb_ptr; + blkmp_ctlptr.hdr.agg_record_addr = (char *) agg_recptr; - agg_recptr->blkmp_ctlptr->hdr.bmap_record_addr = + blkmp_ctlptr.hdr.bmap_record_addr = (char *) bmap_recptr; - agg_recptr->blkmp_ctlptr->hdr.fscklog_full = + blkmp_ctlptr.hdr.fscklog_full = agg_recptr->fscklog_full; - agg_recptr->blkmp_ctlptr->hdr.fscklog_buf_allocated = + blkmp_ctlptr.hdr.fscklog_buf_allocated = agg_recptr->fscklog_buf_allocated; - agg_recptr->blkmp_ctlptr->hdr.fscklog_buf_alloc_err = + blkmp_ctlptr.hdr.fscklog_buf_alloc_err = agg_recptr->fscklog_buf_alloc_err; - agg_recptr->blkmp_ctlptr->hdr.fscklog_agg_offset = + blkmp_ctlptr.hdr.fscklog_agg_offset = agg_recptr->ondev_fscklog_byte_offset; Current_Time = time(NULL); fsck_DateTime = localtime(&Current_Time); - sprintf(&(agg_recptr->blkmp_ctlptr->hdr.start_time[0]), + sprintf(&(blkmp_ctlptr.hdr.start_time[0]), "%d/%d/%d %d:%02d:%02d", fsck_DateTime->tm_mon + 1, fsck_DateTime->tm_mday, (fsck_DateTime->tm_year + 1900), fsck_DateTime->tm_hour, fsck_DateTime->tm_min, fsck_DateTime->tm_sec); + memcpy(&agg_recptr->blkmp_ctlptr, &blkmp_ctlptr, sizeof(blkmp_ctlptr)); if (!(agg_recptr->processing_readonly)) { /* diff -urN jfsutils-1.1.12~/include/jfs_byteorder.h jfsutils-1.1.12/include/jfs_byteorder.h --- jfsutils-1.1.12~/include/jfs_byteorder.h 2005-11-22 21:43:54.000000000 +0100 +++ jfsutils-1.1.12/include/jfs_byteorder.h 2008-10-14 23:37:30.000000000 +0200 @@ -25,6 +25,7 @@ #elif HAVE_ENDIAN_H # include <endian.h> #endif +#include <string.h> #define __swab16(x) \ ({ \ @@ -53,6 +54,7 @@ (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ }) + #define __swab64(x) \ ({ \ uint64_t __x = (x); \ @@ -67,6 +69,52 @@ (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ }) +static inline void __inplace_swab64_nonaligned(unsigned char *c1) { + uint64_t tmp; + unsigned char* c2 = (unsigned char *) &tmp+7; + *c2-- = *c1++; + *c2-- = *c1++; + *c2-- = *c1++; + *c2-- = *c1++; + *c2-- = *c1++; + *c2-- = *c1++; + *c2-- = *c1++; + *c2 = *c1++; + memcpy(c1-8,c2,8); +} + +typedef union { + uint64_t a; + struct { + uint32_t b1; + uint32_t b2; + }; +} uint64_as_uint32_t; +typedef union { + int64_t a; + struct { + uint32_t b1; + uint32_t b2; + }; +} int64_as_uint32_t; + +static inline int64_t __read_nonaligned_s64 (int64_as_uint32_t c1) { + int64_as_uint32_t c2; + c2.b1 = c1.b1; + c2.b2 = c1.b2; + return c2.a; +} + +static inline uint64_t __read_nonaligned_u64 (uint64_as_uint32_t c1) { + uint64_as_uint32_t c2; + c2.b1 = c1.b1; + c2.b2 = c1.b2; + return c2.a; +} + +// ifdef for SPARC only +#define __read64u_ua(x) __read_nonaligned_u64((uint64_as_uint32_t) x) +#define __read64s_ua(x) __read_nonaligned_s64((int64_as_uint32_t) x) #if (BYTE_ORDER == LITTLE_ENDIAN) #define __cpu_to_le16(x) ((uint16_t)(x)) @@ -77,6 +125,7 @@ #define __le24_to_cpu(x) ((uint32_t)(x)) #define __le32_to_cpu(x) ((uint32_t)(x)) #define __le64_to_cpu(x) ((uint64_t)(x)) + #define __inplace_le64_to_cpu_nonaligned(x) #elif (BYTE_ORDER == BIG_ENDIAN) #define __cpu_to_le16(x) __swab16(x) #define __cpu_to_le24(x) __swab24(x) @@ -86,6 +135,7 @@ #define __le24_to_cpu(x) __swab24(x) #define __le32_to_cpu(x) __swab32(x) #define __le64_to_cpu(x) __swab64(x) + #define __inplace_le64_to_cpu_nonaligned(x) (__inplace_swab64_nonaligned((unsigned char *)(&x))) #else # error "JFS works only on big- or littleendian machines" #endif diff -urN jfsutils-1.1.12~/jfsutils.spec jfsutils-1.1.12/jfsutils.spec --- jfsutils-1.1.12~/jfsutils.spec 2007-08-24 22:26:01.000000000 +0200 +++ jfsutils-1.1.12/jfsutils.spec 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -Name : jfsutils -Version : 1.1.12 -Release : 1 -Group : System/Kernel - -Summary : IBM JFS utility programs - -Copyright : GPL -Packager : JFS/Linux team <[EMAIL PROTECTED]> -URL : http://jfs.sourceforge.net/ - -Buildroot : %{_tmppath}/%{name}-%{version} -Source : %{name}-%{version}.tar.gz - - -%Description -Utilities for managing IBM's Journaled File System (JFS) under Linux. The -following utilities are available: jfs_fsck - initiate replay of the JFS -transaction log, and check and repair a JFS formatted device. jfs_fscklog - -extract a log from the JFS fsck workspace into a file and/or display it. -jfs_logdump - dump a JFS formatted device's journal log. jfs_mkfs - create -a JFS formatted partition. jfs_tune - adjust tunable parameters of the JFS -file system. jfs_debugfs - shell-type JFS file system editor. - - -%Prep -%setup -q - -%Build -CFLAGS="${RPM_OPT_FLAGS}" ./configure --mandir=/usr/share/man/en/ -make - -%Install -make install DESTDIR=${RPM_BUILD_ROOT} - -%Clean -rm -rf ${RPM_BUILD_ROOT} - -%Files -%defattr(-,root,root) -/sbin/* -%{_mandir}/en/man8/* -%doc AUTHORS COPYING INSTALL NEWS README ChangeLog diff -urN jfsutils-1.1.12~/libfs/fsckwsp.h jfsutils-1.1.12/libfs/fsckwsp.h --- jfsutils-1.1.12~/libfs/fsckwsp.h 2005-11-22 21:43:55.000000000 +0100 +++ jfsutils-1.1.12/libfs/fsckwsp.h 2008-10-14 23:37:41.000000000 +0200 @@ -394,7 +394,7 @@ struct fsck_agg_record { char eyecatcher[8]; uint32_t ondev_jlog_fsblk_length; - int64_t ondev_jlog_fsblk_offset; + int64_t ondev_jlog_fsblk_offset; int64_t ondev_wsp_byte_length; int64_t ondev_wsp_byte_offset; uint32_t ondev_wsp_fsblk_length; diff -urN jfsutils-1.1.12~/libfs/jfs_endian.c jfsutils-1.1.12/libfs/jfs_endian.c --- jfsutils-1.1.12~/libfs/jfs_endian.c 2006-11-02 23:37:13.000000000 +0100 +++ jfsutils-1.1.12/libfs/jfs_endian.c 2008-10-14 23:37:41.000000000 +0200 @@ -77,8 +77,8 @@ di->di_number = __le32_to_cpu(di->di_number); di->di_gen = __le32_to_cpu(di->di_gen); - di->di_size = __le64_to_cpu(di->di_size); - di->di_nblocks = __le64_to_cpu(di->di_nblocks); + __inplace_le64_to_cpu_nonaligned(di->di_size); + __inplace_le64_to_cpu_nonaligned(di->di_nblocks); di->di_nlink = __le32_to_cpu(di->di_nlink); di->di_uid = __le32_to_cpu(di->di_uid); di->di_gid = __le32_to_cpu(di->di_gid); @@ -352,26 +352,25 @@ fsck_bmap_h->cbblrec.fs_blksize = __le32_to_cpu(fsck_bmap_h->cbblrec.fs_blksize); fsck_bmap_h->cbblrec.lv_blksize = __le32_to_cpu(fsck_bmap_h->cbblrec.lv_blksize); fsck_bmap_h->cbblrec.fs_lv_ratio = __le32_to_cpu(fsck_bmap_h->cbblrec.fs_lv_ratio); - fsck_bmap_h->cbblrec.fs_last_metablk = __le64_to_cpu(fsck_bmap_h->cbblrec.fs_last_metablk); - fsck_bmap_h->cbblrec.fs_first_wspblk = __le64_to_cpu(fsck_bmap_h->cbblrec.fs_first_wspblk); + __inplace_le64_to_cpu_nonaligned(fsck_bmap_h->cbblrec.fs_last_metablk); + __inplace_le64_to_cpu_nonaligned(fsck_bmap_h->cbblrec.fs_first_wspblk); fsck_bmap_h->cbblrec.total_bad_blocks = __le32_to_cpu(fsck_bmap_h->cbblrec.total_bad_blocks); fsck_bmap_h->cbblrec.resolved_blocks = __le32_to_cpu(fsck_bmap_h->cbblrec.resolved_blocks); fsck_bmap_h->cbblrec.reloc_extents = __le32_to_cpu(fsck_bmap_h->cbblrec.reloc_extents); - fsck_bmap_h->cbblrec.reloc_blocks = __le64_to_cpu(fsck_bmap_h->cbblrec.reloc_blocks); + __inplace_le64_to_cpu_nonaligned(fsck_bmap_h->cbblrec.reloc_blocks); fsck_bmap_h->cbblrec.LVM_lists = __le32_to_cpu(fsck_bmap_h->cbblrec.LVM_lists); fsck_bmap_h->hdr.last_entry_pos = __le32_to_cpu(fsck_bmap_h->hdr.last_entry_pos); fsck_bmap_h->hdr.next_entry_pos = __le32_to_cpu(fsck_bmap_h->hdr.next_entry_pos); fsck_bmap_h->hdr.return_code = __le32_to_cpu(fsck_bmap_h->hdr.return_code); - fsck_bmap_h->hdr.fscklog_agg_offset = __le64_to_cpu(fsck_bmap_h->hdr.fscklog_agg_offset); + __inplace_le64_to_cpu_nonaligned(fsck_bmap_h->hdr.fscklog_agg_offset); fsck_bmap_h->hdr.num_logwrite_errors = __le32_to_cpu(fsck_bmap_h->hdr.num_logwrite_errors); /* struct fscklog_error logerr[125] */ for (i = 0; i < 125; i++) { - fsck_bmap_h->hdr.logerr[i].err_offset = - __le64_to_cpu(fsck_bmap_h->hdr.logerr[i].err_offset); + __inplace_le64_to_cpu_nonaligned(fsck_bmap_h->hdr.logerr[i].err_offset); fsck_bmap_h->hdr.logerr[i].bytes_written = __le32_to_cpu(fsck_bmap_h->hdr.logerr[i].bytes_written); fsck_bmap_h->hdr.logerr[i].io_retcode = @@ -416,7 +415,7 @@ /* iag in jfs_logmgr.h */ - ia_t->agstart = __le64_to_cpu(ia_t->agstart); + __inplace_le64_to_cpu_nonaligned(ia_t->agstart); ia_t->iagnum = __le32_to_cpu(ia_t->iagnum); ia_t->inofreefwd = __le32_to_cpu(ia_t->inofreefwd); ia_t->inofreeback = __le32_to_cpu(ia_t->inofreeback); @@ -598,8 +597,8 @@ /* xtpage_t in jfs_xtree.h */ /* struct xtheader header; */ - xtp_t->header.next = __le64_to_cpu(xtp_t->header.next); - xtp_t->header.prev = __le64_to_cpu(xtp_t->header.prev); + __inplace_le64_to_cpu_nonaligned(xtp_t->header.next); + __inplace_le64_to_cpu_nonaligned(xtp_t->header.prev); xtp_t->header.maxentry = __le16_to_cpu(xtp_t->header.maxentry); xtp_t->header.rsrvd2 = __le16_to_cpu(xtp_t->header.rsrvd2); diff -urN jfsutils-1.1.12~/libfs/log_work.c jfsutils-1.1.12/libfs/log_work.c --- jfsutils-1.1.12~/libfs/log_work.c 2006-06-04 23:37:29.000000000 +0200 +++ jfsutils-1.1.12/libfs/log_work.c 2008-10-14 23:37:41.000000000 +0200 @@ -2412,7 +2412,7 @@ xad_t *xad_p; pxd_t pxd1; struct iag_data *imp; - struct dinode *dip = 0; + struct dinode dip; int32_t xlen, xlength; int16_t nword; int8_t upd_possible = 0; @@ -2713,7 +2713,7 @@ */ if (ino_rem == 0) { /* inode base segment */ - dip = (struct dinode *) data; + memcpy(&dip, data, sizeof(dip)); if (ln == 1) { /* ibase only */ if (db->db_ibase & mask_8) @@ -2798,7 +2798,7 @@ * this case, we will mark block map to show * the whole inode extent (all 4 pages) as * allocated */ - allocate = (dip->di_nlink != 0); + allocate = (dip.di_nlink != 0); inoext_alloc |= allocate; /* * There is only one fileset per aggregate, so @@ -2807,8 +2807,8 @@ */ if (ld->log.redopage.inode == FILESYSTEM_I) { rc = markImap(&vopen[vol].fsimap_lst, - __le32_to_cpu(dip->di_number), - dip->di_ixpxd, allocate, vol); + __le32_to_cpu(dip.di_number), + dip.di_ixpxd, allocate, vol); if (rc) { fsck_send_msg(lrdo_UPPGMIMPFAIL, rc); return (rc); @@ -2824,7 +2824,7 @@ */ if (!allocate) - doNoRedoFile(ld, __le32_to_cpu(dip->di_number)); + doNoRedoFile(ld, __le32_to_cpu(dip.di_number)); } } else if ((ld->log.redopage.type & (LOG_BTROOT | LOG_XTREE)) == (LOG_BTROOT | LOG_XTREE)) { @@ -3107,7 +3107,7 @@ /* * figure out which IAG and which extent */ - iag_num = INOTOIAG(__le32_to_cpu(dip->di_number)); + iag_num = INOTOIAG(__le32_to_cpu(dip.di_number)); imp = vopen[vol].fsimap_lst.imap_wsp[(iag_num + 1) ].imap_data; @@ -3121,18 +3121,18 @@ ].imap_data; } /* end first touch to this IAG */ - ino = __le32_to_cpu(dip->di_number) & (INOSPERIAG - 1); + ino = __le32_to_cpu(dip.di_number) & (INOSPERIAG - 1); extno = ino >> L2INOSPEREXT; /* * make sure the IAG points to it correctly */ - imp->inoext[extno] = dip->di_ixpxd; + imp->inoext[extno] = dip.di_ixpxd; } /* end fileset owned */ /* * make sure the block map shows it allocated */ - rc = markBmap((struct dmap *) vopen[vol].bmap_ctl, dip->di_ixpxd, 1, vol); + rc = markBmap((struct dmap *) vopen[vol].bmap_ctl, dip.di_ixpxd, 1, vol); if (rc) { fsck_send_msg(lrdo_UPPGMBMPFAIL, rc); return (rc); diff -urN jfsutils-1.1.12~/libfs/super.c jfsutils-1.1.12/libfs/super.c --- jfsutils-1.1.12~/libfs/super.c 2005-11-22 21:43:55.000000000 +0100 +++ jfsutils-1.1.12/libfs/super.c 2008-10-14 23:37:41.000000000 +0200 @@ -162,14 +162,14 @@ */ int ujfs_put_superblk(FILE *fp, struct superblock *sb, int16_t is_primary) { - char buf[SIZE_OF_SUPER]; + struct superblock buf[(SIZE_OF_SUPER+sizeof(*sb)-1)/sizeof(*sb)]; int rc; memset(buf, 0, SIZE_OF_SUPER); memcpy(buf, sb, sizeof (*sb)); /* swap if on big endian machine */ - ujfs_swap_superblock((struct superblock *) buf); + ujfs_swap_superblock(buf); rc = ujfs_rw_diskblocks(fp, (is_primary ? SUPER1_OFF : SUPER2_OFF), SIZE_OF_SUPER, buf, PUT);