add ifdefs for dev_bsize (almost working)
[unix-history] / usr / src / sys / ufs / lfs / lfs_balloc.c
index 5f90878..48870ad 100644 (file)
@@ -1,14 +1,19 @@
-/*     lfs_balloc.c    5.2     82/09/25        */
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)lfs_balloc.c        7.1.1.1 (Berkeley) %G%
+ */
 
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/inode.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/proc.h"
-#include "../h/fs.h"
+#include "param.h"
+#include "systm.h"
+#include "inode.h"
+#include "dir.h"
+#include "user.h"
+#include "buf.h"
+#include "proc.h"
+#include "fs.h"
 
 /*
  * Bmap defines the structure of file system storage
 
 /*
  * Bmap defines the structure of file system storage
@@ -51,8 +56,10 @@ bmap(ip, bn, rwflg, size)
                osize = blksize(fs, ip, nb);
                if (osize < fs->fs_bsize && osize > 0) {
                        bp = realloccg(ip, ip->i_db[nb],
                osize = blksize(fs, ip, nb);
                if (osize < fs->fs_bsize && osize > 0) {
                        bp = realloccg(ip, ip->i_db[nb],
-                               blkpref(ip, nb, nb, &ip->i_db[0]),
-                               osize, fs->fs_bsize);
+                               blkpref(ip, nb, (int)nb, &ip->i_db[0]),
+                               osize, (int)fs->fs_bsize);
+                       if (bp == NULL)
+                               return ((daddr_t)-1);
                        ip->i_size = (nb + 1) * fs->fs_bsize;
                        ip->i_db[nb] = dbtofsb(fs, bp->b_blkno);
                        ip->i_flag |= IUPD|ICHG;
                        ip->i_size = (nb + 1) * fs->fs_bsize;
                        ip->i_db[nb] = dbtofsb(fs, bp->b_blkno);
                        ip->i_flag |= IUPD|ICHG;
@@ -77,7 +84,7 @@ bmap(ip, bn, rwflg, size)
                                if (nsize <= osize)
                                        goto gotit;
                                bp = realloccg(ip, nb,
                                if (nsize <= osize)
                                        goto gotit;
                                bp = realloccg(ip, nb,
-                                       blkpref(ip, bn, bn, &ip->i_db[0]),
+                                       blkpref(ip, bn, (int)bn, &ip->i_db[0]),
                                        osize, nsize);
                        } else {
                                if (ip->i_size < (bn + 1) * fs->fs_bsize)
                                        osize, nsize);
                        } else {
                                if (ip->i_size < (bn + 1) * fs->fs_bsize)
@@ -85,7 +92,7 @@ bmap(ip, bn, rwflg, size)
                                else
                                        nsize = fs->fs_bsize;
                                bp = alloc(ip,
                                else
                                        nsize = fs->fs_bsize;
                                bp = alloc(ip,
-                                       blkpref(ip, bn, bn, &ip->i_db[0]),
+                                       blkpref(ip, bn, (int)bn, &ip->i_db[0]),
                                        nsize);
                        }
                        if (bp == NULL)
                                        nsize);
                        }
                        if (bp == NULL)
@@ -136,8 +143,8 @@ gotit:
        if (nb == 0) {
                if (rwflg == B_READ)
                        return ((daddr_t)-1);
        if (nb == 0) {
                if (rwflg == B_READ)
                        return ((daddr_t)-1);
-               pref = blkpref(ip, lbn, 0, 0);
-               bp = alloc(ip, pref, fs->fs_bsize);
+               pref = blkpref(ip, lbn, 0, (daddr_t *)0);
+               bp = alloc(ip, pref, (int)fs->fs_bsize);
                if (bp == NULL)
                        return ((daddr_t)-1);
                nb = dbtofsb(fs, bp->b_blkno);
                if (bp == NULL)
                        return ((daddr_t)-1);
                nb = dbtofsb(fs, bp->b_blkno);
@@ -154,7 +161,12 @@ gotit:
         * fetch through the indirect blocks
         */
        for (; j <= NIADDR; j++) {
         * fetch through the indirect blocks
         */
        for (; j <= NIADDR; j++) {
-               bp = bread(ip->i_dev, fsbtodb(fs, nb), fs->fs_bsize);
+#ifdef SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize,
+                   fs->fs_dbsize);
+#else SECSIZE
+               bp = bread(ip->i_dev, fsbtodb(fs, nb), (int)fs->fs_bsize);
+#endif SECSIZE
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return ((daddr_t)0);
                if (bp->b_flags & B_ERROR) {
                        brelse(bp);
                        return ((daddr_t)0);
@@ -170,10 +182,11 @@ gotit:
                        }
                        if (pref == 0)
                                if (j < NIADDR)
                        }
                        if (pref == 0)
                                if (j < NIADDR)
-                                       pref = blkpref(ip, lbn, 0, 0);
+                                       pref = blkpref(ip, lbn, 0,
+                                               (daddr_t *)0);
                                else
                                        pref = blkpref(ip, lbn, i, &bap[0]);
                                else
                                        pref = blkpref(ip, lbn, i, &bap[0]);
-                       nbp = alloc(ip, pref, fs->fs_bsize);
+                       nbp = alloc(ip, pref, (int)fs->fs_bsize);
                        if (nbp == NULL) {
                                brelse(bp);
                                return ((daddr_t)-1);
                        if (nbp == NULL) {
                                brelse(bp);
                                return ((daddr_t)-1);