summaryrefslogtreecommitdiffstats
path: root/tools/getiversion
diff options
context:
space:
mode:
authorhjl <hjl>1999-10-18 23:21:12 +0000
committerhjl <hjl>1999-10-18 23:21:12 +0000
commit8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9 (patch)
tree0904ef8554ed680fe3244fa618685e1fb7ea148b /tools/getiversion
downloadnfs-utils-8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9.tar.gz
nfs-utils-8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9.tar.xz
nfs-utils-8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9.zip
Initial revision
Diffstat (limited to 'tools/getiversion')
-rw-r--r--tools/getiversion/Makefile11
-rw-r--r--tools/getiversion/getiversion.c37
2 files changed, 48 insertions, 0 deletions
diff --git a/tools/getiversion/Makefile b/tools/getiversion/Makefile
new file mode 100644
index 0000000..46c7150
--- /dev/null
+++ b/tools/getiversion/Makefile
@@ -0,0 +1,11 @@
+#
+# knfsd tools
+#
+
+TOOL = getiversion
+OBJS = getiversion.o
+
+include $(TOP)rules.mk
+
+install::
+ @:
diff --git a/tools/getiversion/getiversion.c b/tools/getiversion/getiversion.c
new file mode 100644
index 0000000..e9cb391
--- /dev/null
+++ b/tools/getiversion/getiversion.c
@@ -0,0 +1,37 @@
+/*
+ * getiversion
+ *
+ * Get version number for an inode on an ext2 file system.
+ */
+
+#include "config.h"
+
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/fs/ext2fs.h>
+
+int
+main(int argc, char **argv)
+{
+ int i, fd;
+ u_int32_t vers;
+
+ if (argc <= 1) {
+ fprintf(stderr, "usage: getiversion file ...\n");
+ return 1;
+ }
+
+ for (i = 1; i < argc; i++) {
+ if ((fd = open(argv[i], O_RDONLY)) < 0
+ || ioctl(fd, EXT2_IOC_GETVERSION, &vers) < 0) {
+ perror(argv[i]);
+ continue;
+ } else {
+ printf("%-20s %d\n", argv[i], vers);
+ }
+ close(fd);
+ }
+ return 0;
+}