From 89a133fe09ec89eb8ff01b8c07eebf979b444e44 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Wed, 6 Aug 2008 17:28:00 +0000 Subject: [PATCH] Dcookie entry, required by Chopstix. --- factory/Makefile | 4 ++++ factory/dcookie.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 factory/Makefile create mode 100644 factory/dcookie.c diff --git a/factory/Makefile b/factory/Makefile new file mode 100644 index 0000000..22ff5b5 --- /dev/null +++ b/factory/Makefile @@ -0,0 +1,4 @@ +CC=gcc +CFLAGS=-g -O2 + +all: dcookie diff --git a/factory/dcookie.c b/factory/dcookie.c new file mode 100644 index 0000000..f5d01cd --- /dev/null +++ b/factory/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 +#include +#include +#include +#include +#include +#include + +#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[PAGE_SIZE],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"); + } + } +} -- 2.43.0