Parcourir la source

just some snippets so far

max il y a 8 ans
Parent
commit
5f393988ee
9 fichiers modifiés avec 663 ajouts et 0 suppressions
  1. 9 0
      agent/Makefile
  2. 186 0
      agent/myco-agent.c
  3. 121 0
      agent/myco-agent.h
  4. 18 0
      agent/mycoagent.c
  5. 9 0
      daemon/Makefile
  6. 41 0
      daemon/myco-daemon.h
  7. 87 0
      daemon/mycodaemon.c
  8. 7 0
      kernelmodule/Makefile
  9. 185 0
      kernelmodule/mycokernel.c

+ 9 - 0
agent/Makefile

@@ -0,0 +1,9 @@
+OBJ = mycoagent.o 
+BIN = mycoagent 
+SRC = mycoagent.c myco-agent.c
+
+all:
+		gcc -Wall -o $(BIN) $(SRC)
+
+clean:
+		rm -rf $(BIN) $(OBJ)

+ 186 - 0
agent/myco-agent.c

@@ -0,0 +1,186 @@
+/* Copyright (C) 2016 Max Riechelmann <max.riechelmann@student.kit.edu>
+   (Karlsruhe Institute of Technology)
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or (at your
+   option) any later version.
+   This library is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+   details.
+   You should have received a copy of the GNU Lesser General Public License along
+   with this library; if not, write to the Free Software Foundation, Inc., 51
+   Franklin St, Fifth Floor, Boston, MA 02110, USA
+   */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int myco_send (const char *message, const char *myco_daemon_address, uint16_t myco_daemon_port) {
+    int create_socket;
+    struct sockaddr_in address;
+
+    if ((create_socket = socket (AF_INET, SOCK_STREAM, 0)) < 1)
+        return -1;
+    address.sin_family = AF_INET;
+    address.sin_port = htons (myco_daemon_port);
+    inet_aton (myco_daemon_address, &address.sin_addr);
+    if (connect ( create_socket, (struct sockaddr *) &address, sizeof (address)) != 0)
+        return -1;
+
+    send(create_socket, message, strlen (message), 0);
+
+    close (create_socket);
+
+    return 0;
+}
+
+int myco_recv (char *message, const char *myco_daemon_address, uint16_t myco_daemon_port) {
+    int buf = 1024;
+    int create_socket, new_socket;
+    socklen_t addrlen;
+    char *buffer = malloc (buf);
+    ssize_t size;
+    struct sockaddr_in address;
+    const int y = 1;
+    printf ("\e[2J");
+    if ((create_socket=socket (AF_INET, SOCK_STREAM, 0)) > 0)
+        printf ("Socket wurde angelegt\n");
+    setsockopt( create_socket, SOL_SOCKET,
+            SO_REUSEADDR, &y, sizeof(int));
+    address.sin_family = AF_INET;
+    address.sin_addr.s_addr = INADDR_ANY;
+    address.sin_port = htons (myco_daemon_port);
+    if (bind ( create_socket,
+                (struct sockaddr *) &address,
+                sizeof (address)) != 0) {
+        printf( "Der Port ist nicht frei – belegt!\n");
+    }
+    listen (create_socket, 5);
+    addrlen = sizeof (struct sockaddr_in);
+    new_socket = accept ( create_socket,
+            (struct sockaddr *) &address,
+            &addrlen );
+    if (new_socket > 0)
+        printf ("Ein Client (%s) ist verbunden ...\n",
+                inet_ntoa (address.sin_addr));
+    size = recv (new_socket, buffer, buf-1, 0);
+    if( size > 0)
+        buffer[size] = '\0';
+    printf ("Nachricht empfangen: %s\n", buffer);
+
+    close (new_socket);
+
+    return 0;
+
+}
+
+int myco_agent_register (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port) {
+    int size = 1024;
+    char *message = malloc (size);
+    char *buffer = malloc(50);
+
+    strcat (message, "REGISTER: ");
+    strcat (message, myco_daemon_address);
+    sprintf (buffer, ":%d", myco_daemon_port);
+    strcat (message, buffer);
+    sprintf (buffer, " %d", pid);
+    strcat (message, buffer);
+
+    if (myco_send(message, myco_daemon_address, myco_daemon_port) != 0) {
+        return -1;
+    }
+
+    return 0;
+}
+
+int myco_agent_unregister (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port) {
+    int size = 1024;
+    char *message = malloc (size);
+    char *buffer = malloc(50);
+
+    strcat (message, "UNREGISTER: ");
+    strcat (message, myco_daemon_address);
+    sprintf (buffer, ":%d", myco_daemon_port);
+    strcat (message, buffer);
+    sprintf (buffer, " %d", pid);
+    strcat (message, buffer);
+
+    if (myco_send(message, myco_daemon_address, myco_daemon_port) != 0) {
+        return -1;
+    }
+
+    return 0;
+}
+
+int myco_agent_register_resource (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, const char *resource_name) {
+    int size = 1024;
+    char *message = malloc (size);
+    char *buffer = malloc(50);
+
+    strcat (message, "RESOURCE: ");
+    strcat (message, myco_daemon_address);
+    sprintf (buffer, ":%d", myco_daemon_port);
+    strcat (message, buffer);
+    sprintf (buffer, " %d ", pid);
+    strcat (message, buffer);
+    strcat (message, resource_name);
+
+    if (myco_send(message, myco_daemon_address, myco_daemon_port) != 0) {
+        return -1;
+    }
+
+    return myco_recv(message, myco_daemon_address, myco_daemon_port);
+}
+
+/**
+ * myco_agent_request_resource:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_id: The unique resource id.
+ * @resource_pointer: Pointer to the local memory region where to write the resource to.
+ * @resource_size: Size in Bytes the resource takes.
+ * @resource_name: Variable for resource name, filled by daemon.
+ *
+ * Requests a resource from the daemon. If size equals actual resource size transfer is
+ * done immediatly. This only works if resource size is known beforehand. If resource 
+ * size is unknown check with myco_agent_request_resource_info();
+ *
+ * Returns: -1 on error, 0 on success
+ */
+int myco_agent_request_resource(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, int resource_id, void *resource_pointer, int resource_size, char *resource_name);
+
+/**
+ * myco_agent_request_resource_info:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_id: The unique resource id.
+ * @resource_size: Size in Bytes the resource takes.
+ * @resource_name: Variable for resource name, filled by daemon.
+ *
+ * Requests resource information from the daemon. 
+ *
+ * Returns: -1 on error, 0 on success
+ */
+int myco_agent_request_resource_info(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, int resource_id, int resource_size, char *resource_name);
+
+/**
+ * myco_agent_request_resource_list:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_list: A comma seperated list of resources (id, name, size).
+ *
+ * Requests resource list. Obtains a list of all resources in the current network.
+ *
+ * Returns: -1 on error, 0 on success
+ */
+int myco_agent_request_resource_list(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, char *resource_list);

+ 121 - 0
agent/myco-agent.h

@@ -0,0 +1,121 @@
+/* Copyright (C) 2016 Max Riechelmann <max.riechelmann@student.kit.edu>
+   (Karlsruhe Institute of Technology)
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or (at your
+   option) any later version.
+   This library is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+   details.
+   You should have received a copy of the GNU Lesser General Public License along
+   with this library; if not, write to the Free Software Foundation, Inc., 51
+   Franklin St, Fifth Floor, Boston, MA 02110, USA
+*/
+
+/**
+ * SECTION: myco-agent
+ * @Short_description: agent library
+ * @Title: MycoAgent
+ *
+ * MycoAgent implements the agent side of the Mycorrhiza distributed system.
+ * It (un-)registers with the mycoagent and provides information about 
+ * accessible data RESOURCES.
+ */
+
+#ifndef __MYCO_AGENT_H
+#define __MYCO_AGENT_H
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/**
+ * myco_agent_register:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ *
+ * Registers self with the local daemon process.
+ *
+ * Returns: 0 on success, -1 on error 
+ */
+int myco_agent_register (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port);
+
+/**
+ * myco_agent_unregister:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ *
+ * Unregisters self with the local daemon process.
+ *
+ * Returns: 0 on success, -1 on error 
+ */
+int myco_agent_unregister (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port);
+
+/**
+ * myco_agent_register_resource:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_name: Name of resource.
+ *
+ * Registers self with the local daemon process.
+ *
+ * Returns: -1 on error, the unique resource id on success
+ */
+int myco_agent_register_resource (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, const char *resource_name);
+
+/**
+ * myco_agent_request_resource:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_id: The unique resource id.
+ * @resource_pointer: Pointer to the local memory region where to write the resource to.
+ * @resource_size: Size in Bytes the resource takes.
+ * @resource_name: Variable for resource name, filled by daemon.
+ *
+ * Requests a resource from the daemon. If size equals actual resource size transfer is
+ * done immediatly. This only works if resource size is known beforehand. If resource 
+ * size is unknown check with myco_agent_request_resource_info();
+ *
+ * Returns: -1 on error, 0 on success
+ */
+int myco_agent_request_resource(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, int resource_id, void *resource_pointer, int resource_size, char *resource_name);
+
+/**
+ * myco_agent_request_resource_info:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_id: The unique resource id.
+ * @resource_size: Size in Bytes the resource takes.
+ * @resource_name: Variable for resource name, filled by daemon.
+ *
+ * Requests resource information from the daemon. 
+ *
+ * Returns: -1 on error, 0 on success
+ */
+int myco_agent_request_resource_info(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, int resource_id, int resource_size, char *resource_name);
+
+/**
+ * myco_agent_request_resource_list:
+ * @pid: The PID of the user program.
+ * @myco_daemon_address: The IP address of the daemon (usually localhost).
+ * @myco_daemon_port: The port of the daemon.
+ * @resource_list: A comma seperated list of resources (id, name, size).
+ *
+ * Requests resource list. Obtains a list of all resources in the current network.
+ *
+ * Returns: -1 on error, 0 on success
+ */
+int myco_agent_request_resource_list(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, char *resource_list);
+
+#endif //__MYCO_AGENT_H

+ 18 - 0
agent/mycoagent.c

@@ -0,0 +1,18 @@
+/*  
+ * mycoagent.c
+ */
+
+#include "myco-agent.h"
+
+int main() {
+    // Test register resource
+    const char *resource_name = "Example resource";
+    int resource_id = myco_agent_register_resource (getpid(), "127.0.0.1", 15000, resource_name);
+    if (resource_id > -1) {
+        printf ("Success. Resource_id: %d\n", resource_id);
+    } else {
+        printf ("Failure.\n");
+    }
+
+    return 0;
+}

+ 9 - 0
daemon/Makefile

@@ -0,0 +1,9 @@
+OBJ = mycodaemon.o
+BIN = mycodaemon
+SRC = mycodaemon.c
+
+all:
+		gcc -Wall -o $(BIN) $(SRC)
+
+clean:
+		rm -rf $(BIN) $(OBJ)

+ 41 - 0
daemon/myco-daemon.h

@@ -0,0 +1,41 @@
+/* Copyright (C) 2016 Max Riechelmann <max.riechelmann@student.kit.edu>
+   (Karlsruhe Institute of Technology)
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published by the
+   Free Software Foundation; either version 2.1 of the License, or (at your
+   option) any later version.
+   This library is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+   details.
+   You should have received a copy of the GNU Lesser General Public License along
+   with this library; if not, write to the Free Software Foundation, Inc., 51
+   Franklin St, Fifth Floor, Boston, MA 02110, USA
+*/
+
+/**
+ * SECTION: myco-daemon
+ * @Short_description: daemon library
+ * @Title: MycoDaemon
+ *
+ * MycoAgent implements the agent side of the Mycorrhiza distributed system.
+ * It (un-)registers with the mycoagent and provides information about 
+ * accessible data RESOURCES.
+ */
+
+#ifndef __MYCO_DAEMON_H
+#define __MYCO_DAEMON_H
+
+/**
+ * myco_daemon_start:
+ * @myco_daemon_port: The port of the daemon
+ *
+ * Starts the daemon process on localhost.
+ *
+ * Returns: 0 on success, -1 on error 
+ */
+int myco_daemon_start ();
+
+// TODO: Communication with indexserver
+
+

+ 87 - 0
daemon/mycodaemon.c

@@ -0,0 +1,87 @@
+/*
+ *  mycodaemon.c
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int myco_send (const char *message, const char *myco_daemon_address, uint16_t myco_daemon_port) {
+    int create_socket;
+    struct sockaddr_in address;
+
+    if ((create_socket = socket (AF_INET, SOCK_STREAM, 0)) < 1)
+        return -1;
+    address.sin_family = AF_INET;
+    address.sin_port = htons (myco_daemon_port);
+    inet_aton (myco_daemon_address, &address.sin_addr);
+    if (connect ( create_socket, (struct sockaddr *) &address, sizeof (address)) != 0)
+        return -1;
+
+    send(create_socket, message, strlen (message), 0);
+
+    close (create_socket);
+
+    return 0;
+}
+
+int myco_recv (char *message, const char *myco_daemon_address, uint16_t myco_daemon_port) {
+    int buf = 1024;
+    int create_socket, new_socket;
+    socklen_t addrlen;
+    char *buffer = malloc (buf);
+    ssize_t size;
+    struct sockaddr_in address;
+    const int y = 1;
+    printf ("\e[2J");
+    if ((create_socket=socket (AF_INET, SOCK_STREAM, 0)) > 0)
+        printf ("Socket wurde angelegt\n");
+    setsockopt( create_socket, SOL_SOCKET,
+            SO_REUSEADDR, &y, sizeof(int));
+    address.sin_family = AF_INET;
+    address.sin_addr.s_addr = INADDR_ANY;
+    address.sin_port = htons (myco_daemon_port);
+    if (bind ( create_socket,
+                (struct sockaddr *) &address,
+                sizeof (address)) != 0) {
+        printf( "Der Port ist nicht frei – belegt!\n");
+    }
+    listen (create_socket, 5);
+    addrlen = sizeof (struct sockaddr_in);
+    new_socket = accept ( create_socket,
+            (struct sockaddr *) &address,
+            &addrlen );
+    if (new_socket > 0)
+        printf ("Ein Client (%s) ist verbunden ...\n",
+                inet_ntoa (address.sin_addr));
+    size = recv (new_socket, buffer, buf-1, 0);
+    if( size > 0)
+        buffer[size] = '\0';
+    printf ("Nachricht empfangen: %s\n", buffer);
+
+    close (new_socket);
+
+    return EXIT_SUCCESS;
+
+}
+
+
+// make into daemon later
+int main() {
+    char *message = malloc(1024);
+
+    if (myco_recv (message, "127.0.0.1", 15000))
+            printf ("Receive.\n");
+
+    if (myco_send ("foobar", "127.0.0.1", 15000))
+            printf ("Send.\n");
+
+    return EXIT_SUCCESS;
+
+}

+ 7 - 0
kernelmodule/Makefile

@@ -0,0 +1,7 @@
+obj-m += mycokernel.o
+
+all:
+		make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+		make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

+ 185 - 0
kernelmodule/mycokernel.c

@@ -0,0 +1,185 @@
+/*  
+ * mycokernel.c
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/pid.h>
+#include <linux/pid_namespace.h>
+#include <linux/moduleparam.h>
+#include <asm/atomic.h>
+#include <asm/tlbflush.h>
+#include <asm/tlb.h>
+#include <linux/pagemap.h>
+
+MODULE_AUTHOR("Max Riechelmann");
+MODULE_DESCRIPTION("TODO:");
+MODULE_LICENSE("GPL");
+
+// Passing argc: sudo insmod mycokernel.ko mypid=1234
+int mypid1 = 0;
+int mypid2 = 0;
+int addr1 = 0;
+int addr2 = 0;
+module_param(mypid1, int, 0);
+module_param(mypid2, int, 0);
+module_param(addr1, int, 0);
+module_param(addr2, int, 0);
+
+void print_task(struct task_struct *task)
+{
+    struct vm_area_struct *vma;
+    int count = 0;
+
+    printk("Task: %d\n", task->pid);
+
+    // Print virtual memory area information
+    printk("This mm_struct has %d vmas.\n", task->mm->map_count);
+    for (vma = task->mm->mmap ; vma ; vma = vma->vm_next) {
+        printk("%d  Starts at 0x%lx, Ends at 0x%lx\n",
+                ++count, vma->vm_start, vma->vm_end);
+    }
+    printk("Code  Segment start = 0x%lx, end = 0x%lx \n"
+            "Data  Segment start = 0x%lx, end = 0x%lx \n"
+            "Stack Segment start = 0x%lx \n"
+            "Heap Segment start = 0x%lx, end = 0x%lx \n"
+            "mmap Segment start = 0x%lx \n"
+            "number of pagetables %ld \n"
+            "total pages mapped %lu \n",
+            task->mm->start_code, task->mm->end_code,
+            task->mm->start_data, task->mm->end_data,
+            task->mm->start_stack,
+            task->mm->start_brk, task->mm->brk,
+            task->mm->mmap_base,
+            atomic_long_read(&task->mm->nr_ptes),
+            task->mm->total_vm);
+}
+
+int init_module(void)
+{
+    struct task_struct *task1, *task2;
+    int res;
+    struct page *page;
+    int *my_page_address;
+
+    
+    // Find the task by its pid
+    task1 = pid_task(find_get_pid(mypid1), PIDTYPE_PID);
+    task2 = pid_task(find_get_pid(mypid2), PIDTYPE_PID);
+
+    // Get page from user task
+    //down_read(task1->mm->mmap_sem);
+    res = get_user_pages(task1, task1->mm, addr1, 1, 1, 1, &page, NULL);
+    my_page_address = kmap(page);
+
+    if (res == 1) {
+        printk("Translated 0x%x to 0x%p\n", addr1, my_page_address);
+        printk("Its value is : %d\n", *my_page_address);
+    } else {
+        printk("Could not read page!\n");
+    }
+
+    kunmap(page);
+    SetPageDirty(page);
+    page_cache_release(page);
+
+    return 0;
+
+    // Old2
+    
+    /*
+    if (access_ok(VERIFY_WRITE, addr, size ) == 0) {
+        printk("Access not ok for 0x%lx\n", addr);
+    }
+    else
+    {
+        printk("Access ok for 0x%lx\n", addr);
+    }
+
+    if (clear_user((void *)addr, 1) > size) {
+        printk("Could not clear 0x%lx\n", addr);
+    }
+
+    while (vma2->vm_start < task2->mm->mmap_base) {
+        vma2 = vma2->vm_next;
+    }
+    printk("old vm_area task1: %lx task2: %lx\n", (long unsigned int)vma1, (long unsigned int)vma2);
+    vma_temp = vma1;
+    //vma1 = vma2;
+    //vma2 = vma_temp;
+    printk("new vm_area task1: %lx task2: %lx\n", (long unsigned int)vma1, (long unsigned int)vma2);
+
+    // Flush TLB
+    tlb_migrate_finish(task1->mm);
+    tlb_migrate_finish(task2->mm);
+    */
+
+
+    /*
+    // Old
+    struct task_struct *task;
+    struct vm_area_struct *vma;
+    int count = 0;
+    // pte = page table entry
+    struct page *pte;
+
+    // Find the task by its pid
+    task = pid_task(find_get_pid(mypid), PIDTYPE_PID);
+    printk("Messing with task %d\n", task->pid);
+
+    // Print virtual memory area information
+    printk("This mm_struct has %d vmas.\n", task->mm->map_count);
+    for (vma = task->mm->mmap ; vma ; vma = vma->vm_next) {
+        printk("%d  Starts at 0x%lx, Ends at 0x%lx\n",
+                ++count, vma->vm_start, vma->vm_end);
+    }
+    printk("Code  Segment start = 0x%lx, end = 0x%lx \n"
+            "Data  Segment start = 0x%lx, end = 0x%lx \n"
+            "Stack Segment start = 0x%lx \n"
+            "Heap Segment start = 0x%lx, end = 0x%lx \n"
+            "mmap Segment start = 0x%lx \n"
+            "number of pagetables %ld \n"
+            "total pages mapped %lu \n",
+            task->mm->start_code, task->mm->end_code,
+            task->mm->start_data, task->mm->end_data,
+            task->mm->start_stack,
+            task->mm->start_brk, task->mm->brk,
+            task->mm->mmap_base,
+            atomic_long_read(&task->mm->nr_ptes),
+            task->mm->total_vm);
+    
+    // Magic
+    pte = follow_page(task->mm->mmap, task->mm->mmap->vm_start, FOLL_WRITE);
+    printk("PTE: %d", pte->first_page->pages);
+
+    
+
+    //printk("Pointer to page table: 0x%lu\n", task->mm->pgd->pgd);
+    //page = (void *)task->mm->pgd->pgd;
+    //page_table_entry = (long unsigned int)page & (0x000000000000000 << 49);
+    //page_table_entry = (unsigned long int)page;
+    //page_table_entry = page_table_entry >> 14;
+    //printk("The first PTE is: %lu\n", page_table_entry);
+    //printk("The first PTE is: %lx\n", pgd_val(task->mm->pgd->pgd));
+    //printk("page_table_entry bits: %lu", sizeof(page_table_entry) * 8);
+    //printk("pagetable: %lu", page);
+    //printk("Physical address of mmap segment = 0x%lx\n", (long)virt_to_phys((void *)task->mm->mmap_base));
+    //printk("mmap ptr = 0x%lx\n", task->mm->mmap_base);
+    //ptr = (int *)task->mm->mmap_base;
+    //ptr = 0;
+    //printk("Physical address of mmap segment = 0x%lx\n", (long)virt_to_phys((void *)task->mm->mmap_base));
+    //printk("Virtual address of mmap segment = 0x%lx\n", task->mm->mmap_base);
+    //printk("Physical address of mmap segment = 0x%lx\n", (long)phys_to_virt(task->mm->mmap_base));
+
+
+    return 0;
+    */
+}
+
+void cleanup_module(void)
+{
+    printk(KERN_INFO "Done.\n");
+}