#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
+#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
+
+#include <roken.h>
-#define VICE /* allow us to put our changes in at will */
-#include <stdio.h>
+#include <ctype.h>
-#include <sys/param.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+
+#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
-#include <ndir.h>
-#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 */
-
-#ifdef AFS_DEC_ENV
-#include <sys/fs_types.h>
-#endif
-#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;
#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
struct fstab *fsp;
int pid, passno, sumstatus;
char *name;
- register struct disk *dk, *nextdisk;
- register struct part *pt;
+ struct disk *dk, *nextdisk;
+ struct part *pt;
extern char *AFSVersion; /* generated version */
#ifdef AFS_SUN5_ENV
int other_than_ufs = 0;
#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
preen++;
break;
#endif
-#if defined(AFS_DEC_ENV)
- /* On the late versions of Ultrix they changed the defn of '-p' a bit. Particularly,
- * -p is used to check a file system that was not unmounted cleanly, and they added,
- * -P to check a file system regardless of how it was unmounted; this, unfortunately,
- * is identical to '-p' on the rest of the systems but we have to maintain vendor's
- * semantics so we leave it the way Dec likes it.
- */
case 'p':
- only_when_needed++;
- /* P is for Ultrix compatibility */
- case 'P':
-#else
- case 'p':
-#endif
preen++;
break;
#if defined(AFS_HPUX100_ENV)
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++;
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
&& strcmp(fsp->fs_type, FSTAB_RO)
&& strcmp(fsp->fs_type, FSTAB_RQ))
continue;
-#ifdef AFS_DEC_ENV
- /* Only check local (i.e. ufs) file systems */
- if (strcmp(fsp->fs_name, "4.2") && strcmp(fsp->fs_name, "ufs"))
- continue;
-#endif
-#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);
finddisk(name)
char *name;
{
- register struct disk *dk, **dkp;
- register char *p;
+ struct disk *dk, **dkp;
+ char *p;
int len;
for (p = name + strlen(name) - 1; p >= name; --p)
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;
char *name, *fsname;
{
struct disk *dk = finddisk(name);
- register struct part *pt, **ppt = &dk->part;
+ struct part *pt, **ppt = &dk->part;
for (pt = dk->part; pt; ppt = &pt->next, pt = pt->next)
if (strcmp(pt->name, name) == 0) {
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;
}
startdisk(dk)
- register struct disk *dk;
+ struct disk *dk;
{
nrun++;
struct zlncnt *zlnp;
char devbuffer[128];
int ret_val;
-#ifdef AFS_DEC_ENV
- int retries = 3; /* # of retries fora clean fsck pass */
- int fsdirty = 0; /* file system was or is dirty */
- int rootdirty = 0; /* Root was or is dirty */
-#endif
-
-#ifdef AFS_OSF_ENV
- int temp;
-#endif /* AFS_OSF_ENV */
#ifdef AFS_SUN_ENV
iscorrupt = 1;
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 */
EnsureDevice(devname); /* canonicalize name */
if (debug && preen)
pinfo("starting\n");
-#ifdef AFS_DEC_ENV
- for (; retries > 0; retries--) { /* 003 - Loop for NUMRETRIES or until clean */
-#endif
ret_val = setup(devname);
} else if (ret_val == -1) { /* pclean && FS_CLEAN */
return (1);
#endif
-#if defined(AFS_DEC_ENV) || defined(AFS_OSF_ENV)
- } else if (ret_val == FS_CLEAN) { /* pclean && FS_CLEAN */
- return (1);
-#endif
}
#if defined(AFS_HPUX100_ENV)
if (mflag)
msgprintf("** Phase 5 - Check Cyl groups\n");
pass5();
-#ifdef AFS_DEC_ENV
- if (fsmodified || (sblk.b_dirty) || (cgblk.b_dirty)) {
- fsdirty = 1;
- if (hotroot)
- rootdirty = 1;
- if (retries <= 1) {
- /*
- * 003 - Number of retry attempts have been
- * exhausted. Mark super block as dirty.
- */
- (void)time(&sblock.fs_time);
- sbdirty();
- }
- } else {
- /*
- * 003 - If checking root file system, and it was
- * modified during any pass, don't assume it is ok. Must reboot.
- */
- if (rootdirty) {
- sbdirty();
- retries = 0;
- } else {
- if ((!hotroot) && (!bflag) && (!nflag) && (!iscorrupt)) {
- sblock.fs_fmod = 0;
- sblock.fs_clean = FS_CLEAN;
- (void)time(&sblock.fs_time);
- (void)time(&sblock.fs_lastfsck);
- if ((sblock.fs_deftimer) && (sblock.fs_deftimer > 0)
- && (sblock.fs_deftimer < 255))
- sblock.fs_cleantimer = sblock.fs_deftimer;
- else
- sblock.fs_cleantimer = sblock.fs_deftimer =
- FSCLEAN_TIMEOUTFACTOR;
- sbdirty();
- }
- /*
- * 006 - If an alternate super block was used,
- * we want to re fsck the partition after
- * updating the primary super block.
- */
- if (!bflag)
- retries = 0;
- }
- }
- /* Unless no updates are to be done, write out maps. */
- if (nflag)
- retries = 0;
- else
- ckfini();
- if (debug) {
- daddr_t nn_files = n_files;
- daddr_t nn_blks = n_blks;
-
- n_ffree = sblock.fs_cstotal.cs_nffree;
- n_bfree = sblock.fs_cstotal.cs_nbfree;
- if (nn_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree)
- printf("%d files missing\n", nn_files);
- nn_blks +=
- sblock.fs_ncg * (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
- nn_blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
- nn_blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
- if (nn_blks -= maxfsblock - (n_ffree + sblock.fs_frag * n_bfree))
- printf("%d blocks missing\n", nn_blks);
- }
- if (duplist != NULL) {
- if (debug)
- printf("The following duplicate blocks remain:");
- for (dp = duplist; dp; dp = dp->next) {
- if (debug)
- printf(" %d,", dp->dup);
- free(dp);
- }
- if (debug)
- printf("\n");
- }
- if (zlnhead != NULL) {
- if (debug)
- printf("The following zero link count inodes remain:");
- for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) {
- if (debug)
- printf(" %d,", zlnp->zlncnt);
- free(zlnp);
- }
- if (debug)
- printf("\n");
- }
- zlnhead = NULL;
- duplist = NULL;
-
- free(blockmap);
- free(statemap);
- free((char *)lncntp);
- /* Print out retry message, and fsck file system again. */
- if (retries > 1)
- if (preen)
- printf("%s: FILE SYSTEM MODIFIED, VERIFYING\n", filesys);
- else
- printf("**** FILE SYSTEM MODIFIED, VERIFYING\n");
- } /* for retries */
-#endif
-
-#if defined(AFS_SUN_ENV) && !defined(AFS_SUN3_ENV)
+#if defined(AFS_SUN_ENV)
updateclean();
if (debug)
printclean();
n printf("(%d frags, %d blocks, %.1f%% fragmentation)\n", n_ffree,
n_bfree, (float)(n_ffree * 100) / sblock.fs_dsize);
#endif /* VICE */
-#ifdef AFS_DEC_ENV
- if ((!fsdirty) && (!rootdirty))
- return;
- if (!preen) {
- printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
- if (hotroot)
- printf("\n***** HALT PROCESSOR WITHOUT SYNCING DISK *****\n");
- }
- if (hotroot) {
- sync();
- exit(4);
- }
-#else
if (debug && (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree))
msgprintf("%d files missing\n", n_files);
if (debug) {
msgprintf("\n");
}
}
-#endif
#ifdef AFS_HPUX_ENV
/* if user's specification denotes that the file system block
* is going to be modified (nflag == 0) then fsck store the
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)) {
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
-#ifndef AFS_DEC_ENV
ckfini();
free(blockmap);
free(statemap);
- free((char *)lncntp);
+ free(lncntp);
lncntp = NULL;
blockmap = statemap = NULL;
#ifdef AFS_SUN5_ENV
exit(4);
#endif
}
-#endif
#ifdef VICE
(void)close(fsreadfd);
(void)close(fswritefd);
if (nViceFiles || tryForce) {
/* Modified file system with vice files: force full salvage */
/* Salvager recognizes the file FORCESALVAGE in the root of each partition */
-#if !defined(AFS_DEC_ENV)
struct ufs_args ufsargs;
-#endif
char pname[100], fname[100], *special;
int fd, code, failed = 0;
}
}
#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) {
if (failed && parname) {
strcpy(pname, parname);
}
-#if !defined(AFS_DEC_ENV) && !defined(AFS_HPUX_ENV)
+#if !defined(AFS_HPUX_ENV)
#ifdef AFS_SUN5_ENV
ufsargs.flags = UFSMNT_NOINTR;
#else
ufsargs.fspec = devname;
#endif
-#ifdef AFS_SUN_ENV
#ifdef AFS_SUN5_ENV
if (mount
(devname, pname, MS_DATA, "ufs", (char *)&ufsargs,
sizeof(ufsargs)) < 0) {
#else
- if (mount("4.2", pname, M_NEWTYPE, &ufsargs) < 0) {
-#endif
-#else
if (mount(MOUNT_UFS, pname, 0, &ufsargs) < 0) {
#endif
#else
-#ifdef AFS_DEC_ENV
- if (mount(devname, pname, 0, GT_ULTRIX, NULL)) {
-#else
if (mount(devname, pname, 0) < 0) {
#endif
-#endif
printf
("Couldn't mount %s on %s to force FULL SALVAGE; continuing anyway (%d)!\n",
devname, pname, errno);
fd = open(fname, O_CREAT, 0);
if (fd == -1) {
errexit("Couldn't create %s to force full salvage!\n", fname);
-#if defined(AFS_DEC_ENV)
- stat(".", &tstat);
-#endif
} else {
fstat(fd, &tstat);
close(fd);
}
-#if /*defined(AFS_VFS_ENV) &&*/ !defined(AFS_DEC_ENV) && !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_DEC_ENV)
- umount(tstat.st_dev);
-#else
-#if defined(AFS_OSF_ENV)
- umount(pname, MNT_NOFORCE);
-#else /* AFS_OSF_ENV */
umount(devname);
#endif
-#endif
-#endif
}
rmdir(pname);
}
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) {
/*
* 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)
/*
* 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))) {
}
#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 *
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 *