summaryrefslogtreecommitdiff
path: root/ufs
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-09-23 21:50:56 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-09-23 21:50:56 +0000
commit349a9b0bc01159f9136c2c31d8b82b189e319784 (patch)
tree5a8eada2744654d8a1f7d783029976d71aba8b63 /ufs
parenta204f7f38dd2bee28f14b3d0ddb5ec23477fd448 (diff)
Formerly bmap.c.~3~
Diffstat (limited to 'ufs')
-rw-r--r--ufs/bmap.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/ufs/bmap.c b/ufs/bmap.c
index c2eea356..58ec06f4 100644
--- a/ufs/bmap.c
+++ b/ufs/bmap.c
@@ -21,10 +21,6 @@
#include "ufs.h"
#include "dinode.h"
-#include "fs.h"
-
-/* Number of block pointers that fit in a single disk block */
-#define NIPTR (sblock->fs_bsize / sizeof (daddr_t))
/* For logical block number LBN of file NP, look it the block address,
giving the "path" of indirect blocks to the file, starting
@@ -52,21 +48,21 @@ fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs)
lbn -= NDADDR;
- indirs[0].offset = lbn % NIPTR;
+ indirs[0].offset = lbn % NINDIR (sblock)
- if (lbn / NIPTR)
+ if (lbn / NINBIR (sblock))
{
/* We will use the double indirect block */
int ibn;
daddr_t *diblock;
- ibn = lbn / NIPTR - 1;
+ ibn = lbn / NINDIR (sblock) - 1;
- indirs[1].offset = ibn % NIPTR;
+ indirs[1].offset = ibn % NINDIR (sblock);
/* We don't support triple indirect blocks, but this
is where we'd do it. */
- assert (!(ibn / NIPTR));
+ assert (!(ibn / NINDIR (sblock)));
indirs[2].offset = -1;
indirs[2].bno = di->di_ib[INDIR_DOUBLE];
@@ -97,7 +93,21 @@ fetch_indir_spec (struct node *np, daddr_t lbn, struct iblock_spec *indirs)
return 0;
}
+
+/* Mark indirect block BNO as dirty on node NP's list. NP must
+ be locked. */
+void
+mark_indir_dirty (struct node *np, daddr_t bno)
+{
+ struct dirty_indir *d;
+ for (d = np->dn->dirty; d; d = d->next)
+ if (d->bno == bno)
+ return;
-
+ d = malloc (sizeof (struct dirty_indir));
+ d->bno = bno;
+ d->next = np->dn->dirty;
+ np->dn->dirty = d;
+}