UML little patches for 2.6.16
cover UML little patches for 2.6.16
I'm sending some little fixups for inclusion 2.6.16. I've held some other fixes which need wider testing. Please merge now.
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
PATCH 1/6 uml: correct error messages in COW driver
Improve some error messages in the COW driver, and say V3, not V2, when talking about V3 format. Also resync with our userspace code utility a bit more.
---
arch/um/drivers/cow_sys.h | 2 +- arch/um/drivers/cow_user.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-)
arch/um/drivers/cow_sys.h +1 -1
@@ -33,7 +33,7 @@ static inline int cow_file_size(char *fireturn (os_file_size (file, size_out)); } -static inline int cow_write_file (int fd,char *buf,int size) +static inline int cow_write_file (int fd,void *buf,int size) {return (os_write_file (fd, buf, size)); }
arch/um/drivers/cow_user.c +12 -9
@@ -176,7 +176,7 @@ int write_cow_header(char *cow_file, int err = -ENOMEM ; header =cow_malloc (sizeof (*header));if (header ==NULL ){ -cow_printf ("Failed to allocate COW V3 header\n" ); +cow_printf ("write_cow_header - failed to allocate COW V3 header\n" ); goto out; } header->magic =htonl (COW_MAGIC );
@@ -196,15 +196,17 @@ int write_cow_header(char *cow_file, int err =os_file_modtime (header->backing_file, &modtime);if (err <0 ){ -cow_printf ("Backing file '%s' mtime request failed, " -"err = %d\n" , header->backing_file, -err); +cow_printf ("write_cow_header - backing file '%s' mtime " +"request failed, err = %d\n" , header->backing_file, + -err); goto out_free; } err =cow_file_size (header->backing_file, size);if (err <0 ){ -cow_printf ("Couldn't get size of backing file '%s', " -"err = %d\n" , header->backing_file, -err); +cow_printf ("write_cow_header - couldn't get size of " +"backing file '%s', err = %d\n" , + header->backing_file, -err); goto out_free; }
@@ -214,10 +216,11 @@ int write_cow_header(char *cow_file, int header->alignment =htonl (alignment); header->cow_format =COW_BITMAP ; - err =os_write_file (fd, header,sizeof (*header)); + err =cow_write_file (fd, header,sizeof (*header));if (err !=sizeof (*header)){ -cow_printf ("Write of header to new COW file '%s' failed, " -"err = %d\n" , cow_file, -err); +cow_printf ("write_cow_header - write of header to " +"new COW file '%s' failed, err = %d\n" , cow_file, + -err); goto out_free; } err =0 ;
@@ -299,7 +302,7 @@ int read_cow_header(int (*reader)(__u64, }else if (version ==3 ){if (n <sizeof (header->v3)){ -cow_printf ("read_cow_header - failed to read V2 " +cow_printf ("read_cow_header - failed to read V3 " "header\n" ); goto out; }
PATCH 2/6 uml: fix usage of kernel_errno in place of errno
In reply to Paolo 'Blaisorblade' GiarrussoFrom: Paolo 'Blaisorblade' Giarrusso <[email protected]>
To avoid conflicts, in kernel files errno is expanded to kernel_errno, to distinguish it from glibc errno. In this case, the code wants to use the libc errno but the kernel one is used; in the other usage, we return errno in place of -errno in case of an error.
---
arch/um/include/os.h | 3 +++ arch/um/os-Linux/process.c | 15 +++++++++++++++ arch/um/sys-i386/ldt.c | 9 +++------ 3 files changed, 21 insertions(+), 6 deletions(-)
arch/um/include/os.h +3 -0
@@ -179,8 +179,11 @@ extern void os_stop_process(int pid);extern void os_kill_process (int pid,int reap_child);extern void os_kill_ptraced_process (int pid,int reap_child);extern void os_usr1_process (int pid); +extern long os_ptrace_ldt (long pid,long addr,long data); +extern int os_getpid (void );extern int os_getpgrp (void ); +extern void init_new_thread_stack (void *sig_stack,void (*usr1_handler)(int ));extern void init_new_thread_signals (int altstack);extern int run_kernel_thread (int (*fn)(void *),void *arg,void **jmp_ptr);
arch/um/os-Linux/process.c +15 -0
@@ -19,6 +19,7 @@#include "irq_user.h" #include "kern_util.h" #include "longjmp.h" +#include "skas_ptrace.h" #define ARBITRARY_ADDR -1#define FAILURE_PID -1
@@ -100,6 +101,20 @@ void os_kill_process(int pid, int reap_c } +/* This is here uniquely to have access to the userspace errno, i.e. the one +* used by ptrace in case of error. +*/ + +long os_ptrace_ldt (long pid,long addr,long data) { +int ret; + + ret =ptrace (PTRACE_LDT , pid, addr, data); + +if (ret <0 ) +return -errno; +return ret; +} +/* Kill off a ptraced child by all means available. kill it normally first, * then PTRACE_KILL it, then PTRACE_CONT it in case it's in a run state from * which it can't exit directly.
arch/um/sys-i386/ldt.c +3 -6
@@ -107,7 +107,7 @@ long write_ldt_entry(struct mm_id * mm_i* So we need to switch child's mm into our userspace, then * later switch back. * -* Note: I'm unshure: should interrupts be disabled here? +* Note: I'm unsure: should interrupts be disabled here? */ if (!current->active_mm || current->active_mm == &init_mm || mm_idp != ¤t->active_mm->context.skas.id)
@@ -129,9 +129,7 @@ long write_ldt_entry(struct mm_id * mm_i pid = userspace_pid[cpu]; } - res =ptrace (PTRACE_LDT , pid,0 , (unsigned long ) &ldt_op); -if (res) - res = errno; + res =os_ptrace_ldt (pid,0 , (unsigned long ) &ldt_op);if (proc_mm)put_cpu ();
@@ -181,8 +179,7 @@ static long read_ldt_from_host(void __us*/ cpu =get_cpu (); - res =ptrace (PTRACE_LDT , userspace_pid[cpu],0 , - (unsigned long ) &ptrace_ldt); + res =os_ptrace_ldt (userspace_pid[cpu],0 , (unsigned long ) &ptrace_ldt);put_cpu ();if (res <0 ) goto out;
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
PATCH 3/6 uml: fix ((unused)) attribute
In reply to Paolo 'Blaisorblade' GiarrussoUse __attribute_used__ instead of __attribute__ ((unused)). This will help with GCC > 3.2.
---
arch/um/include/init.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/um/include/init.h +1 -1
@@ -122,7 +122,7 @@ extern struct uml_param __uml_setup_star#define __exitcall (fn) static exitcall_t __exitcall_##fn __exit_call = fn -#define __init_call __attribute__ ((unused,__section__ (".initcall.init"))) +#define __init_call __attribute_used__ __attribute__ ((__section__ (".initcall.init")))#endif
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
PATCH 4/6 uml: os_connect_socket error path fixup
In reply to Paolo 'Blaisorblade' GiarrussoFix an fd leak and a return of -1 instead of -errno in the error path - this showed up in intensive testing of HPPFS, the os_connect_socket user.
---
arch/um/os-Linux/file.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
arch/um/os-Linux/file.c +14 -5
@@ -272,14 +272,23 @@ int os_connect_socket(char *name)snprintf (sock.sun_path,sizeof (sock.sun_path),"%s" , name); fd =socket (AF_UNIX ,SOCK_STREAM ,0 ); -if (fd <0 ) -return (fd); +if (fd <0 ) { + err = -errno; + goto out; + } err =connect (fd, (struct sockaddr *) &sock,sizeof (sock)); -if (err) -return (-errno); +if (err) { + err = -errno; + goto out_close; + } -return (fd); +return fd; + +out_close: +close (fd); +out: +return err; }void os_close_file (int fd)
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
PATCH 5/6 uml: better error reporting for read_output
In reply to Paolo 'Blaisorblade' GiarrussoDo precise error handling: print precise error messages, distinguishing short reads and read errors. This functions fails frequently enough for me so I bothered doing this fix.
---
arch/um/drivers/net_user.c | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-)
arch/um/drivers/net_user.c +22 -12
@@ -47,10 +47,12 @@ void tap_check_ips(char *gate_addr, unsi } } +/* Do reliable error handling as this fails frequently enough. */ void read_output (int fd,char *output,int len) { -int remain, n, actual; +int remain, ret, expected;char c; +char *str;if (output ==NULL ){ output = &c;
@@ -58,23 +60,31 @@ void read_output(int fd, char *output, i } *output ='\0' ; - n =os_read_file (fd, &remain,sizeof (remain)); -if (n !=sizeof (remain)){ -printk ("read_output - read of length failed, err = %d\n" , -n); -return ; + ret =os_read_file (fd, &remain,sizeof (remain)); + +if (ret !=sizeof (remain)) { + expected =sizeof (remain); + str ="length" ; + goto err; }while (remain !=0 ){ - n = (remain < len) ? remain : len; - actual =os_read_file (fd, output, n); -if (actual != n){ -printk ("read_output - read of data failed, " -"err = %d\n" , -actual); -return ; + expected = (remain < len) ? remain : len; + ret =os_read_file (fd, output, expected); +if (ret != expected) { + str ="data" ; + goto err; } - remain -= actual; + remain -= ret; } +return ; + +err: +if (ret <0 ) +printk ("read_output - read of %s failed, errno = %d\n" , str, -ret); +else +printk ("read_output - read of %s failed, read only %d of %d bytes\n" , str, ret, expected); }int net_read (int fd,void *buf,int len)
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
PATCH 6/6 uml: tidying COW code
In reply to Paolo 'Blaisorblade' GiarrussoImprove (especially for coherence) some prototypes, and return code of init_cow_file in error case - for a short write return -EINVAL, otherwise return the error we got!
---
arch/um/drivers/cow.h | 2 +- arch/um/drivers/cow_sys.h | 4 ++-- arch/um/drivers/cow_user.c | 3 ++- arch/um/drivers/ubd_kern.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
arch/um/drivers/cow.h +1 -1
@@ -46,7 +46,7 @@ extern int file_reader(__u64 offset, chaextern int read_cow_header (int (*reader)(__u64 ,char *,int ,void *),void *arg,__u32 *version_out,char **backing_file_out,time_t *mtime_out, -unsigned long long *size_out,int *sectorsize_out, +__u64 *size_out,int *sectorsize_out,__u32 *align_out,int *bitmap_offset_out); extern int write_cow_header(char *cow_file, int fd, char *backing_file,
arch/um/drivers/cow_sys.h +2 -2
@@ -23,12 +23,12 @@ static inline char *cow_strdup(char *strreturn (uml_strdup (str)); } -static inline int cow_seek_file (int fd,unsigned long long offset) +static inline int cow_seek_file (int fd,__u64 offset) {return (os_seek_file (fd, offset)); } -static inline int cow_file_size (char *file,unsigned long long *size_out) +static inline int cow_file_size (char *file,__u64 *size_out) {return (os_file_size (file, size_out)); }
arch/um/drivers/cow_user.c +2 -1
@@ -362,7 +362,8 @@ int init_cow_file(int fd, char *cow_fileif (err !=sizeof (zero)){cow_printf ("Write of bitmap to new COW file '%s' failed, " "err = %d\n" , cow_file, -err); - err = -EINVAL ; +if (err >=0 ) + err = -EINVAL ; goto out; }
arch/um/drivers/ubd_kern.c +1 -1
@@ -1141,7 +1141,7 @@ static int path_requires_switch(char *frstatic int backing_file_mismatch (char *file,__u64 size,time_t mtime) {unsigned long modtime; -long long actual; +unsigned long long actual;int err; err =os_file_modtime (file, &modtime);
Quoted 2 lines · Paolo 'Blaisorblade' Giarrusso
I'm sending some little fixups for inclusion 2.6.16. I've held some other fixes which need wider testing. Please merge now.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel