Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/newfs Increase alignement of the global "buf" variable ...
details: https://anonhg.NetBSD.org/src/rev/272e5b4ad7fd
branches: trunk
changeset: 328974:272e5b4ad7fd
user: martin <martin%NetBSD.org@localhost>
date: Sat Apr 26 14:15:08 2014 +0000
description:
Increase alignement of the global "buf" variable to cover all pointers it
is casted too. Fixes a crash on arm v5.
diffstat:
sbin/newfs/mkfs.c | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diffs (108 lines):
diff -r 4d7abe04b15b -r 272e5b4ad7fd sbin/newfs/mkfs.c
--- a/sbin/newfs/mkfs.c Sat Apr 26 13:23:49 2014 +0000
+++ b/sbin/newfs/mkfs.c Sat Apr 26 14:15:08 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkfs.c,v 1.121 2014/04/05 12:32:27 justin Exp $ */
+/* $NetBSD: mkfs.c,v 1.122 2014/04/26 14:15:08 martin Exp $ */
/*
* Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: mkfs.c,v 1.121 2014/04/05 12:32:27 justin Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.122 2014/04/26 14:15:08 martin Exp $");
#endif
#endif /* not lint */
@@ -131,10 +131,15 @@
union {
struct fs fs;
- char pad[SBLOCKSIZE];
+ char data[SBLOCKSIZE];
} fsun;
#define sblock fsun.fs
+union {
+ struct quota2_header q2h;
+ char data[MAXBSIZE];
+} buf;
+
struct csum *fscs_0; /* first block of cylinder summaries */
struct csum *fscs_next; /* place for next summary */
struct csum *fscs_end; /* end of summary buffer */
@@ -1012,7 +1017,7 @@
{ 0, DIRBLKSIZ, 0, 0 },
};
#endif
-char buf[MAXBSIZE];
+
static void copy_dir(struct direct *, struct direct *);
int
@@ -1124,7 +1129,7 @@
node.dp1.di_blocks = btodb(ffs_fragroundup(&sblock,
node.dp1.di_size));
qblocks += node.dp1.di_blocks;
- wtfs(FFS_FSBTODB(&sblock, node.dp1.di_db[0]), sblock.fs_fsize, buf);
+ wtfs(FFS_FSBTODB(&sblock, node.dp1.di_db[0]), sblock.fs_fsize, &buf);
} else {
if (mfs) {
node.dp2.di_mode = IFDIR | mfsmode;
@@ -1151,7 +1156,7 @@
node.dp2.di_blocks = btodb(ffs_fragroundup(&sblock,
node.dp2.di_size));
qblocks += node.dp2.di_blocks;
- wtfs(FFS_FSBTODB(&sblock, node.dp2.di_db[0]), sblock.fs_fsize, buf);
+ wtfs(FFS_FSBTODB(&sblock, node.dp2.di_db[0]), sblock.fs_fsize, &buf);
}
qinos++;
iput(&node, UFS_ROOTINO);
@@ -1177,12 +1182,12 @@
if ((quotas & FS_Q2_DO_TYPE(i)) == 0)
continue;
- quota2_create_blk0(sblock.fs_bsize, buf, q2h_hash_shift,
+ quota2_create_blk0(sblock.fs_bsize, &buf, q2h_hash_shift,
i, needswap);
/* grab an entry from header for root dir */
- q2h = (void *)buf;
+ q2h = &buf.q2h;
offset = ufs_rw64(q2h->q2h_free, needswap);
- q2e = (void *)((char *)buf + offset);
+ q2e = (void *)((char *)&buf + offset);
q2h->q2h_free = q2e->q2e_next;
memcpy(q2e, &q2h->q2h_defentry, sizeof(*q2e));
q2e->q2e_uid = ufs_rw32(uid, needswap);
@@ -1213,7 +1218,7 @@
node.dp1.di_uid = geteuid();
node.dp1.di_gid = getegid();
wtfs(FFS_FSBTODB(&sblock, node.dp1.di_db[0]),
- node.dp1.di_size, buf);
+ node.dp1.di_size, &buf);
} else {
node.dp2.di_atime = tv->tv_sec;
node.dp2.di_atimensec = tv->tv_usec * 1000;
@@ -1235,7 +1240,7 @@
node.dp2.di_uid = geteuid();
node.dp2.di_gid = getegid();
wtfs(FFS_FSBTODB(&sblock, node.dp2.di_db[0]),
- node.dp2.di_size, buf);
+ node.dp2.di_size, &buf);
}
iput(&node, nextino);
sblock.fs_quotafile[i] = nextino;
@@ -1257,9 +1262,9 @@
if (isappleufs)
dirblksiz = APPLEUFS_DIRBLKSIZ;
- memset(buf, 0, UFS_DIRBLKSIZ);
+ memset(&buf, 0, UFS_DIRBLKSIZ);
spcleft = dirblksiz;
- for (cp = buf, i = 0; i < entries - 1; i++) {
+ for (cp = buf.data, i = 0; i < entries - 1; i++) {
protodir[i].d_reclen = UFS_DIRSIZ(Oflag == 0, &protodir[i], 0);
copy_dir(&protodir[i], (struct direct*)cp);
cp += protodir[i].d_reclen;
Home |
Main Index |
Thread Index |
Old Index