(no commit message)
authorSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 27 Feb 2009 17:51:55 +0000 (17:51 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 27 Feb 2009 17:51:55 +0000 (17:51 +0000)
dcookie.c [new file with mode: 0644]

diff --git a/dcookie.c b/dcookie.c
new file mode 100644 (file)
index 0000000..ca22353
--- /dev/null
+++ b/dcookie.c
@@ -0,0 +1,36 @@
+/* dcookie retrieval vsys entry, required by Chopstix.
+ * The lookup_dcookie system call retrieves a pathname */
+
+#define __NR_LOOKUP_DCOOKIE 253
+
+#include <sys/syscall.h>
+/*#include <asm/page.h>*/
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#define INT64_MAXSZ    "18446744073709551615Z"
+
+int lookup_dcookie(uint64_t cookie, char * buf, size_t size)
+{
+               return syscall(__NR_LOOKUP_DCOOKIE, cookie, buf, size);
+}
+
+int main(int argc,char *argv[]) {
+               /* fs/dcookie.c uses PAGE_SIZE */
+               char path_buf[16384],dcookie_buf[sizeof(INT64_MAXSZ)];
+
+               /* In case nothing happens */
+               path_buf[0]='\0';
+
+               while (fgets(dcookie_buf, sizeof(dcookie_buf),stdin)) {
+                       if (lookup_dcookie(atoll(dcookie_buf), path_buf, sizeof(path_buf))>0) { 
+                                       printf("%s\n",path_buf);
+                       }
+                       else {
+                                       printf("% Not found\n");
+                       }
+               }
+}