summaryrefslogtreecommitdiffstats
path: root/extras/stripe-merge.c
diff options
context:
space:
mode:
authorVikas Gorur <vikas@zresearch.com>2009-02-18 17:36:07 +0530
committerVikas Gorur <vikas@zresearch.com>2009-02-18 17:36:07 +0530
commit77adf4cd648dce41f89469dd185deec6b6b53a0b (patch)
tree02e155a5753b398ee572b45793f889b538efab6b /extras/stripe-merge.c
parentf3b2e6580e5663292ee113c741343c8a43ee133f (diff)
Added all files
Diffstat (limited to 'extras/stripe-merge.c')
-rw-r--r--extras/stripe-merge.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/extras/stripe-merge.c b/extras/stripe-merge.c
new file mode 100644
index 000000000..3f8e4b124
--- /dev/null
+++ b/extras/stripe-merge.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int
+main (int argc, char *argv[])
+{
+ int fds[argc-1];
+ char buf[argc-1][4096];
+ int i;
+ int max_ret, ret;
+
+ if (argc < 2) {
+ printf ("Usage: %s file1 file2 ... >file\n", argv[0]);
+ return 1;
+ }
+
+ for (i=0; i<argc-1; i++) {
+ fds[i] = open (argv[i+1], O_RDONLY);
+ if (fds[i] == -1) {
+ perror (argv[i+1]);
+ return 1;
+ }
+ }
+
+ max_ret = 0;
+ do {
+ char newbuf[4096] = {0, };
+ int j;
+
+ max_ret = 0;
+ for (i=0; i<argc-1; i++) {
+ memset (buf[i], 0, 4096);
+ ret = read (fds[i], buf[i], 4096);
+ if (ret > max_ret)
+ max_ret = ret;
+ }
+ for (i=0; i<max_ret;i++)
+ for (j=0; j<argc-1; j++)
+ newbuf[i] |= buf[j][i];
+ write (1, newbuf, max_ret);
+ } while (max_ret);
+
+ return 0;
+}
+