Browse Source

Reorganized project

max 8 years ago
parent
commit
9917ce3c0b

+ 3 - 0
.gitignore

@@ -1,4 +1,7 @@
 # ---> C
+# bin folder
+bin/*
+
 # Object files
 *.o
 *.ko

+ 5 - 0
CMakeLists.txt

@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.3)
+project (Mycorrhiza)
+
+add_executable(mycoagent test/mycoagent.c)
+add_executable(mycodaemon test/mycodaemon.c)

+ 0 - 9
agent/Makefile

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

+ 0 - 9
daemon/Makefile

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

+ 0 - 7
kernelmodule/Makefile

@@ -1,7 +0,0 @@
-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

+ 0 - 185
kernelmodule/mycokernel.c

@@ -1,185 +0,0 @@
-/*  
- * 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");
-}

+ 1 - 0
agent/myco-agent.c → src/myco-agent.c

@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "myco-agent.h"
 
 int myco_send (const char *message, const char *myco_daemon_address, uint16_t myco_daemon_port) {
     int create_socket;

+ 0 - 0
agent/myco-agent.h → src/myco-agent.h


+ 0 - 0
src/myco-daemon.c


+ 0 - 0
daemon/myco-daemon.h → src/myco-daemon.h


+ 0 - 0
src/myco-indexer.c


+ 41 - 0
src/myco-indexer.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
+
+

+ 1 - 1
agent/mycoagent.c → test/mycoagent.c

@@ -2,7 +2,7 @@
  * mycoagent.c
  */
 
-#include "myco-agent.h"
+#include "../src/myco-agent.c"
 
 int main() {
     // Test register resource

+ 0 - 0
daemon/mycodaemon.c → test/mycodaemon.c