mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 06:50:12 +00:00
vol: de-orbit test programs
The updateDirInode and listVicepx utilities are obsolete; they no longer build, are severely bitrotted, and have been largely replaced by volscan. While here, also remove other objects that have not been built by default since before the original IBM import: - ILIST ilist.exe - NAMEI_PROGS nicreate, nincdec, nino, nilist Remove all of them from the tree. Change-Id: I8f68ec425cce5e84bcc5f41d598eec23102109de Reviewed-on: https://gerrit.openafs.org/13793 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
0a7d0c30a9
commit
2928dbd78f
@ -933,7 +933,6 @@ distclean: clean
|
||||
src/vlserver/Makefile \
|
||||
src/tvlserver/Makefile \
|
||||
src/vol/Makefile \
|
||||
src/vol/test/Makefile \
|
||||
src/volser/Makefile \
|
||||
src/xstat/Makefile \
|
||||
tests/Makefile \
|
||||
|
@ -186,7 +186,6 @@ AC_CONFIG_FILES([
|
||||
src/vlserver/Makefile
|
||||
src/tvlserver/Makefile
|
||||
src/vol/Makefile
|
||||
src/vol/test/Makefile
|
||||
src/volser/Makefile
|
||||
src/xstat/Makefile
|
||||
src/helper-splint.sh
|
||||
|
@ -245,10 +245,6 @@ clean:
|
||||
$(RM) -f *.o *.a AFS_component_version_number.c
|
||||
$(RM) -f ${SCMPROGS} ${STAGEPROGS} core salvager volinfo volscan gi fssync-debug
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
cd test && $(MAKE)
|
||||
|
||||
include ../config/Makefile.version
|
||||
|
||||
check-splint::
|
||||
|
@ -1,67 +0,0 @@
|
||||
# Copyright 2000, International Business Machines Corporation and others.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# This software has been released under the terms of the IBM Public
|
||||
# License. For details, see the LICENSE file in the top-level source
|
||||
# directory or online at http://www.openafs.org/dl/license10.html
|
||||
|
||||
srcdir=@srcdir@
|
||||
include @TOP_OBJDIR@/src/config/Makefile.config
|
||||
include @TOP_OBJDIR@/src/config/Makefile.lwp
|
||||
|
||||
INCDIRS=-I. -I.. -I${TOP_INCDIR} ${FSINCLUDES}
|
||||
|
||||
LIBS=${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/vlib.a \
|
||||
${TOP_LIBDIR}/util.a \
|
||||
${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libdir.a \
|
||||
${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libacl.a ${XLIBS}
|
||||
|
||||
NAMEI_LIBS=../vlib.a ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/liblwp.a
|
||||
|
||||
MODULE_CFLAGS = -D${SYS_NAME} -g
|
||||
|
||||
PROGS = listVicepx
|
||||
|
||||
PUBLICHEADERS=../nfs.h ../vnode.h ../viceinode.h ../volume.h ../vldb.h \
|
||||
../voldefs.h ../partition.h ../fssync.h ../inodeops.h
|
||||
|
||||
OBJECTS=listVicepx.o utilities.o updateDirInode.o
|
||||
|
||||
all: listVicepx updateDirInode testpart
|
||||
|
||||
install:
|
||||
|
||||
${OBJECTS}: ${PUBLICHEADERS} ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/lock.h ${TOP_INCDIR}/afs/afsint.h ../filesignal.h ../vutils.h ../vldb.h ../salvage.h ../volinodes.h ../qiin.h
|
||||
|
||||
testpart: testpart.c ../vlib.a
|
||||
$(AFS_LDRULE) testpart.c ${TOP_LIBDIR}/vlib.a ${TOP_LIBDIR}/liblwp.a \
|
||||
${TOP_LIBDIR}/util.a ${XLIBS}
|
||||
|
||||
|
||||
listVicepx: listVicepx.o utilities.o
|
||||
$(AFS_LDRULE) listVicepx.o utilities.o ${LIBS}
|
||||
|
||||
updateDirInode: updateDirInode.o
|
||||
$(AFS_LDRULE) updateDirInode.o ${LIBS}
|
||||
|
||||
|
||||
NAMEI_PROGS = nicreate nincdec nino nilist
|
||||
namei: ${NAMEI_PROGS}
|
||||
|
||||
nicreate: nicreate.o nsubr.o
|
||||
$(AFS_LDRULE) nicreate.o nsubr.o ${NAMEI_LIBS}
|
||||
|
||||
nincdec: nincdec.o nsubr.o
|
||||
$(AFS_LDRULE) nincdec.o nsubr.o ${NAMEI_LIBS}
|
||||
|
||||
nilist: nilist.o nsubr.o
|
||||
$(AFS_LDRULE) nilist.o nsubr.o ${NAMEI_LIBS}
|
||||
|
||||
nino: nino.o
|
||||
$(AFS_LDRULE) nino.o ${TOP_LIBDIR}/util.a
|
||||
|
||||
clean:
|
||||
$(RM) -f *.o *.a
|
||||
$(RM) -f ${SCMPROGS} ${STAGEPROGS} core listVicepx updateDirInode
|
||||
dest:
|
||||
|
@ -1,47 +0,0 @@
|
||||
# Copyright 2000, International Business Machines Corporation and others.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# This software has been released under the terms of the IBM Public
|
||||
# License. For details, see the LICENSE file in the top-level source
|
||||
# directory or online at http://www.openafs.org/dl/license10.html
|
||||
|
||||
RELDIR=vol\test
|
||||
!INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
|
||||
!INCLUDE ..\..\config\NTMakefile.version
|
||||
|
||||
############################################################################
|
||||
# External libraries
|
||||
|
||||
EXEC_LIBS = \
|
||||
$(DESTDIR)\lib\afs\afscmd.lib \
|
||||
$(DESTDIR)\lib\afs\afsvol.lib \
|
||||
$(DESTDIR)\lib\afs\afsutil.lib \
|
||||
$(DESTDIR)\lib\afs\afsdir.lib \
|
||||
$(DESTDIR)\lib\afslwp.lib \
|
||||
$(DESTDIR)\lib\afs\afsacl.lib \
|
||||
$(DESTDIR)\lib\afs\afsreg.lib
|
||||
|
||||
|
||||
############################################################################
|
||||
# build inode lister
|
||||
ILIST = $(OUT)\ilist.exe
|
||||
|
||||
$(ILIST): $(OUT)\ilist_nt.obj $(EXEC_LIBS)
|
||||
$(EXECONLINK)
|
||||
$(_VC_MANIFEST_EMBED_EXE)
|
||||
$(CODESIGN_USERLAND)
|
||||
$(SYMSTORE_IMPORT)
|
||||
|
||||
|
||||
############################################################################
|
||||
# build link table lister
|
||||
LTLIST = $(OUT)\ltlist.exe
|
||||
|
||||
$(LTLIST): $(OUT)\ltlist.obj $(EXEC_LIBS)
|
||||
$(EXECONLINK)
|
||||
$(_VC_MANIFEST_EMBED_EXE)
|
||||
$(CODESIGN_USERLAND)
|
||||
$(SYMSTORE_IMPORT)
|
||||
|
||||
mkdir:
|
||||
|
@ -1,40 +0,0 @@
|
||||
Copyright 2000, International Business Machines Corporation and others.
|
||||
All Rights Reserved.
|
||||
|
||||
This software has been released under the terms of the IBM Public
|
||||
License. For details, see the LICENSE file in the top-level source
|
||||
directory or online at http://www.openafs.org/dl/license10.html
|
||||
|
||||
/* Tool for listing /vicepX partition
|
||||
**
|
||||
*/
|
||||
listVicepx -p < partitionName> -v <volumeName>
|
||||
[-ls | -lsl | -ld | -dir <directoryInode> ]
|
||||
|
||||
Without any input options, it prints out the names of symlinks and
|
||||
directory names where any of its file is mounted.
|
||||
|
||||
With the -ls option, it prints out the names of all file/symlinks
|
||||
inside the volume.
|
||||
|
||||
With the -lsl option, it prints out metadata about all file/symlink.
|
||||
This metadata includes the inode number(Ind), UNIX mode bits(Mod),
|
||||
link count(Lnk), the owner(Own), the group(Grp) and the file size(Siz).
|
||||
|
||||
With the -ld option, it prints out metadata about all directories
|
||||
in this volume. This metadata includes the directory inode(Ind) and
|
||||
the directory vnode(Vnd) along with the directory name. The root
|
||||
directory of the volume is indicated as ~.
|
||||
|
||||
With the -dir <directory inode> option, this tool prints out the
|
||||
contents of this directory. The inode number has to be a directory inode.
|
||||
|
||||
COMPILATION:
|
||||
mkdir objvol/test
|
||||
cd obj/vol/test
|
||||
ln -s ../SRC/test SRC
|
||||
ln -s ../DEST DEST
|
||||
make install
|
||||
|
||||
The executable name is listVicepx.
|
||||
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/* ilist_nt.c - List the "inode" information for one or all volumes on
|
||||
* a partition.
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#include "nfs.h"
|
||||
#include "ihandle.h"
|
||||
#include <afs/afsint.h>
|
||||
#include <lock.h>
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "viceinode.h"
|
||||
|
||||
|
||||
void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage: ilist ilist partition [volume]\n");
|
||||
printf
|
||||
("List all \"inodes\" for the volume group containing the volume\n");
|
||||
printf("or for the entire partition.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* This judge function can be a dummy since I know how nt_ListAFSFiles works */
|
||||
int
|
||||
Judge(struct ViceInodeInfo *info, int vid)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
PrintInodeInfo(FILE * fp, struct ViceInodeInfo *info, char *dir, char *name)
|
||||
{
|
||||
static int lastVID = -1;
|
||||
int rwVID;
|
||||
char dname[1024];
|
||||
|
||||
rwVID =
|
||||
info->u.param[1] ==
|
||||
-1 ? info->u.special.parentId : info->u.vnode.volumeId;
|
||||
|
||||
if (rwVID != lastVID) {
|
||||
if (lastVID != -1)
|
||||
printf("\n");
|
||||
lastVID = rwVID;
|
||||
/* This munging of the name remove a "\R". */
|
||||
(void)strcpy(dname, dir);
|
||||
dname[strlen(dname) - 2] = '\0';
|
||||
printf("Parent Volume %d, Directory %s\n", rwVID, dname);
|
||||
printf("%14s %8s %5s %10s %10s %10s %10s %s\n", "Inode", "Size",
|
||||
"Nlink", "P1", "P2", "P3", "P4", "Name");
|
||||
}
|
||||
printf("%14I64d %8d %5d %10d %10d %10d %10d %s\n", info->inodeNumber,
|
||||
info->byteCount, info->linkCount, info->u.param[0],
|
||||
info->u.param[1], info->u.param[2], info->u.param[3], name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int singleVolumeNumber = 0;
|
||||
char *part;
|
||||
int ninodes;
|
||||
|
||||
if (ac < 2 || ac > 3)
|
||||
Usage();
|
||||
|
||||
part = av[1];
|
||||
if (ac == 3)
|
||||
singleVolumeNumber = atoi(av[2]);
|
||||
|
||||
ninodes =
|
||||
nt_ListAFSFiles(part, PrintInodeInfo, stdout, Judge,
|
||||
singleVolumeNumber);
|
||||
}
|
@ -1,657 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/*
|
||||
** Lists all files in a /vicepX partition. This started as an
|
||||
** exercise to know the layout of AFS data in a fileserver
|
||||
** partition. Later on, it proved useful in debugging problems
|
||||
** at customer sites too.
|
||||
**
|
||||
*/
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <rx/xdr.h>
|
||||
#include <afs/afsint.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/param.h>
|
||||
#if !defined(AFS_SGI_ENV)
|
||||
#ifdef AFS_VFSINCL_ENV
|
||||
#define VFS
|
||||
#ifdef AFS_SUN5_ENV
|
||||
#include <sys/fs/ufs_fs.h>
|
||||
#else
|
||||
#include <ufs/fs.h>
|
||||
#endif
|
||||
#else /* AFS_VFSINCL_ENV */
|
||||
#ifndef AFS_AIX_ENV
|
||||
#include <sys/fs.h>
|
||||
#endif
|
||||
#endif /* AFS_VFSINCL_ENV */
|
||||
#endif /* AFS_SGI_ENV */
|
||||
#include <sys/errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/file.h>
|
||||
#if defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_BSD_ENV))
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif
|
||||
#ifdef AFS_AIX_ENV
|
||||
#include <sys/vfs.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#ifdef AFS_HPUX_ENV
|
||||
#include <fcntl.h>
|
||||
#include <mntent.h>
|
||||
#else
|
||||
#if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
|
||||
#ifdef AFS_SUN5_ENV
|
||||
#include <sys/mnttab.h>
|
||||
#include <sys/mntent.h>
|
||||
#else
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
#else
|
||||
#if defined(AFS_SGI_ENV)
|
||||
#include <fcntl.h>
|
||||
#include <mntent.h>
|
||||
|
||||
/*
|
||||
#include <sys/fs/efs.h>
|
||||
*/
|
||||
#include "efs.h" /* until 5.1 release */
|
||||
|
||||
#define ROOTINO EFS_ROOTINO
|
||||
#else
|
||||
#include <fstab.h>
|
||||
#endif
|
||||
#endif /* AFS_SGI_ENV */
|
||||
#endif /* AFS_HPUX_ENV */
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/wait.h>
|
||||
#include <setjmp.h>
|
||||
#ifndef ITIMER_REAL
|
||||
#include <sys/time.h>
|
||||
#endif /* ITIMER_REAL */
|
||||
|
||||
#include "nfs.h"
|
||||
#include <afs/errors.h>
|
||||
#include "lock.h"
|
||||
#include "lwp.h"
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "vldb.h"
|
||||
#include "partition.h"
|
||||
#include "filesignal.h"
|
||||
#include "vutils.h"
|
||||
#include "daemon_com.h"
|
||||
#include "fssync.h"
|
||||
#include <afs/auxinode.h>
|
||||
#include <afs/dir.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "salvage.h"
|
||||
int volumeId;
|
||||
int VolumeChanged; /* to satisfy library libdir use */
|
||||
|
||||
#include "listVicepx.h"
|
||||
char *orphan_NoVnode = "ORPHANED_NoVnode";
|
||||
char *orphan_NoUnique = "ORPHANED_NoUnique";
|
||||
|
||||
#define allNull 0x00
|
||||
#define allFiles 0x01 /* equivalent to /bin/ls */
|
||||
#define lFlag 0x02 /* equivalent to /bin/ls -l */
|
||||
#define allDirs 0x04 /* equivalent to /bin/ls -ld */
|
||||
#define contentsDInode 0x08 /* list contents of dir inode */
|
||||
#define volInfo 0x10 /* list info from vol header */
|
||||
|
||||
extern DirEnt *lookup();
|
||||
extern char *getFileName(), *getDirName(), *printStack();
|
||||
extern DirEnt *hash[];
|
||||
|
||||
int
|
||||
Usage(name)
|
||||
char *name;
|
||||
{
|
||||
assert(name);
|
||||
printf
|
||||
("Usage is %s -p <partition name> -v <volume name> [-ls | -lsl | -ld] [-volInfo] [-dir <directory inode>] \n",
|
||||
name);
|
||||
printf("-ls : lists all files\n");
|
||||
printf("-lsl : lists all files along with its properties\n");
|
||||
printf("-ld : lists all directories\n");
|
||||
printf("-volInfo : lists volume header \n");
|
||||
printf("-dir <inode number>: prints contents of directory inode\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char fullName[32 + VNAMESIZE + sizeof(VHDREXT) + 4];
|
||||
char partition[32], volume[VNAMESIZE];
|
||||
struct stat statBuf;
|
||||
struct VolumeHeader volumeHeader;
|
||||
int fd, i, sawPart = 0, sawVolume = 0, sawDirContents = 0;
|
||||
char option = allNull; /* no default options */
|
||||
Inode dirInode; /* list contents of this dir Inode */
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-p")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
assert(strlen(argv[i + 1]) < 32);
|
||||
strcpy(partition, argv[++i]);
|
||||
sawPart = 1;
|
||||
} else if (!strcmp(argv[i], "-v")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
assert(strlen(argv[i + 1]) < VNAMESIZE);
|
||||
strcpy(volume, argv[++i]);
|
||||
sawVolume = 1;
|
||||
} else if (!strcmp(argv[i], "-dir")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
dirInode = atoi(argv[++i]);
|
||||
option |= contentsDInode;
|
||||
sawDirContents = 1;
|
||||
} else if (!strcmp(argv[i], "-ls"))
|
||||
option |= allFiles;
|
||||
else if (!strcmp(argv[i], "-lsl"))
|
||||
option |= (allFiles | lFlag);
|
||||
else if (!strcmp(argv[i], "-ld"))
|
||||
option |= allDirs;
|
||||
else if (!strcmp(argv[i], "-volInfo"))
|
||||
option |= volInfo;
|
||||
else
|
||||
Usage(argv[0]);
|
||||
}
|
||||
/* check input parameters */
|
||||
if (!sawPart || !sawVolume)
|
||||
Usage(argv[0]);
|
||||
|
||||
/* extract volume id */
|
||||
volumeId = atoi(volume);
|
||||
|
||||
/* construct unix file name */
|
||||
strcpy(fullName, partition);
|
||||
strcat(fullName, "/V");
|
||||
strcat(fullName, volume);
|
||||
strcat(fullName, VHDREXT);
|
||||
|
||||
/* check to see that volume exists */
|
||||
if (stat(fullName, &statBuf) < 0) {
|
||||
printf("Error in stat(%s) : %d\n", fullName, errno);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* read volume header */
|
||||
if ((fd = open(fullName, O_RDONLY)) < 0) {
|
||||
printf("Error in open(%s) : %d\n", fullName, errno);
|
||||
exit(3);
|
||||
}
|
||||
if (read(fd, &volumeHeader, sizeof(struct VolumeHeader)) <
|
||||
sizeof(struct VolumeHeader)) {
|
||||
printf("Error in reading Volume Header : %d\n", errno);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
switch (option) {
|
||||
case volInfo: /* volume header info */
|
||||
printf
|
||||
("VolId:%d VolInfo:%d mag:%x vers:%d smallVnodeIndex:%d largeVnodeIndex:%d VoAcl:%d volMntTab:%d\n",
|
||||
volumeHeader.id, volumeHeader.volumeInfo,
|
||||
volumeHeader.stamp.magic, volumeHeader.stamp.version,
|
||||
volumeHeader.smallVnodeIndex, volumeHeader.largeVnodeIndex,
|
||||
volumeHeader.volumeAcl, volumeHeader.volumeMountTable);
|
||||
break;
|
||||
|
||||
case contentsDInode: /* list directory entries */
|
||||
printContentsOfDirInode(statBuf.st_dev, dirInode, fullName, option);
|
||||
break;
|
||||
}
|
||||
|
||||
scanLargeVnode(statBuf.st_dev, volumeHeader.largeVnodeIndex, fullName,
|
||||
option);
|
||||
if (option & allDirs)
|
||||
printDirs(fullName);
|
||||
|
||||
if (option & allFiles)
|
||||
scanSmallVnode(statBuf.st_dev, volumeHeader.smallVnodeIndex, fullName,
|
||||
option);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int
|
||||
scanLargeVnode(dev, node, partitionName, option)
|
||||
dev_t dev;
|
||||
Inode node;
|
||||
char *partitionName;
|
||||
char option; /* user options */
|
||||
{
|
||||
afs_int32 diskSize = SIZEOF_LARGEDISKVNODE;
|
||||
int nVnodes, fdi, vnodeIndex, offset = 0;
|
||||
char buf[SIZEOF_LARGEDISKVNODE];
|
||||
struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
|
||||
FILE *file;
|
||||
struct stat statBuf;
|
||||
|
||||
/* open this largeVodeIndex */
|
||||
if ((fdi = iopen(dev, node, O_RDONLY)) < 0) {
|
||||
printf("Error in reading node : %d\n", errno);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/* get a FILE pointer */
|
||||
if ((file = fdopen(fdi, "r")) == 0) {
|
||||
printf("fdopen failed : %d\n", errno);
|
||||
exit(6);
|
||||
}
|
||||
|
||||
/*find out how many directories are there in this volume */
|
||||
if (fstat(fdi, &statBuf) < 0) {
|
||||
printf("Error in stat(fd=%d): %d\n", fdi, errno);
|
||||
exit(6);
|
||||
}
|
||||
nVnodes = (statBuf.st_size / diskSize) - 1;
|
||||
if (nVnodes > 0)
|
||||
fseek(file, diskSize, 0);
|
||||
else
|
||||
nVnodes = 0;
|
||||
|
||||
/* scan all entries in this volume */
|
||||
DInit(10); /* initialise directory buffer */
|
||||
|
||||
for (vnodeIndex = 0; nVnodes && fread(vnode, diskSize, 1, file) == 1;
|
||||
nVnodes--, vnodeIndex++, offset += diskSize) {
|
||||
/* scan this directory */
|
||||
int createDirEnt();
|
||||
if ((vnode->type == vDirectory) && (vnode->inodeNumber)) {
|
||||
DirHandle dir;
|
||||
DirEnt *dirEntry;
|
||||
|
||||
dir.volume = volumeId;
|
||||
dir.device = dev;
|
||||
dir.cacheCheck = 0;
|
||||
dir.inode = vnode->inodeNumber;
|
||||
#ifdef DEBUG
|
||||
printf
|
||||
("Directory inode %d (parent vnode = %d) contains the entries :\n",
|
||||
vnode->inodeNumber, vnode->parent);
|
||||
#endif
|
||||
|
||||
assert(dirEntry = malloc(sizeof(DirEnt)));
|
||||
dirEntry->inode = vnode->inodeNumber;
|
||||
dirEntry->numEntries = 0;
|
||||
dirEntry->vnodeName = NULL;
|
||||
EnumerateDir(&dir, &createDirEnt, dirEntry);
|
||||
insertHash(dirEntry); /* insert in hash table */
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
#ifdef DEBUG
|
||||
printHash();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
createDirEnt(dirEntry, fileName, vnode, unique)
|
||||
DirEnt *dirEntry;
|
||||
char *fileName;
|
||||
afs_int32 vnode;
|
||||
afs_int32 unique;
|
||||
{
|
||||
int fdi;
|
||||
FILE *file;
|
||||
struct stat statBuf;
|
||||
|
||||
/* fil up special fields for itself and parent */
|
||||
if (strcmp(fileName, ".") == 0) {
|
||||
dirEntry->vnode = vnode;
|
||||
return;
|
||||
}
|
||||
if (strcmp(fileName, "..") == 0) {
|
||||
dirEntry->vnodeParent = vnode;
|
||||
return;
|
||||
}
|
||||
|
||||
(dirEntry->numEntries)++;
|
||||
assert(dirEntry->vnodeName =
|
||||
realloc(dirEntry->vnodeName,
|
||||
dirEntry->numEntries * sizeof(VnodeName)));
|
||||
dirEntry->vnodeName[dirEntry->numEntries - 1].vnode = vnode;
|
||||
dirEntry->vnodeName[dirEntry->numEntries - 1].vunique = unique;
|
||||
dirEntry->vnodeName[dirEntry->numEntries - 1].name = strdup(fileName);
|
||||
assert(dirEntry->vnodeName[dirEntry->numEntries - 1].name);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
scanSmallVnode(dev, node, partitionName, option)
|
||||
dev_t dev;
|
||||
Inode node;
|
||||
char *partitionName;
|
||||
char option; /* user options */
|
||||
{
|
||||
afs_int32 diskSize = SIZEOF_SMALLDISKVNODE;
|
||||
int nVnodes, fdi, vnodeIndex, offset = 0;
|
||||
char buf[SIZEOF_LARGEDISKVNODE];
|
||||
struct VnodeDiskObject *vnode = (struct VnodeDiskObject *)buf;
|
||||
FILE *file;
|
||||
struct stat statBuf;
|
||||
|
||||
/* open this smallVodeIndex */
|
||||
if ((fdi = iopen(dev, node, O_RDONLY)) < 0) {
|
||||
printf("Error in reading node : %d\n", errno);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/* get a FILE pointer */
|
||||
if ((file = fdopen(fdi, "r")) == 0) {
|
||||
printf("fdopen failed : %d\n", errno);
|
||||
exit(6);
|
||||
}
|
||||
|
||||
/*find out how many files are there in this volume */
|
||||
if (fstat(fdi, &statBuf) < 0) {
|
||||
printf("Error in stat(fd=%d): %d\n", fdi, errno);
|
||||
exit(6);
|
||||
}
|
||||
nVnodes = (statBuf.st_size / diskSize) - 1;
|
||||
if (nVnodes > 0)
|
||||
fseek(file, diskSize, 0);
|
||||
else
|
||||
nVnodes = 0;
|
||||
|
||||
/* scan all entries in this volume */
|
||||
for (vnodeIndex = 0; nVnodes && fread(vnode, diskSize, 1, file) == 1;
|
||||
nVnodes--, vnodeIndex++, offset += 1)
|
||||
if ((vnode->type == vFile) || (vnode->type == vSymlink)) {
|
||||
char *name, *fullPathName;
|
||||
int pNode, nNode, orphan = 0;
|
||||
DirEnt *dir;
|
||||
#ifdef FILE_DEBUG
|
||||
printf(" File Inode = %d parent vnode=%d ", vnode->inodeNumber,
|
||||
vnode->parent);
|
||||
#endif
|
||||
|
||||
if ((dir = lookup(vnode->parent)) == 0) /* orphaned */
|
||||
orphan = 1, pushStack(orphan_NoVnode);
|
||||
if (!orphan) {
|
||||
name = getFileName(dir, vnode->uniquifier);
|
||||
if (name == 0)
|
||||
orphan = 1, pushStack(orphan_NoUnique);
|
||||
}
|
||||
if (!orphan) {
|
||||
/* push the file name on stack */
|
||||
pushStack(name);
|
||||
pNode = vnode->parent;
|
||||
nNode = dir->vnodeParent;
|
||||
}
|
||||
while (!orphan && (pNode != nNode)) {
|
||||
if ((dir = lookup(nNode)) == 0) {
|
||||
orphan = 1, pushStack(orphan_NoVnode);
|
||||
break;
|
||||
}
|
||||
if ((name = getDirName(dir, pNode)) == 0) {
|
||||
orphan = 1, pushStack(orphan_NoVnode);
|
||||
break;
|
||||
}
|
||||
pushStack(name);
|
||||
pNode = nNode;
|
||||
nNode = dir->vnodeParent;
|
||||
}
|
||||
fullPathName = printStack(); /* full name of file or symLink */
|
||||
if (vnode->type == vSymlink) { /* check if mount point */
|
||||
/* read contents of link */
|
||||
struct stat statLink;
|
||||
int fdLink;
|
||||
char *symLink;
|
||||
if ((fdLink = iopen(dev, vnode->inodeNumber, O_RDONLY)) < 0) {
|
||||
printf("Error in opening symbolic link : %d\n", errno);
|
||||
exit(10);
|
||||
}
|
||||
if (fstat(fdLink, &statLink) < 0) {
|
||||
printf("Error in symLink stat(fd=%d): %d\n", fdLink,
|
||||
errno);
|
||||
exit(12);
|
||||
}
|
||||
assert(symLink = malloc(statLink.st_size + 1));
|
||||
if (read(fdLink, symLink, statLink.st_size) < 0) {
|
||||
printf("Error in reading symbolic link : %d\n", errno);
|
||||
exit(11);
|
||||
}
|
||||
symLink[statLink.st_size] = 0; /* null termination */
|
||||
if (symLink[0] == '#') /* this is a mount point */
|
||||
printf("Volume %s mounted on %s%s\n", symLink,
|
||||
partitionName, fullPathName);
|
||||
free(symLink);
|
||||
close(fdLink);
|
||||
}
|
||||
if (option & allFiles) {
|
||||
if (option & lFlag) {
|
||||
switch (vnode->type) {
|
||||
case vFile:
|
||||
printf("F ");
|
||||
break;
|
||||
case vDirectory:
|
||||
printf("D ");
|
||||
break;
|
||||
case vSymlink:
|
||||
printf("S ");
|
||||
break;
|
||||
default:
|
||||
printf("U ");
|
||||
break;
|
||||
}
|
||||
printf("Ind:%d ", vnode->inodeNumber);
|
||||
printf("Mod:%x ", vnode->modeBits);
|
||||
printf("Lnk:%d ", vnode->linkCount);
|
||||
printf("Own:%d ", vnode->owner);
|
||||
printf("Grp:%d ", vnode->group);
|
||||
printf("Siz:%d ", vnode->length);
|
||||
}
|
||||
printf("~%s\n", fullPathName);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
/* Lists all directories in the volume */
|
||||
printDirs(partitionName)
|
||||
char *partitionName;
|
||||
{
|
||||
int i, j, vnode, inode;
|
||||
DirEnt *ptr, *dir, *tmpDir;
|
||||
|
||||
/* The root level vnode for this volume */
|
||||
tmpDir = lookup(1); /* root vnode is 1 */
|
||||
if (tmpDir == 0)
|
||||
printf("Root vnode(1) does not exists :%s\n", partitionName);
|
||||
else
|
||||
printf("D Ind:%d Vnd:1 ~\n", tmpDir->inode);
|
||||
|
||||
for (i = 0; i < MAX_HASH_SIZE; i++)
|
||||
for (ptr = (DirEnt *) hash[i]; ptr; ptr = ptr->next)
|
||||
for (j = 0; j < ptr->numEntries; j++) {
|
||||
int nVnode, pVnode;
|
||||
char *fullPathName, *name;
|
||||
|
||||
pVnode = ptr->vnodeParent; /* parent vnode */
|
||||
nVnode = ptr->vnode; /* this dir vnode */
|
||||
vnode = ptr->vnodeName[j].vnode; /* my Vnode */
|
||||
|
||||
/* directory vnode numbers are odd */
|
||||
if ((vnode % 2) == 0)
|
||||
continue;
|
||||
|
||||
tmpDir = lookup(vnode);
|
||||
if (!tmpDir) { /* orphaned directory */
|
||||
printf("%s : vnode:%d \n", orphan_NoVnode, vnode);
|
||||
continue;
|
||||
}
|
||||
inode = tmpDir->inode; /* the inode for this vnode */
|
||||
|
||||
pushStack(ptr->vnodeName[j].name);
|
||||
|
||||
while (pVnode != 1) {
|
||||
dir = lookup(pVnode);
|
||||
if (dir == 0) { /* orphan */
|
||||
pushStack(orphan_NoVnode);
|
||||
break;
|
||||
}
|
||||
name = getDirName(dir, nVnode);
|
||||
if (name == 0) {
|
||||
pushStack(orphan_NoVnode);
|
||||
break;
|
||||
}
|
||||
pushStack(name);
|
||||
nVnode = pVnode;
|
||||
pVnode = dir->vnodeParent;
|
||||
}
|
||||
fullPathName = printStack(); /* full path name of directory */
|
||||
printf("D Ind:%d Vnd:%d ~%s\n", inode, vnode, fullPathName);
|
||||
}
|
||||
}
|
||||
|
||||
/* figure out how many pages in use in a directory, given ptr to its (locked) he
|
||||
ader */
|
||||
static
|
||||
ComputeUsedPages(dhp)
|
||||
struct DirHeader *dhp;
|
||||
{
|
||||
afs_int32 usedPages, i;
|
||||
|
||||
if (dhp->header.pgcount != 0) {
|
||||
/* new style */
|
||||
usedPages = ntohs(dhp->header.pgcount);
|
||||
} else {
|
||||
/* old style */
|
||||
usedPages = 0;
|
||||
for (i = 0; i < MAXPAGES; i++) {
|
||||
if (dhp->alloMap[i] == EPP) {
|
||||
usedPages = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (usedPages == 0)
|
||||
usedPages = MAXPAGES;
|
||||
}
|
||||
return usedPages;
|
||||
}
|
||||
|
||||
printContentsOfDirInode(device, dirInode, fullName, options)
|
||||
dev_t device;
|
||||
Inode dirInode;
|
||||
char *fullName;
|
||||
char options;
|
||||
{
|
||||
int fd, i, j, usedPages, pages;
|
||||
FILE *file;
|
||||
struct stat statBuf;
|
||||
char dirPage[2048];
|
||||
struct DirHeader *dhp = (struct DirHeader *)&dirPage[0];
|
||||
struct DirEntry *de;
|
||||
struct PageHeader *pg;
|
||||
|
||||
fd = iopen(device, dirInode, O_RDONLY);
|
||||
if (fd <= 0) {
|
||||
printf("Cannot open direcory inode %d\n", dirInode);
|
||||
return -1;
|
||||
}
|
||||
if ((file = fdopen(fd, "r")) == 0) { /* for buffered read */
|
||||
printf("fdopen failed : %d\n", errno);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
if (fstat(fd, &statBuf) < 0) {
|
||||
printf("Error in stat(fd=%d): %d\n", fd, errno);
|
||||
return -1;
|
||||
}
|
||||
/* read first page */
|
||||
if (fread(&dirPage, sizeof(dirPage), 1, file) != 1) {
|
||||
printf("Cannot read dir header from inode %d(errno %d)\n", dirInode,
|
||||
errno);
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
usedPages = ComputeUsedPages(dhp);
|
||||
|
||||
printf("Alloc map: ");
|
||||
for (i = 0; i < MAXPAGES; i++) {
|
||||
if ((i % 16) == 0)
|
||||
printf("\n");
|
||||
printf("%.2x ", (unsigned char)dhp->alloMap[i]);
|
||||
}
|
||||
printf("\nHash table:");
|
||||
for (i = 0; i < NHASHENT; i++) {
|
||||
if ((i % 16) == 0)
|
||||
printf("\n");
|
||||
printf("%.2d ", dhp->hashTable[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/* print header of first page */
|
||||
printf("--------------- Page 0 ---------------\n");
|
||||
printf("pgcnt :%d\n", usedPages);
|
||||
printf("tag :%d\n", dhp->header.tag);
|
||||
printf("freecnt :%d(not used)\n", dhp->header.freecount);
|
||||
printf("freebitmap :");
|
||||
for (i = 0; i < EPP / 8; i++)
|
||||
printf("%.2x ", (unsigned char)(dhp->header.freebitmap[i]));
|
||||
printf("\n");
|
||||
|
||||
/* print slots in the first page of this directory */
|
||||
de = ((struct DirPage0 *)dirPage)->entry;
|
||||
for (i = DHE + 1; i < EPP; i++, de = (struct DirEntry *)((char *)de + 32))
|
||||
printf("ent %d: f=%d l=%d n=%d vn=%d vu=%d name:%s\n", i, de->flag,
|
||||
de->length, de->next, de->fid.vnode, de->fid.vunique,
|
||||
de->name);
|
||||
|
||||
/* read all succeeding pages of this directory */
|
||||
for (pages = 1; pages < usedPages; pages++) {
|
||||
if (fread(&dirPage, sizeof(dirPage), 1, file) != 1) {
|
||||
printf("Cannot read %s page from inode %d(errno %d)\n", pages,
|
||||
dirInode, errno);
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
pg = &((struct DirPage1 *)dirPage)->header; /* page header */
|
||||
de = ((struct DirPage1 *)dirPage)->entry;
|
||||
|
||||
/* print page header info */
|
||||
printf("--------------- Page %d ---------------\n", pages);
|
||||
printf("pgcnt :%d\n", pg->pgcount);
|
||||
printf("tag :%d\n", pg->tag);
|
||||
printf("freecnt :%d(not used)\n", pg->freecount);
|
||||
printf("freebitmap :");
|
||||
for (i = 0; i < EPP / 8; i++)
|
||||
printf("%.2x ", (unsigned char)(pg->freebitmap[i]));
|
||||
printf("\n");
|
||||
|
||||
/* print slots in this page */
|
||||
for (i = 1; i < EPP; i++, de = (struct DirEntry *)((char *)de + 32))
|
||||
printf("ent %d: f=%d l=%d n=%d vn=%d vu=%d name:%s\n", i,
|
||||
de->flag, de->length, de->next, de->fid.vnode,
|
||||
de->fid.vunique, de->name);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
#define MAX_HASH_SIZE 100
|
||||
#define MAX_STACK_SIZE 1000
|
||||
|
||||
typedef struct vnodeName {
|
||||
int vnode;
|
||||
int vunique; /* uniquefier */
|
||||
char *name; /* name for this vnode */
|
||||
} VnodeName;
|
||||
|
||||
typedef struct dirEnt {
|
||||
int vnode; /* this directory's vnode */
|
||||
int inode; /* this directory's inode */
|
||||
int vnodeParent; /* parent directory's vnode */
|
||||
int numEntries; /* number of enrtries in this directory */
|
||||
VnodeName *vnodeName; /* the entries themselves */
|
||||
struct dirEntry *next; /* used by hash table */
|
||||
} DirEnt;
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/* ltlist - a standalone program to dump the link count table. */
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef AFS_NT40_ENV
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned short row;
|
||||
int i;
|
||||
int count;
|
||||
int stamp[2];
|
||||
|
||||
if (ac != 2) {
|
||||
printf("Usage ltlist <filename>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fp = fopen(av[1], "r");
|
||||
if (!fp) {
|
||||
printf("Can't open %s for reading.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Print the magic and version numbers in hex. */
|
||||
count = fread((void *)stamp, 1, 8, fp);
|
||||
if (count != 8) {
|
||||
if (feof(fp)) {
|
||||
printf("Only read %d bytes of %s, wanted 8 for stamp.\n", count,
|
||||
av[1]);
|
||||
} else {
|
||||
#ifdef AFS_NT40_ENV
|
||||
printf("NT Error %d reading 8 bytes from %s\n", GetLastError(),
|
||||
av[1]);
|
||||
#else
|
||||
perror("fread");
|
||||
#endif
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("magic=0x%x, version=0x%x\n", stamp[0], stamp[1]);
|
||||
|
||||
printf("%10s %2s %2s %2s %2s %2s\n", "Vnode", "F1", "F2", "F3", "F4",
|
||||
"F5");
|
||||
i = 0;
|
||||
while (fread((void *)&row, 1, 2, fp)) {
|
||||
printf("%10d %2d %2d %2d %2d %2d\n", i, (int)(row & 0x7),
|
||||
(int)((row >> 3) & 0x7), (int)((row >> 6) & 0x7),
|
||||
(int)((row >> 9) & 0x7), (int)((row >> 12) & 0x7));
|
||||
i++;
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/* nicreate
|
||||
* Test "inode" creation in the user space file system.
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#ifdef AFS_NAMEI_ENV
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <lock.h>
|
||||
#include <afs/afsutil.h>
|
||||
#include "nfs.h"
|
||||
#include <afs/afsint.h>
|
||||
#include "ihandle.h"
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "viceinode.h"
|
||||
#include "voldefs.h"
|
||||
#include "partition.h"
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
char *prog = "nicreate";
|
||||
IHandle_t *GetLinkHandle(char *part, int volid);
|
||||
|
||||
void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage: %s partition RWvolid p1 p2 p3 p4\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
char *part;
|
||||
int volid;
|
||||
int p1, p2, p3, p4;
|
||||
IHandle_t lh, *lhp;
|
||||
Inode ino;
|
||||
|
||||
if (ac != 7)
|
||||
Usage();
|
||||
|
||||
part = av[1];
|
||||
volid = atoi(av[2]);
|
||||
p1 = atoi(av[3]);
|
||||
p2 = atoi(av[4]);
|
||||
p3 = atoi(av[5]);
|
||||
p4 = atoi(av[6]);
|
||||
|
||||
if (p2 == -1 && p3 == VI_LINKTABLE)
|
||||
lhp = NULL;
|
||||
else {
|
||||
lhp = GetLinkHandle(part, volid);
|
||||
if (!lhp) {
|
||||
perror("Getting link handle.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
ino = namei_icreate(lhp, part, p1, p2, p3, p4);
|
||||
if (!VALID_INO(ino)) {
|
||||
perror("namei_icreate");
|
||||
} else {
|
||||
printf("Returned inode %s\n", PrintInode(NULL, ino));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AFS_NAMEI_ENV */
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/* nilist.c - List the "inode" information for one or all volumes on
|
||||
* a partition.
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef AFS_NT40_ENV
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
#include "nfs.h"
|
||||
#include <afs/afsint.h>
|
||||
#include "ihandle.h"
|
||||
#include <lock.h>
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "viceinode.h"
|
||||
|
||||
#ifndef AFS_NAMEI_ENV
|
||||
main()
|
||||
{
|
||||
printf("nilist is only useful for namei AFS file server"
|
||||
" implementations.\n");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
|
||||
void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage: nilist partition [volume]\n");
|
||||
printf
|
||||
("List all \"inodes\" for the volume group containing the volume\n");
|
||||
printf("or for the entire partition.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* This judge function can be a dummy since I know how nt_ListAFSFiles works */
|
||||
int
|
||||
Judge(struct ViceInodeInfo *info, int vid)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
PrintInodeInfo(FILE * fp, struct ViceInodeInfo *info, char *dir, char *name)
|
||||
{
|
||||
static int lastVID = -1;
|
||||
int rwVID;
|
||||
char dname[1024];
|
||||
|
||||
rwVID =
|
||||
info->u.param[1] ==
|
||||
-1 ? info->u.special.parentId : info->u.vnode.volumeId;
|
||||
|
||||
if (rwVID != lastVID) {
|
||||
if (lastVID != -1)
|
||||
printf("\n");
|
||||
lastVID = rwVID;
|
||||
/* This munging of the name remove a "\R". */
|
||||
(void)strcpy(dname, dir);
|
||||
dname[strlen(dname) - 2] = '\0';
|
||||
printf("Parent Volume %d, Directory %s\n", rwVID, dname);
|
||||
printf("%19s %8s %5s %10s %10s %10s %10s %s\n", "Inode", "Size",
|
||||
"Nlink", "P1", "P2", "P3", "P4", "Name");
|
||||
}
|
||||
#ifdef AFS_NT40_ENV
|
||||
printf("%19I64d %8d %5d %10d %10d %10d %10d %s\n", info->inodeNumber,
|
||||
info->byteCount, info->linkCount, info->u.param[0],
|
||||
info->u.param[1], info->u.param[2], info->u.param[3], name);
|
||||
#else
|
||||
printf("%19lld %8d %5d %10d %10d %10d %10d %s\n", info->inodeNumber,
|
||||
info->byteCount, info->linkCount, info->u.param[0],
|
||||
info->u.param[1], info->u.param[2], info->u.param[3], name);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int singleVolumeNumber = 0;
|
||||
char *part;
|
||||
int ninodes;
|
||||
|
||||
if (ac < 2 || ac > 3)
|
||||
Usage();
|
||||
|
||||
part = av[1];
|
||||
if (ac == 3)
|
||||
singleVolumeNumber = atoi(av[2]);
|
||||
|
||||
#ifdef AFS_NT40_ENV
|
||||
ninodes =
|
||||
nt_ListAFSFiles(part, PrintInodeInfo, stdout, Judge,
|
||||
singleVolumeNumber);
|
||||
#else
|
||||
ninodes =
|
||||
namei_ListAFSFiles(part, PrintInodeInfo, stdout, Judge,
|
||||
singleVolumeNumber);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* AFS_NAMEI_ENV */
|
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/* nicreate
|
||||
* Test "inode" creation in the user space file system.
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#ifdef AFS_NAMEI_ENV
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <lock.h>
|
||||
#include <afs/afsutil.h>
|
||||
#include "nfs.h"
|
||||
#include <afs/afsint.h>
|
||||
#include "ihandle.h"
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "viceinode.h"
|
||||
#include "voldefs.h"
|
||||
#include "partition.h"
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
char *prog = "nincdec";
|
||||
IHandle_t *GetLinkHandle(char *part, int volid);
|
||||
|
||||
|
||||
void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage: %s <part> <volid> <-i ino | -v vno uniq tag> <inc|dec>\n",
|
||||
prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
char *part;
|
||||
int volid;
|
||||
Inode ino;
|
||||
Inode vno;
|
||||
Inode tag;
|
||||
Inode uniq;
|
||||
int code;
|
||||
IHandle_t *lh;
|
||||
int do_inc = -1;
|
||||
char *incdecarg;
|
||||
int i;
|
||||
|
||||
|
||||
if (ac < 5)
|
||||
Usage();
|
||||
|
||||
part = av[1];
|
||||
volid = atoi(av[2]);
|
||||
|
||||
i = 4;
|
||||
if (!strcmp(av[3], "-i")) {
|
||||
code = sscanf(av[i++], "%Lu", &ino);
|
||||
if (code != 1) {
|
||||
printf("Failed to get inode from %s\n", av[4]);
|
||||
exit(1);
|
||||
}
|
||||
} else if (!strcmp(av[3], "-v")) {
|
||||
vno = (int64_t) atoi(av[i++]);
|
||||
vno &= 0x3ffffff;
|
||||
tag = (int64_t) atoi(av[i++]);
|
||||
uniq = (int64_t) atoi(av[i++]);
|
||||
ino = uniq;
|
||||
ino |= tag << 32;
|
||||
ino |= vno << 35;
|
||||
printf("ino=%Lu\n", ino);
|
||||
} else {
|
||||
printf("Expected \"-i\" or \"-v\" for inode value\n");
|
||||
Usage();
|
||||
}
|
||||
|
||||
incdecarg = av[i++];
|
||||
if (!strcmp(incdecarg, "dec"))
|
||||
do_inc = 0;
|
||||
else if (!strcmp(incdecarg, "inc"))
|
||||
do_inc = 1;
|
||||
else {
|
||||
printf("%s: Expected \"inc\" or \"dec\"\n", incdecarg);
|
||||
Usage();
|
||||
}
|
||||
|
||||
|
||||
lh = GetLinkHandle(part, volid);
|
||||
if (!lh) {
|
||||
printf("Failed to get link handle, exiting\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (do_inc)
|
||||
code = namei_inc(lh, ino, volid);
|
||||
else
|
||||
code = namei_dec(lh, ino, volid);
|
||||
|
||||
printf("namei_%s returned %d\n", do_inc ? "inc" : "dec", code);
|
||||
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
#endif /* AFS_NAMEI_ENV */
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* translate between inode numbers and contents.
|
||||
*/
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "util/afsutil.h"
|
||||
|
||||
void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage: nino <-i ino> | <-c uniq tag vno> | <-a ino_base64>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void do_contents(int ac, char **av);
|
||||
void do_ino(int ac, char **av);
|
||||
void do_inobase64(int ac, char **av);
|
||||
|
||||
|
||||
main(int ac, char **av)
|
||||
{
|
||||
if (ac < 3)
|
||||
Usage();
|
||||
|
||||
if (!strcmp("-c", av[1]))
|
||||
do_contents(ac, av);
|
||||
else if (!strcmp("-i", av[1]))
|
||||
do_ino(ac, av);
|
||||
else if (!strcmp("-a", av[1]))
|
||||
do_inobase64(ac, av);
|
||||
else
|
||||
Usage();
|
||||
}
|
||||
|
||||
void
|
||||
do_contents(int ac, char **av)
|
||||
{
|
||||
int64_t ino;
|
||||
int64_t vno, tag, uniq;
|
||||
int count;
|
||||
lb64_string_t str;
|
||||
|
||||
if (ac != 5) {
|
||||
printf("Bad argument count for -c option.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vno = (int64_t) atoi(av[4]);
|
||||
vno &= 0x3ffffff;
|
||||
tag = (int64_t) atoi(av[3]);
|
||||
tag &= 0x7;
|
||||
uniq = (int64_t) atoi(av[2]);
|
||||
|
||||
ino = vno;
|
||||
ino |= tag << 26;
|
||||
ino |= uniq << 32;
|
||||
int64_to_flipbase64(str, ino);
|
||||
|
||||
printf("ino=%Lu, base64=%s\n", ino, str);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
do_ino(int ac, char **av)
|
||||
{
|
||||
int64_t ino1 = 0;
|
||||
int64_t ino = 0;
|
||||
int64_t ino2 = 0;
|
||||
int vno;
|
||||
lb64_string_t str;
|
||||
|
||||
if (ac != 3) {
|
||||
printf("Bad argument count for -i option.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ino = (int64_t) - 1;
|
||||
sscanf(av[2], "%qu", &ino);
|
||||
printf("%Lu %Lu %Lu\n", ino, ino1, ino2);
|
||||
|
||||
vno = (int)ino;
|
||||
if (vno == 0x3ffffff)
|
||||
vno = -1;
|
||||
int64_to_flipbase64(str, ino);
|
||||
printf("ino=%Lu, vno=%d, tag=%u, uniq=%u, base64=%s\n", ino, vno,
|
||||
(int)((ino >> 26) & 0x7), (int)((ino >> 32) & 0xffffffff), str);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
do_inobase64(int ac, char **av)
|
||||
{
|
||||
int64_t ino1 = 0;
|
||||
int64_t ino = 0;
|
||||
int64_t ino2 = 0;
|
||||
int vno;
|
||||
|
||||
|
||||
if (ac != 3) {
|
||||
printf("Bad argument count for -a option.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ino = flipbase64_to_int64(av[2]);
|
||||
|
||||
vno = (int)ino;
|
||||
if (vno == 0x3ffffff)
|
||||
vno = -1;
|
||||
printf("ino=%Lu, vno=%d, tag=%u, uniq=%u\n", ino, vno,
|
||||
(int)((ino >> 26) & 0x7), (int)((ino >> 32) & 0xffffffff));
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#ifdef AFS_NAMEI_ENV
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <lock.h>
|
||||
#include <afs/afsutil.h>
|
||||
#include "nfs.h"
|
||||
#include <afs/afsint.h>
|
||||
#include "ihandle.h"
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "viceinode.h"
|
||||
#include "voldefs.h"
|
||||
#include "partition.h"
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
|
||||
IHandle_t *
|
||||
GetLinkHandle(char *part, int volid)
|
||||
{
|
||||
int dev;
|
||||
Inode ino;
|
||||
IHandle_t *lh;
|
||||
|
||||
dev = volutil_GetPartitionID(part);
|
||||
ino = namei_MakeSpecIno(volid, VI_LINKTABLE);
|
||||
|
||||
IH_INIT(lh, dev, volid, ino);
|
||||
return lh;
|
||||
}
|
||||
|
||||
void
|
||||
DFlushVolume(void)
|
||||
{
|
||||
};
|
||||
|
||||
#endif /* AFS_NAMEI_ENV */
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
Log(a, b, c, d, e, f, g, h, i, j, k)
|
||||
{
|
||||
printf(a, b, c, d, e, f, g, h, i, j, k);
|
||||
}
|
||||
|
||||
iopen()
|
||||
{
|
||||
}
|
||||
|
||||
AssertionFailed()
|
||||
{
|
||||
printf("assertion failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Abort()
|
||||
{
|
||||
printf("Aborting\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
VolumePackageOptions opts;
|
||||
|
||||
VOptDefaults(1, &opts);
|
||||
if (VInitVolumePackage2(1, &opts)) {
|
||||
printf("errors encountered initializing volume package\n");
|
||||
exit(-1);
|
||||
}
|
||||
VPrintDiskStats();
|
||||
|
||||
}
|
@ -1,430 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
/*
|
||||
** Lists all files in a /vicepX partition. This started as an
|
||||
** exercise to know the layout of AFS data in a fileserver
|
||||
** partition. Later on, it proved useful in debugging problems
|
||||
** at customer sites too.
|
||||
**
|
||||
*/
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <rx/xdr.h>
|
||||
#include <afs/afsint.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/param.h>
|
||||
#if !defined(AFS_SGI_ENV)
|
||||
#ifdef AFS_VFSINCL_ENV
|
||||
#define VFS
|
||||
#ifdef AFS_SUN5_ENV
|
||||
#include <sys/fs/ufs_fs.h>
|
||||
#else
|
||||
#include <ufs/fs.h>
|
||||
#endif
|
||||
#else /* AFS_VFSINCL_ENV */
|
||||
#ifndef AFS_AIX_ENV
|
||||
#include <sys/fs.h>
|
||||
#endif
|
||||
#endif /* AFS_VFSINCL_ENV */
|
||||
#endif /* AFS_SGI_ENV */
|
||||
#include <sys/errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/file.h>
|
||||
#if defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_BSD_ENV))
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif
|
||||
#ifdef AFS_AIX_ENV
|
||||
#include <sys/vfs.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#ifdef AFS_HPUX_ENV
|
||||
#include <fcntl.h>
|
||||
#include <mntent.h>
|
||||
#else
|
||||
#if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
|
||||
#ifdef AFS_SUN5_ENV
|
||||
#include <sys/mnttab.h>
|
||||
#include <sys/mntent.h>
|
||||
#else
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
#else
|
||||
#if defined(AFS_SGI_ENV)
|
||||
#include <fcntl.h>
|
||||
#include <mntent.h>
|
||||
|
||||
/*
|
||||
#include <sys/fs/efs.h>
|
||||
*/
|
||||
#include "efs.h" /* until 5.1 release */
|
||||
|
||||
#define ROOTINO EFS_ROOTINO
|
||||
#else
|
||||
#include <fstab.h>
|
||||
#endif
|
||||
#endif /* AFS_SGI_ENV */
|
||||
#endif /* AFS_HPUX_ENV */
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/wait.h>
|
||||
#include <setjmp.h>
|
||||
#ifndef ITIMER_REAL
|
||||
#include <sys/time.h>
|
||||
#endif /* ITIMER_REAL */
|
||||
|
||||
#include "nfs.h"
|
||||
#include <afs/errors.h>
|
||||
#include "lock.h"
|
||||
#include "lwp.h"
|
||||
#include "vnode.h"
|
||||
#include "volume.h"
|
||||
#include "vldb.h"
|
||||
#include "partition.h"
|
||||
#include "afs/opr_assert.h"
|
||||
#include "filesignal.h"
|
||||
#include "vutils.h"
|
||||
#include "daemon_com.h"
|
||||
#include "fssync.h"
|
||||
#include <afs/auxinode.h>
|
||||
#include <afs/dir.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "salvage.h"
|
||||
int volumeId;
|
||||
int VolumeChanged; /* to satisfy library libdir use */
|
||||
|
||||
#include "listVicepx.h"
|
||||
char *orphan_NoVnode = "ORPHANED_NoVnode";
|
||||
char *orphan_NoUnique = "ORPHANED_NoUnique";
|
||||
#define READBUFSIZE 5*1024
|
||||
|
||||
|
||||
#define allNull 0x00
|
||||
#define verbose 0x01
|
||||
#define update 0x02 /* update specified dir inode */
|
||||
|
||||
int
|
||||
Usage(name)
|
||||
char *name;
|
||||
{
|
||||
assert(name);
|
||||
printf
|
||||
("Usage is %s -p <partition name> -v <volume name> -dirInode <directory inode> -f <directoryFileName> -verbose\n",
|
||||
name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char fullName[32 + VNAMESIZE + sizeof(VHDREXT) + 4];
|
||||
char partition[32], volume[VNAMESIZE];
|
||||
struct stat statBuf;
|
||||
struct VolumeHeader volumeHeader;
|
||||
int fd, i, sawPart = 0, sawVolume = 0, sawDirContents = 0, sawDirFile = 0;
|
||||
char option = allNull; /* no default options */
|
||||
Inode dirInode; /* destination dir Inode */
|
||||
char *fileName; /* source directory file */
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-p")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
assert(strlen(argv[i + 1]) < 32);
|
||||
strcpy(partition, argv[++i]);
|
||||
sawPart = 1;
|
||||
} else if (!strcmp(argv[i], "-v")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
assert(strlen(argv[i + 1]) < VNAMESIZE);
|
||||
strcpy(volume, argv[++i]);
|
||||
sawVolume = 1;
|
||||
} else if (!strcmp(argv[i], "-dirInode")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
dirInode = atoi(argv[++i]);
|
||||
sawDirContents = 1;
|
||||
option |= update;
|
||||
} else if (!strcmp(argv[i], "-f")) {
|
||||
if ((i + 1) >= argc)
|
||||
Usage(argv[0]);
|
||||
fileName = argv[++i];
|
||||
sawDirFile = 1;
|
||||
} else if (!strcmp(argv[i], "-verbose"))
|
||||
option |= verbose;
|
||||
else
|
||||
Usage(argv[0]);
|
||||
}
|
||||
|
||||
/* option to verify whether input file is syntactically good */
|
||||
if (sawDirFile && !sawPart && !sawVolume && !sawDirContents) {
|
||||
scanDirFile(0, 0, fileName, option);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* check input parameters */
|
||||
if (!sawPart || !sawVolume || !sawDirFile || !sawDirContents)
|
||||
Usage(argv[0]);
|
||||
|
||||
/* extract volume id */
|
||||
volumeId = atoi(volume);
|
||||
|
||||
/* construct unix file name */
|
||||
strcpy(fullName, partition);
|
||||
strcat(fullName, "/V");
|
||||
strcat(fullName, volume);
|
||||
strcat(fullName, VHDREXT);
|
||||
|
||||
/* check to see that volume exists */
|
||||
if (stat(fullName, &statBuf) < 0) {
|
||||
printf("Error in stat(%s) : %d\n", fullName, errno);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* read volume header */
|
||||
if ((fd = open(fullName, O_RDONLY)) < 0) {
|
||||
printf("Error in open(%s) : %d\n", fullName, errno);
|
||||
exit(3);
|
||||
}
|
||||
if (read(fd, &volumeHeader, sizeof(struct VolumeHeader)) <
|
||||
sizeof(struct VolumeHeader)) {
|
||||
printf("Error in reading Volume Header : %d\n", errno);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
scanDirFile(statBuf.st_dev, dirInode, fileName, option);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int
|
||||
scanDirFile(dev, node, fileName, option)
|
||||
dev_t dev;
|
||||
Inode node; /* destination directory inode number */
|
||||
char *fileName; /* source file to update from */
|
||||
char option; /* user options */
|
||||
{
|
||||
int fd, i, j, temp;
|
||||
FILE *fp;
|
||||
char dirPage[2048];
|
||||
char buf[READBUFSIZE]; /* read buffer */
|
||||
struct DirHeader *dhp = (struct DirHeader *)&dirPage[0];
|
||||
struct stat statBuf;
|
||||
int pgCount = 0; /* current page */
|
||||
|
||||
/* open this directory source file */
|
||||
if ((fp = fopen(fileName, "r")) == 0) {
|
||||
printf("fopen of %s failed : %d\n", fileName, errno);
|
||||
exit(6);
|
||||
}
|
||||
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore "Alloc map:" */
|
||||
for (i = 0; i < MAXPAGES; i++) { /* read alloMap */
|
||||
fscanf(fp, "%x", &temp);
|
||||
dhp->alloMap[i] = (unsigned char)temp;
|
||||
}
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore trailing spaces */
|
||||
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore "Hash map:" */
|
||||
for (i = 0; i < NHASHENT; i++) {
|
||||
fscanf(fp, "%d", &temp);
|
||||
dhp->hashTable[i] = (unsigned short)temp;
|
||||
}
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore trailing spaces */
|
||||
|
||||
while (ReadPage(fp, dhp, pgCount)) { /* read from source file */
|
||||
if (option & verbose)
|
||||
PrintDir(dhp, pgCount);
|
||||
if (option & update) { /* update destnation dir inode */
|
||||
if (pgCount == 0) /* first page */
|
||||
if ((fd = iopen(dev, node, O_WRONLY)) < 0) {
|
||||
printf("Error in opening destination inode %d(err %d)\n",
|
||||
node, errno);
|
||||
exit(1);
|
||||
}
|
||||
if (write(fd, dirPage, sizeof(dirPage)) != sizeof(dirPage)) {
|
||||
printf("Error in writing %d th page into inode %d(err %d)\n",
|
||||
pgCount, node, errno);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
pgCount++;
|
||||
}
|
||||
fclose(fp);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* prints out a directory data */
|
||||
PrintDir(dhp, pgCount)
|
||||
struct DirHeader *dhp;
|
||||
int pgCount; /* current page Number */
|
||||
{
|
||||
int i;
|
||||
struct DirEntry *de;
|
||||
struct PageHeader *pg;
|
||||
|
||||
if (pgCount == 0) { /* first page */
|
||||
printf("Alloc map: ");
|
||||
for (i = 0; i < MAXPAGES; i++) { /* read alloMap */
|
||||
if ((i % 16) == 0)
|
||||
printf("\n");
|
||||
printf("%.2x ", dhp->alloMap[i]);
|
||||
}
|
||||
printf("\nHash table:");
|
||||
for (i = 0; i < NHASHENT; i++) {
|
||||
if ((i % 16) == 0)
|
||||
printf("\n");
|
||||
printf("%.2d ", dhp->hashTable[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/* print page header info */
|
||||
printf("--------------- Page 0 ---------------\n");
|
||||
printf("pgcnt :%d\n", dhp->header.pgcount);
|
||||
printf("tag :%d\n", dhp->header.tag);
|
||||
printf("freecnt :%d(not used)\n", dhp->header.freecount);
|
||||
printf("freebitmap :");
|
||||
for (i = 0; i < EPP / 8; i++)
|
||||
printf("%.2x ", (unsigned char)(dhp->header.freebitmap[i]));
|
||||
printf("\n");
|
||||
|
||||
/* print slots in the first page of this directory */
|
||||
de = ((struct DirPage0 *)dhp)->entry;
|
||||
for (i = DHE + 1; i < EPP;
|
||||
i++, de = (struct DirEntry *)((char *)de + 32))
|
||||
printf("ent %d: f=%d l=%d n=%d vn=%d vu=%d name:%s\n", i,
|
||||
de->flag, de->length, de->next, de->fid.vnode,
|
||||
de->fid.vunique, de->name);
|
||||
} else {
|
||||
pg = &((struct DirPage1 *)dhp)->header; /* page header */
|
||||
de = ((struct DirPage1 *)dhp)->entry;
|
||||
|
||||
/* print page header info */
|
||||
printf("--------------- Page %d ---------------\n", pgCount);
|
||||
printf("pgcnt :%d\n", pg->pgcount);
|
||||
printf("tag :%d\n", pg->tag);
|
||||
printf("freecnt :%d(not used)\n", pg->freecount);
|
||||
printf("freebitmap :");
|
||||
for (i = 0; i < EPP / 8; i++)
|
||||
printf("%.2x ", (unsigned char)(pg->freebitmap[i]));
|
||||
printf("\n");
|
||||
|
||||
/* print slots in this page */
|
||||
for (i = 1; i < EPP; i++, de = (struct DirEntry *)((char *)de + 32))
|
||||
printf("ent %d: f=%d l=%d n=%d vn=%d vu=%d name:%s\n", i,
|
||||
de->flag, de->length, de->next, de->fid.vnode,
|
||||
de->fid.vunique, de->name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Returns 0 if there are no more pages
|
||||
** Returns 1 if there are more pages to be read
|
||||
*/
|
||||
ReadPage(fp, dhp, pageNo) /* Read one page(pageNo) from file fp into dhp */
|
||||
FILE *fp;
|
||||
struct DirHeader *dhp;
|
||||
int pageNo;
|
||||
{
|
||||
int pgcnt, page, freecnt, freebit[EPP / 8];
|
||||
int tag;
|
||||
char buf[READBUFSIZE]; /* read buffer */
|
||||
int start;
|
||||
int i, ent, f, l, n, vnode, unique;
|
||||
char dirName[18];
|
||||
struct DirEntry *dirEntry;
|
||||
struct PageHeader *pageHeader;
|
||||
|
||||
if (fscanf(fp, "--------------- Page %d ---------------\n", &page) != 1) {
|
||||
return 0; /* no more pages */
|
||||
}
|
||||
/* defensive check */
|
||||
if (page != pageNo) {
|
||||
printf("Wrong page: pageNo %d does not match data in file %d\n",
|
||||
pageNo, page);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fscanf(fp, "pgcnt :%d", &pgcnt) != 1) {
|
||||
printf("Error in looking for pgcnt:<int> in page %d\n", pageNo);
|
||||
exit(1);
|
||||
}
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore trailing spaces */
|
||||
|
||||
if (fscanf(fp, "tag :%d", &tag) != 1) {
|
||||
printf("Error in looking for tag:<int> in page %d\n", pageNo);
|
||||
exit(1);
|
||||
}
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore trailing spaces */
|
||||
|
||||
if (fscanf(fp, "freecnt :%d", &freecnt) != 1) {
|
||||
printf("Error in looking for freecnt:<int> in page %d\n", pageNo);
|
||||
exit(1);
|
||||
}
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore trailing spaces */
|
||||
|
||||
if (fscanf
|
||||
(fp, "freebitmap :%x %x %x %x %x %x %x %x", &freebit[0], &freebit[1],
|
||||
&freebit[2], &freebit[3], &freebit[4], &freebit[5], &freebit[6],
|
||||
&freebit[7]) != 8) {
|
||||
printf("Error in looking for freecnt:<ints> in page %d\n", pageNo);
|
||||
exit(1);
|
||||
}
|
||||
fgets(buf, READBUFSIZE, fp); /* ignore trailing spaces */
|
||||
|
||||
if (pageNo == 0) { /* first page */
|
||||
start = DHE + 1; /* this is 13 */
|
||||
dirEntry = ((struct DirPage0 *)dhp)->entry;
|
||||
pageHeader = &(dhp->header);
|
||||
} else {
|
||||
start = 1;
|
||||
dirEntry = ((struct DirPage1 *)dhp)->entry;
|
||||
pageHeader = &(((struct DirPage1 *)dhp)->header);
|
||||
}
|
||||
|
||||
/* update page header */
|
||||
pageHeader->pgcount = pgcnt;
|
||||
pageHeader->tag = tag;
|
||||
pageHeader->freecount = freecnt; /* this is currently unused */
|
||||
for (i = 0; i < EPP / 8; i++)
|
||||
pageHeader->freebitmap[i] = freebit[i];
|
||||
|
||||
/* update directory entries */
|
||||
for (; start < EPP; start++) {
|
||||
if (fscanf
|
||||
(fp, "ent %d: f=%d l=%d n=%d vn=%d vu=%d name:%s\n", &ent, &f, &l,
|
||||
&n, &vnode, &unique, dirName) != 7) {
|
||||
printf("Error in reading the %d th entry in page %d\n", start,
|
||||
pageNo);
|
||||
exit(1);
|
||||
}
|
||||
if (ent != start) {
|
||||
printf("Wrong dir entry: found %d, has to be %\n", ent, start);
|
||||
exit(1);
|
||||
}
|
||||
dirEntry->flag = f;
|
||||
dirEntry->length = l;
|
||||
dirEntry->next = n;
|
||||
dirEntry->fid.vnode = vnode;
|
||||
dirEntry->fid.vunique = unique;
|
||||
memcpy(dirEntry->name, dirName, 18);
|
||||
strncpy(dirEntry->name, dirName);
|
||||
|
||||
dirEntry = (struct DirEntry *)((char *)dirEntry + 32);
|
||||
}
|
||||
return 1; /* there are more pages */
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000, International Business Machines Corporation and others.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software has been released under the terms of the IBM Public
|
||||
* License. For details, see the LICENSE file in the top-level source
|
||||
* directory or online at http://www.openafs.org/dl/license10.html
|
||||
*/
|
||||
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "listVicepx.h"
|
||||
|
||||
DirEnt *hash[MAX_HASH_SIZE];
|
||||
static char *stack[MAX_STACK_SIZE];
|
||||
static int stackSize;
|
||||
static char fileName[2048];
|
||||
|
||||
/* hashes a number in the range 1.. MAX_HASH_SIZE */
|
||||
mountHash(num)
|
||||
int num;
|
||||
{
|
||||
return (num % MAX_HASH_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/* insert entry in hash table */
|
||||
insertHash(dir)
|
||||
DirEnt *dir;
|
||||
{
|
||||
int h;
|
||||
h = mountHash(dir->vnode);
|
||||
|
||||
/* insert in hash table */
|
||||
dir->next = hash[h];
|
||||
hash[h] = dir;
|
||||
}
|
||||
|
||||
DirEnt *
|
||||
lookup(vnode)
|
||||
int vnode;
|
||||
{
|
||||
DirEnt *ptr;
|
||||
ptr = hash[mountHash(vnode)];
|
||||
while (ptr)
|
||||
if (ptr->vnode == vnode)
|
||||
return ptr;
|
||||
else
|
||||
ptr = ptr->next;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
getDirName(dir, node)
|
||||
DirEnt *dir;
|
||||
int node;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < dir->numEntries; i++)
|
||||
if (dir->vnodeName[i].vnode == node)
|
||||
return dir->vnodeName[i].name;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* this shud be called on a vnode for a file only */
|
||||
char *
|
||||
getFileName(dir, unique)
|
||||
DirEnt *dir;
|
||||
int unique;
|
||||
{
|
||||
/* go down the linked list */
|
||||
int i;
|
||||
for (i = 0; i < dir->numEntries; i++)
|
||||
if (dir->vnodeName[i].vunique == unique)
|
||||
return dir->vnodeName[i].name;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* for debugging */
|
||||
printHash()
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < MAX_HASH_SIZE; i++) {
|
||||
DirEnt *ptr = hash[i];
|
||||
while (ptr) {
|
||||
#ifdef DEBUG
|
||||
printf("Vnode: %d Parent Vnode : %d \n", ptr->vnode,
|
||||
ptr->vnodeParent);
|
||||
#endif
|
||||
for (j = 0; j < ptr->numEntries; j++)
|
||||
printf("\t %s %d %d\n", ptr->vnodeName[j].name,
|
||||
ptr->vnodeName[j].vnode, ptr->vnodeName[j].vunique);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pushStack(name)
|
||||
char *name;
|
||||
{
|
||||
assert(stackSize < MAX_STACK_SIZE);
|
||||
assert(stack[stackSize] = strdup(name));
|
||||
stackSize++;
|
||||
}
|
||||
|
||||
char *
|
||||
popStack()
|
||||
{
|
||||
if (stackSize == 0)
|
||||
return 0; /* stack empty */
|
||||
return stack[--stackSize];
|
||||
}
|
||||
|
||||
char *
|
||||
printStack()
|
||||
{
|
||||
char *name;
|
||||
fileName[0] = 0;
|
||||
while (name = popStack()) {
|
||||
strcat(fileName, "/");
|
||||
strcat(fileName, name);
|
||||
free(name);
|
||||
}
|
||||
return fileName;
|
||||
}
|
Loading…
Reference in New Issue
Block a user