* [PATCH 2.6] 4/7 replace uml_strdup by kstrdup
@ 2005-02-01 3:28 pmarques
2005-02-02 7:52 ` Pekka Enberg
0 siblings, 1 reply; 5+ messages in thread
From: pmarques @ 2005-02-01 3:28 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, user-mode-linux-devel
[-- Attachment #1: Type: text/plain, Size: 342 bytes --]
This patch removes the strdup implementation in the UML architecture
(uml_strdup), and updates it to use the kstrdup library function.
Signed-off-by: Paulo Marques <pmarques@grupopie.com>
--
Paulo Marques - www.grupopie.com
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch4 --]
[-- Type: text/x-diff; name="patch4", Size: 8696 bytes --]
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/drivers/cow_sys.h linux-2.6.11-rc2-bk9/arch/um/drivers/cow_sys.h
--- vanilla-2.6.11-rc2-bk9/arch/um/drivers/cow_sys.h 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/drivers/cow_sys.h 2005-01-31 20:40:01.713782823 +0000
@@ -18,11 +18,6 @@ static inline void cow_free(void *ptr)
#define cow_printf printk
-static inline char *cow_strdup(char *str)
-{
- return(uml_strdup(str));
-}
-
static inline int cow_seek_file(int fd, unsigned long long offset)
{
return(os_seek_file(fd, offset));
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/drivers/cow_user.c linux-2.6.11-rc2-bk9/arch/um/drivers/cow_user.c
--- vanilla-2.6.11-rc2-bk9/arch/um/drivers/cow_user.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/drivers/cow_user.c 2005-01-31 20:39:08.587154730 +0000
@@ -7,6 +7,7 @@
#include <sys/param.h>
#include <sys/user.h>
#include <netinet/in.h>
+#include <linux/string.h>
#include "os.h"
@@ -313,7 +314,7 @@ int read_cow_header(int (*reader)(__u64,
goto out;
}
err = -ENOMEM;
- *backing_file_out = cow_strdup(file);
+ *backing_file_out = kstrdup(file, GFP_KERNEL);
if(*backing_file_out == NULL){
cow_printf("read_cow_header - failed to allocate backing "
"file\n");
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/drivers/line.c linux-2.6.11-rc2-bk9/arch/um/drivers/line.c
--- vanilla-2.6.11-rc2-bk9/arch/um/drivers/line.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/drivers/line.c 2005-01-31 20:39:08.587154730 +0000
@@ -9,6 +9,7 @@
#include "linux/kd.h"
#include "linux/interrupt.h"
#include "linux/devfs_fs_kernel.h"
+#include "linux/string.h"
#include "asm/uaccess.h"
#include "chan_kern.h"
#include "irq_user.h"
@@ -445,10 +446,10 @@ int line_setup(struct line *lines, int n
int line_config(struct line *lines, int num, char *str)
{
- char *new = uml_strdup(str);
+ char *new = kstrdup(str, GFP_KERNEL);
if(new == NULL){
- printk("line_config - uml_strdup failed\n");
+ printk("line_config - kstrdup failed\n");
return(-ENOMEM);
}
return(!line_setup(lines, num, new, 0));
@@ -555,9 +556,9 @@ void lines_init(struct line *lines, int
INIT_LIST_HEAD(&line->chan_list);
sema_init(&line->sem, 1);
if(line->init_str != NULL){
- line->init_str = uml_strdup(line->init_str);
+ line->init_str = kstrdup(line->init_str, GFP_KERNEL);
if(line->init_str == NULL)
- printk("lines_init - uml_strdup returned "
+ printk("lines_init - kstrdup returned "
"NULL\n");
}
}
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/drivers/mconsole_kern.c linux-2.6.11-rc2-bk9/arch/um/drivers/mconsole_kern.c
--- vanilla-2.6.11-rc2-bk9/arch/um/drivers/mconsole_kern.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/drivers/mconsole_kern.c 2005-01-31 20:39:08.588154554 +0000
@@ -20,6 +20,7 @@
#include "linux/namei.h"
#include "linux/proc_fs.h"
#include "linux/syscalls.h"
+#include "linux/string.h"
#include "asm/irq.h"
#include "asm/uaccess.h"
#include "user_util.h"
@@ -483,7 +484,7 @@ int mconsole_init(void)
}
if(notify_socket != NULL){
- notify_socket = uml_strdup(notify_socket);
+ notify_socket = kstrdup(notify_socket, GFP_KERNEL);
if(notify_socket != NULL)
mconsole_notify(notify_socket, MCONSOLE_SOCKET,
mconsole_socket_name,
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/drivers/net_kern.c linux-2.6.11-rc2-bk9/arch/um/drivers/net_kern.c
--- vanilla-2.6.11-rc2-bk9/arch/um/drivers/net_kern.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/drivers/net_kern.c 2005-01-31 20:39:08.589154377 +0000
@@ -20,6 +20,7 @@
#include "linux/ctype.h"
#include "linux/bootmem.h"
#include "linux/ethtool.h"
+#include "linux/string.h"
#include "asm/uaccess.h"
#include "user_util.h"
#include "kern_util.h"
@@ -602,7 +603,7 @@ static int net_config(char *str)
err = eth_parse(str, &n, &str);
if(err) return(err);
- str = uml_strdup(str);
+ str = kstrdup(str, GFP_KERNEL);
if(str == NULL){
printk(KERN_ERR "net_config failed to strdup string\n");
return(-1);
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/drivers/ubd_kern.c linux-2.6.11-rc2-bk9/arch/um/drivers/ubd_kern.c
--- vanilla-2.6.11-rc2-bk9/arch/um/drivers/ubd_kern.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/drivers/ubd_kern.c 2005-01-31 20:39:08.589154377 +0000
@@ -35,6 +35,7 @@
#include "linux/blkpg.h"
#include "linux/genhd.h"
#include "linux/spinlock.h"
+#include "linux/string.h"
#include "asm/segment.h"
#include "asm/uaccess.h"
#include "asm/irq.h"
@@ -722,7 +723,7 @@ static int ubd_config(char *str)
{
int n, err;
- str = uml_strdup(str);
+ str = kstrdup(str, GFP_KERNEL);
if(str == NULL){
printk(KERN_ERR "ubd_config failed to strdup string\n");
return(1);
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/include/kern_util.h linux-2.6.11-rc2-bk9/arch/um/include/kern_util.h
--- vanilla-2.6.11-rc2-bk9/arch/um/include/kern_util.h 2004-12-24 21:34:31.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/include/kern_util.h 2005-01-31 20:40:37.752426461 +0000
@@ -85,7 +85,6 @@ extern int attach_debugger(int idle_pid,
extern void bad_segv(unsigned long address, unsigned long ip, int is_write);
extern int config_gdb(char *str);
extern int remove_gdb(void);
-extern char *uml_strdup(char *string);
extern void unprotect_kernel_mem(void);
extern void protect_kernel_mem(void);
extern void uml_cleanup(void);
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/kernel/ksyms.c linux-2.6.11-rc2-bk9/arch/um/kernel/ksyms.c
--- vanilla-2.6.11-rc2-bk9/arch/um/kernel/ksyms.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/kernel/ksyms.c 2005-01-31 20:39:08.590154201 +0000
@@ -61,7 +61,6 @@ EXPORT_SYMBOL(strncpy_from_user_skas);
EXPORT_SYMBOL(copy_to_user_skas);
EXPORT_SYMBOL(copy_from_user_skas);
#endif
-EXPORT_SYMBOL(uml_strdup);
EXPORT_SYMBOL(os_stat_fd);
EXPORT_SYMBOL(os_stat_file);
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/kernel/process_kern.c linux-2.6.11-rc2-bk9/arch/um/kernel/process_kern.c
--- vanilla-2.6.11-rc2-bk9/arch/um/kernel/process_kern.c 2005-01-31 20:05:17.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/kernel/process_kern.c 2005-01-31 20:39:08.590154201 +0000
@@ -353,16 +353,6 @@ void do_uml_exitcalls(void)
(*call)();
}
-char *uml_strdup(char *string)
-{
- char *new;
-
- new = kmalloc(strlen(string) + 1, GFP_KERNEL);
- if(new == NULL) return(NULL);
- strcpy(new, string);
- return(new);
-}
-
void *get_init_task(void)
{
return(&init_thread_union.thread_info.task);
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/kernel/tempfile.c linux-2.6.11-rc2-bk9/arch/um/kernel/tempfile.c
--- vanilla-2.6.11-rc2-bk9/arch/um/kernel/tempfile.c 2004-12-24 21:34:58.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/kernel/tempfile.c 2005-01-31 20:39:08.590154201 +0000
@@ -9,6 +9,7 @@
#include <string.h>
#include <errno.h>
#include <sys/param.h>
+#include <linux/string.h>
#include "init.h"
/* Modified from create_mem_file and start_debugger */
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/kernel/tt/gdb.c linux-2.6.11-rc2-bk9/arch/um/kernel/tt/gdb.c
--- vanilla-2.6.11-rc2-bk9/arch/um/kernel/tt/gdb.c 2005-01-31 20:05:18.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/kernel/tt/gdb.c 2005-01-31 20:39:08.591154025 +0000
@@ -10,6 +10,7 @@
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/types.h>
+#include <linux/string.h>
#include "uml-config.h"
#include "kern_constants.h"
#include "chan_user.h"
@@ -200,7 +201,7 @@ int attach_debugger(int idle_pid, int pi
#ifdef notdef /* Put this back in when it does something useful */
static int __init uml_gdb_init_setup(char *line, int *add)
{
- gdb_init = uml_strdup(line);
+ gdb_init = kstrdup(line, GFP_KERNEL);
return 0;
}
diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c
--- vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2004-12-24 21:35:40.000000000 +0000
+++ linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2005-01-31 20:39:08.591154025 +0000
@@ -15,6 +15,7 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/if_tun.h>
+#include <linux/string.h>
#include "net_user.h"
#include "tuntap.h"
#include "kern_util.h"
@@ -175,7 +176,7 @@ static int tuntap_open(void *data)
return(err);
}
- pri->dev_name = uml_strdup(buffer);
+ pri->dev_name = kstrdup(buffer);
output += IFNAMSIZ;
printk("%s", output);
free_output_buffer(buffer);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2.6] 4/7 replace uml_strdup by kstrdup
2005-02-01 3:28 [PATCH 2.6] 4/7 replace uml_strdup by kstrdup pmarques
@ 2005-02-02 7:52 ` Pekka Enberg
2005-02-02 11:55 ` Paulo Marques
0 siblings, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2005-02-02 7:52 UTC (permalink / raw)
To: pmarques@grupopie.com
Cc: Andrew Morton, linux-kernel, user-mode-linux-devel, penberg
On Tue, 1 Feb 2005 03:28:31 +0000, pmarques@grupopie.com
<pmarques@grupopie.com> wrote:
> diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c
> --- vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2004-12-24 21:35:40.000000000 +0000
> +++ linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2005-01-31 20:39:08.591154025 +0000
[snip]
> - pri->dev_name = uml_strdup(buffer);
> + pri->dev_name = kstrdup(buffer);
Please compile-test before submitting.
Pekka
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2.6] 4/7 replace uml_strdup by kstrdup
2005-02-02 7:52 ` Pekka Enberg
@ 2005-02-02 11:55 ` Paulo Marques
2005-02-03 19:51 ` [uml-devel] " Blaisorblade
0 siblings, 1 reply; 5+ messages in thread
From: Paulo Marques @ 2005-02-02 11:55 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Andrew Morton, linux-kernel, user-mode-linux-devel, penberg
Pekka Enberg wrote:
> On Tue, 1 Feb 2005 03:28:31 +0000, pmarques@grupopie.com
> <pmarques@grupopie.com> wrote:
>
>>diff -buprN -X dontdiff vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c
>>--- vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2004-12-24 21:35:40.000000000 +0000
>>+++ linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2005-01-31 20:39:08.591154025 +0000
>
>
> [snip]
>
>
>>- pri->dev_name = uml_strdup(buffer);
>>+ pri->dev_name = kstrdup(buffer);
>
>
> Please compile-test before submitting.
I'm really sorry about this...
I've compiled with an allyesconfig to validate the changes, but that
doesn't build the UML parts :(
Anyway, thanks for pointing this out. I still haven't got feedback
regarding the acceptance of these patches. If there is a chance they're
accepted, maybe the best thing to do is to post the series again with
this correction and the sound patch corrections.
--
Paulo Marques - www.grupopie.com
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [uml-devel] Re: [PATCH 2.6] 4/7 replace uml_strdup by kstrdup
2005-02-02 11:55 ` Paulo Marques
@ 2005-02-03 19:51 ` Blaisorblade
2005-02-04 12:45 ` Paulo Marques
0 siblings, 1 reply; 5+ messages in thread
From: Blaisorblade @ 2005-02-03 19:51 UTC (permalink / raw)
To: user-mode-linux-devel
Cc: Paulo Marques, Pekka Enberg, Andrew Morton, linux-kernel, penberg
On Wednesday 02 February 2005 12:55, you wrote:
> Pekka Enberg wrote:
> > On Tue, 1 Feb 2005 03:28:31 +0000, pmarques@grupopie.com
> >
> > <pmarques@grupopie.com> wrote:
> >>diff -buprN -X dontdiff
> >> vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c
> >> linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c ---
> >> vanilla-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c
> >> 2004-12-24 21:35:40.000000000 +0000 +++
> >> linux-2.6.11-rc2-bk9/arch/um/os-Linux/drivers/tuntap_user.c 2005-01-31
> >> 20:39:08.591154025 +0000
> >
> > [snip]
> >
> >>- pri->dev_name = uml_strdup(buffer);
> >>+ pri->dev_name = kstrdup(buffer);
> >
> > Please compile-test before submitting.
>
> I'm really sorry about this...
>
> I've compiled with an allyesconfig to validate the changes, but that
> doesn't build the UML parts :(
Well, the answer is to do add a "ARCH=um" to the build commands... you could
maybe use a "make defconfig ARCH=um" however because UML itself, sometimes,
does not build with allyesconfig /allmodconfig...
However, that said, there are bigger problems for UML.
Since of its particular nature, it contains some code which is compiled
against userspace headers. For instance cow_user.c (the list includes
*_user.c and everything that is explicitly listed in USER_OBJS inside the
Makefiles)
So, for cow_user.c, when you add <linux/string.h> to cow_user.c, you are
actually making it include /usr/include/linux/string.h...
For UML, you should probably add the prototype to a good header inside
arch/um/include (those headers are in the searchpath for every file under
arch/um) - probably the one which declared uml_strdup. Yes, we have had to
duplicate prototypes for many functions... for inlines, we've had to provide
in many case a non-inline version.
> Anyway, thanks for pointing this out. I still haven't got feedback
> regarding the acceptance of these patches. If there is a chance they're
> accepted, maybe the best thing to do is to post the series again with
> this correction and the sound patch corrections.
--
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [uml-devel] Re: [PATCH 2.6] 4/7 replace uml_strdup by kstrdup
2005-02-03 19:51 ` [uml-devel] " Blaisorblade
@ 2005-02-04 12:45 ` Paulo Marques
0 siblings, 0 replies; 5+ messages in thread
From: Paulo Marques @ 2005-02-04 12:45 UTC (permalink / raw)
To: Blaisorblade
Cc: user-mode-linux-devel, Pekka Enberg, Andrew Morton, linux-kernel,
penberg
Blaisorblade wrote:
>[...]
> For UML, you should probably add the prototype to a good header inside
> arch/um/include (those headers are in the searchpath for every file under
> arch/um) - probably the one which declared uml_strdup. Yes, we have had to
> duplicate prototypes for many functions... for inlines, we've had to provide
> in many case a non-inline version.
Thanks for the tip. I'll have to read the code more carefully to
understand better where the userspace ends and the kernel begins, so
that I don't do similar mistakes in the future.
I'll redo the patch and post it for review, probably during next week. I
don't think there is much hurry, because, even if this gets accepted, it
should go in only in 2.6.12-rc1-mm1 or something like that, so there is
still time to review this more carefully.
Thanks for reviewing the patch,
--
Paulo Marques - www.grupopie.com
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-02-04 12:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-01 3:28 [PATCH 2.6] 4/7 replace uml_strdup by kstrdup pmarques
2005-02-02 7:52 ` Pekka Enberg
2005-02-02 11:55 ` Paulo Marques
2005-02-03 19:51 ` [uml-devel] " Blaisorblade
2005-02-04 12:45 ` Paulo Marques
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox