2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <sys/types.h>
21 #include "AFS_component_version_number.c"
23 int main(int argc, char **argv)
29 #if defined(AFS_NT40_ENV) || defined(AFS_NAMEI_ENV)
30 fprintf(stderr, "gi not supported on NT or NAMEI systems.\n");
35 while (argc && **argv == '-') {
36 if (strcmp(*argv, "-stat") == 0)
44 if (error || argc!=2) {
45 fprintf(stderr, "Usage: gi [-stat] partition inodenumber\n");
48 if (stat(*argv, &status) != 0) {
49 fprintf(stderr, "gi: cannot stat %s [should be mounted partition name]\n", *argv);
53 inode = atoi(*++argv);
54 fd = iopen(dev, inode, 0);
56 Perror("Unable to open inode %d", inode);
60 if (fstat(fd, &status) != 0) {
61 Perror("Unable to fstat the inode!");
64 printf("Inode status: dev=%d, ino=%d, mode=%o, nlink=%d, uid=%d, gid=%d, size=%d, mtime=%d, blocks=%d\n", status.st_dev, status.st_ino, status.st_mode, status.st_nlink, status.st_uid, status.st_gid, status.st_size, status.st_mtime);
67 /* Send the inode to standard out */
68 char buf[4096]; int n;
69 while ((n = read(fd, buf, sizeof(buf))) >0)
73 #endif /* AFS_NT40_ENV || AFS_NAMEI_ENV */
76 void Perror(char *err, int a1, int a2, int a3)
79 sprintf(msg, err, a1, a2, a3);