X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fmain.c;h=7b40e192f717f5f82073eb54f1fb728c880ce266;hb=a8686374c6aa74d805b32e7675f42f7ab9a0b348;hp=310c5a11d3027df36853594d360ae9098c76f021;hpb=d775bbfa668ce9968bacc0e4257cf86e5ab88e90;p=palacios.git diff --git a/linux_module/main.c b/linux_module/main.c index 310c5a1..7b40e19 100644 --- a/linux_module/main.c +++ b/linux_module/main.c @@ -122,6 +122,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 +410,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 +493,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 +578,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 +681,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); }