Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / vol / test / ilist_nt.c
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10 /* ilist_nt.c - List the "inode" information for one or all volumes on
11 * a partition.
12 */
13
14 #include <afsconfig.h>
15 #include <afs/param.h>
16
17
18 #include <stdio.h>
19 #include <windows.h>
20 #include <winbase.h>
21 #include "nfs.h"
22 #include "ihandle.h"
23 #include <afs/afsint.h>
24 #include <lock.h>
25 #include "vnode.h"
26 #include "volume.h"
27 #include "viceinode.h"
28
29
30 void
31 Usage(void)
32 {
33 printf("Usage: ilist ilist partition [volume]\n");
34 printf
35 ("List all \"inodes\" for the volume group containing the volume\n");
36 printf("or for the entire partition.\n");
37 exit(1);
38 }
39
40 /* This judge function can be a dummy since I know how nt_ListAFSFiles works */
41 int
42 Judge(struct ViceInodeInfo *info, int vid)
43 {
44 return 1;
45 }
46
47 int
48 PrintInodeInfo(FILE * fp, struct ViceInodeInfo *info, char *dir, char *name)
49 {
50 static int lastVID = -1;
51 int rwVID;
52 char dname[1024];
53
54 rwVID =
55 info->u.param[1] ==
56 -1 ? info->u.special.parentId : info->u.vnode.volumeId;
57
58 if (rwVID != lastVID) {
59 if (lastVID != -1)
60 printf("\n");
61 lastVID = rwVID;
62 /* This munging of the name remove a "\R". */
63 (void)strcpy(dname, dir);
64 dname[strlen(dname) - 2] = '\0';
65 printf("Parent Volume %d, Directory %s\n", rwVID, dname);
66 printf("%14s %8s %5s %10s %10s %10s %10s %s\n", "Inode", "Size",
67 "Nlink", "P1", "P2", "P3", "P4", "Name");
68 }
69 printf("%14I64d %8d %5d %10d %10d %10d %10d %s\n", info->inodeNumber,
70 info->byteCount, info->linkCount, info->u.param[0],
71 info->u.param[1], info->u.param[2], info->u.param[3], name);
72 return 0;
73 }
74
75 main(int ac, char **av)
76 {
77 int singleVolumeNumber = 0;
78 char *part;
79 int ninodes;
80
81 if (ac < 2 || ac > 3)
82 Usage();
83
84 part = av[1];
85 if (ac == 3)
86 singleVolumeNumber = atoi(av[2]);
87
88 ninodes =
89 nt_ListAFSFiles(part, PrintInodeInfo, stdout, Judge,
90 singleVolumeNumber);
91 }