X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fmain.c;h=b0dbfee42c101aa5afa75d5105a0501c2b86d820;hb=c8b23e99efde3aa5a2c26d1b8e9bc7dc914e6113;hp=310c5a11d3027df36853594d360ae9098c76f021;hpb=d775bbfa668ce9968bacc0e4257cf86e5ab88e90;p=palacios.git diff --git a/linux_module/main.c b/linux_module/main.c index 310c5a1..b0dbfee 100644 --- a/linux_module/main.c +++ b/linux_module/main.c @@ -36,6 +36,7 @@ #include "util-hashtable.h" + MODULE_LICENSE("GPL"); // Module parameter @@ -122,6 +123,7 @@ static long v3_dev_ioctl(struct file * filp, guest->img_size = user_image.size; DEBUG("Palacios: Allocating kernel memory for guest image (%llu bytes)\n", user_image.size); + // overflow possible here, but only if guest image is probably to large for kernel anyway... guest->img = palacios_valloc(guest->img_size); if (!guest->img) { @@ -409,7 +411,7 @@ static int read_guests_details(struct seq_file *s, void *v) out: - if (mem) { palacios_vfree(mem); } + if (mem) { palacios_vfree(mem); } // dead code but kept for clarity if (core) { palacios_vfree(core); } if (base) { palacios_vfree(base); } @@ -492,14 +494,12 @@ static int read_guests(struct seq_file *s, void *v) static int guests_short_proc_open(struct inode * inode, struct file * filp) { - struct proc_dir_entry * proc_entry = PDE(inode); - return single_open(filp, read_guests, proc_entry->data); + return single_open(filp, read_guests, PAL_PROC_GETDATA(inode)); } static int guests_full_proc_open(struct inode * inode, struct file * filp) { - struct proc_dir_entry * proc_entry = PDE(inode); - return single_open(filp, read_guests_details, proc_entry->data); + return single_open(filp, read_guests_details, PAL_PROC_GETDATA(inode)); } @@ -579,8 +579,7 @@ static int read_info(struct seq_file *s, void *v) static int info_proc_open(struct inode * inode, struct file * filp) { - struct proc_dir_entry * proc_entry = PDE(inode); - return single_open(filp, read_info, proc_entry->data); + return single_open(filp, read_info, PAL_PROC_GETDATA(inode)); } @@ -683,31 +682,26 @@ static int __init v3_init(void) { { struct proc_dir_entry *entry; - entry = create_proc_entry("v3-guests", 0444, palacios_proc_dir); - if (entry) { - entry->proc_fops = &guest_short_proc_ops; - INFO("/proc/v3vee/v3-guests successfully created\n"); - } else { - ERROR("Could not create proc entry\n"); - goto failure6; - } - entry = create_proc_entry("v3-guests-details", 0444, palacios_proc_dir); - if (entry) { - entry->proc_fops = &guest_full_proc_ops; - INFO("/proc/v3vee/v3-guests-details successfully created\n"); - } else { - ERROR("Could not create proc entry\n"); - goto failure7; - } +#define PALPROC(ent, success, error, out_target, fname, perm, parent, fops) \ + PAL_PROC_CREATE(ent, fname, perm, parent, fops); \ + if (ent) { \ + INFO(success); \ + } else { \ + ERROR(error); \ + goto out_target; \ + } - entry = create_proc_entry("v3-info", 0444, palacios_proc_dir); - if (entry) { - entry->proc_fops = &info_proc_ops; - INFO("/proc/v3vee/v3-info successfully created\n"); - } else { - ERROR("Could not create proc entry\n"); - goto failure8; - } + PALPROC(entry, "/proc/v3vee/v3-guests succesfully created\n", + "Could not create proc entry\n", failure6, + "v3-guests", 0444, palacios_proc_dir, &guest_short_proc_ops); + + PALPROC(entry, "/proc/v3vee/v3-guests-details successfully created\n", + "Could not create proc entry\n", failure7, + "v3-guests-details", 0444, palacios_proc_dir, &guest_full_proc_ops); + + PALPROC(entry, "/proc/v3vee/v3-info successfully created\n", + "Could not create proc entry\n", failure8, + "v3-info", 0444, palacios_proc_dir, &info_proc_ops); }