1 | /* IBM_PROLOG_BEGIN_TAG */ |
---|
2 | /* This is an automatically generated prolog. */ |
---|
3 | /* */ |
---|
4 | /* */ |
---|
5 | /* */ |
---|
6 | /* Licensed Materials - Property of IBM */ |
---|
7 | /* */ |
---|
8 | /* (C) COPYRIGHT International Business Machines Corp. 2002,2006 */ |
---|
9 | /* All Rights Reserved */ |
---|
10 | /* */ |
---|
11 | /* US Government Users Restricted Rights - Use, duplication or */ |
---|
12 | /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ |
---|
13 | /* */ |
---|
14 | /* IBM_PROLOG_END_TAG */ |
---|
15 | |
---|
16 | /*==================================================================== |
---|
17 | * |
---|
18 | * tstimes command: list the ctime and mtime for all inodes |
---|
19 | * |
---|
20 | * Syntax: tstimes pathname |
---|
21 | * |
---|
22 | * The "pathname" parameter should be the directory where the root of |
---|
23 | * the filesystem is found. |
---|
24 | * |
---|
25 | *==================================================================*/ |
---|
26 | |
---|
27 | #include <stdlib.h> |
---|
28 | #include <stdio.h> |
---|
29 | #include <string.h> |
---|
30 | #include <errno.h> |
---|
31 | |
---|
32 | #include <gpfs.h> |
---|
33 | |
---|
34 | extern char *basename(char *); |
---|
35 | |
---|
36 | /* print usage message and exit */ |
---|
37 | void usage(char *argv0) |
---|
38 | { |
---|
39 | fprintf(stderr, "Usage: %s pathname\n", basename(argv0)); |
---|
40 | exit(1); |
---|
41 | } |
---|
42 | |
---|
43 | /* Scan all inodes in the file system */ |
---|
44 | int read_inodes(char *pathP) |
---|
45 | { |
---|
46 | int rc = 0; |
---|
47 | const gpfs_iattr_t *iattrP; |
---|
48 | gpfs_fssnap_handle_t *fsP = NULL; |
---|
49 | gpfs_iscan_t *iscanP = NULL; |
---|
50 | |
---|
51 | |
---|
52 | /* Open the file system */ |
---|
53 | fsP = gpfs_get_fssnaphandle_by_path(pathP); |
---|
54 | if (fsP == NULL) |
---|
55 | { |
---|
56 | rc = errno; |
---|
57 | fprintf(stderr, "gpfs_get_fssnaphandle_by_path(%s): %s\n", |
---|
58 | pathP, strerror(rc)); |
---|
59 | goto exit; |
---|
60 | } |
---|
61 | |
---|
62 | /* Open an inode scan on the file system */ |
---|
63 | iscanP = gpfs_open_inodescan(fsP, NULL, NULL); |
---|
64 | if (iscanP == NULL) |
---|
65 | { |
---|
66 | rc = errno; |
---|
67 | fprintf(stderr, "gpfs_open_inodescan(%s): %s\n", |
---|
68 | pathP, strerror(rc)); |
---|
69 | goto exit; |
---|
70 | } |
---|
71 | |
---|
72 | /* Loop over inodes */ |
---|
73 | while (1) |
---|
74 | { |
---|
75 | rc = gpfs_next_inode(iscanP, 0, &iattrP); |
---|
76 | if (rc != 0) |
---|
77 | { |
---|
78 | int saveerrno = errno; |
---|
79 | fprintf(stderr, "gpfs_next_inode(%s): rc %d %s\n", |
---|
80 | pathP, rc, strerror(saveerrno)); |
---|
81 | rc = saveerrno; |
---|
82 | goto exit; |
---|
83 | } |
---|
84 | if (iattrP == NULL) |
---|
85 | break; |
---|
86 | |
---|
87 | /* Print inode info on stdout . |
---|
88 | Only print the low 16 bits of the file's generation number, |
---|
89 | since the tsreaddir only has the low 16 bits. |
---|
90 | (leading 0s on inodenumber/generation allow join command |
---|
91 | to do character sort to merge output with tsreaddir.) */ |
---|
92 | printf("%010d/%010d\t%010u.%09d\t%010u.%09d\n", |
---|
93 | iattrP->ia_inode, (iattrP->ia_gen & 0x0000FFFF), |
---|
94 | iattrP->ia_mtime.tv_sec, iattrP->ia_mtime.tv_nsec, |
---|
95 | iattrP->ia_ctime.tv_sec, iattrP->ia_ctime.tv_nsec); |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | exit: |
---|
100 | if (iscanP) |
---|
101 | gpfs_close_inodescan(iscanP); |
---|
102 | if (fsP) |
---|
103 | gpfs_free_fssnaphandle(fsP); |
---|
104 | |
---|
105 | return rc; |
---|
106 | } |
---|
107 | |
---|
108 | /* main */ |
---|
109 | int main(int argc, char *argv[]) |
---|
110 | { |
---|
111 | int rc; |
---|
112 | |
---|
113 | /* if pathname was not specified, there is nothing to do */ |
---|
114 | if (argc != 2) |
---|
115 | usage(argv[0]); |
---|
116 | |
---|
117 | /* Read the inodes */ |
---|
118 | rc = read_inodes(argv[1]); |
---|
119 | return rc; |
---|
120 | } |
---|