Module Name: src Committed By: martin Date: Sat Apr 26 13:23:49 UTC 2014
Modified Files: src/sbin/tunefs: tunefs.c Log Message: Provide proper alignement for "buf" - it is casted to a struct fs pointer, so it requires the same alignement. Fixes crashes on armv5. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sbin/tunefs/tunefs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/tunefs/tunefs.c diff -u src/sbin/tunefs/tunefs.c:1.46 src/sbin/tunefs/tunefs.c:1.47 --- src/sbin/tunefs/tunefs.c:1.46 Sun Jun 23 02:06:05 2013 +++ src/sbin/tunefs/tunefs.c Sat Apr 26 13:23:49 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tunefs.c,v 1.46 2013/06/23 02:06:05 dholland Exp $ */ +/* $NetBSD: tunefs.c,v 1.47 2014/04/26 13:23:49 martin Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)tunefs.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: tunefs.c,v 1.46 2013/06/23 02:06:05 dholland Exp $"); +__RCSID("$NetBSD: tunefs.c,v 1.47 2014/04/26 13:23:49 martin Exp $"); #endif #endif /* not lint */ @@ -71,10 +71,9 @@ __RCSID("$NetBSD: tunefs.c,v 1.46 2013/0 union { struct fs sb; - char pad[MAXBSIZE]; -} sbun; + char data[MAXBSIZE]; +} sbun, buf; #define sblock sbun.sb -char buf[MAXBSIZE]; int fi; long dev_bsize = 512; @@ -326,14 +325,14 @@ main(int argc, char *argv[]) exit(0); } - memcpy(buf, (char *)&sblock, SBLOCKSIZE); + memcpy(&buf, (char *)&sblock, SBLOCKSIZE); if (needswap) - ffs_sb_swap((struct fs*)buf, (struct fs*)buf); - bwrite(sblockloc, buf, SBLOCKSIZE, special); + ffs_sb_swap((struct fs*)&buf, (struct fs*)&buf); + bwrite(sblockloc, buf.data, SBLOCKSIZE, special); if (Aflag) for (i = 0; i < sblock.fs_ncg; i++) bwrite(FFS_FSBTODB(&sblock, cgsblock(&sblock, i)), - buf, SBLOCKSIZE, special); + buf.data, SBLOCKSIZE, special); close(fi); exit(0); }