Remove DUX/OSF code
[openafs.git] / src / vfsck / main.c
index 665eed4..679c541 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#ifdef AFS_HPUX_ENV
+/* We need the old directory type headers (included below), so don't include
+ * the normal dirent.h, or it will conflict. */
+# undef HAVE_DIRENT_H
+# include <sys/inode.h>
+# define       LONGFILENAMES   1
+# include <sys/sysmacros.h>
+# include <sys/ino.h>
+# define       DIRSIZ_MACRO
+# ifdef HAVE_USR_OLD_USR_INCLUDE_NDIR_H
+#  include </usr/old/usr/include/ndir.h>
+# else
+#  include <ndir.h>
+# endif
+#endif
 
-#define VICE                   /* allow us to put our changes in at will */
-#include <stdio.h>
+#include <roken.h>
+
+#include <ctype.h>
+
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
 
-#include <sys/param.h>
-#include <sys/time.h>
+#define VICE                   /* allow us to put our changes in at will */
 
 #ifdef AFS_SUN_ENV
 #define KERNEL
 #undef KERNEL
 #endif
 
-#include <sys/file.h>
-
-#ifdef AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #include <sys/vnode.h>
 #ifdef   AFS_SUN5_ENV
-#include <unistd.h>
 #include <sys/fs/ufs_inode.h>
 #include <sys/fs/ufs_fs.h>
 #define _KERNEL
 #else /* AFS_VFSINCL_ENV */
 
 #include <sys/inode.h>
-#ifdef AFS_HPUX_ENV
-#include <ctype.h>
-#define        LONGFILENAMES   1
-#include <sys/sysmacros.h>
-#include <sys/ino.h>
-#define        DIRSIZ_MACRO
-#ifdef HAVE_USR_OLD_USR_INCLUDE_NDIR_H
-#include </usr/old/usr/include/ndir.h>
-#else
-#include <ndir.h>
-#endif
-#else
+#ifndef        AFS_HPUX_ENV
 #define KERNEL
 #include <sys/dir.h>
 #undef KERNEL
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
-#include <sys/stat.h>
 #include <sys/wait.h>
-#ifdef AFS_SUN5_ENV
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#include <ctype.h>
 #ifdef XAFS_SUN_ENV
 #include <mntent.h>
 #else
 #endif
 #endif
 #include "fsck.h"
-#include <errno.h>
 #include <sys/signal.h>
 
-char *rawname(), *unrawname(), *blockcheck(), *malloc();
+char *rawname(), *unrawname(), *blockcheck();
 void catch(), catchquit(), voidquit();
 static int tryForce;
 int returntosingle;
@@ -149,10 +139,10 @@ int mnt_passno = 0;
 #include "AFS_component_version_number.c"
 
 #ifdef AFS_HPUX_ENV
-int ge_danger = 0;             /* on when fsck is not able to fix the dirty file 
+int ge_danger = 0;             /* on when fsck is not able to fix the dirty file
                                 * system within single run. Problems like dup table
                                 * overflow, maxdup is exceeding MAXDUP.. etc. could
-                                * potentailly prevent fsck from doing a complete 
+                                * potentailly prevent fsck from doing a complete
                                 * repair. This is found in a GE hotsite. */
 #endif
 
@@ -181,7 +171,7 @@ main(argc, argv)
 #if    defined(AFS_HPUX_ENV)
     pclean = 0;
 #endif
-#if    defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV)
+#if    defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV)
     fflag = 0;
 #endif
 #ifdef AFS_SUN5_ENV
@@ -337,11 +327,6 @@ main(argc, argv)
            break;
 #endif /* AFS_HPUX100_ENV */
 #endif /* AFS_SUN5_ENV */
-#ifdef AFS_OSF_ENV
-       case 'o':
-           fflag++;
-           break;
-#endif /* AFS_OSF_ENV */
        case 'n':
        case 'N':
            nflag++;
@@ -386,7 +371,7 @@ main(argc, argv)
            hotroot = 0;
 #ifdef AFS_SUN5_ENV
            if (wflag && !writable(*argv)) {
-               (void)fprintf(stderr, "not writeable '%s'\n", *argv);
+               (void)fprintf(stderr, "not writable '%s'\n", *argv);
                argv++;
            } else
 #endif
@@ -438,11 +423,6 @@ main(argc, argv)
                && strcmp(fsp->fs_type, FSTAB_RO)
                && strcmp(fsp->fs_type, FSTAB_RQ))
                continue;
-#ifdef AFS_OSF_ENV
-           if (strcmp(fsp->fs_vfstype, "ufs") || fsp->fs_passno == 0) {
-               continue;
-           }
-#endif /* AFS_OSF_ENV */
            if (preen == 0 || passno == 1 && fsp->fs_passno == 1) {
                if (passno == 1) {
                    name = blockcheck(fsp->fs_spec);
@@ -561,13 +541,11 @@ finddisk(name)
        if (strncmp(dk->name, name, len) == 0 && dk->name[len] == 0)
            return (dk);
     }
-    if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL)
+    if ((*dkp = malloc(sizeof(struct disk))) == NULL)
        errexit("out of memory");
     dk = *dkp;
-    if ((dk->name = malloc((unsigned int)len + 1)) == NULL)
+    if ((dk->name = strdup(name)) == NULL)
        errexit("out of memory");
-    strncpy(dk->name, name, len);
-    dk->name[len] = '\0';
     dk->part = NULL;
     dk->next = NULL;
     dk->pid = 0;
@@ -586,15 +564,13 @@ addpart(name, fsname)
            printf("%s in fstab more than once!\n", name);
            return;
        }
-    if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL)
+    if ((*ppt = malloc(sizeof(struct part))) == NULL)
        errexit("out of memory");
     pt = *ppt;
-    if ((pt->name = malloc((unsigned int)strlen(name) + 1)) == NULL)
+    if ((pt->name = strdup(name)) == NULL)
        errexit("out of memory");
-    strcpy(pt->name, name);
-    if ((pt->fsname = malloc((unsigned int)strlen(fsname) + 1)) == NULL)
+    if ((pt->fsname = strdup(fsname)) == NULL)
        errexit("out of memory");
-    strcpy(pt->fsname, fsname);
     pt->next = NULL;
 }
 
@@ -625,10 +601,6 @@ checkfilesys(filesys, parname)
     char devbuffer[128];
     int ret_val;
 
-#ifdef AFS_OSF_ENV
-    int temp;
-#endif /* AFS_OSF_ENV */
-
 #ifdef AFS_SUN_ENV
     iscorrupt = 1;
 #endif
@@ -637,7 +609,7 @@ checkfilesys(filesys, parname)
     isconvert = 0;
 #endif
 #ifdef AFS_HPUX_ENV
-    ge_danger = 0;             /* set to 1 by any table overflow or more 
+    ge_danger = 0;             /* set to 1 by any table overflow or more
                                 * dup/bad blocks than expected */
 
     fixed = 1;                 /* set to 0 by any 'no' reply */
@@ -667,10 +639,6 @@ checkfilesys(filesys, parname)
        } else if (ret_val == -1) {     /* pclean && FS_CLEAN */
            return (1);
 #endif
-#if    defined(AFS_OSF_ENV)
-       } else if (ret_val == FS_CLEAN) {       /* pclean && FS_CLEAN */
-           return (1);
-#endif
        }
 #if    defined(AFS_HPUX100_ENV)
        if (mflag)
@@ -824,7 +792,7 @@ checkfilesys(filesys, parname)
                    sblock.fs_clean = FS_CLEAN;
                /*
                 *  Fix fs_clean if there were no 'no' replies.
-                *  This is done for both the s300 and s800.  The s800 root will be 
+                *  This is done for both the s300 and s800.  The s800 root will be
                 *  guaranteed clean as of 7.0.
                 */
                if (fixed && (sblock.fs_clean != FS_OK)) {
@@ -881,26 +849,15 @@ checkfilesys(filesys, parname)
        sbdirty();
     }
 #else
-#ifdef AFS_OSF_ENV
-    if (!nflag && !bflag && !hotroot) {
-       temp = fsmodified;
-       sblock.fs_clean = FS_CLEAN;
-       (void)time(&sblock.fs_time);
-       sbdirty();
-       flush(fswritefd, &sblk);
-       fsmodified = temp;
-    }
-#else /* AFS_OSF_ENV */
     if (fsmodified) {
        (void)time(&sblock.fs_time);
        sbdirty();
     }
 #endif
-#endif
     ckfini();
     free(blockmap);
     free(statemap);
-    free((char *)lncntp);
+    free(lncntp);
     lncntp = NULL;
     blockmap = statemap = NULL;
 #ifdef AFS_SUN5_ENV
@@ -965,18 +922,6 @@ checkfilesys(filesys, parname)
            }
        }
 #endif
-#ifdef AFS_OSF_ENV
-       /* if system mounted / as read-only, we'll try to fix now */
-       if (access("/", W_OK) < 0 && errno == EROFS) {
-           printf("Can't RW acceess /; %d\n", errno);
-           code = system("/sbin/mount -u /");
-           if (code) {
-               printf("Couldn't remount / R/W; continuing anyway (%d).\n",
-                      errno);
-               failed = 1;
-           }
-       }
-#endif
        rmdir(pname);
        unlink(pname);
        if (mkdir(pname, 0777) < 0) {
@@ -1017,15 +962,11 @@ checkfilesys(filesys, parname)
                fstat(fd, &tstat);
                close(fd);
            }
-#if !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV)
+#if !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV)
            unmount(pname);
 #else
-#if    defined(AFS_OSF_ENV)
-           umount(pname, MNT_NOFORCE);
-#else /* AFS_OSF_ENV */
            umount(devname);
 #endif
-#endif
        }
        rmdir(pname);
     }
@@ -1061,9 +1002,7 @@ blockcheck(name)
     if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
        if (stslash.st_dev == stblock.st_rdev) {
            hotroot++;
-#if    !defined(AFS_OSF_ENV)   /*  OSF/1 always uses the raw device, even for / */
            return (name);
-#endif /* AFS_OSF_ENV */
        }
        raw = rawname(name);
        if (raw) {
@@ -1158,7 +1097,7 @@ check_sanity(filename)
     /*
      * We mount the ufs root file system read-only first.  After fsck
      * runs, we remount the root as read-write.  Therefore, we no longer
-     * check for different values for fs_state between the root file 
+     * check for different values for fs_state between the root file
      * system and the rest of file systems.
      */
     if (!((sblock.fs_state + (time_t) sblock.fs_time == FSOKAY)
@@ -1234,7 +1173,7 @@ check_sanity(filename)
     /*
      * We mount the ufs root file system read-only first.  After fsck
      * runs, we remount the root as read-write.  Therefore, we no longer
-     * check for different values for fs_state between the root file 
+     * check for different values for fs_state between the root file
      * system and the rest of file systems.
      */
     if (!((sblock.fs_clean == FS_CLEAN || sblock.fs_clean == FS_OK))) {
@@ -1260,9 +1199,9 @@ numbers(yp)
 }
 #endif
 
-/* Convert a raw device name into a block device name. 
+/* Convert a raw device name into a block device name.
  * If the block device is not found, return the raw device name.
- * For HP and SUN, the returned value is not changed. For other 
+ * For HP and SUN, the returned value is not changed. For other
  * platforms it is changed (I see no rhyme or reason -jpm).
  */
 char *
@@ -1297,7 +1236,7 @@ unrawname(rawdev)
     return (rawdev);
 }
 
-/* Convert a block device name into a raw device name. 
+/* Convert a block device name into a raw device name.
  * If the block device is not found, return null
  */
 char *