byte swapping prototype directory entries on old little
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 28 Oct 1994 07:46:56 +0000 (23:46 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 28 Oct 1994 07:46:56 +0000 (23:46 -0800)
endian filesystems (from mycroft)

SCCS-vsn: sbin/fsck/pass2.c 8.6

usr/src/sbin/fsck/pass2.c

index 73b050c..3aafa7d 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass2.c    8.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)pass2.c    8.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -215,6 +215,15 @@ pass2check(idesc)
                proto.d_type = 0;
        proto.d_namlen = 1;
        (void)strcpy(proto.d_name, ".");
                proto.d_type = 0;
        proto.d_namlen = 1;
        (void)strcpy(proto.d_name, ".");
+#      if BYTE_ORDER == LITTLE_ENDIAN
+               if (!newinofmt) {
+                       u_char tmp;
+
+                       tmp = proto.d_type;
+                       proto.d_type = proto.d_namlen;
+                       proto.d_namlen = tmp;
+               }
+#      endif
        entrysize = DIRSIZ(0, &proto);
        if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
                pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
        entrysize = DIRSIZ(0, &proto);
        if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
                pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
@@ -249,6 +258,15 @@ chk1:
                proto.d_type = 0;
        proto.d_namlen = 2;
        (void)strcpy(proto.d_name, "..");
                proto.d_type = 0;
        proto.d_namlen = 2;
        (void)strcpy(proto.d_name, "..");
+#      if BYTE_ORDER == LITTLE_ENDIAN
+               if (!newinofmt) {
+                       u_char tmp;
+
+                       tmp = proto.d_type;
+                       proto.d_type = proto.d_namlen;
+                       proto.d_namlen = tmp;
+               }
+#      endif
        entrysize = DIRSIZ(0, &proto);
        if (idesc->id_entryno == 0) {
                n = DIRSIZ(0, dirp);
        entrysize = DIRSIZ(0, &proto);
        if (idesc->id_entryno == 0) {
                n = DIRSIZ(0, dirp);