X-Git-Url: http://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fvfsck%2Fmain.c;h=679c5419d7cbd3b2c428cfa08833fe43a856f606;hp=ee034f2d410f46e9d5fa68f22fff258ac93c3031;hb=6534b10a4180ec10bceebbc11405718e7969fa21;hpb=aee18ed884d2af05174594120ba1825bfe76c96a diff --git a/src/vfsck/main.c b/src/vfsck/main.c index ee034f2..679c541 100644 --- a/src/vfsck/main.c +++ b/src/vfsck/main.c @@ -18,14 +18,31 @@ #include #include -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 +# define LONGFILENAMES 1 +# include +# include +# define DIRSIZ_MACRO +# ifdef HAVE_USR_OLD_USR_INCLUDE_NDIR_H +# include +# else +# include +# endif +#endif -#define VICE /* allow us to put our changes in at will */ -#include +#include + +#include + +#ifdef HAVE_SYS_FILE_H +#include +#endif -#include -#include +#define VICE /* allow us to put our changes in at will */ #ifdef AFS_SUN_ENV #define KERNEL @@ -35,19 +52,10 @@ RCSID #undef KERNEL #endif -#include - -#ifdef AFS_OSF_ENV -#include -#include -#include -#include -#else /* AFS_OSF_ENV */ #ifdef AFS_VFSINCL_ENV #define VFS #include #ifdef AFS_SUN5_ENV -#include #include #include #define _KERNEL @@ -64,34 +72,15 @@ RCSID #else /* AFS_VFSINCL_ENV */ #include -#ifdef AFS_HPUX_ENV -#include -#define LONGFILENAMES 1 -#include -#include -#define DIRSIZ_MACRO -#ifdef HAVE_USR_OLD_USR_INCLUDE_NDIR_H -#include -#else -#include -#endif -#else +#ifndef AFS_HPUX_ENV #define KERNEL #include #undef KERNEL #endif #include #endif /* AFS_VFSINCL_ENV */ -#endif /* AFS_OSF_ENV */ -#include #include -#ifdef AFS_SUN5_ENV -#include -#else -#include -#endif -#include #ifdef XAFS_SUN_ENV #include #else @@ -105,10 +94,9 @@ RCSID #endif #endif #include "fsck.h" -#include #include -char *rawname(), *unrawname(), *blockcheck(), *malloc(); +char *rawname(), *unrawname(), *blockcheck(); void catch(), catchquit(), voidquit(); static int tryForce; int returntosingle; @@ -151,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 @@ -165,8 +153,8 @@ main(argc, argv) 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; @@ -183,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 @@ -339,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++; @@ -388,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 @@ -440,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); @@ -547,8 +525,8 @@ struct disk * 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) @@ -563,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; @@ -581,27 +557,25 @@ addpart(name, fsname) 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++; @@ -627,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 @@ -639,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 */ @@ -669,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) @@ -826,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)) { @@ -883,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 @@ -967,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) { @@ -1019,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); } @@ -1063,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) { @@ -1160,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) @@ -1236,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))) { @@ -1262,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 * @@ -1299,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 *