pkgsrc/security/tct/patches/patch-af
ben 4c8d18d16a Make tct build and run on NetBSD 2.0 and bump PKGREVISION.
This does not add support for ffsv2 filesystems nor superblocks.
This addresses PR#28357.
2005-01-22 15:59:58 +00:00

118 lines
3.9 KiB
Text

$NetBSD: patch-af,v 1.2 2005/01/22 15:59:58 ben Exp $
--- src/fstools/ffs.c.orig 2001-09-15 13:45:56.000000000 -0700
+++ src/fstools/ffs.c
@@ -28,6 +28,16 @@
#include "mymalloc.h"
#include "error.h"
+#if defined(NETBSD2)
+#define MY_DINODE ufs1_dinode
+#define MY_SBOFF SBLOCK_UFS1
+#define MY_FS_MAGIC FS_UFS1_MAGIC
+#else
+#define MY_DINODE dinode
+#define MY_SBOFF SBOFF
+#define MY_FS_MAGIC FS_MAGIC
+#endif
+
/*
* Structure of a fast file system handle.
*/
@@ -36,7 +46,7 @@ typedef struct {
struct fs *fs; /* super block buffer */
FS_BUF *cg_buf; /* cylinder block buffer */
FS_BUF *dino_buf; /* inode block buffer */
- struct dinode dinode; /* disk inode */
+ struct MY_DINODE dinode; /* disk inode */
} FFS_INFO;
/* ffs_cgroup_lookup - look up cached cylinder group info */
@@ -84,7 +94,7 @@ static void ffs_cgroup_free(FFS_INFO *ff
/* ffs_dinode_lookup - look up cached disk inode */
-static struct dinode *ffs_dinode_lookup(FFS_INFO *ffs, INUM_T inum)
+static struct MY_DINODE *ffs_dinode_lookup(FFS_INFO *ffs, INUM_T inum)
{
DADDR_T addr;
int offs;
@@ -109,9 +119,9 @@ static struct dinode *ffs_dinode_lookup(
* Copy the inode, in order to avoid alignment problems when accessing
* structure members.
*/
- offs = itoo(ffs->fs, inum) * sizeof(struct dinode);
+ offs = itoo(ffs->fs, inum) * sizeof(struct MY_DINODE);
memcpy((char *) &ffs->dinode, ffs->dino_buf->data + offs,
- sizeof(struct dinode));
+ sizeof(struct MY_DINODE));
return (&ffs->dinode);
}
@@ -125,7 +135,7 @@ static void ffs_dinode_free(FFS_INFO *ff
/* ffs_copy_inode - copy disk inode to generic inode */
-static void ffs_copy_inode(struct dinode * dino, FS_INODE *fs_inode)
+static void ffs_copy_inode(struct MY_DINODE * dino, FS_INODE *fs_inode)
{
int i;
@@ -151,7 +161,7 @@ static FS_INODE *ffs_inode_lookup(FS_INF
{
FFS_INFO *ffs = (FFS_INFO *) fs;
FS_INODE *fs_inode = fs_inode_alloc(NDADDR, NIADDR);
- struct dinode *dino = ffs_dinode_lookup(ffs, inum);
+ struct MY_DINODE *dino = ffs_dinode_lookup(ffs, inum);
ffs_copy_inode(dino, fs_inode);
return (fs_inode);
@@ -168,7 +178,7 @@ void ffs_inode_walk(FS_INFO *fs, INUM
struct cg *cg = 0;
INUM_T inum;
unsigned char *inosused;
- struct dinode *dino;
+ struct MY_DINODE *dino;
FS_INODE *fs_inode = fs_inode_alloc(NDADDR, NIADDR);
int myflags;
INUM_T ibase;
@@ -193,7 +203,12 @@ void ffs_inode_walk(FS_INFO *fs, INUM
cg_num = INO_TO_CG(ffs->fs, inum);
if (cg == 0 || cg->cg_cgx != cg_num) {
cg = ffs_cgroup_lookup(ffs, cg_num);
+#if defined(NETBSD1) || defined(NETBSD2)
+ /* BYTE_SWAPPED filesystems can come later */
+ inosused = (unsigned char *) cg_inosused(cg, 0);
+#else
inosused = (unsigned char *) cg_inosused(cg);
+#endif
ibase = cg_num * ffs->fs->fs_ipg;
}
@@ -290,7 +305,12 @@ void ffs_block_walk(FS_INFO *fs, DADD
cg_num = dtog(ffs->fs, addr);
if (cg == 0 || cg->cg_cgx != cg_num) {
cg = ffs_cgroup_lookup(ffs, cg_num);
+#if defined(NETBSD1) || defined(NETBSD2)
+ /* BYTE_SWAPPED filesystems can come later */
+ freeblocks = (unsigned char *) cg_blksfree(cg, 0);
+#else
freeblocks = (unsigned char *) cg_blksfree(cg);
+#endif
dbase = cgbase(ffs->fs, cg_num);
dmin = cgdmin(ffs->fs, cg_num);
sblock = cgsblock(ffs->fs, cg_num);
@@ -390,11 +410,11 @@ FS_INFO *ffs_open(const char *name)
*/
len = roundup(sizeof(struct fs), DEV_BSIZE);
ffs->fs = (struct fs *) mymalloc(len);
- if (LSEEK(ffs->fs_info.fd, SBOFF, SEEK_SET) != SBOFF)
+ if (LSEEK(ffs->fs_info.fd, MY_SBOFF, SEEK_SET) != MY_SBOFF)
error("%s: lseek: %m", myname);
if (read(ffs->fs_info.fd, (char *) ffs->fs, len) != len)
error("%s: read superblock: %m", name);
- if (ffs->fs->fs_magic != FS_MAGIC)
+ if (ffs->fs->fs_magic != MY_FS_MAGIC)
error("%s: bad magic number in superblock", name);
/*