BSD 4_4_Lite2 release
[unix-history] / usr / src / sbin / fsck / dir.c
index 330ecb4..f9b8b63 100644 (file)
@@ -2,11 +2,37 @@
  * Copyright (c) 1980, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Copyright (c) 1980, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dir.c      8.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)dir.c      8.8 (Berkeley) 4/28/95";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -94,7 +120,7 @@ dirscan(idesc)
        idesc->id_loc = 0;
        for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
                dsize = dp->d_reclen;
        idesc->id_loc = 0;
        for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
                dsize = dp->d_reclen;
-               bcopy((char *)dp, dbuf, (size_t)dsize);
+               memmove(dbuf, dp, (size_t)dsize);
 #              if (BYTE_ORDER == LITTLE_ENDIAN)
                        if (!newinofmt) {
                                struct direct *tdp = (struct direct *)dbuf;
 #              if (BYTE_ORDER == LITTLE_ENDIAN)
                        if (!newinofmt) {
                                struct direct *tdp = (struct direct *)dbuf;
@@ -119,7 +145,7 @@ dirscan(idesc)
                                }
 #                      endif
                        bp = getdirblk(idesc->id_blkno, blksiz);
                                }
 #                      endif
                        bp = getdirblk(idesc->id_blkno, blksiz);
-                       bcopy(dbuf, bp->b_un.b_buf + idesc->id_loc - dsize,
+                       memmove(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf,
                            (size_t)dsize);
                        dirty(bp);
                        sbdirty();
                            (size_t)dsize);
                        dirty(bp);
                        sbdirty();
@@ -329,7 +355,7 @@ mkentry(idesc)
        else
                dirp->d_type = 0;
        dirp->d_namlen = newent.d_namlen;
        else
                dirp->d_type = 0;
        dirp->d_namlen = newent.d_namlen;
-       bcopy(idesc->id_name, dirp->d_name, (size_t)newent.d_namlen + 1);
+       memmove(dirp->d_name, idesc->id_name, (size_t)newent.d_namlen + 1);
 #      if (BYTE_ORDER == LITTLE_ENDIAN)
                /*
                 * If the entry was split, dirscan() will only reverse the byte
 #      if (BYTE_ORDER == LITTLE_ENDIAN)
                /*
                 * If the entry was split, dirscan() will only reverse the byte
@@ -354,7 +380,7 @@ chgino(idesc)
 {
        register struct direct *dirp = idesc->id_dirp;
 
 {
        register struct direct *dirp = idesc->id_dirp;
 
-       if (bcmp(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1))
+       if (memcmp(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1))
                return (KEEPON);
        dirp->d_ino = idesc->id_parent;
        if (newinofmt)
                return (KEEPON);
        dirp->d_ino = idesc->id_parent;
        if (newinofmt)
@@ -376,7 +402,7 @@ linkup(orphan, parentdir)
        char tempname[BUFSIZ];
        extern int pass4check();
 
        char tempname[BUFSIZ];
        extern int pass4check();
 
-       bzero((char *)&idesc, sizeof(struct inodesc));
+       memset(&idesc, 0, sizeof(struct inodesc));
        dp = ginode(orphan);
        lostdir = (dp->di_mode & IFMT) == IFDIR;
        pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
        dp = ginode(orphan);
        lostdir = (dp->di_mode & IFMT) == IFDIR;
        pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
@@ -480,7 +506,7 @@ changeino(dir, name, newnum)
 {
        struct inodesc idesc;
 
 {
        struct inodesc idesc;
 
-       bzero((char *)&idesc, sizeof(struct inodesc));
+       memset(&idesc, 0, sizeof(struct inodesc));
        idesc.id_type = DATA;
        idesc.id_func = chgino;
        idesc.id_number = dir;
        idesc.id_type = DATA;
        idesc.id_func = chgino;
        idesc.id_number = dir;
@@ -505,7 +531,7 @@ makeentry(parent, ino, name)
        if (parent < ROOTINO || parent >= maxino ||
            ino < ROOTINO || ino >= maxino)
                return (0);
        if (parent < ROOTINO || parent >= maxino ||
            ino < ROOTINO || ino >= maxino)
                return (0);
-       bzero((char *)&idesc, sizeof(struct inodesc));
+       memset(&idesc, 0, sizeof(struct inodesc));
        idesc.id_type = DATA;
        idesc.id_func = mkentry;
        idesc.id_number = parent;
        idesc.id_type = DATA;
        idesc.id_func = mkentry;
        idesc.id_number = parent;
@@ -551,21 +577,21 @@ expanddir(dp, name)
                (long)dblksize(&sblock, dp, lastbn + 1));
        if (bp->b_errs)
                goto bad;
                (long)dblksize(&sblock, dp, lastbn + 1));
        if (bp->b_errs)
                goto bad;
-       bcopy(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
+       memmove(firstblk, bp->b_un.b_buf, DIRBLKSIZ);
        bp = getdirblk(newblk, sblock.fs_bsize);
        if (bp->b_errs)
                goto bad;
        bp = getdirblk(newblk, sblock.fs_bsize);
        if (bp->b_errs)
                goto bad;
-       bcopy(firstblk, bp->b_un.b_buf, DIRBLKSIZ);
+       memmove(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
        for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
             cp < &bp->b_un.b_buf[sblock.fs_bsize];
             cp += DIRBLKSIZ)
        for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
             cp < &bp->b_un.b_buf[sblock.fs_bsize];
             cp += DIRBLKSIZ)
-               bcopy((char *)&emptydir, cp, sizeof emptydir);
+               memmove(cp, &emptydir, sizeof emptydir);
        dirty(bp);
        bp = getdirblk(dp->di_db[lastbn + 1],
                (long)dblksize(&sblock, dp, lastbn + 1));
        if (bp->b_errs)
                goto bad;
        dirty(bp);
        bp = getdirblk(dp->di_db[lastbn + 1],
                (long)dblksize(&sblock, dp, lastbn + 1));
        if (bp->b_errs)
                goto bad;
-       bcopy((char *)&emptydir, bp->b_un.b_buf, sizeof emptydir);
+       memmove(bp->b_un.b_buf, &emptydir, sizeof emptydir);
        pwarn("NO SPACE LEFT IN %s", name);
        if (preen)
                printf(" (EXPANDED)\n");
        pwarn("NO SPACE LEFT IN %s", name);
        if (preen)
                printf(" (EXPANDED)\n");
@@ -610,11 +636,11 @@ allocdir(parent, request, mode)
                freeino(ino);
                return (0);
        }
                freeino(ino);
                return (0);
        }
-       bcopy((char *)dirp, bp->b_un.b_buf, sizeof(struct dirtemplate));
+       memmove(bp->b_un.b_buf, dirp, sizeof(struct dirtemplate));
        for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
             cp < &bp->b_un.b_buf[sblock.fs_fsize];
             cp += DIRBLKSIZ)
        for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
             cp < &bp->b_un.b_buf[sblock.fs_fsize];
             cp += DIRBLKSIZ)
-               bcopy((char *)&emptydir, cp, sizeof emptydir);
+               memmove(cp, &emptydir, sizeof emptydir);
        dirty(bp);
        dp->di_nlink = 2;
        inodirty();
        dirty(bp);
        dp->di_nlink = 2;
        inodirty();