summaryrefslogtreecommitdiff
path: root/security/tct/patches/patch-af
blob: 468114c7dcca19e2e5f3d4916698f9a28bde7401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
$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);
 
     /*