diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-12-02 20:56:17 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-12-02 20:56:17 +0000 |
commit | dbff0b77ad0ea0d7694d8119618b0c4f1404eb61 (patch) | |
tree | e30dff0499165299084e0d94df361d2f043a6cad | |
parent | 0e5be44a108cd4563ebf6856bea60483e2668951 (diff) | |
download | xen-dbff0b77ad0ea0d7694d8119618b0c4f1404eb61.tar.gz xen-dbff0b77ad0ea0d7694d8119618b0c4f1404eb61.tar.bz2 xen-dbff0b77ad0ea0d7694d8119618b0c4f1404eb61.zip |
bitkeeper revision 1.1159.187.55 (41af81710ePtgtFPsGTTUHYqD1qviA)
Simpler balloon proc entry.
-rw-r--r-- | linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c | 68 |
1 files changed, 18 insertions, 50 deletions
diff --git a/linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c b/linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c index 443a0240d6..f914998bfe 100644 --- a/linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c +++ b/linux-2.6.9-xen-sparse/drivers/xen/balloon/balloon.c @@ -320,55 +320,38 @@ static void balloon_ctrlif_rx(ctrl_msg_t *msg, unsigned long id) ctrl_if_send_response(msg); } -static int balloon_write(struct file *file, const char *buffer, - size_t count, loff_t *offp) +static int balloon_write(struct file *file, const char __user *buffer, + unsigned long count, void *data) { char memstring[64], *endchar; - int len, i; unsigned long long target_bytes; if ( !capable(CAP_SYS_ADMIN) ) return -EPERM; + if ( count <= 1 ) + return -EBADMSG; /* runt */ if ( count > sizeof(memstring) ) - return -EFBIG; - - len = strnlen_user(buffer, count); - if ( len == 0 ) - return -EBADMSG; - if ( len == 1 ) - goto out; /* input starts with a NUL char */ - if ( strncpy_from_user(memstring, buffer, len) < 0 ) - return -EFAULT; + return -EFBIG; /* too long */ - endchar = memstring; - for ( i = 0; i < len; ++i, ++endchar ) - if ( (memstring[i] < '0') || (memstring[i] > '9') ) - break; - if ( i == 0 ) - return -EBADMSG; + if ( copy_from_user(memstring, buffer, count) ) + return -EFAULT; + memstring[sizeof(memstring)-1] = '\0'; - target_bytes = memparse(memstring,&endchar); + target_bytes = memparse(memstring, &endchar); set_new_target(target_bytes >> PAGE_SHIFT); - out: - *offp += len; - return len; + return count; } -static int balloon_read(struct file *filp, char *buffer, - size_t count, loff_t *offp) +static int balloon_read(char *page, char **start, off_t off, + int count, int *eof, void *data) { - char *priv_buf; int len; - priv_buf = (char *)__get_free_page(GFP_KERNEL); - if ( priv_buf == NULL ) - return -ENOMEM; - #define K(_p) ((_p)<<(PAGE_SHIFT-10)) len = sprintf( - priv_buf, + page, "Current allocation: %8lu kB\n" "Target allocation: %8lu kB / %8lu kB (actual / requested)\n" "Unused heap space: %8lu kB / %8lu kB (low-mem / high-mem)\n" @@ -379,34 +362,18 @@ static int balloon_read(struct file *filp, char *buffer, if ( hard_limit != ~0UL ) len += sprintf( - priv_buf + len, + page + len, "%8lu kB (inc. %8lu kB driver headroom)\n", K(hard_limit), K(driver_pages)); else len += sprintf( - priv_buf + len, + page + len, " ??? kB\n"); - len -= *offp; - if ( len > count) - len = count; - if ( len < 0 ) - len = 0; - - if ( len != 0 ) - (void)copy_to_user(buffer, &priv_buf[*offp], len); - - free_page((unsigned long)priv_buf); - - *offp += len; + *eof = 1; return len; } -static struct file_operations balloon_fops = { - .read = balloon_read, - .write = balloon_write -}; - static int __init balloon_init(void) { unsigned long pfn; @@ -431,7 +398,8 @@ static int __init balloon_init(void) return -1; } - balloon_pde->proc_fops = &balloon_fops; + balloon_pde->read_proc = balloon_read; + balloon_pde->write_proc = balloon_write; (void)ctrl_if_register_receiver(CMSG_MEM_REQUEST, balloon_ctrlif_rx, 0); |