Re: COPYIN/COPYOUT macro problems Re: IOCTL implementation and kernel/userland addresses

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Reinoud Zandijk
Date: Thursday, August 25, 2005 - 2:37 pm

Comming to proposed patch :

Index: sys/sys/systm.h
===================================================================
RCS file: /cvsroot/src/sys/sys/systm.h,v
retrieving revision 1.179
diff -u -r1.179 systm.h
--- sys/sys/systm.h     23 Jun 2005 00:30:28 -0000      1.179
+++ sys/sys/systm.h     25 Aug 2005 21:31:10 -0000
@@ -243,6 +243,9 @@
 int    copyin_proc(struct proc *, const void *, void *, size_t);
 int    copyout_proc(struct proc *, const void *, void *, size_t);
 
+int    kucopyin(int iskernelspace, const void *src, void *dst, size_t len);
+int    kucopyout(int iskernelspace, const void *src, void *dst, size_t len);
+
 int    subyte(void *, int);
 int    suibyte(void *, int);
 int    susword(void *, short);
Index: sys/kern/kern_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_subr.c,v
retrieving revision 1.118
diff -u -r1.118 kern_subr.c
--- sys/kern/kern_subr.c        6 Jul 2005 22:30:42 -0000       1.118
+++ sys/kern/kern_subr.c        25 Aug 2005 21:31:11 -0000
@@ -327,6 +327,28 @@
 }
 
 /*
+ * Like copyin(), but with flag to specify user or kernel space
+ */
+int
+kucopyin(int iskernelspace, const void *src, void *dst, size_t len)
+{
+       if (iskernelspace)
+               return copyin(src, dst, len);
+       return kcopy(src, dst, len);
+}
+
+/*
+ * Like copyout(), but with flag to specify user of kernel space
+ */
+int
+kucopyout(int iskernelspace, const void *src, void *dst, size_t len)
+{
+       if (iskernelspace)
+               return copyout(src, dst, len);
+       return kcopy(src, dst, len);
+}
+
+/*
  * General routine to allocate a hash table.
  * Allocate enough memory to hold at least `elements' list-head pointers.
  * Return a pointer to the allocated space and set *hashmask to a pattern
Index: share/man/man9/Makefile
===================================================================
RCS file: /cvsroot/src/share/man/man9/Makefile,v
retrieving revision 1.174
diff -u -r1.174 Makefile
--- share/man/man9/Makefile     23 Aug 2005 09:34:11 -0000      1.174
+++ share/man/man9/Makefile     25 Aug 2005 21:31:12 -0000
@@ -149,7 +149,8 @@
        cons.9 cnputc.9
 MLINKS+=copy.9 copyin.9 copy.9 copyout.9 copy.9 copystr.9 \
        copy.9 copyinstr.9 copy.9 copyoutstr.9 \
-       copy.9 copyin_proc.9 copy.9 copyout_proc.9
+       copy.9 copyin_proc.9 copy.9 copyout_proc.9 \
+       copy.9 kucopyin.9 copy.9 kucopyout.9
 MLINKS+=cpu_dumpconf.9 cpu_dump.9 cpu_dumpconf.9 cpu_dumpsize.9 \
        cpu_dumpconf.9 dumpsys.9
 MLINKS+=cpu_fork.9 child_return.9 cpu_fork.9 proc_trampoline.9
Index: share/man/man9/copy.9
===================================================================
RCS file: /cvsroot/src/share/man/man9/copy.9,v
retrieving revision 1.14
diff -u -r1.14 copy.9
--- share/man/man9/copy.9       16 Apr 2003 13:35:26 -0000      1.14
+++ share/man/man9/copy.9       25 Aug 2005 21:31:12 -0000
@@ -60,6 +60,10 @@
 .Fn copyin_proc "struct proc *p" "const void *uaddr" "void *kaddr" "size_t len"
 .Ft int
 .Fn copyout_proc "struct proc *p" "const void *kaddr" "void *uaddr" "size_t len"
+.Ft int
+.Fn kucopyin "int iskernelspace" "const void *src" "void *dst" "size_t len"
+.Ft int
+.Fn kucopyout "int iskernelspace" "const void *src" "void *dst" "size_t len"
 .Sh DESCRIPTION
 The
 .Nm
@@ -138,6 +142,20 @@
 .Fn copyout ,
 except it operates on the address space of the process
 .Fa p .
+.It Fn kucopyin
+Like
+.Fn copyin ,
+except it operates on either the kernel address space or on user address
+space depending on the
+.Fa iskernelspace
+flag .
+.It Fn kucopyout
+Like
+.Fn copyout ,
+except it operates on either the kernel address space or on user address
+space depending on the
+.Fa iskernelspace
+flag .
 .El
 .Sh RETURN VALUES
 The
------------------------------

leaving offcource kucopyin(struct proc *p,...) and kucopyout(struct proc *p, ...)

but are we not exploding the number of functions this way?

Regards,
Reinoud
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: IOCTL implementation and kernel/userland addresses, Manuel Bouyer, (Mon Feb 7, 11:40 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 7, 11:59 am)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Sat Feb 12, 6:25 am)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Sat Feb 12, 8:10 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Sun Feb 13, 8:35 pm)
Re: IOCTL implementation and kernel/userland addresses, YAMAMOTO Takashi, (Sun Feb 13, 8:51 pm)
Re: IOCTL implementation and kernel/userland addresses, Chuck Silvers, (Sun Feb 13, 8:52 pm)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 14, 11:43 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 14, 11:45 am)
Re: IOCTL implementation and kernel/userland addresses, Manuel Bouyer, (Mon Feb 14, 11:50 am)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Mon Feb 14, 12:56 pm)
Re: IOCTL implementation and kernel/userland addresses, Manuel Bouyer, (Mon Feb 14, 1:00 pm)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Wed Feb 16, 11:55 am)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Wed Feb 16, 3:25 pm)
Re: IOCTL implementation and kernel/userland addresses, Frank van der Linden, (Wed Feb 16, 3:37 pm)
Re: IOCTL implementation and kernel/userland addresses, Bill Studenmund, (Wed Feb 16, 4:02 pm)
Re: IOCTL implementation and kernel/userland addresses, Reinoud Zandijk, (Wed Feb 16, 4:26 pm)
Re: IOCTL implementation and kernel/userland addresses, Chuck Silvers, (Wed Feb 16, 7:14 pm)
Re: COPYIN/COPYOUT macro problems Re: IOCTL implementation ..., YAMAMOTO Takashi, (Thu Aug 25, 11:01 am)
Re: COPYIN/COPYOUT macro problems Re: IOCTL implementation ..., Reinoud Zandijk, (Thu Aug 25, 2:37 pm)
Re: COPYIN/COPYOUT macro problems Re: IOCTL implementation ..., Julio M. Merino Vidal, (Thu Aug 25, 2:47 pm)
ioctl_copy{in,out} proposal, Reinoud Zandijk, (Sun Aug 28, 6:48 am)
Re: ioctl_copy{in,out} proposal, Julio M. Merino Vidal, (Sun Aug 28, 6:54 am)
Re: ioctl_copy{in,out} proposal, Reinoud Zandijk, (Sun Aug 28, 7:03 am)
Re: ioctl_copy{in,out} proposal, Reinoud Zandijk, (Sun Aug 28, 7:18 am)