Commit 6e8f75be by Andrew Dahl

Fixed overlapping variable names

parent a8aa48ae
Showing with 29 additions and 31 deletions
......@@ -39,21 +39,19 @@ ssize_t permex_write( struct file *filp, const char __user *buff, unsigned long
{
char *buffer;
buffer = (char *)vmalloc(len);
printk(KERN_CRIT "Length: %ld\n",len);
if (copy_from_user( buffer, buff, len))
{
return -EFAULT;
}
permnode_clear(perm_list);
//perm_list = NULL;
parse_list(perm_list, buffer, len);
permnode_clear();
parse_list(buffer, len);
return len;
}
void parse_list(struct permnode *head, const char *buffer, int len)
void parse_list(const char *buffer, int len)
{
struct permnode *perm;
struct filenode *file;
......@@ -69,10 +67,8 @@ void parse_list(struct permnode *head, const char *buffer, int len)
for(i=0; i < len; i++)
{
//printk(KERN_CRIT "One: %d:%s\n",i,buffer[i]);
if(buffer[i] == ':')
{
// printk(KERN_CRIT "Two: %d:%s\n",i,buffer[i]);
j--;
num = 0;
for(l = 0; j != -1; l++)
......@@ -87,12 +83,11 @@ void parse_list(struct permnode *head, const char *buffer, int len)
inode += num;
j--;
}
// printk(KERN_CRIT "Three:%d\n",inode);
//We have inode...
i++;
while(buffer[i] != '\n')
{
// printk(KERN_CRIT "Sixe:\n");
id = 0;
if(buffer[i] == 'u')
isUser = true;
......@@ -107,7 +102,7 @@ void parse_list(struct permnode *head, const char *buffer, int len)
j++;
temp[j] = buffer[i];
}
// printk(KERN_CRIT "Seven%d:%s\n",j,temp);
for(l = 0; j != -1; l++)
{
num = temp[l] - 48;
......@@ -120,8 +115,8 @@ void parse_list(struct permnode *head, const char *buffer, int len)
id += num;
j--;
}
// printk(KERN_CRIT "Eight%d\n",id);
// Get Permissions
// Get Permissions
i++;
j = -1;
for(;buffer[i] != ':' && buffer[i] != '\n'; i++)
......@@ -129,7 +124,6 @@ void parse_list(struct permnode *head, const char *buffer, int len)
j++;
temp[j] = buffer[i];
}
// printk(KERN_CRIT "Four:\n");
k = 0;
file = (struct filenode *) vmalloc( sizeof(struct filenode) );
perm = (struct permnode *) vmalloc( sizeof(struct permnode) );
......@@ -158,10 +152,8 @@ void parse_list(struct permnode *head, const char *buffer, int len)
else
file->perms[k] = true;
}
// printk(KERN_EMERG "About to add!!!\n");
permnode_add(head, perm, file);
// printk(KERN_EMERG "Added!!!\n");
// permnode_print(head);
permnode_add(perm, file);
}
}
else
......@@ -170,8 +162,8 @@ void parse_list(struct permnode *head, const char *buffer, int len)
j++;
}
}
printk(KERN_EMERG "Exiting Write Function\n");
permnode_print(head);
permnode_print();
}
......
......@@ -12,7 +12,7 @@
#include <linux/proc_fs.h>
#include <linux/namei.h>
#include <linux/cred.h>
#include "permnode.c"
//#include "permnode.c"
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("permex - Extended Permission Kernel Module");
......@@ -23,8 +23,10 @@ static struct proc_dir_entry *proc_entry;
unsigned long sys_call_table_address = 0;
struct permnode *perm_list = NULL;
#include "permnode.c"
ssize_t permex_write(struct file *, const char *, unsigned long , void *);
void parse_list(struct permnode *, const char *, int);
void parse_list(const char *, int);
int init_my_module(void);
void cleanup_my_module(void);
......
......@@ -8,10 +8,11 @@ struct permnode {
struct filenode* file_list;
};
void permnode_print(struct permnode *head)
void permnode_print()
{
printk(KERN_EMERG "10:%ld\n",(long)perm_list);
int i = 0;
struct permnode *cur_ptr = head;
struct permnode *cur_ptr = perm_list;
if(cur_ptr == NULL)
printk("\nList is Empty");
......@@ -29,12 +30,14 @@ void permnode_print(struct permnode *head)
printk("\n");
}
printk(KERN_EMERG "11:%ld\n",(long)perm_list);
}
void permnode_add(struct permnode *head, struct permnode *perm, struct filenode *file)
void permnode_add(struct permnode *perm, struct filenode *file)
{
printk(KERN_EMERG "8:%ld\n",(long)perm_list);
struct permnode *prev_ptr = NULL;
struct permnode *cur_ptr = head;
struct permnode *cur_ptr = perm_list;
struct filenode *file_head = NULL;
while(cur_ptr != NULL && ( cur_ptr->uid != perm->uid || cur_ptr->gid != perm->gid ))
......@@ -52,8 +55,8 @@ void permnode_add(struct permnode *head, struct permnode *perm, struct filenode
}
else
{
head = perm;
head->file_list = file;
perm_list = perm;
perm_list->file_list = file;
}
}
else
......@@ -62,14 +65,15 @@ void permnode_add(struct permnode *head, struct permnode *perm, struct filenode
file_head = cur_ptr->file_list;
filenode_add(file_head, file);
}
printk(KERN_EMERG "9:%ld\n",(long)perm_list);
}
/* Count the number of elements in the permnode list */
int permnode_length(struct permnode *head)
int permnode_length(struct permnode *perm_list)
{
int count = 0;
struct permnode *cur_ptr = head;
struct permnode *cur_ptr = perm_list;
for(count = 0; cur_ptr != NULL; count++)
cur_ptr = cur_ptr->next;
......@@ -77,10 +81,10 @@ int permnode_length(struct permnode *head)
return (count);
}
void permnode_clear(struct permnode *head)
void permnode_clear()
{
struct permnode *cur_ptr;
struct permnode *next_ptr = head;
struct permnode *next_ptr = perm_list;
while(next_ptr != NULL)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment