/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* (C) COPYRIGHT International Business Machines Corp. 2002,2006 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /*==================================================================== * * tstimes command: list the ctime and mtime for all inodes * * Syntax: tstimes pathname * * The "pathname" parameter should be the directory where the root of * the filesystem is found. * *==================================================================*/ #include #include #include #include #include extern char *basename(char *); /* print usage message and exit */ void usage(char *argv0) { fprintf(stderr, "Usage: %s pathname\n", basename(argv0)); exit(1); } /* Scan all inodes in the file system */ int read_inodes(char *pathP) { int rc = 0; const gpfs_iattr_t *iattrP; gpfs_fssnap_handle_t *fsP = NULL; gpfs_iscan_t *iscanP = NULL; /* Open the file system */ fsP = gpfs_get_fssnaphandle_by_path(pathP); if (fsP == NULL) { rc = errno; fprintf(stderr, "gpfs_get_fssnaphandle_by_path(%s): %s\n", pathP, strerror(rc)); goto exit; } /* Open an inode scan on the file system */ iscanP = gpfs_open_inodescan(fsP, NULL, NULL); if (iscanP == NULL) { rc = errno; fprintf(stderr, "gpfs_open_inodescan(%s): %s\n", pathP, strerror(rc)); goto exit; } /* Loop over inodes */ while (1) { rc = gpfs_next_inode(iscanP, 0, &iattrP); if (rc != 0) { int saveerrno = errno; fprintf(stderr, "gpfs_next_inode(%s): rc %d %s\n", pathP, rc, strerror(saveerrno)); rc = saveerrno; goto exit; } if (iattrP == NULL) break; /* Print inode info on stdout . Only print the low 16 bits of the file's generation number, since the tsreaddir only has the low 16 bits. (leading 0s on inodenumber/generation allow join command to do character sort to merge output with tsreaddir.) */ printf("%010d/%010d\t%010u.%09d\t%010u.%09d\n", iattrP->ia_inode, (iattrP->ia_gen & 0x0000FFFF), iattrP->ia_mtime.tv_sec, iattrP->ia_mtime.tv_nsec, iattrP->ia_ctime.tv_sec, iattrP->ia_ctime.tv_nsec); } exit: if (iscanP) gpfs_close_inodescan(iscanP); if (fsP) gpfs_free_fssnaphandle(fsP); return rc; } /* main */ int main(int argc, char *argv[]) { int rc; /* if pathname was not specified, there is nothing to do */ if (argc != 2) usage(argv[0]); /* Read the inodes */ rc = read_inodes(argv[1]); return rc; }